Message ID | 20170316175112.27913-2-chris.brandt@renesas.com |
---|---|
State | Superseded |
Headers | show |
Hi Chris, On Thu, Mar 16, 2017 at 6:51 PM, Chris Brandt <chris.brandt@renesas.com> wrote: > This same RTC is used in RZ/A series MPUs, therefore with some slight > changes, this driver can be reused. Additionally, since ARM architectures > require Device Tree configurations, device tree support has been added. Thanks for your patch! > Signed-off-by: Chris Brandt <chris.brandt@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- a/drivers/rtc/Kconfig > +++ b/drivers/rtc/Kconfig > @@ -1303,10 +1303,10 @@ config RTC_DRV_SA1100 > > config RTC_DRV_SH > tristate "SuperH On-Chip RTC" > - depends on SUPERH && HAVE_CLK > + depends on (SUPERH || ARCH_RENESAS) && HAVE_CLK I believe the dependency on HAVE_CLK is not needed. SuperH selects CLKDEV_LOOKUP, which selects HAVE_CLK. ARM (and ARM64) selects COMMON_CLK, which selects HAVE_CLK. interestingly, SuperH already did so at the time the dependency was added... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert, On Friday, March 17, 2017, Geert Uytterhoeven wrote: > > --- a/drivers/rtc/Kconfig > > +++ b/drivers/rtc/Kconfig > > @@ -1303,10 +1303,10 @@ config RTC_DRV_SA1100 > > > > config RTC_DRV_SH > > tristate "SuperH On-Chip RTC" > > - depends on SUPERH && HAVE_CLK > > + depends on (SUPERH || ARCH_RENESAS) && HAVE_CLK > > I believe the dependency on HAVE_CLK is not needed. > SuperH selects CLKDEV_LOOKUP, which selects HAVE_CLK. > ARM (and ARM64) selects COMMON_CLK, which selects HAVE_CLK. > > interestingly, SuperH already did so at the time the dependency was > added... OK, I'll take it out. I just didn't want to break any SH stuff. Chris
Mostly good, one nitpick: On 16/03/2017 at 13:51:08 -0400, Chris Brandt wrote: > res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + if (res == NULL) if (!res) is preferred here
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index ee1b0e9..77d1495 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1303,10 +1303,10 @@ config RTC_DRV_SA1100 config RTC_DRV_SH tristate "SuperH On-Chip RTC" - depends on SUPERH && HAVE_CLK + depends on (SUPERH || ARCH_RENESAS) && HAVE_CLK help Say Y here to enable support for the on-chip RTC found in - most SuperH processors. + most SuperH processors. This RTC is also found in RZ/A SoCs. To compile this driver as a module, choose M here: the module will be called rtc-sh. diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index c626e43..2ef4ac7 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -27,7 +27,15 @@ #include <linux/log2.h> #include <linux/clk.h> #include <linux/slab.h> +#ifdef CONFIG_SUPERH #include <asm/rtc.h> +#else +/* Default values for RZ/A RTC */ +#define rtc_reg_size sizeof(u16) +#define RTC_BIT_INVERTED 0 /* no chip bugs */ +#define RTC_CAP_4_DIGIT_YEAR (1 << 0) +#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR +#endif #define DRV_NAME "sh-rtc" @@ -570,6 +578,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) rtc->alarm_irq = platform_get_irq(pdev, 2); res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(res == NULL)) { dev_err(&pdev->dev, "No IO resource\n"); return -ENOENT; @@ -608,6 +618,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) clk_enable(rtc->clk); rtc->capabilities = RTC_DEF_CAPABILITIES; + +#ifdef CONFIG_SUPERH if (dev_get_platdata(&pdev->dev)) { struct sh_rtc_platform_info *pinfo = dev_get_platdata(&pdev->dev); @@ -618,6 +630,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) */ rtc->capabilities |= pinfo->capabilities; } +#endif if (rtc->carry_irq <= 0) { /* register shared periodic/carry/alarm irq */ @@ -738,10 +751,17 @@ static int sh_rtc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sh_rtc_pm_ops, sh_rtc_suspend, sh_rtc_resume); +static const struct of_device_id sh_rtc_of_match[] = { + { .compatible = "renesas,sh-rtc", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sh_rtc_of_match); + static struct platform_driver sh_rtc_platform_driver = { .driver = { .name = DRV_NAME, .pm = &sh_rtc_pm_ops, + .of_match_table = sh_rtc_of_match, }, .remove = __exit_p(sh_rtc_remove), };
This same RTC is used in RZ/A series MPUs, therefore with some slight changes, this driver can be reused. Additionally, since ARM architectures require Device Tree configurations, device tree support has been added. Signed-off-by: Chris Brandt <chris.brandt@renesas.com> --- drivers/rtc/Kconfig | 4 ++-- drivers/rtc/rtc-sh.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-)