All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80
@ 2015-01-13  1:37 Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Chen-Yu Tsai
                   ` (12 more replies)
  0 siblings, 13 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

-- 
2.1.4

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:26   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi/clk-mod0.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
index e37eb6fe19e8..4430d1398ce6 100644
--- a/drivers/clk/sunxi/clk-mod0.c
+++ b/drivers/clk/sunxi/clk-mod0.c
@@ -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);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:28   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
 drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index e4c42276c577..0dfd018ba47b 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -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.
 
diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
index 4430d1398ce6..99ff2c7cccf7 100644
--- a/drivers/clk/sunxi/clk-mod0.c
+++ b/drivers/clk/sunxi/clk-mod0.c
@@ -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);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes for A80
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:30   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 4b584cb9c2f0..ddc34676987d 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (2 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:37   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 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

diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 0dfd018ba47b..60b44285250d 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -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";
+};
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index a66953c0f430..3a5292e3fcf8 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -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 \
diff --git a/drivers/clk/sunxi/clk-sun9i-mmc.c b/drivers/clk/sunxi/clk-sun9i-mmc.c
new file mode 100644
index 000000000000..aeb3a52e0a9f
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun9i-mmc.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2013 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai	<wens@csie.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/reset.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#define SUN9I_MMC_WIDTH		4
+
+#define SUN9I_MMC_GATE_BIT	16
+#define SUN9I_MMC_RESET_BIT	18
+
+struct sun9i_mmc_clk_data {
+	spinlock_t			lock;
+	void __iomem			*membase;
+	struct clk			*clk;
+	struct reset_control		*reset;
+	struct clk_onecell_data		clk_data;
+	struct reset_controller_dev	rcdev;
+};
+
+static int sun9i_mmc_reset_assert(struct reset_controller_dev *rcdev,
+			      unsigned long id)
+{
+	struct sun9i_mmc_clk_data *data = container_of(rcdev,
+						       struct sun9i_mmc_clk_data,
+						       rcdev);
+	unsigned long flags;
+	void __iomem *reg = data->membase + SUN9I_MMC_WIDTH * id;
+	u32 val;
+
+	clk_prepare_enable(data->clk);
+	spin_lock_irqsave(&data->lock, flags);
+
+	val = readl(reg);
+	writel(val & ~BIT(SUN9I_MMC_RESET_BIT), reg);
+
+	spin_unlock_irqrestore(&data->lock, flags);
+	clk_disable_unprepare(data->clk);
+
+	return 0;
+}
+
+static int sun9i_mmc_reset_deassert(struct reset_controller_dev *rcdev,
+				unsigned long id)
+{
+	struct sun9i_mmc_clk_data *data = container_of(rcdev,
+						       struct sun9i_mmc_clk_data,
+						       rcdev);
+	unsigned long flags;
+	void __iomem *reg = data->membase + SUN9I_MMC_WIDTH * id;
+	u32 val;
+
+	clk_prepare_enable(data->clk);
+	spin_lock_irqsave(&data->lock, flags);
+
+	val = readl(reg);
+	writel(val | BIT(SUN9I_MMC_RESET_BIT), reg);
+
+	spin_unlock_irqrestore(&data->lock, flags);
+	clk_disable_unprepare(data->clk);
+
+	return 0;
+}
+
+static struct reset_control_ops sun9i_mmc_reset_ops = {
+	.assert		= sun9i_mmc_reset_assert,
+	.deassert	= sun9i_mmc_reset_deassert,
+};
+
+static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct sun9i_mmc_clk_data *data;
+	struct clk_onecell_data *clk_data;
+	const char *clk_name = np->name;
+	const char *clk_parent;
+	struct resource *r;
+	int count, i, ret;
+
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	spin_lock_init(&data->lock);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	/* one clock/reset pair per word */
+	count = DIV_ROUND_UP((r->end - r->start + 1), SUN9I_MMC_WIDTH);
+	data->membase = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(data->membase))
+		return PTR_ERR(data->membase);
+
+	clk_data = &data->clk_data;
+	clk_data->clk_num = count;
+	clk_data->clks = devm_kcalloc(&pdev->dev, count, sizeof(struct clk *),
+				      GFP_KERNEL);
+	if (!clk_data->clks)
+		return -ENOMEM;
+
+	clk_parent = of_clk_get_parent_name(np, 0);
+	if (!clk_parent)
+		return -EINVAL;
+
+	data->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(data->clk)) {
+		dev_err(&pdev->dev, "Could not get clock\n");
+		return PTR_ERR(data->clk);
+	}
+
+	data->reset = devm_reset_control_get(&pdev->dev, NULL);
+	if (IS_ERR(data->reset)) {
+		dev_err(&pdev->dev, "Could not get reset control\n");
+		return PTR_ERR(data->reset);
+	}
+
+	ret = reset_control_deassert(data->reset);
+	if (ret) {
+		dev_err(&pdev->dev, "Reset deassert err %d\n", ret);
+		return ret;
+	}
+
+	for (i = 0; i < count; i++) {
+		of_property_read_string_index(np, "clock-output-names",
+					      i, &clk_name);
+
+		clk_data->clks[i] = clk_register_gate(&pdev->dev, clk_name,
+						      clk_parent, 0,
+						      data->membase + SUN9I_MMC_WIDTH * i,
+						      SUN9I_MMC_GATE_BIT, 0,
+						      &data->lock);
+
+		if (IS_ERR(clk_data->clks[i])) {
+			ret = PTR_ERR(clk_data->clks[i]);
+			goto err_clk_register;
+		}
+	}
+
+	ret = of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
+	if (ret)
+		goto err_clk_provider;
+
+	data->rcdev.owner = THIS_MODULE;
+	data->rcdev.nr_resets = count;
+	data->rcdev.ops = &sun9i_mmc_reset_ops;
+	data->rcdev.of_node = pdev->dev.of_node;
+
+	ret = reset_controller_register(&data->rcdev);
+	if (ret)
+		goto err_rc_reg;
+
+	platform_set_drvdata(pdev, data);
+
+	return 0;
+
+err_rc_reg:
+	of_clk_del_provider(np);
+
+err_clk_provider:
+	for (i = 0; i < count; i++)
+		clk_unregister(clk_data->clks[i]);
+
+err_clk_register:
+	reset_control_assert(data->reset);
+
+	return ret;
+}
+
+static int sun9i_a80_mmc_config_clk_remove(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct sun9i_mmc_clk_data *data = platform_get_drvdata(pdev);
+	struct clk_onecell_data *clk_data = &data->clk_data;
+	int i;
+
+	reset_controller_unregister(&data->rcdev);
+	of_clk_del_provider(np);
+	for (i = 0; i < clk_data->clk_num; i++)
+		clk_unregister(clk_data->clks[i]);
+
+	reset_control_assert(data->reset);
+
+	return 0;
+}
+
+static const struct of_device_id sun9i_a80_mmc_config_clk_dt_ids[] = {
+	{ .compatible = "allwinner,sun9i-a80-mmc-config-clk" },
+	{ /* sentinel */ }
+};
+
+static struct platform_driver sun9i_a80_mmc_config_clk_driver = {
+	.driver = {
+		.name = "sun9i-a80-mmc-config-clk",
+		.of_match_table = sun9i_a80_mmc_config_clk_dt_ids,
+	},
+	.probe = sun9i_a80_mmc_config_clk_probe,
+	.remove = sun9i_a80_mmc_config_clk_remove,
+};
+module_platform_driver(sun9i_a80_mmc_config_clk_driver);
+
+MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
+MODULE_DESCRIPTION("Allwinner A80 MMC clock/reset Driver");
+MODULE_LICENSE("GPL v2");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (3 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:33   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index ddc34676987d..9d0a66c14caf 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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",
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (4 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:38   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 9d0a66c14caf..9b3b71c6f29b 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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>,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (5 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:39   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 08/13] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi Chen-Yu Tsai
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sunxi-common-regulators.dtsi | 54 +++++++++++++-------------
 1 file changed, 26 insertions(+), 28 deletions(-)

diff --git a/arch/arm/boot/dts/sunxi-common-regulators.dtsi b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
index b1d64dd183f4..e02baa66b33c 100644
--- a/arch/arm/boot/dts/sunxi-common-regulators.dtsi
+++ b/arch/arm/boot/dts/sunxi-common-regulators.dtsi
@@ -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";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 08/13] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (6 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

The A80 has 4 mmc controllers.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 48 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 9b3b71c6f29b..a31dff35d15b 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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>;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (7 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 08/13] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-14 16:40   ` Maxime Ripard
  2015-01-13  1:37 ` [PATCH v3 10/13] ARM: dts: sun9i: Convert a80 optimus board dts to label referencing Chen-Yu Tsai
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index a31dff35d15b..7387fb2a5111 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 10/13] ARM: dts: sun9i: Convert a80 optimus board dts to label referencing
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (8 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 11/13] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board Chen-Yu Tsai
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 76 ++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 39 deletions(-)

diff --git a/arch/arm/boot/dts/sun9i-a80-optimus.dts b/arch/arm/boot/dts/sun9i-a80-optimus.dts
index 58f5cb346519..f329ec85f4e4 100644
--- a/arch/arm/boot/dts/sun9i-a80-optimus.dts
+++ b/arch/arm/boot/dts/sun9i-a80-optimus.dts
@@ -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";
+};
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 11/13] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (9 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 10/13] ARM: dts: sun9i: Convert a80 optimus board dts to label referencing Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 12/13] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2 Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 13/13] ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board Chen-Yu Tsai
  12 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80-optimus.dts b/arch/arm/boot/dts/sun9i-a80-optimus.dts
index f329ec85f4e4..c8e038aafa9f 100644
--- a/arch/arm/boot/dts/sun9i-a80-optimus.dts
+++ b/arch/arm/boot/dts/sun9i-a80-optimus.dts
@@ -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 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 12/13] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (10 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 11/13] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  2015-01-13  1:37 ` [PATCH v3 13/13] ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board Chen-Yu Tsai
  12 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 7387fb2a5111..9e28ffc6dd90 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -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";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 13/13] ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board
  2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
                   ` (11 preceding siblings ...)
  2015-01-13  1:37 ` [PATCH v3 12/13] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2 Chen-Yu Tsai
@ 2015-01-13  1:37 ` Chen-Yu Tsai
  12 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-13  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Andreas F?rber <afaerber@suse.de>
---
 arch/arm/boot/dts/sun9i-a80-optimus.dts | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80-optimus.dts b/arch/arm/boot/dts/sun9i-a80-optimus.dts
index c8e038aafa9f..6a122a13f84e 100644
--- a/arch/arm/boot/dts/sun9i-a80-optimus.dts
+++ b/arch/arm/boot/dts/sun9i-a80-optimus.dts
@@ -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";
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks
  2015-01-13  1:37 ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Chen-Yu Tsai
@ 2015-01-14 16:26   ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:23AM +0800, Chen-Yu Tsai wrote:
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Applied, thanks!

Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80
  2015-01-13  1:37 ` [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
@ 2015-01-14 16:28   ` Maxime Ripard
  2015-01-15  2:34     ` Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:24AM +0800, Chen-Yu Tsai wrote:
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
>  drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
>  2 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index e4c42276c577..0dfd018ba47b 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -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.
>  
> diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
> index 4430d1398ce6..99ff2c7cccf7 100644
> --- a/drivers/clk/sunxi/clk-mod0.c
> +++ b/drivers/clk/sunxi/clk-mod0.c
> @@ -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) {

of_io_request_and_map returns an error pointer.

Looks good otherwise.

Thanks!
Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes for A80
  2015-01-13  1:37 ` [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
@ 2015-01-14 16:30   ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:25AM +0800, Chen-Yu Tsai wrote:
> The mmc module clocks are A80 specific module 0 (storage) type clocks.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Andreas F?rber <afaerber@suse.de>

Applied, thanks!

Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-13  1:37 ` [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
@ 2015-01-14 16:33   ` Maxime Ripard
  2015-01-15  2:24     ` Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

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

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets
  2015-01-13  1:37 ` [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
@ 2015-01-14 16:37   ` Maxime Ripard
  2015-01-15  2:29     ` Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:26AM +0800, Chen-Yu Tsai wrote:
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  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
> 
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index 0dfd018ba47b..60b44285250d 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -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

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes
  2015-01-13  1:37 ` [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
@ 2015-01-14 16:38   ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:28AM +0800, Chen-Yu Tsai wrote:
> Add the device tree nodes for the mmc config clock nodes.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  arch/arm/boot/dts/sun9i-a80.dtsi | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
> index 9d0a66c14caf..9b3b71c6f29b 100644
> --- a/arch/arm/boot/dts/sun9i-a80.dtsi
> +++ b/arch/arm/boot/dts/sun9i-a80.dtsi
> @@ -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 ..... ?


-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators
  2015-01-13  1:37 ` [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
@ 2015-01-14 16:39   ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:29AM +0800, Chen-Yu Tsai wrote:
> 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.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Applied, thanks!

Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0
  2015-01-13  1:37 ` [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
@ 2015-01-14 16:40   ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-14 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 13, 2015 at 09:37:31AM +0800, Chen-Yu Tsai wrote:
> mmc0 is only available on port F, and is always used with a 4 bit wide
> bus for the onboard micro-sd slot.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Andreas F?rber <afaerber@suse.de>

Applied, thanks!
Maxime

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-14 16:33   ` Maxime Ripard
@ 2015-01-15  2:24     ` Chen-Yu Tsai
  2015-01-15 15:20       ` Maxime Ripard
  0 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-15  2:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
>> 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.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>
> 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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets
  2015-01-14 16:37   ` Maxime Ripard
@ 2015-01-15  2:29     ` Chen-Yu Tsai
  0 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-15  2:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 12:37 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Tue, Jan 13, 2015 at 09:37:26AM +0800, Chen-Yu Tsai wrote:
>> 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.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>>  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
>>
>> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
>> index 0dfd018ba47b..60b44285250d 100644
>> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
>> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
>> @@ -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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80
  2015-01-14 16:28   ` Maxime Ripard
@ 2015-01-15  2:34     ` Chen-Yu Tsai
  0 siblings, 0 replies; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-15  2:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 12:28 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Tue, Jan 13, 2015 at 09:37:24AM +0800, Chen-Yu Tsai wrote:
>> 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.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>>  Documentation/devicetree/bindings/clock/sunxi.txt |  7 +++--
>>  drivers/clk/sunxi/clk-mod0.c                      | 32 +++++++++++++++++++++++
>>  2 files changed, 37 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
>> index e4c42276c577..0dfd018ba47b 100644
>> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
>> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
>> @@ -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.
>>
>> diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
>> index 4430d1398ce6..99ff2c7cccf7 100644
>> --- a/drivers/clk/sunxi/clk-mod0.c
>> +++ b/drivers/clk/sunxi/clk-mod0.c
>> @@ -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) {
>
> of_io_request_and_map returns an error pointer.

Fixed in my branch.

ChenYu

> Looks good otherwise.
>
> Thanks!
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-15  2:24     ` Chen-Yu Tsai
@ 2015-01-15 15:20       ` Maxime Ripard
  2015-01-15 15:35         ` [linux-sunxi] " Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Maxime Ripard @ 2015-01-15 15:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 10:24:04AM +0800, Chen-Yu Tsai wrote:
> On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
> >> 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.
> >>
> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >
> > 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

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-15 15:20       ` Maxime Ripard
@ 2015-01-15 15:35         ` Chen-Yu Tsai
  2015-01-15 15:51           ` Maxime Ripard
  0 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-15 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 11:20 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Thu, Jan 15, 2015 at 10:24:04AM +0800, Chen-Yu Tsai wrote:
>> On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
>> <maxime.ripard@free-electrons.com> wrote:
>> > On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
>> >> 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.
>> >>
>> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> >
>> > 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 :)

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-15 15:35         ` [linux-sunxi] " Chen-Yu Tsai
@ 2015-01-15 15:51           ` Maxime Ripard
  2015-01-15 16:09             ` Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Maxime Ripard @ 2015-01-15 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 11:35:42PM +0800, Chen-Yu Tsai wrote:
> On Thu, Jan 15, 2015 at 11:20 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > On Thu, Jan 15, 2015 at 10:24:04AM +0800, Chen-Yu Tsai wrote:
> >> On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
> >> <maxime.ripard@free-electrons.com> wrote:
> >> > On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
> >> >> 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.
> >> >>
> >> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >> >
> >> > 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 :)
> 
> 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.

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

> 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

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-15 15:51           ` Maxime Ripard
@ 2015-01-15 16:09             ` Chen-Yu Tsai
  2015-01-15 21:46               ` Maxime Ripard
  0 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2015-01-15 16:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 11:51 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Thu, Jan 15, 2015 at 11:35:42PM +0800, Chen-Yu Tsai wrote:
>> On Thu, Jan 15, 2015 at 11:20 PM, Maxime Ripard
>> <maxime.ripard@free-electrons.com> wrote:
>> > On Thu, Jan 15, 2015 at 10:24:04AM +0800, Chen-Yu Tsai wrote:
>> >> On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
>> >> <maxime.ripard@free-electrons.com> wrote:
>> >> > On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
>> >> >> 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.
>> >> >>
>> >> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> >> >
>> >> > 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 :)
>>
>> 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.
>
> Yeah, I know what it does, and we do agree on the fact that it's
> needed.
>
>> 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.

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [linux-sunxi] Re: [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks
  2015-01-15 16:09             ` Chen-Yu Tsai
@ 2015-01-15 21:46               ` Maxime Ripard
  0 siblings, 0 replies; 30+ messages in thread
From: Maxime Ripard @ 2015-01-15 21:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jan 16, 2015 at 12:09:01AM +0800, Chen-Yu Tsai wrote:
> On Thu, Jan 15, 2015 at 11:51 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > On Thu, Jan 15, 2015 at 11:35:42PM +0800, Chen-Yu Tsai wrote:
> >> On Thu, Jan 15, 2015 at 11:20 PM, Maxime Ripard
> >> <maxime.ripard@free-electrons.com> wrote:
> >> > On Thu, Jan 15, 2015 at 10:24:04AM +0800, Chen-Yu Tsai wrote:
> >> >> On Thu, Jan 15, 2015 at 12:33 AM, Maxime Ripard
> >> >> <maxime.ripard@free-electrons.com> wrote:
> >> >> > On Tue, Jan 13, 2015 at 09:37:27AM +0800, Chen-Yu Tsai wrote:
> >> >> >> 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.
> >> >> >>
> >> >> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >> >> >
> >> >> > 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 :)
> >>
> >> 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.
> >
> > Yeah, I know what it does, and we do agree on the fact that it's
> > needed.
> >
> >> 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.
> 
> 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.

> 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 :)

> 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

-- 
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>

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2015-01-15 21:46 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Chen-Yu Tsai
2015-01-14 16:26   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
2015-01-14 16:28   ` Maxime Ripard
2015-01-15  2:34     ` Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
2015-01-14 16:30   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
2015-01-14 16:37   ` Maxime Ripard
2015-01-15  2:29     ` Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
2015-01-14 16:33   ` Maxime Ripard
2015-01-15  2:24     ` Chen-Yu Tsai
2015-01-15 15:20       ` Maxime Ripard
2015-01-15 15:35         ` [linux-sunxi] " Chen-Yu Tsai
2015-01-15 15:51           ` Maxime Ripard
2015-01-15 16:09             ` Chen-Yu Tsai
2015-01-15 21:46               ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
2015-01-14 16:38   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
2015-01-14 16:39   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 08/13] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
2015-01-14 16:40   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 10/13] ARM: dts: sun9i: Convert a80 optimus board dts to label referencing Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 11/13] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 12/13] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2 Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 13/13] ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board Chen-Yu Tsai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.