Lines Matching refs:config

85 static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config)  in spear_rtc_clear_interrupt()  argument
90 spin_lock_irqsave(&config->lock, flags); in spear_rtc_clear_interrupt()
91 val = readl(config->ioaddr + STATUS_REG); in spear_rtc_clear_interrupt()
93 writel(val, config->ioaddr + STATUS_REG); in spear_rtc_clear_interrupt()
94 spin_unlock_irqrestore(&config->lock, flags); in spear_rtc_clear_interrupt()
97 static inline void spear_rtc_enable_interrupt(struct spear_rtc_config *config) in spear_rtc_enable_interrupt() argument
101 val = readl(config->ioaddr + CTRL_REG); in spear_rtc_enable_interrupt()
103 spear_rtc_clear_interrupt(config); in spear_rtc_enable_interrupt()
105 writel(val, config->ioaddr + CTRL_REG); in spear_rtc_enable_interrupt()
109 static inline void spear_rtc_disable_interrupt(struct spear_rtc_config *config) in spear_rtc_disable_interrupt() argument
113 val = readl(config->ioaddr + CTRL_REG); in spear_rtc_disable_interrupt()
116 writel(val, config->ioaddr + CTRL_REG); in spear_rtc_disable_interrupt()
120 static inline int is_write_complete(struct spear_rtc_config *config) in is_write_complete() argument
125 spin_lock_irqsave(&config->lock, flags); in is_write_complete()
126 if ((readl(config->ioaddr + STATUS_REG)) & STATUS_FAIL) in is_write_complete()
128 spin_unlock_irqrestore(&config->lock, flags); in is_write_complete()
133 static void rtc_wait_not_busy(struct spear_rtc_config *config) in rtc_wait_not_busy() argument
140 spin_lock_irqsave(&config->lock, flags); in rtc_wait_not_busy()
141 status = readl(config->ioaddr + STATUS_REG); in rtc_wait_not_busy()
142 spin_unlock_irqrestore(&config->lock, flags); in rtc_wait_not_busy()
152 struct spear_rtc_config *config = dev_id; in spear_rtc_irq() local
156 spin_lock(&config->lock); in spear_rtc_irq()
157 irq_data = readl(config->ioaddr + STATUS_REG); in spear_rtc_irq()
158 spin_unlock(&config->lock); in spear_rtc_irq()
161 spear_rtc_clear_interrupt(config); in spear_rtc_irq()
163 rtc_update_irq(config->rtc, 1, events); in spear_rtc_irq()
201 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_read_time() local
205 rtc_wait_not_busy(config); in spear_rtc_read_time()
208 time = readl(config->ioaddr + TIME_REG); in spear_rtc_read_time()
209 date = readl(config->ioaddr + DATE_REG); in spear_rtc_read_time()
210 } while (time == readl(config->ioaddr + TIME_REG)); in spear_rtc_read_time()
232 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_set_time() local
237 rtc_wait_not_busy(config); in spear_rtc_set_time()
242 writel(time, config->ioaddr + TIME_REG); in spear_rtc_set_time()
243 writel(date, config->ioaddr + DATE_REG); in spear_rtc_set_time()
245 return is_write_complete(config); in spear_rtc_set_time()
258 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_read_alarm() local
261 rtc_wait_not_busy(config); in spear_rtc_read_alarm()
263 time = readl(config->ioaddr + ALARM_TIME_REG); in spear_rtc_read_alarm()
264 date = readl(config->ioaddr + ALARM_DATE_REG); in spear_rtc_read_alarm()
273 alm->enabled = readl(config->ioaddr + CTRL_REG) & INT_ENABLE; in spear_rtc_read_alarm()
288 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_set_alarm() local
294 rtc_wait_not_busy(config); in spear_rtc_set_alarm()
301 writel(time, config->ioaddr + ALARM_TIME_REG); in spear_rtc_set_alarm()
302 writel(date, config->ioaddr + ALARM_DATE_REG); in spear_rtc_set_alarm()
303 err = is_write_complete(config); in spear_rtc_set_alarm()
308 spear_rtc_enable_interrupt(config); in spear_rtc_set_alarm()
310 spear_rtc_disable_interrupt(config); in spear_rtc_set_alarm()
317 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_alarm_irq_enable() local
320 spear_rtc_clear_interrupt(config); in spear_alarm_irq_enable()
325 spear_rtc_disable_interrupt(config); in spear_alarm_irq_enable()
329 spear_rtc_enable_interrupt(config); in spear_alarm_irq_enable()
349 struct spear_rtc_config *config; in spear_rtc_probe() local
353 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); in spear_rtc_probe()
354 if (!config) in spear_rtc_probe()
357 config->rtc = devm_rtc_allocate_device(&pdev->dev); in spear_rtc_probe()
358 if (IS_ERR(config->rtc)) in spear_rtc_probe()
359 return PTR_ERR(config->rtc); in spear_rtc_probe()
367 config); in spear_rtc_probe()
374 config->ioaddr = devm_platform_ioremap_resource(pdev, 0); in spear_rtc_probe()
375 if (IS_ERR(config->ioaddr)) in spear_rtc_probe()
376 return PTR_ERR(config->ioaddr); in spear_rtc_probe()
378 config->clk = devm_clk_get(&pdev->dev, NULL); in spear_rtc_probe()
379 if (IS_ERR(config->clk)) in spear_rtc_probe()
380 return PTR_ERR(config->clk); in spear_rtc_probe()
382 status = clk_prepare_enable(config->clk); in spear_rtc_probe()
386 spin_lock_init(&config->lock); in spear_rtc_probe()
387 platform_set_drvdata(pdev, config); in spear_rtc_probe()
389 config->rtc->ops = &spear_rtc_ops; in spear_rtc_probe()
390 config->rtc->range_min = RTC_TIMESTAMP_BEGIN_0000; in spear_rtc_probe()
391 config->rtc->range_max = RTC_TIMESTAMP_END_9999; in spear_rtc_probe()
393 status = devm_rtc_register_device(config->rtc); in spear_rtc_probe()
403 clk_disable_unprepare(config->clk); in spear_rtc_probe()
410 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_remove() local
412 spear_rtc_disable_interrupt(config); in spear_rtc_remove()
413 clk_disable_unprepare(config->clk); in spear_rtc_remove()
421 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_suspend() local
427 config->irq_wake = 1; in spear_rtc_suspend()
429 spear_rtc_disable_interrupt(config); in spear_rtc_suspend()
430 clk_disable(config->clk); in spear_rtc_suspend()
439 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_resume() local
445 if (config->irq_wake) { in spear_rtc_resume()
447 config->irq_wake = 0; in spear_rtc_resume()
450 clk_enable(config->clk); in spear_rtc_resume()
451 spear_rtc_enable_interrupt(config); in spear_rtc_resume()
462 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_shutdown() local
464 spear_rtc_disable_interrupt(config); in spear_rtc_shutdown()
465 clk_disable(config->clk); in spear_rtc_shutdown()