Samuel Holland | f7d4954 | 2021-09-12 09:47:25 -0500 | [diff] [blame] | 1 | // 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 | |
| 13 | static 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 | |
| 23 | static 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 | |
| 31 | static const struct ccu_desc a31_r_ccu_desc = { |
| 32 | .gates = a31_r_gates, |
| 33 | .resets = a31_r_resets, |
| 34 | }; |
| 35 | |
| 36 | static int a31_r_clk_bind(struct udevice *dev) |
| 37 | { |
| 38 | return sunxi_reset_bind(dev, ARRAY_SIZE(a31_r_resets)); |
| 39 | } |
| 40 | |
| 41 | static 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 | |
| 51 | U_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 | }; |