Lines Matching defs:rtc
7 * based on rtc-sunxi.c
28 #include <linux/rtc.h>
145 struct rtc_device *rtc;
165 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
168 val = readl(rtc->base + SUN6I_LOSC_CTRL);
172 if (rtc->data->fixed_prescaler)
173 parent_rate /= rtc->data->fixed_prescaler;
175 if (rtc->data->has_prescaler) {
176 val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL);
185 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
187 return readl(rtc->base + SUN6I_LOSC_CTRL) & SUN6I_LOSC_CTRL_EXT_OSC;
192 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
199 spin_lock_irqsave(&rtc->lock, flags);
200 val = readl(rtc->base + SUN6I_LOSC_CTRL);
204 if (rtc->data->has_losc_en) {
208 writel(val, rtc->base + SUN6I_LOSC_CTRL);
209 spin_unlock_irqrestore(&rtc->lock, flags);
226 struct sun6i_rtc_dev *rtc;
231 const char *iosc_name = "rtc-int-osc";
236 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
237 if (!rtc)
240 rtc->data = data;
243 kfree(rtc);
247 spin_lock_init(&rtc->lock);
249 rtc->base = of_io_request_and_map(node, 0, of_node_full_name(node));
250 if (IS_ERR(rtc->base)) {
256 if (rtc->data->has_auto_swt) {
259 writel(reg, rtc->base + SUN6I_LOSC_CTRL);
265 if (rtc->data->has_losc_en)
268 writel(reg, rtc->base + SUN6I_LOSC_CTRL);
271 sun6i_rtc = rtc;
276 rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
279 rtc->data->rc_osc_rate,
281 if (IS_ERR(rtc->int_osc)) {
286 parents[0] = clk_hw_get_name(rtc->int_osc);
290 rtc->hw.init = &init;
298 rtc->losc = clk_register(NULL, &rtc->hw);
299 if (IS_ERR(rtc->losc)) {
306 rtc->ext_losc = clk_register_gate(NULL, clkout_name, init.name,
307 0, rtc->base + SUN6I_LOSC_OUT_GATING,
309 &rtc->lock);
310 if (IS_ERR(rtc->ext_losc)) {
316 clk_data->hws[0] = &rtc->hw;
317 clk_data->hws[1] = __clk_get_hw(rtc->ext_losc);
318 clk_data->hws[2] = rtc->int_osc;
323 clk_hw_unregister_fixed_rate(rtc->int_osc);
337 CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc",
350 CLK_OF_DECLARE_DRIVER(sun8i_a23_rtc_clk, "allwinner,sun8i-a23-rtc",
364 CLK_OF_DECLARE_DRIVER(sun8i_h3_rtc_clk, "allwinner,sun8i-h3-rtc",
367 CLK_OF_DECLARE_DRIVER(sun50i_h5_rtc_clk, "allwinner,sun50i-h5-rtc",
383 CLK_OF_DECLARE_DRIVER(sun50i_h6_rtc_clk, "allwinner,sun50i-h6-rtc",
399 CLK_OF_DECLARE_DRIVER(sun8i_r40_rtc_clk, "allwinner,sun8i-r40-rtc",
411 CLK_OF_DECLARE_DRIVER(sun8i_v3_rtc_clk, "allwinner,sun8i-v3-rtc",
427 rtc_update_irq(chip->rtc, 1, RTC_AF | RTC_IRQF);
625 dev_err(dev, "rtc is still busy.\n");
639 dev_err(dev, "Failed to set rtc time.\n");
653 dev_err(dev, "Failed to set rtc time.\n");
830 chip->rtc = devm_rtc_allocate_device(&pdev->dev);
831 if (IS_ERR(chip->rtc))
832 return PTR_ERR(chip->rtc);
834 chip->rtc->ops = &sun6i_rtc_ops;
836 chip->rtc->range_max = (65536 * SECS_PER_DAY) - 1;
838 chip->rtc->range_max = 2019686399LL; /* 2033-12-31 23:59:59 */
840 ret = devm_rtc_register_device(chip->rtc);
845 ret = devm_rtc_nvmem_register(chip->rtc, &sun6i_rtc_nvmem_cfg);
859 { .compatible = "allwinner,sun6i-a31-rtc" },
860 { .compatible = "allwinner,sun8i-a23-rtc" },
861 { .compatible = "allwinner,sun8i-h3-rtc" },
862 { .compatible = "allwinner,sun8i-r40-rtc" },
863 { .compatible = "allwinner,sun8i-v3-rtc" },
864 { .compatible = "allwinner,sun50i-h5-rtc" },
865 { .compatible = "allwinner,sun50i-h6-rtc" },
866 { .compatible = "allwinner,sun50i-h616-rtc",
868 { .compatible = "allwinner,sun50i-r329-rtc",
877 .name = "sun6i-rtc",