Lines Matching refs:twl_rtc
139 struct twl_rtc { struct
158 static int twl_rtc_read_u8(struct twl_rtc *twl_rtc, u8 *data, u8 reg) in twl_rtc_read_u8() argument
162 ret = twl_i2c_read_u8(TWL_MODULE_RTC, data, (twl_rtc->reg_map[reg])); in twl_rtc_read_u8()
171 static int twl_rtc_write_u8(struct twl_rtc *twl_rtc, u8 data, u8 reg) in twl_rtc_write_u8() argument
175 ret = twl_i2c_write_u8(TWL_MODULE_RTC, data, (twl_rtc->reg_map[reg])); in twl_rtc_write_u8()
185 static int set_rtc_irq_bit(struct twl_rtc *twl_rtc, unsigned char bit) in set_rtc_irq_bit() argument
191 if (twl_rtc->rtc_irq_bits & bit) in set_rtc_irq_bit()
194 val = twl_rtc->rtc_irq_bits | bit; in set_rtc_irq_bit()
196 ret = twl_rtc_write_u8(twl_rtc, val, REG_RTC_INTERRUPTS_REG); in set_rtc_irq_bit()
198 twl_rtc->rtc_irq_bits = val; in set_rtc_irq_bit()
206 static int mask_rtc_irq_bit(struct twl_rtc *twl_rtc, unsigned char bit) in mask_rtc_irq_bit() argument
212 if (!(twl_rtc->rtc_irq_bits & bit)) in mask_rtc_irq_bit()
215 val = twl_rtc->rtc_irq_bits & ~bit; in mask_rtc_irq_bit()
216 ret = twl_rtc_write_u8(twl_rtc, val, REG_RTC_INTERRUPTS_REG); in mask_rtc_irq_bit()
218 twl_rtc->rtc_irq_bits = val; in mask_rtc_irq_bit()
226 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_alarm_irq_enable() local
231 ret = set_rtc_irq_bit(twl_rtc, in twl_rtc_alarm_irq_enable()
233 if (device_can_wakeup(dev) && !twl_rtc->wake_enabled) { in twl_rtc_alarm_irq_enable()
235 twl_rtc->wake_enabled = true; in twl_rtc_alarm_irq_enable()
238 ret = mask_rtc_irq_bit(twl_rtc, in twl_rtc_alarm_irq_enable()
240 if (twl_rtc->wake_enabled) { in twl_rtc_alarm_irq_enable()
242 twl_rtc->wake_enabled = false; in twl_rtc_alarm_irq_enable()
260 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_read_time() local
266 ret = twl_rtc_read_u8(twl_rtc, &save_control, REG_RTC_CTRL_REG); in twl_rtc_read_time()
272 if (twl_rtc->class == TWL_6030) { in twl_rtc_read_time()
275 ret = twl_rtc_write_u8(twl_rtc, save_control, in twl_rtc_read_time()
289 if (twl_rtc->class == TWL_6030) in twl_rtc_read_time()
292 ret = twl_rtc_write_u8(twl_rtc, rtc_control, REG_RTC_CTRL_REG); in twl_rtc_read_time()
299 (twl_rtc->reg_map[REG_SECONDS_REG]), ALL_TIME_REGS); in twl_rtc_read_time()
307 if (twl_rtc->class == TWL_6030) { in twl_rtc_read_time()
308 ret = twl_rtc_write_u8(twl_rtc, save_control, REG_RTC_CTRL_REG); in twl_rtc_read_time()
328 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_set_time() local
341 ret = twl_rtc_read_u8(twl_rtc, &save_control, REG_RTC_CTRL_REG); in twl_rtc_set_time()
346 ret = twl_rtc_write_u8(twl_rtc, save_control, REG_RTC_CTRL_REG); in twl_rtc_set_time()
352 (twl_rtc->reg_map[REG_SECONDS_REG]), ALL_TIME_REGS); in twl_rtc_set_time()
360 ret = twl_rtc_write_u8(twl_rtc, save_control, REG_RTC_CTRL_REG); in twl_rtc_set_time()
371 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_read_alarm() local
376 twl_rtc->reg_map[REG_ALARM_SECONDS_REG], ALL_TIME_REGS); in twl_rtc_read_alarm()
391 if (twl_rtc->rtc_irq_bits & BIT_RTC_INTERRUPTS_REG_IT_ALARM_M) in twl_rtc_read_alarm()
399 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_set_alarm() local
417 twl_rtc->reg_map[REG_ALARM_SECONDS_REG], ALL_TIME_REGS); in twl_rtc_set_alarm()
431 struct twl_rtc *twl_rtc = data; in twl_rtc_interrupt() local
437 res = twl_rtc_read_u8(twl_rtc, &rd_reg, REG_RTC_STATUS_REG); in twl_rtc_interrupt()
451 res = twl_rtc_write_u8(twl_rtc, BIT_RTC_STATUS_REG_ALARM_M, in twl_rtc_interrupt()
456 if (twl_rtc->class == TWL_4030) { in twl_rtc_interrupt()
475 rtc_update_irq(twl_rtc->rtc, 1, events); in twl_rtc_interrupt()
506 struct twl_rtc *twl_rtc; in twl_rtc_probe() local
521 twl_rtc = devm_kzalloc(&pdev->dev, sizeof(*twl_rtc), GFP_KERNEL); in twl_rtc_probe()
522 if (!twl_rtc) in twl_rtc_probe()
526 twl_rtc->class = TWL_4030; in twl_rtc_probe()
527 twl_rtc->reg_map = (u8 *)twl4030_rtc_reg_map; in twl_rtc_probe()
529 twl_rtc->class = TWL_6030; in twl_rtc_probe()
530 twl_rtc->reg_map = (u8 *)twl6030_rtc_reg_map; in twl_rtc_probe()
536 ret = twl_rtc_read_u8(twl_rtc, &rd_reg, REG_RTC_STATUS_REG); in twl_rtc_probe()
547 ret = twl_rtc_write_u8(twl_rtc, rd_reg, REG_RTC_STATUS_REG); in twl_rtc_probe()
551 if (twl_rtc->class == TWL_6030) { in twl_rtc_probe()
558 ret = twl_rtc_write_u8(twl_rtc, BIT_RTC_CTRL_REG_STOP_RTC_M, in twl_rtc_probe()
564 ret = twl_rtc_write_u8(twl_rtc, 0, REG_RTC_INTERRUPTS_REG); in twl_rtc_probe()
569 ret = twl_rtc_read_u8(twl_rtc, &twl_rtc->rtc_irq_bits, in twl_rtc_probe()
574 platform_set_drvdata(pdev, twl_rtc); in twl_rtc_probe()
577 twl_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, in twl_rtc_probe()
579 if (IS_ERR(twl_rtc->rtc)) in twl_rtc_probe()
580 return PTR_ERR(twl_rtc->rtc); in twl_rtc_probe()
585 dev_name(&twl_rtc->rtc->dev), twl_rtc); in twl_rtc_probe()
602 devm_rtc_nvmem_register(twl_rtc->rtc, &nvmem_cfg); in twl_rtc_probe()
607 devm_rtc_nvmem_register(twl_rtc->rtc, &nvmem_cfg); in twl_rtc_probe()
612 devm_rtc_nvmem_register(twl_rtc->rtc, &nvmem_cfg); in twl_rtc_probe()
624 struct twl_rtc *twl_rtc = platform_get_drvdata(pdev); in twl_rtc_remove() local
627 mask_rtc_irq_bit(twl_rtc, BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); in twl_rtc_remove()
628 mask_rtc_irq_bit(twl_rtc, BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); in twl_rtc_remove()
629 if (twl_rtc->class == TWL_6030) { in twl_rtc_remove()
639 struct twl_rtc *twl_rtc = platform_get_drvdata(pdev); in twl_rtc_shutdown() local
643 mask_rtc_irq_bit(twl_rtc, BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); in twl_rtc_shutdown()
649 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_suspend() local
651 twl_rtc->irqstat = twl_rtc->rtc_irq_bits; in twl_rtc_suspend()
653 mask_rtc_irq_bit(twl_rtc, BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); in twl_rtc_suspend()
659 struct twl_rtc *twl_rtc = dev_get_drvdata(dev); in twl_rtc_resume() local
661 set_rtc_irq_bit(twl_rtc, twl_rtc->irqstat); in twl_rtc_resume()