blob: 6751af8a8031170c6ebf24462f558089bba2ea3c [file] [log] [blame]
Jagan Teki6901aab2019-01-11 15:41:46 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Amarula Solutions.
4 * Author: Jagan Teki <jagan@amarulasolutions.com>
5 */
6
Jagan Teki6901aab2019-01-11 15:41:46 +05307#include <clk-uclass.h>
8#include <dm.h>
9#include <errno.h>
Samuel Holland21d314a2021-09-12 11:48:43 -050010#include <clk/sunxi.h>
Jagan Teki6901aab2019-01-11 15:41:46 +053011#include <dt-bindings/clock/sun9i-a80-ccu.h>
12#include <dt-bindings/reset/sun9i-a80-ccu.h>
Simon Glasscd93d622020-05-10 11:40:13 -060013#include <linux/bitops.h>
Jagan Teki6901aab2019-01-11 15:41:46 +053014
15static const struct ccu_clk_gate a80_gates[] = {
Samuel Holland59c1ddd2023-01-22 16:06:31 -060016 [CLK_NAND0_0] = GATE(0x400, BIT(31)),
17 [CLK_NAND0_1] = GATE(0x404, BIT(31)),
18 [CLK_NAND1_0] = GATE(0x408, BIT(31)),
19 [CLK_NAND1_1] = GATE(0x40c, BIT(31)),
Jagan Teki82111462019-02-27 20:02:06 +053020 [CLK_SPI0] = GATE(0x430, BIT(31)),
21 [CLK_SPI1] = GATE(0x434, BIT(31)),
22 [CLK_SPI2] = GATE(0x438, BIT(31)),
23 [CLK_SPI3] = GATE(0x43c, BIT(31)),
24
Andre Przywarabb3e5aa2019-01-29 15:54:09 +000025 [CLK_BUS_MMC] = GATE(0x580, BIT(8)),
Samuel Holland59c1ddd2023-01-22 16:06:31 -060026 [CLK_BUS_NAND0] = GATE(0x580, BIT(13)),
27 [CLK_BUS_NAND1] = GATE(0x580, BIT(12)),
Jagan Teki82111462019-02-27 20:02:06 +053028 [CLK_BUS_SPI0] = GATE(0x580, BIT(20)),
29 [CLK_BUS_SPI1] = GATE(0x580, BIT(21)),
30 [CLK_BUS_SPI2] = GATE(0x580, BIT(22)),
31 [CLK_BUS_SPI3] = GATE(0x580, BIT(23)),
Andre Przywarabb3e5aa2019-01-29 15:54:09 +000032
Andre Przywara444ab352022-05-04 22:10:28 +010033 [CLK_BUS_PIO] = GATE(0x590, BIT(5)),
34
Samuel Hollandc61897b2021-09-12 09:47:24 -050035 [CLK_BUS_I2C0] = GATE(0x594, BIT(0)),
36 [CLK_BUS_I2C1] = GATE(0x594, BIT(1)),
37 [CLK_BUS_I2C2] = GATE(0x594, BIT(2)),
38 [CLK_BUS_I2C3] = GATE(0x594, BIT(3)),
39 [CLK_BUS_I2C4] = GATE(0x594, BIT(4)),
Jagan Teki6901aab2019-01-11 15:41:46 +053040 [CLK_BUS_UART0] = GATE(0x594, BIT(16)),
41 [CLK_BUS_UART1] = GATE(0x594, BIT(17)),
42 [CLK_BUS_UART2] = GATE(0x594, BIT(18)),
43 [CLK_BUS_UART3] = GATE(0x594, BIT(19)),
44 [CLK_BUS_UART4] = GATE(0x594, BIT(20)),
45 [CLK_BUS_UART5] = GATE(0x594, BIT(21)),
46};
47
48static const struct ccu_reset a80_resets[] = {
Andre Przywarabb3e5aa2019-01-29 15:54:09 +000049 [RST_BUS_MMC] = RESET(0x5a0, BIT(8)),
Samuel Holland59c1ddd2023-01-22 16:06:31 -060050 [RST_BUS_NAND0] = RESET(0x5a0, BIT(13)),
51 [RST_BUS_NAND1] = RESET(0x5a0, BIT(12)),
Jagan Teki82111462019-02-27 20:02:06 +053052 [RST_BUS_SPI0] = RESET(0x5a0, BIT(20)),
53 [RST_BUS_SPI1] = RESET(0x5a0, BIT(21)),
54 [RST_BUS_SPI2] = RESET(0x5a0, BIT(22)),
55 [RST_BUS_SPI3] = RESET(0x5a0, BIT(23)),
Andre Przywarabb3e5aa2019-01-29 15:54:09 +000056
Samuel Hollandc61897b2021-09-12 09:47:24 -050057 [RST_BUS_I2C0] = RESET(0x5b4, BIT(0)),
58 [RST_BUS_I2C1] = RESET(0x5b4, BIT(1)),
59 [RST_BUS_I2C2] = RESET(0x5b4, BIT(2)),
60 [RST_BUS_I2C3] = RESET(0x5b4, BIT(3)),
61 [RST_BUS_I2C4] = RESET(0x5b4, BIT(4)),
Jagan Teki6901aab2019-01-11 15:41:46 +053062 [RST_BUS_UART0] = RESET(0x5b4, BIT(16)),
63 [RST_BUS_UART1] = RESET(0x5b4, BIT(17)),
64 [RST_BUS_UART2] = RESET(0x5b4, BIT(18)),
65 [RST_BUS_UART3] = RESET(0x5b4, BIT(19)),
66 [RST_BUS_UART4] = RESET(0x5b4, BIT(20)),
67 [RST_BUS_UART5] = RESET(0x5b4, BIT(21)),
68};
69
Andre Przywarae0c7ce72019-01-29 15:54:10 +000070static const struct ccu_clk_gate a80_mmc_gates[] = {
71 [0] = GATE(0x0, BIT(16)),
72 [1] = GATE(0x4, BIT(16)),
73 [2] = GATE(0x8, BIT(16)),
74 [3] = GATE(0xc, BIT(16)),
75};
76
77static const struct ccu_reset a80_mmc_resets[] = {
78 [0] = GATE(0x0, BIT(18)),
79 [1] = GATE(0x4, BIT(18)),
80 [2] = GATE(0x8, BIT(18)),
81 [3] = GATE(0xc, BIT(18)),
82};
83
Samuel Holland46fa23f2022-05-09 00:29:34 -050084const struct ccu_desc a80_ccu_desc = {
Jagan Teki6901aab2019-01-11 15:41:46 +053085 .gates = a80_gates,
86 .resets = a80_resets,
Samuel Holland49b2b0a2022-05-09 00:29:31 -050087 .num_gates = ARRAY_SIZE(a80_gates),
88 .num_resets = ARRAY_SIZE(a80_resets),
Jagan Teki6901aab2019-01-11 15:41:46 +053089};
90
Samuel Holland46fa23f2022-05-09 00:29:34 -050091const struct ccu_desc a80_mmc_clk_desc = {
Andre Przywarae0c7ce72019-01-29 15:54:10 +000092 .gates = a80_mmc_gates,
93 .resets = a80_mmc_resets,
Samuel Holland49b2b0a2022-05-09 00:29:31 -050094 .num_gates = ARRAY_SIZE(a80_mmc_gates),
95 .num_resets = ARRAY_SIZE(a80_mmc_resets),
Andre Przywarae0c7ce72019-01-29 15:54:10 +000096};