blob: c5834f44103f1471d8d91cf45b10925a7a7f7580 [file] [log] [blame]
Jagan Tekie366a0c2019-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
7#include <common.h>
8#include <clk-uclass.h>
9#include <dm.h>
10#include <errno.h>
Samuel Holland12e3faa2021-09-12 11:48:43 -050011#include <clk/sunxi.h>
Jagan Tekie366a0c2019-01-11 15:41:46 +053012#include <dt-bindings/clock/sun9i-a80-ccu.h>
13#include <dt-bindings/reset/sun9i-a80-ccu.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060014#include <linux/bitops.h>
Jagan Tekie366a0c2019-01-11 15:41:46 +053015
16static const struct ccu_clk_gate a80_gates[] = {
Samuel Hollanda0f27ba2023-01-22 16:06:31 -060017 [CLK_NAND0_0] = GATE(0x400, BIT(31)),
18 [CLK_NAND0_1] = GATE(0x404, BIT(31)),
19 [CLK_NAND1_0] = GATE(0x408, BIT(31)),
20 [CLK_NAND1_1] = GATE(0x40c, BIT(31)),
Jagan Tekibc123132019-02-27 20:02:06 +053021 [CLK_SPI0] = GATE(0x430, BIT(31)),
22 [CLK_SPI1] = GATE(0x434, BIT(31)),
23 [CLK_SPI2] = GATE(0x438, BIT(31)),
24 [CLK_SPI3] = GATE(0x43c, BIT(31)),
25
Andre Przywaraddf33c12019-01-29 15:54:09 +000026 [CLK_BUS_MMC] = GATE(0x580, BIT(8)),
Samuel Hollanda0f27ba2023-01-22 16:06:31 -060027 [CLK_BUS_NAND0] = GATE(0x580, BIT(13)),
28 [CLK_BUS_NAND1] = GATE(0x580, BIT(12)),
Jagan Tekibc123132019-02-27 20:02:06 +053029 [CLK_BUS_SPI0] = GATE(0x580, BIT(20)),
30 [CLK_BUS_SPI1] = GATE(0x580, BIT(21)),
31 [CLK_BUS_SPI2] = GATE(0x580, BIT(22)),
32 [CLK_BUS_SPI3] = GATE(0x580, BIT(23)),
Andre Przywaraddf33c12019-01-29 15:54:09 +000033
Andre Przywara3e9aa0b2022-05-04 22:10:28 +010034 [CLK_BUS_PIO] = GATE(0x590, BIT(5)),
35
Samuel Hollandfa7a7fa2021-09-12 09:47:24 -050036 [CLK_BUS_I2C0] = GATE(0x594, BIT(0)),
37 [CLK_BUS_I2C1] = GATE(0x594, BIT(1)),
38 [CLK_BUS_I2C2] = GATE(0x594, BIT(2)),
39 [CLK_BUS_I2C3] = GATE(0x594, BIT(3)),
40 [CLK_BUS_I2C4] = GATE(0x594, BIT(4)),
Jagan Tekie366a0c2019-01-11 15:41:46 +053041 [CLK_BUS_UART0] = GATE(0x594, BIT(16)),
42 [CLK_BUS_UART1] = GATE(0x594, BIT(17)),
43 [CLK_BUS_UART2] = GATE(0x594, BIT(18)),
44 [CLK_BUS_UART3] = GATE(0x594, BIT(19)),
45 [CLK_BUS_UART4] = GATE(0x594, BIT(20)),
46 [CLK_BUS_UART5] = GATE(0x594, BIT(21)),
47};
48
49static const struct ccu_reset a80_resets[] = {
Andre Przywaraddf33c12019-01-29 15:54:09 +000050 [RST_BUS_MMC] = RESET(0x5a0, BIT(8)),
Samuel Hollanda0f27ba2023-01-22 16:06:31 -060051 [RST_BUS_NAND0] = RESET(0x5a0, BIT(13)),
52 [RST_BUS_NAND1] = RESET(0x5a0, BIT(12)),
Jagan Tekibc123132019-02-27 20:02:06 +053053 [RST_BUS_SPI0] = RESET(0x5a0, BIT(20)),
54 [RST_BUS_SPI1] = RESET(0x5a0, BIT(21)),
55 [RST_BUS_SPI2] = RESET(0x5a0, BIT(22)),
56 [RST_BUS_SPI3] = RESET(0x5a0, BIT(23)),
Andre Przywaraddf33c12019-01-29 15:54:09 +000057
Samuel Hollandfa7a7fa2021-09-12 09:47:24 -050058 [RST_BUS_I2C0] = RESET(0x5b4, BIT(0)),
59 [RST_BUS_I2C1] = RESET(0x5b4, BIT(1)),
60 [RST_BUS_I2C2] = RESET(0x5b4, BIT(2)),
61 [RST_BUS_I2C3] = RESET(0x5b4, BIT(3)),
62 [RST_BUS_I2C4] = RESET(0x5b4, BIT(4)),
Jagan Tekie366a0c2019-01-11 15:41:46 +053063 [RST_BUS_UART0] = RESET(0x5b4, BIT(16)),
64 [RST_BUS_UART1] = RESET(0x5b4, BIT(17)),
65 [RST_BUS_UART2] = RESET(0x5b4, BIT(18)),
66 [RST_BUS_UART3] = RESET(0x5b4, BIT(19)),
67 [RST_BUS_UART4] = RESET(0x5b4, BIT(20)),
68 [RST_BUS_UART5] = RESET(0x5b4, BIT(21)),
69};
70
Andre Przywara8c8c8a42019-01-29 15:54:10 +000071static const struct ccu_clk_gate a80_mmc_gates[] = {
72 [0] = GATE(0x0, BIT(16)),
73 [1] = GATE(0x4, BIT(16)),
74 [2] = GATE(0x8, BIT(16)),
75 [3] = GATE(0xc, BIT(16)),
76};
77
78static const struct ccu_reset a80_mmc_resets[] = {
79 [0] = GATE(0x0, BIT(18)),
80 [1] = GATE(0x4, BIT(18)),
81 [2] = GATE(0x8, BIT(18)),
82 [3] = GATE(0xc, BIT(18)),
83};
84
Samuel Holland751c6c62022-05-09 00:29:34 -050085const struct ccu_desc a80_ccu_desc = {
Jagan Tekie366a0c2019-01-11 15:41:46 +053086 .gates = a80_gates,
87 .resets = a80_resets,
Samuel Holland84436502022-05-09 00:29:31 -050088 .num_gates = ARRAY_SIZE(a80_gates),
89 .num_resets = ARRAY_SIZE(a80_resets),
Jagan Tekie366a0c2019-01-11 15:41:46 +053090};
91
Samuel Holland751c6c62022-05-09 00:29:34 -050092const struct ccu_desc a80_mmc_clk_desc = {
Andre Przywara8c8c8a42019-01-29 15:54:10 +000093 .gates = a80_mmc_gates,
94 .resets = a80_mmc_resets,
Samuel Holland84436502022-05-09 00:29:31 -050095 .num_gates = ARRAY_SIZE(a80_mmc_gates),
96 .num_resets = ARRAY_SIZE(a80_mmc_resets),
Andre Przywara8c8c8a42019-01-29 15:54:10 +000097};