* [PATCH v3 0/2] AMLogic Meson SoC RTC driver @ 2016-07-05 19:48 Ben Dooks [not found] ` <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 0 siblings, 1 reply; 11+ messages in thread From: Ben Dooks @ 2016-07-05 19:48 UTC (permalink / raw) To: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w, Ben Dooks This series adds support for the on SoC RTC driver on the AMLogic Meson devices. The device-tree updates are not included as they depend on the reset-controller support in -next. The series does not have any build dependencies, but does require the reset controller and device-tree entries for the relevant boards and has been tested on the ODroid-C1 board. Thanks to Kevin Hilmand and Neil Armstrong for reviewing the driver. Changes since V1: <1467039135-26588-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> - Fixed checkpatch and sparse errors - Fixed minor locking bug when writing static-control register - Updated the code ordering in the rtc-meson.c driver - Fixed alphanumeric ordering in on-cpu rtc block - Added Rob Hering's ack for the DT binding documentation - Added better description to the RTC driver header. Ben Dooks (2): rtc: support for amlogic meson rtc meson-rtc: add device-tree binding .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 ++ drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-meson.c | 349 +++++++++++++++++++++ 6 files changed, 392 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt create mode 100644 drivers/rtc/rtc-meson.c -- 2.8.1 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>]
* [PATCH v3 0/2] AMLogic Meson SoC RTC driver [not found] ` <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> @ 2016-07-05 19:48 ` Ben Dooks 2016-07-05 19:48 ` [PATCH v3 1/4] rtc: support for amlogic meson rtc Ben Dooks 2016-07-05 19:48 ` [PATCH v3 2/4] meson-rtc: add device-tree binding Ben Dooks 2 siblings, 0 replies; 11+ messages in thread From: Ben Dooks @ 2016-07-05 19:48 UTC (permalink / raw) To: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w, Ben Dooks This series adds support for the on SoC RTC driver on the AMLogic Meson devices. The device-tree updates are not included as they depend on the reset-controller support in -next. The series does not have any build dependencies, but does require the reset controller and device-tree entries for the relevant boards and has been tested on the ODroid-C1 board. Changes since V1: <1467039135-26588-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> - Fixed checkpatch and sparse errors - Fixed minor locking bug when writing static-control register - Updated the code ordering in the rtc-meson.c driver - Fixed alphanumeric ordering in on-cpu rtc block - Added Rob Hering's ack for the DT binding documentation - Added better description to the RTC driver header. Ben Dooks (2): rtc: support for amlogic meson rtc meson-rtc: add device-tree binding .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 ++ drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-meson.c | 349 +++++++++++++++++++++ 6 files changed, 392 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt create mode 100644 drivers/rtc/rtc-meson.c -- 2.8.1 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 1/4] rtc: support for amlogic meson rtc [not found] ` <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-05 19:48 ` Ben Dooks @ 2016-07-05 19:48 ` Ben Dooks [not found] ` <1467748122-14833-3-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-05 19:48 ` [PATCH v3 2/4] meson-rtc: add device-tree binding Ben Dooks 2 siblings, 1 reply; 11+ messages in thread From: Ben Dooks @ 2016-07-05 19:48 UTC (permalink / raw) To: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w, Ben Dooks Add support for the AMLogic meson8b/meson6 RTC block. Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> --- V3..V1: - Fixed alpha-ordering in Kconfig - Fixed checkpatch errors - Added basic driver information - Re-organised static-register access functions above rtc driver layer Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> --- drivers/rtc/Kconfig | 9 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-meson.c | 349 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 359 insertions(+) create mode 100644 drivers/rtc/rtc-meson.c diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 18639e0..6f4097e 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1181,6 +1181,15 @@ config RTC_DRV_ASM9260 This driver can also be built as a module. If so, the module will be called rtc-asm9260. +config RTC_DRV_MESON + tristate "AMLogic Meson Real Time Clock" + depends on ARCH_MESON || COMPILE_TEST + help + Support for AMLogic Meson RTC block. + + This driver can also be built as a module, if so, the module + will be called "rtc-meson". + config RTC_DRV_DAVINCI tristate "TI DaVinci RTC" depends on ARCH_DAVINCI_DM365 || COMPILE_TEST diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index ea28337..0b4f106 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -92,6 +92,7 @@ obj-$(CONFIG_RTC_DRV_MAX8997) += rtc-max8997.o obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o obj-$(CONFIG_RTC_DRV_MCP795) += rtc-mcp795.o +obj-$(CONFIG_RTC_DRV_MESON) += rtc-meson.o obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o diff --git a/drivers/rtc/rtc-meson.c b/drivers/rtc/rtc-meson.c new file mode 100644 index 0000000..b40b0c9 --- /dev/null +++ b/drivers/rtc/rtc-meson.c @@ -0,0 +1,349 @@ +/* drivers/rtc/rtc-meson.c + * + * RTC driver for the interal RTC block in the AMlogic SoCs. + * + * The RTC is split in to two parts, the AHB front end and a simple serial + * connection to the actual registers. This driver manages both parts. + * + * Copyright (c) 2015 Codethink Ltd + * Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> + * Based on origin by Carlo Caione <carlo-6IF/jdPJHihWk0Htik3J/w@public.gmane.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/reset.h> +#include <linux/rtc.h> +#include <linux/io.h> +#include <linux/of.h> + +/* registers accessed from cpu bus */ +#define RTC_REG(x) ((x) * 4) /* rtc registers 0-4 */ + +#define LINE_SDI (1 << 2) +#define LINE_SEN (1 << 1) +#define LINE_SCLK (1 << 0) + +#define RTCREG0_START_SER BIT(17) +#define RTCREG0_WAIT_SER BIT(22) +#define RTC_REG0_DATA(__data) ((__data) << 24) + +#define RTCREG1_READY BIT(1) + +/* rtc registers accessed via rtc-serial interface */ +#define RTC_COUNTER (0) +#define RTC_SEC_ADJ (2) + +#define RTC_ADDR_BITS (3) /* number of address bits to send */ +#define RTC_DATA_BITS (32) /* number of data bits to tx/rx */ + +#define MESON_STATIC_BIAS_CUR (0x5 << 1) +#define MESON_STATIC_VOLTAGE (0x3 << 11) +#define MESON_STATIC_DEFAULT (MESON_STATIC_BIAS_CUR | MESON_STATIC_VOLTAGE) + +struct meson_rtc { + struct rtc_device *rtc; /* rtc device we created */ + struct device *dev; /* device we bound from */ + struct reset_control *reset; /* reset source */ + struct mutex lock; /* rtc lock */ + void __iomem *regs; /* rtc register access */ +}; + +/* RTC front-end serialiser controls */ + +static void meson_rtc_setline(struct meson_rtc *rtc, + unsigned int bit, unsigned int to) +{ + u32 reg0; + + reg0 = readl(rtc->regs + RTC_REG(0)); + if (to) + reg0 |= bit; + else + reg0 &= ~bit; + writel(reg0, rtc->regs + RTC_REG(0)); +} + +static void meson_rtc_sclk_pulse(struct meson_rtc *rtc) +{ + udelay(5); + meson_rtc_setline(rtc, LINE_SCLK, 0); + udelay(5); + meson_rtc_setline(rtc, LINE_SCLK, 1); +} + +static void meson_rtc_send_bit(struct meson_rtc *rtc, unsigned int bit) +{ + meson_rtc_setline(rtc, LINE_SDI, bit ? 1 : 0); + meson_rtc_sclk_pulse(rtc); +} + +static void meson_rtc_send_bits(struct meson_rtc *rtc, + u32 data, unsigned int nr) +{ + u32 bit = 1 << (nr - 1); + + while (bit) { + meson_rtc_send_bit(rtc, data & bit); + bit >>= 1; + } +} + +static void meson_rtc_set_dir(struct meson_rtc *rtc, u32 mode) +{ + meson_rtc_setline(rtc, LINE_SEN, 0); + meson_rtc_setline(rtc, LINE_SDI, 0); + meson_rtc_send_bit(rtc, mode); + meson_rtc_setline(rtc, LINE_SDI, 0); +} + +static u32 meson_rtc_read_sdo(struct meson_rtc *rtc) +{ + return readl(rtc->regs + RTC_REG(1)) & BIT(0); +} + +static u32 meson_rtc_get_data(struct meson_rtc *rtc) +{ + u32 val = 0; + int bit; + + for (bit = 0; bit < RTC_DATA_BITS; bit++) { + meson_rtc_sclk_pulse(rtc); + val <<= 1; + val |= meson_rtc_read_sdo(rtc); + } + + return val; +} + +static int meson_rtc_wait_bus(struct meson_rtc *rtc, unsigned int timeout_ms) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms); + u32 val; + + while (time_before(jiffies, timeout)) { + val = readl(rtc->regs + RTC_REG(1)); + if (val & RTCREG1_READY) + return 1; + + dev_dbg(rtc->dev, "%s: reg0=%08x reg1=%08x\n", + __func__, readl(rtc->regs + RTC_REG(0)), val); + msleep(10); + } + + return 0; +} + +static int meson_rtc_get_bus(struct meson_rtc *rtc) +{ + int ret, retries = 3; + u32 val; + + /* prepare bus for transfers, set all lines low */ + val = readl(rtc->regs + RTC_REG(0)); + val &= ~(LINE_SDI | LINE_SEN | LINE_SCLK); + writel(val, rtc->regs + RTC_REG(0)); + + while (retries) { + if (meson_rtc_wait_bus(rtc, 300)) + return 0; + + dev_warn(rtc->dev, "failed to get bus, re-setting\n"); + + retries--; + ret = reset_control_reset(rtc->reset); + if (ret) + return ret; + } + + dev_err(rtc->dev, "%s: bus is not ready\n", __func__); + return -ETIMEDOUT; +} + +static int meson_rtc_read(struct meson_rtc *rtc, unsigned int reg, u32 *data) +{ + int ret; + + ret = meson_rtc_get_bus(rtc); + if (ret) + return ret; + + meson_rtc_setline(rtc, LINE_SEN, 1); + meson_rtc_send_bits(rtc, reg, RTC_ADDR_BITS); + meson_rtc_set_dir(rtc, 0); + *data = meson_rtc_get_data(rtc); + + return 0; +} + +static int meson_rtc_write(struct meson_rtc *rtc, unsigned int reg, u32 data) +{ + int ret; + + dev_dbg(rtc->dev, "%s: reg %d val %08x)\n", __func__, reg, data); + + ret = meson_rtc_get_bus(rtc); + if (ret) + return ret; + + meson_rtc_setline(rtc, LINE_SEN, 1); + meson_rtc_send_bits(rtc, data, RTC_DATA_BITS); + meson_rtc_send_bits(rtc, reg, RTC_ADDR_BITS); + meson_rtc_set_dir(rtc, 1); + + return 0; +} + +static int meson_rtc_wait_serialiser(struct meson_rtc *rtc) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(100); + + while (time_before(jiffies, timeout)) { + if (!(readl(rtc->regs + RTC_REG(0)) & RTCREG0_WAIT_SER)) + return 0; + msleep(10); + } + + return -ETIMEDOUT; +} + +static int meson_rtc_write_static(struct meson_rtc *rtc, u32 data) +{ + u32 tmp; + int ret = 0; + + mutex_lock(&rtc->lock); + + writel(data >> 8, rtc->regs + RTC_REG(4)); + + tmp = readl(rtc->regs + RTC_REG(0)); + tmp &= ~RTC_REG0_DATA(0xff); + tmp |= RTC_REG0_DATA(data); + tmp |= RTCREG0_START_SER; + writel(tmp, rtc->regs + RTC_REG(0)); + + if (meson_rtc_wait_serialiser(rtc)) + ret = -ETIMEDOUT; + + dev_dbg(rtc->dev, "%s: ret=%d, rtc_reg0 = %08x\n", + __func__, ret, readl(rtc->regs + RTC_REG(0))); + mutex_unlock(&rtc->lock); + + return ret; +} + +/* RTC interface layer functions */ + +static int meson_rtc_gettime(struct device *dev, struct rtc_time *tm) +{ + struct meson_rtc *rtc = dev_get_drvdata(dev); + int ret; + u32 time; + + mutex_lock(&rtc->lock); + + ret = meson_rtc_read(rtc, RTC_COUNTER, &time); + if (!ret) { + rtc_time_to_tm(time, tm); + dev_dbg(dev, "read time %lu\n", (unsigned long)time); + } + + mutex_unlock(&rtc->lock); + return ret; +} + +static int meson_rtc_settime(struct device *dev, struct rtc_time *tm) +{ + struct meson_rtc *rtc = dev_get_drvdata(dev); + unsigned long time; + int ret; + + mutex_lock(&rtc->lock); + + rtc_tm_to_time(tm, &time); + ret = meson_rtc_write(rtc, RTC_COUNTER, time); + + mutex_unlock(&rtc->lock); + return ret; +} + +static const struct rtc_class_ops meson_rtc_ops = { + .read_time = meson_rtc_gettime, + .set_time = meson_rtc_settime, +}; + +static int meson_rtc_probe(struct platform_device *pdev) +{ + struct meson_rtc *rtc; + struct device *dev = &pdev->dev; + struct resource *res; + u32 tm; + int ret; + + rtc = devm_kzalloc(dev, sizeof(struct meson_rtc), GFP_KERNEL); + if (!rtc) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + rtc->regs = devm_ioremap_resource(dev, res); + rtc->dev = dev; + + if (IS_ERR(rtc->regs)) + return PTR_ERR(rtc->regs); + + mutex_init(&rtc->lock); + platform_set_drvdata(pdev, rtc); + + ret = meson_rtc_write_static(rtc, MESON_STATIC_DEFAULT); + if (ret) { + dev_err(dev, "failed to set static values\n"); + return ret; + } + + rtc->reset = devm_reset_control_get(dev, NULL); + if (IS_ERR(rtc->reset)) + dev_warn(dev, "no reset available, rtc may not work\n"); + + /* check if we can read RTC counter, if not then the RTC is probably + * not functional. If it isn't probably best to not bind. + */ + ret = meson_rtc_read(rtc, RTC_COUNTER, &tm); + if (ret) { + dev_err(dev, "cannot read RTC counter, RTC not functional\n"); + return ret; + } + + rtc->rtc = devm_rtc_device_register(dev, "meson", + &meson_rtc_ops, THIS_MODULE); + if (IS_ERR(rtc->rtc)) + return PTR_ERR(rtc->rtc); + + return 0; +} + +static const struct of_device_id meson_rtc_dt_match[] = { + { .compatible = "amlogic,meson6-rtc", }, + { .compatible = "amlogic,meson8-rtc", }, + { .compatible = "amlogic,meson8b-rtc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, meson_rtc_dt_match); + +static struct platform_driver meson_rtc_driver = { + .probe = meson_rtc_probe, + .driver = { + .name = "meson-rtc", + .of_match_table = of_match_ptr(meson_rtc_dt_match), + }, +}; +module_platform_driver(meson_rtc_driver); + +MODULE_DESCRIPTION("AMLogic MESON RTC Driver"); +MODULE_AUTHOR("Ben Dooks <ben.doosk-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:meson-rtc"); -- 2.8.1 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply related [flat|nested] 11+ messages in thread
[parent not found: <1467748122-14833-3-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>]
* Re: [PATCH v3 1/4] rtc: support for amlogic meson rtc [not found] ` <1467748122-14833-3-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> @ 2016-07-08 16:16 ` Kevin Hilman 2016-07-12 17:22 ` Alexandre Belloni 1 sibling, 0 replies; 11+ messages in thread From: Kevin Hilman @ 2016-07-08 16:16 UTC (permalink / raw) To: Ben Dooks Cc: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> writes: > Add support for the AMLogic meson8b/meson6 RTC block. > > Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> Tested-by: Kevin Hilman <khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org> -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/4] rtc: support for amlogic meson rtc [not found] ` <1467748122-14833-3-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-08 16:16 ` Kevin Hilman @ 2016-07-12 17:22 ` Alexandre Belloni [not found] ` <20160712172235.GU22202-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org> 1 sibling, 1 reply; 11+ messages in thread From: Alexandre Belloni @ 2016-07-12 17:22 UTC (permalink / raw) To: Ben Dooks Cc: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w Hi, Very few comments below On 05/07/2016 at 20:48:41 +0100, Ben Dooks wrote : > +/* registers accessed from cpu bus */ > +#define RTC_REG(x) ((x) * 4) /* rtc registers 0-4 */ > + > +#define LINE_SDI (1 << 2) > +#define LINE_SEN (1 << 1) > +#define LINE_SCLK (1 << 0) > + Maybe use BIT() here. > +/* RTC interface layer functions */ > + > +static int meson_rtc_gettime(struct device *dev, struct rtc_time *tm) > +{ > + struct meson_rtc *rtc = dev_get_drvdata(dev); > + int ret; > + u32 time; > + > + mutex_lock(&rtc->lock); > + > + ret = meson_rtc_read(rtc, RTC_COUNTER, &time); > + if (!ret) { > + rtc_time_to_tm(time, tm); Can you use the 64bit version? > + dev_dbg(dev, "read time %lu\n", (unsigned long)time); > + } > + > + mutex_unlock(&rtc->lock); > + return ret; > +} > + > +static int meson_rtc_settime(struct device *dev, struct rtc_time *tm) > +{ > + struct meson_rtc *rtc = dev_get_drvdata(dev); > + unsigned long time; > + int ret; > + > + mutex_lock(&rtc->lock); > + > + rtc_tm_to_time(tm, &time); Ditto. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <20160712172235.GU22202-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>]
* Re: [PATCH v3 1/4] rtc: support for amlogic meson rtc [not found] ` <20160712172235.GU22202-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org> @ 2016-07-12 17:27 ` Ben Dooks [not found] ` <4d98df06-cf00-b4fd-dfb5-1ac5d9c548fc-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 0 siblings, 1 reply; 11+ messages in thread From: Ben Dooks @ 2016-07-12 17:27 UTC (permalink / raw) To: Alexandre Belloni Cc: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w On 12/07/16 18:22, Alexandre Belloni wrote: > Hi, > > Very few comments below > > On 05/07/2016 at 20:48:41 +0100, Ben Dooks wrote : >> +/* registers accessed from cpu bus */ >> +#define RTC_REG(x) ((x) * 4) /* rtc registers 0-4 */ >> + >> +#define LINE_SDI (1 << 2) >> +#define LINE_SEN (1 << 1) >> +#define LINE_SCLK (1 << 0) > > Maybe use BIT() here. I'll sort that out later. >> +/* RTC interface layer functions */ >> + >> +static int meson_rtc_gettime(struct device *dev, struct rtc_time *tm) >> +{ >> + struct meson_rtc *rtc = dev_get_drvdata(dev); >> + int ret; >> + u32 time; >> + >> + mutex_lock(&rtc->lock); >> + >> + ret = meson_rtc_read(rtc, RTC_COUNTER, &time); >> + if (!ret) { >> + rtc_time_to_tm(time, tm); > > Can you use the 64bit version? What would the 64bit version gain? The hardware register is 32bit. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <4d98df06-cf00-b4fd-dfb5-1ac5d9c548fc-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>]
* Re: [PATCH v3 1/4] rtc: support for amlogic meson rtc [not found] ` <4d98df06-cf00-b4fd-dfb5-1ac5d9c548fc-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> @ 2016-07-12 17:37 ` Alexandre Belloni 0 siblings, 0 replies; 11+ messages in thread From: Alexandre Belloni @ 2016-07-12 17:37 UTC (permalink / raw) To: Ben Dooks Cc: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w On 12/07/2016 at 18:27:12 +0100, Ben Dooks wrote : > On 12/07/16 18:22, Alexandre Belloni wrote: > > Hi, > > > > Very few comments below > > > > On 05/07/2016 at 20:48:41 +0100, Ben Dooks wrote : > >> +/* registers accessed from cpu bus */ > >> +#define RTC_REG(x) ((x) * 4) /* rtc registers 0-4 */ > >> + > >> +#define LINE_SDI (1 << 2) > >> +#define LINE_SEN (1 << 1) > >> +#define LINE_SCLK (1 << 0) > > > > Maybe use BIT() here. > > I'll sort that out later. > > >> +/* RTC interface layer functions */ > >> + > >> +static int meson_rtc_gettime(struct device *dev, struct rtc_time *tm) > >> +{ > >> + struct meson_rtc *rtc = dev_get_drvdata(dev); > >> + int ret; > >> + u32 time; > >> + > >> + mutex_lock(&rtc->lock); > >> + > >> + ret = meson_rtc_read(rtc, RTC_COUNTER, &time); > >> + if (!ret) { > >> + rtc_time_to_tm(time, tm); > > > > Can you use the 64bit version? > > What would the 64bit version gain? The hardware register is 32bit. > Well, at some point, I'll remove the 32bit version: http://lxr.free-electrons.com/source/include/linux/rtc.h#L36 -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 2/4] meson-rtc: add device-tree binding [not found] ` <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-05 19:48 ` Ben Dooks 2016-07-05 19:48 ` [PATCH v3 1/4] rtc: support for amlogic meson rtc Ben Dooks @ 2016-07-05 19:48 ` Ben Dooks [not found] ` <1467748122-14833-4-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2 siblings, 1 reply; 11+ messages in thread From: Ben Dooks @ 2016-07-05 19:48 UTC (permalink / raw) To: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, frowand.list-Re5JQEeQqe8AvxtiuMwx3w, khilman-rdvid1DuHRBWk0Htik3J/w, Ben Dooks Add documentation for the AMLogic Meson RTC. Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt diff --git a/Documentation/devicetree/bindings/rtc/rtc-amlogic.txt b/Documentation/devicetree/bindings/rtc/rtc-amlogic.txt new file mode 100644 index 0000000..efc7672 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/rtc-amlogic.txt @@ -0,0 +1,21 @@ +* AMlogic Meson RTC + +Required properties: +- compatible: should be one of the following describing the hardware: + * "amlogic,meson6-rtc" + * "amlogic,meson8-rtc" + * "amlogic,meson8b-rtc" + +- reg: physical register space for the controller's memory mapped registers. + +Optional properties: +- resets: reset controller reference to allow reset of the controller +- interrupts: single interrupt reference if interrupt support needed + +Example: + + rtc: rtc@c8100740 { + compatible = "amlogic,meson6-rtc"; + reg = <0xc8100740 0x14>; + status = "disabled"; + }; -- 2.8.1 -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply related [flat|nested] 11+ messages in thread
[parent not found: <1467748122-14833-4-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>]
* Re: [PATCH v3 2/4] meson-rtc: add device-tree binding [not found] ` <1467748122-14833-4-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> @ 2016-07-13 5:57 ` Frank Rowand [not found] ` <5785D83C.2000809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 11+ messages in thread From: Frank Rowand @ 2016-07-13 5:57 UTC (permalink / raw) To: Ben Dooks, linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, khilman-rdvid1DuHRBWk0Htik3J/w On 07/05/16 12:48, Ben Dooks wrote: > Add documentation for the AMLogic Meson RTC. > > Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> > Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > --- > .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt Hi Ben, I suspect you already know this since you have Rob's ack, but you need to send bindings to Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> -Frank -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <5785D83C.2000809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3 2/4] meson-rtc: add device-tree binding [not found] ` <5785D83C.2000809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-07-13 9:09 ` Ben Dooks [not found] ` <51411c13-8cb4-3623-f70e-03b4190655f2-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 0 siblings, 1 reply; 11+ messages in thread From: Ben Dooks @ 2016-07-13 9:09 UTC (permalink / raw) To: Frank Rowand, linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw Cc: a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, khilman-rdvid1DuHRBWk0Htik3J/w, Mark Rutland On 13/07/16 06:57, Frank Rowand wrote: > On 07/05/16 12:48, Ben Dooks wrote: >> Add documentation for the AMLogic Meson RTC. >> >> Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> >> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> >> --- >> .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt > > Hi Ben, > > I suspect you already know this since you have Rob's ack, but you need to > send bindings to > > Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> Sorry, missed copying the email when sending. I hope he's seen them from being on the devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org list? I've added him as an CC: on this one to check. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <51411c13-8cb4-3623-f70e-03b4190655f2-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>]
* Re: [PATCH v3 2/4] meson-rtc: add device-tree binding [not found] ` <51411c13-8cb4-3623-f70e-03b4190655f2-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> @ 2016-07-13 11:25 ` Mark Rutland 0 siblings, 0 replies; 11+ messages in thread From: Mark Rutland @ 2016-07-13 11:25 UTC (permalink / raw) To: Ben Dooks Cc: Frank Rowand, linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, rtc-linux-/JYPxA39Uh5TLH3MbocFFw, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, devicetree-u79uwXL29TY76Z2rM5mHXA, narmstrong-rdvid1DuHRBWk0Htik3J/w, khilman-rdvid1DuHRBWk0Htik3J/w On Wed, Jul 13, 2016 at 10:09:44AM +0100, Ben Dooks wrote: > On 13/07/16 06:57, Frank Rowand wrote: > > On 07/05/16 12:48, Ben Dooks wrote: > >> Add documentation for the AMLogic Meson RTC. > >> > >> Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> > >> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > >> --- > >> .../devicetree/bindings/rtc/rtc-amlogic.txt | 21 +++++++++++++++++++++ > >> 1 file changed, 21 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt > > > > Hi Ben, > > > > I suspect you already know this since you have Rob's ack, but you need to > > send bindings to > > > > Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > > Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> > > Sorry, missed copying the email when sending. > > I hope he's seen them from being on the devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > list? I've added him as an CC: on this one to check. >From my perspective, having devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org alone is fine. I appreciate tastes vary across maintainers, either way is fine by me. :) You already have Rob's ack, which is sufficient, but FWIW the patch looks fine, so feel free to add mine: Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> Thanks, Mark. -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-07-13 11:25 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-07-05 19:48 [PATCH v3 0/2] AMLogic Meson SoC RTC driver Ben Dooks [not found] ` <1467748122-14833-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-05 19:48 ` Ben Dooks 2016-07-05 19:48 ` [PATCH v3 1/4] rtc: support for amlogic meson rtc Ben Dooks [not found] ` <1467748122-14833-3-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-08 16:16 ` Kevin Hilman 2016-07-12 17:22 ` Alexandre Belloni [not found] ` <20160712172235.GU22202-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org> 2016-07-12 17:27 ` Ben Dooks [not found] ` <4d98df06-cf00-b4fd-dfb5-1ac5d9c548fc-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-12 17:37 ` Alexandre Belloni 2016-07-05 19:48 ` [PATCH v3 2/4] meson-rtc: add device-tree binding Ben Dooks [not found] ` <1467748122-14833-4-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-13 5:57 ` Frank Rowand [not found] ` <5785D83C.2000809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2016-07-13 9:09 ` Ben Dooks [not found] ` <51411c13-8cb4-3623-f70e-03b4190655f2-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org> 2016-07-13 11:25 ` Mark Rutland
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).