Lines Matching defs:rtc
7 * based on rtc-sunxi.c
28 #include <linux/rtc.h>
136 struct rtc_device *rtc;
155 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
158 val = readl(rtc->base + SUN6I_LOSC_CTRL);
162 if (rtc->data->fixed_prescaler)
163 parent_rate /= rtc->data->fixed_prescaler;
165 if (rtc->data->has_prescaler) {
166 val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL);
175 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
177 return readl(rtc->base + SUN6I_LOSC_CTRL) & SUN6I_LOSC_CTRL_EXT_OSC;
182 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
189 spin_lock_irqsave(&rtc->lock, flags);
190 val = readl(rtc->base + SUN6I_LOSC_CTRL);
194 if (rtc->data->has_losc_en) {
198 writel(val, rtc->base + SUN6I_LOSC_CTRL);
199 spin_unlock_irqrestore(&rtc->lock, flags);
215 struct sun6i_rtc_dev *rtc;
220 const char *iosc_name = "rtc-int-osc";
225 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
226 if (!rtc)
229 rtc->data = data;
232 kfree(rtc);
236 spin_lock_init(&rtc->lock);
238 rtc->base = of_io_request_and_map(node, 0, of_node_full_name(node));
239 if (IS_ERR(rtc->base)) {
245 if (rtc->data->has_auto_swt) {
248 writel(reg, rtc->base + SUN6I_LOSC_CTRL);
254 if (rtc->data->has_losc_en)
257 writel(reg, rtc->base + SUN6I_LOSC_CTRL);
260 sun6i_rtc = rtc;
265 rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
268 rtc->data->rc_osc_rate,
270 if (IS_ERR(rtc->int_osc)) {
275 parents[0] = clk_hw_get_name(rtc->int_osc);
279 rtc->hw.init = &init;
287 rtc->losc = clk_register(NULL, &rtc->hw);
288 if (IS_ERR(rtc->losc)) {
295 rtc->ext_losc = clk_register_gate(NULL, clkout_name, init.name,
296 0, rtc->base + SUN6I_LOSC_OUT_GATING,
298 &rtc->lock);
299 if (IS_ERR(rtc->ext_losc)) {
305 clk_data->hws[0] = &rtc->hw;
306 clk_data->hws[1] = __clk_get_hw(rtc->ext_losc);
307 clk_data->hws[2] = rtc->int_osc;
312 clk_hw_unregister_fixed_rate(rtc->int_osc);
326 CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc",
339 CLK_OF_DECLARE_DRIVER(sun8i_a23_rtc_clk, "allwinner,sun8i-a23-rtc",
353 CLK_OF_DECLARE_DRIVER(sun8i_h3_rtc_clk, "allwinner,sun8i-h3-rtc",
356 CLK_OF_DECLARE_DRIVER(sun50i_h5_rtc_clk, "allwinner,sun50i-h5-rtc",
372 CLK_OF_DECLARE_DRIVER(sun50i_h6_rtc_clk, "allwinner,sun50i-h6-rtc",
388 CLK_OF_DECLARE_DRIVER(sun8i_r40_rtc_clk, "allwinner,sun8i-r40-rtc",
400 CLK_OF_DECLARE_DRIVER(sun8i_v3_rtc_clk, "allwinner,sun8i-v3-rtc",
416 rtc_update_irq(chip->rtc, 1, RTC_AF | RTC_IRQF);
579 dev_err(dev, "rtc is still busy.\n");
593 dev_err(dev, "Failed to set rtc time.\n");
607 dev_err(dev, "Failed to set rtc time.\n");
710 chip->rtc = devm_rtc_allocate_device(&pdev->dev);
711 if (IS_ERR(chip->rtc))
712 return PTR_ERR(chip->rtc);
714 chip->rtc->ops = &sun6i_rtc_ops;
715 chip->rtc->range_max = 2019686399LL; /* 2033-12-31 23:59:59 */
717 ret = rtc_register_device(chip->rtc);
733 { .compatible = "allwinner,sun6i-a31-rtc" },
734 { .compatible = "allwinner,sun8i-a23-rtc" },
735 { .compatible = "allwinner,sun8i-h3-rtc" },
736 { .compatible = "allwinner,sun8i-r40-rtc" },
737 { .compatible = "allwinner,sun8i-v3-rtc" },
738 { .compatible = "allwinner,sun50i-h5-rtc" },
739 { .compatible = "allwinner,sun50i-h6-rtc" },
747 .name = "sun6i-rtc",