blob: 1f08ea956f90b905a628bdfb383b71c52d51e266 [file] [log] [blame]
Samuel Hollandf7d49542021-09-12 09:47:25 -05001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) Samuel Holland <samuel@sholland.org>
4 */
5
6#include <clk-uclass.h>
7#include <dm.h>
8#include <clk/sunxi.h>
9#include <dt-bindings/clock/sun8i-r-ccu.h>
10#include <dt-bindings/reset/sun8i-r-ccu.h>
11#include <linux/bitops.h>
12
13static struct ccu_clk_gate a31_r_gates[] = {
14 [CLK_APB0_PIO] = GATE(0x028, BIT(0)),
15 [CLK_APB0_IR] = GATE(0x028, BIT(1)),
16 [CLK_APB0_TIMER] = GATE(0x028, BIT(2)),
17 [CLK_APB0_RSB] = GATE(0x028, BIT(3)),
18 [CLK_APB0_UART] = GATE(0x028, BIT(4)),
19 [CLK_APB0_I2C] = GATE(0x028, BIT(6)),
20 [CLK_APB0_TWD] = GATE(0x028, BIT(7)),
21};
22
23static struct ccu_reset a31_r_resets[] = {
24 [RST_APB0_IR] = RESET(0x0b0, BIT(1)),
25 [RST_APB0_TIMER] = RESET(0x0b0, BIT(2)),
26 [RST_APB0_RSB] = RESET(0x0b0, BIT(3)),
27 [RST_APB0_UART] = RESET(0x0b0, BIT(4)),
28 [RST_APB0_I2C] = RESET(0x0b0, BIT(6)),
29};
30
31static const struct ccu_desc a31_r_ccu_desc = {
32 .gates = a31_r_gates,
33 .resets = a31_r_resets,
34};
35
36static int a31_r_clk_bind(struct udevice *dev)
37{
38 return sunxi_reset_bind(dev, ARRAY_SIZE(a31_r_resets));
39}
40
41static const struct udevice_id a31_r_clk_ids[] = {
42 { .compatible = "allwinner,sun8i-a83t-r-ccu",
43 .data = (ulong)&a31_r_ccu_desc },
44 { .compatible = "allwinner,sun8i-h3-r-ccu",
45 .data = (ulong)&a31_r_ccu_desc },
46 { .compatible = "allwinner,sun50i-a64-r-ccu",
47 .data = (ulong)&a31_r_ccu_desc },
48 { }
49};
50
51U_BOOT_DRIVER(clk_sun6i_a31_r) = {
52 .name = "sun6i_a31_r_ccu",
53 .id = UCLASS_CLK,
54 .of_match = a31_r_clk_ids,
55 .priv_auto = sizeof(struct ccu_priv),
56 .ops = &sunxi_clk_ops,
57 .probe = sunxi_clk_probe,
58 .bind = a31_r_clk_bind,
59};