Lines Matching full:rtc

3  * RTC driver for NXP LPC178x/18xx/43xx Real-Time Clock (RTC)
15 #include <linux/rtc.h>
17 /* LPC24xx RTC register offsets and bits */
63 struct rtc_device *rtc; member
70 struct lpc24xx_rtc *rtc = dev_get_drvdata(dev); in lpc24xx_rtc_set_time() local
72 /* Disable RTC during update */ in lpc24xx_rtc_set_time()
73 rtc_writel(rtc, LPC24XX_CCR, LPC178X_CCALEN); in lpc24xx_rtc_set_time()
75 rtc_writel(rtc, LPC24XX_SEC, tm->tm_sec); in lpc24xx_rtc_set_time()
76 rtc_writel(rtc, LPC24XX_MIN, tm->tm_min); in lpc24xx_rtc_set_time()
77 rtc_writel(rtc, LPC24XX_HOUR, tm->tm_hour); in lpc24xx_rtc_set_time()
78 rtc_writel(rtc, LPC24XX_DOW, tm->tm_wday); in lpc24xx_rtc_set_time()
79 rtc_writel(rtc, LPC24XX_DOM, tm->tm_mday); in lpc24xx_rtc_set_time()
80 rtc_writel(rtc, LPC24XX_DOY, tm->tm_yday); in lpc24xx_rtc_set_time()
81 rtc_writel(rtc, LPC24XX_MONTH, tm->tm_mon); in lpc24xx_rtc_set_time()
82 rtc_writel(rtc, LPC24XX_YEAR, tm->tm_year); in lpc24xx_rtc_set_time()
84 rtc_writel(rtc, LPC24XX_CCR, LPC24XX_CLKEN | LPC178X_CCALEN); in lpc24xx_rtc_set_time()
91 struct lpc24xx_rtc *rtc = dev_get_drvdata(dev); in lpc24xx_rtc_read_time() local
94 ct0 = rtc_readl(rtc, LPC24XX_CTIME0); in lpc24xx_rtc_read_time()
95 ct1 = rtc_readl(rtc, LPC24XX_CTIME1); in lpc24xx_rtc_read_time()
96 ct2 = rtc_readl(rtc, LPC24XX_CTIME2); in lpc24xx_rtc_read_time()
112 struct lpc24xx_rtc *rtc = dev_get_drvdata(dev); in lpc24xx_rtc_read_alarm() local
115 tm->tm_sec = rtc_readl(rtc, LPC24XX_ALSEC); in lpc24xx_rtc_read_alarm()
116 tm->tm_min = rtc_readl(rtc, LPC24XX_ALMIN); in lpc24xx_rtc_read_alarm()
117 tm->tm_hour = rtc_readl(rtc, LPC24XX_ALHOUR); in lpc24xx_rtc_read_alarm()
118 tm->tm_mday = rtc_readl(rtc, LPC24XX_ALDOM); in lpc24xx_rtc_read_alarm()
119 tm->tm_wday = rtc_readl(rtc, LPC24XX_ALDOW); in lpc24xx_rtc_read_alarm()
120 tm->tm_yday = rtc_readl(rtc, LPC24XX_ALDOY); in lpc24xx_rtc_read_alarm()
121 tm->tm_mon = rtc_readl(rtc, LPC24XX_ALMON); in lpc24xx_rtc_read_alarm()
122 tm->tm_year = rtc_readl(rtc, LPC24XX_ALYEAR); in lpc24xx_rtc_read_alarm()
124 wkalrm->enabled = rtc_readl(rtc, LPC24XX_AMR) == 0; in lpc24xx_rtc_read_alarm()
125 wkalrm->pending = !!(rtc_readl(rtc, LPC24XX_ILR) & LPC24XX_RTCCIF); in lpc24xx_rtc_read_alarm()
132 struct lpc24xx_rtc *rtc = dev_get_drvdata(dev); in lpc24xx_rtc_set_alarm() local
136 rtc_writel(rtc, LPC24XX_AMR, LPC24XX_ALARM_DISABLE); in lpc24xx_rtc_set_alarm()
138 rtc_writel(rtc, LPC24XX_ALSEC, tm->tm_sec); in lpc24xx_rtc_set_alarm()
139 rtc_writel(rtc, LPC24XX_ALMIN, tm->tm_min); in lpc24xx_rtc_set_alarm()
140 rtc_writel(rtc, LPC24XX_ALHOUR, tm->tm_hour); in lpc24xx_rtc_set_alarm()
141 rtc_writel(rtc, LPC24XX_ALDOM, tm->tm_mday); in lpc24xx_rtc_set_alarm()
142 rtc_writel(rtc, LPC24XX_ALDOW, tm->tm_wday); in lpc24xx_rtc_set_alarm()
143 rtc_writel(rtc, LPC24XX_ALDOY, tm->tm_yday); in lpc24xx_rtc_set_alarm()
144 rtc_writel(rtc, LPC24XX_ALMON, tm->tm_mon); in lpc24xx_rtc_set_alarm()
145 rtc_writel(rtc, LPC24XX_ALYEAR, tm->tm_year); in lpc24xx_rtc_set_alarm()
148 rtc_writel(rtc, LPC24XX_AMR, 0); in lpc24xx_rtc_set_alarm()
155 struct lpc24xx_rtc *rtc = dev_get_drvdata(dev); in lpc24xx_rtc_alarm_irq_enable() local
158 rtc_writel(rtc, LPC24XX_AMR, 0); in lpc24xx_rtc_alarm_irq_enable()
160 rtc_writel(rtc, LPC24XX_AMR, LPC24XX_ALARM_DISABLE); in lpc24xx_rtc_alarm_irq_enable()
168 struct lpc24xx_rtc *rtc = data; in lpc24xx_rtc_interrupt() local
172 rtc_iir = rtc_readl(rtc, LPC24XX_ILR); in lpc24xx_rtc_interrupt()
175 rtc_writel(rtc, LPC24XX_AMR, LPC24XX_ALARM_DISABLE); in lpc24xx_rtc_interrupt()
179 rtc_writel(rtc, LPC24XX_ILR, rtc_iir); in lpc24xx_rtc_interrupt()
180 rtc_update_irq(rtc->rtc, 1, events); in lpc24xx_rtc_interrupt()
195 struct lpc24xx_rtc *rtc; in lpc24xx_rtc_probe() local
198 rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); in lpc24xx_rtc_probe()
199 if (!rtc) in lpc24xx_rtc_probe()
202 rtc->rtc_base = devm_platform_ioremap_resource(pdev, 0); in lpc24xx_rtc_probe()
203 if (IS_ERR(rtc->rtc_base)) in lpc24xx_rtc_probe()
204 return PTR_ERR(rtc->rtc_base); in lpc24xx_rtc_probe()
210 rtc->clk_rtc = devm_clk_get(&pdev->dev, "rtc"); in lpc24xx_rtc_probe()
211 if (IS_ERR(rtc->clk_rtc)) { in lpc24xx_rtc_probe()
212 dev_err(&pdev->dev, "error getting rtc clock\n"); in lpc24xx_rtc_probe()
213 return PTR_ERR(rtc->clk_rtc); in lpc24xx_rtc_probe()
216 rtc->clk_reg = devm_clk_get(&pdev->dev, "reg"); in lpc24xx_rtc_probe()
217 if (IS_ERR(rtc->clk_reg)) { in lpc24xx_rtc_probe()
219 return PTR_ERR(rtc->clk_reg); in lpc24xx_rtc_probe()
222 ret = clk_prepare_enable(rtc->clk_rtc); in lpc24xx_rtc_probe()
224 dev_err(&pdev->dev, "unable to enable rtc clock\n"); in lpc24xx_rtc_probe()
228 ret = clk_prepare_enable(rtc->clk_reg); in lpc24xx_rtc_probe()
234 platform_set_drvdata(pdev, rtc); in lpc24xx_rtc_probe()
237 rtc_writel(rtc, LPC24XX_ILR, LPC24XX_RTCCIF | LPC24XX_RTCALF); in lpc24xx_rtc_probe()
239 /* Enable RTC count */ in lpc24xx_rtc_probe()
240 rtc_writel(rtc, LPC24XX_CCR, LPC24XX_CLKEN | LPC178X_CCALEN); in lpc24xx_rtc_probe()
243 pdev->name, rtc); in lpc24xx_rtc_probe()
249 rtc->rtc = devm_rtc_device_register(&pdev->dev, "lpc24xx-rtc", in lpc24xx_rtc_probe()
251 if (IS_ERR(rtc->rtc)) { in lpc24xx_rtc_probe()
252 dev_err(&pdev->dev, "can't register rtc device\n"); in lpc24xx_rtc_probe()
253 ret = PTR_ERR(rtc->rtc); in lpc24xx_rtc_probe()
260 clk_disable_unprepare(rtc->clk_reg); in lpc24xx_rtc_probe()
262 clk_disable_unprepare(rtc->clk_rtc); in lpc24xx_rtc_probe()
268 struct lpc24xx_rtc *rtc = platform_get_drvdata(pdev); in lpc24xx_rtc_remove() local
271 rtc_writel(rtc, LPC24XX_AMR, LPC24XX_ALARM_DISABLE); in lpc24xx_rtc_remove()
272 rtc_writel(rtc, LPC24XX_CIIR, 0); in lpc24xx_rtc_remove()
274 rtc_writel(rtc, LPC24XX_CCR, LPC178X_CCALEN); in lpc24xx_rtc_remove()
276 clk_disable_unprepare(rtc->clk_rtc); in lpc24xx_rtc_remove()
277 clk_disable_unprepare(rtc->clk_reg); in lpc24xx_rtc_remove()
281 { .compatible = "nxp,lpc1788-rtc" },
290 .name = "lpc24xx-rtc",
297 MODULE_DESCRIPTION("RTC driver for the LPC178x/18xx/408x/43xx SoCs");