Lines Matching +full:meson +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0
19 #include <linux/nvmem-provider.h>
46 /* rtc registers accessed via rtc-serial interface */
62 struct rtc_device *rtc; /* rtc device we created */
63 struct device *dev; /* device we bound from */
71 .name = "peripheral-registers",
79 /* RTC front-end serialiser controls */
84 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SCLK, 0); in meson_rtc_sclk_pulse()
86 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SCLK, in meson_rtc_sclk_pulse()
92 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SDI, in meson_rtc_send_bit()
100 u32 bit = 1 << (nr - 1); in meson_rtc_send_bits()
110 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SEN, 0); in meson_rtc_set_dir()
111 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SDI, 0); in meson_rtc_set_dir()
113 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SDI, 0); in meson_rtc_set_dir()
125 regmap_read(rtc->peripheral, RTC_ADDR1, &tmp); in meson_rtc_get_data()
139 regmap_update_bits(rtc->peripheral, RTC_ADDR0, val, 0); in meson_rtc_get_bus()
143 if (!regmap_read_poll_timeout(rtc->peripheral, RTC_ADDR1, val, in meson_rtc_get_bus()
148 dev_warn(rtc->dev, "failed to get bus, resetting RTC\n"); in meson_rtc_get_bus()
150 ret = reset_control_reset(rtc->reset); in meson_rtc_get_bus()
155 dev_err(rtc->dev, "bus is not ready\n"); in meson_rtc_get_bus()
156 return -ETIMEDOUT; in meson_rtc_get_bus()
169 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SEN, in meson_rtc_serial_bus_reg_read()
188 regmap_update_bits(rtc->peripheral, RTC_ADDR0, RTC_ADDR0_LINE_SEN, in meson_rtc_serial_bus_reg_write()
203 .name = "serial-registers",
215 regmap_write(rtc->peripheral, RTC_REG4, in meson_rtc_write_static()
220 regmap_update_bits(rtc->peripheral, RTC_ADDR0, in meson_rtc_write_static()
224 return regmap_read_poll_timeout(rtc->peripheral, RTC_REG4, tmp, in meson_rtc_write_static()
231 static int meson_rtc_gettime(struct device *dev, struct rtc_time *tm) in meson_rtc_gettime()
237 ret = regmap_read(rtc->serial, RTC_COUNTER, &time); in meson_rtc_gettime()
244 static int meson_rtc_settime(struct device *dev, struct rtc_time *tm) in meson_rtc_settime()
248 return regmap_write(rtc->serial, RTC_COUNTER, rtc_tm_to_time64(tm)); in meson_rtc_settime()
267 return regmap_bulk_read(rtc->serial, read_offset, buf, read_size); in meson_rtc_regmem_read()
279 return regmap_bulk_write(rtc->serial, write_offset, buf, write_size); in meson_rtc_regmem_write()
285 .name = "meson-rtc-regmem", in meson_rtc_probe()
293 struct device *dev = &pdev->dev; in meson_rtc_probe()
301 return -ENOMEM; in meson_rtc_probe()
303 rtc->rtc = devm_rtc_allocate_device(dev); in meson_rtc_probe()
304 if (IS_ERR(rtc->rtc)) in meson_rtc_probe()
305 return PTR_ERR(rtc->rtc); in meson_rtc_probe()
309 rtc->dev = dev; in meson_rtc_probe()
311 rtc->rtc->ops = &meson_rtc_ops; in meson_rtc_probe()
312 rtc->rtc->range_max = U32_MAX; in meson_rtc_probe()
318 rtc->peripheral = devm_regmap_init_mmio(dev, base, in meson_rtc_probe()
320 if (IS_ERR(rtc->peripheral)) { in meson_rtc_probe()
322 return PTR_ERR(rtc->peripheral); in meson_rtc_probe()
325 rtc->reset = devm_reset_control_get(dev, NULL); in meson_rtc_probe()
326 if (IS_ERR(rtc->reset)) { in meson_rtc_probe()
328 return PTR_ERR(rtc->reset); in meson_rtc_probe()
331 rtc->vdd = devm_regulator_get(dev, "vdd"); in meson_rtc_probe()
332 if (IS_ERR(rtc->vdd)) { in meson_rtc_probe()
333 dev_err(dev, "failed to get the vdd-supply\n"); in meson_rtc_probe()
334 return PTR_ERR(rtc->vdd); in meson_rtc_probe()
337 ret = regulator_enable(rtc->vdd); in meson_rtc_probe()
339 dev_err(dev, "failed to enable vdd-supply\n"); in meson_rtc_probe()
349 rtc->serial = devm_regmap_init(dev, &meson_rtc_serial_bus, rtc, in meson_rtc_probe()
351 if (IS_ERR(rtc->serial)) { in meson_rtc_probe()
353 ret = PTR_ERR(rtc->serial); in meson_rtc_probe()
361 ret = regmap_read(rtc->serial, RTC_COUNTER, &tm); in meson_rtc_probe()
368 ret = devm_rtc_nvmem_register(rtc->rtc, &meson_rtc_nvmem_config); in meson_rtc_probe()
372 ret = devm_rtc_register_device(rtc->rtc); in meson_rtc_probe()
379 regulator_disable(rtc->vdd); in meson_rtc_probe()
384 { .compatible = "amlogic,meson6-rtc", },
385 { .compatible = "amlogic,meson8-rtc", },
386 { .compatible = "amlogic,meson8b-rtc", },
387 { .compatible = "amlogic,meson8m2-rtc", },
395 .name = "meson-rtc",
401 MODULE_DESCRIPTION("Amlogic Meson RTC Driver");
405 MODULE_ALIAS("platform:meson-rtc");