Skip to contentSkip to conversation

ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

PATCH New Chen-Yu Tsai 3 participants 10 messages Mar 3, 2015 – Apr 25, 2015 2 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

Hi everyone,

Some time ago I sent out an RFC series, which was not merged due to lack of matching documentation for the SoC. A few weeks back I sent out a request for the documents again. I have not received a response. So I'm sending out the series now.

This series adds support for the Power Reset and Clock Management module on Allwinner's A80 SoC. The PRCM manages clocks and resets for the "special" block of peripherals, or the R/RTC block in earlier SoCs. These peripherals include a standby processor core, a timer block, a watchdog, pin controller, 1 wire interface, PS/2 interface, a UART, the RSB controller, a DMA controller, a consumer IR receiver block, 2 I2C controllers, and 2 I2S controllers. We do not have documents for all the peripherals. Support will be added where possible.

Patch 1 adds support for the apbs (apb0 in earlier SoCs) gates.

Patch 2 adds sun9i-a80 support to the PRCM mfd driver

Patch 3 adds the clock and reset nodes for the PRCM to the A80 DTSI.

To Allwinner people:
If you have any related documents or comments, please send them out.

Regards,
ChenYu

Chen-Yu Tsai (3):
clk: sunxi: sun6i-apb0: Add support for sun9i A80 apbs gates
mfd: sun6i-prcm: Add support for PRCM found on Allwinner A80 SoC
ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes

 Documentation/devicetree/bindings/clock/sunxi.txt  |  1 +
 .../devicetree/bindings/mfd/sun6i-prcm.txt         |  3 +-
 arch/arm/boot/dts/sun9i-a80.dtsi                   | 54 +++++++++++++++++++-
 drivers/clk/sunxi/clk-sun6i-apb0-gates.c           |  6 +++
 drivers/mfd/sun6i-prcm.c                           | 58 ++++++++++++++++++++++
 5 files changed, 120 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/3 clk: sunxi: sun6i-apb0: Add support for sun9i A80 apbs gates

This patch adds support for the PRCM apbs clock gates found on the Allwinner A80 SoC.

The gate bitmask is not complete. The lowest 7 bits seem to be the same as found on the A31, judging by Allwinner's kernel sources and what was enabled by the bootloader. Bits 17 and 18 are documented in the SDK sources.

This still leaves some peripherals missing, such as the dma controller, a second i2c controller, and 2 PS/2 controllers.

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 drivers/clk/sunxi/clk-sun6i-apb0-gates.c          | 6 ++++++
 2 files changed, 7 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
index 3f1dcd879af7..60c85071d022 100644
@@ -54,6 +54,7 @@ Required properties:
 	"allwinner,sun9i-a80-apb1-gates-clk" - for the APB1 gates on A80
 	"allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31
 	"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
+	"allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80
 	"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
 	"allwinner,sun4i-a10-mmc-clk" - for the MMC clock
 	"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
drivers/clk/sunxi/clk-sun6i-apb0-gates.c +6 -0
index 64f3e46d383c..0039b7375a40 100644
@@ -29,9 +29,15 @@ static const struct gates_data sun8i_a23_apb0_gates __initconst = {
 	.mask = {0x5D},
 };
 
+/* XXX This is an imcomplete mask due to a lack of documents */
+static const struct gates_data sun9i_a80_apbs_gates __initconst = {
+	.mask = {0x6007f},
+};
+
 static const struct of_device_id sun6i_a31_apb0_gates_clk_dt_ids[] = {
 	{ .compatible = "allwinner,sun6i-a31-apb0-gates-clk", .data = &sun6i_a31_apb0_gates },
 	{ .compatible = "allwinner,sun8i-a23-apb0-gates-clk", .data = &sun8i_a23_apb0_gates },
+	{ .compatible = "allwinner,sun9i-a80-apbs-gates-clk", .data = &sun9i_a80_apbs_gates },
 	{ /* sentinel */ }
 };
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/3 mfd: sun6i-prcm: Add support for PRCM found on Allwinner A80 SoC

In reply to Chen-Yu Tsai

This patch adds support for the PRCM on the A80 SoC. There is little to no document for this at the moment. Only register offsets are available. However with some testing, the clock and reset controls seem to be the similar to the ones on the A31.

One thing that needs verifying is whether the apbs divider is the same as the A31 or the A23. The lowest divider is different between those 2 implementations.

---
 .../devicetree/bindings/mfd/sun6i-prcm.txt         |  3 +-
 drivers/mfd/sun6i-prcm.c                           | 58 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mfd/sun6i-prcm.txt +2 -1
index 03c5a551da55..c100abfcb2a4 100644
@@ -4,7 +4,8 @@ PRCM is an MFD device exposing several Power Management related devices
 (like clks and reset controllers).
 
 Required properties:
- - compatible: "allwinner,sun6i-a31-prcm" or "allwinner,sun8i-a23-prcm"
+ - compatible: "allwinner,sun6i-a31-prcm", "allwinner,sun8i-a23-prcm",
+	       "allwinner,sun9i-a80-prcm"
  - reg: The PRCM registers range
 
 The prcm node may contain several subdevices definitions:
drivers/mfd/sun6i-prcm.c +58 -0

82 lines not on this page · raw message

Signature · 1 line
2.1.4
#3 lore raw

PATCH 2/3 mfd: sun6i-prcm: Add support for PRCM found on Allwinner A80 SoC

Quoted 9 lines · Chen-Yu Tsai

This patch adds support for the PRCM on the A80 SoC. There is little to no document for this at the moment. Only register offsets are available. However with some testing, the clock and reset controls seem to be the similar to the ones on the A31.

One thing that needs verifying is whether the apbs divider is the same as the A31 or the A23. The lowest divider is different between those 2 implementations.

Quoted 5 lines
---
 .../devicetree/bindings/mfd/sun6i-prcm.txt         |  3 +-
 drivers/mfd/sun6i-prcm.c                           | 58 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)
Quoted 104 lines
Documentation/devicetree/bindings/mfd/sun6i-prcm.txt +2 -1
index 03c5a551da55..c100abfcb2a4 100644
@@ -4,7 +4,8 @@ PRCM is an MFD device exposing several Power Management related devices
 (like clks and reset controllers).
 
 Required properties:
- - compatible: "allwinner,sun6i-a31-prcm" or "allwinner,sun8i-a23-prcm"
+ - compatible: "allwinner,sun6i-a31-prcm", "allwinner,sun8i-a23-prcm",
+	       "allwinner,sun9i-a80-prcm"
  - reg: The PRCM registers range
 
 The prcm node may contain several subdevices definitions:
drivers/mfd/sun6i-prcm.c +58 -0
index 191173166d65..d067c77fb512 100644
@@ -33,6 +33,22 @@ static const struct resource sun6i_a31_apb0_clk_res[] = {
 	},
 };
 
+static const struct resource sun9i_a80_cpus_clk_res[] = {
+	{
+		.start = 0x10,
+		.end = 0x13,
+		.flags = IORESOURCE_MEM,
+	},
+};
+
+static const struct resource sun9i_a80_apbs_clk_res[] = {
+	{
+		.start = 0x1c,
+		.end = 0x1f,
+		.flags = IORESOURCE_MEM,
+	},
+};
+
 static const struct resource sun6i_a31_apb0_gates_clk_res[] = {
 	{
 		.start = 0x28,
@@ -111,6 +127,39 @@ static const struct mfd_cell sun8i_a23_prcm_subdevs[] = {
 	},
 };
 
+static const struct mfd_cell sun9i_a80_prcm_subdevs[] = {
+	{
+		.name = "sun6i-a31-ar100-clk",
+		.of_compatible = "allwinner,sun6i-a31-ar100-clk",
+		.num_resources = ARRAY_SIZE(sun9i_a80_cpus_clk_res),
+		.resources = sun9i_a80_cpus_clk_res,
+	},
+	{
+		.name = "sun8i-a23-apb0-clk",
+		.of_compatible = "allwinner,sun8i-a23-apb0-clk",
+		.num_resources = ARRAY_SIZE(sun9i_a80_apbs_clk_res),
+		.resources = sun9i_a80_apbs_clk_res,
+	},
+	{
+		.name = "sun6i-a31-apb0-gates-clk",
+		.of_compatible = "allwinner,sun9i-a80-apbs-gates-clk",
+		.num_resources = ARRAY_SIZE(sun6i_a31_apb0_gates_clk_res),
+		.resources = sun6i_a31_apb0_gates_clk_res,
+	},
+	{
+		.name = "sun6i-a31-ir-clk",
+		.of_compatible = "allwinner,sun4i-a10-mod0-clk",
+		.num_resources = ARRAY_SIZE(sun6i_a31_ir_clk_res),
+		.resources = sun6i_a31_ir_clk_res,
+	},
+	{
+		.name = "sun6i-a31-apb0-clock-reset",
+		.of_compatible = "allwinner,sun6i-a31-clock-reset",
+		.num_resources = ARRAY_SIZE(sun6i_a31_apb0_rstc_res),
+		.resources = sun6i_a31_apb0_rstc_res,
+	},
+};
+
 static const struct prcm_data sun6i_a31_prcm_data = {
 	.nsubdevs = ARRAY_SIZE(sun6i_a31_prcm_subdevs),
 	.subdevs = sun6i_a31_prcm_subdevs,
@@ -121,6 +170,11 @@ static const struct prcm_data sun8i_a23_prcm_data = {
 	.subdevs = sun8i_a23_prcm_subdevs,
 };
 
+static const struct prcm_data sun9i_a80_prcm_data = {
+	.nsubdevs = ARRAY_SIZE(sun9i_a80_prcm_subdevs),
+	.subdevs = sun9i_a80_prcm_subdevs,
+};
+
 static const struct of_device_id sun6i_prcm_dt_ids[] = {
 	{
 		.compatible = "allwinner,sun6i-a31-prcm",
@@ -130,6 +184,10 @@ static const struct of_device_id sun6i_prcm_dt_ids[] = {
 		.compatible = "allwinner,sun8i-a23-prcm",
 		.data = &sun8i_a23_prcm_data,
 	},
+	{
+		.compatible = "allwinner,sun9i-a80-prcm",
+		.data = &sun9i_a80_prcm_data,
+	},
 	{ /* sentinel */ },
 };
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

PATCH 3/3 ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes

In reply to Chen-Yu Tsai

This adds the PRCM clocks and reset controls to the A80 dtsi.

The list of apbs clock gates is incomplete. Tests show that bits 0~20 are mutable. We will need documents from Allwinner to complete the support.

Also update clock and reset phandles for r_uart.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 54 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)
arch/arm/boot/dts/sun9i-a80.dtsi +53 -1
index 2f7f82cc86ba..8db78d87bdb9 100644
@@ -733,13 +733,65 @@
 			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
+		prcm at 08001400 {
+			compatible = "allwinner,sun9i-a80-prcm";
+			reg = <0x08001400 0x200>;
+
+			cpus_clk: cpus_clk {
+				compatible = "allwinner,sun6i-a31-ar100-clk";
+				#clock-cells = <0>;
+				clocks = <&osc32k>, <&osc24M>, <&pll4>;
+				clock-output-names = "cpus";
+			};
+
+			ahbs: ahbs_clk {
+				compatible = "fixed-factor-clock";
+				#clock-cells = <0>;
+				clock-div = <1>;
+				clock-mult = <1>;
+				clocks = <&cpus_clk>;
+				clock-output-names = "ahbs";
+			};
+
+			apbs: apbs_clk {
+				compatible = "allwinner,sun8i-a23-apb0-clk";
+				#clock-cells = <0>;
+				clocks = <&ahbs>;
+				clock-output-names = "apbs";
+			};
+
+			apbs_gates: apbs_gates_clk {
+				compatible = "allwinner,sun9i-a80-apbs-gates-clk";
+				#clock-cells = <1>;
+				clocks = <&apbs>;
+				clock-output-names = "apbs_pio", "apbs_ir",
+						"apbs_timer", "apbs_rsb",
+						"apbs_uart", "apbs_1wire",
+						"apbs_i2c", "apbs_i2s0",
+						"apbs_i2s1";
+			};
+
+			r_ir_clk: r_ir_clk {
+				#clock-cells = <0>;
+				compatible = "allwinner,sun4i-a10-mod0-clk";
+				clocks = <&osc32k>, <&osc24M>;
+				clock-output-names = "r_ir";
+			};
+
+			apbs_rst: apbs_rst {
+				compatible = "allwinner,sun6i-a31-clock-reset";
+				#reset-cells = <1>;
+			};
+		};
+
 		r_uart: serial at 08002800 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0x08002800 0x400>;
 			interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc24M>;
+			clocks = <&apbs_gates 4>;
+			resets = <&apbs_rst 4>;
 			status = "disabled";
 		};
 	};
Signature · 1 line
2.1.4
#5 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

In reply to Chen-Yu Tsai

Hi Chen-Yu,

Quoted 18 lines · Chen-Yu Tsai

Hi everyone,

Some time ago I sent out an RFC series, which was not merged due to lack of matching documentation for the SoC. A few weeks back I sent out a request for the documents again. I have not received a response. So I'm sending out the series now.

This series adds support for the Power Reset and Clock Management module on Allwinner's A80 SoC. The PRCM manages clocks and resets for the "special" block of peripherals, or the R/RTC block in earlier SoCs. These peripherals include a standby processor core, a timer block, a watchdog, pin controller, 1 wire interface, PS/2 interface, a UART, the RSB controller, a DMA controller, a consumer IR receiver block, 2 I2C controllers, and 2 I2S controllers. We do not have documents for all the peripherals. Support will be added where possible.

Quoted 5 lines

Patch 1 adds support for the apbs (apb0 in earlier SoCs) gates.

Patch 2 adds sun9i-a80 support to the PRCM mfd driver

Patch 3 adds the clock and reset nodes for the PRCM to the A80 DTSI.

These three patches look fine to me. Have you seen that the new bootloader code has some interesting infos about RSB and PRCM?

If so, does it match what you did so far?

Quoted 2 lines

To Allwinner people:
If you have any related documents or comments, please send them out.

Kevin, Shuge, your input would be greatly appreciated.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150308/15daee82/attachment.sig>
#6 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

Hi,

Quoted 23 lines · Maxime Ripard

Hi Chen-Yu,

Quoted 20 lines · Chen-Yu Tsai

Hi everyone,

Some time ago I sent out an RFC series, which was not merged due to lack of matching documentation for the SoC. A few weeks back I sent out a request for the documents again. I have not received a response. So I'm sending out the series now.

This series adds support for the Power Reset and Clock Management module on Allwinner's A80 SoC. The PRCM manages clocks and resets for the "special" block of peripherals, or the R/RTC block in earlier SoCs. These peripherals include a standby processor core, a timer block, a watchdog, pin controller, 1 wire interface, PS/2 interface, a UART, the RSB controller, a DMA controller, a consumer IR receiver block, 2 I2C controllers, and 2 I2S controllers. We do not have documents for all the peripherals. Support will be added where possible.

Patch 1 adds support for the apbs (apb0 in earlier SoCs) gates.

Quoted 8 lines
Quoted 3 lines

Patch 2 adds sun9i-a80 support to the PRCM mfd driver

Patch 3 adds the clock and reset nodes for the PRCM to the A80 DTSI.

These three patches look fine to me. Have you seen that the new bootloader code has some interesting infos about RSB and PRCM?

If so, does it match what you did so far?

It does. Though that's the only stuff I found on PRCM in there. Previously I used u-boot and kernel sources from the SDK as a source of information.

ChenYu

Quoted 12 lines
Quoted 2 lines

To Allwinner people:
If you have any related documents or comments, please send them out.

Kevin, Shuge, your input would be greatly appreciated.

Thanks!
Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

Hi Kevin,

Quoted 5 lines · kevin at allwinnertech.com

Dear All,

I have requested to release the document for the PRCM, but need my boss support. I will try my best to convince them, and provide the document ASAP. If any progress, I will update to you immediately.

Ok, thanks a lot!

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150310/9b55a9dd/attachment.sig>

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

Hi Kevin,

Quoted 4 lines · kevin at allwinnertech.com

Hi, Maxime,

We have add the PRCM module description to the A80 document.
You can download it from the github: https://github.com/allwinner-zh/documents

Awesome, thanks a lot.

We'll look into it.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150330/245c3aab/attachment-0001.sig>
#11 lore raw

cover ARM: sun9i: Add support for PRCM on Allwinner A80 SoC

Hi Kevin,

(Dropped a few people from CC.)

Quoted 11 lines · maxime.ripard

Hi Kevin,

Quoted 4 lines · kevin at allwinnertech.com

Hi, Maxime,

We have add the PRCM module description to the A80 document.
You can download it from the github: https://github.com/allwinner-zh/documents

Awesome, thanks a lot.

We'll look into it.

I looked at the new PRCM description, which is very detailed. I have some questions though:

1. There is a "PLL_AUDIO control". Is this a new PLL? Or just another set of mapped
registers for PLL_AUDIO in CCU? I assume it is the latter.

2. What is the source of "24 MHz" in the main CCU? The external 24 MHz oscillator
(HOSC) or the mux after HOSC and CLK16M_RC? (ref: page 331, the
PRCM block diagram)

Please help clarify them. Thank you.

Regards
ChenYu