* [PATCH 1/3] rtc: gemini: Add optional clock handling @ 2017-05-18 21:56 Linus Walleij 2017-05-18 21:56 ` [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday Linus Walleij ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Linus Walleij @ 2017-05-18 21:56 UTC (permalink / raw) To: linux-arm-kernel This makes the Gemini optionally take two clock references to the PCLK and EXTCLK. As we are adding a clock framework to the Gemini platform we need to make sure that we get the right references. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/rtc/rtc-gemini.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c index 5279390bb42d..d69a35aa80e7 100644 --- a/drivers/rtc/rtc-gemini.c +++ b/drivers/rtc/rtc-gemini.c @@ -26,6 +26,7 @@ #include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/clk.h> #define DRV_NAME "rtc-gemini" @@ -38,6 +39,8 @@ struct gemini_rtc { struct rtc_device *rtc_dev; void __iomem *rtc_base; int rtc_irq; + struct clk *pclk; + struct clk *extclk; }; enum gemini_rtc_offsets { @@ -127,6 +130,27 @@ static int gemini_rtc_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, rtc); + rtc->pclk = clk_get(dev, "PCLK"); + if (IS_ERR(rtc->pclk)) { + dev_err(dev, "could not get PCLK\n"); + } else { + ret = clk_prepare_enable(rtc->pclk); + if (ret) { + dev_err(dev, "failed to enable PCLK\n"); + return ret; + } + } + rtc->extclk = clk_get(dev, "EXTCLK"); + if (IS_ERR(rtc->extclk)) { + dev_err(dev, "could not get EXTCLK\n"); + } else { + ret = clk_prepare_enable(rtc->extclk); + if (ret) { + dev_err(dev, "failed to enable EXTCLK\n"); + return ret; + } + } + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) return -ENODEV; @@ -156,6 +180,10 @@ static int gemini_rtc_remove(struct platform_device *pdev) { struct gemini_rtc *rtc = platform_get_drvdata(pdev); + if (!IS_ERR(rtc->extclk)) + clk_disable_unprepare(rtc->extclk); + if (!IS_ERR(rtc->pclk)) + clk_disable_unprepare(rtc->pclk); rtc_device_unregister(rtc->rtc_dev); return 0; -- 2.9.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday 2017-05-18 21:56 [PATCH 1/3] rtc: gemini: Add optional clock handling Linus Walleij @ 2017-05-18 21:56 ` Linus Walleij 2017-05-23 14:27 ` Rob Herring 2017-05-18 21:56 ` [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols Linus Walleij ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: Linus Walleij @ 2017-05-18 21:56 UTC (permalink / raw) To: linux-arm-kernel The Gemini RTC is actually a standard IP block from Faraday Technology called FTRTC010. Rename the bindings, add the generic compatible string and add definitions for the two available clocks. Cc: devicetree at vger.kernel.org Cc: Po-Yu Chuang <ratbert@faraday-tech.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- .../devicetree/bindings/rtc/cortina,gemini.txt | 14 ----------- .../devicetree/bindings/rtc/faraday,ftrtc010.txt | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rtc/cortina,gemini.txt create mode 100644 Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt diff --git a/Documentation/devicetree/bindings/rtc/cortina,gemini.txt b/Documentation/devicetree/bindings/rtc/cortina,gemini.txt deleted file mode 100644 index 4ce4e794ddbb..000000000000 --- a/Documentation/devicetree/bindings/rtc/cortina,gemini.txt +++ /dev/null @@ -1,14 +0,0 @@ -* Cortina Systems Gemini RTC - -Gemini SoC real-time clock. - -Required properties: -- compatible : Should be "cortina,gemini-rtc" - -Examples: - -rtc at 45000000 { - compatible = "cortina,gemini-rtc"; - reg = <0x45000000 0x100>; - interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; -}; diff --git a/Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt b/Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt new file mode 100644 index 000000000000..e3938f5e0b6c --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt @@ -0,0 +1,28 @@ +* Faraday Technology FTRTC010 Real Time Clock + +This RTC appears in for example the Storlink Gemini family of +SoCs. + +Required properties: +- compatible : Should be one of: + "faraday,ftrtc010" + "cortina,gemini-rtc", "faraday,ftrtc010" + +Optional properties: +- clocks: when present should contain clock references to the + PCLK and EXTCLK clocks. Faraday calls the later CLK1HZ and + says the clock should be 1 Hz, but implementers actually seem + to choose different clocks here, like Cortina who chose + 32768 Hz (a typical low-power clock). +- clock-names: should name the clocks "PCLK" and "EXTCLK" + respectively. + +Examples: + +rtc at 45000000 { + compatible = "cortina,gemini-rtc"; + reg = <0x45000000 0x100>; + interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&foo 0>, <&foo 1>; + clock-names = "PCLK", "EXTCLK"; +}; -- 2.9.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday 2017-05-18 21:56 ` [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday Linus Walleij @ 2017-05-23 14:27 ` Rob Herring 0 siblings, 0 replies; 7+ messages in thread From: Rob Herring @ 2017-05-23 14:27 UTC (permalink / raw) To: linux-arm-kernel On Thu, May 18, 2017 at 11:56:34PM +0200, Linus Walleij wrote: > The Gemini RTC is actually a standard IP block from Faraday > Technology called FTRTC010. Rename the bindings, add the > generic compatible string and add definitions for the two > available clocks. > > Cc: devicetree at vger.kernel.org > Cc: Po-Yu Chuang <ratbert@faraday-tech.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > .../devicetree/bindings/rtc/cortina,gemini.txt | 14 ----------- > .../devicetree/bindings/rtc/faraday,ftrtc010.txt | 28 ++++++++++++++++++++++ > 2 files changed, 28 insertions(+), 14 deletions(-) > delete mode 100644 Documentation/devicetree/bindings/rtc/cortina,gemini.txt > create mode 100644 Documentation/devicetree/bindings/rtc/faraday,ftrtc010.txt Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols 2017-05-18 21:56 [PATCH 1/3] rtc: gemini: Add optional clock handling Linus Walleij 2017-05-18 21:56 ` [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday Linus Walleij @ 2017-05-18 21:56 ` Linus Walleij 2017-05-19 18:10 ` Hans Ulli Kroll 2017-05-18 22:30 ` [PATCH 1/3] rtc: gemini: Add optional clock handling Russell King - ARM Linux 2017-05-19 18:11 ` Hans Ulli Kroll 3 siblings, 1 reply; 7+ messages in thread From: Linus Walleij @ 2017-05-18 21:56 UTC (permalink / raw) To: linux-arm-kernel The Gemini RTC is actually a generic IP block from Faraday Technology names FTRTC010. Rename the driver file and all symbols to match this IP name. The relationship can be clearly seen in the U-Boot driver posted by Po-Yu Chuang for the Faraday A320 board: https://lists.denx.de/pipermail/u-boot/2009-September/061326.html Remove the dependency on ARCH_GEMINI but select the driver for ARCH_GEMINI so we get a smooth transition. The IP block is synthsized on different silicon and architectures. Cc: Po-Yu Chuang <ratbert@faraday-tech.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- MAINTAINERS | 2 +- drivers/rtc/Kconfig | 10 +-- drivers/rtc/Makefile | 2 +- drivers/rtc/{rtc-gemini.c => rtc-ftrtc010.c} | 91 ++++++++++++++-------------- 4 files changed, 53 insertions(+), 52 deletions(-) rename drivers/rtc/{rtc-gemini.c => rtc-ftrtc010.c} (62%) diff --git a/MAINTAINERS b/MAINTAINERS index f7d568b8f133..c6f0f412b32e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1226,7 +1226,7 @@ L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) T: git git://github.com/ulli-kroll/linux.git S: Maintained F: arch/arm/mach-gemini/ -F: drivers/rtc/rtc-gemini.c +F: drivers/rtc/rtc-ftrtc010.c ARM/CSR SIRFPRIMA2 MACHINE SUPPORT M: Barry Song <baohua@kernel.org> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 8d3b95728326..e60ed55d0b82 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1484,16 +1484,16 @@ config RTC_DRV_ARMADA38X This driver can also be built as a module. If so, the module will be called armada38x-rtc. -config RTC_DRV_GEMINI - tristate "Gemini SoC RTC" - depends on ARCH_GEMINI || COMPILE_TEST +config RTC_DRV_FTRTC010 + tristate "Faraday Technology FTRTC010 RTC" depends on HAS_IOMEM + default ARCH_GEMINI help If you say Y here you will get support for the - RTC found on Gemini SoC's. + Faraday Technolog FTRTC010 found on e.g. Gemini SoC's. This driver can also be built as a module. If so, the module - will be called rtc-gemini. + will be called rtc-ftrtc010. config RTC_DRV_PS3 tristate "PS3 RTC" diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 13857d2fce09..5d3944a42d48 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -67,7 +67,7 @@ obj-$(CONFIG_RTC_DRV_EFI) += rtc-efi.o obj-$(CONFIG_RTC_DRV_EM3027) += rtc-em3027.o obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o -obj-$(CONFIG_RTC_DRV_GEMINI) += rtc-gemini.o +obj-$(CONFIG_RTC_DRV_FTRTC010) += rtc-ftrtc010.o obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-ftrtc010.c similarity index 62% rename from drivers/rtc/rtc-gemini.c rename to drivers/rtc/rtc-ftrtc010.c index d69a35aa80e7..31281beb8ebd 100644 --- a/drivers/rtc/rtc-gemini.c +++ b/drivers/rtc/rtc-ftrtc010.c @@ -1,5 +1,5 @@ /* - * Gemini OnChip RTC + * Faraday Technology FTRTC010 driver * * Copyright (C) 2009 Janos Laube <janos.dev@gmail.com> * @@ -28,14 +28,14 @@ #include <linux/module.h> #include <linux/clk.h> -#define DRV_NAME "rtc-gemini" +#define DRV_NAME "rtc-ftrtc010" MODULE_AUTHOR("Hans Ulli Kroll <ulli.kroll@googlemail.com>"); MODULE_DESCRIPTION("RTC driver for Gemini SoC"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" DRV_NAME); -struct gemini_rtc { +struct ftrtc010_rtc { struct rtc_device *rtc_dev; void __iomem *rtc_base; int rtc_irq; @@ -43,19 +43,19 @@ struct gemini_rtc { struct clk *extclk; }; -enum gemini_rtc_offsets { - GEMINI_RTC_SECOND = 0x00, - GEMINI_RTC_MINUTE = 0x04, - GEMINI_RTC_HOUR = 0x08, - GEMINI_RTC_DAYS = 0x0C, - GEMINI_RTC_ALARM_SECOND = 0x10, - GEMINI_RTC_ALARM_MINUTE = 0x14, - GEMINI_RTC_ALARM_HOUR = 0x18, - GEMINI_RTC_RECORD = 0x1C, - GEMINI_RTC_CR = 0x20 +enum ftrtc010_rtc_offsets { + FTRTC010_RTC_SECOND = 0x00, + FTRTC010_RTC_MINUTE = 0x04, + FTRTC010_RTC_HOUR = 0x08, + FTRTC010_RTC_DAYS = 0x0C, + FTRTC010_RTC_ALARM_SECOND = 0x10, + FTRTC010_RTC_ALARM_MINUTE = 0x14, + FTRTC010_RTC_ALARM_HOUR = 0x18, + FTRTC010_RTC_RECORD = 0x1C, + FTRTC010_RTC_CR = 0x20, }; -static irqreturn_t gemini_rtc_interrupt(int irq, void *dev) +static irqreturn_t ftrtc010_rtc_interrupt(int irq, void *dev) { return IRQ_HANDLED; } @@ -69,18 +69,18 @@ static irqreturn_t gemini_rtc_interrupt(int irq, void *dev) * the same thing, without the rtc-lib.c calls. */ -static int gemini_rtc_read_time(struct device *dev, struct rtc_time *tm) +static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) { - struct gemini_rtc *rtc = dev_get_drvdata(dev); + struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); unsigned int days, hour, min, sec; unsigned long offset, time; - sec = readl(rtc->rtc_base + GEMINI_RTC_SECOND); - min = readl(rtc->rtc_base + GEMINI_RTC_MINUTE); - hour = readl(rtc->rtc_base + GEMINI_RTC_HOUR); - days = readl(rtc->rtc_base + GEMINI_RTC_DAYS); - offset = readl(rtc->rtc_base + GEMINI_RTC_RECORD); + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); + days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); + offset = readl(rtc->rtc_base + FTRTC010_RTC_RECORD); time = offset + days * 86400 + hour * 3600 + min * 60 + sec; @@ -89,9 +89,9 @@ static int gemini_rtc_read_time(struct device *dev, struct rtc_time *tm) return 0; } -static int gemini_rtc_set_time(struct device *dev, struct rtc_time *tm) +static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) { - struct gemini_rtc *rtc = dev_get_drvdata(dev); + struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); unsigned int sec, min, hour, day; unsigned long offset, time; @@ -100,27 +100,27 @@ static int gemini_rtc_set_time(struct device *dev, struct rtc_time *tm) rtc_tm_to_time(tm, &time); - sec = readl(rtc->rtc_base + GEMINI_RTC_SECOND); - min = readl(rtc->rtc_base + GEMINI_RTC_MINUTE); - hour = readl(rtc->rtc_base + GEMINI_RTC_HOUR); - day = readl(rtc->rtc_base + GEMINI_RTC_DAYS); + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); + day = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); offset = time - (day * 86400 + hour * 3600 + min * 60 + sec); - writel(offset, rtc->rtc_base + GEMINI_RTC_RECORD); - writel(0x01, rtc->rtc_base + GEMINI_RTC_CR); + writel(offset, rtc->rtc_base + FTRTC010_RTC_RECORD); + writel(0x01, rtc->rtc_base + FTRTC010_RTC_CR); return 0; } -static const struct rtc_class_ops gemini_rtc_ops = { - .read_time = gemini_rtc_read_time, - .set_time = gemini_rtc_set_time, +static const struct rtc_class_ops ftrtc010_rtc_ops = { + .read_time = ftrtc010_rtc_read_time, + .set_time = ftrtc010_rtc_set_time, }; -static int gemini_rtc_probe(struct platform_device *pdev) +static int ftrtc010_rtc_probe(struct platform_device *pdev) { - struct gemini_rtc *rtc; + struct ftrtc010_rtc *rtc; struct device *dev = &pdev->dev; struct resource *res; int ret; @@ -166,19 +166,19 @@ static int gemini_rtc_probe(struct platform_device *pdev) if (!rtc->rtc_base) return -ENOMEM; - ret = devm_request_irq(dev, rtc->rtc_irq, gemini_rtc_interrupt, + ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, IRQF_SHARED, pdev->name, dev); if (unlikely(ret)) return ret; rtc->rtc_dev = rtc_device_register(pdev->name, dev, - &gemini_rtc_ops, THIS_MODULE); + &ftrtc010_rtc_ops, THIS_MODULE); return PTR_ERR_OR_ZERO(rtc->rtc_dev); } -static int gemini_rtc_remove(struct platform_device *pdev) +static int ftrtc010_rtc_remove(struct platform_device *pdev) { - struct gemini_rtc *rtc = platform_get_drvdata(pdev); + struct ftrtc010_rtc *rtc = platform_get_drvdata(pdev); if (!IS_ERR(rtc->extclk)) clk_disable_unprepare(rtc->extclk); @@ -189,19 +189,20 @@ static int gemini_rtc_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id gemini_rtc_dt_match[] = { +static const struct of_device_id ftrtc010_rtc_dt_match[] = { { .compatible = "cortina,gemini-rtc" }, + { .compatible = "faraday,ftrtc010" }, { } }; -MODULE_DEVICE_TABLE(of, gemini_rtc_dt_match); +MODULE_DEVICE_TABLE(of, ftrtc010_rtc_dt_match); -static struct platform_driver gemini_rtc_driver = { +static struct platform_driver ftrtc010_rtc_driver = { .driver = { .name = DRV_NAME, - .of_match_table = gemini_rtc_dt_match, + .of_match_table = ftrtc010_rtc_dt_match, }, - .probe = gemini_rtc_probe, - .remove = gemini_rtc_remove, + .probe = ftrtc010_rtc_probe, + .remove = ftrtc010_rtc_remove, }; -module_platform_driver_probe(gemini_rtc_driver, gemini_rtc_probe); +module_platform_driver_probe(ftrtc010_rtc_driver, ftrtc010_rtc_probe); -- 2.9.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols 2017-05-18 21:56 ` [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols Linus Walleij @ 2017-05-19 18:10 ` Hans Ulli Kroll 0 siblings, 0 replies; 7+ messages in thread From: Hans Ulli Kroll @ 2017-05-19 18:10 UTC (permalink / raw) To: linux-arm-kernel Hi Linus On Thu, 18 May 2017, Linus Walleij wrote: > The Gemini RTC is actually a generic IP block from Faraday > Technology names FTRTC010. Rename the driver file and all > symbols to match this IP name. > > The relationship can be clearly seen in the U-Boot driver > posted by Po-Yu Chuang for the Faraday A320 board: > https://lists.denx.de/pipermail/u-boot/2009-September/061326.html > > Remove the dependency on ARCH_GEMINI but select the driver > for ARCH_GEMINI so we get a smooth transition. The IP block > is synthsized on different silicon and architectures. > > Cc: Po-Yu Chuang <ratbert@faraday-tech.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > MAINTAINERS | 2 +- > drivers/rtc/Kconfig | 10 +-- > drivers/rtc/Makefile | 2 +- > drivers/rtc/{rtc-gemini.c => rtc-ftrtc010.c} | 91 ++++++++++++++-------------- > 4 files changed, 53 insertions(+), 52 deletions(-) > rename drivers/rtc/{rtc-gemini.c => rtc-ftrtc010.c} (62%) > > diff --git a/MAINTAINERS b/MAINTAINERS > index f7d568b8f133..c6f0f412b32e 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1226,7 +1226,7 @@ L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) > T: git git://github.com/ulli-kroll/linux.git > S: Maintained > F: arch/arm/mach-gemini/ > -F: drivers/rtc/rtc-gemini.c > +F: drivers/rtc/rtc-ftrtc010.c > > ARM/CSR SIRFPRIMA2 MACHINE SUPPORT > M: Barry Song <baohua@kernel.org> > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig > index 8d3b95728326..e60ed55d0b82 100644 > --- a/drivers/rtc/Kconfig > +++ b/drivers/rtc/Kconfig > @@ -1484,16 +1484,16 @@ config RTC_DRV_ARMADA38X > This driver can also be built as a module. If so, the module > will be called armada38x-rtc. > > -config RTC_DRV_GEMINI > - tristate "Gemini SoC RTC" > - depends on ARCH_GEMINI || COMPILE_TEST > +config RTC_DRV_FTRTC010 > + tristate "Faraday Technology FTRTC010 RTC" > depends on HAS_IOMEM > + default ARCH_GEMINI > help > If you say Y here you will get support for the > - RTC found on Gemini SoC's. > + Faraday Technolog FTRTC010 found on e.g. Gemini SoC's. > > This driver can also be built as a module. If so, the module > - will be called rtc-gemini. > + will be called rtc-ftrtc010. > > config RTC_DRV_PS3 > tristate "PS3 RTC" > diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile > index 13857d2fce09..5d3944a42d48 100644 > --- a/drivers/rtc/Makefile > +++ b/drivers/rtc/Makefile > @@ -67,7 +67,7 @@ obj-$(CONFIG_RTC_DRV_EFI) += rtc-efi.o > obj-$(CONFIG_RTC_DRV_EM3027) += rtc-em3027.o > obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o > obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o > -obj-$(CONFIG_RTC_DRV_GEMINI) += rtc-gemini.o > +obj-$(CONFIG_RTC_DRV_FTRTC010) += rtc-ftrtc010.o > obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o > obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o > obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o > diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-ftrtc010.c > similarity index 62% > rename from drivers/rtc/rtc-gemini.c > rename to drivers/rtc/rtc-ftrtc010.c > index d69a35aa80e7..31281beb8ebd 100644 > --- a/drivers/rtc/rtc-gemini.c > +++ b/drivers/rtc/rtc-ftrtc010.c > @@ -1,5 +1,5 @@ > /* > - * Gemini OnChip RTC > + * Faraday Technology FTRTC010 driver > * > * Copyright (C) 2009 Janos Laube <janos.dev@gmail.com> > * > @@ -28,14 +28,14 @@ > #include <linux/module.h> > #include <linux/clk.h> > > -#define DRV_NAME "rtc-gemini" > +#define DRV_NAME "rtc-ftrtc010" > > MODULE_AUTHOR("Hans Ulli Kroll <ulli.kroll@googlemail.com>"); > MODULE_DESCRIPTION("RTC driver for Gemini SoC"); > MODULE_LICENSE("GPL"); > MODULE_ALIAS("platform:" DRV_NAME); > > -struct gemini_rtc { > +struct ftrtc010_rtc { > struct rtc_device *rtc_dev; > void __iomem *rtc_base; > int rtc_irq; > @@ -43,19 +43,19 @@ struct gemini_rtc { > struct clk *extclk; > }; > > -enum gemini_rtc_offsets { > - GEMINI_RTC_SECOND = 0x00, > - GEMINI_RTC_MINUTE = 0x04, > - GEMINI_RTC_HOUR = 0x08, > - GEMINI_RTC_DAYS = 0x0C, > - GEMINI_RTC_ALARM_SECOND = 0x10, > - GEMINI_RTC_ALARM_MINUTE = 0x14, > - GEMINI_RTC_ALARM_HOUR = 0x18, > - GEMINI_RTC_RECORD = 0x1C, > - GEMINI_RTC_CR = 0x20 > +enum ftrtc010_rtc_offsets { > + FTRTC010_RTC_SECOND = 0x00, > + FTRTC010_RTC_MINUTE = 0x04, > + FTRTC010_RTC_HOUR = 0x08, > + FTRTC010_RTC_DAYS = 0x0C, > + FTRTC010_RTC_ALARM_SECOND = 0x10, > + FTRTC010_RTC_ALARM_MINUTE = 0x14, > + FTRTC010_RTC_ALARM_HOUR = 0x18, > + FTRTC010_RTC_RECORD = 0x1C, > + FTRTC010_RTC_CR = 0x20, > }; > > -static irqreturn_t gemini_rtc_interrupt(int irq, void *dev) > +static irqreturn_t ftrtc010_rtc_interrupt(int irq, void *dev) > { > return IRQ_HANDLED; > } > @@ -69,18 +69,18 @@ static irqreturn_t gemini_rtc_interrupt(int irq, void *dev) > * the same thing, without the rtc-lib.c calls. > */ > > -static int gemini_rtc_read_time(struct device *dev, struct rtc_time *tm) > +static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) > { > - struct gemini_rtc *rtc = dev_get_drvdata(dev); > + struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); > > unsigned int days, hour, min, sec; > unsigned long offset, time; > > - sec = readl(rtc->rtc_base + GEMINI_RTC_SECOND); > - min = readl(rtc->rtc_base + GEMINI_RTC_MINUTE); > - hour = readl(rtc->rtc_base + GEMINI_RTC_HOUR); > - days = readl(rtc->rtc_base + GEMINI_RTC_DAYS); > - offset = readl(rtc->rtc_base + GEMINI_RTC_RECORD); > + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); > + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); > + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); > + days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); > + offset = readl(rtc->rtc_base + FTRTC010_RTC_RECORD); > > time = offset + days * 86400 + hour * 3600 + min * 60 + sec; > > @@ -89,9 +89,9 @@ static int gemini_rtc_read_time(struct device *dev, struct rtc_time *tm) > return 0; > } > > -static int gemini_rtc_set_time(struct device *dev, struct rtc_time *tm) > +static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) > { > - struct gemini_rtc *rtc = dev_get_drvdata(dev); > + struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); > unsigned int sec, min, hour, day; > unsigned long offset, time; > > @@ -100,27 +100,27 @@ static int gemini_rtc_set_time(struct device *dev, struct rtc_time *tm) > > rtc_tm_to_time(tm, &time); > > - sec = readl(rtc->rtc_base + GEMINI_RTC_SECOND); > - min = readl(rtc->rtc_base + GEMINI_RTC_MINUTE); > - hour = readl(rtc->rtc_base + GEMINI_RTC_HOUR); > - day = readl(rtc->rtc_base + GEMINI_RTC_DAYS); > + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); > + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); > + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); > + day = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); > > offset = time - (day * 86400 + hour * 3600 + min * 60 + sec); > > - writel(offset, rtc->rtc_base + GEMINI_RTC_RECORD); > - writel(0x01, rtc->rtc_base + GEMINI_RTC_CR); > + writel(offset, rtc->rtc_base + FTRTC010_RTC_RECORD); > + writel(0x01, rtc->rtc_base + FTRTC010_RTC_CR); > > return 0; > } > > -static const struct rtc_class_ops gemini_rtc_ops = { > - .read_time = gemini_rtc_read_time, > - .set_time = gemini_rtc_set_time, > +static const struct rtc_class_ops ftrtc010_rtc_ops = { > + .read_time = ftrtc010_rtc_read_time, > + .set_time = ftrtc010_rtc_set_time, > }; > > -static int gemini_rtc_probe(struct platform_device *pdev) > +static int ftrtc010_rtc_probe(struct platform_device *pdev) > { > - struct gemini_rtc *rtc; > + struct ftrtc010_rtc *rtc; > struct device *dev = &pdev->dev; > struct resource *res; > int ret; > @@ -166,19 +166,19 @@ static int gemini_rtc_probe(struct platform_device *pdev) > if (!rtc->rtc_base) > return -ENOMEM; > > - ret = devm_request_irq(dev, rtc->rtc_irq, gemini_rtc_interrupt, > + ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, > IRQF_SHARED, pdev->name, dev); > if (unlikely(ret)) > return ret; > > rtc->rtc_dev = rtc_device_register(pdev->name, dev, > - &gemini_rtc_ops, THIS_MODULE); > + &ftrtc010_rtc_ops, THIS_MODULE); > return PTR_ERR_OR_ZERO(rtc->rtc_dev); > } > > -static int gemini_rtc_remove(struct platform_device *pdev) > +static int ftrtc010_rtc_remove(struct platform_device *pdev) > { > - struct gemini_rtc *rtc = platform_get_drvdata(pdev); > + struct ftrtc010_rtc *rtc = platform_get_drvdata(pdev); > > if (!IS_ERR(rtc->extclk)) > clk_disable_unprepare(rtc->extclk); > @@ -189,19 +189,20 @@ static int gemini_rtc_remove(struct platform_device *pdev) > return 0; > } > > -static const struct of_device_id gemini_rtc_dt_match[] = { > +static const struct of_device_id ftrtc010_rtc_dt_match[] = { > { .compatible = "cortina,gemini-rtc" }, > + { .compatible = "faraday,ftrtc010" }, > { } > }; > -MODULE_DEVICE_TABLE(of, gemini_rtc_dt_match); > +MODULE_DEVICE_TABLE(of, ftrtc010_rtc_dt_match); > > -static struct platform_driver gemini_rtc_driver = { > +static struct platform_driver ftrtc010_rtc_driver = { > .driver = { > .name = DRV_NAME, > - .of_match_table = gemini_rtc_dt_match, > + .of_match_table = ftrtc010_rtc_dt_match, > }, > - .probe = gemini_rtc_probe, > - .remove = gemini_rtc_remove, > + .probe = ftrtc010_rtc_probe, > + .remove = ftrtc010_rtc_remove, > }; > > -module_platform_driver_probe(gemini_rtc_driver, gemini_rtc_probe); > +module_platform_driver_probe(ftrtc010_rtc_driver, ftrtc010_rtc_probe); > -- > 2.9.3 > > Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] rtc: gemini: Add optional clock handling 2017-05-18 21:56 [PATCH 1/3] rtc: gemini: Add optional clock handling Linus Walleij 2017-05-18 21:56 ` [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday Linus Walleij 2017-05-18 21:56 ` [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols Linus Walleij @ 2017-05-18 22:30 ` Russell King - ARM Linux 2017-05-19 18:11 ` Hans Ulli Kroll 3 siblings, 0 replies; 7+ messages in thread From: Russell King - ARM Linux @ 2017-05-18 22:30 UTC (permalink / raw) To: linux-arm-kernel On Thu, May 18, 2017 at 11:56:33PM +0200, Linus Walleij wrote: > + rtc->pclk = clk_get(dev, "PCLK"); > + if (IS_ERR(rtc->pclk)) { > + dev_err(dev, "could not get PCLK\n"); > + } else { > + ret = clk_prepare_enable(rtc->pclk); > + if (ret) { > + dev_err(dev, "failed to enable PCLK\n"); > + return ret; Proper cleanup? Maybe consider using devm_clk_get() right from the get-go? > + } > + } > + rtc->extclk = clk_get(dev, "EXTCLK"); > + if (IS_ERR(rtc->extclk)) { > + dev_err(dev, "could not get EXTCLK\n"); > + } else { > + ret = clk_prepare_enable(rtc->extclk); > + if (ret) { > + dev_err(dev, "failed to enable EXTCLK\n"); > + return ret; Ditto. > + } > + } > + > res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > if (!res) > return -ENODEV; > @@ -156,6 +180,10 @@ static int gemini_rtc_remove(struct platform_device *pdev) > { > struct gemini_rtc *rtc = platform_get_drvdata(pdev); > > + if (!IS_ERR(rtc->extclk)) > + clk_disable_unprepare(rtc->extclk); > + if (!IS_ERR(rtc->pclk)) > + clk_disable_unprepare(rtc->pclk); No clk_put(), but if you used devm_clk_get(), you don't need it. > rtc_device_unregister(rtc->rtc_dev); > > return 0; > -- > 2.9.3 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel at lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] rtc: gemini: Add optional clock handling 2017-05-18 21:56 [PATCH 1/3] rtc: gemini: Add optional clock handling Linus Walleij ` (2 preceding siblings ...) 2017-05-18 22:30 ` [PATCH 1/3] rtc: gemini: Add optional clock handling Russell King - ARM Linux @ 2017-05-19 18:11 ` Hans Ulli Kroll 3 siblings, 0 replies; 7+ messages in thread From: Hans Ulli Kroll @ 2017-05-19 18:11 UTC (permalink / raw) To: linux-arm-kernel Hi Linus, On Thu, 18 May 2017, Linus Walleij wrote: > This makes the Gemini optionally take two clock references to > the PCLK and EXTCLK. As we are adding a clock framework to the > Gemini platform we need to make sure that we get the right > references. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/rtc/rtc-gemini.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c > index 5279390bb42d..d69a35aa80e7 100644 > --- a/drivers/rtc/rtc-gemini.c > +++ b/drivers/rtc/rtc-gemini.c > @@ -26,6 +26,7 @@ > #include <linux/platform_device.h> > #include <linux/kernel.h> > #include <linux/module.h> > +#include <linux/clk.h> > > #define DRV_NAME "rtc-gemini" > > @@ -38,6 +39,8 @@ struct gemini_rtc { > struct rtc_device *rtc_dev; > void __iomem *rtc_base; > int rtc_irq; > + struct clk *pclk; > + struct clk *extclk; > }; > > enum gemini_rtc_offsets { > @@ -127,6 +130,27 @@ static int gemini_rtc_probe(struct platform_device *pdev) > return -ENOMEM; > platform_set_drvdata(pdev, rtc); > > + rtc->pclk = clk_get(dev, "PCLK"); > + if (IS_ERR(rtc->pclk)) { > + dev_err(dev, "could not get PCLK\n"); > + } else { > + ret = clk_prepare_enable(rtc->pclk); > + if (ret) { > + dev_err(dev, "failed to enable PCLK\n"); > + return ret; > + } > + } > + rtc->extclk = clk_get(dev, "EXTCLK"); > + if (IS_ERR(rtc->extclk)) { > + dev_err(dev, "could not get EXTCLK\n"); > + } else { > + ret = clk_prepare_enable(rtc->extclk); > + if (ret) { > + dev_err(dev, "failed to enable EXTCLK\n"); > + return ret; > + } > + } > + > res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > if (!res) > return -ENODEV; > @@ -156,6 +180,10 @@ static int gemini_rtc_remove(struct platform_device *pdev) > { > struct gemini_rtc *rtc = platform_get_drvdata(pdev); > > + if (!IS_ERR(rtc->extclk)) > + clk_disable_unprepare(rtc->extclk); > + if (!IS_ERR(rtc->pclk)) > + clk_disable_unprepare(rtc->pclk); > rtc_device_unregister(rtc->rtc_dev); > > return 0; > -- > 2.9.3 > > Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-23 14:27 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-18 21:56 [PATCH 1/3] rtc: gemini: Add optional clock handling Linus Walleij 2017-05-18 21:56 ` [PATCH 2/3] rtc: gemini: Augment DT bindings for Faraday Linus Walleij 2017-05-23 14:27 ` Rob Herring 2017-05-18 21:56 ` [PATCH 3/3] rtc: gemini/ftrtc010: rename driver and symbols Linus Walleij 2017-05-19 18:10 ` Hans Ulli Kroll 2017-05-18 22:30 ` [PATCH 1/3] rtc: gemini: Add optional clock handling Russell King - ARM Linux 2017-05-19 18:11 ` Hans Ulli Kroll
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).