]> Git Repo - J-u-boot.git/blob - drivers/clk/sunxi/clk_a80.c
Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi
[J-u-boot.git] / drivers / clk / sunxi / clk_a80.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018 Amarula Solutions.
4  * Author: Jagan Teki <[email protected]>
5  */
6
7 #include <common.h>
8 #include <clk-uclass.h>
9 #include <dm.h>
10 #include <errno.h>
11 #include <clk/sunxi.h>
12 #include <dt-bindings/clock/sun9i-a80-ccu.h>
13 #include <dt-bindings/reset/sun9i-a80-ccu.h>
14 #include <linux/bitops.h>
15
16 static const struct ccu_clk_gate a80_gates[] = {
17         [CLK_SPI0]              = GATE(0x430, BIT(31)),
18         [CLK_SPI1]              = GATE(0x434, BIT(31)),
19         [CLK_SPI2]              = GATE(0x438, BIT(31)),
20         [CLK_SPI3]              = GATE(0x43c, BIT(31)),
21
22         [CLK_BUS_MMC]           = GATE(0x580, BIT(8)),
23         [CLK_BUS_SPI0]          = GATE(0x580, BIT(20)),
24         [CLK_BUS_SPI1]          = GATE(0x580, BIT(21)),
25         [CLK_BUS_SPI2]          = GATE(0x580, BIT(22)),
26         [CLK_BUS_SPI3]          = GATE(0x580, BIT(23)),
27
28         [CLK_BUS_I2C0]          = GATE(0x594, BIT(0)),
29         [CLK_BUS_I2C1]          = GATE(0x594, BIT(1)),
30         [CLK_BUS_I2C2]          = GATE(0x594, BIT(2)),
31         [CLK_BUS_I2C3]          = GATE(0x594, BIT(3)),
32         [CLK_BUS_I2C4]          = GATE(0x594, BIT(4)),
33         [CLK_BUS_UART0]         = GATE(0x594, BIT(16)),
34         [CLK_BUS_UART1]         = GATE(0x594, BIT(17)),
35         [CLK_BUS_UART2]         = GATE(0x594, BIT(18)),
36         [CLK_BUS_UART3]         = GATE(0x594, BIT(19)),
37         [CLK_BUS_UART4]         = GATE(0x594, BIT(20)),
38         [CLK_BUS_UART5]         = GATE(0x594, BIT(21)),
39 };
40
41 static const struct ccu_reset a80_resets[] = {
42         [RST_BUS_MMC]           = RESET(0x5a0, BIT(8)),
43         [RST_BUS_SPI0]          = RESET(0x5a0, BIT(20)),
44         [RST_BUS_SPI1]          = RESET(0x5a0, BIT(21)),
45         [RST_BUS_SPI2]          = RESET(0x5a0, BIT(22)),
46         [RST_BUS_SPI3]          = RESET(0x5a0, BIT(23)),
47
48         [RST_BUS_I2C0]          = RESET(0x5b4, BIT(0)),
49         [RST_BUS_I2C1]          = RESET(0x5b4, BIT(1)),
50         [RST_BUS_I2C2]          = RESET(0x5b4, BIT(2)),
51         [RST_BUS_I2C3]          = RESET(0x5b4, BIT(3)),
52         [RST_BUS_I2C4]          = RESET(0x5b4, BIT(4)),
53         [RST_BUS_UART0]         = RESET(0x5b4, BIT(16)),
54         [RST_BUS_UART1]         = RESET(0x5b4, BIT(17)),
55         [RST_BUS_UART2]         = RESET(0x5b4, BIT(18)),
56         [RST_BUS_UART3]         = RESET(0x5b4, BIT(19)),
57         [RST_BUS_UART4]         = RESET(0x5b4, BIT(20)),
58         [RST_BUS_UART5]         = RESET(0x5b4, BIT(21)),
59 };
60
61 static const struct ccu_clk_gate a80_mmc_gates[] = {
62         [0]                     = GATE(0x0, BIT(16)),
63         [1]                     = GATE(0x4, BIT(16)),
64         [2]                     = GATE(0x8, BIT(16)),
65         [3]                     = GATE(0xc, BIT(16)),
66 };
67
68 static const struct ccu_reset a80_mmc_resets[] = {
69         [0]                     = GATE(0x0, BIT(18)),
70         [1]                     = GATE(0x4, BIT(18)),
71         [2]                     = GATE(0x8, BIT(18)),
72         [3]                     = GATE(0xc, BIT(18)),
73 };
74
75 static const struct ccu_desc a80_ccu_desc = {
76         .gates = a80_gates,
77         .resets = a80_resets,
78 };
79
80 static const struct ccu_desc a80_mmc_clk_desc = {
81         .gates = a80_mmc_gates,
82         .resets = a80_mmc_resets,
83 };
84
85 static int a80_clk_bind(struct udevice *dev)
86 {
87         ulong count = ARRAY_SIZE(a80_resets);
88
89         if (device_is_compatible(dev, "allwinner,sun9i-a80-mmc-config-clk"))
90                 count = ARRAY_SIZE(a80_mmc_resets);
91
92         return sunxi_reset_bind(dev, count);
93 }
94
95 static const struct udevice_id a80_ccu_ids[] = {
96         { .compatible = "allwinner,sun9i-a80-ccu",
97           .data = (ulong)&a80_ccu_desc },
98         { .compatible = "allwinner,sun9i-a80-mmc-config-clk",
99           .data = (ulong)&a80_mmc_clk_desc },
100         { }
101 };
102
103 U_BOOT_DRIVER(clk_sun9i_a80) = {
104         .name           = "sun9i_a80_ccu",
105         .id             = UCLASS_CLK,
106         .of_match       = a80_ccu_ids,
107         .priv_auto      = sizeof(struct ccu_priv),
108         .ops            = &sunxi_clk_ops,
109         .probe          = sunxi_clk_probe,
110         .bind           = a80_clk_bind,
111 };
This page took 0.030438 seconds and 4 git commands to generate.