1df17f631Sdmitry pervushin /* 2df17f631Sdmitry pervushin * Freescale STMP37XX/STMP378X Real Time Clock driver 3df17f631Sdmitry pervushin * 4df17f631Sdmitry pervushin * Copyright (c) 2007 Sigmatel, Inc. 5df17f631Sdmitry pervushin * Peter Hartley, <peter.hartley@sigmatel.com> 6df17f631Sdmitry pervushin * 7df17f631Sdmitry pervushin * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. 8df17f631Sdmitry pervushin * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. 97e794cb7SWolfram Sang * Copyright 2011 Wolfram Sang, Pengutronix e.K. 10df17f631Sdmitry pervushin */ 11df17f631Sdmitry pervushin 12df17f631Sdmitry pervushin /* 13df17f631Sdmitry pervushin * The code contained herein is licensed under the GNU General Public 14df17f631Sdmitry pervushin * License. You may obtain a copy of the GNU General Public License 15df17f631Sdmitry pervushin * Version 2 or later at the following locations: 16df17f631Sdmitry pervushin * 17df17f631Sdmitry pervushin * http://www.opensource.org/licenses/gpl-license.html 18df17f631Sdmitry pervushin * http://www.gnu.org/copyleft/gpl.html 19df17f631Sdmitry pervushin */ 20df17f631Sdmitry pervushin #include <linux/kernel.h> 21df17f631Sdmitry pervushin #include <linux/module.h> 22b5167159SWolfram Sang #include <linux/io.h> 23df17f631Sdmitry pervushin #include <linux/init.h> 24df17f631Sdmitry pervushin #include <linux/platform_device.h> 25df17f631Sdmitry pervushin #include <linux/interrupt.h> 2628a0c883SLothar Waßmann #include <linux/delay.h> 27df17f631Sdmitry pervushin #include <linux/rtc.h> 285a0e3ad6STejun Heo #include <linux/slab.h> 29dd8d20a3SMarek Vasut #include <linux/of_device.h> 30c8a6046eSSachin Kamat #include <linux/of.h> 311a71fb84SWolfram Sang #include <linux/stmp_device.h> 321a71fb84SWolfram Sang #include <linux/stmp3xxx_rtc_wdt.h> 33df17f631Sdmitry pervushin 3447eac337SWolfram Sang #define STMP3XXX_RTC_CTRL 0x0 35b5167159SWolfram Sang #define STMP3XXX_RTC_CTRL_SET 0x4 36b5167159SWolfram Sang #define STMP3XXX_RTC_CTRL_CLR 0x8 3747eac337SWolfram Sang #define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001 3847eac337SWolfram Sang #define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002 3947eac337SWolfram Sang #define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004 401a71fb84SWolfram Sang #define STMP3XXX_RTC_CTRL_WATCHDOGEN 0x00000010 4147eac337SWolfram Sang 4247eac337SWolfram Sang #define STMP3XXX_RTC_STAT 0x10 4347eac337SWolfram Sang #define STMP3XXX_RTC_STAT_STALE_SHIFT 16 4447eac337SWolfram Sang #define STMP3XXX_RTC_STAT_RTC_PRESENT 0x80000000 4547eac337SWolfram Sang 4647eac337SWolfram Sang #define STMP3XXX_RTC_SECONDS 0x30 4747eac337SWolfram Sang 4847eac337SWolfram Sang #define STMP3XXX_RTC_ALARM 0x40 4947eac337SWolfram Sang 501a71fb84SWolfram Sang #define STMP3XXX_RTC_WATCHDOG 0x50 511a71fb84SWolfram Sang 5247eac337SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0 0x60 53b5167159SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0_SET 0x64 54b5167159SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0_CLR 0x68 5547eac337SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN 0x00000002 5647eac337SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0_ALARM_EN 0x00000004 5747eac337SWolfram Sang #define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE 0x00000080 58df17f631Sdmitry pervushin 591a71fb84SWolfram Sang #define STMP3XXX_RTC_PERSISTENT1 0x70 601a71fb84SWolfram Sang /* missing bitmask in headers */ 611a71fb84SWolfram Sang #define STMP3XXX_RTC_PERSISTENT1_FORCE_UPDATER 0x80000000 621a71fb84SWolfram Sang 63df17f631Sdmitry pervushin struct stmp3xxx_rtc_data { 64df17f631Sdmitry pervushin struct rtc_device *rtc; 65df17f631Sdmitry pervushin void __iomem *io; 667e794cb7SWolfram Sang int irq_alarm; 67df17f631Sdmitry pervushin }; 68df17f631Sdmitry pervushin 691a71fb84SWolfram Sang #if IS_ENABLED(CONFIG_STMP3XXX_RTC_WATCHDOG) 701a71fb84SWolfram Sang /** 711a71fb84SWolfram Sang * stmp3xxx_wdt_set_timeout - configure the watchdog inside the STMP3xxx RTC 721a71fb84SWolfram Sang * @dev: the parent device of the watchdog (= the RTC) 731a71fb84SWolfram Sang * @timeout: the desired value for the timeout register of the watchdog. 741a71fb84SWolfram Sang * 0 disables the watchdog 751a71fb84SWolfram Sang * 761a71fb84SWolfram Sang * The watchdog needs one register and two bits which are in the RTC domain. 771a71fb84SWolfram Sang * To handle the resource conflict, the RTC driver will create another 781a71fb84SWolfram Sang * platform_device for the watchdog driver as a child of the RTC device. 791a71fb84SWolfram Sang * The watchdog driver is passed the below accessor function via platform_data 801a71fb84SWolfram Sang * to configure the watchdog. Locking is not needed because accessing SET/CLR 811a71fb84SWolfram Sang * registers is atomic. 821a71fb84SWolfram Sang */ 831a71fb84SWolfram Sang 841a71fb84SWolfram Sang static void stmp3xxx_wdt_set_timeout(struct device *dev, u32 timeout) 851a71fb84SWolfram Sang { 861a71fb84SWolfram Sang struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 871a71fb84SWolfram Sang 881a71fb84SWolfram Sang if (timeout) { 891a71fb84SWolfram Sang writel(timeout, rtc_data->io + STMP3XXX_RTC_WATCHDOG); 901a71fb84SWolfram Sang writel(STMP3XXX_RTC_CTRL_WATCHDOGEN, 911a71fb84SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL + STMP_OFFSET_REG_SET); 921a71fb84SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT1_FORCE_UPDATER, 931a71fb84SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT1 + STMP_OFFSET_REG_SET); 941a71fb84SWolfram Sang } else { 951a71fb84SWolfram Sang writel(STMP3XXX_RTC_CTRL_WATCHDOGEN, 961a71fb84SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL + STMP_OFFSET_REG_CLR); 971a71fb84SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT1_FORCE_UPDATER, 981a71fb84SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT1 + STMP_OFFSET_REG_CLR); 991a71fb84SWolfram Sang } 1001a71fb84SWolfram Sang } 1011a71fb84SWolfram Sang 1021a71fb84SWolfram Sang static struct stmp3xxx_wdt_pdata wdt_pdata = { 1031a71fb84SWolfram Sang .wdt_set_timeout = stmp3xxx_wdt_set_timeout, 1041a71fb84SWolfram Sang }; 1051a71fb84SWolfram Sang 1061a71fb84SWolfram Sang static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev) 1071a71fb84SWolfram Sang { 1081a71fb84SWolfram Sang struct platform_device *wdt_pdev = 1091a71fb84SWolfram Sang platform_device_alloc("stmp3xxx_rtc_wdt", rtc_pdev->id); 1101a71fb84SWolfram Sang 1111a71fb84SWolfram Sang if (wdt_pdev) { 1121a71fb84SWolfram Sang wdt_pdev->dev.parent = &rtc_pdev->dev; 1131a71fb84SWolfram Sang wdt_pdev->dev.platform_data = &wdt_pdata; 1141a71fb84SWolfram Sang platform_device_add(wdt_pdev); 1151a71fb84SWolfram Sang } 1161a71fb84SWolfram Sang } 1171a71fb84SWolfram Sang #else 1181a71fb84SWolfram Sang static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev) 1191a71fb84SWolfram Sang { 1201a71fb84SWolfram Sang } 1211a71fb84SWolfram Sang #endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */ 1221a71fb84SWolfram Sang 12328a0c883SLothar Waßmann static int stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data) 124df17f631Sdmitry pervushin { 12528a0c883SLothar Waßmann int timeout = 5000; /* 3ms according to i.MX28 Ref Manual */ 126df17f631Sdmitry pervushin /* 12728a0c883SLothar Waßmann * The i.MX28 Applications Processor Reference Manual, Rev. 1, 2010 12828a0c883SLothar Waßmann * states: 12928a0c883SLothar Waßmann * | The order in which registers are updated is 13028a0c883SLothar Waßmann * | Persistent 0, 1, 2, 3, 4, 5, Alarm, Seconds. 13128a0c883SLothar Waßmann * | (This list is in bitfield order, from LSB to MSB, as they would 13228a0c883SLothar Waßmann * | appear in the STALE_REGS and NEW_REGS bitfields of the HW_RTC_STAT 13328a0c883SLothar Waßmann * | register. For example, the Seconds register corresponds to 13428a0c883SLothar Waßmann * | STALE_REGS or NEW_REGS containing 0x80.) 135df17f631Sdmitry pervushin */ 13628a0c883SLothar Waßmann do { 13728a0c883SLothar Waßmann if (!(readl(rtc_data->io + STMP3XXX_RTC_STAT) & 13828a0c883SLothar Waßmann (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT))) 13928a0c883SLothar Waßmann return 0; 14028a0c883SLothar Waßmann udelay(1); 14128a0c883SLothar Waßmann } while (--timeout > 0); 14228a0c883SLothar Waßmann return (readl(rtc_data->io + STMP3XXX_RTC_STAT) & 14328a0c883SLothar Waßmann (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) ? -ETIME : 0; 144df17f631Sdmitry pervushin } 145df17f631Sdmitry pervushin 146df17f631Sdmitry pervushin /* Time read/write */ 147df17f631Sdmitry pervushin static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) 148df17f631Sdmitry pervushin { 14928a0c883SLothar Waßmann int ret; 150df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 151df17f631Sdmitry pervushin 15228a0c883SLothar Waßmann ret = stmp3xxx_wait_time(rtc_data); 15328a0c883SLothar Waßmann if (ret) 15428a0c883SLothar Waßmann return ret; 15528a0c883SLothar Waßmann 156b5167159SWolfram Sang rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm); 157df17f631Sdmitry pervushin return 0; 158df17f631Sdmitry pervushin } 159df17f631Sdmitry pervushin 160df17f631Sdmitry pervushin static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t) 161df17f631Sdmitry pervushin { 162df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 163df17f631Sdmitry pervushin 164b5167159SWolfram Sang writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS); 16528a0c883SLothar Waßmann return stmp3xxx_wait_time(rtc_data); 166df17f631Sdmitry pervushin } 167df17f631Sdmitry pervushin 168df17f631Sdmitry pervushin /* interrupt(s) handler */ 169df17f631Sdmitry pervushin static irqreturn_t stmp3xxx_rtc_interrupt(int irq, void *dev_id) 170df17f631Sdmitry pervushin { 171df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev_id); 1727e794cb7SWolfram Sang u32 status = readl(rtc_data->io + STMP3XXX_RTC_CTRL); 173df17f631Sdmitry pervushin 17447eac337SWolfram Sang if (status & STMP3XXX_RTC_CTRL_ALARM_IRQ) { 175b5167159SWolfram Sang writel(STMP3XXX_RTC_CTRL_ALARM_IRQ, 176b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 1777e794cb7SWolfram Sang rtc_update_irq(rtc_data->rtc, 1, RTC_AF | RTC_IRQF); 178df17f631Sdmitry pervushin return IRQ_HANDLED; 179df17f631Sdmitry pervushin } 180df17f631Sdmitry pervushin 1817e794cb7SWolfram Sang return IRQ_NONE; 1827e794cb7SWolfram Sang } 1837e794cb7SWolfram Sang 184df17f631Sdmitry pervushin static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) 185df17f631Sdmitry pervushin { 186df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 187df17f631Sdmitry pervushin 188df17f631Sdmitry pervushin if (enabled) { 189b5167159SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 190b5167159SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN, 191b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT0_SET); 192b5167159SWolfram Sang writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 193b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL_SET); 194df17f631Sdmitry pervushin } else { 195b5167159SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 196b5167159SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN, 197b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); 198b5167159SWolfram Sang writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 199b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 200df17f631Sdmitry pervushin } 201df17f631Sdmitry pervushin return 0; 202df17f631Sdmitry pervushin } 203df17f631Sdmitry pervushin 204df17f631Sdmitry pervushin static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) 205df17f631Sdmitry pervushin { 206df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 207df17f631Sdmitry pervushin 208b5167159SWolfram Sang rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), &alm->time); 209df17f631Sdmitry pervushin return 0; 210df17f631Sdmitry pervushin } 211df17f631Sdmitry pervushin 212df17f631Sdmitry pervushin static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 213df17f631Sdmitry pervushin { 214df17f631Sdmitry pervushin unsigned long t; 215df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 216df17f631Sdmitry pervushin 217df17f631Sdmitry pervushin rtc_tm_to_time(&alm->time, &t); 218b5167159SWolfram Sang writel(t, rtc_data->io + STMP3XXX_RTC_ALARM); 2197e794cb7SWolfram Sang 2207e794cb7SWolfram Sang stmp3xxx_alarm_irq_enable(dev, alm->enabled); 2217e794cb7SWolfram Sang 222df17f631Sdmitry pervushin return 0; 223df17f631Sdmitry pervushin } 224df17f631Sdmitry pervushin 225df17f631Sdmitry pervushin static struct rtc_class_ops stmp3xxx_rtc_ops = { 226df17f631Sdmitry pervushin .alarm_irq_enable = 227df17f631Sdmitry pervushin stmp3xxx_alarm_irq_enable, 228df17f631Sdmitry pervushin .read_time = stmp3xxx_rtc_gettime, 229df17f631Sdmitry pervushin .set_mmss = stmp3xxx_rtc_set_mmss, 230df17f631Sdmitry pervushin .read_alarm = stmp3xxx_rtc_read_alarm, 231df17f631Sdmitry pervushin .set_alarm = stmp3xxx_rtc_set_alarm, 232df17f631Sdmitry pervushin }; 233df17f631Sdmitry pervushin 234df17f631Sdmitry pervushin static int stmp3xxx_rtc_remove(struct platform_device *pdev) 235df17f631Sdmitry pervushin { 236df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data = platform_get_drvdata(pdev); 237df17f631Sdmitry pervushin 238df17f631Sdmitry pervushin if (!rtc_data) 239df17f631Sdmitry pervushin return 0; 240df17f631Sdmitry pervushin 2417e794cb7SWolfram Sang writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 242b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 243df17f631Sdmitry pervushin 244df17f631Sdmitry pervushin return 0; 245df17f631Sdmitry pervushin } 246df17f631Sdmitry pervushin 247df17f631Sdmitry pervushin static int stmp3xxx_rtc_probe(struct platform_device *pdev) 248df17f631Sdmitry pervushin { 249df17f631Sdmitry pervushin struct stmp3xxx_rtc_data *rtc_data; 250df17f631Sdmitry pervushin struct resource *r; 251df17f631Sdmitry pervushin int err; 252df17f631Sdmitry pervushin 25387a81420SJingoo Han rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL); 254df17f631Sdmitry pervushin if (!rtc_data) 255df17f631Sdmitry pervushin return -ENOMEM; 256df17f631Sdmitry pervushin 257df17f631Sdmitry pervushin r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 258df17f631Sdmitry pervushin if (!r) { 259df17f631Sdmitry pervushin dev_err(&pdev->dev, "failed to get resource\n"); 26087a81420SJingoo Han return -ENXIO; 261df17f631Sdmitry pervushin } 262df17f631Sdmitry pervushin 26387a81420SJingoo Han rtc_data->io = devm_ioremap(&pdev->dev, r->start, resource_size(r)); 264df17f631Sdmitry pervushin if (!rtc_data->io) { 265df17f631Sdmitry pervushin dev_err(&pdev->dev, "ioremap failed\n"); 26687a81420SJingoo Han return -EIO; 267df17f631Sdmitry pervushin } 268df17f631Sdmitry pervushin 269df17f631Sdmitry pervushin rtc_data->irq_alarm = platform_get_irq(pdev, 0); 270df17f631Sdmitry pervushin 271b5167159SWolfram Sang if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & 27247eac337SWolfram Sang STMP3XXX_RTC_STAT_RTC_PRESENT)) { 273df17f631Sdmitry pervushin dev_err(&pdev->dev, "no device onboard\n"); 27487a81420SJingoo Han return -ENODEV; 275df17f631Sdmitry pervushin } 276df17f631Sdmitry pervushin 277a91d2babSWolfram Sang platform_set_drvdata(pdev, rtc_data); 278a91d2babSWolfram Sang 2794e80b188SFabio Estevam err = stmp_reset_block(rtc_data->io); 2804e80b188SFabio Estevam if (err) { 2814e80b188SFabio Estevam dev_err(&pdev->dev, "stmp_reset_block failed: %d\n", err); 2824e80b188SFabio Estevam return err; 2834e80b188SFabio Estevam } 2844e80b188SFabio Estevam 285b5167159SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 28647eac337SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | 28747eac337SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, 288b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); 289a91d2babSWolfram Sang 2907e794cb7SWolfram Sang writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | 2917e794cb7SWolfram Sang STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 2927e794cb7SWolfram Sang rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 2937e794cb7SWolfram Sang 29487a81420SJingoo Han rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, 295df17f631Sdmitry pervushin &stmp3xxx_rtc_ops, THIS_MODULE); 296dfd2a178SJingoo Han if (IS_ERR(rtc_data->rtc)) 297dfd2a178SJingoo Han return PTR_ERR(rtc_data->rtc); 298df17f631Sdmitry pervushin 29987a81420SJingoo Han err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm, 30087a81420SJingoo Han stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev); 301df17f631Sdmitry pervushin if (err) { 302df17f631Sdmitry pervushin dev_err(&pdev->dev, "Cannot claim IRQ%d\n", 303df17f631Sdmitry pervushin rtc_data->irq_alarm); 304dfd2a178SJingoo Han return err; 305df17f631Sdmitry pervushin } 306df17f631Sdmitry pervushin 3071a71fb84SWolfram Sang stmp3xxx_wdt_register(pdev); 308df17f631Sdmitry pervushin return 0; 309df17f631Sdmitry pervushin } 310df17f631Sdmitry pervushin 311ef69a7f0SJingoo Han #ifdef CONFIG_PM_SLEEP 312ef69a7f0SJingoo Han static int stmp3xxx_rtc_suspend(struct device *dev) 313df17f631Sdmitry pervushin { 314df17f631Sdmitry pervushin return 0; 315df17f631Sdmitry pervushin } 316df17f631Sdmitry pervushin 317ef69a7f0SJingoo Han static int stmp3xxx_rtc_resume(struct device *dev) 318df17f631Sdmitry pervushin { 319ef69a7f0SJingoo Han struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 320df17f631Sdmitry pervushin 32136d1da1dSShawn Guo stmp_reset_block(rtc_data->io); 322b5167159SWolfram Sang writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 32347eac337SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | 32447eac337SWolfram Sang STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, 325b5167159SWolfram Sang rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); 326df17f631Sdmitry pervushin return 0; 327df17f631Sdmitry pervushin } 328df17f631Sdmitry pervushin #endif 329df17f631Sdmitry pervushin 330ef69a7f0SJingoo Han static SIMPLE_DEV_PM_OPS(stmp3xxx_rtc_pm_ops, stmp3xxx_rtc_suspend, 331ef69a7f0SJingoo Han stmp3xxx_rtc_resume); 332ef69a7f0SJingoo Han 333dd8d20a3SMarek Vasut static const struct of_device_id rtc_dt_ids[] = { 334dd8d20a3SMarek Vasut { .compatible = "fsl,stmp3xxx-rtc", }, 335dd8d20a3SMarek Vasut { /* sentinel */ } 336dd8d20a3SMarek Vasut }; 337dd8d20a3SMarek Vasut MODULE_DEVICE_TABLE(of, rtc_dt_ids); 338dd8d20a3SMarek Vasut 339df17f631Sdmitry pervushin static struct platform_driver stmp3xxx_rtcdrv = { 340df17f631Sdmitry pervushin .probe = stmp3xxx_rtc_probe, 341df17f631Sdmitry pervushin .remove = stmp3xxx_rtc_remove, 342df17f631Sdmitry pervushin .driver = { 343df17f631Sdmitry pervushin .name = "stmp3xxx-rtc", 344df17f631Sdmitry pervushin .owner = THIS_MODULE, 345ef69a7f0SJingoo Han .pm = &stmp3xxx_rtc_pm_ops, 346*462a465bSSachin Kamat .of_match_table = rtc_dt_ids, 347df17f631Sdmitry pervushin }, 348df17f631Sdmitry pervushin }; 349df17f631Sdmitry pervushin 3500c4eae66SAxel Lin module_platform_driver(stmp3xxx_rtcdrv); 351df17f631Sdmitry pervushin 352df17f631Sdmitry pervushin MODULE_DESCRIPTION("STMP3xxx RTC Driver"); 3537e794cb7SWolfram Sang MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com> and " 3547e794cb7SWolfram Sang "Wolfram Sang <w.sang@pengutronix.de>"); 355df17f631Sdmitry pervushin MODULE_LICENSE("GPL"); 356