19aa449beSKevin Wells /* 29aa449beSKevin Wells * Copyright (C) 2010 NXP Semiconductors 39aa449beSKevin Wells * 49aa449beSKevin Wells * This program is free software; you can redistribute it and/or modify 59aa449beSKevin Wells * it under the terms of the GNU General Public License as published by 69aa449beSKevin Wells * the Free Software Foundation; either version 2 of the License, or 79aa449beSKevin Wells * (at your option) any later version. 89aa449beSKevin Wells * 99aa449beSKevin Wells * You should have received a copy of the GNU General Public License along 109aa449beSKevin Wells * with this program; if not, write to the Free Software Foundation, Inc., 119aa449beSKevin Wells * 675 Mass Ave, Cambridge, MA 02139, USA. 129aa449beSKevin Wells */ 139aa449beSKevin Wells 149aa449beSKevin Wells #include <linux/kernel.h> 159aa449beSKevin Wells #include <linux/module.h> 169aa449beSKevin Wells #include <linux/init.h> 179aa449beSKevin Wells #include <linux/platform_device.h> 189aa449beSKevin Wells #include <linux/spinlock.h> 199aa449beSKevin Wells #include <linux/rtc.h> 209aa449beSKevin Wells #include <linux/slab.h> 219aa449beSKevin Wells #include <linux/io.h> 22e862e7c4SRoland Stigge #include <linux/of.h> 239aa449beSKevin Wells 249aa449beSKevin Wells /* 259aa449beSKevin Wells * Clock and Power control register offsets 269aa449beSKevin Wells */ 279aa449beSKevin Wells #define LPC32XX_RTC_UCOUNT 0x00 289aa449beSKevin Wells #define LPC32XX_RTC_DCOUNT 0x04 299aa449beSKevin Wells #define LPC32XX_RTC_MATCH0 0x08 309aa449beSKevin Wells #define LPC32XX_RTC_MATCH1 0x0C 319aa449beSKevin Wells #define LPC32XX_RTC_CTRL 0x10 329aa449beSKevin Wells #define LPC32XX_RTC_INTSTAT 0x14 339aa449beSKevin Wells #define LPC32XX_RTC_KEY 0x18 349aa449beSKevin Wells #define LPC32XX_RTC_SRAM 0x80 359aa449beSKevin Wells 369aa449beSKevin Wells #define LPC32XX_RTC_CTRL_MATCH0 (1 << 0) 379aa449beSKevin Wells #define LPC32XX_RTC_CTRL_MATCH1 (1 << 1) 389aa449beSKevin Wells #define LPC32XX_RTC_CTRL_ONSW_MATCH0 (1 << 2) 399aa449beSKevin Wells #define LPC32XX_RTC_CTRL_ONSW_MATCH1 (1 << 3) 409aa449beSKevin Wells #define LPC32XX_RTC_CTRL_SW_RESET (1 << 4) 419aa449beSKevin Wells #define LPC32XX_RTC_CTRL_CNTR_DIS (1 << 6) 429aa449beSKevin Wells #define LPC32XX_RTC_CTRL_ONSW_FORCE_HI (1 << 7) 439aa449beSKevin Wells 449aa449beSKevin Wells #define LPC32XX_RTC_INTSTAT_MATCH0 (1 << 0) 459aa449beSKevin Wells #define LPC32XX_RTC_INTSTAT_MATCH1 (1 << 1) 469aa449beSKevin Wells #define LPC32XX_RTC_INTSTAT_ONSW (1 << 2) 479aa449beSKevin Wells 489aa449beSKevin Wells #define LPC32XX_RTC_KEY_ONSW_LOADVAL 0xB5C13F27 499aa449beSKevin Wells 509aa449beSKevin Wells #define RTC_NAME "rtc-lpc32xx" 519aa449beSKevin Wells 529aa449beSKevin Wells #define rtc_readl(dev, reg) \ 539aa449beSKevin Wells __raw_readl((dev)->rtc_base + (reg)) 549aa449beSKevin Wells #define rtc_writel(dev, reg, val) \ 559aa449beSKevin Wells __raw_writel((val), (dev)->rtc_base + (reg)) 569aa449beSKevin Wells 579aa449beSKevin Wells struct lpc32xx_rtc { 589aa449beSKevin Wells void __iomem *rtc_base; 599aa449beSKevin Wells int irq; 609aa449beSKevin Wells unsigned char alarm_enabled; 619aa449beSKevin Wells struct rtc_device *rtc; 629aa449beSKevin Wells spinlock_t lock; 639aa449beSKevin Wells }; 649aa449beSKevin Wells 659aa449beSKevin Wells static int lpc32xx_rtc_read_time(struct device *dev, struct rtc_time *time) 669aa449beSKevin Wells { 679aa449beSKevin Wells unsigned long elapsed_sec; 689aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); 699aa449beSKevin Wells 709aa449beSKevin Wells elapsed_sec = rtc_readl(rtc, LPC32XX_RTC_UCOUNT); 719aa449beSKevin Wells rtc_time_to_tm(elapsed_sec, time); 729aa449beSKevin Wells 73*ab62670eSAlexandre Belloni return 0; 749aa449beSKevin Wells } 759aa449beSKevin Wells 769aa449beSKevin Wells static int lpc32xx_rtc_set_mmss(struct device *dev, unsigned long secs) 779aa449beSKevin Wells { 789aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); 799aa449beSKevin Wells u32 tmp; 809aa449beSKevin Wells 819aa449beSKevin Wells spin_lock_irq(&rtc->lock); 829aa449beSKevin Wells 839aa449beSKevin Wells /* RTC must be disabled during count update */ 849aa449beSKevin Wells tmp = rtc_readl(rtc, LPC32XX_RTC_CTRL); 859aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp | LPC32XX_RTC_CTRL_CNTR_DIS); 869aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_UCOUNT, secs); 879aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_DCOUNT, 0xFFFFFFFF - secs); 889aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp &= ~LPC32XX_RTC_CTRL_CNTR_DIS); 899aa449beSKevin Wells 909aa449beSKevin Wells spin_unlock_irq(&rtc->lock); 919aa449beSKevin Wells 929aa449beSKevin Wells return 0; 939aa449beSKevin Wells } 949aa449beSKevin Wells 959aa449beSKevin Wells static int lpc32xx_rtc_read_alarm(struct device *dev, 969aa449beSKevin Wells struct rtc_wkalrm *wkalrm) 979aa449beSKevin Wells { 989aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); 999aa449beSKevin Wells 1009aa449beSKevin Wells rtc_time_to_tm(rtc_readl(rtc, LPC32XX_RTC_MATCH0), &wkalrm->time); 1019aa449beSKevin Wells wkalrm->enabled = rtc->alarm_enabled; 1029aa449beSKevin Wells wkalrm->pending = !!(rtc_readl(rtc, LPC32XX_RTC_INTSTAT) & 1039aa449beSKevin Wells LPC32XX_RTC_INTSTAT_MATCH0); 1049aa449beSKevin Wells 1059aa449beSKevin Wells return rtc_valid_tm(&wkalrm->time); 1069aa449beSKevin Wells } 1079aa449beSKevin Wells 1089aa449beSKevin Wells static int lpc32xx_rtc_set_alarm(struct device *dev, 1099aa449beSKevin Wells struct rtc_wkalrm *wkalrm) 1109aa449beSKevin Wells { 1119aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); 1129aa449beSKevin Wells unsigned long alarmsecs; 1139aa449beSKevin Wells u32 tmp; 1149aa449beSKevin Wells int ret; 1159aa449beSKevin Wells 1169aa449beSKevin Wells ret = rtc_tm_to_time(&wkalrm->time, &alarmsecs); 1179aa449beSKevin Wells if (ret < 0) { 1189aa449beSKevin Wells dev_warn(dev, "Failed to convert time: %d\n", ret); 1199aa449beSKevin Wells return ret; 1209aa449beSKevin Wells } 1219aa449beSKevin Wells 1229aa449beSKevin Wells spin_lock_irq(&rtc->lock); 1239aa449beSKevin Wells 1249aa449beSKevin Wells /* Disable alarm during update */ 1259aa449beSKevin Wells tmp = rtc_readl(rtc, LPC32XX_RTC_CTRL); 1269aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp & ~LPC32XX_RTC_CTRL_MATCH0); 1279aa449beSKevin Wells 1289aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_MATCH0, alarmsecs); 1299aa449beSKevin Wells 1309aa449beSKevin Wells rtc->alarm_enabled = wkalrm->enabled; 1319aa449beSKevin Wells if (wkalrm->enabled) { 1329aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_INTSTAT, 1339aa449beSKevin Wells LPC32XX_RTC_INTSTAT_MATCH0); 1349aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp | 1359aa449beSKevin Wells LPC32XX_RTC_CTRL_MATCH0); 1369aa449beSKevin Wells } 1379aa449beSKevin Wells 1389aa449beSKevin Wells spin_unlock_irq(&rtc->lock); 1399aa449beSKevin Wells 1409aa449beSKevin Wells return 0; 1419aa449beSKevin Wells } 1429aa449beSKevin Wells 1439aa449beSKevin Wells static int lpc32xx_rtc_alarm_irq_enable(struct device *dev, 1449aa449beSKevin Wells unsigned int enabled) 1459aa449beSKevin Wells { 1469aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev_get_drvdata(dev); 1479aa449beSKevin Wells u32 tmp; 1489aa449beSKevin Wells 1499aa449beSKevin Wells spin_lock_irq(&rtc->lock); 1509aa449beSKevin Wells tmp = rtc_readl(rtc, LPC32XX_RTC_CTRL); 1519aa449beSKevin Wells 1529aa449beSKevin Wells if (enabled) { 1539aa449beSKevin Wells rtc->alarm_enabled = 1; 1549aa449beSKevin Wells tmp |= LPC32XX_RTC_CTRL_MATCH0; 1559aa449beSKevin Wells } else { 1569aa449beSKevin Wells rtc->alarm_enabled = 0; 1579aa449beSKevin Wells tmp &= ~LPC32XX_RTC_CTRL_MATCH0; 1589aa449beSKevin Wells } 1599aa449beSKevin Wells 1609aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp); 1619aa449beSKevin Wells spin_unlock_irq(&rtc->lock); 1629aa449beSKevin Wells 1639aa449beSKevin Wells return 0; 1649aa449beSKevin Wells } 1659aa449beSKevin Wells 1669aa449beSKevin Wells static irqreturn_t lpc32xx_rtc_alarm_interrupt(int irq, void *dev) 1679aa449beSKevin Wells { 1689aa449beSKevin Wells struct lpc32xx_rtc *rtc = dev; 1699aa449beSKevin Wells 1709aa449beSKevin Wells spin_lock(&rtc->lock); 1719aa449beSKevin Wells 1729aa449beSKevin Wells /* Disable alarm interrupt */ 1739aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, 1749aa449beSKevin Wells rtc_readl(rtc, LPC32XX_RTC_CTRL) & 1759aa449beSKevin Wells ~LPC32XX_RTC_CTRL_MATCH0); 1769aa449beSKevin Wells rtc->alarm_enabled = 0; 1779aa449beSKevin Wells 1789aa449beSKevin Wells /* 1799aa449beSKevin Wells * Write a large value to the match value so the RTC won't 1809aa449beSKevin Wells * keep firing the match status 1819aa449beSKevin Wells */ 1829aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_MATCH0, 0xFFFFFFFF); 1839aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_INTSTAT, LPC32XX_RTC_INTSTAT_MATCH0); 1849aa449beSKevin Wells 1859aa449beSKevin Wells spin_unlock(&rtc->lock); 1869aa449beSKevin Wells 1879aa449beSKevin Wells rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); 1889aa449beSKevin Wells 1899aa449beSKevin Wells return IRQ_HANDLED; 1909aa449beSKevin Wells } 1919aa449beSKevin Wells 1929aa449beSKevin Wells static const struct rtc_class_ops lpc32xx_rtc_ops = { 1939aa449beSKevin Wells .read_time = lpc32xx_rtc_read_time, 1949aa449beSKevin Wells .set_mmss = lpc32xx_rtc_set_mmss, 1959aa449beSKevin Wells .read_alarm = lpc32xx_rtc_read_alarm, 1969aa449beSKevin Wells .set_alarm = lpc32xx_rtc_set_alarm, 1979aa449beSKevin Wells .alarm_irq_enable = lpc32xx_rtc_alarm_irq_enable, 1989aa449beSKevin Wells }; 1999aa449beSKevin Wells 2005a167f45SGreg Kroah-Hartman static int lpc32xx_rtc_probe(struct platform_device *pdev) 2019aa449beSKevin Wells { 2029aa449beSKevin Wells struct resource *res; 2039aa449beSKevin Wells struct lpc32xx_rtc *rtc; 2049aa449beSKevin Wells int rtcirq; 2059aa449beSKevin Wells u32 tmp; 2069aa449beSKevin Wells 2079aa449beSKevin Wells rtcirq = platform_get_irq(pdev, 0); 208529af7d1SVladimir Zapolskiy if (rtcirq < 0) { 2099aa449beSKevin Wells dev_warn(&pdev->dev, "Can't get interrupt resource\n"); 2109aa449beSKevin Wells rtcirq = -1; 2119aa449beSKevin Wells } 2129aa449beSKevin Wells 2139aa449beSKevin Wells rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); 2145c336b0aSJingoo Han if (unlikely(!rtc)) 2159aa449beSKevin Wells return -ENOMEM; 2165c336b0aSJingoo Han 2179aa449beSKevin Wells rtc->irq = rtcirq; 2189aa449beSKevin Wells 2197c1d69eeSJulia Lawall res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2207c1d69eeSJulia Lawall rtc->rtc_base = devm_ioremap_resource(&pdev->dev, res); 2217c1d69eeSJulia Lawall if (IS_ERR(rtc->rtc_base)) 2227c1d69eeSJulia Lawall return PTR_ERR(rtc->rtc_base); 2239aa449beSKevin Wells 2249aa449beSKevin Wells spin_lock_init(&rtc->lock); 2259aa449beSKevin Wells 2269aa449beSKevin Wells /* 22725985edcSLucas De Marchi * The RTC is on a separate power domain and can keep it's state 2289aa449beSKevin Wells * across a chip power cycle. If the RTC has never been previously 2299aa449beSKevin Wells * setup, then set it up now for the first time. 2309aa449beSKevin Wells */ 2319aa449beSKevin Wells tmp = rtc_readl(rtc, LPC32XX_RTC_CTRL); 2329aa449beSKevin Wells if (rtc_readl(rtc, LPC32XX_RTC_KEY) != LPC32XX_RTC_KEY_ONSW_LOADVAL) { 2339aa449beSKevin Wells tmp &= ~(LPC32XX_RTC_CTRL_SW_RESET | 2349aa449beSKevin Wells LPC32XX_RTC_CTRL_CNTR_DIS | 2359aa449beSKevin Wells LPC32XX_RTC_CTRL_MATCH0 | 2369aa449beSKevin Wells LPC32XX_RTC_CTRL_MATCH1 | 2379aa449beSKevin Wells LPC32XX_RTC_CTRL_ONSW_MATCH0 | 2389aa449beSKevin Wells LPC32XX_RTC_CTRL_ONSW_MATCH1 | 2399aa449beSKevin Wells LPC32XX_RTC_CTRL_ONSW_FORCE_HI); 2409aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, tmp); 2419aa449beSKevin Wells 2429aa449beSKevin Wells /* Clear latched interrupt states */ 2439aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_MATCH0, 0xFFFFFFFF); 2449aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_INTSTAT, 2459aa449beSKevin Wells LPC32XX_RTC_INTSTAT_MATCH0 | 2469aa449beSKevin Wells LPC32XX_RTC_INTSTAT_MATCH1 | 2479aa449beSKevin Wells LPC32XX_RTC_INTSTAT_ONSW); 2489aa449beSKevin Wells 2499aa449beSKevin Wells /* Write key value to RTC so it won't reload on reset */ 2509aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_KEY, 2519aa449beSKevin Wells LPC32XX_RTC_KEY_ONSW_LOADVAL); 2529aa449beSKevin Wells } else { 2539aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, 2549aa449beSKevin Wells tmp & ~LPC32XX_RTC_CTRL_MATCH0); 2559aa449beSKevin Wells } 2569aa449beSKevin Wells 2579aa449beSKevin Wells platform_set_drvdata(pdev, rtc); 2589aa449beSKevin Wells 259bbd05b2dSJingoo Han rtc->rtc = devm_rtc_device_register(&pdev->dev, RTC_NAME, 260bbd05b2dSJingoo Han &lpc32xx_rtc_ops, THIS_MODULE); 2619aa449beSKevin Wells if (IS_ERR(rtc->rtc)) { 2629aa449beSKevin Wells dev_err(&pdev->dev, "Can't get RTC\n"); 2639aa449beSKevin Wells return PTR_ERR(rtc->rtc); 2649aa449beSKevin Wells } 2659aa449beSKevin Wells 2669aa449beSKevin Wells /* 2679aa449beSKevin Wells * IRQ is enabled after device registration in case alarm IRQ 2689aa449beSKevin Wells * is pending upon suspend exit. 2699aa449beSKevin Wells */ 2709aa449beSKevin Wells if (rtc->irq >= 0) { 2719aa449beSKevin Wells if (devm_request_irq(&pdev->dev, rtc->irq, 2729aa449beSKevin Wells lpc32xx_rtc_alarm_interrupt, 2732f6e5f94SYong Zhang 0, pdev->name, rtc) < 0) { 2749aa449beSKevin Wells dev_warn(&pdev->dev, "Can't request interrupt.\n"); 2759aa449beSKevin Wells rtc->irq = -1; 2769aa449beSKevin Wells } else { 2779aa449beSKevin Wells device_init_wakeup(&pdev->dev, 1); 2789aa449beSKevin Wells } 2799aa449beSKevin Wells } 2809aa449beSKevin Wells 2819aa449beSKevin Wells return 0; 2829aa449beSKevin Wells } 2839aa449beSKevin Wells 2845a167f45SGreg Kroah-Hartman static int lpc32xx_rtc_remove(struct platform_device *pdev) 2859aa449beSKevin Wells { 2869aa449beSKevin Wells struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev); 2879aa449beSKevin Wells 2889aa449beSKevin Wells if (rtc->irq >= 0) 2899aa449beSKevin Wells device_init_wakeup(&pdev->dev, 0); 2909aa449beSKevin Wells 2919aa449beSKevin Wells return 0; 2929aa449beSKevin Wells } 2939aa449beSKevin Wells 2949aa449beSKevin Wells #ifdef CONFIG_PM 2959aa449beSKevin Wells static int lpc32xx_rtc_suspend(struct device *dev) 2969aa449beSKevin Wells { 2979aa449beSKevin Wells struct platform_device *pdev = to_platform_device(dev); 2989aa449beSKevin Wells struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev); 2999aa449beSKevin Wells 3009aa449beSKevin Wells if (rtc->irq >= 0) { 3019aa449beSKevin Wells if (device_may_wakeup(&pdev->dev)) 3029aa449beSKevin Wells enable_irq_wake(rtc->irq); 3039aa449beSKevin Wells else 3049aa449beSKevin Wells disable_irq_wake(rtc->irq); 3059aa449beSKevin Wells } 3069aa449beSKevin Wells 3079aa449beSKevin Wells return 0; 3089aa449beSKevin Wells } 3099aa449beSKevin Wells 3109aa449beSKevin Wells static int lpc32xx_rtc_resume(struct device *dev) 3119aa449beSKevin Wells { 3129aa449beSKevin Wells struct platform_device *pdev = to_platform_device(dev); 3139aa449beSKevin Wells struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev); 3149aa449beSKevin Wells 3159aa449beSKevin Wells if (rtc->irq >= 0 && device_may_wakeup(&pdev->dev)) 3169aa449beSKevin Wells disable_irq_wake(rtc->irq); 3179aa449beSKevin Wells 3189aa449beSKevin Wells return 0; 3199aa449beSKevin Wells } 3209aa449beSKevin Wells 3219aa449beSKevin Wells /* Unconditionally disable the alarm */ 3229aa449beSKevin Wells static int lpc32xx_rtc_freeze(struct device *dev) 3239aa449beSKevin Wells { 3249aa449beSKevin Wells struct platform_device *pdev = to_platform_device(dev); 3259aa449beSKevin Wells struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev); 3269aa449beSKevin Wells 3279aa449beSKevin Wells spin_lock_irq(&rtc->lock); 3289aa449beSKevin Wells 3299aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, 3309aa449beSKevin Wells rtc_readl(rtc, LPC32XX_RTC_CTRL) & 3319aa449beSKevin Wells ~LPC32XX_RTC_CTRL_MATCH0); 3329aa449beSKevin Wells 3339aa449beSKevin Wells spin_unlock_irq(&rtc->lock); 3349aa449beSKevin Wells 3359aa449beSKevin Wells return 0; 3369aa449beSKevin Wells } 3379aa449beSKevin Wells 3389aa449beSKevin Wells static int lpc32xx_rtc_thaw(struct device *dev) 3399aa449beSKevin Wells { 3409aa449beSKevin Wells struct platform_device *pdev = to_platform_device(dev); 3419aa449beSKevin Wells struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev); 3429aa449beSKevin Wells 3439aa449beSKevin Wells if (rtc->alarm_enabled) { 3449aa449beSKevin Wells spin_lock_irq(&rtc->lock); 3459aa449beSKevin Wells 3469aa449beSKevin Wells rtc_writel(rtc, LPC32XX_RTC_CTRL, 3479aa449beSKevin Wells rtc_readl(rtc, LPC32XX_RTC_CTRL) | 3489aa449beSKevin Wells LPC32XX_RTC_CTRL_MATCH0); 3499aa449beSKevin Wells 3509aa449beSKevin Wells spin_unlock_irq(&rtc->lock); 3519aa449beSKevin Wells } 3529aa449beSKevin Wells 3539aa449beSKevin Wells return 0; 3549aa449beSKevin Wells } 3559aa449beSKevin Wells 3569aa449beSKevin Wells static const struct dev_pm_ops lpc32xx_rtc_pm_ops = { 3579aa449beSKevin Wells .suspend = lpc32xx_rtc_suspend, 3589aa449beSKevin Wells .resume = lpc32xx_rtc_resume, 3599aa449beSKevin Wells .freeze = lpc32xx_rtc_freeze, 3609aa449beSKevin Wells .thaw = lpc32xx_rtc_thaw, 3619aa449beSKevin Wells .restore = lpc32xx_rtc_resume 3629aa449beSKevin Wells }; 3639aa449beSKevin Wells 3649aa449beSKevin Wells #define LPC32XX_RTC_PM_OPS (&lpc32xx_rtc_pm_ops) 3659aa449beSKevin Wells #else 3669aa449beSKevin Wells #define LPC32XX_RTC_PM_OPS NULL 3679aa449beSKevin Wells #endif 3689aa449beSKevin Wells 369e862e7c4SRoland Stigge #ifdef CONFIG_OF 370e862e7c4SRoland Stigge static const struct of_device_id lpc32xx_rtc_match[] = { 371e862e7c4SRoland Stigge { .compatible = "nxp,lpc3220-rtc" }, 372e862e7c4SRoland Stigge { } 373e862e7c4SRoland Stigge }; 374e862e7c4SRoland Stigge MODULE_DEVICE_TABLE(of, lpc32xx_rtc_match); 375e862e7c4SRoland Stigge #endif 376e862e7c4SRoland Stigge 3779aa449beSKevin Wells static struct platform_driver lpc32xx_rtc_driver = { 3789aa449beSKevin Wells .probe = lpc32xx_rtc_probe, 3795a167f45SGreg Kroah-Hartman .remove = lpc32xx_rtc_remove, 3809aa449beSKevin Wells .driver = { 3819aa449beSKevin Wells .name = RTC_NAME, 382e862e7c4SRoland Stigge .pm = LPC32XX_RTC_PM_OPS, 383e862e7c4SRoland Stigge .of_match_table = of_match_ptr(lpc32xx_rtc_match), 3849aa449beSKevin Wells }, 3859aa449beSKevin Wells }; 3869aa449beSKevin Wells 3870c4eae66SAxel Lin module_platform_driver(lpc32xx_rtc_driver); 3889aa449beSKevin Wells 3899aa449beSKevin Wells MODULE_AUTHOR("Kevin Wells <wellsk40@gmail.com"); 3909aa449beSKevin Wells MODULE_DESCRIPTION("RTC driver for the LPC32xx SoC"); 3919aa449beSKevin Wells MODULE_LICENSE("GPL"); 3929aa449beSKevin Wells MODULE_ALIAS("platform:rtc-lpc32xx"); 393