Lines Matching full:bbnsm

42 static u32 bbnsm_read_counter(struct bbnsm_rtc *bbnsm)  in bbnsm_read_counter()  argument
52 regmap_read(bbnsm->regmap, BBNSM_RTC_MS, &rtc_msb); in bbnsm_read_counter()
54 regmap_read(bbnsm->regmap, BBNSM_RTC_LS, &rtc_lsb); in bbnsm_read_counter()
64 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_read_time() local
68 regmap_read(bbnsm->regmap, BBNSM_CTRL, &val); in bbnsm_rtc_read_time()
72 time = bbnsm_read_counter(bbnsm); in bbnsm_rtc_read_time()
80 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_set_time() local
84 regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, 0); in bbnsm_rtc_set_time()
87 regmap_write(bbnsm->regmap, BBNSM_RTC_LS, time << CNTR_TO_SECS_SH); in bbnsm_rtc_set_time()
88 regmap_write(bbnsm->regmap, BBNSM_RTC_MS, time >> (32 - CNTR_TO_SECS_SH)); in bbnsm_rtc_set_time()
91 regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN); in bbnsm_rtc_set_time()
98 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_read_alarm() local
101 regmap_read(bbnsm->regmap, BBNSM_TA, &bbnsm_ta); in bbnsm_rtc_read_alarm()
104 regmap_read(bbnsm->regmap, BBNSM_EVENTS, &bbnsm_events); in bbnsm_rtc_read_alarm()
112 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_alarm_irq_enable() local
115 regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN_MSK, enable ? TA_EN : TA_DIS); in bbnsm_rtc_alarm_irq_enable()
117 regmap_update_bits(bbnsm->regmap, BBNSM_INT_EN, TA_EN_MSK, enable ? TA_EN : TA_DIS); in bbnsm_rtc_alarm_irq_enable()
124 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_set_alarm() local
128 regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN, TA_EN); in bbnsm_rtc_set_alarm()
131 regmap_write(bbnsm->regmap, BBNSM_TA, time); in bbnsm_rtc_set_alarm()
147 struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); in bbnsm_rtc_irq_handler() local
150 regmap_read(bbnsm->regmap, BBNSM_EVENTS, &val); in bbnsm_rtc_irq_handler()
154 regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, TA_EN_MSK, BBNSM_EVENT_TA); in bbnsm_rtc_irq_handler()
155 rtc_update_irq(bbnsm->rtc, 1, RTC_AF | RTC_IRQF); in bbnsm_rtc_irq_handler()
166 struct bbnsm_rtc *bbnsm; in bbnsm_rtc_probe() local
169 bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL); in bbnsm_rtc_probe()
170 if (!bbnsm) in bbnsm_rtc_probe()
173 bbnsm->rtc = devm_rtc_allocate_device(&pdev->dev); in bbnsm_rtc_probe()
174 if (IS_ERR(bbnsm->rtc)) in bbnsm_rtc_probe()
175 return PTR_ERR(bbnsm->rtc); in bbnsm_rtc_probe()
177 bbnsm->regmap = syscon_node_to_regmap(np->parent); in bbnsm_rtc_probe()
178 if (IS_ERR(bbnsm->regmap)) { in bbnsm_rtc_probe()
179 dev_dbg(&pdev->dev, "bbnsm get regmap failed\n"); in bbnsm_rtc_probe()
180 return PTR_ERR(bbnsm->regmap); in bbnsm_rtc_probe()
183 bbnsm->irq = platform_get_irq(pdev, 0); in bbnsm_rtc_probe()
184 if (bbnsm->irq < 0) in bbnsm_rtc_probe()
185 return bbnsm->irq; in bbnsm_rtc_probe()
187 platform_set_drvdata(pdev, bbnsm); in bbnsm_rtc_probe()
190 regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A); in bbnsm_rtc_probe()
193 dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); in bbnsm_rtc_probe()
195 ret = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler, in bbnsm_rtc_probe()
199 bbnsm->irq, ret); in bbnsm_rtc_probe()
203 bbnsm->rtc->ops = &bbnsm_rtc_ops; in bbnsm_rtc_probe()
204 bbnsm->rtc->range_max = U32_MAX; in bbnsm_rtc_probe()
206 return devm_rtc_register_device(bbnsm->rtc); in bbnsm_rtc_probe()
210 { .compatible = "nxp,imx93-bbnsm-rtc" },
225 MODULE_DESCRIPTION("NXP BBNSM RTC Driver");