Skip to contentSkip to conversation

clk: meson: Add G12A AO Clock + Reset Controller

PATCH Superseded Neil Armstrong 3 participants 8 messages Feb 4, 2019 – Feb 7, 2019

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover clk: meson: Add G12A AO Clock + Reset Controller

This patchset add support for the Amlogic G12A SoC family Always-On clock and reset controller.

This adds support for clocks on the Always-On domain like :
- Always-On UARTS & I2C Controllers
- CEC Controllers
- SARADC source and bus clock
- Infrared Decoder/Encoder bus clock
- USB 32K reference clock

This also adds resets lines for :
- Always-On UARTS & I2C Controllers
- SARADC, Infrared Decoder/Encoder

This patchset depends on the ("clk: meson: rework drivers dependencies") from Jerome Brunet at [1].

[1] https://lkml.kernel.org/r/[email protected]

Neil Armstrong (2):
dt-bindings: clk: add G12A AO Clock and Reset Bindings
clk: meson: Add G12A AO Clock + Reset Controller

 .../bindings/clock/amlogic,gxbb-aoclkc.txt    |   1 +
 drivers/clk/meson/Kconfig                     |   2 +
 drivers/clk/meson/Makefile                    |   2 +-
 drivers/clk/meson/g12a-aoclk.c                | 448 ++++++++++++++++++
 drivers/clk/meson/g12a-aoclk.h                |  15 +
 include/dt-bindings/clock/g12a-aoclkc.h       |  43 ++
 include/dt-bindings/reset/g12a-aoclkc.h       |  18 +
 7 files changed, 528 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/meson/g12a-aoclk.c
 create mode 100644 drivers/clk/meson/g12a-aoclk.h
 create mode 100644 include/dt-bindings/clock/g12a-aoclkc.h
 create mode 100644 include/dt-bindings/reset/g12a-aoclkc.h
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 dt-bindings: clk: add G12A AO Clock and Reset Bindings

Add bindings for the Amlogic G12A AO Clock and Reset controllers.

---
 .../bindings/clock/amlogic,gxbb-aoclkc.txt    |  1 +
 include/dt-bindings/clock/g12a-aoclkc.h       | 43 +++++++++++++++++++
 include/dt-bindings/reset/g12a-aoclkc.h       | 18 ++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 include/dt-bindings/clock/g12a-aoclkc.h
 create mode 100644 include/dt-bindings/reset/g12a-aoclkc.h
Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt +1 -0
index 79511d7bb321..c41f0be5d438 100644
@@ -10,6 +10,7 @@ Required Properties:
 	- GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc"
 	- GXM (S912) : "amlogic,meson-gxm-aoclkc"
 	- AXG (A113D, A113X) : "amlogic,meson-axg-aoclkc"
+	- G12A (S905X2, S905D2, S905Y2) : "amlogic,meson-g12a-aoclkc"
 	followed by the common "amlogic,meson-gx-aoclkc"
 - clocks: list of clock phandle, one for each entry clock-names.
 - clock-names: should contain the following:
include/dt-bindings/clock/g12a-aoclkc.h new file +43 -0

43 lines not on this page · raw message

include/dt-bindings/reset/g12a-aoclkc.h new file +18 -0
new file mode 100644
index 000000000000..bd2e2337135c
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2016 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+#define DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+
+#define RESET_AO_IR_IN		0
+#define RESET_AO_UART		1
+#define RESET_AO_I2C_M		2
+#define RESET_AO_I2C_S		3
+#define RESET_AO_SAR_ADC	4
+#define RESET_AO_UART2		5
+#define RESET_AO_IR_OUT		6
+
+#endif
Signature · 1 line
2.20.1
maintainer
#2 lore raw

Re: [PATCH 1/2] dt-bindings: clk: add G12A AO Clock and Reset Bindings

Quoted 51 lines · Neil Armstrong

Add bindings for the Amlogic G12A AO Clock and Reset controllers.

---
 .../bindings/clock/amlogic,gxbb-aoclkc.txt    |  1 +
 include/dt-bindings/clock/g12a-aoclkc.h       | 43 +++++++++++++++++++
 include/dt-bindings/reset/g12a-aoclkc.h       | 18 ++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 include/dt-bindings/clock/g12a-aoclkc.h
 create mode 100644 include/dt-bindings/reset/g12a-aoclkc.h
Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt +1 -0
index 79511d7bb321..c41f0be5d438 100644
@@ -10,6 +10,7 @@ Required Properties:
 	- GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc"
 	- GXM (S912) : "amlogic,meson-gxm-aoclkc"
 	- AXG (A113D, A113X) : "amlogic,meson-axg-aoclkc"
+	- G12A (S905X2, S905D2, S905Y2) : "amlogic,meson-g12a-aoclkc"
 	followed by the common "amlogic,meson-gx-aoclkc"
 - clocks: list of clock phandle, one for each entry clock-names.
 - clock-names: should contain the following:
include/dt- renamed from include/dt-bindings/clock/g12a-aoclkc.h +0 -0

bindings/clock/g12a-aoclkc.h
new file mode 100644
index 000000000000..997aca16c94f

include/dt-bindings/clock/g12a-aoclkc.h new file +20 -0
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2016 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ *
+ * Copyright (c) 2018 Amlogic, inc.
+ * Author: Qiufang Dai <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_CLOCK_AMLOGIC_MESON_G12A_AOCLK
+#define DT_BINDINGS_CLOCK_AMLOGIC_MESON_G12A_AOCLK
+
+#define CLKID_AO_AHB		0
+#define CLKID_AO_IR_IN		1
+#define CLKID_AO_I2C_M0		2
+#define CLKID_AO_I2C_S0		3
+#define CLKID_AO_UART		4
+#define CLKID_AO_PROD_I2C	5
+#define CLKID_AO_UART2		6
+#define CLKID_AO_IR_OUT		7

include/dt-bindings/clock/g12a-aoclkc.h line 30

Quoted 10 lines
include/dt-bindings/clock/g12a-aoclkc.h new file +10 -0
+#define CLKID_AO_SAR_ADC	8
+#define CLKID_AO_MAILBOX	9
+#define CLKID_AO_M3		10
+#define CLKID_AO_AHB_SRAM	11
+#define CLKID_AO_RTI		12
+#define CLKID_AO_M4_FCLK	13
+#define CLKID_AO_M4_HCLK	14
+#define CLKID_AO_CLK81		15
+#define CLKID_AO_SAR_ADC_SEL	16
+#define CLKID_AO_SAR_ADC_DIV	17

Do we need to export the internal part of these composite clock ? I know the other AO controller do it but it would be nice to avoid it, like for the EE controllers ... unless there is good reason of course.

Same for the others below.

Quoted 38 lines
include/dt-bindings/clock/g12a-aoclkc.h new file +13 -0
+#define CLKID_AO_SAR_ADC_CLK	18
+#define CLKID_AO_CTS_OSCIN	19
+#define CLKID_AO_32K_PRE	20
+#define CLKID_AO_32K_DIV	21
+#define CLKID_AO_32K_SEL	22
+#define CLKID_AO_32K		23
+#define CLKID_AO_CEC_PRE	24
+#define CLKID_AO_CEC_DIV	25
+#define CLKID_AO_CEC_SEL	26
+#define CLKID_AO_CEC		27
+#define CLKID_AO_CTS_RTC_OSCIN	28
+
+#endif
include/dt- renamed from include/dt-bindings/reset/g12a-aoclkc.h +0 -0

bindings/reset/g12a-aoclkc.h
new file mode 100644
index 000000000000..bd2e2337135c

include/dt-bindings/reset/g12a-aoclkc.h new file +18 -0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2016 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+#define DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+
+#define RESET_AO_IR_IN		0
+#define RESET_AO_UART		1
+#define RESET_AO_I2C_M		2
+#define RESET_AO_I2C_S		3
+#define RESET_AO_SAR_ADC	4
+#define RESET_AO_UART2		5
+#define RESET_AO_IR_OUT		6
+
+#endif
#3 lore raw

Re: [PATCH 1/2] dt-bindings: clk: add G12A AO Clock and Reset Bindings

Quoted 58 lines · Jerome Brunet
Quoted 57 lines · Neil Armstrong

Add bindings for the Amlogic G12A AO Clock and Reset controllers.

---
 .../bindings/clock/amlogic,gxbb-aoclkc.txt    |  1 +
 include/dt-bindings/clock/g12a-aoclkc.h       | 43 +++++++++++++++++++
 include/dt-bindings/reset/g12a-aoclkc.h       | 18 ++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 include/dt-bindings/clock/g12a-aoclkc.h
 create mode 100644 include/dt-bindings/reset/g12a-aoclkc.h
Documentation/devicetree/bindings/clock/amlogic,gxbb-aoclkc.txt +1 -0
index 79511d7bb321..c41f0be5d438 100644
@@ -10,6 +10,7 @@ Required Properties:
 	- GXL (S905X, S905D) : "amlogic,meson-gxl-aoclkc"
 	- GXM (S912) : "amlogic,meson-gxm-aoclkc"
 	- AXG (A113D, A113X) : "amlogic,meson-axg-aoclkc"
+	- G12A (S905X2, S905D2, S905Y2) : "amlogic,meson-g12a-aoclkc"
 	followed by the common "amlogic,meson-gx-aoclkc"
 - clocks: list of clock phandle, one for each entry clock-names.
 - clock-names: should contain the following:
include/dt- renamed from include/dt-bindings/clock/g12a-aoclkc.h +0 -0

bindings/clock/g12a-aoclkc.h
new file mode 100644
index 000000000000..997aca16c94f

include/dt-bindings/clock/g12a-aoclkc.h new file +26 -0
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2016 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ *
+ * Copyright (c) 2018 Amlogic, inc.
+ * Author: Qiufang Dai <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_CLOCK_AMLOGIC_MESON_G12A_AOCLK
+#define DT_BINDINGS_CLOCK_AMLOGIC_MESON_G12A_AOCLK
+
+#define CLKID_AO_AHB		0
+#define CLKID_AO_IR_IN		1
+#define CLKID_AO_I2C_M0		2
+#define CLKID_AO_I2C_S0		3
+#define CLKID_AO_UART		4
+#define CLKID_AO_PROD_I2C	5
+#define CLKID_AO_UART2		6
+#define CLKID_AO_IR_OUT		7
+#define CLKID_AO_SAR_ADC	8
+#define CLKID_AO_MAILBOX	9
+#define CLKID_AO_M3		10
+#define CLKID_AO_AHB_SRAM	11
+#define CLKID_AO_RTI		12
+#define CLKID_AO_M4_FCLK	13
Quoted 8 lines

include/dt-bindings/clock/g12a-aoclkc.h line 30

Quoted 4 lines
include/dt-bindings/clock/g12a-aoclkc.h new file +4 -0
+#define CLKID_AO_M4_HCLK	14
+#define CLKID_AO_CLK81		15
+#define CLKID_AO_SAR_ADC_SEL	16
+#define CLKID_AO_SAR_ADC_DIV	17

Do we need to export the internal part of these composite clock ? I know the other AO controller do it but it would be nice to avoid it, like for the EE controllers ... unless there is good reason of course.

Historically, we exposed everything for the AO controller, we can follow the same scheme as the EE controller starting from this one.
There is no strong reason to expose everything...

I'll res-pin a v2 with both issues fixed.

Quoted 43 lines

Same for the others below.

Quoted 38 lines
include/dt-bindings/clock/g12a-aoclkc.h new file +13 -0
+#define CLKID_AO_SAR_ADC_CLK	18
+#define CLKID_AO_CTS_OSCIN	19
+#define CLKID_AO_32K_PRE	20
+#define CLKID_AO_32K_DIV	21
+#define CLKID_AO_32K_SEL	22
+#define CLKID_AO_32K		23
+#define CLKID_AO_CEC_PRE	24
+#define CLKID_AO_CEC_DIV	25
+#define CLKID_AO_CEC_SEL	26
+#define CLKID_AO_CEC		27
+#define CLKID_AO_CTS_RTC_OSCIN	28
+
+#endif
include/dt- renamed from include/dt-bindings/reset/g12a-aoclkc.h +0 -0

bindings/reset/g12a-aoclkc.h
new file mode 100644
index 000000000000..bd2e2337135c

include/dt-bindings/reset/g12a-aoclkc.h new file +18 -0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2016 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#ifndef DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+#define DT_BINDINGS_RESET_AMLOGIC_MESON_G12A_AOCLK
+
+#define RESET_AO_IR_IN		0
+#define RESET_AO_UART		1
+#define RESET_AO_I2C_M		2
+#define RESET_AO_I2C_S		3
+#define RESET_AO_SAR_ADC	4
+#define RESET_AO_UART2		5
+#define RESET_AO_IR_OUT		6
+
+#endif
#4 lore raw

PATCH 2/2 clk: meson: Add G12A AO Clock + Reset Controller

In reply to Neil Armstrong

Add the Amlogic G12A AO Clock and Reset controller driver handling generation of Always-On clocks :
- AO Clocks and Reset for Always-On modules
- 32K Generation for USB and CEC
- SAR ADC controller clock

---
 drivers/clk/meson/Kconfig      |   2 +
 drivers/clk/meson/Makefile     |   2 +-
 drivers/clk/meson/g12a-aoclk.c | 448 +++++++++++++++++++++++++++++++++
 drivers/clk/meson/g12a-aoclk.h |  15 ++
 4 files changed, 466 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/meson/g12a-aoclk.c
 create mode 100644 drivers/clk/meson/g12a-aoclk.h
drivers/clk/meson/Kconfig +2 -0
index b72439315340..3858747f5438 100644
@@ -98,8 +98,10 @@ config COMMON_CLK_G12A
 	bool
 	depends on ARCH_MESON
 	select COMMON_CLK_MESON_REGMAP
+	select COMMON_CLK_MESON_DUALDIV
 	select COMMON_CLK_MESON_MPLL
 	select COMMON_CLK_MESON_PLL
+	select COMMON_CLK_MESON_AO_CLKC
 	select COMMON_CLK_MESON_EE_CLKC
 	select MFD_SYSCON
 	help
drivers/clk/meson/Makefile +1 -1
index 32d17f18541e..021fc290e749 100644
@@ -16,5 +16,5 @@ obj-$(CONFIG_COMMON_CLK_MESON_VID_PLL_DIV) += vid-pll-div.o
 obj-$(CONFIG_COMMON_CLK_AXG) += axg.o axg-aoclk.o
 obj-$(CONFIG_COMMON_CLK_AXG_AUDIO) += axg-audio.o
 obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o
-obj-$(CONFIG_COMMON_CLK_G12A) += g12a.o
+obj-$(CONFIG_COMMON_CLK_G12A) += g12a.o g12a-aoclk.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
drivers/clk/meson/g12a-aoclk.c new file +448 -0

448 lines not on this page · raw message

drivers/clk/meson/g12a-aoclk.h new file +15 -0
new file mode 100644
index 000000000000..9ebfa25688eb
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * Copyright (c) 2019 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#ifndef __G12A_AOCLKC_H
+#define __G12A_AOCLKC_H
+
+#define NR_CLKS	29
+
+#include <dt-bindings/clock/g12a-aoclkc.h>
+#include <dt-bindings/reset/g12a-aoclkc.h>
+
+#endif /* __G12A_AOCLKC_H */
Signature · 1 line
2.20.1
maintainer
#5 lore raw

Quoting Neil Armstrong (2019-02-04 01:13:30)

Quoted 16 lines

+ * Register offsets from the data sheet must be multiplied by 4.
+ */

drivers/clk/meson/g12a-aoclk.c new file +14 -0
+#define AO_RTI_STATUS_REG3     0x0C
+#define AO_RTI_PWR_CNTL_REG0   0x10
+#define AO_RTI_GEN_CNTL_REG0   0x40
+#define AO_CLK_GATE0           0x4c
+#define AO_CLK_GATE0_SP                0x50
+#define AO_OSCIN_CNTL          0x58
+#define AO_CEC_CLK_CNTL_REG0   0x74
+#define AO_CEC_CLK_CNTL_REG1   0x78
+#define AO_SAR_CLK             0x90
+#define AO_RTC_ALT_CLK_CNTL0   0x94
+#define AO_RTC_ALT_CLK_CNTL1   0x98
+
+#define AXG_AO_GATE(_name, _reg, _bit)                                 \
+static struct clk_regmap g12a_aoclk_##_name = {                                \

drivers/clk/meson/g12a-aoclk.c line 50

Quoted 10 lines
drivers/clk/meson/g12a-aoclk.c new file +10 -0
+       .data = &(struct clk_regmap_gate_data) {                        \
+               .offset = (_reg),                                       \
+               .bit_idx = (_bit),                                      \
+       },                                                              \
+       .hw.init = &(struct clk_init_data) {                            \
+               .name =  "g12a_ao_" #_name,                             \
+               .ops = &clk_regmap_gate_ops,                            \
+               .parent_names = (const char *[]){ IN_PREFIX "mpeg-clk" }, \
+               .num_parents = 1,                                       \
+               .flags = CLK_IGNORE_UNUSED,                             \

Can you please add a comment explaining why CLK_IGNORE_UNUSED is here? It will help future readers know what's going on with this special flag.

#6 lore raw

Hi,

Quoted 22 lines · Stephen Boyd

Quoting Neil Armstrong (2019-02-04 01:13:30)

Quoted 21 lines

+ * Register offsets from the data sheet must be multiplied by 4.
+ */

drivers/clk/meson/g12a-aoclk.c new file +19 -0
+#define AO_RTI_STATUS_REG3     0x0C
+#define AO_RTI_PWR_CNTL_REG0   0x10
+#define AO_RTI_GEN_CNTL_REG0   0x40
+#define AO_CLK_GATE0           0x4c
+#define AO_CLK_GATE0_SP                0x50
+#define AO_OSCIN_CNTL          0x58
+#define AO_CEC_CLK_CNTL_REG0   0x74
+#define AO_CEC_CLK_CNTL_REG1   0x78
+#define AO_SAR_CLK             0x90
+#define AO_RTC_ALT_CLK_CNTL0   0x94
+#define AO_RTC_ALT_CLK_CNTL1   0x98
+
+#define AXG_AO_GATE(_name, _reg, _bit)                                 \
+static struct clk_regmap g12a_aoclk_##_name = {                                \
+       .data = &(struct clk_regmap_gate_data) {                        \
+               .offset = (_reg),                                       \
+               .bit_idx = (_bit),                                      \
+       },                                                              \
+       .hw.init = &(struct clk_init_data) {                            \
Quoted 9 lines

drivers/clk/meson/g12a-aoclk.c line 50

Quoted 5 lines
drivers/clk/meson/g12a-aoclk.c new file +5 -0
+               .name =  "g12a_ao_" #_name,                             \
+               .ops = &clk_regmap_gate_ops,                            \
+               .parent_names = (const char *[]){ IN_PREFIX "mpeg-clk" }, \
+               .num_parents = 1,                                       \
+               .flags = CLK_IGNORE_UNUSED,                             \

Can you please add a comment explaining why CLK_IGNORE_UNUSED is here? It will help future readers know what's going on with this special flag.

Sure, I'll add it.

Neil

maintainer Acked-by on the v1 series
#7 lore raw
In reply to Neil Armstrong
Quoted 23 lines · Neil Armstrong

This patchset add support for the Amlogic G12A SoC family Always-On clock and reset controller.

This adds support for clocks on the Always-On domain like :
- Always-On UARTS & I2C Controllers
- CEC Controllers
- SARADC source and bus clock
- Infrared Decoder/Encoder bus clock
- USB 32K reference clock

This also adds resets lines for :
- Always-On UARTS & I2C Controllers
- SARADC, Infrared Decoder/Encoder

This patchset depends on the ("clk: meson: rework drivers dependencies") from Jerome Brunet at [1].

[1] https://lkml.kernel.org/r/[email protected]

Neil Armstrong (2):
dt-bindings: clk: add G12A AO Clock and Reset Bindings
clk: meson: Add G12A AO Clock + Reset Controller

Quoted 12 lines
 .../bindings/clock/amlogic,gxbb-aoclkc.txt    |   1 +
 drivers/clk/meson/Kconfig                     |   2 +
 drivers/clk/meson/Makefile                    |   2 +-
 drivers/clk/meson/g12a-aoclk.c                | 448 ++++++++++++++++++
 drivers/clk/meson/g12a-aoclk.h                |  15 +
 include/dt-bindings/clock/g12a-aoclkc.h       |  43 ++
 include/dt-bindings/reset/g12a-aoclkc.h       |  18 +
 7 files changed, 528 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/meson/g12a-aoclk.c
 create mode 100644 drivers/clk/meson/g12a-aoclk.h
 create mode 100644 include/dt-bindings/clock/g12a-aoclkc.h
 create mode 100644 include/dt-bindings/reset/g12a-aoclkc.h

Nothing out the ordinary, just a minor comment on the bindings.