Lines Matching refs:rtc_dd
81 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_set_time() local
82 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_set_time()
84 if (!rtc_dd->allow_set_time) in pm8xxx_rtc_set_time()
96 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_set_time()
98 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); in pm8xxx_rtc_set_time()
105 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); in pm8xxx_rtc_set_time()
113 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &rtc_ctrl_reg); in pm8xxx_rtc_set_time()
120 rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); in pm8xxx_rtc_set_time()
128 rc = regmap_write(rtc_dd->regmap, regs->write, 0); in pm8xxx_rtc_set_time()
135 rc = regmap_bulk_write(rtc_dd->regmap, regs->write + 1, in pm8xxx_rtc_set_time()
143 rc = regmap_write(rtc_dd->regmap, regs->write, value[0]); in pm8xxx_rtc_set_time()
152 rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); in pm8xxx_rtc_set_time()
161 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); in pm8xxx_rtc_set_time()
169 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_set_time()
180 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_read_time() local
181 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_read_time()
183 rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); in pm8xxx_rtc_read_time()
193 rc = regmap_read(rtc_dd->regmap, regs->read, ®); in pm8xxx_rtc_read_time()
200 rc = regmap_bulk_read(rtc_dd->regmap, regs->read, in pm8xxx_rtc_read_time()
223 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_set_alarm() local
224 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_set_alarm()
233 rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, in pm8xxx_rtc_set_alarm()
238 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_set_alarm()
240 rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, in pm8xxx_rtc_set_alarm()
248 rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, in pm8xxx_rtc_set_alarm()
257 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_set_alarm()
266 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_read_alarm() local
267 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_read_alarm()
269 rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value, in pm8xxx_rtc_read_alarm()
291 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_alarm_irq_enable() local
292 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_alarm_irq_enable()
296 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_alarm_irq_enable()
298 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); in pm8xxx_rtc_alarm_irq_enable()
307 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); in pm8xxx_rtc_alarm_irq_enable()
315 rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, in pm8xxx_rtc_alarm_irq_enable()
324 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_rtc_alarm_irq_enable()
338 struct pm8xxx_rtc *rtc_dd = dev_id; in pm8xxx_alarm_trigger() local
339 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_alarm_trigger()
344 rtc_update_irq(rtc_dd->rtc, 1, RTC_IRQF | RTC_AF); in pm8xxx_alarm_trigger()
346 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_alarm_trigger()
349 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); in pm8xxx_alarm_trigger()
351 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_alarm_trigger()
357 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); in pm8xxx_alarm_trigger()
359 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_alarm_trigger()
360 dev_err(rtc_dd->rtc_dev, in pm8xxx_alarm_trigger()
365 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); in pm8xxx_alarm_trigger()
368 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl2, &ctrl_reg); in pm8xxx_alarm_trigger()
370 dev_err(rtc_dd->rtc_dev, in pm8xxx_alarm_trigger()
376 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl2, ctrl_reg); in pm8xxx_alarm_trigger()
378 dev_err(rtc_dd->rtc_dev, in pm8xxx_alarm_trigger()
385 static int pm8xxx_rtc_enable(struct pm8xxx_rtc *rtc_dd) in pm8xxx_rtc_enable() argument
387 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; in pm8xxx_rtc_enable()
392 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg); in pm8xxx_rtc_enable()
398 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg); in pm8xxx_rtc_enable()
451 struct pm8xxx_rtc *rtc_dd; in pm8xxx_rtc_probe() local
458 rtc_dd = devm_kzalloc(&pdev->dev, sizeof(*rtc_dd), GFP_KERNEL); in pm8xxx_rtc_probe()
459 if (rtc_dd == NULL) in pm8xxx_rtc_probe()
463 spin_lock_init(&rtc_dd->ctrl_reg_lock); in pm8xxx_rtc_probe()
465 rtc_dd->regmap = dev_get_regmap(pdev->dev.parent, NULL); in pm8xxx_rtc_probe()
466 if (!rtc_dd->regmap) { in pm8xxx_rtc_probe()
471 rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); in pm8xxx_rtc_probe()
472 if (rtc_dd->rtc_alarm_irq < 0) in pm8xxx_rtc_probe()
475 rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, in pm8xxx_rtc_probe()
478 rtc_dd->regs = match->data; in pm8xxx_rtc_probe()
479 rtc_dd->rtc_dev = &pdev->dev; in pm8xxx_rtc_probe()
481 rc = pm8xxx_rtc_enable(rtc_dd); in pm8xxx_rtc_probe()
485 platform_set_drvdata(pdev, rtc_dd); in pm8xxx_rtc_probe()
490 rtc_dd->rtc = devm_rtc_allocate_device(&pdev->dev); in pm8xxx_rtc_probe()
491 if (IS_ERR(rtc_dd->rtc)) in pm8xxx_rtc_probe()
492 return PTR_ERR(rtc_dd->rtc); in pm8xxx_rtc_probe()
494 rtc_dd->rtc->ops = &pm8xxx_rtc_ops; in pm8xxx_rtc_probe()
495 rtc_dd->rtc->range_max = U32_MAX; in pm8xxx_rtc_probe()
498 rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->rtc_alarm_irq, in pm8xxx_rtc_probe()
501 "pm8xxx_rtc_alarm", rtc_dd); in pm8xxx_rtc_probe()
507 return rtc_register_device(rtc_dd->rtc); in pm8xxx_rtc_probe()
513 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_resume() local
516 disable_irq_wake(rtc_dd->rtc_alarm_irq); in pm8xxx_rtc_resume()
523 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); in pm8xxx_rtc_suspend() local
526 enable_irq_wake(rtc_dd->rtc_alarm_irq); in pm8xxx_rtc_suspend()