• Home
  • Raw
  • Download

Lines Matching +full:re +full:- +full:clocked

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2007-2009 ST-Ericsson AB
4 * Real Time Clock interface for ST-Ericsson AB COH 901 331 RTC.
6 * Based on rtc-pl031.c by Deepak Saxena <dsaxena@plexity.net>
27 /* Indication if current time is valid 32bit (R/-) */
29 /* Read the current time 32bit (R/-) */
58 clk_enable(rtap->clk); in coh901331_interrupt()
60 writel(1, rtap->virtbase + COH901331_IRQ_EVENT); in coh901331_interrupt()
63 * the RTC lives on a lower-clocked line and will in coh901331_interrupt()
65 * clock cycles. The interrupt will be re-enabled when in coh901331_interrupt()
68 writel(0, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_interrupt()
69 clk_disable(rtap->clk); in coh901331_interrupt()
72 rtc_update_irq(rtap->rtc, 1, RTC_AF); in coh901331_interrupt()
81 clk_enable(rtap->clk); in coh901331_read_time()
83 if (!readl(rtap->virtbase + COH901331_VALID)) { in coh901331_read_time()
84 clk_disable(rtap->clk); in coh901331_read_time()
85 return -EINVAL; in coh901331_read_time()
88 rtc_time64_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm); in coh901331_read_time()
89 clk_disable(rtap->clk); in coh901331_read_time()
97 clk_enable(rtap->clk); in coh901331_set_time()
98 writel(rtc_tm_to_time64(tm), rtap->virtbase + COH901331_SET_TIME); in coh901331_set_time()
99 clk_disable(rtap->clk); in coh901331_set_time()
108 clk_enable(rtap->clk); in coh901331_read_alarm()
109 rtc_time64_to_tm(readl(rtap->virtbase + COH901331_ALARM), &alarm->time); in coh901331_read_alarm()
110 alarm->pending = readl(rtap->virtbase + COH901331_IRQ_EVENT) & 1U; in coh901331_read_alarm()
111 alarm->enabled = readl(rtap->virtbase + COH901331_IRQ_MASK) & 1U; in coh901331_read_alarm()
112 clk_disable(rtap->clk); in coh901331_read_alarm()
120 unsigned long time = rtc_tm_to_time64(&alarm->time); in coh901331_set_alarm()
122 clk_enable(rtap->clk); in coh901331_set_alarm()
123 writel(time, rtap->virtbase + COH901331_ALARM); in coh901331_set_alarm()
124 writel(alarm->enabled, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_set_alarm()
125 clk_disable(rtap->clk); in coh901331_set_alarm()
134 clk_enable(rtap->clk); in coh901331_alarm_irq_enable()
136 writel(1, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_alarm_irq_enable()
138 writel(0, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_alarm_irq_enable()
139 clk_disable(rtap->clk); in coh901331_alarm_irq_enable()
157 clk_unprepare(rtap->clk); in coh901331_remove()
168 rtap = devm_kzalloc(&pdev->dev, in coh901331_probe()
171 return -ENOMEM; in coh901331_probe()
173 rtap->virtbase = devm_platform_ioremap_resource(pdev, 0); in coh901331_probe()
174 if (IS_ERR(rtap->virtbase)) in coh901331_probe()
175 return PTR_ERR(rtap->virtbase); in coh901331_probe()
177 rtap->irq = platform_get_irq(pdev, 0); in coh901331_probe()
178 if (devm_request_irq(&pdev->dev, rtap->irq, coh901331_interrupt, 0, in coh901331_probe()
180 return -EIO; in coh901331_probe()
182 rtap->clk = devm_clk_get(&pdev->dev, NULL); in coh901331_probe()
183 if (IS_ERR(rtap->clk)) { in coh901331_probe()
184 ret = PTR_ERR(rtap->clk); in coh901331_probe()
185 dev_err(&pdev->dev, "could not get clock\n"); in coh901331_probe()
189 rtap->rtc = devm_rtc_allocate_device(&pdev->dev); in coh901331_probe()
190 if (IS_ERR(rtap->rtc)) in coh901331_probe()
191 return PTR_ERR(rtap->rtc); in coh901331_probe()
193 rtap->rtc->ops = &coh901331_ops; in coh901331_probe()
194 rtap->rtc->range_max = U32_MAX; in coh901331_probe()
197 ret = clk_prepare_enable(rtap->clk); in coh901331_probe()
199 dev_err(&pdev->dev, "could not enable clock\n"); in coh901331_probe()
202 clk_disable(rtap->clk); in coh901331_probe()
206 ret = rtc_register_device(rtap->rtc); in coh901331_probe()
213 clk_unprepare(rtap->clk); in coh901331_probe()
228 enable_irq_wake(rtap->irq); in coh901331_suspend()
230 clk_enable(rtap->clk); in coh901331_suspend()
231 rtap->irqmaskstore = readl(rtap->virtbase + COH901331_IRQ_MASK); in coh901331_suspend()
232 writel(0, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_suspend()
233 clk_disable(rtap->clk); in coh901331_suspend()
235 clk_unprepare(rtap->clk); in coh901331_suspend()
244 ret = clk_prepare(rtap->clk); in coh901331_resume()
249 disable_irq_wake(rtap->irq); in coh901331_resume()
251 clk_enable(rtap->clk); in coh901331_resume()
252 writel(rtap->irqmaskstore, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_resume()
253 clk_disable(rtap->clk); in coh901331_resume()
265 clk_enable(rtap->clk); in coh901331_shutdown()
266 writel(0, rtap->virtbase + COH901331_IRQ_MASK); in coh901331_shutdown()
267 clk_disable_unprepare(rtap->clk); in coh901331_shutdown()
278 .name = "rtc-coh901331",
289 MODULE_DESCRIPTION("ST-Ericsson AB COH 901 331 RTC Driver");