Skip to contentSkip to conversation

ARM: sun9i: Enable MMC support on Allwinner A80

PATCH Superseded Chen-Yu Tsai 2 participants 30 messages Jan 13, 2015 – Jan 15, 2015

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover ARM: sun9i: Enable MMC support on Allwinner A80

Hi Maxime,

This is v3 of the sun9i mmc series. It is based on your v3 of your sunxi mmc phase clocks series. v3 has 2 new patches. Patch 1 generalizes the mmc phase clock setup function, like you asked. Patch 10 converts the a80 optimus board to using label references.

This series enables MMC support on the A80 using existing drivers we have. The A80 has 4 MMC controllers. These controllers share a common clock gate and reset control, which are then sub-divided to each controller.

The phase clocks are the same as the older SoCs, so it should be straight forward to add them with the rest of the sunxi family. I did find that Allwinner's kernel uses different delay values for the A80, but so far I've not run into any issues using the mainline kernel.

Patch 1 adds a generic setup function for the mmc module/phase clocks, which is re-used in patch 2.

Patch 2 adds module 0 type clock support for the A80. These are essentially the same as mod0 clocks on other Allwinner SoCs, except for the wider mux bits.

Patch 3 adds mmc mod clocks to the DTSI.

Patch 4 adds support for the mmc config (term from user manual) clocks. This is the part that breaks out the clock gates and reset controls for each controller. This is implemented as a platform driver, as the shared reset control must be de-asserted for any of either this or the mmc blocks to work.

Patch 5 adds clock-indices properties to the AHB/APB gate clocks. This is needed for of_clk_get_parent_name to work properly, as we use bit indices instead of counting the entries.

Patch 6 adds the mmc config clock nodes to the DTSI.

Patch 7 changes sunxi-common-regulators.dtsi to use labels to reference the pio node.

Patch 8 adds the mmc controller nodes to the DTSI.

Patch 9 and 12 add the pinmux settings for mmc0 and mmc2.

Patch 10 converts the a80 optimus board dts to using label references, which is the preferred way, before enabling any new devices.

Patch 11 and 13 enable mmc0 and mmc2 on the A80 Optimus Board.

Kudos to Andreas for figuring out all the DT bits. His SoB is on the relevant patches.

Changes since v2:

- Rebased onto current sunxi-next and sunxi mmc phase clock series v3
- Added patch "clk: sunxi: Add a common setup function for mmc module clocks"
- Use new common setup function for a80 mmc module clocks
- Added patch "ARM: dts: sun9i: Convert a80 optimus board dts to label referencing"
- Use label referencing in a80 optimus board dts

Changes since v1:

- Use sunxi-common-regulators.dtsi for vmmc regulator
- Rebased onto sunxi mmc phase clock series v2
- Use new multi-output mmc module clock style
- Rename sun9i mmc config clock name and compatible
- Make mmc2_pins include all pins needed, and change name to mmc2_8bit_pins
- Add spaces between pin names in mmc pins
- Add clk_prepare_enable()/clk_disable_unprepare() calls to reset control ops for the mmc config clock
- Use DIV_ROUND_UP when calculating number of clocks in sun9i mmc config clock probe function
- Add required properties and outputs section for sun9i mmc config clock in bindings doc; also add an example

Cheers
ChenYu Tsai

Chen-Yu Tsai (13):
clk: sunxi: Add a common setup function for mmc module clocks
clk: sunxi: Add mod0 and mmc module clock support for A80
ARM: dts: sun9i: Add mmc module clock nodes for A80
clk: sunxi: Add driver for A80 MMC config clocks/resets
ARM: dts: sun9i: Add clock-indices property for bus gate clocks
ARM: dts: sun9i: Add mmc config clock nodes
ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators
ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi
ARM: dts: sun9i: Add pinmux setting for mmc0
ARM: dts: sun9i: Convert a80 optimus board dts to label referencing
ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board
ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2
ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board

 Documentation/devicetree/bindings/clock/sunxi.txt |  30 ++-
 arch/arm/boot/dts/sun9i-a80-optimus.dts           | 103 ++++++----
 arch/arm/boot/dts/sun9i-a80.dtsi                  | 124 ++++++++++++
 arch/arm/boot/dts/sunxi-common-regulators.dtsi    |  54 +++---
 drivers/clk/sunxi/Makefile                        |   1 +
 drivers/clk/sunxi/clk-mod0.c                      |  58 +++++-
 drivers/clk/sunxi/clk-sun9i-mmc.c                 | 222 ++++++++++++++++++++++
 7 files changed, 516 insertions(+), 76 deletions(-)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-mmc.c
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/13 clk: sunxi: Add a common setup function for mmc module clocks

The only difference between module clocks on different platforms is the width of the mux register bits and the valid values, which are passed in through struct factors_data. The phase clocks parts are identical.

This patch generalizes the setup function, so most of the code can be reused when adding sun9i support, which has a wider mux register.

---
 drivers/clk/sunxi/clk-mod0.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/clk/sunxi/clk-mod0.c +19 -7
index e37eb6fe19e8..4430d1398ce6 100644
@@ -272,9 +272,16 @@ static const struct clk_ops mmc_clk_ops = {
 	.set_phase	= mmc_set_phase,
 };
 
-static DEFINE_SPINLOCK(sun4i_a10_mmc_lock);
-
-static void __init sun4i_a10_mmc_setup(struct device_node *node)
+/*
+ * sunxi_mmc_setup - Common setup function for mmc module clocks
+ *
+ * The only difference between module clocks on different platforms is the
+ * width of the mux register bits and the valid values, which are passed in
+ * through struct factors_data. The phase clocks parts are identical.
+ */
+static void __init sunxi_mmc_setup(struct device_node *node,
+				   const struct factors_data *data,
+				   spinlock_t *lock)
 {
 	struct clk_onecell_data *clk_data;
 	const char *parent;
@@ -296,9 +303,7 @@ static void __init sun4i_a10_mmc_setup(struct device_node *node)
 		goto err_free_data;
 
 	clk_data->clk_num = 3;
-	clk_data->clks[0] = sunxi_factors_register(node,
-						   &sun4i_a10_mod0_data,
-						   &sun4i_a10_mmc_lock, reg);
+	clk_data->clks[0] = sunxi_factors_register(node, data, lock, reg);
 	if (!clk_data->clks[0])
 		goto err_free_clks;
 
@@ -318,7 +323,7 @@ static void __init sun4i_a10_mmc_setup(struct device_node *node)
 
 		phase->hw.init = &init;
 		phase->reg = reg;
-		phase->lock = &sun4i_a10_mmc_lock;
+		phase->lock = lock;
 
 		if (i == 1)
 			phase->offset = 8;
@@ -345,4 +350,11 @@ err_free_clks:
 err_free_data:
 	kfree(clk_data);
 }
+
+static DEFINE_SPINLOCK(sun4i_a10_mmc_lock);
+
+static void __init sun4i_a10_mmc_setup(struct device_node *node)
+{
+	sunxi_mmc_setup(node, &sun4i_a10_mod0_data, &sun4i_a10_mmc_lock);
+}
 CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup);
Signature · 1 line
2.1.4
#2 lore raw

PATCH v3 1/13 clk: sunxi: Add a common setup function for mmc module clocks

Quoted 8 lines · Chen-Yu Tsai

The only difference between module clocks on different platforms is the width of the mux register bits and the valid values, which are passed in through struct factors_data. The phase clocks parts are identical.

This patch generalizes the setup function, so most of the code can be reused when adding sun9i support, which has a wider mux register.

Applied, 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/20150114/aaf2b557/attachment.sig>
#3 lore raw

PATCH v3 2/13 clk: sunxi: Add mod0 and mmc module clock support for A80

In reply to Chen-Yu Tsai

The module 0 style clocks, or storage module clocks as named in the official SDK, are almost the same as the module 0 clocks on earlier Allwinner SoCs. The only difference is wider mux register bits.

As with earlier Allwinner SoCs, mmc module clocks are a special case of mod0 clocks, with phase controls for 2 child clocks, output and sample.

This patch adds support for both.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
 drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +5 -2
index e4c42276c577..0dfd018ba47b 100644
@@ -56,7 +56,9 @@ Required properties:
 	"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
 	"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
 	"allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
+	"allwinner,sun9i-a80-mod0-clk" - for module 0 (storage) clocks on A80
 	"allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
 	"allwinner,sun7i-a20-out-clk" - for the external output clocks
 	"allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
@@ -72,7 +74,8 @@ Required properties for all clocks:
 - #clock-cells : from common clock binding; shall be set to 0 except for
 	the following compatibles where it shall be set to 1:
 	"allwinner,*-gates-clk", "allwinner,sun4i-pll5-clk",
-	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk"
+	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk",
+	"allwinner,*-usb-clk", "allwinner,*-mmc-clk"
 - clock-output-names : shall be the corresponding names of the outputs.
 	If the clock module only has one output, the name shall be the
 	module name.
@@ -94,7 +97,7 @@ For "allwinner,sun6i-a31-pll6-clk", there are 2 outputs. The first output
 is the normal PLL6 output, or "pll6". The second output is rate doubled
 PLL6, or "pll6x2".
 
-The "allwinner,sun4i-a10-mmc-clk" has three different outputs: the
+The "allwinner,*-mmc-clk" clocks have three different outputs: the
 main clock, with the ID 0, and the output and sample clocks, with the
 IDs 1 and 2, respectively.
 
drivers/clk/sunxi/clk-mod0.c +32 -0
index 4430d1398ce6..99ff2c7cccf7 100644
@@ -130,6 +130,30 @@ static struct platform_driver sun4i_a10_mod0_clk_driver = {
 };
 module_platform_driver(sun4i_a10_mod0_clk_driver);
 
+static const struct factors_data sun9i_a80_mod0_data __initconst = {
+	.enable = 31,
+	.mux = 24,
+	.muxmask = BIT(3) | BIT(2) | BIT(1) | BIT(0),
+	.table = &sun4i_a10_mod0_config,
+	.getter = sun4i_a10_get_mod0_factors,
+};
+
+static void __init sun9i_a80_mod0_setup(struct device_node *node)
+{
+	void __iomem *reg;
+
+	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+	if (!reg) {
+		pr_err("Could not get registers for mod0-clk: %s\n",
+		       node->name);
+		return;
+	}
+
+	sunxi_factors_register(node, &sun9i_a80_mod0_data,
+			       &sun4i_a10_mod0_lock, reg);
+}
+CLK_OF_DECLARE(sun9i_a80_mod0, "allwinner,sun9i-a80-mod0-clk", sun9i_a80_mod0_setup);
+
 static DEFINE_SPINLOCK(sun5i_a13_mbus_lock);
 
 static void __init sun5i_a13_mbus_setup(struct device_node *node)
@@ -358,3 +382,11 @@ static void __init sun4i_a10_mmc_setup(struct device_node *node)
 	sunxi_mmc_setup(node, &sun4i_a10_mod0_data, &sun4i_a10_mmc_lock);
 }
 CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup);
+
+static DEFINE_SPINLOCK(sun9i_a80_mmc_lock);
+
+static void __init sun9i_a80_mmc_setup(struct device_node *node)
+{
+	sunxi_mmc_setup(node, &sun9i_a80_mod0_data, &sun9i_a80_mmc_lock);
+}
+CLK_OF_DECLARE(sun9i_a80_mmc, "allwinner,sun9i-a80-mmc-clk", sun9i_a80_mmc_setup);
Signature · 1 line
2.1.4
#4 lore raw

PATCH v3 2/13 clk: sunxi: Add mod0 and mmc module clock support for A80

Quoted 61 lines · Chen-Yu Tsai

The module 0 style clocks, or storage module clocks as named in the official SDK, are almost the same as the module 0 clocks on earlier Allwinner SoCs. The only difference is wider mux register bits.

As with earlier Allwinner SoCs, mmc module clocks are a special case of mod0 clocks, with phase controls for 2 child clocks, output and sample.

This patch adds support for both.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
 drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +5 -2
index e4c42276c577..0dfd018ba47b 100644
@@ -56,7 +56,9 @@ Required properties:
 	"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
 	"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
 	"allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
+	"allwinner,sun9i-a80-mod0-clk" - for module 0 (storage) clocks on A80
 	"allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
 	"allwinner,sun7i-a20-out-clk" - for the external output clocks
 	"allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
@@ -72,7 +74,8 @@ Required properties for all clocks:
 - #clock-cells : from common clock binding; shall be set to 0 except for
 	the following compatibles where it shall be set to 1:
 	"allwinner,*-gates-clk", "allwinner,sun4i-pll5-clk",
-	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk"
+	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk",
+	"allwinner,*-usb-clk", "allwinner,*-mmc-clk"
 - clock-output-names : shall be the corresponding names of the outputs.
 	If the clock module only has one output, the name shall be the
 	module name.
@@ -94,7 +97,7 @@ For "allwinner,sun6i-a31-pll6-clk", there are 2 outputs. The first output
 is the normal PLL6 output, or "pll6". The second output is rate doubled
 PLL6, or "pll6x2".
 
-The "allwinner,sun4i-a10-mmc-clk" has three different outputs: the
+The "allwinner,*-mmc-clk" clocks have three different outputs: the
 main clock, with the ID 0, and the output and sample clocks, with the
 IDs 1 and 2, respectively.
 
drivers/clk/sunxi/clk-mod0.c +4 -0
index 4430d1398ce6..99ff2c7cccf7 100644
@@ -130,6 +130,30 @@ static struct platform_driver sun4i_a10_mod0_clk_driver = {
 };
 module_platform_driver(sun4i_a10_mod0_clk_driver);
 
+static const struct factors_data sun9i_a80_mod0_data __initconst = {
+	.enable = 31,
+	.mux = 24,
+	.muxmask = BIT(3) | BIT(2) | BIT(1) | BIT(0),

drivers/clk/sunxi/clk-mod0.c static struct platform_driver sun4i_a10_mod0_clk_driver = { · line 146

Quoted 10 lines
drivers/clk/sunxi/clk-mod0.c +10 -0
+	.table = &sun4i_a10_mod0_config,
+	.getter = sun4i_a10_get_mod0_factors,
+};
+
+static void __init sun9i_a80_mod0_setup(struct device_node *node)
+{
+	void __iomem *reg;
+
+	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+	if (!reg) {

of_io_request_and_map returns an error pointer.

Looks good otherwise.

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/20150114/aff9db07/attachment-0001.sig>
#5 lore raw

PATCH v3 2/13 clk: sunxi: Add mod0 and mmc module clock support for A80

Quoted 58 lines · Maxime Ripard
Quoted 57 lines · Chen-Yu Tsai

The module 0 style clocks, or storage module clocks as named in the official SDK, are almost the same as the module 0 clocks on earlier Allwinner SoCs. The only difference is wider mux register bits.

As with earlier Allwinner SoCs, mmc module clocks are a special case of mod0 clocks, with phase controls for 2 child clocks, output and sample.

This patch adds support for both.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
 drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +5 -2
index e4c42276c577..0dfd018ba47b 100644
@@ -56,7 +56,9 @@ Required properties:
      "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
      "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
      "allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
+     "allwinner,sun9i-a80-mod0-clk" - for module 0 (storage) clocks on A80
      "allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
      "allwinner,sun7i-a20-out-clk" - for the external output clocks
      "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
@@ -72,7 +74,8 @@ Required properties for all clocks:
 - #clock-cells : from common clock binding; shall be set to 0 except for
      the following compatibles where it shall be set to 1:
      "allwinner,*-gates-clk", "allwinner,sun4i-pll5-clk",
-     "allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk"
+     "allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk",
+     "allwinner,*-usb-clk", "allwinner,*-mmc-clk"
 - clock-output-names : shall be the corresponding names of the outputs.
      If the clock module only has one output, the name shall be the
      module name.
@@ -94,7 +97,7 @@ For "allwinner,sun6i-a31-pll6-clk", there are 2 outputs. The first output
 is the normal PLL6 output, or "pll6". The second output is rate doubled
 PLL6, or "pll6x2".
 
-The "allwinner,sun4i-a10-mmc-clk" has three different outputs: the
+The "allwinner,*-mmc-clk" clocks have three different outputs: the
 main clock, with the ID 0, and the output and sample clocks, with the
 IDs 1 and 2, respectively.
 
drivers/clk/sunxi/clk-mod0.c +0 -0
index 4430d1398ce6..99ff2c7cccf7 100644
@@ -130,6 +130,30 @@ static struct platform_driver sun4i_a10_mod0_clk_driver = {
 };
 module_platform_driver(sun4i_a10_mod0_clk_driver);
 
Quoted 16 lines
Quoted 4 lines
drivers/clk/sunxi/clk-mod0.c +4 -0
+static const struct factors_data sun9i_a80_mod0_data __initconst = {
+     .enable = 31,
+     .mux = 24,
+     .muxmask = BIT(3) | BIT(2) | BIT(1) | BIT(0),

drivers/clk/sunxi/clk-mod0.c static struct platform_driver sun4i_a10_mod0_clk_driver = { · line 146

Quoted 10 lines
drivers/clk/sunxi/clk-mod0.c +10 -0
+     .table = &sun4i_a10_mod0_config,
+     .getter = sun4i_a10_get_mod0_factors,
+};
+
+static void __init sun9i_a80_mod0_setup(struct device_node *node)
+{
+     void __iomem *reg;
+
+     reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+     if (!reg) {

of_io_request_and_map returns an error pointer.

Fixed in my branch.

ChenYu

Quoted 9 lines

Looks good otherwise.

Thanks!
Maxime

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

#6 lore raw

PATCH v3 3/13 ARM: dts: sun9i: Add mmc module clock nodes for A80

In reply to Chen-Yu Tsai

The mmc module clocks are A80 specific module 0 (storage) type clocks.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +36 -0
index 4b584cb9c2f0..ddc34676987d 100644
@@ -219,6 +219,42 @@
 			clock-output-names = "cci400";
 		};
 
+		mmc0_clk: clk at 06000410 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun9i-a80-mmc-clk";
+			reg = <0x06000410 0x4>;
+			clocks = <&osc24M>, <&pll4>;
+			clock-output-names = "mmc0", "mmc0_output",
+					     "mmc0_sample";
+		};
+
+		mmc1_clk: clk at 06000414 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun9i-a80-mmc-clk";
+			reg = <0x06000414 0x4>;
+			clocks = <&osc24M>, <&pll4>;
+			clock-output-names = "mmc1", "mmc1_output",
+					     "mmc1_sample";
+		};
+
+		mmc2_clk: clk at 06000418 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun9i-a80-mmc-clk";
+			reg = <0x06000418 0x4>;
+			clocks = <&osc24M>, <&pll4>;
+			clock-output-names = "mmc2", "mmc2_output",
+					     "mmc2_sample";
+		};
+
+		mmc3_clk: clk at 0600041c {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun9i-a80-mmc-clk";
+			reg = <0x0600041c 0x4>;
+			clocks = <&osc24M>, <&pll4>;
+			clock-output-names = "mmc3", "mmc3_output",
+					     "mmc3_sample";
+		};
+
 		ahb0_gates: clk at 06000580 {
 			#clock-cells = <1>;
 			compatible = "allwinner,sun9i-a80-ahb0-gates-clk";
Signature · 1 line
2.1.4
#7 lore raw

PATCH v3 3/13 ARM: dts: sun9i: Add mmc module clock nodes for A80

Quoted 4 lines · Chen-Yu Tsai

The mmc module clocks are A80 specific module 0 (storage) type clocks.

Applied, 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/20150114/35f45742/attachment.sig>
#8 lore raw

PATCH v3 4/13 clk: sunxi: Add driver for A80 MMC config clocks/resets

In reply to Chen-Yu Tsai

On the A80 SoC, the 4 mmc controllers each have a separate register controlling their register access clocks and reset controls. These registers in turn share a ahb clock gate and reset control.

This patch adds a platform device driver for these controls. It requires both clocks and reset controls to be available, so using CLK_OF_DECLARE might not be the best way.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  25 ++-
 drivers/clk/sunxi/Makefile                        |   1 +
 drivers/clk/sunxi/clk-sun9i-mmc.c                 | 222 ++++++++++++++++++++++
 3 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-mmc.c
Documentation/devicetree/bindings/clock/sunxi.txt +24 -1
index 0dfd018ba47b..60b44285250d 100644
@@ -57,6 +57,7 @@ Required properties:
 	"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
+	"allwinner,sun9i-a80-mmc-config-clk" - for mmc gates + resets on A80
 	"allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
 	"allwinner,sun9i-a80-mod0-clk" - for module 0 (storage) clocks on A80
 	"allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
@@ -75,7 +76,8 @@ Required properties for all clocks:
 	the following compatibles where it shall be set to 1:
 	"allwinner,*-gates-clk", "allwinner,sun4i-pll5-clk",
 	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk",
-	"allwinner,*-usb-clk", "allwinner,*-mmc-clk"
+	"allwinner,*-usb-clk", "allwinner,*-mmc-clk",
+	"allwinner,*-mmc-config-clk"
 - clock-output-names : shall be the corresponding names of the outputs.
 	If the clock module only has one output, the name shall be the
 	module name.
@@ -83,6 +85,10 @@ Required properties for all clocks:
 And "allwinner,*-usb-clk" clocks also require:
 - reset-cells : shall be set to 1
 
+The "allwinner,sun9i-a80-mmc-config-clk" clock also requires:
+- #reset-cells : shall be set to 1
+- resets : shall be the reset control phandle for the mmc block.
+
 For "allwinner,sun7i-a20-gmac-clk", the parent clocks shall be fixed rate
 dummy clocks at 25 MHz and 125 MHz, respectively. See example.
 
@@ -101,6 +107,10 @@ The "allwinner,*-mmc-clk" clocks have three different outputs: the
 main clock, with the ID 0, and the output and sample clocks, with the
 IDs 1 and 2, respectively.
 
+The "allwinner,sun9i-a80-mmc-config-clk" clock has one clock/reset output
+per mmc controller. The number of outputs is determined by the size of
+the address block, which is related to the overall mmc block.
+
 For example:
 
 osc24M: clk at 01c20050 {
@@ -176,3 +186,16 @@ gmac_clk: clk at 01c20164 {
 	clocks = <&mii_phy_tx_clk>, <&gmac_int_tx_clk>;
 	clock-output-names = "gmac";
 };
+
+mmc_config_clk: clk at 01c13000 {
+	compatible = "allwinner,sun9i-a80-mmc-config-clk";
+	reg = <0x01c13000 0x10>;
+	clocks = <&ahb0_gates 8>;
+	clock-names = "ahb";
+	resets = <&ahb0_resets 8>;
+	reset-names = "ahb";
+	#clock-cells = <1>;
+	#reset-cells = <1>;
+	clock-output-names = "mmc0_config", "mmc1_config",
+			     "mmc2_config", "mmc3_config";
+};
drivers/clk/sunxi/Makefile +1 -0
index a66953c0f430..3a5292e3fcf8 100644
@@ -8,6 +8,7 @@ obj-y += clk-a20-gmac.o
 obj-y += clk-mod0.o
 obj-y += clk-sun8i-mbus.o
 obj-y += clk-sun9i-core.o
+obj-y += clk-sun9i-mmc.o
 
 obj-$(CONFIG_MFD_SUN6I_PRCM) += \
 	clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
drivers/clk/sunxi/clk-sun9i-mmc.c new file +222 -0

222 lines not on this page · raw message

Signature · 1 line
2.1.4
#9 lore raw

PATCH v3 4/13 clk: sunxi: Add driver for A80 MMC config clocks/resets

Quoted 21 lines · Chen-Yu Tsai

On the A80 SoC, the 4 mmc controllers each have a separate register controlling their register access clocks and reset controls. These registers in turn share a ahb clock gate and reset control.

This patch adds a platform device driver for these controls. It requires both clocks and reset controls to be available, so using CLK_OF_DECLARE might not be the best way.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  25 ++-
 drivers/clk/sunxi/Makefile                        |   1 +
 drivers/clk/sunxi/clk-sun9i-mmc.c                 | 222 ++++++++++++++++++++++
 3 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-mmc.c
Documentation/devicetree/bindings/clock/sunxi.txt +0 -0
index 0dfd018ba47b..60b44285250d 100644

Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 60

Quoted 4 lines
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
@@ -57,6 +57,7 @@ Required properties:
 	"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
+	"allwinner,sun9i-a80-mmc-config-clk" - for mmc gates + resets on A80

It looks like it's not just a clock. How about dropping the -clk suffix?

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/20150114/69f80c0d/attachment.sig>
#10 lore raw

PATCH v3 4/13 clk: sunxi: Add driver for A80 MMC config clocks/resets

Quoted 17 lines · Maxime Ripard
Quoted 16 lines · Chen-Yu Tsai

On the A80 SoC, the 4 mmc controllers each have a separate register controlling their register access clocks and reset controls. These registers in turn share a ahb clock gate and reset control.

This patch adds a platform device driver for these controls. It requires both clocks and reset controls to be available, so using CLK_OF_DECLARE might not be the best way.

---
 Documentation/devicetree/bindings/clock/sunxi.txt |  25 ++-
 drivers/clk/sunxi/Makefile                        |   1 +
 drivers/clk/sunxi/clk-sun9i-mmc.c                 | 222 ++++++++++++++++++++++
 3 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-mmc.c
Quoted 12 lines

Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 60

Quoted 9 lines
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
index 0dfd018ba47b..60b44285250d 100644
@@ -57,6 +57,7 @@ Required properties:
      "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
+     "allwinner,sun9i-a80-mmc-config-clk" - for mmc gates + resets on A80

It looks like it's not just a clock. How about dropping the -clk suffix?

It is like *-usb-clk, which has clock gates and reset controls. mmc-config has additional clock input gate and master reset control upstream.

IMO, it is a leaf clock control unit.

ChenYu

#11 lore raw

PATCH v3 5/13 ARM: dts: sun9i: Add clock-indices property for bus gate clocks

In reply to Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +10 -0
index ddc34676987d..9d0a66c14caf 100644
@@ -260,6 +260,9 @@
 			compatible = "allwinner,sun9i-a80-ahb0-gates-clk";
 			reg = <0x06000580 0x4>;
 			clocks = <&ahb0>;
+			clock-indices = <0>, <1>, <3>, <5>, <8>, <12>, <13>,
+					<14>, <15>, <16>, <18>, <20>, <21>,
+					<22>, <23>;
 			clock-output-names = "ahb0_fd", "ahb0_ve", "ahb0_gpu",
 					"ahb0_ss", "ahb0_sd", "ahb0_nand1",
 					"ahb0_nand0", "ahb0_sdram",
@@ -273,6 +276,7 @@
 			compatible = "allwinner,sun9i-a80-ahb1-gates-clk";
 			reg = <0x06000584 0x4>;
 			clocks = <&ahb1>;
+			clock-indices = <0>, <1>, <17>, <21>, <22>, <23>, <24>;
 			clock-output-names = "ahb1_usbotg", "ahb1_usbhci",
 					"ahb1_gmac", "ahb1_msgbox",
 					"ahb1_spinlock", "ahb1_hstimer",
@@ -284,6 +288,8 @@
 			compatible = "allwinner,sun9i-a80-ahb2-gates-clk";
 			reg = <0x06000588 0x4>;
 			clocks = <&ahb2>;
+			clock-indices = <0>, <1>, <2>, <4>, <5>, <7>, <8>,
+					<11>;
 			clock-output-names = "ahb2_lcd0", "ahb2_lcd1",
 					"ahb2_edp", "ahb2_csi", "ahb2_hdmi",
 					"ahb2_de", "ahb2_mp", "ahb2_mipi_dsi";
@@ -294,6 +300,8 @@
 			compatible = "allwinner,sun9i-a80-apb0-gates-clk";
 			reg = <0x06000590 0x4>;
 			clocks = <&apb0>;
+			clock-indices = <1>, <5>, <11>, <12>, <13>, <15>,
+					<17>, <18>, <19>;
 			clock-output-names = "apb0_spdif", "apb0_pio",
 					"apb0_ac97", "apb0_i2s0", "apb0_i2s1",
 					"apb0_lradc", "apb0_gpadc", "apb0_twd",
@@ -305,6 +313,8 @@
 			compatible = "allwinner,sun9i-a80-apb1-gates-clk";
 			reg = <0x06000594 0x4>;
 			clocks = <&apb1>;
+			clock-indices = <0>, <1>, <2>, <3>, <4>,
+					<16>, <17>, <18>, <19>, <20>, <21>;
 			clock-output-names = "apb1_i2c0", "apb1_i2c1",
 					"apb1_i2c2", "apb1_i2c3", "apb1_i2c4",
 					"apb1_uart0", "apb1_uart1",
Signature · 1 line
2.1.4
#12 lore raw

PATCH v3 5/13 ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

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/20150114/e1d6b39a/attachment.sig>
#13 lore raw

PATCH v3 5/13 ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 9 lines · Maxime Ripard
Quoted 8 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Quoted 5 lines
Quoted 1 line

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

ChenYu

#14 lore raw

PATCH v3 5/13 ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 13 lines · Chen-Yu Tsai
Quoted 11 lines · Maxime Ripard
Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Quoted 7 lines
Quoted 3 lines

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

Erm.... These are gates. They are not muxable and are not handled through clk-factors, so I'm not sure how it is relevant :)

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/20150115/7fef886b/attachment.sig>
#15 lore raw

[linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 18 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
Quoted 14 lines · Maxime Ripard
Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Quoted 6 lines
Quoted 3 lines

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

Erm.... These are gates. They are not muxable and are not handled through clk-factors, so I'm not sure how it is relevant :)

Sorry. I jumped to the mux mask stuff. Yes the gate masks are still used, and the gates are still referenced by the bit offset.

As described in the commit message, clock-indices is used by of_clk_get_parent_name() to match the index used in the phandle to the correct name in clock-names.

Take apb1 for example:

                       clock-indices = <0>, <1>, <2>, <3>, <4>,
                                       <16>, <17>, <18>, <19>, <20>, <21>;
                       clock-output-names = "apb1_i2c0", "apb1_i2c1",
                                       "apb1_i2c2", "apb1_i2c3", "apb1_i2c4",
                                       "apb1_uart0", "apb1_uart1", ...

If we have "clocks = <&apb1 16>;" in some device, and we call of_clk_get_parent_name() on said clock, it would try to get clock_output_names[16], which obviously is the wrong one.

With clock-indices, of_clk_get_parent_name first looks at that array, finds an entry matching 16, then uses the index of the matching entry to get the name from clock-output-names.

So, we are still using the gate bitmask to declare valid clock gates. The sunxi driver does not use clock-indices directly. Nor do I think it was intended to be used by clock drivers directly.

Hope this clears things up.

ChenYu

#16 lore raw

[linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 42 lines · Chen-Yu Tsai
Quoted 18 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
Quoted 14 lines · Maxime Ripard
Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Quoted 6 lines
Quoted 3 lines

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

Erm.... These are gates. They are not muxable and are not handled through clk-factors, so I'm not sure how it is relevant :)

Sorry. I jumped to the mux mask stuff. Yes the gate masks are still used, and the gates are still referenced by the bit offset.

As described in the commit message, clock-indices is used by of_clk_get_parent_name() to match the index used in the phandle to the correct name in clock-names.

Take apb1 for example:

                       clock-indices = <0>, <1>, <2>, <3>, <4>,
                                       <16>, <17>, <18>, <19>, <20>, <21>;
                       clock-output-names = "apb1_i2c0", "apb1_i2c1",
                                       "apb1_i2c2", "apb1_i2c3", "apb1_i2c4",
                                       "apb1_uart0", "apb1_uart1", ...
Quoted 8 lines

If we have "clocks = <&apb1 16>;" in some device, and we call of_clk_get_parent_name() on said clock, it would try to get clock_output_names[16], which obviously is the wrong one.

With clock-indices, of_clk_get_parent_name first looks at that array, finds an entry matching 16, then uses the index of the matching entry to get the name from clock-output-names.

Yeah, I know what it does, and we do agree on the fact that it's needed.

Quoted 4 lines

So, we are still using the gate bitmask to declare valid clock gates. The sunxi driver does not use clock-indices directly. Nor do I think it was intended to be used by clock drivers directly.

However, the gate bitmask itself carries exactly the same information than clock-indices. It's the exact same list of numbers, just with two different ways of defining it.

If we go with clock-indices, which is the right solution, then we can just drop the other one.

I actually started to do just this last evening. A31 boots without any gates bit mask but the USB clocks one so far, I intend on converting the others as well.

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/20150115/7b35f4af/attachment.sig>
#17 lore raw

[linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 64 lines · Maxime Ripard
Quoted 42 lines · Chen-Yu Tsai
Quoted 18 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
Quoted 14 lines · Maxime Ripard
Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Quoted 6 lines
Quoted 3 lines

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

Erm.... These are gates. They are not muxable and are not handled through clk-factors, so I'm not sure how it is relevant :)

Sorry. I jumped to the mux mask stuff. Yes the gate masks are still used, and the gates are still referenced by the bit offset.

As described in the commit message, clock-indices is used by of_clk_get_parent_name() to match the index used in the phandle to the correct name in clock-names.

Take apb1 for example:

                       clock-indices = <0>, <1>, <2>, <3>, <4>,
                                       <16>, <17>, <18>, <19>, <20>, <21>;
                       clock-output-names = "apb1_i2c0", "apb1_i2c1",
                                       "apb1_i2c2", "apb1_i2c3", "apb1_i2c4",
                                       "apb1_uart0", "apb1_uart1", ...
Quoted 8 lines

If we have "clocks = <&apb1 16>;" in some device, and we call of_clk_get_parent_name() on said clock, it would try to get clock_output_names[16], which obviously is the wrong one.

With clock-indices, of_clk_get_parent_name first looks at that array, finds an entry matching 16, then uses the index of the matching entry to get the name from clock-output-names.

Yeah, I know what it does, and we do agree on the fact that it's needed.

Quoted 4 lines

So, we are still using the gate bitmask to declare valid clock gates. The sunxi driver does not use clock-indices directly. Nor do I think it was intended to be used by clock drivers directly.

However, the gate bitmask itself carries exactly the same information than clock-indices. It's the exact same list of numbers, just with two different ways of defining it.

Quoted 6 lines

If we go with clock-indices, which is the right solution, then we can just drop the other one.

I actually started to do just this last evening. A31 boots without any gates bit mask but the USB clocks one so far, I intend on converting the others as well.

So as I understand, you want to replace the masks in the clock drivers with clock-indices in the dt. Is this correct? This potentially makes the gates clock driver very generic, which is nice.

I only see drivers/clk/shmobile/clk-mstp.c using it this way though. Didn't we have this for sun6i-apb0-gates at one time?

I'm not against it. Just want to make sure everyone agrees, and we can work who and how we're going about this.

Thanks
ChenYu

#18 lore raw

[linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks

Quoted 69 lines · Chen-Yu Tsai
Quoted 67 lines · Maxime Ripard
Quoted 42 lines · Chen-Yu Tsai
Quoted 18 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
Quoted 14 lines · Maxime Ripard
Quoted 9 lines · Chen-Yu Tsai

of_clk_get_parent_name() uses the clock-indices property to resolve clock phandle arguments in case that the argument index does not match the clock-output-names sequence.

This is the case on sunxi, where we use the actual bit index as the argument to the phandle. Add the clock-indices property so that of_clk_get_parent_name() resolves the names correctly.

Applied. Are the mask in the clock driver still of any use now? I don't think they are, and if we're going that way, I'd rather have them removed from the driver.

Quoted 6 lines
Quoted 3 lines

Yes they are still passed through factors_data, for mux_clk_ops to know about the width of the mux, which is 3 bits on older SoCs vs 4 bits on sun9i.

Erm.... These are gates. They are not muxable and are not handled through clk-factors, so I'm not sure how it is relevant :)

Sorry. I jumped to the mux mask stuff. Yes the gate masks are still used, and the gates are still referenced by the bit offset.

As described in the commit message, clock-indices is used by of_clk_get_parent_name() to match the index used in the phandle to the correct name in clock-names.

Take apb1 for example:

                       clock-indices = <0>, <1>, <2>, <3>, <4>,
                                       <16>, <17>, <18>, <19>, <20>, <21>;
                       clock-output-names = "apb1_i2c0", "apb1_i2c1",
                                       "apb1_i2c2", "apb1_i2c3", "apb1_i2c4",
                                       "apb1_uart0", "apb1_uart1", ...
Quoted 8 lines

If we have "clocks = <&apb1 16>;" in some device, and we call of_clk_get_parent_name() on said clock, it would try to get clock_output_names[16], which obviously is the wrong one.

With clock-indices, of_clk_get_parent_name first looks at that array, finds an entry matching 16, then uses the index of the matching entry to get the name from clock-output-names.

Yeah, I know what it does, and we do agree on the fact that it's needed.

Quoted 4 lines

So, we are still using the gate bitmask to declare valid clock gates. The sunxi driver does not use clock-indices directly. Nor do I think it was intended to be used by clock drivers directly.

However, the gate bitmask itself carries exactly the same information than clock-indices. It's the exact same list of numbers, just with two different ways of defining it.

If we go with clock-indices, which is the right solution, then we can just drop the other one.

Quoted 7 lines
Quoted 3 lines

I actually started to do just this last evening. A31 boots without any gates bit mask but the USB clocks one so far, I intend on converting the others as well.

So as I understand, you want to replace the masks in the clock drivers with clock-indices in the dt. Is this correct? This potentially makes the gates clock driver very generic, which is nice.

Yeah, the only thing that is not are the clocks protected, which will depend on the compatible.

Quoted 2 lines

I only see drivers/clk/shmobile/clk-mstp.c using it this way though. Didn't we have this for sun6i-apb0-gates at one time?

I don't think we did. Or at least, it was never merged.

And since this property was introduced for shmobile iirc, I don't find it very surprising :)

Quoted 2 lines

I'm not against it. Just want to make sure everyone agrees, and we can work who and how we're going about this.

I did most of the work tonight, for all the sun7i, sun8i and sun9i SoCs. sun6i work, I'll test sun9i, but I'll need some tests from you for the A23 if it's ok :)

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/20150115/7cd3e7b6/attachment.sig>
#19 lore raw

PATCH v3 6/13 ARM: dts: sun9i: Add mmc config clock nodes

In reply to Chen-Yu Tsai

Add the device tree nodes for the mmc config clock nodes.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +13 -0
index 9d0a66c14caf..9b3b71c6f29b 100644
@@ -333,6 +333,19 @@
 		 */
 		ranges = <0 0 0 0x20000000>;
 
+		mmc_config_clk: clk at 01c13000 {
+			compatible = "allwinner,sun9i-a80-mmc-config-clk";
+			reg = <0x01c13000 0x10>;
+			clocks = <&ahb0_gates 8>;
+			clock-names = "ahb";
+			resets = <&ahb0_resets 8>;
+			reset-names = "ahb";
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+			clock-output-names = "mmc0_config", "mmc1_config",
+					     "mmc2_config", "mmc3_config";
+		};
+
 		gic: interrupt-controller at 01c41000 {
 			compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
 			reg = <0x01c41000 0x1000>,
Signature · 1 line
2.1.4
#20 lore raw

PATCH v3 6/13 ARM: dts: sun9i: Add mmc config clock nodes

Quoted 12 lines · Chen-Yu Tsai

Add the device tree nodes for the mmc config clock nodes.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +0 -0
index 9d0a66c14caf..9b3b71c6f29b 100644

arch/arm/boot/dts/sun9i-a80.dtsi line 336

Quoted 4 lines
arch/arm/boot/dts/sun9i-a80.dtsi +1 -0
@@ -333,6 +333,19 @@
 		 */
 		ranges = <0 0 0 0x20000000>;
 
+		mmc_config_clk: clk at 01c13000 {

The node names and labels are not really clocks. What about:

    	       mmc_config: mmc_config at ..... ?
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/20150114/b325053c/attachment.sig>
#21 lore raw

PATCH v3 7/13 ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators

In reply to Chen-Yu Tsai

Use the label to reference the pin controller node, so that we can use sunxi-common-regulators with sunxi families that don't share the same address space mappings, such as sun9i.

This patch is mostly space changes due to the reduction of node parents.

---
 arch/arm/boot/dts/sunxi-common-regulators.dtsi | 54 +++++++++++++-------------
 1 file changed, 26 insertions(+), 28 deletions(-)
arch/arm/boot/dts/sunxi-common-regulators.dtsi +26 -28
index b1d64dd183f4..e02baa66b33c 100644
@@ -50,39 +50,37 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/pinctrl/sun4i-a10.h>
 
-/ {
-	soc at 01c00000 {
-		pio: pinctrl at 01c20800 {
-			ahci_pwr_pin_a: ahci_pwr_pin at 0 {
-				allwinner,pins = "PB8";
-				allwinner,function = "gpio_out";
-				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
-				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
-			};
+&pio {
+	ahci_pwr_pin_a: ahci_pwr_pin at 0 {
+		allwinner,pins = "PB8";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
 
-			usb0_vbus_pin_a: usb0_vbus_pin at 0 {
-				allwinner,pins = "PB9";
-				allwinner,function = "gpio_out";
-				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
-				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
-			};
+	usb0_vbus_pin_a: usb0_vbus_pin at 0 {
+		allwinner,pins = "PB9";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
 
-			usb1_vbus_pin_a: usb1_vbus_pin at 0 {
-				allwinner,pins = "PH6";
-				allwinner,function = "gpio_out";
-				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
-				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
-			};
+	usb1_vbus_pin_a: usb1_vbus_pin at 0 {
+		allwinner,pins = "PH6";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
 
-			usb2_vbus_pin_a: usb2_vbus_pin at 0 {
-				allwinner,pins = "PH3";
-				allwinner,function = "gpio_out";
-				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
-				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
-			};
-		};
+	usb2_vbus_pin_a: usb2_vbus_pin at 0 {
+		allwinner,pins = "PH3";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
+};
 
+/ {
 	reg_ahci_5v: ahci-5v {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
Signature · 1 line
2.1.4
#22 lore raw

PATCH v3 7/13 ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators

Quoted 7 lines · Chen-Yu Tsai

Use the label to reference the pin controller node, so that we can use sunxi-common-regulators with sunxi families that don't share the same address space mappings, such as sun9i.

This patch is mostly space changes due to the reduction of node parents.

Applied, 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/20150114/70e595aa/attachment.sig>
#23 lore raw

PATCH v3 8/13 ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi

In reply to Chen-Yu Tsai

The A80 has 4 mmc controllers.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 48 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +48 -0
index 9b3b71c6f29b..a31dff35d15b 100644
@@ -333,6 +333,54 @@
 		 */
 		ranges = <0 0 0 0x20000000>;
 
+		mmc0: mmc at 01c0f000 {
+			compatible = "allwinner,sun5i-a13-mmc";
+			reg = <0x01c0f000 0x1000>;
+			clocks = <&mmc_config_clk 0>, <&mmc0_clk 0>,
+				 <&mmc0_clk 1>, <&mmc0_clk 2>;
+			clock-names = "ahb", "mmc", "output", "sample";
+			resets = <&mmc_config_clk 0>;
+			reset-names = "ahb";
+			interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
+		mmc1: mmc at 01c10000 {
+			compatible = "allwinner,sun5i-a13-mmc";
+			reg = <0x01c10000 0x1000>;
+			clocks = <&mmc_config_clk 1>, <&mmc1_clk 0>,
+				 <&mmc1_clk 1>, <&mmc1_clk 2>;
+			clock-names = "ahb", "mmc", "output", "sample";
+			resets = <&mmc_config_clk 1>;
+			reset-names = "ahb";
+			interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
+		mmc2: mmc at 01c11000 {
+			compatible = "allwinner,sun5i-a13-mmc";
+			reg = <0x01c11000 0x1000>;
+			clocks = <&mmc_config_clk 2>, <&mmc2_clk 0>,
+				 <&mmc2_clk 1>, <&mmc2_clk 2>;
+			clock-names = "ahb", "mmc", "output", "sample";
+			resets = <&mmc_config_clk 2>;
+			reset-names = "ahb";
+			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
+		mmc3: mmc at 01c12000 {
+			compatible = "allwinner,sun5i-a13-mmc";
+			reg = <0x01c12000 0x1000>;
+			clocks = <&mmc_config_clk 3>, <&mmc3_clk 0>,
+				 <&mmc3_clk 1>, <&mmc3_clk 2>;
+			clock-names = "ahb", "mmc", "output", "sample";
+			resets = <&mmc_config_clk 3>;
+			reset-names = "ahb";
+			interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+			status = "disabled";
+		};
+
 		mmc_config_clk: clk at 01c13000 {
 			compatible = "allwinner,sun9i-a80-mmc-config-clk";
 			reg = <0x01c13000 0x10>;
Signature · 1 line
2.1.4
#24 lore raw

PATCH v3 9/13 ARM: dts: sun9i: Add pinmux setting for mmc0

In reply to Chen-Yu Tsai

mmc0 is only available on port F, and is always used with a 4 bit wide bus for the onboard micro-sd slot.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +8 -0
index a31dff35d15b..7387fb2a5111 100644
@@ -470,6 +470,14 @@
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
 
+			mmc0_pins: mmc0 {
+				allwinner,pins = "PF0", "PF1" ,"PF2", "PF3",
+						 "PF4", "PF5";
+				allwinner,function = "mmc0";
+				allwinner,drive = <SUN4I_PINCTRL_30_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
 			uart0_pins_a: uart0 at 0 {
 				allwinner,pins = "PH12", "PH13";
 				allwinner,function = "uart0";
Signature · 1 line
2.1.4
#25 lore raw

PATCH v3 9/13 ARM: dts: sun9i: Add pinmux setting for mmc0

Quoted 5 lines · Chen-Yu Tsai

mmc0 is only available on port F, and is always used with a 4 bit wide bus for the onboard micro-sd slot.

Applied, 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/20150114/db59f9a0/attachment.sig>
#26 lore raw

PATCH v3 10/13 ARM: dts: sun9i: Convert a80 optimus board dts to label referencing

In reply to Chen-Yu Tsai

The preferred method of referencing nodes from the dtsi is to use labels, instead of copying the complete tree.

This patch converts sun9i-a80-optimus.dts to use label references.

---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 76 ++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 39 deletions(-)
arch/arm/boot/dts/sun9i-a80-optimus.dts +37 -39
index 58f5cb346519..f329ec85f4e4 100644
@@ -61,45 +61,6 @@
 		bootargs = "earlyprintk console=ttyS0,115200";
 	};
 
-	soc {
-		pio: pinctrl at 06000800 {
-			i2c3_pins_a: i2c3 at 0 {
-				/* Enable internal pull-up */
-				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
-			};
-
-			led_pins_optimus: led-pins at 0 {
-				allwinner,pins = "PH0", "PH1";
-				allwinner,function = "gpio_out";
-				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
-				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
-			};
-
-			uart4_pins_a: uart4 at 0 {
-				/* Enable internal pull-up */
-				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
-			};
-		};
-
-		uart0: serial at 07000000 {
-			pinctrl-names = "default";
-			pinctrl-0 = <&uart0_pins_a>;
-			status = "okay";
-		};
-
-		uart4: serial at 07001000 {
-			pinctrl-names = "default";
-			pinctrl-0 = <&uart4_pins_a>;
-			status = "okay";
-		};
-
-		i2c3: i2c at 07003400 {
-			pinctrl-names = "default";
-			pinctrl-0 = <&i2c3_pins_a>;
-			status = "okay";
-		};
-	};
-
 	leds {
 		compatible = "gpio-leds";
 		pinctrl-names = "default";
@@ -120,3 +81,40 @@
 		};
 	};
 };
+
+&pio {
+	led_pins_optimus: led-pins at 0 {
+		allwinner,pins = "PH0", "PH1";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
+};
+
+&i2c3_pins_a {
+	/* Enable internal pull-up */
+	allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+};
+
+&uart4_pins_a {
+	/* Enable internal pull-up */
+	allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
+
+&uart4 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart4_pins_a>;
+	status = "okay";
+};
+
+&i2c3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c3_pins_a>;
+	status = "okay";
+};
Signature · 1 line
2.1.4
#27 lore raw

PATCH v3 11/13 ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board

In reply to Chen-Yu Tsai

Enable the micro-sd slot on the A80 Optimus Board, which is connected to mmc0. This adds the card-detect gpio and enables mmc0.

---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/boot/dts/sun9i-a80-optimus.dts +18 -0
index f329ec85f4e4..c8e038aafa9f 100644
@@ -49,6 +49,7 @@
 
 /dts-v1/;
 #include "sun9i-a80.dtsi"
+#include "sunxi-common-regulators.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/pinctrl/sun4i-a10.h>
@@ -82,6 +83,16 @@
 	};
 };
 
+&mmc0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc0_pins>, <&mmc0_cd_pin_optimus>;
+	vmmc-supply = <&reg_vcc3v0>;
+	bus-width = <4>;
+	cd-gpios = <&pio 7 18 GPIO_ACTIVE_HIGH>; /* PH8 */
+	cd-inverted;
+	status = "okay";
+};
+
 &pio {
 	led_pins_optimus: led-pins at 0 {
 		allwinner,pins = "PH0", "PH1";
@@ -89,6 +100,13 @@
 		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
 		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
+
+	mmc0_cd_pin_optimus: mmc0_cd_pin at 0 {
+		allwinner,pins = "PH18";
+		allwinner,function = "gpio_in";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+	};
 };
 
 &i2c3_pins_a {
Signature · 1 line
2.1.4
#28 lore raw

PATCH v3 12/13 ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2

In reply to Chen-Yu Tsai

mmc2 is available on port C. Add a pinmux setting for 8 bit wide eMMC.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +9 -0
index 7387fb2a5111..9e28ffc6dd90 100644
@@ -478,6 +478,15 @@
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
 
+			mmc2_8bit_pins: mmc2_8bit {
+				allwinner,pins = "PC6", "PC7", "PC8", "PC9",
+						 "PC10", "PC11", "PC12",
+						 "PC13", "PC14", "PC15";
+				allwinner,function = "mmc2";
+				allwinner,drive = <SUN4I_PINCTRL_30_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
 			uart0_pins_a: uart0 at 0 {
 				allwinner,pins = "PH12", "PH13";
 				allwinner,function = "uart0";
Signature · 1 line
2.1.4
#29 lore raw

PATCH v3 13/13 ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board

In reply to Chen-Yu Tsai

The A80 Optimus Board has a 16GB eMMC connected to mmc2, with 8 bit wide data bus.

---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun9i-a80-optimus.dts +9 -0
index c8e038aafa9f..6a122a13f84e 100644
@@ -93,6 +93,15 @@
 	status = "okay";
 };
 
+&mmc2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc2_8bit_pins>;
+	vmmc-supply = <&reg_vcc3v0>;
+	bus-width = <8>;
+	non-removable;
+	status = "okay";
+};
+
 &pio {
 	led_pins_optimus: led-pins at 0 {
 		allwinner,pins = "PH0", "PH1";
Signature · 1 line
2.1.4