Lines Matching refs:config
88 static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config) in spear_rtc_clear_interrupt() argument
93 spin_lock_irqsave(&config->lock, flags); in spear_rtc_clear_interrupt()
94 val = readl(config->ioaddr + STATUS_REG); in spear_rtc_clear_interrupt()
96 writel(val, config->ioaddr + STATUS_REG); in spear_rtc_clear_interrupt()
97 spin_unlock_irqrestore(&config->lock, flags); in spear_rtc_clear_interrupt()
100 static inline void spear_rtc_enable_interrupt(struct spear_rtc_config *config) in spear_rtc_enable_interrupt() argument
104 val = readl(config->ioaddr + CTRL_REG); in spear_rtc_enable_interrupt()
106 spear_rtc_clear_interrupt(config); in spear_rtc_enable_interrupt()
108 writel(val, config->ioaddr + CTRL_REG); in spear_rtc_enable_interrupt()
112 static inline void spear_rtc_disable_interrupt(struct spear_rtc_config *config) in spear_rtc_disable_interrupt() argument
116 val = readl(config->ioaddr + CTRL_REG); in spear_rtc_disable_interrupt()
119 writel(val, config->ioaddr + CTRL_REG); in spear_rtc_disable_interrupt()
123 static inline int is_write_complete(struct spear_rtc_config *config) in is_write_complete() argument
128 spin_lock_irqsave(&config->lock, flags); in is_write_complete()
129 if ((readl(config->ioaddr + STATUS_REG)) & STATUS_FAIL) in is_write_complete()
131 spin_unlock_irqrestore(&config->lock, flags); in is_write_complete()
136 static void rtc_wait_not_busy(struct spear_rtc_config *config) in rtc_wait_not_busy() argument
143 spin_lock_irqsave(&config->lock, flags); in rtc_wait_not_busy()
144 status = readl(config->ioaddr + STATUS_REG); in rtc_wait_not_busy()
145 spin_unlock_irqrestore(&config->lock, flags); in rtc_wait_not_busy()
155 struct spear_rtc_config *config = dev_id; in spear_rtc_irq() local
159 spin_lock_irqsave(&config->lock, flags); in spear_rtc_irq()
160 irq_data = readl(config->ioaddr + STATUS_REG); in spear_rtc_irq()
161 spin_unlock_irqrestore(&config->lock, flags); in spear_rtc_irq()
164 spear_rtc_clear_interrupt(config); in spear_rtc_irq()
166 rtc_update_irq(config->rtc, 1, events); in spear_rtc_irq()
208 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_read_time() local
212 rtc_wait_not_busy(config); in spear_rtc_read_time()
214 time = readl(config->ioaddr + TIME_REG); in spear_rtc_read_time()
215 date = readl(config->ioaddr + DATE_REG); in spear_rtc_read_time()
237 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_set_time() local
243 rtc_wait_not_busy(config); in spear_rtc_set_time()
248 writel(time, config->ioaddr + TIME_REG); in spear_rtc_set_time()
249 writel(date, config->ioaddr + DATE_REG); in spear_rtc_set_time()
251 return is_write_complete(config); in spear_rtc_set_time()
264 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_read_alarm() local
267 rtc_wait_not_busy(config); in spear_rtc_read_alarm()
269 time = readl(config->ioaddr + ALARM_TIME_REG); in spear_rtc_read_alarm()
270 date = readl(config->ioaddr + ALARM_DATE_REG); in spear_rtc_read_alarm()
279 alm->enabled = readl(config->ioaddr + CTRL_REG) & INT_ENABLE; in spear_rtc_read_alarm()
294 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_rtc_set_alarm() local
301 rtc_wait_not_busy(config); in spear_rtc_set_alarm()
308 writel(time, config->ioaddr + ALARM_TIME_REG); in spear_rtc_set_alarm()
309 writel(date, config->ioaddr + ALARM_DATE_REG); in spear_rtc_set_alarm()
310 err = is_write_complete(config); in spear_rtc_set_alarm()
315 spear_rtc_enable_interrupt(config); in spear_rtc_set_alarm()
317 spear_rtc_disable_interrupt(config); in spear_rtc_set_alarm()
324 struct spear_rtc_config *config = dev_get_drvdata(dev); in spear_alarm_irq_enable() local
327 spear_rtc_clear_interrupt(config); in spear_alarm_irq_enable()
332 spear_rtc_disable_interrupt(config); in spear_alarm_irq_enable()
336 spear_rtc_enable_interrupt(config); in spear_alarm_irq_enable()
357 struct spear_rtc_config *config; in spear_rtc_probe() local
367 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); in spear_rtc_probe()
368 if (!config) { in spear_rtc_probe()
381 config); in spear_rtc_probe()
388 config->ioaddr = devm_ioremap_resource(&pdev->dev, res); in spear_rtc_probe()
389 if (IS_ERR(config->ioaddr)) in spear_rtc_probe()
390 return PTR_ERR(config->ioaddr); in spear_rtc_probe()
392 config->clk = devm_clk_get(&pdev->dev, NULL); in spear_rtc_probe()
393 if (IS_ERR(config->clk)) in spear_rtc_probe()
394 return PTR_ERR(config->clk); in spear_rtc_probe()
396 status = clk_prepare_enable(config->clk); in spear_rtc_probe()
400 spin_lock_init(&config->lock); in spear_rtc_probe()
401 platform_set_drvdata(pdev, config); in spear_rtc_probe()
403 config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, in spear_rtc_probe()
405 if (IS_ERR(config->rtc)) { in spear_rtc_probe()
407 PTR_ERR(config->rtc)); in spear_rtc_probe()
408 status = PTR_ERR(config->rtc); in spear_rtc_probe()
412 config->rtc->uie_unsupported = 1; in spear_rtc_probe()
421 clk_disable_unprepare(config->clk); in spear_rtc_probe()
428 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_remove() local
430 spear_rtc_disable_interrupt(config); in spear_rtc_remove()
431 clk_disable_unprepare(config->clk); in spear_rtc_remove()
441 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_suspend() local
447 config->irq_wake = 1; in spear_rtc_suspend()
449 spear_rtc_disable_interrupt(config); in spear_rtc_suspend()
450 clk_disable(config->clk); in spear_rtc_suspend()
459 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_resume() local
465 if (config->irq_wake) { in spear_rtc_resume()
467 config->irq_wake = 0; in spear_rtc_resume()
470 clk_enable(config->clk); in spear_rtc_resume()
471 spear_rtc_enable_interrupt(config); in spear_rtc_resume()
482 struct spear_rtc_config *config = platform_get_drvdata(pdev); in spear_rtc_shutdown() local
484 spear_rtc_disable_interrupt(config); in spear_rtc_shutdown()
485 clk_disable(config->clk); in spear_rtc_shutdown()