rtc: at91sam9: drop platform_data support
Subsystems (2)
Alexandre Belloni
maintainerPATCH 1/6 rtc: at91sam9: drop platform_data support
ARCH_AT91 is DT only for a while, drop platform data support.
--- drivers/rtc/Kconfig | 2 +- drivers/rtc/rtc-at91sam9.c | 44 +++++++------------------------------- 2 files changed, 9 insertions(+), 37 deletions(-)
drivers/rtc/Kconfig +1 -1
@@ -1432,7 +1432,7 @@ config RTC_DRV_AT91RM9200 config RTC_DRV_AT91SAM9 tristate "AT91SAM9 RTT as RTC" depends on ARCH_AT91 || COMPILE_TEST - depends on HAS_IOMEM + depends on OF && HAS_IOMEM select MFD_SYSCON help Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block which
drivers/rtc/rtc-at91sam9.c +8 -36
74 lines not on this page · raw message
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 2/6 rtc: at91sam9: convert to devm_rtc_allocate_device
This allows further improvement of the driver.
--- drivers/rtc/rtc-at91sam9.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-at91sam9.c +4 -3
@@ -418,13 +418,14 @@ static int at91_rtc_probe(struct platform_device *pdev) mr &= ~(AT91_RTT_ALMIEN |AT91_RTT_RTTINCIEN );rtt_writel (rtc,MR , mr); - rtc->rtcdev =devm_rtc_device_register (&pdev->dev, pdev->name, - &at91_rtc_ops,THIS_MODULE ); + rtc->rtcdev =devm_rtc_allocate_device (&pdev->dev);if (IS_ERR (rtc->rtcdev)) { ret =PTR_ERR (rtc->rtcdev); goto err_clk; } + rtc->rtcdev->ops = &at91_rtc_ops; +/* register irq handler after we know what name we'll use */ ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt, IRQF_SHARED | IRQF_COND_SUSPEND,
@@ -444,7 +445,7 @@ static int at91_rtc_probe(struct platform_device *pdev)dev_warn (&pdev->dev,"%s: SET TIME!\n" ,dev_name (&rtc->rtcdev->dev)); -return 0 ; +return rtc_register_device (rtc->rtcdev); err_clk:clk_disable_unprepare (rtc->sclk);
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 3/6 rtc: at91sam9: set range
In reply to Alexandre BelloniThe AT91 RTT is a 32bit second counter that is saved in a 32bit global purpose register.
--- drivers/rtc/rtc-at91sam9.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-at91sam9.c +1 -0
@@ -425,6 +425,7 @@ static int at91_rtc_probe(struct platform_device *pdev) } rtc->rtcdev->ops = &at91_rtc_ops; + rtc->rtcdev->range_max =U32_MAX ;/* register irq handler after we know what name we'll use */ ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 4/6 rtc: at91sam9: switch to rtc_time64_to_tm/rtc_tm_to_time64
In reply to Alexandre BelloniCall the 64bit versions of rtc_tm time conversion as the range is enforced by the core.
--- drivers/rtc/rtc-at91sam9.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/rtc/rtc-at91sam9.c +4 -10
@@ -122,7 +122,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)if (secs != secs2) secs =rtt_readl (rtc,VR ); -rtc_time_to_tm (offset + secs, tm); +rtc_time64_to_tm (offset + secs, tm);dev_dbg (dev,"%s: %ptR\n" , __func__, tm);
@@ -135,15 +135,12 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)static int at91_rtc_settime (struct device *dev,struct rtc_time *tm) {struct sam9_rtc *rtc =dev_get_drvdata (dev); -int err;u32 offset, alarm, mr;unsigned long secs;dev_dbg (dev,"%s: %ptR\n" , __func__, tm); - err =rtc_tm_to_time (tm, &secs); -if (err !=0 ) -return err; + secs =rtc_tm_to_time64 (tm); mr =rtt_readl (rtc,MR );
@@ -193,7 +190,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)memset (alrm,0 ,sizeof (*alrm));if (alarm !=ALARM_DISABLED && offset !=0 ) { -rtc_time_to_tm (offset + alarm, tm); +rtc_time64_to_tm (offset + alarm, tm);dev_dbg (dev,"%s: %ptR\n" , __func__, tm);
@@ -211,11 +208,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)unsigned long secs;u32 offset;u32 mr; -int err; - err =rtc_tm_to_time (tm, &secs); -if (err !=0 ) -return err; + secs =rtc_tm_to_time64 (tm); offset =gpbr_readl (rtc);if (offset ==0 ) {
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 5/6 rtc: at91sam9: convert to SPDX identifier
In reply to Alexandre BelloniUse SPDX-License-Identifier instead of a verbose license text
--- drivers/rtc/rtc-at91sam9.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/rtc/rtc-at91sam9.c +1 -5
@@ -1,14 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * "RTT as Real Time Clock" driver for AT91SAM9 SoC family * * (C) 2007 Michel Benoit * * Based on rtc-at91rm9200.c by Rick Bronson -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. */ #include <linux/clk.h>
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 6/6 rtc: at91sam9: correct trivial checkpatch warnings
In reply to Alexandre BelloniCorrect trivial checkpatch warnings, mostly whitespace issues and unbalanced braces.
--- drivers/rtc/rtc-at91sam9.c | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/rtc/rtc-at91sam9.c +20 -20
@@ -43,21 +43,21 @@* registers available, likewise usable for more than "RTC" support. */ -#define AT91_RTT_MR 0x00/* Real-time Mode Register */ -#define AT91_RTT_RTPRES (0xffff << 0)/* Real-time Timer Prescaler Value */ -#define AT91_RTT_ALMIEN (1 << 16)/* Alarm Interrupt Enable */ -#define AT91_RTT_RTTINCIEN (1 << 17)/* Real Time Timer Increment Interrupt Enable */ -#define AT91_RTT_RTTRST (1 << 18)/* Real Time Timer Restart */ +#define AT91_RTT_MR 0x00/* Real-time Mode Register */ +#define AT91_RTT_RTPRES (0xffff << 0)/* Timer Prescaler Value */ +#define AT91_RTT_ALMIEN BIT(16)/* Alarm Interrupt Enable */ +#define AT91_RTT_RTTINCIEN BIT(17)/* Increment Interrupt Enable */ +#define AT91_RTT_RTTRST BIT(18)/* Timer Restart */ -#define AT91_RTT_AR 0x04/* Real-time Alarm Register */ -#define AT91_RTT_ALMV (0xffffffff)/* Alarm Value */ +#define AT91_RTT_AR 0x04/* Real-time Alarm Register */ +#define AT91_RTT_ALMV (0xffffffff)/* Alarm Value */ -#define AT91_RTT_VR 0x08/* Real-time Value Register */ -#define AT91_RTT_CRTV (0xffffffff)/* Current Real-time Value */ +#define AT91_RTT_VR 0x08/* Real-time Value Register */ +#define AT91_RTT_CRTV (0xffffffff)/* Current Real-time Value */ -#define AT91_RTT_SR 0x0c/* Real-time Status Register */ -#define AT91_RTT_ALMS (1 << 0)/* Real-time Alarm Status */ -#define AT91_RTT_RTTINC (1 << 1)/* Real-time Timer Increment */ +#define AT91_RTT_SR 0x0c/* Real-time Status Register */ +#define AT91_RTT_ALMS BIT(0)/* Alarm Status */ +#define AT91_RTT_RTTINC BIT(1)/* Timer Increment */ /* * We store ALARM_DISABLED in ALMV to record that no alarm is set.
@@ -65,14 +65,13 @@*/ #define ALARM_DISABLED ((u32)~0) -struct sam9_rtc {void __iomem *rtt;struct rtc_device *rtcdev;u32 imr;struct regmap *gpbr;unsigned int gpbr_offset; -int irq; +int irq;struct clk *sclk;bool suspended;unsigned long events;
@@ -253,7 +252,7 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq)u32 mr =rtt_readl (rtc,MR );seq_printf (seq,"update_IRQ\t: %s\n" , - (mr &AT91_RTT_RTTINCIEN ) ?"yes" :"no" ); + (mr &AT91_RTT_RTTINCIEN ) ?"yes" :"no" );return 0 ; }
@@ -289,7 +288,7 @@ static void at91_rtc_flush_events(struct sam9_rtc *rtc) rtc->events =0 ;pr_debug ("%s: num=%ld, events=0x%02lx\n" , __func__, - rtc->events >>8 , rtc->events &0x000000FF ); + rtc->events >>8 , rtc->events &0x000000FF ); }/*
@@ -367,8 +366,8 @@ static int at91_rtc_probe(struct platform_device *pdev)return PTR_ERR (rtc->rtt); ret =of_parse_phandle_with_fixed_args (pdev->dev.of_node, -"atmel,rtt-rtc-time-reg" ,1 ,0 , - &args); +"atmel,rtt-rtc-time-reg" ,1 ,0 , + &args);if (ret)return ret;
@@ -434,7 +433,7 @@ static int at91_rtc_probe(struct platform_device *pdev)if (gpbr_readl (rtc) ==0 )dev_warn (&pdev->dev,"%s: SET TIME!\n" , -dev_name (&rtc->rtcdev->dev)); +dev_name (&rtc->rtcdev->dev));return rtc_register_device (rtc->rtcdev);
@@ -494,8 +493,9 @@ static int at91_rtc_suspend(struct device *dev)/* don't let RTTINC cause wakeups */ if (mr &AT91_RTT_RTTINCIEN )rtt_writel (rtc,MR , mr & ~AT91_RTT_RTTINCIEN ); - }else + }else {rtt_writel (rtc,MR , mr & ~rtc->imr); + } }return 0 ;
Signature · 1 line
2.20.1
Quoted 3 lines · Alexandre Belloni
ARCH_AT91is DT only for a while, drop platform data support.Signed-off-by Alexandre Belloni <[email protected]>
For the whole series:
Quoted 101 lines
--- drivers/rtc/Kconfig | 2 +- drivers/rtc/rtc-at91sam9.c | 44 +++++++------------------------------- 2 files changed, 9 insertions(+), 37 deletions(-)drivers/rtc/Kconfig +1
-1@@ -1432,7 +1432,7 @@ config RTC_DRV_AT91RM9200 config RTC_DRV_AT91SAM9 tristate "AT91SAM9 RTT as RTC" depends on ARCH_AT91 || COMPILE_TEST - depends on HAS_IOMEM + depends on OF && HAS_IOMEM select MFD_SYSCON help Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block whichdrivers/rtc/rtc-at91sam9.c +8
-36@@ -340,13 +340,6 @@ static const struct rtc_class_ops at91_rtc_ops = { .alarm_irq_enable = at91_rtc_alarm_irq_enable, }; -static const struct regmap_config gpbr_regmap_config = { - .name ="gpbr" , - .reg_bits =32 , - .val_bits =32 , - .reg_stride =4 , -}; -/* * Initialize and install RTC driver */ @@ -357,6 +350,7 @@ static int at91_rtc_probe(struct platform_device *pdev)int ret, irq;u32 mr;unsigned int sclk_rate; +struct of_phandle_args args; irq =platform_get_irq (pdev,0 );if (irq <0 ) {@@ -382,34 +376,14 @@ static int at91_rtc_probe(struct platform_device *pdev)if (IS_ERR (rtc->rtt))return PTR_ERR (rtc->rtt); -if (!pdev->dev.of_node) { -/* -* TODO: Remove this code chunk when removing non DT board -* support. Remember to remove the gpbr_regmap_config -* variable too. -*/ -void __iomem *gpbr; - - r =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - gpbr =devm_ioremap_resource (&pdev->dev, r); -if (IS_ERR (gpbr)) -return PTR_ERR (gpbr); - - rtc->gpbr =regmap_init_mmio (NULL , gpbr, - &gpbr_regmap_config); - }else { -struct of_phandle_args args; - - ret =of_parse_phandle_with_fixed_args (pdev->dev.of_node, -"atmel,rtt-rtc-time-reg" ,1 ,0 , - &args); -if (ret) -return ret; - - rtc->gpbr =syscon_node_to_regmap (args.np); - rtc->gpbr_offset = args.args[0 ]; - } + ret =of_parse_phandle_with_fixed_args (pdev->dev.of_node, +"atmel,rtt-rtc-time-reg" ,1 ,0 , + &args); +if (ret) +return ret; + rtc->gpbr =syscon_node_to_regmap (args.np); + rtc->gpbr_offset = args.args[0 ];if (IS_ERR (rtc->gpbr)) {dev_err (&pdev->dev,"failed to retrieve gpbr regmap, aborting.\n" );return -ENOMEM ;@@ -561,13 +535,11 @@ static int at91_rtc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); -#ifdef CONFIG_OF static const struct of_device_id at91_rtc_dt_ids[] = { { .compatible ="atmel,at91sam9260-rtt" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, at91_rtc_dt_ids); -#endif static struct platform_driver at91_rtc_driver = { .probe = at91_rtc_probe,
Signature · 5 lines
Nicolas Ferre _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel