aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-08-23 18:28:52 -0400
committerStephen Boyd <sboyd@codeaurora.org>2017-08-23 18:28:52 -0400
commit3477a72b41f3515913f7da704965884ca51b4352 (patch)
treea1ec371bcdcedd1bb3c0ee19d4f109d6f1a4a474
parente66d57a92ee249f53691c8c33da81da91f651e14 (diff)
parent62ec0b9754aced0b4c02694886cbe9bfd3d00f2f (diff)
Merge tag 'meson-clk-for-4.14' of git://github.com/baylibre/clk-meson into clk-next
Pull Amlogic clock driver updates from Neil Armstrong: * meson8b: add the reset controller to the clkc * meson: expose all clk ids * gxbb-aoclk: Add CEC 32k clock * gxbb: add mmc input 0 clocks * meson: fix protection against undefined clks * gxbb: fix audio divider flags * tag 'meson-clk-for-4.14' of git://github.com/baylibre/clk-meson: clk: meson: gxbb-aoclk: Add CEC 32k clock clk: meson: gxbb-aoclk: Switch to regmap for register access dt-bindings: clock: amlogic, gxbb-aoclkc: Update bindings clk: meson: gxbb: Add sd_emmc clk0 clocks clk: meson: gxbb: fix clk_mclk_i958 divider flags clk: meson: gxbb: fix meson cts_amclk divider flags clk: meson: meson8b: register the built-in reset controller dt-bindings: clock: gxbb-aoclk: Add CEC 32k clock clk: meson: gxbb: Add sd_emmc clk0 clkids clk: meson-gxbb: expose almost every clock in the bindings clk: meson8b: expose every clock in the bindings clk: meson: gxbb: fix protection against undefined clks clk: meson: meson8b: fix protection against undefined clks dt-bindings: clock: meson8b: describe the embedded reset controller
-rw-r--r--Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt22
-rw-r--r--Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt9
-rw-r--r--drivers/clk/meson/Kconfig1
-rw-r--r--drivers/clk/meson/Makefile2
-rw-r--r--drivers/clk/meson/gxbb-aoclk-32k.c194
-rw-r--r--drivers/clk/meson/gxbb-aoclk-regmap.c46
-rw-r--r--drivers/clk/meson/gxbb-aoclk.c65
-rw-r--r--drivers/clk/meson/gxbb-aoclk.h42
-rw-r--r--drivers/clk/meson/gxbb.c189
-rw-r--r--drivers/clk/meson/gxbb.h125
-rw-r--r--drivers/clk/meson/meson8b.c160
-rw-r--r--drivers/clk/meson/meson8b.h112
-rw-r--r--include/dt-bindings/clock/gxbb-aoclkc.h1
-rw-r--r--include/dt-bindings/clock/gxbb-clkc.h63
-rw-r--r--include/dt-bindings/clock/meson8b-clkc.h70
-rw-r--r--include/dt-bindings/reset/amlogic,meson8b-clkc-reset.h27
16 files changed, 870 insertions, 258 deletions
diff --git a/Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt b/Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt
index a55d31b48d6e..64884ede4938 100644
--- a/Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt
+++ b/Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt
@@ -5,9 +5,11 @@ controllers within the Always-On part of the SoC.
5 5
6Required Properties: 6Required Properties:
7 7
8- compatible: should be "amlogic,gxbb-aoclkc" 8- compatible: value should be different for each SoC family as :
9- reg: physical base address of the clock controller and length of memory 9 - GXBB (S905) : "amlogic,meson-gxbb-aoclkc"
10 mapped region. 10 - GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc"
11 - GXM (S912) : "amlogic,meson-gxm-aoclkc"
12 followed by the common "amlogic,meson-gx-aoclkc"
11 13
12- #clock-cells: should be 1. 14- #clock-cells: should be 1.
13 15
@@ -23,14 +25,22 @@ to specify the reset which they consume. All available resets are defined as
23preprocessor macros in the dt-bindings/reset/gxbb-aoclkc.h header and can be 25preprocessor macros in the dt-bindings/reset/gxbb-aoclkc.h header and can be
24used in device tree sources. 26used in device tree sources.
25 27
28Parent node should have the following properties :
29- compatible: "amlogic,meson-gx-ao-sysctrl", "syscon", "simple-mfd"
30- reg: base address and size of the AO system control register space.
31
26Example: AO Clock controller node: 32Example: AO Clock controller node:
27 33
28 clkc_AO: clock-controller@040 { 34ao_sysctrl: sys-ctrl@0 {
29 compatible = "amlogic,gxbb-aoclkc"; 35 compatible = "amlogic,meson-gx-ao-sysctrl", "syscon", "simple-mfd";
30 reg = <0x0 0x040 0x0 0x4>; 36 reg = <0x0 0x0 0x0 0x100>;
37
38 clkc_AO: clock-controller {
39 compatible = "amlogic,meson-gxbb-aoclkc", "amlogic,meson-gx-aoclkc";
31 #clock-cells = <1>; 40 #clock-cells = <1>;
32 #reset-cells = <1>; 41 #reset-cells = <1>;
33 }; 42 };
43};
34 44
35Example: UART controller node that consumes the clock and reset generated 45Example: UART controller node that consumes the clock and reset generated
36 by the clock controller: 46 by the clock controller:
diff --git a/Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt b/Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt
index 606da38c0959..c858fd64f680 100644
--- a/Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt
+++ b/Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt
@@ -16,18 +16,25 @@ Required Properties:
16 mapped region. 16 mapped region.
17 17
18- #clock-cells: should be 1. 18- #clock-cells: should be 1.
19- #reset-cells: should be 1.
19 20
20Each clock is assigned an identifier and client nodes can use this identifier 21Each clock is assigned an identifier and client nodes can use this identifier
21to specify the clock which they consume. All available clocks are defined as 22to specify the clock which they consume. All available clocks are defined as
22preprocessor macros in the dt-bindings/clock/meson8b-clkc.h header and can be 23preprocessor macros in the dt-bindings/clock/meson8b-clkc.h header and can be
23used in device tree sources. 24used in device tree sources.
24 25
26Similarly a preprocessor macro for each reset line is defined in
27dt-bindings/reset/amlogic,meson8b-clkc-reset.h (which can be used from the
28device tree sources).
29
30
25Example: Clock controller node: 31Example: Clock controller node:
26 32
27 clkc: clock-controller@c1104000 { 33 clkc: clock-controller@c1104000 {
28 #clock-cells = <1>;
29 compatible = "amlogic,meson8b-clkc"; 34 compatible = "amlogic,meson8b-clkc";
30 reg = <0xc1108000 0x4>, <0xc1104000 0x460>; 35 reg = <0xc1108000 0x4>, <0xc1104000 0x460>;
36 #clock-cells = <1>;
37 #reset-cells = <1>;
31 }; 38 };
32 39
33 40
diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig
index 5588f75a8414..d2d0174a6eca 100644
--- a/drivers/clk/meson/Kconfig
+++ b/drivers/clk/meson/Kconfig
@@ -6,6 +6,7 @@ config COMMON_CLK_AMLOGIC
6config COMMON_CLK_MESON8B 6config COMMON_CLK_MESON8B
7 bool 7 bool
8 depends on COMMON_CLK_AMLOGIC 8 depends on COMMON_CLK_AMLOGIC
9 select RESET_CONTROLLER
9 help 10 help
10 Support for the clock controller on AmLogic S802 (Meson8), 11 Support for the clock controller on AmLogic S802 (Meson8),
11 S805 (Meson8b) and S812 (Meson8m2) devices. Say Y if you 12 S805 (Meson8b) and S812 (Meson8m2) devices. Say Y if you
diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index 83b6d9d65aa1..b139d41b25da 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -4,4 +4,4 @@
4 4
5obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o clk-audio-divider.o 5obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o clk-audio-divider.o
6obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o 6obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
7obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o 7obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-regmap.o gxbb-aoclk-32k.o
diff --git a/drivers/clk/meson/gxbb-aoclk-32k.c b/drivers/clk/meson/gxbb-aoclk-32k.c
new file mode 100644
index 000000000000..491634dbc985
--- /dev/null
+++ b/drivers/clk/meson/gxbb-aoclk-32k.c
@@ -0,0 +1,194 @@
1/*
2 * Copyright (c) 2017 BayLibre, SAS.
3 * Author: Neil Armstrong <narmstrong@baylibre.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <linux/clk-provider.h>
9#include <linux/bitfield.h>
10#include <linux/regmap.h>
11#include "gxbb-aoclk.h"
12
13/*
14 * The AO Domain embeds a dual/divider to generate a more precise
15 * 32,768KHz clock for low-power suspend mode and CEC.
16 * ______ ______
17 * | | | |
18 * ______ | Div1 |-| Cnt1 | ______
19 * | | /|______| |______|\ | |
20 * Xtal-->| Gate |---| ______ ______ X-X--| Gate |-->
21 * |______| | \| | | |/ | |______|
22 * | | Div2 |-| Cnt2 | |
23 * | |______| |______| |
24 * |_______________________|
25 *
26 * The dividing can be switched to single or dual, with a counter
27 * for each divider to set when the switching is done.
28 * The entire dividing mechanism can be also bypassed.
29 */
30
31#define CLK_CNTL0_N1_MASK GENMASK(11, 0)
32#define CLK_CNTL0_N2_MASK GENMASK(23, 12)
33#define CLK_CNTL0_DUALDIV_EN BIT(28)
34#define CLK_CNTL0_OUT_GATE_EN BIT(30)
35#define CLK_CNTL0_IN_GATE_EN BIT(31)
36
37#define CLK_CNTL1_M1_MASK GENMASK(11, 0)
38#define CLK_CNTL1_M2_MASK GENMASK(23, 12)
39#define CLK_CNTL1_BYPASS_EN BIT(24)
40#define CLK_CNTL1_SELECT_OSC BIT(27)
41
42#define PWR_CNTL_ALT_32K_SEL GENMASK(13, 10)
43
44struct cec_32k_freq_table {
45 unsigned long parent_rate;
46 unsigned long target_rate;
47 bool dualdiv;
48 unsigned int n1;
49 unsigned int n2;
50 unsigned int m1;
51 unsigned int m2;
52};
53
54static const struct cec_32k_freq_table aoclk_cec_32k_table[] = {
55 [0] = {
56 .parent_rate = 24000000,
57 .target_rate = 32768,
58 .dualdiv = true,
59 .n1 = 733,
60 .n2 = 732,
61 .m1 = 8,
62 .m2 = 11,
63 },
64};
65
66/*
67 * If CLK_CNTL0_DUALDIV_EN == 0
68 * - will use N1 divider only
69 * If CLK_CNTL0_DUALDIV_EN == 1
70 * - hold M1 cycles of N1 divider then changes to N2
71 * - hold M2 cycles of N2 divider then changes to N1
72 * Then we can get more accurate division.
73 */
74static unsigned long aoclk_cec_32k_recalc_rate(struct clk_hw *hw,
75 unsigned long parent_rate)
76{
77 struct aoclk_cec_32k *cec_32k = to_aoclk_cec_32k(hw);
78 unsigned long n1;
79 u32 reg0, reg1;
80
81 regmap_read(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0, &reg0);
82 regmap_read(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL1, &reg1);
83
84 if (reg1 & CLK_CNTL1_BYPASS_EN)
85 return parent_rate;
86
87 if (reg0 & CLK_CNTL0_DUALDIV_EN) {
88 unsigned long n2, m1, m2, f1, f2, p1, p2;
89
90 n1 = FIELD_GET(CLK_CNTL0_N1_MASK, reg0) + 1;
91 n2 = FIELD_GET(CLK_CNTL0_N2_MASK, reg0) + 1;
92
93 m1 = FIELD_GET(CLK_CNTL1_M1_MASK, reg1) + 1;
94 m2 = FIELD_GET(CLK_CNTL1_M2_MASK, reg1) + 1;
95
96 f1 = DIV_ROUND_CLOSEST(parent_rate, n1);
97 f2 = DIV_ROUND_CLOSEST(parent_rate, n2);
98
99 p1 = DIV_ROUND_CLOSEST(100000000 * m1, f1 * (m1 + m2));
100 p2 = DIV_ROUND_CLOSEST(100000000 * m2, f2 * (m1 + m2));
101
102 return DIV_ROUND_UP(100000000, p1 + p2);
103 }
104
105 n1 = FIELD_GET(CLK_CNTL0_N1_MASK, reg0) + 1;
106
107 return DIV_ROUND_CLOSEST(parent_rate, n1);
108}
109
110static const struct cec_32k_freq_table *find_cec_32k_freq(unsigned long rate,
111 unsigned long prate)
112{
113 int i;
114
115 for (i = 0 ; i < ARRAY_SIZE(aoclk_cec_32k_table) ; ++i)
116 if (aoclk_cec_32k_table[i].parent_rate == prate &&
117 aoclk_cec_32k_table[i].target_rate == rate)
118 return &aoclk_cec_32k_table[i];
119
120 return NULL;
121}
122
123static long aoclk_cec_32k_round_rate(struct clk_hw *hw, unsigned long rate,
124 unsigned long *prate)
125{
126 const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
127 *prate);
128
129 /* If invalid return first one */
130 if (!freq)
131 return aoclk_cec_32k_table[0].target_rate;
132
133 return freq->target_rate;
134}
135
136/*
137 * From the Amlogic init procedure, the IN and OUT gates needs to be handled
138 * in the init procedure to avoid any glitches.
139 */
140
141static int aoclk_cec_32k_set_rate(struct clk_hw *hw, unsigned long rate,
142 unsigned long parent_rate)
143{
144 const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
145 parent_rate);
146 struct aoclk_cec_32k *cec_32k = to_aoclk_cec_32k(hw);
147 u32 reg = 0;
148
149 if (!freq)
150 return -EINVAL;
151
152 /* Disable clock */
153 regmap_update_bits(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0,
154 CLK_CNTL0_IN_GATE_EN | CLK_CNTL0_OUT_GATE_EN, 0);
155
156 reg = FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1);
157 if (freq->dualdiv)
158 reg |= CLK_CNTL0_DUALDIV_EN |
159 FIELD_PREP(CLK_CNTL0_N2_MASK, freq->n2 - 1);
160
161 regmap_write(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0, reg);
162
163 reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1);
164 if (freq->dualdiv)
165 reg |= FIELD_PREP(CLK_CNTL1_M2_MASK, freq->m2 - 1);
166
167 regmap_write(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL1, reg);
168
169 /* Enable clock */
170 regmap_update_bits(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0,
171 CLK_CNTL0_IN_GATE_EN, CLK_CNTL0_IN_GATE_EN);
172
173 udelay(200);
174
175 regmap_update_bits(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0,
176 CLK_CNTL0_OUT_GATE_EN, CLK_CNTL0_OUT_GATE_EN);
177
178 regmap_update_bits(cec_32k->regmap, AO_CRT_CLK_CNTL1,
179 CLK_CNTL1_SELECT_OSC, CLK_CNTL1_SELECT_OSC);
180
181 /* Select 32k from XTAL */
182 regmap_update_bits(cec_32k->regmap,
183 AO_RTI_PWR_CNTL_REG0,
184 PWR_CNTL_ALT_32K_SEL,
185 FIELD_PREP(PWR_CNTL_ALT_32K_SEL, 4));
186
187 return 0;
188}
189
190const struct clk_ops meson_aoclk_cec_32k_ops = {
191 .recalc_rate = aoclk_cec_32k_recalc_rate,
192 .round_rate = aoclk_cec_32k_round_rate,
193 .set_rate = aoclk_cec_32k_set_rate,
194};
diff --git a/drivers/clk/meson/gxbb-aoclk-regmap.c b/drivers/clk/meson/gxbb-aoclk-regmap.c
new file mode 100644
index 000000000000..2515fbfa0467
--- /dev/null
+++ b/drivers/clk/meson/gxbb-aoclk-regmap.c
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) 2017 BayLibre, SAS.
3 * Author: Neil Armstrong <narmstrong@baylibre.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <linux/clk-provider.h>
9#include <linux/bitfield.h>
10#include <linux/regmap.h>
11#include "gxbb-aoclk.h"
12
13static int aoclk_gate_regmap_enable(struct clk_hw *hw)
14{
15 struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
16
17 return regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
18 BIT(gate->bit_idx), BIT(gate->bit_idx));
19}
20
21static void aoclk_gate_regmap_disable(struct clk_hw *hw)
22{
23 struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
24
25 regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
26 BIT(gate->bit_idx), 0);
27}
28
29static int aoclk_gate_regmap_is_enabled(struct clk_hw *hw)
30{
31 struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
32 unsigned int val;
33 int ret;
34
35 ret = regmap_read(gate->regmap, AO_RTI_GEN_CNTL_REG0, &val);
36 if (ret)
37 return ret;
38
39 return (val & BIT(gate->bit_idx)) != 0;
40}
41
42const struct clk_ops meson_aoclk_gate_regmap_ops = {
43 .enable = aoclk_gate_regmap_enable,
44 .disable = aoclk_gate_regmap_disable,
45 .is_enabled = aoclk_gate_regmap_is_enabled,
46};
diff --git a/drivers/clk/meson/gxbb-aoclk.c b/drivers/clk/meson/gxbb-aoclk.c
index b45c5fba7e35..6c161e0a8e59 100644
--- a/drivers/clk/meson/gxbb-aoclk.c
+++ b/drivers/clk/meson/gxbb-aoclk.c
@@ -56,16 +56,20 @@
56#include <linux/of_address.h> 56#include <linux/of_address.h>
57#include <linux/platform_device.h> 57#include <linux/platform_device.h>
58#include <linux/reset-controller.h> 58#include <linux/reset-controller.h>
59#include <linux/mfd/syscon.h>
60#include <linux/regmap.h>
59#include <linux/init.h> 61#include <linux/init.h>
62#include <linux/delay.h>
60#include <dt-bindings/clock/gxbb-aoclkc.h> 63#include <dt-bindings/clock/gxbb-aoclkc.h>
61#include <dt-bindings/reset/gxbb-aoclkc.h> 64#include <dt-bindings/reset/gxbb-aoclkc.h>
65#include "gxbb-aoclk.h"
62 66
63static DEFINE_SPINLOCK(gxbb_aoclk_lock); 67static DEFINE_SPINLOCK(gxbb_aoclk_lock);
64 68
65struct gxbb_aoclk_reset_controller { 69struct gxbb_aoclk_reset_controller {
66 struct reset_controller_dev reset; 70 struct reset_controller_dev reset;
67 unsigned int *data; 71 unsigned int *data;
68 void __iomem *base; 72 struct regmap *regmap;
69}; 73};
70 74
71static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev, 75static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev,
@@ -74,9 +78,8 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev,
74 struct gxbb_aoclk_reset_controller *reset = 78 struct gxbb_aoclk_reset_controller *reset =
75 container_of(rcdev, struct gxbb_aoclk_reset_controller, reset); 79 container_of(rcdev, struct gxbb_aoclk_reset_controller, reset);
76 80
77 writel(BIT(reset->data[id]), reset->base); 81 return regmap_write(reset->regmap, AO_RTI_GEN_CNTL_REG0,
78 82 BIT(reset->data[id]));
79 return 0;
80} 83}
81 84
82static const struct reset_control_ops gxbb_aoclk_reset_ops = { 85static const struct reset_control_ops gxbb_aoclk_reset_ops = {
@@ -84,13 +87,12 @@ static const struct reset_control_ops gxbb_aoclk_reset_ops = {
84}; 87};
85 88
86#define GXBB_AO_GATE(_name, _bit) \ 89#define GXBB_AO_GATE(_name, _bit) \
87static struct clk_gate _name##_ao = { \ 90static struct aoclk_gate_regmap _name##_ao = { \
88 .reg = (void __iomem *)0, \
89 .bit_idx = (_bit), \ 91 .bit_idx = (_bit), \
90 .lock = &gxbb_aoclk_lock, \ 92 .lock = &gxbb_aoclk_lock, \
91 .hw.init = &(struct clk_init_data) { \ 93 .hw.init = &(struct clk_init_data) { \
92 .name = #_name "_ao", \ 94 .name = #_name "_ao", \
93 .ops = &clk_gate_ops, \ 95 .ops = &meson_aoclk_gate_regmap_ops, \
94 .parent_names = (const char *[]){ "clk81" }, \ 96 .parent_names = (const char *[]){ "clk81" }, \
95 .num_parents = 1, \ 97 .num_parents = 1, \
96 .flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \ 98 .flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \
@@ -104,6 +106,17 @@ GXBB_AO_GATE(uart1, 3);
104GXBB_AO_GATE(uart2, 5); 106GXBB_AO_GATE(uart2, 5);
105GXBB_AO_GATE(ir_blaster, 6); 107GXBB_AO_GATE(ir_blaster, 6);
106 108
109static struct aoclk_cec_32k cec_32k_ao = {
110 .lock = &gxbb_aoclk_lock,
111 .hw.init = &(struct clk_init_data) {
112 .name = "cec_32k_ao",
113 .ops = &meson_aoclk_cec_32k_ops,
114 .parent_names = (const char *[]){ "xtal" },
115 .num_parents = 1,
116 .flags = CLK_IGNORE_UNUSED,
117 },
118};
119
107static unsigned int gxbb_aoclk_reset[] = { 120static unsigned int gxbb_aoclk_reset[] = {
108 [RESET_AO_REMOTE] = 16, 121 [RESET_AO_REMOTE] = 16,
109 [RESET_AO_I2C_MASTER] = 18, 122 [RESET_AO_I2C_MASTER] = 18,
@@ -113,7 +126,7 @@ static unsigned int gxbb_aoclk_reset[] = {
113 [RESET_AO_IR_BLASTER] = 23, 126 [RESET_AO_IR_BLASTER] = 23,
114}; 127};
115 128
116static struct clk_gate *gxbb_aoclk_gate[] = { 129static struct aoclk_gate_regmap *gxbb_aoclk_gate[] = {
117 [CLKID_AO_REMOTE] = &remote_ao, 130 [CLKID_AO_REMOTE] = &remote_ao,
118 [CLKID_AO_I2C_MASTER] = &i2c_master_ao, 131 [CLKID_AO_I2C_MASTER] = &i2c_master_ao,
119 [CLKID_AO_I2C_SLAVE] = &i2c_slave_ao, 132 [CLKID_AO_I2C_SLAVE] = &i2c_slave_ao,
@@ -130,30 +143,30 @@ static struct clk_hw_onecell_data gxbb_aoclk_onecell_data = {
130 [CLKID_AO_UART1] = &uart1_ao.hw, 143 [CLKID_AO_UART1] = &uart1_ao.hw,
131 [CLKID_AO_UART2] = &uart2_ao.hw, 144 [CLKID_AO_UART2] = &uart2_ao.hw,
132 [CLKID_AO_IR_BLASTER] = &ir_blaster_ao.hw, 145 [CLKID_AO_IR_BLASTER] = &ir_blaster_ao.hw,
146 [CLKID_AO_CEC_32K] = &cec_32k_ao.hw,
133 }, 147 },
134 .num = ARRAY_SIZE(gxbb_aoclk_gate), 148 .num = 7,
135}; 149};
136 150
137static int gxbb_aoclkc_probe(struct platform_device *pdev) 151static int gxbb_aoclkc_probe(struct platform_device *pdev)
138{ 152{
139 struct resource *res;
140 void __iomem *base;
141 int ret, clkid;
142 struct device *dev = &pdev->dev;
143 struct gxbb_aoclk_reset_controller *rstc; 153 struct gxbb_aoclk_reset_controller *rstc;
154 struct device *dev = &pdev->dev;
155 struct regmap *regmap;
156 int ret, clkid;
144 157
145 rstc = devm_kzalloc(dev, sizeof(*rstc), GFP_KERNEL); 158 rstc = devm_kzalloc(dev, sizeof(*rstc), GFP_KERNEL);
146 if (!rstc) 159 if (!rstc)
147 return -ENOMEM; 160 return -ENOMEM;
148 161
149 /* Generic clocks */ 162 regmap = syscon_node_to_regmap(of_get_parent(dev->of_node));
150 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 163 if (IS_ERR(regmap)) {
151 base = devm_ioremap_resource(dev, res); 164 dev_err(dev, "failed to get regmap\n");
152 if (IS_ERR(base)) 165 return -ENODEV;
153 return PTR_ERR(base); 166 }
154 167
155 /* Reset Controller */ 168 /* Reset Controller */
156 rstc->base = base; 169 rstc->regmap = regmap;
157 rstc->data = gxbb_aoclk_reset; 170 rstc->data = gxbb_aoclk_reset;
158 rstc->reset.ops = &gxbb_aoclk_reset_ops; 171 rstc->reset.ops = &gxbb_aoclk_reset_ops;
159 rstc->reset.nr_resets = ARRAY_SIZE(gxbb_aoclk_reset); 172 rstc->reset.nr_resets = ARRAY_SIZE(gxbb_aoclk_reset);
@@ -161,10 +174,10 @@ static int gxbb_aoclkc_probe(struct platform_device *pdev)
161 ret = devm_reset_controller_register(dev, &rstc->reset); 174 ret = devm_reset_controller_register(dev, &rstc->reset);
162 175
163 /* 176 /*
164 * Populate base address and register all clks 177 * Populate regmap and register all clks
165 */ 178 */
166 for (clkid = 0; clkid < gxbb_aoclk_onecell_data.num; clkid++) { 179 for (clkid = 0; clkid < ARRAY_SIZE(gxbb_aoclk_gate); clkid++) {
167 gxbb_aoclk_gate[clkid]->reg = base; 180 gxbb_aoclk_gate[clkid]->regmap = regmap;
168 181
169 ret = devm_clk_hw_register(dev, 182 ret = devm_clk_hw_register(dev,
170 gxbb_aoclk_onecell_data.hws[clkid]); 183 gxbb_aoclk_onecell_data.hws[clkid]);
@@ -172,12 +185,18 @@ static int gxbb_aoclkc_probe(struct platform_device *pdev)
172 return ret; 185 return ret;
173 } 186 }
174 187
188 /* Specific clocks */
189 cec_32k_ao.regmap = regmap;
190 ret = devm_clk_hw_register(dev, &cec_32k_ao.hw);
191 if (ret)
192 return ret;
193
175 return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, 194 return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
176 &gxbb_aoclk_onecell_data); 195 &gxbb_aoclk_onecell_data);
177} 196}
178 197
179static const struct of_device_id gxbb_aoclkc_match_table[] = { 198static const struct of_device_id gxbb_aoclkc_match_table[] = {
180 { .compatible = "amlogic,gxbb-aoclkc" }, 199 { .compatible = "amlogic,meson-gx-aoclkc" },
181 { } 200 { }
182}; 201};
183 202
diff --git a/drivers/clk/meson/gxbb-aoclk.h b/drivers/clk/meson/gxbb-aoclk.h
new file mode 100644
index 000000000000..e8604c8f7eee
--- /dev/null
+++ b/drivers/clk/meson/gxbb-aoclk.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (c) 2017 BayLibre, SAS
3 * Author: Neil Armstrong <narmstrong@baylibre.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef __GXBB_AOCLKC_H
9#define __GXBB_AOCLKC_H
10
11/* AO Configuration Clock registers offsets */
12#define AO_RTI_PWR_CNTL_REG1 0x0c
13#define AO_RTI_PWR_CNTL_REG0 0x10
14#define AO_RTI_GEN_CNTL_REG0 0x40
15#define AO_OSCIN_CNTL 0x58
16#define AO_CRT_CLK_CNTL1 0x68
17#define AO_RTC_ALT_CLK_CNTL0 0x94
18#define AO_RTC_ALT_CLK_CNTL1 0x98
19
20struct aoclk_gate_regmap {
21 struct clk_hw hw;
22 unsigned bit_idx;
23 struct regmap *regmap;
24 spinlock_t *lock;
25};
26
27#define to_aoclk_gate_regmap(_hw) \
28 container_of(_hw, struct aoclk_gate_regmap, hw)
29
30extern const struct clk_ops meson_aoclk_gate_regmap_ops;
31
32struct aoclk_cec_32k {
33 struct clk_hw hw;
34 struct regmap *regmap;
35 spinlock_t *lock;
36};
37
38#define to_aoclk_cec_32k(_hw) container_of(_hw, struct aoclk_cec_32k, hw)
39
40extern const struct clk_ops meson_aoclk_cec_32k_ops;
41
42#endif /* __GXBB_AOCLKC_H */
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index a7ea5f3da89d..b2d1e8ed7152 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -850,13 +850,14 @@ static struct meson_clk_audio_divider gxbb_cts_amclk_div = {
850 .shift = 0, 850 .shift = 0,
851 .width = 8, 851 .width = 8,
852 }, 852 },
853 .flags = CLK_DIVIDER_ROUND_CLOSEST,
853 .lock = &clk_lock, 854 .lock = &clk_lock,
854 .hw.init = &(struct clk_init_data){ 855 .hw.init = &(struct clk_init_data){
855 .name = "cts_amclk_div", 856 .name = "cts_amclk_div",
856 .ops = &meson_clk_audio_divider_ops, 857 .ops = &meson_clk_audio_divider_ops,
857 .parent_names = (const char *[]){ "cts_amclk_sel" }, 858 .parent_names = (const char *[]){ "cts_amclk_sel" },
858 .num_parents = 1, 859 .num_parents = 1,
859 .flags = CLK_SET_RATE_PARENT | CLK_DIVIDER_ROUND_CLOSEST, 860 .flags = CLK_SET_RATE_PARENT,
860 }, 861 },
861}; 862};
862 863
@@ -880,7 +881,7 @@ static struct clk_mux gxbb_cts_mclk_i958_sel = {
880 /* Default parent unknown (register reset value: 0) */ 881 /* Default parent unknown (register reset value: 0) */
881 .table = (u32[]){ 1, 2, 3 }, 882 .table = (u32[]){ 1, 2, 3 },
882 .lock = &clk_lock, 883 .lock = &clk_lock,
883 .hw.init = &(struct clk_init_data){ 884 .hw.init = &(struct clk_init_data) {
884 .name = "cts_mclk_i958_sel", 885 .name = "cts_mclk_i958_sel",
885 .ops = &clk_mux_ops, 886 .ops = &clk_mux_ops,
886 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" }, 887 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" },
@@ -894,12 +895,13 @@ static struct clk_divider gxbb_cts_mclk_i958_div = {
894 .shift = 16, 895 .shift = 16,
895 .width = 8, 896 .width = 8,
896 .lock = &clk_lock, 897 .lock = &clk_lock,
897 .hw.init = &(struct clk_init_data){ 898 .flags = CLK_DIVIDER_ROUND_CLOSEST,
899 .hw.init = &(struct clk_init_data) {
898 .name = "cts_mclk_i958_div", 900 .name = "cts_mclk_i958_div",
899 .ops = &clk_divider_ops, 901 .ops = &clk_divider_ops,
900 .parent_names = (const char *[]){ "cts_mclk_i958_sel" }, 902 .parent_names = (const char *[]){ "cts_mclk_i958_sel" },
901 .num_parents = 1, 903 .num_parents = 1,
902 .flags = CLK_SET_RATE_PARENT | CLK_DIVIDER_ROUND_CLOSEST, 904 .flags = CLK_SET_RATE_PARENT,
903 }, 905 },
904}; 906};
905 907
@@ -979,6 +981,156 @@ static struct clk_mux gxbb_32k_clk_sel = {
979 }, 981 },
980}; 982};
981 983
984static const char * const gxbb_sd_emmc_clk0_parent_names[] = {
985 "xtal", "fclk_div2", "fclk_div3", "fclk_div5", "fclk_div7",
986
987 /*
988 * Following these parent clocks, we should also have had mpll2, mpll3
989 * and gp0_pll but these clocks are too precious to be used here. All
990 * the necessary rates for MMC and NAND operation can be acheived using
991 * xtal or fclk_div clocks
992 */
993};
994
995/* SDIO clock */
996static struct clk_mux gxbb_sd_emmc_a_clk0_sel = {
997 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
998 .mask = 0x7,
999 .shift = 9,
1000 .lock = &clk_lock,
1001 .hw.init = &(struct clk_init_data) {
1002 .name = "sd_emmc_a_clk0_sel",
1003 .ops = &clk_mux_ops,
1004 .parent_names = gxbb_sd_emmc_clk0_parent_names,
1005 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
1006 .flags = CLK_SET_RATE_PARENT,
1007 },
1008};
1009
1010static struct clk_divider gxbb_sd_emmc_a_clk0_div = {
1011 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
1012 .shift = 0,
1013 .width = 7,
1014 .lock = &clk_lock,
1015 .flags = CLK_DIVIDER_ROUND_CLOSEST,
1016 .hw.init = &(struct clk_init_data) {
1017 .name = "sd_emmc_a_clk0_div",
1018 .ops = &clk_divider_ops,
1019 .parent_names = (const char *[]){ "sd_emmc_a_clk0_sel" },
1020 .num_parents = 1,
1021 .flags = CLK_SET_RATE_PARENT,
1022 },
1023};
1024
1025static struct clk_gate gxbb_sd_emmc_a_clk0 = {
1026 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
1027 .bit_idx = 7,
1028 .lock = &clk_lock,
1029 .hw.init = &(struct clk_init_data){
1030 .name = "sd_emmc_a_clk0",
1031 .ops = &clk_gate_ops,
1032 .parent_names = (const char *[]){ "sd_emmc_a_clk0_div" },
1033 .num_parents = 1,
1034
1035 /*
1036 * FIXME:
1037 * We need CLK_IGNORE_UNUSED because mmc DT node point to xtal
1038 * instead of this clock. CCF would gate this on boot, killing
1039 * the mmc controller. Please remove this flag once DT properly
1040 * point to this clock instead of xtal
1041 *
1042 * Same goes for emmc B and C clocks
1043 */
1044 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1045 },
1046};
1047
1048/* SDcard clock */
1049static struct clk_mux gxbb_sd_emmc_b_clk0_sel = {
1050 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
1051 .mask = 0x7,
1052 .shift = 25,
1053 .lock = &clk_lock,
1054 .hw.init = &(struct clk_init_data) {
1055 .name = "sd_emmc_b_clk0_sel",
1056 .ops = &clk_mux_ops,
1057 .parent_names = gxbb_sd_emmc_clk0_parent_names,
1058 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
1059 .flags = CLK_SET_RATE_PARENT,
1060 },
1061};
1062
1063static struct clk_divider gxbb_sd_emmc_b_clk0_div = {
1064 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
1065 .shift = 16,
1066 .width = 7,
1067 .lock = &clk_lock,
1068 .flags = CLK_DIVIDER_ROUND_CLOSEST,
1069 .hw.init = &(struct clk_init_data) {
1070 .name = "sd_emmc_b_clk0_div",
1071 .ops = &clk_divider_ops,
1072 .parent_names = (const char *[]){ "sd_emmc_b_clk0_sel" },
1073 .num_parents = 1,
1074 .flags = CLK_SET_RATE_PARENT,
1075 },
1076};
1077
1078static struct clk_gate gxbb_sd_emmc_b_clk0 = {
1079 .reg = (void *)HHI_SD_EMMC_CLK_CNTL,
1080 .bit_idx = 23,
1081 .lock = &clk_lock,
1082 .hw.init = &(struct clk_init_data){
1083 .name = "sd_emmc_b_clk0",
1084 .ops = &clk_gate_ops,
1085 .parent_names = (const char *[]){ "sd_emmc_b_clk0_div" },
1086 .num_parents = 1,
1087 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1088 },
1089};
1090
1091/* EMMC/NAND clock */
1092static struct clk_mux gxbb_sd_emmc_c_clk0_sel = {
1093 .reg = (void *)HHI_NAND_CLK_CNTL,
1094 .mask = 0x7,
1095 .shift = 9,
1096 .lock = &clk_lock,
1097 .hw.init = &(struct clk_init_data) {
1098 .name = "sd_emmc_c_clk0_sel",
1099 .ops = &clk_mux_ops,
1100 .parent_names = gxbb_sd_emmc_clk0_parent_names,
1101 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
1102 .flags = CLK_SET_RATE_PARENT,
1103 },
1104};
1105
1106static struct clk_divider gxbb_sd_emmc_c_clk0_div = {
1107 .reg = (void *)HHI_NAND_CLK_CNTL,
1108 .shift = 0,
1109 .width = 7,
1110 .lock = &clk_lock,
1111 .flags = CLK_DIVIDER_ROUND_CLOSEST,
1112 .hw.init = &(struct clk_init_data) {
1113 .name = "sd_emmc_c_clk0_div",
1114 .ops = &clk_divider_ops,
1115 .parent_names = (const char *[]){ "sd_emmc_c_clk0_sel" },
1116 .num_parents = 1,
1117 .flags = CLK_SET_RATE_PARENT,
1118 },
1119};
1120
1121static struct clk_gate gxbb_sd_emmc_c_clk0 = {
1122 .reg = (void *)HHI_NAND_CLK_CNTL,
1123 .bit_idx = 7,
1124 .lock = &clk_lock,
1125 .hw.init = &(struct clk_init_data){
1126 .name = "sd_emmc_c_clk0",
1127 .ops = &clk_gate_ops,
1128 .parent_names = (const char *[]){ "sd_emmc_c_clk0_div" },
1129 .num_parents = 1,
1130 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1131 },
1132};
1133
982/* Everything Else (EE) domain gates */ 1134/* Everything Else (EE) domain gates */
983static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0); 1135static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0);
984static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1); 1136static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1);
@@ -1188,6 +1340,16 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = {
1188 [CLKID_32K_CLK] = &gxbb_32k_clk.hw, 1340 [CLKID_32K_CLK] = &gxbb_32k_clk.hw,
1189 [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw, 1341 [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw,
1190 [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw, 1342 [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw,
1343 [CLKID_SD_EMMC_A_CLK0_SEL] = &gxbb_sd_emmc_a_clk0_sel.hw,
1344 [CLKID_SD_EMMC_A_CLK0_DIV] = &gxbb_sd_emmc_a_clk0_div.hw,
1345 [CLKID_SD_EMMC_A_CLK0] = &gxbb_sd_emmc_a_clk0.hw,
1346 [CLKID_SD_EMMC_B_CLK0_SEL] = &gxbb_sd_emmc_b_clk0_sel.hw,
1347 [CLKID_SD_EMMC_B_CLK0_DIV] = &gxbb_sd_emmc_b_clk0_div.hw,
1348 [CLKID_SD_EMMC_B_CLK0] = &gxbb_sd_emmc_b_clk0.hw,
1349 [CLKID_SD_EMMC_C_CLK0_SEL] = &gxbb_sd_emmc_c_clk0_sel.hw,
1350 [CLKID_SD_EMMC_C_CLK0_DIV] = &gxbb_sd_emmc_c_clk0_div.hw,
1351 [CLKID_SD_EMMC_C_CLK0] = &gxbb_sd_emmc_c_clk0.hw,
1352 [NR_CLKS] = NULL,
1191 }, 1353 },
1192 .num = NR_CLKS, 1354 .num = NR_CLKS,
1193}; 1355};
@@ -1310,6 +1472,16 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = {
1310 [CLKID_32K_CLK] = &gxbb_32k_clk.hw, 1472 [CLKID_32K_CLK] = &gxbb_32k_clk.hw,
1311 [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw, 1473 [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw,
1312 [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw, 1474 [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw,
1475 [CLKID_SD_EMMC_A_CLK0_SEL] = &gxbb_sd_emmc_a_clk0_sel.hw,
1476 [CLKID_SD_EMMC_A_CLK0_DIV] = &gxbb_sd_emmc_a_clk0_div.hw,
1477 [CLKID_SD_EMMC_A_CLK0] = &gxbb_sd_emmc_a_clk0.hw,
1478 [CLKID_SD_EMMC_B_CLK0_SEL] = &gxbb_sd_emmc_b_clk0_sel.hw,
1479 [CLKID_SD_EMMC_B_CLK0_DIV] = &gxbb_sd_emmc_b_clk0_div.hw,
1480 [CLKID_SD_EMMC_B_CLK0] = &gxbb_sd_emmc_b_clk0.hw,
1481 [CLKID_SD_EMMC_C_CLK0_SEL] = &gxbb_sd_emmc_c_clk0_sel.hw,
1482 [CLKID_SD_EMMC_C_CLK0_DIV] = &gxbb_sd_emmc_c_clk0_div.hw,
1483 [CLKID_SD_EMMC_C_CLK0] = &gxbb_sd_emmc_c_clk0.hw,
1484 [NR_CLKS] = NULL,
1313 }, 1485 },
1314 .num = NR_CLKS, 1486 .num = NR_CLKS,
1315}; 1487};
@@ -1425,6 +1597,9 @@ static struct clk_gate *const gxbb_clk_gates[] = {
1425 &gxbb_cts_amclk, 1597 &gxbb_cts_amclk,
1426 &gxbb_cts_mclk_i958, 1598 &gxbb_cts_mclk_i958,
1427 &gxbb_32k_clk, 1599 &gxbb_32k_clk,
1600 &gxbb_sd_emmc_a_clk0,
1601 &gxbb_sd_emmc_b_clk0,
1602 &gxbb_sd_emmc_c_clk0,
1428}; 1603};
1429 1604
1430static struct clk_mux *const gxbb_clk_muxes[] = { 1605static struct clk_mux *const gxbb_clk_muxes[] = {
@@ -1437,6 +1612,9 @@ static struct clk_mux *const gxbb_clk_muxes[] = {
1437 &gxbb_cts_mclk_i958_sel, 1612 &gxbb_cts_mclk_i958_sel,
1438 &gxbb_cts_i958, 1613 &gxbb_cts_i958,
1439 &gxbb_32k_clk_sel, 1614 &gxbb_32k_clk_sel,
1615 &gxbb_sd_emmc_a_clk0_sel,
1616 &gxbb_sd_emmc_b_clk0_sel,
1617 &gxbb_sd_emmc_c_clk0_sel,
1440}; 1618};
1441 1619
1442static struct clk_divider *const gxbb_clk_dividers[] = { 1620static struct clk_divider *const gxbb_clk_dividers[] = {
@@ -1446,6 +1624,9 @@ static struct clk_divider *const gxbb_clk_dividers[] = {
1446 &gxbb_mali_1_div, 1624 &gxbb_mali_1_div,
1447 &gxbb_cts_mclk_i958_div, 1625 &gxbb_cts_mclk_i958_div,
1448 &gxbb_32k_clk_div, 1626 &gxbb_32k_clk_div,
1627 &gxbb_sd_emmc_a_clk0_div,
1628 &gxbb_sd_emmc_b_clk0_div,
1629 &gxbb_sd_emmc_c_clk0_div,
1449}; 1630};
1450 1631
1451static struct meson_clk_audio_divider *const gxbb_audio_dividers[] = { 1632static struct meson_clk_audio_divider *const gxbb_audio_dividers[] = {
diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h
index d63e77e8433d..5b1d4b374d1c 100644
--- a/drivers/clk/meson/gxbb.h
+++ b/drivers/clk/meson/gxbb.h
@@ -167,130 +167,33 @@
167 * CLKID index values 167 * CLKID index values
168 * 168 *
169 * These indices are entirely contrived and do not map onto the hardware. 169 * These indices are entirely contrived and do not map onto the hardware.
170 * Migrate them out of this header and into the DT header file when they need 170 * It has now been decided to expose everything by default in the DT header:
171 * to be exposed to client nodes in DT: include/dt-bindings/clock/gxbb-clkc.h 171 * include/dt-bindings/clock/gxbb-clkc.h. Only the clocks ids we don't want
172 * to expose, such as the internal muxes and dividers of composite clocks,
173 * will remain defined here.
172 */ 174 */
173#define CLKID_SYS_PLL 0
174/* ID 1 is unused (it was used by the non-existing CLKID_CPUCLK before) */ 175/* ID 1 is unused (it was used by the non-existing CLKID_CPUCLK before) */
175/* CLKID_HDMI_PLL */
176#define CLKID_FIXED_PLL 3
177/* CLKID_FCLK_DIV2 */
178/* CLKID_FCLK_DIV3 */
179/* CLKID_FCLK_DIV4 */
180#define CLKID_FCLK_DIV5 7
181#define CLKID_FCLK_DIV7 8
182/* CLKID_GP0_PLL */
183#define CLKID_MPEG_SEL 10 176#define CLKID_MPEG_SEL 10
184#define CLKID_MPEG_DIV 11 177#define CLKID_MPEG_DIV 11
185/* CLKID_CLK81 */
186#define CLKID_MPLL0 13
187#define CLKID_MPLL1 14
188/* CLKID_MPLL2 */
189#define CLKID_DDR 16
190#define CLKID_DOS 17
191#define CLKID_ISA 18
192#define CLKID_PL301 19
193#define CLKID_PERIPHS 20
194/* CLKID_SPICC */
195/* CLKID_I2C */
196/* #define CLKID_SAR_ADC */
197#define CLKID_SMART_CARD 24
198/* CLKID_RNG0 */
199/* CLKID_UART0 */
200#define CLKID_SDHC 27
201#define CLKID_STREAM 28
202#define CLKID_ASYNC_FIFO 29
203#define CLKID_SDIO 30
204#define CLKID_ABUF 31
205#define CLKID_HIU_IFACE 32
206#define CLKID_ASSIST_MISC 33
207/* CLKID_SPI */
208#define CLKID_I2S_SPDIF 35
209/* CLKID_ETH */
210#define CLKID_DEMUX 37
211/* CLKID_AIU_GLUE */
212/* CLKID_IEC958 */
213/* CLKID_I2S_OUT */
214#define CLKID_AMCLK 41
215#define CLKID_AIFIFO2 42
216#define CLKID_MIXER 43
217/* CLKID_MIXER_IFACE */
218#define CLKID_ADC 45
219#define CLKID_BLKMV 46
220/* CLKID_AIU */
221/* CLKID_UART1 */
222#define CLKID_G2D 49
223/* CLKID_USB0 */
224/* CLKID_USB1 */
225#define CLKID_RESET 52
226#define CLKID_NAND 53
227#define CLKID_DOS_PARSER 54
228/* CLKID_USB */
229#define CLKID_VDIN1 56
230#define CLKID_AHB_ARB0 57
231#define CLKID_EFUSE 58
232#define CLKID_BOOT_ROM 59
233#define CLKID_AHB_DATA_BUS 60
234#define CLKID_AHB_CTRL_BUS 61
235#define CLKID_HDMI_INTR_SYNC 62
236/* CLKID_HDMI_PCLK */
237/* CLKID_USB1_DDR_BRIDGE */
238/* CLKID_USB0_DDR_BRIDGE */
239#define CLKID_MMC_PCLK 66
240#define CLKID_DVIN 67
241/* CLKID_UART2 */
242/* #define CLKID_SANA */
243#define CLKID_VPU_INTR 70
244#define CLKID_SEC_AHB_AHB3_BRIDGE 71
245#define CLKID_CLK81_A53 72
246#define CLKID_VCLK2_VENCI0 73
247#define CLKID_VCLK2_VENCI1 74
248#define CLKID_VCLK2_VENCP0 75
249#define CLKID_VCLK2_VENCP1 76
250/* CLKID_GCLK_VENCI_INT0 */
251#define CLKID_GCLK_VENCI_INT 78
252#define CLKID_DAC_CLK 79
253/* CLKID_AOCLK_GATE */
254/* CLKID_IEC958_GATE */
255#define CLKID_ENC480P 82
256#define CLKID_RNG1 83
257#define CLKID_GCLK_VENCI_INT1 84
258#define CLKID_VCLK2_VENCLMCC 85
259#define CLKID_VCLK2_VENCL 86
260#define CLKID_VCLK_OTHER 87
261#define CLKID_EDP 88
262#define CLKID_AO_MEDIA_CPU 89
263#define CLKID_AO_AHB_SRAM 90
264#define CLKID_AO_AHB_BUS 91
265#define CLKID_AO_IFACE 92
266/* CLKID_AO_I2C */
267/* CLKID_SD_EMMC_A */
268/* CLKID_SD_EMMC_B */
269/* CLKID_SD_EMMC_C */
270/* CLKID_SAR_ADC_CLK */
271/* CLKID_SAR_ADC_SEL */
272#define CLKID_SAR_ADC_DIV 99 178#define CLKID_SAR_ADC_DIV 99
273/* CLKID_MALI_0_SEL */ 179#define CLKID_MALI_0_DIV 101
274#define CLKID_MALI_0_DIV 101 180#define CLKID_MALI_1_DIV 104
275/* CLKID_MALI_0 */
276/* CLKID_MALI_1_SEL */
277#define CLKID_MALI_1_DIV 104
278/* CLKID_MALI_1 */
279/* CLKID_MALI */
280/* CLKID_CTS_AMCLK */
281#define CLKID_CTS_AMCLK_SEL 108 181#define CLKID_CTS_AMCLK_SEL 108
282#define CLKID_CTS_AMCLK_DIV 109 182#define CLKID_CTS_AMCLK_DIV 109
283/* CLKID_CTS_MCLK_I958 */
284#define CLKID_CTS_MCLK_I958_SEL 111 183#define CLKID_CTS_MCLK_I958_SEL 111
285#define CLKID_CTS_MCLK_I958_DIV 112 184#define CLKID_CTS_MCLK_I958_DIV 112
286/* CLKID_CTS_I958 */
287#define CLKID_32K_CLK 114
288#define CLKID_32K_CLK_SEL 115 185#define CLKID_32K_CLK_SEL 115
289#define CLKID_32K_CLK_DIV 116 186#define CLKID_32K_CLK_DIV 116
187#define CLKID_SD_EMMC_A_CLK0_SEL 117
188#define CLKID_SD_EMMC_A_CLK0_DIV 118
189#define CLKID_SD_EMMC_B_CLK0_SEL 120
190#define CLKID_SD_EMMC_B_CLK0_DIV 121
191#define CLKID_SD_EMMC_C_CLK0_SEL 123
192#define CLKID_SD_EMMC_C_CLK0_DIV 124
290 193
291#define NR_CLKS 117 194#define NR_CLKS 126
292 195
293/* include the CLKIDs that have been made part of the stable DT binding */ 196/* include the CLKIDs that have been made part of the DT binding */
294#include <dt-bindings/clock/gxbb-clkc.h> 197#include <dt-bindings/clock/gxbb-clkc.h>
295 198
296#endif /* __GXBB_H */ 199#endif /* __GXBB_H */
diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
index 6ec512ad2598..20ab7190d328 100644
--- a/drivers/clk/meson/meson8b.c
+++ b/drivers/clk/meson/meson8b.c
@@ -25,6 +25,8 @@
25#include <linux/clk-provider.h> 25#include <linux/clk-provider.h>
26#include <linux/of_address.h> 26#include <linux/of_address.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/reset-controller.h>
29#include <linux/slab.h>
28#include <linux/init.h> 30#include <linux/init.h>
29 31
30#include "clkc.h" 32#include "clkc.h"
@@ -32,6 +34,13 @@
32 34
33static DEFINE_SPINLOCK(clk_lock); 35static DEFINE_SPINLOCK(clk_lock);
34 36
37static void __iomem *clk_base;
38
39struct meson8b_clk_reset {
40 struct reset_controller_dev reset;
41 void __iomem *base;
42};
43
35static const struct pll_rate_table sys_pll_rate_table[] = { 44static const struct pll_rate_table sys_pll_rate_table[] = {
36 PLL_RATE(312000000, 52, 1, 2), 45 PLL_RATE(312000000, 52, 1, 2),
37 PLL_RATE(336000000, 56, 1, 2), 46 PLL_RATE(336000000, 56, 1, 2),
@@ -590,6 +599,7 @@ static struct clk_hw_onecell_data meson8b_hw_onecell_data = {
590 [CLKID_MPLL0] = &meson8b_mpll0.hw, 599 [CLKID_MPLL0] = &meson8b_mpll0.hw,
591 [CLKID_MPLL1] = &meson8b_mpll1.hw, 600 [CLKID_MPLL1] = &meson8b_mpll1.hw,
592 [CLKID_MPLL2] = &meson8b_mpll2.hw, 601 [CLKID_MPLL2] = &meson8b_mpll2.hw,
602 [CLK_NR_CLKS] = NULL,
593 }, 603 },
594 .num = CLK_NR_CLKS, 604 .num = CLK_NR_CLKS,
595}; 605};
@@ -695,20 +705,114 @@ static struct clk_divider *const meson8b_clk_dividers[] = {
695 &meson8b_mpeg_clk_div, 705 &meson8b_mpeg_clk_div,
696}; 706};
697 707
708static const struct meson8b_clk_reset_line {
709 u32 reg;
710 u8 bit_idx;
711} meson8b_clk_reset_bits[] = {
712 [CLKC_RESET_L2_CACHE_SOFT_RESET] = {
713 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 30
714 },
715 [CLKC_RESET_AXI_64_TO_128_BRIDGE_A5_SOFT_RESET] = {
716 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 29
717 },
718 [CLKC_RESET_SCU_SOFT_RESET] = {
719 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 28
720 },
721 [CLKC_RESET_CPU3_SOFT_RESET] = {
722 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 27
723 },
724 [CLKC_RESET_CPU2_SOFT_RESET] = {
725 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 26
726 },
727 [CLKC_RESET_CPU1_SOFT_RESET] = {
728 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 25
729 },
730 [CLKC_RESET_CPU0_SOFT_RESET] = {
731 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 24
732 },
733 [CLKC_RESET_A5_GLOBAL_RESET] = {
734 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 18
735 },
736 [CLKC_RESET_A5_AXI_SOFT_RESET] = {
737 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 17
738 },
739 [CLKC_RESET_A5_ABP_SOFT_RESET] = {
740 .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 16
741 },
742 [CLKC_RESET_AXI_64_TO_128_BRIDGE_MMC_SOFT_RESET] = {
743 .reg = HHI_SYS_CPU_CLK_CNTL1, .bit_idx = 30
744 },
745 [CLKC_RESET_VID_CLK_CNTL_SOFT_RESET] = {
746 .reg = HHI_VID_CLK_CNTL, .bit_idx = 15
747 },
748 [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_POST] = {
749 .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 7
750 },
751 [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_PRE] = {
752 .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 3
753 },
754 [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_POST] = {
755 .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 1
756 },
757 [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_PRE] = {
758 .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 0
759 },
760};
761
762static int meson8b_clk_reset_update(struct reset_controller_dev *rcdev,
763 unsigned long id, bool assert)
764{
765 struct meson8b_clk_reset *meson8b_clk_reset =
766 container_of(rcdev, struct meson8b_clk_reset, reset);
767 unsigned long flags;
768 const struct meson8b_clk_reset_line *reset;
769 u32 val;
770
771 if (id >= ARRAY_SIZE(meson8b_clk_reset_bits))
772 return -EINVAL;
773
774 reset = &meson8b_clk_reset_bits[id];
775
776 spin_lock_irqsave(&clk_lock, flags);
777
778 val = readl(meson8b_clk_reset->base + reset->reg);
779 if (assert)
780 val |= BIT(reset->bit_idx);
781 else
782 val &= ~BIT(reset->bit_idx);
783 writel(val, meson8b_clk_reset->base + reset->reg);
784
785 spin_unlock_irqrestore(&clk_lock, flags);
786
787 return 0;
788}
789
790static int meson8b_clk_reset_assert(struct reset_controller_dev *rcdev,
791 unsigned long id)
792{
793 return meson8b_clk_reset_update(rcdev, id, true);
794}
795
796static int meson8b_clk_reset_deassert(struct reset_controller_dev *rcdev,
797 unsigned long id)
798{
799 return meson8b_clk_reset_update(rcdev, id, false);
800}
801
802static const struct reset_control_ops meson8b_clk_reset_ops = {
803 .assert = meson8b_clk_reset_assert,
804 .deassert = meson8b_clk_reset_deassert,
805};
806
698static int meson8b_clkc_probe(struct platform_device *pdev) 807static int meson8b_clkc_probe(struct platform_device *pdev)
699{ 808{
700 void __iomem *clk_base;
701 int ret, clkid, i; 809 int ret, clkid, i;
702 struct clk_hw *parent_hw; 810 struct clk_hw *parent_hw;
703 struct clk *parent_clk; 811 struct clk *parent_clk;
704 struct device *dev = &pdev->dev; 812 struct device *dev = &pdev->dev;
705 813
706 /* Generic clocks and PLLs */ 814 if (!clk_base)
707 clk_base = of_iomap(dev->of_node, 1);
708 if (!clk_base) {
709 pr_err("%s: Unable to map clk base\n", __func__);
710 return -ENXIO; 815 return -ENXIO;
711 }
712 816
713 /* Populate base address for PLLs */ 817 /* Populate base address for PLLs */
714 for (i = 0; i < ARRAY_SIZE(meson8b_clk_plls); i++) 818 for (i = 0; i < ARRAY_SIZE(meson8b_clk_plls); i++)
@@ -748,7 +852,7 @@ static int meson8b_clkc_probe(struct platform_device *pdev)
748 /* FIXME convert to devm_clk_register */ 852 /* FIXME convert to devm_clk_register */
749 ret = devm_clk_hw_register(dev, meson8b_hw_onecell_data.hws[clkid]); 853 ret = devm_clk_hw_register(dev, meson8b_hw_onecell_data.hws[clkid]);
750 if (ret) 854 if (ret)
751 goto iounmap; 855 return ret;
752 } 856 }
753 857
754 /* 858 /*
@@ -771,15 +875,11 @@ static int meson8b_clkc_probe(struct platform_device *pdev)
771 if (ret) { 875 if (ret) {
772 pr_err("%s: failed to register clock notifier for cpu_clk\n", 876 pr_err("%s: failed to register clock notifier for cpu_clk\n",
773 __func__); 877 __func__);
774 goto iounmap; 878 return ret;
775 } 879 }
776 880
777 return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, 881 return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
778 &meson8b_hw_onecell_data); 882 &meson8b_hw_onecell_data);
779
780iounmap:
781 iounmap(clk_base);
782 return ret;
783} 883}
784 884
785static const struct of_device_id meson8b_clkc_match_table[] = { 885static const struct of_device_id meson8b_clkc_match_table[] = {
@@ -798,3 +898,39 @@ static struct platform_driver meson8b_driver = {
798}; 898};
799 899
800builtin_platform_driver(meson8b_driver); 900builtin_platform_driver(meson8b_driver);
901
902static void __init meson8b_clkc_reset_init(struct device_node *np)
903{
904 struct meson8b_clk_reset *rstc;
905 int ret;
906
907 /* Generic clocks, PLLs and some of the reset-bits */
908 clk_base = of_iomap(np, 1);
909 if (!clk_base) {
910 pr_err("%s: Unable to map clk base\n", __func__);
911 return;
912 }
913
914 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
915 if (!rstc)
916 return;
917
918 /* Reset Controller */
919 rstc->base = clk_base;
920 rstc->reset.ops = &meson8b_clk_reset_ops;
921 rstc->reset.nr_resets = ARRAY_SIZE(meson8b_clk_reset_bits);
922 rstc->reset.of_node = np;
923 ret = reset_controller_register(&rstc->reset);
924 if (ret) {
925 pr_err("%s: Failed to register clkc reset controller: %d\n",
926 __func__, ret);
927 return;
928 }
929}
930
931CLK_OF_DECLARE_DRIVER(meson8_clkc, "amlogic,meson8-clkc",
932 meson8b_clkc_reset_init);
933CLK_OF_DECLARE_DRIVER(meson8b_clkc, "amlogic,meson8b-clkc",
934 meson8b_clkc_reset_init);
935CLK_OF_DECLARE_DRIVER(meson8m2_clkc, "amlogic,meson8m2-clkc",
936 meson8b_clkc_reset_init);
diff --git a/drivers/clk/meson/meson8b.h b/drivers/clk/meson/meson8b.h
index a687e02547dc..2eaf8a52e7dd 100644
--- a/drivers/clk/meson/meson8b.h
+++ b/drivers/clk/meson/meson8b.h
@@ -37,6 +37,9 @@
37#define HHI_GCLK_AO 0x154 /* 0x55 offset in data sheet */ 37#define HHI_GCLK_AO 0x154 /* 0x55 offset in data sheet */
38#define HHI_SYS_CPU_CLK_CNTL1 0x15c /* 0x57 offset in data sheet */ 38#define HHI_SYS_CPU_CLK_CNTL1 0x15c /* 0x57 offset in data sheet */
39#define HHI_MPEG_CLK_CNTL 0x174 /* 0x5d offset in data sheet */ 39#define HHI_MPEG_CLK_CNTL 0x174 /* 0x5d offset in data sheet */
40#define HHI_VID_CLK_CNTL 0x17c /* 0x5f offset in data sheet */
41#define HHI_VID_DIVIDER_CNTL 0x198 /* 0x66 offset in data sheet */
42#define HHI_SYS_CPU_CLK_CNTL0 0x19c /* 0x67 offset in data sheet */
40#define HHI_MPLL_CNTL 0x280 /* 0xa0 offset in data sheet */ 43#define HHI_MPLL_CNTL 0x280 /* 0xa0 offset in data sheet */
41#define HHI_SYS_PLL_CNTL 0x300 /* 0xc0 offset in data sheet */ 44#define HHI_SYS_PLL_CNTL 0x300 /* 0xc0 offset in data sheet */
42#define HHI_VID_PLL_CNTL 0x320 /* 0xc8 offset in data sheet */ 45#define HHI_VID_PLL_CNTL 0x320 /* 0xc8 offset in data sheet */
@@ -60,110 +63,19 @@
60 * CLKID index values 63 * CLKID index values
61 * 64 *
62 * These indices are entirely contrived and do not map onto the hardware. 65 * These indices are entirely contrived and do not map onto the hardware.
63 * Migrate them out of this header and into the DT header file when they need 66 * It has now been decided to expose everything by default in the DT header:
64 * to be exposed to client nodes in DT: include/dt-bindings/clock/meson8b-clkc.h 67 * include/dt-bindings/clock/gxbb-clkc.h. Only the clocks ids we don't want
68 * to expose, such as the internal muxes and dividers of composite clocks,
69 * will remain defined here.
65 */ 70 */
66 71
67/* CLKID_UNUSED */
68/* CLKID_XTAL */
69/* CLKID_PLL_FIXED */
70/* CLKID_PLL_VID */
71/* CLKID_PLL_SYS */
72/* CLKID_FCLK_DIV2 */
73/* CLKID_FCLK_DIV3 */
74/* CLKID_FCLK_DIV4 */
75/* CLKID_FCLK_DIV5 */
76/* CLKID_FCLK_DIV7 */
77/* CLKID_CLK81 */
78/* CLKID_MALI */
79/* CLKID_CPUCLK */
80/* CLKID_ZERO */
81/* CLKID_MPEG_SEL */
82/* CLKID_MPEG_DIV */
83#define CLKID_DDR 16
84#define CLKID_DOS 17
85#define CLKID_ISA 18
86#define CLKID_PL301 19
87#define CLKID_PERIPHS 20
88#define CLKID_SPICC 21
89#define CLKID_I2C 22
90/* #define CLKID_SAR_ADC */
91#define CLKID_SMART_CARD 24
92/* #define CLKID_RNG0 */
93#define CLKID_UART0 26
94#define CLKID_SDHC 27
95#define CLKID_STREAM 28
96#define CLKID_ASYNC_FIFO 29
97/* #define CLKID_SDIO */
98#define CLKID_ABUF 31
99#define CLKID_HIU_IFACE 32
100#define CLKID_ASSIST_MISC 33
101#define CLKID_SPI 34
102#define CLKID_I2S_SPDIF 35
103/* #define CLKID_ETH */
104#define CLKID_DEMUX 37
105#define CLKID_AIU_GLUE 38
106#define CLKID_IEC958 39
107#define CLKID_I2S_OUT 40
108#define CLKID_AMCLK 41
109#define CLKID_AIFIFO2 42
110#define CLKID_MIXER 43
111#define CLKID_MIXER_IFACE 44
112#define CLKID_ADC 45
113#define CLKID_BLKMV 46
114#define CLKID_AIU 47
115#define CLKID_UART1 48
116#define CLKID_G2D 49
117/* #define CLKID_USB0 */
118/* #define CLKID_USB1 */
119#define CLKID_RESET 52
120#define CLKID_NAND 53
121#define CLKID_DOS_PARSER 54
122/* #define CLKID_USB */
123#define CLKID_VDIN1 56
124#define CLKID_AHB_ARB0 57
125#define CLKID_EFUSE 58
126#define CLKID_BOOT_ROM 59
127#define CLKID_AHB_DATA_BUS 60
128#define CLKID_AHB_CTRL_BUS 61
129#define CLKID_HDMI_INTR_SYNC 62
130#define CLKID_HDMI_PCLK 63
131/* CLKID_USB1_DDR_BRIDGE */
132/* CLKID_USB0_DDR_BRIDGE */
133#define CLKID_MMC_PCLK 66
134#define CLKID_DVIN 67
135#define CLKID_UART2 68
136/* #define CLKID_SANA */
137#define CLKID_VPU_INTR 70
138#define CLKID_SEC_AHB_AHB3_BRIDGE 71
139#define CLKID_CLK81_A9 72
140#define CLKID_VCLK2_VENCI0 73
141#define CLKID_VCLK2_VENCI1 74
142#define CLKID_VCLK2_VENCP0 75
143#define CLKID_VCLK2_VENCP1 76
144#define CLKID_GCLK_VENCI_INT 77
145#define CLKID_GCLK_VENCP_INT 78
146#define CLKID_DAC_CLK 79
147#define CLKID_AOCLK_GATE 80
148#define CLKID_IEC958_GATE 81
149#define CLKID_ENC480P 82
150#define CLKID_RNG1 83
151#define CLKID_GCLK_VENCL_INT 84
152#define CLKID_VCLK2_VENCLMCC 85
153#define CLKID_VCLK2_VENCL 86
154#define CLKID_VCLK2_OTHER 87
155#define CLKID_EDP 88
156#define CLKID_AO_MEDIA_CPU 89
157#define CLKID_AO_AHB_SRAM 90
158#define CLKID_AO_AHB_BUS 91
159#define CLKID_AO_IFACE 92
160#define CLKID_MPLL0 93
161#define CLKID_MPLL1 94
162#define CLKID_MPLL2 95
163
164#define CLK_NR_CLKS 96 72#define CLK_NR_CLKS 96
165 73
166/* include the CLKIDs that have been made part of the stable DT binding */ 74/*
75 * include the CLKID and RESETID that have
76 * been made part of the stable DT binding
77 */
167#include <dt-bindings/clock/meson8b-clkc.h> 78#include <dt-bindings/clock/meson8b-clkc.h>
79#include <dt-bindings/reset/amlogic,meson8b-clkc-reset.h>
168 80
169#endif /* __MESON8B_H */ 81#endif /* __MESON8B_H */
diff --git a/include/dt-bindings/clock/gxbb-aoclkc.h b/include/dt-bindings/clock/gxbb-aoclkc.h
index 31751482d13c..9d15e2221fdb 100644
--- a/include/dt-bindings/clock/gxbb-aoclkc.h
+++ b/include/dt-bindings/clock/gxbb-aoclkc.h
@@ -62,5 +62,6 @@
62#define CLKID_AO_UART1 3 62#define CLKID_AO_UART1 3
63#define CLKID_AO_UART2 4 63#define CLKID_AO_UART2 4
64#define CLKID_AO_IR_BLASTER 5 64#define CLKID_AO_IR_BLASTER 5
65#define CLKID_AO_CEC_32K 6
65 66
66#endif 67#endif
diff --git a/include/dt-bindings/clock/gxbb-clkc.h b/include/dt-bindings/clock/gxbb-clkc.h
index e3e9f7919c31..c04a76d8facf 100644
--- a/include/dt-bindings/clock/gxbb-clkc.h
+++ b/include/dt-bindings/clock/gxbb-clkc.h
@@ -5,37 +5,96 @@
5#ifndef __GXBB_CLKC_H 5#ifndef __GXBB_CLKC_H
6#define __GXBB_CLKC_H 6#define __GXBB_CLKC_H
7 7
8#define CLKID_SYS_PLL 0
8#define CLKID_HDMI_PLL 2 9#define CLKID_HDMI_PLL 2
10#define CLKID_FIXED_PLL 3
9#define CLKID_FCLK_DIV2 4 11#define CLKID_FCLK_DIV2 4
10#define CLKID_FCLK_DIV3 5 12#define CLKID_FCLK_DIV3 5
11#define CLKID_FCLK_DIV4 6 13#define CLKID_FCLK_DIV4 6
14#define CLKID_FCLK_DIV5 7
15#define CLKID_FCLK_DIV7 8
12#define CLKID_GP0_PLL 9 16#define CLKID_GP0_PLL 9
13#define CLKID_CLK81 12 17#define CLKID_CLK81 12
18#define CLKID_MPLL0 13
19#define CLKID_MPLL1 14
14#define CLKID_MPLL2 15 20#define CLKID_MPLL2 15
21#define CLKID_DDR 16
22#define CLKID_DOS 17
23#define CLKID_ISA 18
24#define CLKID_PL301 19
25#define CLKID_PERIPHS 20
15#define CLKID_SPICC 21 26#define CLKID_SPICC 21
16#define CLKID_I2C 22 27#define CLKID_I2C 22
17#define CLKID_SAR_ADC 23 28#define CLKID_SAR_ADC 23
29#define CLKID_SMART_CARD 24
18#define CLKID_RNG0 25 30#define CLKID_RNG0 25
19#define CLKID_UART0 26 31#define CLKID_UART0 26
32#define CLKID_SDHC 27
33#define CLKID_STREAM 28
34#define CLKID_ASYNC_FIFO 29
35#define CLKID_SDIO 30
36#define CLKID_ABUF 31
37#define CLKID_HIU_IFACE 32
38#define CLKID_ASSIST_MISC 33
20#define CLKID_SPI 34 39#define CLKID_SPI 34
21#define CLKID_ETH 36 40#define CLKID_ETH 36
41#define CLKID_I2S_SPDIF 35
42#define CLKID_DEMUX 37
22#define CLKID_AIU_GLUE 38 43#define CLKID_AIU_GLUE 38
23#define CLKID_IEC958 39 44#define CLKID_IEC958 39
24#define CLKID_I2S_OUT 40 45#define CLKID_I2S_OUT 40
46#define CLKID_AMCLK 41
47#define CLKID_AIFIFO2 42
48#define CLKID_MIXER 43
25#define CLKID_MIXER_IFACE 44 49#define CLKID_MIXER_IFACE 44
50#define CLKID_ADC 45
51#define CLKID_BLKMV 46
26#define CLKID_AIU 47 52#define CLKID_AIU 47
27#define CLKID_UART1 48 53#define CLKID_UART1 48
54#define CLKID_G2D 49
28#define CLKID_USB0 50 55#define CLKID_USB0 50
29#define CLKID_USB1 51 56#define CLKID_USB1 51
57#define CLKID_RESET 52
58#define CLKID_NAND 53
59#define CLKID_DOS_PARSER 54
30#define CLKID_USB 55 60#define CLKID_USB 55
61#define CLKID_VDIN1 56
62#define CLKID_AHB_ARB0 57
63#define CLKID_EFUSE 58
64#define CLKID_BOOT_ROM 59
65#define CLKID_AHB_DATA_BUS 60
66#define CLKID_AHB_CTRL_BUS 61
67#define CLKID_HDMI_INTR_SYNC 62
31#define CLKID_HDMI_PCLK 63 68#define CLKID_HDMI_PCLK 63
32#define CLKID_USB1_DDR_BRIDGE 64 69#define CLKID_USB1_DDR_BRIDGE 64
33#define CLKID_USB0_DDR_BRIDGE 65 70#define CLKID_USB0_DDR_BRIDGE 65
71#define CLKID_MMC_PCLK 66
72#define CLKID_DVIN 67
34#define CLKID_UART2 68 73#define CLKID_UART2 68
35#define CLKID_SANA 69 74#define CLKID_SANA 69
75#define CLKID_VPU_INTR 70
76#define CLKID_SEC_AHB_AHB3_BRIDGE 71
77#define CLKID_CLK81_A53 72
78#define CLKID_VCLK2_VENCI0 73
79#define CLKID_VCLK2_VENCI1 74
80#define CLKID_VCLK2_VENCP0 75
81#define CLKID_VCLK2_VENCP1 76
36#define CLKID_GCLK_VENCI_INT0 77 82#define CLKID_GCLK_VENCI_INT0 77
83#define CLKID_GCLK_VENCI_INT 78
84#define CLKID_DAC_CLK 79
37#define CLKID_AOCLK_GATE 80 85#define CLKID_AOCLK_GATE 80
38#define CLKID_IEC958_GATE 81 86#define CLKID_IEC958_GATE 81
87#define CLKID_ENC480P 82
88#define CLKID_RNG1 83
89#define CLKID_GCLK_VENCI_INT1 84
90#define CLKID_VCLK2_VENCLMCC 85
91#define CLKID_VCLK2_VENCL 86
92#define CLKID_VCLK_OTHER 87
93#define CLKID_EDP 88
94#define CLKID_AO_MEDIA_CPU 89
95#define CLKID_AO_AHB_SRAM 90
96#define CLKID_AO_AHB_BUS 91
97#define CLKID_AO_IFACE 92
39#define CLKID_AO_I2C 93 98#define CLKID_AO_I2C 93
40#define CLKID_SD_EMMC_A 94 99#define CLKID_SD_EMMC_A 94
41#define CLKID_SD_EMMC_B 95 100#define CLKID_SD_EMMC_B 95
@@ -50,5 +109,9 @@
50#define CLKID_CTS_AMCLK 107 109#define CLKID_CTS_AMCLK 107
51#define CLKID_CTS_MCLK_I958 110 110#define CLKID_CTS_MCLK_I958 110
52#define CLKID_CTS_I958 113 111#define CLKID_CTS_I958 113
112#define CLKID_32K_CLK 114
113#define CLKID_SD_EMMC_A_CLK0 119
114#define CLKID_SD_EMMC_B_CLK0 122
115#define CLKID_SD_EMMC_C_CLK0 125
53 116
54#endif /* __GXBB_CLKC_H */ 117#endif /* __GXBB_CLKC_H */
diff --git a/include/dt-bindings/clock/meson8b-clkc.h b/include/dt-bindings/clock/meson8b-clkc.h
index e29227fb52a1..a9c0306330b6 100644
--- a/include/dt-bindings/clock/meson8b-clkc.h
+++ b/include/dt-bindings/clock/meson8b-clkc.h
@@ -21,15 +21,85 @@
21#define CLKID_ZERO 13 21#define CLKID_ZERO 13
22#define CLKID_MPEG_SEL 14 22#define CLKID_MPEG_SEL 14
23#define CLKID_MPEG_DIV 15 23#define CLKID_MPEG_DIV 15
24#define CLKID_DDR 16
25#define CLKID_DOS 17
26#define CLKID_ISA 18
27#define CLKID_PL301 19
28#define CLKID_PERIPHS 20
29#define CLKID_SPICC 21
30#define CLKID_I2C 22
24#define CLKID_SAR_ADC 23 31#define CLKID_SAR_ADC 23
32#define CLKID_SMART_CARD 24
25#define CLKID_RNG0 25 33#define CLKID_RNG0 25
34#define CLKID_UART0 26
35#define CLKID_SDHC 27
36#define CLKID_STREAM 28
37#define CLKID_ASYNC_FIFO 29
26#define CLKID_SDIO 30 38#define CLKID_SDIO 30
39#define CLKID_ABUF 31
40#define CLKID_HIU_IFACE 32
41#define CLKID_ASSIST_MISC 33
42#define CLKID_SPI 34
43#define CLKID_I2S_SPDIF 35
27#define CLKID_ETH 36 44#define CLKID_ETH 36
45#define CLKID_DEMUX 37
46#define CLKID_AIU_GLUE 38
47#define CLKID_IEC958 39
48#define CLKID_I2S_OUT 40
49#define CLKID_AMCLK 41
50#define CLKID_AIFIFO2 42
51#define CLKID_MIXER 43
52#define CLKID_MIXER_IFACE 44
53#define CLKID_ADC 45
54#define CLKID_BLKMV 46
55#define CLKID_AIU 47
56#define CLKID_UART1 48
57#define CLKID_G2D 49
28#define CLKID_USB0 50 58#define CLKID_USB0 50
29#define CLKID_USB1 51 59#define CLKID_USB1 51
60#define CLKID_RESET 52
61#define CLKID_NAND 53
62#define CLKID_DOS_PARSER 54
30#define CLKID_USB 55 63#define CLKID_USB 55
64#define CLKID_VDIN1 56
65#define CLKID_AHB_ARB0 57
66#define CLKID_EFUSE 58
67#define CLKID_BOOT_ROM 59
68#define CLKID_AHB_DATA_BUS 60
69#define CLKID_AHB_CTRL_BUS 61
70#define CLKID_HDMI_INTR_SYNC 62
71#define CLKID_HDMI_PCLK 63
31#define CLKID_USB1_DDR_BRIDGE 64 72#define CLKID_USB1_DDR_BRIDGE 64
32#define CLKID_USB0_DDR_BRIDGE 65 73#define CLKID_USB0_DDR_BRIDGE 65
74#define CLKID_MMC_PCLK 66
75#define CLKID_DVIN 67
76#define CLKID_UART2 68
33#define CLKID_SANA 69 77#define CLKID_SANA 69
78#define CLKID_VPU_INTR 70
79#define CLKID_SEC_AHB_AHB3_BRIDGE 71
80#define CLKID_CLK81_A9 72
81#define CLKID_VCLK2_VENCI0 73
82#define CLKID_VCLK2_VENCI1 74
83#define CLKID_VCLK2_VENCP0 75
84#define CLKID_VCLK2_VENCP1 76
85#define CLKID_GCLK_VENCI_INT 77
86#define CLKID_GCLK_VENCP_INT 78
87#define CLKID_DAC_CLK 79
88#define CLKID_AOCLK_GATE 80
89#define CLKID_IEC958_GATE 81
90#define CLKID_ENC480P 82
91#define CLKID_RNG1 83
92#define CLKID_GCLK_VENCL_INT 84
93#define CLKID_VCLK2_VENCLMCC 85
94#define CLKID_VCLK2_VENCL 86
95#define CLKID_VCLK2_OTHER 87
96#define CLKID_EDP 88
97#define CLKID_AO_MEDIA_CPU 89
98#define CLKID_AO_AHB_SRAM 90
99#define CLKID_AO_AHB_BUS 91
100#define CLKID_AO_IFACE 92
101#define CLKID_MPLL0 93
102#define CLKID_MPLL1 94
103#define CLKID_MPLL2 95
34 104
35#endif /* __MESON8B_CLKC_H */ 105#endif /* __MESON8B_CLKC_H */
diff --git a/include/dt-bindings/reset/amlogic,meson8b-clkc-reset.h b/include/dt-bindings/reset/amlogic,meson8b-clkc-reset.h
new file mode 100644
index 000000000000..1f1b56e57346
--- /dev/null
+++ b/include/dt-bindings/reset/amlogic,meson8b-clkc-reset.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.com>.
3 *
4 * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
5 */
6
7#ifndef _DT_BINDINGS_AMLOGIC_MESON8B_CLKC_RESET_H
8#define _DT_BINDINGS_AMLOGIC_MESON8B_CLKC_RESET_H
9
10#define CLKC_RESET_L2_CACHE_SOFT_RESET 0
11#define CLKC_RESET_AXI_64_TO_128_BRIDGE_A5_SOFT_RESET 1
12#define CLKC_RESET_SCU_SOFT_RESET 2
13#define CLKC_RESET_CPU0_SOFT_RESET 3
14#define CLKC_RESET_CPU1_SOFT_RESET 4
15#define CLKC_RESET_CPU2_SOFT_RESET 5
16#define CLKC_RESET_CPU3_SOFT_RESET 6
17#define CLKC_RESET_A5_GLOBAL_RESET 7
18#define CLKC_RESET_A5_AXI_SOFT_RESET 8
19#define CLKC_RESET_A5_ABP_SOFT_RESET 9
20#define CLKC_RESET_AXI_64_TO_128_BRIDGE_MMC_SOFT_RESET 10
21#define CLKC_RESET_VID_CLK_CNTL_SOFT_RESET 11
22#define CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_POST 12
23#define CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_PRE 13
24#define CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_POST 14
25#define CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_PRE 15
26
27#endif /* _DT_BINDINGS_AMLOGIC_MESON8B_CLKC_RESET_H */