Lines Matching +full:trickle +full:- +full:resistor +full:- +full:ohms

1 // SPDX-License-Identifier: GPL-2.0
69 *secs = (unsigned long)readl(sp_rtc->reg_base + RTC_TIMER_OUT); in sp_get_seconds()
76 writel((u32)secs, sp_rtc->reg_base + RTC_TIMER_SET); in sp_set_seconds()
105 alarm_time = rtc_tm_to_time64(&alrm->time); in sp_rtc_set_alarm()
107 writel((u32)alarm_time, sp_rtc->reg_base + RTC_ALARM_SET); in sp_rtc_set_alarm()
117 alarm_time = readl(sp_rtc->reg_base + RTC_ALARM_SET); in sp_rtc_read_alarm()
121 alrm->enabled = 0; in sp_rtc_read_alarm()
123 alrm->enabled = 1; in sp_rtc_read_alarm()
125 rtc_time64_to_tm((unsigned long)(alarm_time), &alrm->time); in sp_rtc_read_alarm()
139 sp_rtc->reg_base + RTC_CTRL); in sp_rtc_alarm_irq_enable()
142 0x0, sp_rtc->reg_base + RTC_CTRL); in sp_rtc_alarm_irq_enable()
158 struct sunplus_rtc *sp_rtc = dev_get_drvdata(&plat_dev->dev); in sp_rtc_irq_handler()
160 rtc_update_irq(sp_rtc->rtc, 1, RTC_IRQF | RTC_AF); in sp_rtc_irq_handler()
161 dev_dbg(&plat_dev->dev, "[RTC] ALARM INT\n"); in sp_rtc_irq_handler()
167 * -------------------------------------------------------------------------------------
178 * -------------------------------------------------------------------------------------
183 u32 ohms, rsel; in sp_rtc_set_trickle_charger() local
186 if (of_property_read_u32(dev.of_node, "trickle-resistor-ohms", &ohms) || in sp_rtc_set_trickle_charger()
187 of_property_read_u32(dev.of_node, "aux-voltage-chargeable", &chargeable)) { in sp_rtc_set_trickle_charger()
192 switch (ohms) { in sp_rtc_set_trickle_charger()
206 dev_err(&dev, "invalid charger resistor value (%d)\n", ohms); in sp_rtc_set_trickle_charger()
210 writel(BAT_CHARGE_RSEL_MASK_BIT | rsel, sp_rtc->reg_base + RTC_BATT_CHARGE_CTRL); in sp_rtc_set_trickle_charger()
215 sp_rtc->reg_base + RTC_BATT_CHARGE_CTRL); in sp_rtc_set_trickle_charger()
219 sp_rtc->reg_base + RTC_BATT_CHARGE_CTRL); in sp_rtc_set_trickle_charger()
222 dev_err(&dev, "invalid aux-voltage-chargeable value (%d)\n", chargeable); in sp_rtc_set_trickle_charger()
226 writel(BAT_CHARGE_EN_MASK_BIT | BAT_CHARGE_EN, sp_rtc->reg_base + RTC_BATT_CHARGE_CTRL); in sp_rtc_set_trickle_charger()
234 sp_rtc = devm_kzalloc(&plat_dev->dev, sizeof(*sp_rtc), GFP_KERNEL); in sp_rtc_probe()
236 return -ENOMEM; in sp_rtc_probe()
238 sp_rtc->reg_base = devm_platform_ioremap_resource_byname(plat_dev, RTC_REG_NAME); in sp_rtc_probe()
239 if (IS_ERR(sp_rtc->reg_base)) in sp_rtc_probe()
240 return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->reg_base), in sp_rtc_probe()
242 dev_dbg(&plat_dev->dev, "res = %pR, reg_base = %p\n", in sp_rtc_probe()
243 sp_rtc->res, sp_rtc->reg_base); in sp_rtc_probe()
245 sp_rtc->irq = platform_get_irq(plat_dev, 0); in sp_rtc_probe()
246 if (sp_rtc->irq < 0) in sp_rtc_probe()
247 return sp_rtc->irq; in sp_rtc_probe()
249 ret = devm_request_irq(&plat_dev->dev, sp_rtc->irq, sp_rtc_irq_handler, in sp_rtc_probe()
252 return dev_err_probe(&plat_dev->dev, ret, "devm_request_irq failed:\n"); in sp_rtc_probe()
254 sp_rtc->rtcclk = devm_clk_get(&plat_dev->dev, NULL); in sp_rtc_probe()
255 if (IS_ERR(sp_rtc->rtcclk)) in sp_rtc_probe()
256 return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->rtcclk), in sp_rtc_probe()
259 sp_rtc->rstc = devm_reset_control_get_exclusive(&plat_dev->dev, NULL); in sp_rtc_probe()
260 if (IS_ERR(sp_rtc->rstc)) in sp_rtc_probe()
261 return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->rstc), in sp_rtc_probe()
264 ret = clk_prepare_enable(sp_rtc->rtcclk); in sp_rtc_probe()
268 ret = reset_control_deassert(sp_rtc->rstc); in sp_rtc_probe()
272 device_init_wakeup(&plat_dev->dev, 1); in sp_rtc_probe()
273 dev_set_drvdata(&plat_dev->dev, sp_rtc); in sp_rtc_probe()
275 sp_rtc->rtc = devm_rtc_allocate_device(&plat_dev->dev); in sp_rtc_probe()
276 if (IS_ERR(sp_rtc->rtc)) { in sp_rtc_probe()
277 ret = PTR_ERR(sp_rtc->rtc); in sp_rtc_probe()
281 sp_rtc->rtc->range_max = U32_MAX; in sp_rtc_probe()
282 sp_rtc->rtc->range_min = 0; in sp_rtc_probe()
283 sp_rtc->rtc->ops = &sp_rtc_ops; in sp_rtc_probe()
285 ret = devm_rtc_register_device(sp_rtc->rtc); in sp_rtc_probe()
289 /* Setup trickle charger */ in sp_rtc_probe()
290 if (plat_dev->dev.of_node) in sp_rtc_probe()
291 sp_rtc_set_trickle_charger(plat_dev->dev); in sp_rtc_probe()
294 writel(DIS_SYS_RST_RTC_MASK_BIT | DIS_SYS_RST_RTC, sp_rtc->reg_base + RTC_CTRL); in sp_rtc_probe()
299 reset_control_assert(sp_rtc->rstc); in sp_rtc_probe()
301 clk_disable_unprepare(sp_rtc->rtcclk); in sp_rtc_probe()
308 struct sunplus_rtc *sp_rtc = dev_get_drvdata(&plat_dev->dev); in sp_rtc_remove()
310 device_init_wakeup(&plat_dev->dev, 0); in sp_rtc_remove()
311 reset_control_assert(sp_rtc->rstc); in sp_rtc_remove()
312 clk_disable_unprepare(sp_rtc->rtcclk); in sp_rtc_remove()
321 enable_irq_wake(sp_rtc->irq); in sp_rtc_suspend()
331 disable_irq_wake(sp_rtc->irq); in sp_rtc_resume()
338 { .compatible = "sunplus,sp7021-rtc" },
349 .name = "sp7021-rtc",