Skip to contentSkip to conversation

arm64: Allwinner A64 support based on sunxi-ng

PATCH Superseded Maxime Ripard 7 participants 35 messages Jul 26, 2016 – Sep 9, 2016

Subsystems (6)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover arm64: Allwinner A64 support based on sunxi-ng

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Let me know what you think,
Maxime

1: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/410338.html

Andre Przywara (5):
arm64: sunxi: Kconfig: add essential pinctrl driver
arm64: Kconfig: sunxi: add PINCTRL
Documentation: devicetree: add vendor prefix for Pine64
arm64: dts: add Allwinner A64 SoC .dtsi
arm64: dts: add Pine64 support

Maxime Ripard (8):
clk: sunxi-ng: mux: Rename mux macro to be consistent
clk: sunxi-ng: mux: Add mux table support
clk: sunxi-ng: sun8i: Rename DDR and video plls
clk: sunxi-ng: sun8i: Fix register offset
clk: sunxi-ng: sun8i: Rename H3 only clocks
clk: sunxi-ng: sun8i: Move fixed factors around
clk: sunxi-ng: sun8i: Prefix clock defines by SoC Name
clk: sunxi-ng: Add A64 clocks

 Documentation/devicetree/bindings/arm/sunxi.txt    |   1 +
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  62 +-
 arch/arm64/Kconfig.platforms                       |   2 +
 arch/arm64/boot/dts/Makefile                       |   1 +
 arch/arm64/boot/dts/allwinner/Makefile             |   5 +
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  50 ++
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  70 ++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      | 273 +++++++
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 ++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 896 ++++++++++++++++-----
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h                |  44 +-
 drivers/clk/sunxi-ng/ccu_div.h                     |   2 +-
 drivers/clk/sunxi-ng/ccu_mp.h                      |   2 +-
 drivers/clk/sunxi-ng/ccu_mux.c                     |  14 +
 drivers/clk/sunxi-ng/ccu_mux.h                     |  29 +-
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 +++
 include/dt-bindings/clock/sun8i-h3-ccu.h           | 188 ++---
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++
 23 files changed, 1588 insertions(+), 366 deletions(-)
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
Signature · 1 line
2.9.2
#1 lore raw

PATCH 1/13 clk: sunxi-ng: mux: Rename mux macro to be consistent

Rename the internal mux macro to be consistent with the other internal structure macros.

---
 drivers/clk/sunxi-ng/ccu_div.h | 2 +-
 drivers/clk/sunxi-ng/ccu_mp.h  | 2 +-
 drivers/clk/sunxi-ng/ccu_mux.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/clk/sunxi-ng/ccu_div.h +1 -1
index 653ade5769b3..5d98549e23a6 100644
@@ -83,7 +83,7 @@ struct ccu_div {
 	struct ccu_div _struct = {					\
 		.enable	= _gate,					\
 		.div	= _SUNXI_CCU_DIV(_mshift, _mwidth),		\
-		.mux	= SUNXI_CLK_MUX(_muxshift, _muxwidth),		\
+		.mux	= _SUNXI_CCU_MUX(_muxshift, _muxwidth),		\
 		.common	= {						\
 			.reg		= _reg,				\
 			.hw.init	= CLK_HW_INIT_PARENTS(_name,	\
drivers/clk/sunxi-ng/ccu_mp.h +1 -1
index 3cf12bf95962..edf9215ea8cc 100644
@@ -44,7 +44,7 @@ struct ccu_mp {
 		.enable	= _gate,					\
 		.m	= _SUNXI_CCU_DIV(_mshift, _mwidth),		\
 		.p	= _SUNXI_CCU_DIV(_pshift, _pwidth),		\
-		.mux	= SUNXI_CLK_MUX(_muxshift, _muxwidth),		\
+		.mux	= _SUNXI_CCU_MUX(_muxshift, _muxwidth),		\
 		.common	= {						\
 			.reg		= _reg,				\
 			.hw.init	= CLK_HW_INIT_PARENTS(_name,	\
drivers/clk/sunxi-ng/ccu_mux.h +3 -3
index 945082631e7d..95cfecec3c39 100644
@@ -21,7 +21,7 @@ struct ccu_mux_internal {
 	} variable_prediv;
 };
 
-#define SUNXI_CLK_MUX(_shift, _width)	\
+#define _SUNXI_CCU_MUX(_shift, _width)		\
 	{					\
 		.shift	= _shift,		\
 		.width	= _width,		\
@@ -37,7 +37,7 @@ struct ccu_mux {
 
 #define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, _flags) \
 	struct ccu_mux _struct = {					\
-		.mux	= SUNXI_CLK_MUX(_shift, _width),		\
+		.mux	= _SUNXI_CCU_MUX(_shift, _width),		\
 		.common	= {						\
 			.reg		= _reg,				\
 			.hw.init	= CLK_HW_INIT_PARENTS(_name,	\
@@ -51,7 +51,7 @@ struct ccu_mux {
 				_shift, _width, _gate, _flags)		\
 	struct ccu_mux _struct = {					\
 		.enable	= _gate,					\
-		.mux	= SUNXI_CLK_MUX(_shift, _width),		\
+		.mux	= _SUNXI_CCU_MUX(_shift, _width),		\
 		.common	= {						\
 			.reg		= _reg,				\
 			.hw.init	= CLK_HW_INIT_PARENTS(_name,	\
Signature · 1 line
2.9.2
#2 lore raw

PATCH 2/13 clk: sunxi-ng: mux: Add mux table support

In reply to Maxime Ripard

Add support for the table based muxes, and add macros to register them.

---
 drivers/clk/sunxi-ng/ccu_mux.c | 14 ++++++++++++++
 drivers/clk/sunxi-ng/ccu_mux.h | 27 ++++++++++++++++++++-------
 2 files changed, 34 insertions(+), 7 deletions(-)
drivers/clk/sunxi-ng/ccu_mux.c +14 -0
index 58fc36e7dcce..f942044b038a 100644
@@ -100,6 +100,7 @@ out:
 u8 ccu_mux_helper_get_parent(struct ccu_common *common,
 			     struct ccu_mux_internal *cm)
 {
+	int num_parents = clk_hw_get_num_parents(&common->hw);
 	u32 reg;
 	u8 parent;
 
@@ -107,6 +108,16 @@ u8 ccu_mux_helper_get_parent(struct ccu_common *common,
 	parent = reg >> cm->shift;
 	parent &= (1 << cm->width) - 1;
 
+	if (cm->table) {
+		int i;
+
+		for (i = 0; i < num_parents; i++)
+			if (cm->table[i] == parent)
+				return i;
+
+		return -EINVAL;
+	}
+
 	return parent;
 }
 
@@ -117,6 +128,9 @@ int ccu_mux_helper_set_parent(struct ccu_common *common,
 	unsigned long flags;
 	u32 reg;
 
+	if (cm->table)
+		index = cm->table[index];
+
 	spin_lock_irqsave(common->lock, flags);
 
 	reg = readl(common->base + common->reg);
drivers/clk/sunxi-ng/ccu_mux.h +20 -7
index 95cfecec3c39..00cec8ac6ae3 100644
@@ -9,6 +9,8 @@ struct ccu_mux_internal {
 	u8	shift;
 	u8	width;
 
+	const u8	*table;
+
 	struct {
 		u8	index;
 		u8	div;
@@ -21,12 +23,16 @@ struct ccu_mux_internal {
 	} variable_prediv;
 };
 
-#define _SUNXI_CCU_MUX(_shift, _width)		\
-	{					\
-		.shift	= _shift,		\
-		.width	= _width,		\
+#define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table)	\
+	{						\
+		.shift	= _shift,			\
+		.width	= _width,			\
+		.table	= _table,			\
 	}
 
+#define _SUNXI_CCU_MUX(_shift, _width)			\
+	_SUNXI_CCU_MUX_TABLE(_shift, _width, NULL)
+
 struct ccu_mux {
 	u16			reg;
 	u32			enable;
@@ -47,11 +53,12 @@ struct ccu_mux {
 		}							\
 	}
 
-#define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg,		\
-				_shift, _width, _gate, _flags)		\
+#define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table,	\
+				      _reg,  _shift, _width, _gate,	\
+				      _flags)				\
 	struct ccu_mux _struct = {					\
 		.enable	= _gate,					\
-		.mux	= _SUNXI_CCU_MUX(_shift, _width),		\
+		.mux	= _SUNXI_CCU_MUX_TABLE(_shift, _width, _table),	\
 		.common	= {						\
 			.reg		= _reg,				\
 			.hw.init	= CLK_HW_INIT_PARENTS(_name,	\
@@ -61,6 +68,12 @@ struct ccu_mux {
 		}							\
 	}
 
+#define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg,		\
+				_shift, _width, _gate, _flags)		\
+	SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL,	\
+				      _reg,  _shift, _width, _gate,	\
+				      _flags)
+
 static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
 {
 	struct ccu_common *common = hw_to_ccu_common(hw);
Signature · 1 line
2.9.2
#3 lore raw

PATCH 3/13 clk: sunxi-ng: sun8i: Rename DDR and video plls

In reply to Maxime Ripard

In order to deal with the A64 that will have several video and ddr plls, rename the first ones to add an index.

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +10 -10
index 9af359544110..68492808e5fc 100644
@@ -57,8 +57,8 @@ static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
 				   BIT(28),	/* lock */
 				   0);
 
-static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video",
-					"osc24M", 0x0010,
+static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video0_clk, "pll-video0",
+					"osc24M", 0x010,
 					8, 7,		/* N */
 					0, 4,		/* M */
 					BIT(24),	/* frac enable */
@@ -81,7 +81,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
 					BIT(28),	/* lock */
 					0);
 
-static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr_clk, "pll-ddr",
+static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
 				    "osc24M", 0x020,
 				    8, 5,	/* N */
 				    4, 2,	/* K */
@@ -422,7 +422,7 @@ static SUNXI_CCU_GATE(usb_ohci2_clk,	"usb-ohci2",	"osc24M",
 static SUNXI_CCU_GATE(usb_ohci3_clk,	"usb-ohci3",	"osc24M",
 		      0x0cc, BIT(19), 0);
 
-static const char * const dram_parents[] = { "pll-ddr", "pll-periph0-2x" };
+static const char * const dram_parents[] = { "pll-ddr0", "pll-periph0-2x" };
 static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
 			    0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL);
 
@@ -439,7 +439,7 @@ static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
 static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
 				 0x104, 0, 4, 24, 3, BIT(31), 0);
 
-static const char * const tcon_parents[] = { "pll-video" };
+static const char * const tcon_parents[] = { "pll-video0" };
 static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
 				 0x118, 0, 4, 24, 3, BIT(31), 0);
 
@@ -458,7 +458,7 @@ static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
 static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
 				 0x134, 16, 4, 24, 3, BIT(31), 0);
 
-static const char * const csi_mclk_parents[] = { "osc24M", "pll-video", "pll-periph0" };
+static const char * const csi_mclk_parents[] = { "osc24M", "pll-video0", "pll-periph0" };
 static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents,
 				 0x134, 0, 5, 8, 3, BIT(15), 0);
 
@@ -470,14 +470,14 @@ static SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
 static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
 		      0x144, BIT(31), 0);
 
-static const char * const hdmi_parents[] = { "pll-video" };
+static const char * const hdmi_parents[] = { "pll-video0" };
 static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
 				 0x150, 0, 4, 24, 2, BIT(31), 0);
 
 static SUNXI_CCU_GATE(hdmi_ddc_clk,	"hdmi-ddc",	"osc24M",
 		      0x154, BIT(31), 0);
 
-static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", "pll-ddr" };
+static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", "pll-ddr0" };
 static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
 				 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
 
@@ -487,9 +487,9 @@ static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
 static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&pll_cpux_clk.common,
 	&pll_audio_base_clk.common,
-	&pll_video_clk.common,
+	&pll_video0_clk.common,
 	&pll_ve_clk.common,
-	&pll_ddr_clk.common,
+	&pll_ddr0_clk.common,
 	&pll_periph0_clk.common,
 	&pll_gpu_clk.common,
 	&pll_periph1_clk.common,
Signature · 1 line
2.9.2
#4 lore raw

Re: [PATCH 03/13] clk: sunxi-ng: sun8i: Rename DDR and video plls

reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi,

[auto build test ERROR on clk/clk-next]
[also build test ERROR on next-20160726]
[cannot apply to v4.7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Maxime-Ripard/arm64-Allwinner-A64-support-based-on-sunxi-ng/20160727-084745
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

Note: the linux-review/Maxime-Ripard/arm64-Allwinner-A64-support-based-on-sunxi-ng/20160727-084745 HEAD b4837ac76808c0a3584aef785ddfe74589c1b8fb builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> drivers/clk/sunxi-ng/ccu-sun8i-h3.c:620:23: error: 'pll_video_clk' undeclared here (not in a function)
      [CLK_PLL_VIDEO]  = &pll_video_clk.common.hw,
                          ^
>> drivers/clk/sunxi-ng/ccu-sun8i-h3.c:622:21: error: 'pll_ddr_clk' undeclared here (not in a function)
      [CLK_PLL_DDR]  = &pll_ddr_clk.common.hw,
                        ^

vim +/pll_video_clk +620 drivers/clk/sunxi-ng/ccu-sun8i-h3.c

0577e485 Maxime Ripard 2016-06-29  614  		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29  615  		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29  616  		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
0577e485 Maxime Ripard 2016-06-29  617  		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
0577e485 Maxime Ripard 2016-06-29  618  		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
0577e485 Maxime Ripard 2016-06-29  619  		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
0577e485 Maxime Ripard 2016-06-29 @620  		[CLK_PLL_VIDEO]		= &pll_video_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29  621  		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29 @622  		[CLK_PLL_DDR]		= &pll_ddr_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29  623  		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
0577e485 Maxime Ripard 2016-06-29  624  		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
0577e485 Maxime Ripard 2016-06-29  625  		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,

:::::: The code at line 620 was first introduced by commit :::::: 0577e4853bfb4c65f620fa56d3157692df7f766e clk: sunxi-ng: Add H3 clocks

:::::: TO: Maxime Ripard <[email protected]> :::::: CC: Michael Turquette <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 50253 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160727/6ed10be2/attachment-0001.obj>

#5 lore raw

PATCH 4/13 clk: sunxi-ng: sun8i: Fix register offset

In reply to Maxime Ripard

Some registers offset were having one 0 too many compared to the others. Remove it.

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +3 -3
index 68492808e5fc..3c236eefbb3a 100644
@@ -70,7 +70,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video0_clk, "pll-video0",
 					0);
 
 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
-					"osc24M", 0x0018,
+					"osc24M", 0x018,
 					8, 7,		/* N */
 					0, 4,		/* M */
 					BIT(24),	/* frac enable */
@@ -100,7 +100,7 @@ static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph0_clk, "pll-periph0",
 					   0);
 
 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
-					"osc24M", 0x0038,
+					"osc24M", 0x038,
 					8, 7,		/* N */
 					0, 4,		/* M */
 					BIT(24),	/* frac enable */
@@ -121,7 +121,7 @@ static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1",
 					   0);
 
 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
-					"osc24M", 0x0048,
+					"osc24M", 0x048,
 					8, 7,		/* N */
 					0, 4,		/* M */
 					BIT(24),	/* frac enable */
Signature · 1 line
2.9.2
#6 lore raw

PATCH 5/13 clk: sunxi-ng: sun8i: Rename H3 only clocks

In reply to Maxime Ripard

Add a suffix for the H3-only clocks to prepare the introduction of the A64 clocks.

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 140 ++++++++++++++++++------------------
 1 file changed, 70 insertions(+), 70 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +70 -70
index 3c236eefbb3a..f61d2e245ac4 100644
@@ -111,7 +111,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
 					BIT(28),	/* lock */
 					0);
 
-static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1",
+static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_h3_clk, "pll-periph1",
 					   "osc24M", 0x044,
 					   8, 5,	/* N */
 					   4, 2,	/* K */
@@ -175,9 +175,9 @@ static struct clk_div_table apb1_div_table[] = {
 static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
 			   0x054, 8, 2, apb1_div_table, 0);
 
-static const char * const apb2_parents[] = { "osc32k", "osc24M",
-					     "pll-periph0" , "pll-periph0" };
-static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
+static const char * const apb2_h3_parents[] = { "osc32k", "osc24M",
+						"pll-periph0" , "pll-periph0" };
+static SUNXI_CCU_MP_WITH_MUX(apb2_h3_clk, "apb2", apb2_h3_parents, 0x058,
 			     0, 5,	/* M */
 			     16, 2,	/* P */
 			     24, 2,	/* mux */
@@ -235,17 +235,17 @@ static SUNXI_CCU_GATE(bus_ehci0_clk,	"bus-ehci0",	"ahb1",
 		      0x060, BIT(24), 0);
 static SUNXI_CCU_GATE(bus_ehci1_clk,	"bus-ehci1",	"ahb2",
 		      0x060, BIT(25), 0);
-static SUNXI_CCU_GATE(bus_ehci2_clk,	"bus-ehci2",	"ahb2",
+static SUNXI_CCU_GATE(bus_ehci2_h3_clk,	"bus-ehci2",	"ahb2",
 		      0x060, BIT(26), 0);
-static SUNXI_CCU_GATE(bus_ehci3_clk,	"bus-ehci3",	"ahb2",
+static SUNXI_CCU_GATE(bus_ehci3_h3_clk,	"bus-ehci3",	"ahb2",
 		      0x060, BIT(27), 0);
 static SUNXI_CCU_GATE(bus_ohci0_clk,	"bus-ohci0",	"ahb1",
 		      0x060, BIT(28), 0);
 static SUNXI_CCU_GATE(bus_ohci1_clk,	"bus-ohci1",	"ahb2",
 		      0x060, BIT(29), 0);
-static SUNXI_CCU_GATE(bus_ohci2_clk,	"bus-ohci2",	"ahb2",
+static SUNXI_CCU_GATE(bus_ohci2_h3_clk,	"bus-ohci2",	"ahb2",
 		      0x060, BIT(30), 0);
-static SUNXI_CCU_GATE(bus_ohci3_clk,	"bus-ohci3",	"ahb2",
+static SUNXI_CCU_GATE(bus_ohci3_h3_clk,	"bus-ohci3",	"ahb2",
 		      0x060, BIT(31), 0);
 
 static SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
@@ -258,7 +258,7 @@ static SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb1",
 		      0x064, BIT(5), 0);
 static SUNXI_CCU_GATE(bus_csi_clk,	"bus-csi",	"ahb1",
 		      0x064, BIT(8), 0);
-static SUNXI_CCU_GATE(bus_tve_clk,	"bus-tve",	"ahb1",
+static SUNXI_CCU_GATE(bus_tve_h3_clk,	"bus-tve",	"ahb1",
 		      0x064, BIT(9), 0);
 static SUNXI_CCU_GATE(bus_hdmi_clk,	"bus-hdmi",	"ahb1",
 		      0x064, BIT(11), 0);
@@ -300,10 +300,10 @@ static SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
 		      0x06c, BIT(18), 0);
 static SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
 		      0x06c, BIT(19), 0);
-static SUNXI_CCU_GATE(bus_scr_clk,	"bus-scr",	"apb2",
+static SUNXI_CCU_GATE(bus_scr_h3_clk,	"bus-scr",	"apb2",
 		      0x06c, BIT(20), 0);
 
-static SUNXI_CCU_GATE(bus_ephy_clk,	"bus-ephy",	"ahb1",
+static SUNXI_CCU_GATE(bus_ephy_h3_clk,	"bus-ephy",	"ahb1",
 		      0x070, BIT(0), 0);
 static SUNXI_CCU_GATE(bus_dbg_clk,	"bus-dbg",	"ahb1",
 		      0x070, BIT(7), 0);
@@ -326,40 +326,40 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
 				  BIT(31),	/* gate */
 				  0);
 
-static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
+static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_h3_clk, "mmc0", mod0_default_parents, 0x088,
 				  0, 4,		/* M */
 				  16, 2,	/* P */
 				  24, 2,	/* mux */
 				  BIT(31),	/* gate */
 				  0);
 
-static SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0",
+static SUNXI_CCU_PHASE(mmc0_sample_h3_clk, "mmc0_sample", "mmc0",
 		       0x088, 20, 3, 0);
-static SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0",
+static SUNXI_CCU_PHASE(mmc0_output_h3_clk, "mmc0_output", "mmc0",
 		       0x088, 8, 3, 0);
 
-static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
+static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_h3_clk, "mmc1", mod0_default_parents, 0x08c,
 				  0, 4,		/* M */
 				  16, 2,	/* P */
 				  24, 2,	/* mux */
 				  BIT(31),	/* gate */
 				  0);
 
-static SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1",
+static SUNXI_CCU_PHASE(mmc1_sample_h3_clk, "mmc1_sample", "mmc1",
 		       0x08c, 20, 3, 0);
-static SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1",
+static SUNXI_CCU_PHASE(mmc1_output_h3_clk, "mmc1_output", "mmc1",
 		       0x08c, 8, 3, 0);
 
-static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
+static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_h3_clk, "mmc2", mod0_default_parents, 0x090,
 				  0, 4,		/* M */
 				  16, 2,	/* P */
 				  24, 2,	/* mux */
 				  BIT(31),	/* gate */
 				  0);
 
-static SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2",
+static SUNXI_CCU_PHASE(mmc2_sample_h3_clk, "mmc2_sample", "mmc2",
 		       0x090, 20, 3, 0);
-static SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2",
+static SUNXI_CCU_PHASE(mmc2_output_h3_clk, "mmc2_output", "mmc2",
 		       0x090, 8, 3, 0);
 
 static const char * const ts_parents[] = { "osc24M", "pll-periph0", };
@@ -370,7 +370,7 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
 				  BIT(31),	/* gate */
 				  0);
 
-static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", mod0_default_parents, 0x09c,
+static SUNXI_CCU_MP_WITH_MUX_GATE(ce_h3_clk, "ce", mod0_default_parents, 0x09c,
 				  0, 4,		/* M */
 				  16, 2,	/* P */
 				  24, 2,	/* mux */
@@ -409,21 +409,21 @@ static SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
 		      0x0cc, BIT(8), 0);
 static SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
 		      0x0cc, BIT(9), 0);
-static SUNXI_CCU_GATE(usb_phy2_clk,	"usb-phy2",	"osc24M",
+static SUNXI_CCU_GATE(usb_phy2_h3_clk,	"usb-phy2",	"osc24M",
 		      0x0cc, BIT(10), 0);
-static SUNXI_CCU_GATE(usb_phy3_clk,	"usb-phy3",	"osc24M",
+static SUNXI_CCU_GATE(usb_phy3_h3_clk,	"usb-phy3",	"osc24M",
 		      0x0cc, BIT(11), 0);
-static SUNXI_CCU_GATE(usb_ohci0_clk,	"usb-ohci0",	"osc24M",
+static SUNXI_CCU_GATE(usb_ohci0_h3_clk,	"usb-ohci0",	"osc24M",
 		      0x0cc, BIT(16), 0);
-static SUNXI_CCU_GATE(usb_ohci1_clk,	"usb-ohci1",	"osc24M",
+static SUNXI_CCU_GATE(usb_ohci1_h3_clk,	"usb-ohci1",	"osc24M",
 		      0x0cc, BIT(17), 0);
-static SUNXI_CCU_GATE(usb_ohci2_clk,	"usb-ohci2",	"osc24M",
+static SUNXI_CCU_GATE(usb_ohci2_h3_clk,	"usb-ohci2",	"osc24M",
 		      0x0cc, BIT(18), 0);
-static SUNXI_CCU_GATE(usb_ohci3_clk,	"usb-ohci3",	"osc24M",
+static SUNXI_CCU_GATE(usb_ohci3_h3_clk,	"usb-ohci3",	"osc24M",
 		      0x0cc, BIT(19), 0);
 
-static const char * const dram_parents[] = { "pll-ddr0", "pll-periph0-2x" };
-static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
+static const char * const dram_h3_parents[] = { "pll-ddr0", "pll-periph0-2x" };
+static SUNXI_CCU_M_WITH_MUX(dram_h3_clk, "dram", dram_h3_parents,
 			    0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL);
 
 static SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"dram",
@@ -439,12 +439,12 @@ static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
 static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
 				 0x104, 0, 4, 24, 3, BIT(31), 0);
 
-static const char * const tcon_parents[] = { "pll-video0" };
-static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
+static const char * const tcon0_h3_parents[] = { "pll-video0" };
+static SUNXI_CCU_M_WITH_MUX_GATE(tcon0_h3_clk, "tcon0", tcon0_h3_parents,
 				 0x118, 0, 4, 24, 3, BIT(31), 0);
 
-static const char * const tve_parents[] = { "pll-de", "pll-periph1" };
-static SUNXI_CCU_M_WITH_MUX_GATE(tve_clk, "tve", tve_parents,
+static const char * const tve_h3_parents[] = { "pll-de", "pll-periph1" };
+static SUNXI_CCU_M_WITH_MUX_GATE(tve_h3_clk, "tve", tve_h3_parents,
 				 0x120, 0, 4, 24, 3, BIT(31), 0);
 
 static const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" };
@@ -458,8 +458,8 @@ static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
 static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
 				 0x134, 16, 4, 24, 3, BIT(31), 0);
 
-static const char * const csi_mclk_parents[] = { "osc24M", "pll-video0", "pll-periph0" };
-static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents,
+static const char * const csi_mclk_h3_parents[] = { "osc24M", "pll-video0", "pll-periph0" };
+static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_h3_clk, "csi-mclk", csi_mclk_h3_parents,
 				 0x134, 0, 5, 8, 3, BIT(15), 0);
 
 static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
@@ -470,15 +470,15 @@ static SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
 static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
 		      0x144, BIT(31), 0);
 
-static const char * const hdmi_parents[] = { "pll-video0" };
-static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
+static const char * const hdmi_h3_parents[] = { "pll-video0" };
+static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_h3_clk, "hdmi", hdmi_h3_parents,
 				 0x150, 0, 4, 24, 2, BIT(31), 0);
 
 static SUNXI_CCU_GATE(hdmi_ddc_clk,	"hdmi-ddc",	"osc24M",
 		      0x154, BIT(31), 0);
 
-static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", "pll-ddr0" };
-static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
+static const char * const mbus_h3_parents[] = { "osc24M", "pll-periph0-2x", "pll-ddr0" };
+static SUNXI_CCU_M_WITH_MUX_GATE(mbus_h3_clk, "mbus", mbus_h3_parents,
 				 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
 
 static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
@@ -492,13 +492,13 @@ static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&pll_ddr0_clk.common,
 	&pll_periph0_clk.common,
 	&pll_gpu_clk.common,
-	&pll_periph1_clk.common,
+	&pll_periph1_h3_clk.common,
 	&pll_de_clk.common,
 	&cpux_clk.common,
 	&axi_clk.common,
 	&ahb1_clk.common,
 	&apb1_clk.common,
-	&apb2_clk.common,
+	&apb2_h3_clk.common,
 	&ahb2_clk.common,
 	&bus_ce_clk.common,
 	&bus_dma_clk.common,
@@ -515,18 +515,18 @@ static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&bus_otg_clk.common,
 	&bus_ehci0_clk.common,
 	&bus_ehci1_clk.common,
-	&bus_ehci2_clk.common,
-	&bus_ehci3_clk.common,
+	&bus_ehci2_h3_clk.common,
+	&bus_ehci3_h3_clk.common,
 	&bus_ohci0_clk.common,
 	&bus_ohci1_clk.common,
-	&bus_ohci2_clk.common,
-	&bus_ohci3_clk.common,
+	&bus_ohci2_h3_clk.common,
+	&bus_ohci3_h3_clk.common,
 	&bus_ve_clk.common,
 	&bus_tcon0_clk.common,
 	&bus_tcon1_clk.common,
 	&bus_deinterlace_clk.common,
 	&bus_csi_clk.common,
-	&bus_tve_clk.common,
+	&bus_tve_h3_clk.common,
 	&bus_hdmi_clk.common,
 	&bus_de_clk.common,
 	&bus_gpu_clk.common,
@@ -546,22 +546,22 @@ static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&bus_uart1_clk.common,
 	&bus_uart2_clk.common,
 	&bus_uart3_clk.common,
-	&bus_scr_clk.common,
-	&bus_ephy_clk.common,
+	&bus_scr_h3_clk.common,
+	&bus_ephy_h3_clk.common,
 	&bus_dbg_clk.common,
 	&ths_clk.common,
 	&nand_clk.common,
-	&mmc0_clk.common,
-	&mmc0_sample_clk.common,
-	&mmc0_output_clk.common,
-	&mmc1_clk.common,
-	&mmc1_sample_clk.common,
-	&mmc1_output_clk.common,
-	&mmc2_clk.common,
-	&mmc2_sample_clk.common,
-	&mmc2_output_clk.common,
+	&mmc0_h3_clk.common,
+	&mmc0_sample_h3_clk.common,
+	&mmc0_output_h3_clk.common,
+	&mmc1_h3_clk.common,
+	&mmc1_sample_h3_clk.common,
+	&mmc1_output_h3_clk.common,
+	&mmc2_h3_clk.common,
+	&mmc2_sample_h3_clk.common,
+	&mmc2_output_h3_clk.common,
 	&ts_clk.common,
-	&ce_clk.common,
+	&ce_h3_clk.common,
 	&spi0_clk.common,
 	&spi1_clk.common,
 	&i2s0_clk.common,
@@ -570,30 +570,30 @@ static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&spdif_clk.common,
 	&usb_phy0_clk.common,
 	&usb_phy1_clk.common,
-	&usb_phy2_clk.common,
-	&usb_phy3_clk.common,
-	&usb_ohci0_clk.common,
-	&usb_ohci1_clk.common,
-	&usb_ohci2_clk.common,
-	&usb_ohci3_clk.common,
-	&dram_clk.common,
+	&usb_phy2_h3_clk.common,
+	&usb_phy3_h3_clk.common,
+	&usb_ohci0_h3_clk.common,
+	&usb_ohci1_h3_clk.common,
+	&usb_ohci2_h3_clk.common,
+	&usb_ohci3_h3_clk.common,
+	&dram_h3_clk.common,
 	&dram_ve_clk.common,
 	&dram_csi_clk.common,
 	&dram_deinterlace_clk.common,
 	&dram_ts_clk.common,
 	&de_clk.common,
-	&tcon_clk.common,
-	&tve_clk.common,
+	&tcon0_h3_clk.common,
+	&tve_h3_clk.common,
 	&deinterlace_clk.common,
 	&csi_misc_clk.common,
 	&csi_sclk_clk.common,
-	&csi_mclk_clk.common,
+	&csi_mclk_h3_clk.common,
 	&ve_clk.common,
 	&ac_dig_clk.common,
 	&avs_clk.common,
-	&hdmi_clk.common,
+	&hdmi_h3_clk.common,
 	&hdmi_ddc_clk.common,
-	&mbus_clk.common,
+	&mbus_h3_clk.common,
 	&gpu_clk.common,
 };
 
Signature · 1 line
2.9.2
#7 lore raw

PATCH 6/13 clk: sunxi-ng: sun8i: Move fixed factors around

In reply to Maxime Ripard

Move the fixed factors clocks before the ccu_common list so that we can separate the clocks definitions and the registration part.

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +13 -12
index f61d2e245ac4..ec8c67201e8e 100644
@@ -484,6 +484,19 @@ static SUNXI_CCU_M_WITH_MUX_GATE(mbus_h3_clk, "mbus", mbus_h3_parents,
 static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
 			     0x1a0, 0, 3, BIT(31), 0);
 
+/* Fixed Factor clocks */
+/* We hardcode the divider to 4 for now */
+static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
+			"pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
+static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
+			"pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
+static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
+			"pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
+static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x",
+			"pll-audio-base", 1, 2, CLK_SET_RATE_PARENT);
+static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
+			"pll-periph0", 1, 2, 0);
+
 static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&pll_cpux_clk.common,
 	&pll_audio_base_clk.common,
@@ -597,18 +610,6 @@ static struct ccu_common *sun8i_h3_ccu_clks[] = {
 	&gpu_clk.common,
 };
 
-/* We hardcode the divider to 4 for now */
-static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
-			"pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
-static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
-			"pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
-static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
-			"pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
-static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x",
-			"pll-audio-base", 1, 2, CLK_SET_RATE_PARENT);
-static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x",
-			"pll-periph0", 1, 2, 0);
-
 static struct clk_hw_onecell_data sun8i_h3_hw_clks = {
 	.hws	= {
 		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
Signature · 1 line
2.9.2
#8 lore raw

PATCH 7/13 clk: sunxi-ng: sun8i: Prefix clock defines by SoC Name

In reply to Maxime Ripard

Since the A64 and H3 have a slightly different clock set, they will have different opaque clock numbers set as well. Make that obvious by using the SoC name in the defines.

---
 arch/arm/boot/dts/sun8i-h3.dtsi          |  62 ++++-----
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c      | 232 +++++++++++++++----------------
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h      |  44 +++---
 include/dt-bindings/clock/sun8i-h3-ccu.h | 188 ++++++++++++-------------
 4 files changed, 263 insertions(+), 263 deletions(-)
arch/arm/boot/dts/sun8i-h3.dtsi +31 -31
index 9871bad34742..0e7005865e20 100644
@@ -144,7 +144,7 @@
 			compatible = "allwinner,sun8i-h3-dma";
 			reg = <0x01c02000 0x1000>;
 			interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_DMA>;
+			clocks = <&ccu CLK_H3_BUS_DMA>;
 			resets = <&ccu RST_BUS_DMA>;
 			#dma-cells = <1>;
 		};
@@ -152,10 +152,10 @@
 		mmc0: mmc at 01c0f000 {
 			compatible = "allwinner,sun5i-a13-mmc";
 			reg = <0x01c0f000 0x1000>;
-			clocks = <&ccu CLK_BUS_MMC0>,
-				 <&ccu CLK_MMC0>,
-				 <&ccu CLK_MMC0_OUTPUT>,
-				 <&ccu CLK_MMC0_SAMPLE>;
+			clocks = <&ccu CLK_H3_BUS_MMC0>,
+				 <&ccu CLK_H3_MMC0>,
+				 <&ccu CLK_H3_MMC0_OUTPUT>,
+				 <&ccu CLK_H3_MMC0_SAMPLE>;
 			clock-names = "ahb",
 				      "mmc",
 				      "output",
@@ -171,10 +171,10 @@
 		mmc1: mmc at 01c10000 {
 			compatible = "allwinner,sun5i-a13-mmc";
 			reg = <0x01c10000 0x1000>;
-			clocks = <&ccu CLK_BUS_MMC1>,
-				 <&ccu CLK_MMC1>,
-				 <&ccu CLK_MMC1_OUTPUT>,
-				 <&ccu CLK_MMC1_SAMPLE>;
+			clocks = <&ccu CLK_H3_BUS_MMC1>,
+				 <&ccu CLK_H3_MMC1>,
+				 <&ccu CLK_H3_MMC1_OUTPUT>,
+				 <&ccu CLK_H3_MMC1_SAMPLE>;
 			clock-names = "ahb",
 				      "mmc",
 				      "output",
@@ -190,10 +190,10 @@
 		mmc2: mmc at 01c11000 {
 			compatible = "allwinner,sun5i-a13-mmc";
 			reg = <0x01c11000 0x1000>;
-			clocks = <&ccu CLK_BUS_MMC2>,
-				 <&ccu CLK_MMC2>,
-				 <&ccu CLK_MMC2_OUTPUT>,
-				 <&ccu CLK_MMC2_SAMPLE>;
+			clocks = <&ccu CLK_H3_BUS_MMC2>,
+				 <&ccu CLK_H3_MMC2>,
+				 <&ccu CLK_H3_MMC2_OUTPUT>,
+				 <&ccu CLK_H3_MMC2_SAMPLE>;
 			clock-names = "ahb",
 				      "mmc",
 				      "output",
@@ -218,10 +218,10 @@
 				    "pmu1",
 				    "pmu2",
 				    "pmu3";
-			clocks = <&ccu CLK_USB_PHY0>,
-				 <&ccu CLK_USB_PHY1>,
-				 <&ccu CLK_USB_PHY2>,
-				 <&ccu CLK_USB_PHY3>;
+			clocks = <&ccu CLK_H3_USB_PHY0>,
+				 <&ccu CLK_H3_USB_PHY1>,
+				 <&ccu CLK_H3_USB_PHY2>,
+				 <&ccu CLK_H3_USB_PHY3>;
 			clock-names = "usb0_phy",
 				      "usb1_phy",
 				      "usb2_phy",
@@ -242,7 +242,7 @@
 			compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
 			reg = <0x01c1b000 0x100>;
 			interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>;
+			clocks = <&ccu CLK_H3_BUS_EHCI1>, <&ccu CLK_H3_BUS_OHCI1>;
 			resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
 			phys = <&usbphy 1>;
 			phy-names = "usb";
@@ -253,8 +253,8 @@
 			compatible = "allwinner,sun8i-h3-ohci", "generic-ohci";
 			reg = <0x01c1b400 0x100>;
 			interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>,
-				 <&ccu CLK_USB_OHCI1>;
+			clocks = <&ccu CLK_H3_BUS_EHCI1>, <&ccu CLK_H3_BUS_OHCI1>,
+				 <&ccu CLK_H3_USB_OHCI1>;
 			resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
 			phys = <&usbphy 1>;
 			phy-names = "usb";
@@ -265,7 +265,7 @@
 			compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
 			reg = <0x01c1c000 0x100>;
 			interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>;
+			clocks = <&ccu CLK_H3_BUS_EHCI2>, <&ccu CLK_H3_BUS_OHCI2>;
 			resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
 			phys = <&usbphy 2>;
 			phy-names = "usb";
@@ -276,8 +276,8 @@
 			compatible = "allwinner,sun8i-h3-ohci", "generic-ohci";
 			reg = <0x01c1c400 0x100>;
 			interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>,
-				 <&ccu CLK_USB_OHCI2>;
+			clocks = <&ccu CLK_H3_BUS_EHCI2>, <&ccu CLK_H3_BUS_OHCI2>,
+				 <&ccu CLK_H3_USB_OHCI2>;
 			resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
 			phys = <&usbphy 2>;
 			phy-names = "usb";
@@ -288,7 +288,7 @@
 			compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
 			reg = <0x01c1d000 0x100>;
 			interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>;
+			clocks = <&ccu CLK_H3_BUS_EHCI3>, <&ccu CLK_H3_BUS_OHCI3>;
 			resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
 			phys = <&usbphy 3>;
 			phy-names = "usb";
@@ -299,8 +299,8 @@
 			compatible = "allwinner,sun8i-h3-ohci", "generic-ohci";
 			reg = <0x01c1d400 0x100>;
 			interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>,
-				 <&ccu CLK_USB_OHCI3>;
+			clocks = <&ccu CLK_H3_BUS_EHCI3>, <&ccu CLK_H3_BUS_OHCI3>,
+				 <&ccu CLK_H3_USB_OHCI3>;
 			resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
 			phys = <&usbphy 3>;
 			phy-names = "usb";
@@ -321,7 +321,7 @@
 			reg = <0x01c20800 0x400>;
 			interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_PIO>;
+			clocks = <&ccu CLK_H3_BUS_PIO>;
 			gpio-controller;
 			#gpio-cells = <3>;
 			interrupt-controller;
@@ -388,7 +388,7 @@
 			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&ccu CLK_BUS_UART0>;
+			clocks = <&ccu CLK_H3_BUS_UART0>;
 			resets = <&ccu RST_BUS_UART0>;
 			dmas = <&dma 6>, <&dma 6>;
 			dma-names = "rx", "tx";
@@ -401,7 +401,7 @@
 			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&ccu CLK_BUS_UART1>;
+			clocks = <&ccu CLK_H3_BUS_UART1>;
 			resets = <&ccu RST_BUS_UART1>;
 			dmas = <&dma 7>, <&dma 7>;
 			dma-names = "rx", "tx";
@@ -414,7 +414,7 @@
 			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&ccu CLK_BUS_UART2>;
+			clocks = <&ccu CLK_H3_BUS_UART2>;
 			resets = <&ccu RST_BUS_UART2>;
 			dmas = <&dma 8>, <&dma 8>;
 			dma-names = "rx", "tx";
@@ -427,7 +427,7 @@
 			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&ccu CLK_BUS_UART3>;
+			clocks = <&ccu CLK_H3_BUS_UART3>;
 			resets = <&ccu RST_BUS_UART3>;
 			dmas = <&dma 9>, <&dma 9>;
 			dma-names = "rx", "tx";
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +116 -116

239 lines not on this page · raw message

drivers/clk/sunxi-ng/ccu-sun8i-h3.h +22 -22

65 lines not on this page · raw message

include/dt-bindings/clock/sun8i-h3-ccu.h +94 -94

197 lines not on this page · raw message

Signature · 1 line
2.9.2
#9 lore raw

PATCH 8/13 clk: sunxi-ng: Add A64 clocks

In reply to Maxime Ripard

Add the A64 CCU clocks set.

---
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 +++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 483 +++++++++++++++++++++
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 ++++++
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++++
 7 files changed, 793 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
Documentation/devicetree/bindings/clock/sunxi-ccu.txt +1 -0
index cb91507ffb1e..1502fc6a4aae 100644
@@ -4,6 +4,7 @@ Allwinner Clock Control Unit Binding
 Required properties :
 - compatible: must contain one of the following compatible:
 		- "allwinner,sun8i-h3-ccu"
+		- "allwinner,sun50i-a64-ccu"
 
 - reg: Must contain the registers base address and length
 - clocks: phandle to the oscillators feeding the CCU. Two are needed:
drivers/clk/sunxi-ng/Kconfig +11 -2
index 2afcbd39e41e..81419f63730f 100644
@@ -51,8 +51,8 @@ config SUNXI_CCU_MP
 
 # SoC Drivers
 
-config SUN8I_H3_CCU
-	bool "Support for the Allwinner H3 CCU"
+config SUNXI_H3_A64_CCU_SUPPORT
+	bool
 	select SUNXI_CCU_DIV
 	select SUNXI_CCU_NK
 	select SUNXI_CCU_NKM
@@ -60,6 +60,15 @@ config SUN8I_H3_CCU
 	select SUNXI_CCU_NM
 	select SUNXI_CCU_MP
 	select SUNXI_CCU_PHASE
+
+config SUN8I_H3_CCU
+	bool "Support for the Allwinner H3 CCU"
+	select SUNXI_H3_A64_CCU_SUPPORT
 	default MACH_SUN8I
 
+config SUN50I_A64_CCU
+	bool "Support for the Allwinner A64 CCU"
+	select SUNXI_H3_A64_CCU_SUPPORT
+	default ARM64 && ARCH_SUNXI
+
 endif
drivers/clk/sunxi-ng/Makefile +1 -1
index 633ce642ffae..d46c460a2cd9 100644
@@ -17,4 +17,4 @@ obj-$(CONFIG_SUNXI_CCU_NM)	+= ccu_nm.o
 obj-$(CONFIG_SUNXI_CCU_MP)	+= ccu_mp.o
 
 # SoC support
-obj-$(CONFIG_SUN8I_H3_CCU)	+= ccu-sun8i-h3.o
+obj-$(CONFIG_SUNXI_H3_A64_CCU_SUPPORT)	+= ccu-sun8i-h3.o
drivers/clk/sunxi-ng/ccu-sun50i-a64.h new file +68 -0

68 lines not on this page · raw message

drivers/clk/sunxi-ng/ccu-sun8i-h3.c +483 -0

621 lines not on this page · raw message

include/dt-bindings/clock/sun50i-a64-ccu.h new file +132 -0

132 lines not on this page · raw message

include/dt-bindings/reset/sun50i-a64-ccu.h new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.9.2
maintainer Acked-by on v1 8/13
#10 lore raw

Re: [PATCH 08/13] clk: sunxi-ng: Add A64 clocks

Quoted 5 lines · Maxime Ripard

Add the A64 CCU clocks set.

---
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
Quoted 10 lines
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 +++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 483 +++++++++++++++++++++
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 ++++++
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++++
 7 files changed, 793 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
#11 lore raw

PATCH 9/13 arm64: sunxi: Kconfig: add essential pinctrl driver

In reply to Maxime Ripard

From: Andre Przywara <[email protected]>

The pinctrl driver is essential for the Allwinner SoCs to work. Add the driver's config symbol to the Kconfig entry to always compile it in. We can't use the arm approach to make the _driver's_ Kconfig symbol def_bool, because we lack the MACH_* symbols in arm64.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index 7ef1d05859ae..4cc444c3c2e9 100644
@@ -3,6 +3,7 @@ menu "Platform selection"
 config ARCH_SUNXI
 	bool "Allwinner sunxi 64-bit SoC Family"
 	select GENERIC_IRQ_CHIP
+	select PINCTRL_SUN50I_A64
 	help
 	  This enables support for Allwinner sunxi based SoCs like the A64.
 
Signature · 1 line
2.9.2
#12 lore raw

PATCH 10/13 arm64: Kconfig: sunxi: add PINCTRL

In reply to Maxime Ripard

From: Andre Przywara <[email protected]>

Add required PINCTRL symbol to cover non-defconfig setups.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index 4cc444c3c2e9..83bc4bf3513b 100644
@@ -3,6 +3,7 @@ menu "Platform selection"
 config ARCH_SUNXI
 	bool "Allwinner sunxi 64-bit SoC Family"
 	select GENERIC_IRQ_CHIP
+	select PINCTRL
 	select PINCTRL_SUN50I_A64
 	help
 	  This enables support for Allwinner sunxi based SoCs like the A64.
Signature · 1 line
2.9.2
#13 lore raw

PATCH 11/13 Documentation: devicetree: add vendor prefix for Pine64

In reply to Maxime Ripard

From: Andre Przywara <[email protected]>

[Maxime: Change title prefix to match the usual style]
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index a7440bcd67ff..f25502b28b55 100644
@@ -198,6 +198,7 @@ parade	Parade Technologies Inc.
 pericom	Pericom Technology Inc.
 phytec	PHYTEC Messtechnik GmbH
 picochip	Picochip Ltd
+pine64	Pine64
 plathome	Plat'Home Co., Ltd.
 plda	PLDA
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
Signature · 1 line
2.9.2
#14 lore raw

PATCH 12/13 arm64: dts: add Allwinner A64 SoC .dtsi

In reply to Maxime Ripard

From: Andre Przywara <[email protected]>

The Allwinner A64 SoC is a low-cost chip with 4 ARM Cortex-A53 cores and the typical tablet / TV box peripherals.
The SoC is based on the (32-bit) Allwinner H3 chip, sharing most of the peripherals and the memory map.
Although the cores are proper 64-bit ones, the whole SoC is actually limited to 4GB (including all the supported DRAM), so we use 32-bit address and size cells. This has the nice feature of us being able to reuse the DT for 32-bit kernels as well.
This .dtsi lists the hardware that we support so far.

[Maxime: Convert to CCU binding, drop the MMC support for now]
---
 Documentation/devicetree/bindings/arm/sunxi.txt |   1 +
 MAINTAINERS                                     |   1 +
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi   | 273 ++++++++++++++++++++++++
 3 files changed, 275 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
Documentation/devicetree/bindings/arm/sunxi.txt +1 -0
index 7e79fcc36b0d..7e59d8ba86af 100644
@@ -14,3 +14,4 @@ using one of the following compatible strings:
   allwinner,sun8i-a83t
   allwinner,sun8i-h3
   allwinner,sun9i-a80
+  allwinner,sun50i-a64
MAINTAINERS +1 -0
index 7304d2e37a98..440490126bfb 100644
@@ -955,6 +955,7 @@ M:	Chen-Yu Tsai <[email protected]>
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
 N:	sun[x456789]i
+F:	arch/arm64/boot/dts/allwinner/
 
 ARM/Allwinner SoC Clock Support
 M:	Emilio L?pez <[email protected]>
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +273 -0

273 lines not on this page · raw message

Signature · 1 line
2.9.2
#15 lore raw

Re: [PATCH 12/13] arm64: dts: add Allwinner A64 SoC .dtsi

Hi Maxime,

Quoted 143 lines · Maxime Ripard

From: Andre Przywara <[email protected]>

The Allwinner A64 SoC is a low-cost chip with 4 ARM Cortex-A53 cores and the typical tablet / TV box peripherals.
The SoC is based on the (32-bit) Allwinner H3 chip, sharing most of the peripherals and the memory map.
Although the cores are proper 64-bit ones, the whole SoC is actually limited to 4GB (including all the supported DRAM), so we use 32-bit address and size cells. This has the nice feature of us being able to reuse the DT for 32-bit kernels as well.
This .dtsi lists the hardware that we support so far.

[Maxime: Convert to CCU binding, drop the MMC support for now]
---
 Documentation/devicetree/bindings/arm/sunxi.txt |   1 +
 MAINTAINERS                                     |   1 +
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi   | 273 ++++++++++++++++++++++++
 3 files changed, 275 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
Documentation/devicetree/bindings/arm/sunxi.txt +1 -0
index 7e79fcc36b0d..7e59d8ba86af 100644
@@ -14,3 +14,4 @@ using one of the following compatible strings:
   allwinner,sun8i-a83t
   allwinner,sun8i-h3
   allwinner,sun9i-a80
+  allwinner,sun50i-a64
MAINTAINERS +1 -0
index 7304d2e37a98..440490126bfb 100644
@@ -955,6 +955,7 @@ M:	Chen-Yu Tsai <[email protected]>
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
 N:	sun[x456789]i
+F:	arch/arm64/boot/dts/allwinner/
 
 ARM/Allwinner SoC Clock Support
 M:	Emilio L?pez <[email protected]>
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +93 -0
new file mode 100644
index 000000000000..636165d75373
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2016 ARM Ltd.
+ * based on the Allwinner H3 dtsi:
+ *    Copyright (C) 2015 Jens Kuske <[email protected]>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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 file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <dt-bindings/clock/sun50i-a64-ccu.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/pinctrl/sun4i-a10.h>
+#include <dt-bindings/reset/sun50i-a64-ccu.h>
+
+/ {
+	interrupt-parent = <&gic>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu at 0 {
+			compatible = "arm,cortex-a53", "arm,armv8";
+			device_type = "cpu";
+			reg = <0>;
+			enable-method = "psci";
+		};
+
+		cpu at 1 {
+			compatible = "arm,cortex-a53", "arm,armv8";
+			device_type = "cpu";
+			reg = <1>;
+			enable-method = "psci";
+		};
+
+		cpu at 2 {
+			compatible = "arm,cortex-a53", "arm,armv8";
+			device_type = "cpu";
+			reg = <2>;
+			enable-method = "psci";
+		};
+
+		cpu at 3 {
+			compatible = "arm,cortex-a53", "arm,armv8";
+			device_type = "cpu";
+			reg = <3>;
+			enable-method = "psci";
+		};
+	};
+
+	psci {
+		compatible = "arm,psci-0.2";
+		method = "smc";
+	};
+
+	timer {

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 103

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +10 -0
+		compatible = "arm,armv8-timer";
+		interrupts = <GIC_PPI 13
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 14
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 11
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 10
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+	};

Can you add a PMU node here? Or shall I send a patch on top of it? It would be:

	pmu {
        	compatible = "arm,cortex-a53-pmu", "arm,armv8-pmuv3";
		interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,	
			     <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-affinity = <&cpu0>,
				     <&cpu1>,
				     <&cpu2>,
				     <&cpu3>;
	};

This enables perf to use hardware counters (for cycles and instructions, for instance).

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +10 -0
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		osc24M: osc24M_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <24000000>;

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 123

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +10 -0
+			clock-output-names = "osc24M";
+		};
+
+		osc32k: osc32k_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <32768>;
+			clock-output-names = "osc32k";
+		};
+	};

Can you remove this "clocks" node and put the two subnodes directly onto the top level?
I know that putting clocks into a subnode is quite wide spread, but it does not represent any hardware hierarchy, especially in this fixed-clock case.
So if we can (and it is easy here!) we should avoid any clocks subnode.

(Yes, I know that this was in my original DT as well, but Mark Rutland convinced me of this.)

Cheers,
Andre.

Quoted 151 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +150 -0
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		ccu: clock at 01c20000 {
+			compatible = "allwinner,sun50i-a64-ccu";
+			reg = <0x01c20000 0x400>;
+			clocks = <&osc24M>, <&osc32k>;
+			clock-names = "hosc", "losc";
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+		};
+
+		pio: pinctrl at 1c20800 {
+			compatible = "allwinner,sun50i-a64-pinctrl";
+			reg = <0x01c20800 0x400>;
+			interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_A64_BUS_PIO>;
+			gpio-controller;
+			#gpio-cells = <3>;
+			interrupt-controller;
+			#interrupt-cells = <2>;
+
+			i2c1_pins: i2c1_pins {
+				allwinner,pins = "PH2", "PH3";
+				allwinner,function = "i2c1";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
+			uart0_pins_a: uart0 at 0 {
+				allwinner,pins = "PB8", "PB9";
+				allwinner,function = "uart0";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+		};
+
+		uart0: serial at 1c28000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28000 0x400>;
+			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&ccu CLK_A64_BUS_UART0>;
+			resets = <&ccu RST_A64_BUS_UART0>;
+			status = "disabled";
+		};
+
+		uart1: serial at 1c28400 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28400 0x400>;
+			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&ccu CLK_A64_BUS_UART1>;
+			resets = <&ccu RST_A64_BUS_UART1>;
+			status = "disabled";
+		};
+
+		uart2: serial at 1c28800 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28800 0x400>;
+			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&ccu CLK_A64_BUS_UART2>;
+			resets = <&ccu RST_A64_BUS_UART2>;
+			status = "disabled";
+		};
+
+		uart3: serial at 1c28c00 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28c00 0x400>;
+			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&ccu CLK_A64_BUS_UART3>;
+			resets = <&ccu RST_A64_BUS_UART3>;
+			status = "disabled";
+		};
+
+		uart4: serial at 1c29000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c29000 0x400>;
+			interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&ccu CLK_A64_BUS_UART4>;
+			resets = <&ccu RST_A64_BUS_UART4>;
+			status = "disabled";
+		};
+
+		rtc: rtc at 1f00000 {
+			compatible = "allwinner,sun6i-a31-rtc";
+			reg = <0x01f00000 0x54>;
+			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		i2c0: i2c at 1c2ac00 {
+			compatible = "allwinner,sun6i-a31-i2c";
+			reg = <0x01c2ac00 0x400>;
+			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_A64_BUS_I2C0>;
+			resets = <&ccu RST_A64_BUS_I2C0>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		i2c1: i2c at 1c2b000 {
+			compatible = "allwinner,sun6i-a31-i2c";
+			reg = <0x01c2b000 0x400>;
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_A64_BUS_I2C1>;
+			resets = <&ccu RST_A64_BUS_I2C1>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		i2c2: i2c at 1c2b400 {
+			compatible = "allwinner,sun6i-a31-i2c";
+			reg = <0x01c2b400 0x400>;
+			interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_A64_BUS_I2C2>;
+			resets = <&ccu RST_A64_BUS_I2C2>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		gic: interrupt-controller at 1c81000 {
+			compatible = "arm,gic-400";
+			reg = <0x01c81000 0x1000>,
+			      <0x01c82000 0x2000>,
+			      <0x01c84000 0x2000>,
+			      <0x01c86000 0x2000>;
+			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+			interrupt-controller;
+			#interrupt-cells = <3>;
+		};
+	};
+};
#16 lore raw

Re: [PATCH 12/13] arm64: dts: add Allwinner A64 SoC .dtsi

Hi,

Quoted 58 lines · Andre Przywara

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 103

Quoted 11 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +11 -0
+	timer {
+		compatible = "arm,armv8-timer";
+		interrupts = <GIC_PPI 13
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 14
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 11
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 10
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+	};

Can you add a PMU node here? Or shall I send a patch on top of it? It would be:

	pmu {
        	compatible = "arm,cortex-a53-pmu", "arm,armv8-pmuv3";
		interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,	
			     <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-affinity = <&cpu0>,
				     <&cpu1>,
				     <&cpu2>,
				     <&cpu3>;
	};

This enables perf to use hardware counters (for cycles and instructions, for instance).

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +10 -0
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		osc24M: osc24M_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <24000000>;

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 123

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi new file +10 -0
+			clock-output-names = "osc24M";
+		};
+
+		osc32k: osc32k_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <32768>;
+			clock-output-names = "osc32k";
+		};
+	};

Can you remove this "clocks" node and put the two subnodes directly onto the top level?
I know that putting clocks into a subnode is quite wide spread, but it does not represent any hardware hierarchy, especially in this fixed-clock case.
So if we can (and it is easy here!) we should avoid any clocks subnode.

Quoted 2 lines

(Yes, I know that this was in my original DT as well, but Mark Rutland convinced me of this.)

I'll do those changes before sending the new version.

Maxime

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

PATCH 13/13 arm64: dts: add Pine64 support

In reply to Maxime Ripard

From: Andre Przywara <[email protected]>

The Pine64 is a cost-efficient development board based on the Allwinner A64 SoC.
There are three models: the basic version with Fast Ethernet and 512 MB of DRAM (Pine64) and two Pine64+ versions, which both feature Gigabit Ethernet and additional connectors for touchscreens and a camera. Or as my son put it: "Those are smaller and these are missing." ;-)
The two Pine64+ models just differ in the amount of DRAM (1GB vs. 2GB). Since U-Boot will figure out the right size for us and patches the DT accordingly we just need to provide one DT for the Pine64+.

[Maxime: Removed the common DTSI and include directly the pine64 DTS]
---
 arch/arm64/boot/dts/Makefile                       |  1 +
 arch/arm64/boot/dts/allwinner/Makefile             |  5 ++
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  | 50 ++++++++++++++++
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 70 ++++++++++++++++++++++
 4 files changed, 126 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
arch/arm64/boot/dts/Makefile +1 -0
index 6e199c903676..ddcbf5a2c17e 100644
@@ -1,4 +1,5 @@
 dts-dirs += al
+dts-dirs += allwinner
 dts-dirs += altera
 dts-dirs += amd
 dts-dirs += amlogic
arch/arm64/boot/dts/allwinner/Makefile new file +5 -0
new file mode 100644
index 000000000000..1e29a5ae8282
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pine64-plus.dtb sun50i-a64-pine64.dtb
+
+always		:= $(dtb-y)
+subdir-y	:= $(dts-dirs)
+clean-files	:= *.dtb
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts new file +50 -0

50 lines not on this page · raw message

arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.9.2
#18 lore raw
In reply to Maxime Ripard
Quoted 11 lines · On Tue, 26 Jul 2016 22:30:28 +0200 Maxime Ripard…

ere is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Let me know what you think,

I don't see the interest to have common code for 32bits and 64bits. The clock driver of a SoC will never evolve, so, it is simpler to copy the source common with the H3 into a clean A64 clock driver.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#19 lore raw
Quoted 10 lines · Jean-Francois Moine
Quoted 7 lines · On Tue, 26 Jul 2016 22:30:28 +0200 Maxime Ripard…

ere is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Quoted 8 lines
Quoted 4 lines

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Let me know what you think,

I don't see the interest to have common code for 32bits and 64bits. The clock driver of a SoC will never evolve, so, it is simpler to copy the source common with the H3 into a clean A64 clock driver.

I'm not sure why 32 bits vs 64 bits matters here. We're going to share a significant number of drivers already between armv7 and armv8, like MMC, EMAC, I2C, and so on.

And I expect to share the data in other SoCs for the A10, A13 and A20 for example, or A23/A33, which have a lot of clocks in common too.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160728/0246c7fb/attachment.sig>
#20 lore raw
Quoted 6 lines · On Thu, 28 Jul 2016 22:07:05 +0200 Maxime Ripard…
Quoted 5 lines
Quoted 1 line

Let me know what you think,

I don't see the interest to have common code for 32bits and 64bits. The clock driver of a SoC will never evolve, so, it is simpler to copy the source common with the H3 into a clean A64 clock driver.

Quoted 6 lines

I'm not sure why 32 bits vs 64 bits matters here. We're going to share a significant number of drivers already between armv7 and armv8, like MMC, EMAC, I2C, and so on.

And I expect to share the data in other SoCs for the A10, A13 and A20 for example, or A23/A33, which have a lot of clocks in common too.

The interest of your sunxi-ng approach is that the clocks of each SoC is described in one file. Here you are mixing 2 SoCs in the same source file. The advantage is lost.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#21 lore raw
Quoted 13 lines · Jean-Francois Moine
Quoted 10 lines · On Thu, 28 Jul 2016 22:07:05 +0200 Maxime Ripard…
Quoted 5 lines
Quoted 1 line

Let me know what you think,

I don't see the interest to have common code for 32bits and 64bits. The clock driver of a SoC will never evolve, so, it is simpler to copy the source common with the H3 into a clean A64 clock driver.

I'm not sure why 32 bits vs 64 bits matters here. We're going to share a significant number of drivers already between armv7 and armv8, like MMC, EMAC, I2C, and so on.

Quoted 6 lines
Quoted 2 lines

And I expect to share the data in other SoCs for the A10, A13 and A20 for example, or A23/A33, which have a lot of clocks in common too.

The interest of your sunxi-ng approach is that the clocks of each SoC is described in one file. Here you are mixing 2 SoCs in the same source file. The advantage is lost.

Because (and only because) the huge majority of those clocks are shared between these SoCs.

If it differs in a significant way (like for the A31 that is currently submitted), there's of course no reason to merge it in the same file.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160731/2bf59356/attachment.sig>
#22 lore raw
In reply to Maxime Ripard

Hi Maxime,

Quoted 11 lines · Maxime Ripard

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Thanks very much for looking into this and compiling this series!

In general this looks good to me - apart from the sunxi-ng clock usage. I think I have some small fixes to the DT (have to compare against my latest local branch), I will comment on this later.

As I think I never officially expressed my concerns about the new sunxi clock system, so I use that opportunity here ;-)

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Now the long part ....

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.
- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.
- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.
- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.
- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.
- Having SCPI gives us simple regulators and sensors (temperature, power) for free (in terms of no Linux code required). It also allows for DVFS support, though this may require more work on the firmware side.
- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

So I managed to finish a first prototype this weekend.
SCPI requires a mailbox and a shared memory region to work. The latter is trivial, but we are lacking a proper mailbox driver for sunxi. Besides that the Allwinner mailbox only works between the arisc and the ARM cores, not between ARM cores or within one core in different exception levels. So signalling a mailbox in EL1 and taking the IRQ in EL3 does not work.
As a quick solution I implemented a synchronous "smc" mailbox, which uses the ARM smc instruction to transfer control into firmware. Firmware then reads the payload from the shared memory region, handles the request and returns to EL1. We then advertise this mailbox in the SCPI DT node, and the rest of the SCPI framework can happily work with that. I described the clocks as mentioned above and put the MMC clocks under SCPI control.
I put a draft DT here [2] to illustrate my ideas.

I know this is quite controversial, so what about these following steps:

- I polish my existing patches and send a prototype this week. We can then discuss the merits and drawbacks of this approach based on the code.
- It it turns out that sunxi-ng is the way to go, I will test and comment on this series.
- If we are not sure yet, we can try to go with an almost clock-less DT for now (drop I2C and make UART0 use osc24M directly, for a start). This would leave the door open for either approach. Or we use the simple-gates only for now.

I am happy to discuss this here on the list.

Cheers,
Andre

[1]
http://infocenter.arm.com/help/topic/com.arm.doc.dui0922g/scp_message_interface_v1_2_DUI0922G_en.pdf
[2] https://gist.github.com/apritzel/faa3dc5cbe7591be8c55a439f725578e

Quoted 55 lines

Let me know what you think,
Maxime

1: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/410338.html

Andre Przywara (5):
arm64: sunxi: Kconfig: add essential pinctrl driver
arm64: Kconfig: sunxi: add PINCTRL
Documentation: devicetree: add vendor prefix for Pine64
arm64: dts: add Allwinner A64 SoC .dtsi
arm64: dts: add Pine64 support

Maxime Ripard (8):
clk: sunxi-ng: mux: Rename mux macro to be consistent
clk: sunxi-ng: mux: Add mux table support
clk: sunxi-ng: sun8i: Rename DDR and video plls
clk: sunxi-ng: sun8i: Fix register offset
clk: sunxi-ng: sun8i: Rename H3 only clocks
clk: sunxi-ng: sun8i: Move fixed factors around
clk: sunxi-ng: sun8i: Prefix clock defines by SoC Name
clk: sunxi-ng: Add A64 clocks

 Documentation/devicetree/bindings/arm/sunxi.txt    |   1 +
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  62 +-
 arch/arm64/Kconfig.platforms                       |   2 +
 arch/arm64/boot/dts/Makefile                       |   1 +
 arch/arm64/boot/dts/allwinner/Makefile             |   5 +
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  50 ++
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  70 ++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      | 273 +++++++
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 ++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 896 ++++++++++++++++-----
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h                |  44 +-
 drivers/clk/sunxi-ng/ccu_div.h                     |   2 +-
 drivers/clk/sunxi-ng/ccu_mp.h                      |   2 +-
 drivers/clk/sunxi-ng/ccu_mux.c                     |  14 +
 drivers/clk/sunxi-ng/ccu_mux.h                     |  29 +-
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 +++
 include/dt-bindings/clock/sun8i-h3-ccu.h           | 188 ++---
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++
 23 files changed, 1588 insertions(+), 366 deletions(-)
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
#23 lore raw
Quoted 10 lines · On Mon, 1 Aug 2016 02:43:06 +0100 Andr? Przywara <[email protected]> wrote:

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Hi Andr?,

This looks interesting.
As I understand, the clock enable/rate setting functions would be in the arisc. The arisc firmware would be loaded only once in the Soc and would contain the code for handling this specific SoC.

Quoted 1 line

From my calculations, this would save about 1Mb of clock descriptions

in the kernel for a universal Allwinner kernel.

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#24 lore raw
Quoted 23 lines · Jean-Francois Moine
Quoted 10 lines · On Mon, 1 Aug 2016 02:43:06 +0100 Andr? Przywara <[email protected]> wrote:

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Hi Andr?,

This looks interesting.
As I understand, the clock enable/rate setting functions would be in the arisc. The arisc firmware would be loaded only once in the Soc and would contain the code for handling this specific SoC.
From my calculations, this would save about 1Mb of clock descriptions in the kernel for a universal Allwinner kernel.

Quoted 3 lines

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

For peripherals that have a separate mod clock, having them separate is a good thing. One example might be the audio codecs. You could ungate the bus gate to access its registers to program it, but only enable the mod clock when you actually play something.

Regards
ChenYu

#25 lore raw
Quoted 8 lines · On Mon, 1 Aug 2016 17:13:34 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 3 lines

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

For peripherals that have a separate mod clock, having them separate is a good thing. One example might be the audio codecs. You could ungate the bus gate to access its registers to program it, but only enable the mod clock when you actually play something.

The roles of the bus gate and the clock gate are the same. I don't see any reason to set one gate without setting the other one. More, the spec says what the bus gate must be enabled before the clock gate (and reverse order while disabling). So, setting both gates in one function call seems safer.

Then, if you want to save some power while not playing anything, just do clk_disable() of the (main and only) i2s clock.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#26 lore raw
Quoted 12 lines · Jean-Francois Moine
Quoted 8 lines · On Mon, 1 Aug 2016 17:13:34 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 3 lines

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

For peripherals that have a separate mod clock, having them separate is a good thing. One example might be the audio codecs. You could ungate the bus gate to access its registers to program it, but only enable the mod clock when you actually play something.

Quoted 5 lines

The roles of the bus gate and the clock gate are the same. I don't see any reason to set one gate without setting the other one. More, the spec says what the bus gate must be enabled before the clock gate (and reverse order while disabling). So, setting both gates in one function call seems safer.

Wha? Aren't bus gates and clock gates the same thing in this context?

ChenYu

Quoted 6 lines

Then, if you want to save some power while not playing anything, just do clk_disable() of the (main and only) i2s clock.

--
Ken ar c'henta? | ** Breizh ha Linux atav! **
Jef | http://moinejf.free.fr/

#27 lore raw
Quoted 13 lines · On Mon, 1 Aug 2016 20:01:49 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 12 lines · Jean-Francois Moine
Quoted 8 lines · On Mon, 1 Aug 2016 17:13:34 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 3 lines

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

For peripherals that have a separate mod clock, having them separate is a good thing. One example might be the audio codecs. You could ungate the bus gate to access its registers to program it, but only enable the mod clock when you actually play something.

Quoted 7 lines
Quoted 5 lines

The roles of the bus gate and the clock gate are the same. I don't see any reason to set one gate without setting the other one. More, the spec says what the bus gate must be enabled before the clock gate (and reverse order while disabling). So, setting both gates in one function call seems safer.

Wha? Aren't bus gates and clock gates the same thing in this context?

Yes. What is the problem?

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#28 lore raw
In reply to Jean-Francois Moine

Hi Jean-Francois,

Quoted 14 lines · Jean-Francois Moine
Quoted 10 lines · On Mon, 1 Aug 2016 02:43:06 +0100 André Przywara <[email protected]> wrote:

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Quoted 8 lines

Hi André,

This looks interesting.
As I understand, the clock enable/rate setting functions would be in the arisc. The arisc firmware would be loaded only once in the Soc and would contain the code for handling this specific SoC.
From my calculations, this would save about 1Mb of clock descriptions in the kernel for a universal Allwinner kernel.

This is the rough idea, yes. In the moment the clock code sits in the ARM Trusted Firmware part, but in fact this is an implementation detail. Theoretically we could also move that clock code to U-Boot on 32-bit SoCs to sit next to the PSCI implementation, which uses the same smc call mechanism as I do in this first implementation.
But unfortunately we cannot remove the existing code from the kernel, since that would break all existing users (unless they upgrade their firmware). So I am not sure if supporting older SoCs with this mechanism is worthwhile.

But: yes, I want to avoid adding tedious clock descriptions for each and every new SoC to the kernel. What really worries me is that sunxi-ng makes this situation probably worse, as we now have to add SoC specific "code" (in fact: clock descriptions) for every SoC, even if that chip doesn't introduce any new clock type.

Quoted 3 lines

But I don't see why you are keeping the simple-gates. The bus gate may be ungated/gated when the clock is enabled/disabled, and that's what Allwinner's software does.

We could do. But SCPI does not have an explicit enable/disable interface, it only describes that setting the frequency to 0 disables the clock. For enabling it one would have to set some frequency (!= 0), which the firmware could then translate into a "set that bit in the gate register" for any gate-only clock, which sounds rather hackish to me. Also it would require to alter the SCPI clock driver to implement the enable/disable ops, since I think we never call set_rate for those clocks.

So having the quite straight forward "simple-gates" driver around seems more sane. In the end this driver just translates "clock number x" into "bit number x" in that register, which is very generic. That's why I urged to introduce a fallback compatible name to express this very feature.

Cheers,
Andre.

#29 lore raw

cover arm64: Allwinner A64 support based on sunxi-ng

Hi Andre,

01.08.2016, 18:48, "Andre Przywara" <[email protected]>:

Quoted 54 lines

Hi Jean-Francois,

Quoted 14 lines · Jean-Francois Moine

?On Mon, 1 Aug 2016 02:43:06 +0100

Quoted 10 lines · ?Andr? Przywara

?As this became quite a long read, here a TL;DR:
?- We consider using an SCPI based clock system for the A64, alongside ?allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner ?specific clocks (apart from the simple-gates).
?- ARM Trusted Firmware provides the SCPI implementation - for now, later ?we may move this into a possible arisc firmware.
?- We upstream some basic DT first, possibly omitting any controversial ?clock parts at all.

?Let me know what you think!

Quoted 8 lines

?Hi Andr?,

?This looks interesting.
?As I understand, the clock enable/rate setting functions would be in ?the arisc. The arisc firmware would be loaded only once in the Soc and ?would contain the code for handling this specific SoC. ?From my calculations, this would save about 1Mb of clock descriptions ?in the kernel for a universal Allwinner kernel.

This is the rough idea, yes. In the moment the clock code sits in the ARM Trusted Firmware part, but in fact this is an implementation detail. Theoretically we could also move that clock code to U-Boot on 32-bit SoCs to sit next to the PSCI implementation, which uses the same smc call mechanism as I do in this first implementation.
But unfortunately we cannot remove the existing code from the kernel, since that would break all existing users (unless they upgrade their firmware). So I am not sure if supporting older SoCs with this mechanism is worthwhile.

But: yes, I want to avoid adding tedious clock descriptions for each and every new SoC to the kernel. What really worries me is that sunxi-ng makes this situation probably worse, as we now have to add SoC specific "code" (in fact: clock descriptions) for every SoC, even if that chip doesn't introduce any new clock type.

Quoted 3 lines

?But I don't see why you are keeping the simple-gates. The bus gate may ?be ungated/gated when the clock is enabled/disabled, and that's what ?Allwinner's software does.

We could do. But SCPI does not have an explicit enable/disable interface, it only describes that setting the frequency to 0 disables the clock. For enabling it one would have to set some frequency (!= 0), which the firmware could then translate into a "set that bit in the gate register" for any gate-only clock, which sounds rather hackish to me. Also it would require to alter the SCPI clock driver to implement the enable/disable ops, since I think we never call set_rate for those clocks.

Quoted 8 lines

So having the quite straight forward "simple-gates" driver around seems more sane. In the end this driver just translates "clock number x" into "bit number x" in that register, which is very generic. That's why I urged to introduce a fallback compatible name to express this very feature.

Cheers,
Andre.

It may be unpolite to say that, but I just want a working A64 mainline kernel at first. I'm trying to submit the drivers of the changed IP blocks now, but it's a pity that I cannot submit the DT patches now.
clock-ng is at least now a usable solution.
Or can you work out such a firmware-based clock driver as soon as possible?

I'm expecting your SCPI-based driver!
(ARM is now such a mess that it really needs a standard.)

Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#30 lore raw
In reply to André Przywara

Hi,

Quoted 38 lines · Andr? Przywara

Hi Maxime,

Quoted 11 lines · Maxime Ripard

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Thanks very much for looking into this and compiling this series!

In general this looks good to me - apart from the sunxi-ng clock usage. I think I have some small fixes to the DT (have to compare against my latest local branch), I will comment on this later.

As I think I never officially expressed my concerns about the new sunxi clock system, so I use that opportunity here ;-)

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Now the long part ....

Quoted 11 lines

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.

I'm guessing this was nacked by device tree maintainers and/or clk maintainers. A recent thread adding display timings in DT to the simple-panel binding is a similar example.

Quoted 5 lines

- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

Quoted 7 lines

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.

True. These are set by the bootloader because it uses them.

If you're concerned about the clock rate changing, you can always have the clocks set to read only, i.e. clock rates cannot be changed.

Quoted 7 lines

- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.

My understanding is that because they _are_ different, they are defined by different compatible strings. The fact that we can have a simple clk driver supporting all of them, using the clk-indices property to get the bit offsets, is beside the point.

clk-indices is used for clk name lookup through DT, when the phandle index is not the same as the one used for clk-output-names. We are slightly abusing it to get the bit offsets. It is entirely possible to do a clk binding without them. You would then have that information in the driver.

Quoted 6 lines

- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

Can it also propagate clock rate changes and reparenting such that we do not need to describe clock relationships in the kernel? If not then we still need some kind of description somewhere. And the clk maintainers don't seem too fond of 1 clk per node designs, which would allow you to describe it in the DT.

We will run into this when we do audio and video. The module clocks may or may not have dividers or multiple parents. But in some cases you have to change the PLL clock rate, which in turn changes the clock rate of all the clocks under it. An example would be playing 44.1 KHz audio through the internal codec, which requires a different PLL clock rate than playing 48 KHz audio. But if at the same time you're also using I2S at 44.1 KHz or some multiple, you would want to know the clock rate is about to change, and maybe block the change.

Can SCPI notify the kernel about these changes? If not you'd have some logic in the kernel. Splitting the logic here IMHO is not a good design.

Quoted 12 lines

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.
- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.

Upgrading firmware is still upgrading something... I'm not sure how it's better.

Quoted 3 lines

- Having SCPI gives us simple regulators and sensors (temperature, power) for free (in terms of no Linux code required). It also allows for DVFS support, though this may require more work on the firmware side.

Are you arguing to move PMIC support into SCPI firmware?

Quoted 2 lines

- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

A quick grep through linux-next shows only the Juno platform using "arm,scpi-clocks". Some other consumer oriented vendors, such as mediatek, nvidia, qualcomm, renesas and rockchip have monolithic clock nodes.

Quoted 6 lines

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

Not really. You still have to write the firmware for the new SoCs, unless you expect Allwinner to adopt our design. And getting the new firmware to work with the existing bootloader (if upstream support isn't done yet) may be tricky, as you already went through for the A64.

Quoted 19 lines

So I managed to finish a first prototype this weekend.
SCPI requires a mailbox and a shared memory region to work. The latter is trivial, but we are lacking a proper mailbox driver for sunxi. Besides that the Allwinner mailbox only works between the arisc and the ARM cores, not between ARM cores or within one core in different exception levels. So signalling a mailbox in EL1 and taking the IRQ in EL3 does not work.
As a quick solution I implemented a synchronous "smc" mailbox, which uses the ARM smc instruction to transfer control into firmware. Firmware then reads the payload from the shared memory region, handles the request and returns to EL1. We then advertise this mailbox in the SCPI DT node, and the rest of the SCPI framework can happily work with that. I described the clocks as mentioned above and put the MMC clocks under SCPI control.
I put a draft DT here [2] to illustrate my ideas.

I know this is quite controversial, so what about these following steps:

Quoted 8 lines

- I polish my existing patches and send a prototype this week. We can then discuss the merits and drawbacks of this approach based on the code.
- It it turns out that sunxi-ng is the way to go, I will test and comment on this series.
- If we are not sure yet, we can try to go with an almost clock-less DT for now (drop I2C and make UART0 use osc24M directly, for a start). This would leave the door open for either approach. Or we use the simple-gates only for now.

A clock-less system is quite useless. The only things that work are the peripherals tied to apb2, namely uarts and i2c busses. And maybe simplefb if you get the display pipeline working in the bootloader. This is where A83T has been for some time. :(

Regards
ChenYu

Quoted 65 lines

I am happy to discuss this here on the list.

Cheers,
Andre

[1]
http://infocenter.arm.com/help/topic/com.arm.doc.dui0922g/scp_message_interface_v1_2_DUI0922G_en.pdf
[2] https://gist.github.com/apritzel/faa3dc5cbe7591be8c55a439f725578e

Quoted 55 lines

Let me know what you think,
Maxime

1: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/410338.html

Andre Przywara (5):
arm64: sunxi: Kconfig: add essential pinctrl driver
arm64: Kconfig: sunxi: add PINCTRL
Documentation: devicetree: add vendor prefix for Pine64
arm64: dts: add Allwinner A64 SoC .dtsi
arm64: dts: add Pine64 support

Maxime Ripard (8):
clk: sunxi-ng: mux: Rename mux macro to be consistent
clk: sunxi-ng: mux: Add mux table support
clk: sunxi-ng: sun8i: Rename DDR and video plls
clk: sunxi-ng: sun8i: Fix register offset
clk: sunxi-ng: sun8i: Rename H3 only clocks
clk: sunxi-ng: sun8i: Move fixed factors around
clk: sunxi-ng: sun8i: Prefix clock defines by SoC Name
clk: sunxi-ng: Add A64 clocks

 Documentation/devicetree/bindings/arm/sunxi.txt    |   1 +
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  62 +-
 arch/arm64/Kconfig.platforms                       |   2 +
 arch/arm64/boot/dts/Makefile                       |   1 +
 arch/arm64/boot/dts/allwinner/Makefile             |   5 +
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  50 ++
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  70 ++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      | 273 +++++++
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 ++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 896 ++++++++++++++++-----
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h                |  44 +-
 drivers/clk/sunxi-ng/ccu_div.h                     |   2 +-
 drivers/clk/sunxi-ng/ccu_mp.h                      |   2 +-
 drivers/clk/sunxi-ng/ccu_mux.c                     |  14 +
 drivers/clk/sunxi-ng/ccu_mux.h                     |  29 +-
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 +++
 include/dt-bindings/clock/sun8i-h3-ccu.h           | 188 ++---
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++
 23 files changed, 1588 insertions(+), 366 deletions(-)
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
#31 lore raw
Quoted 1 line · Chen-Yu Tsai

Hi,

Hi Chen-Yu,

thanks for your comments, just found some time to come back to this.

Quoted 82 lines · Andr? Przywara
Quoted 38 lines

Hi Maxime,

Quoted 11 lines · Maxime Ripard

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Thanks very much for looking into this and compiling this series!

In general this looks good to me - apart from the sunxi-ng clock usage. I think I have some small fixes to the DT (have to compare against my latest local branch), I will comment on this later.

As I think I never officially expressed my concerns about the new sunxi clock system, so I use that opportunity here ;-)

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Now the long part ....

Quoted 11 lines

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.

I'm guessing this was nacked by device tree maintainers and/or clk maintainers. A recent thread adding display timings in DT to the simple-panel binding is a similar example.

Quoted 5 lines

- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

Quoted 7 lines

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.

True. These are set by the bootloader because it uses them.

If you're concerned about the clock rate changing, you can always have the clocks set to read only, i.e. clock rates cannot be changed.

Quoted 7 lines

- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.

Quoted 4 lines

My understanding is that because they _are_ different, they are defined by different compatible strings. The fact that we can have a simple clk driver supporting all of them, using the clk-indices property to get the bit offsets, is beside the point.

Why is that? That's why that property is called "compatible", isn't it? In my understanding a fallback name can be chosen exactly for that
purpose: where an existing driver for a binding is capable of handling the new hardware. Yes, we add our new SoC specific name anyway (mostly to be able to handle future driver fixes without changing all DTs). But for that gates clock case we can do:
1) Add the new name to the bindings doc, mostly to mark it as used.
2) Use compatible="soc-specific", "generic"; in the DT. This is how it nicely works for the USB host controllers, for instance. There would be no pointless "code" change in Linux needed.

Quoted 5 lines

clk-indices is used for clk name lookup through DT, when the phandle index is not the same as the one used for clk-output-names. We are slightly abusing it to get the bit offsets. It is entirely possible to do a clk binding without them. You would then have that information in the driver.

But that's not how it should work. The DT is meant to describe the _hardware_, not the driver, especially not one particular one. And we should avoid changing the DT just because we found that we need to rework the Linux driver.
So having the actual bits used as indices makes a lot of sense to me.
Besides: any changes in the references would be DT internal, right? So changing the clock ID in the bus gates node at the same time as the clock reference in, say the MMC controller, would be quite natural and ideally wouldn't break anything.

Quoted 7 lines
Quoted 6 lines

- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

Quoted 5 lines

Can it also propagate clock rate changes and reparenting such that we do not need to describe clock relationships in the kernel? If not then we still need some kind of description somewhere. And the clk maintainers don't seem too fond of 1 clk per node designs, which would allow you to describe it in the DT.

I don't see how rate changes and re-parenting shouldn't be possible with the new approach. We just do it in firmware, which ideally owns all the clocks. We can have comparably simple code there since firmware is by design SoC specific, so we don't need an overly complicated and abstracted clock framework to cover every clock on the planet. Also we wouldn't need to expose the basic PLL clocks (like PLL_AUDIO) themselves if that proves to be problematic, so we can change them at firmware's discretion.

Quoted 8 lines

We will run into this when we do audio and video. The module clocks may or may not have dividers or multiple parents. But in some cases you have to change the PLL clock rate, which in turn changes the clock rate of all the clocks under it. An example would be playing 44.1 KHz audio through the internal codec, which requires a different PLL clock rate than playing 48 KHz audio. But if at the same time you're also using I2S at 44.1 KHz or some multiple, you would want to know the clock rate is about to change, and maybe block the change.

As mentioned, I don't see a reason why this shouldn't be possible. Again this may be even simpler, since the firmware code is expected to know about the SoC, so we don't need to think about abstracting these relations. We could even code a special case for this I2S/codec setup, if that turns out to be a nasty corner case. Or we find a different static setup from the beginning.

If you still see an issue, can you detail one example where this would clash? I am not a clock export, so eager to learn about those cases.

Quoted 3 lines

Can SCPI notify the kernel about these changes? If not you'd have some logic in the kernel. Splitting the logic here IMHO is not a good design.

Why would the kernel need to know? Those SCPI clocks have no parents known to the kernel, and ideally we don't expose any (PLL) clock that would need to change frequency and would be subject to reparenting.

Again, if you can show me a particular counter-example, I'd be grateful.

Quoted 14 lines
Quoted 13 lines

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.
- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.

Quoted 2 lines

Upgrading firmware is still upgrading something... I'm not sure how it's better.

There is supposed to be _one_ firmware for one SoC (or board), whereas there as dozens of kernels out there - upstream plus various stable kernels, from various distributions.
So in the worst case a fix in the kernel would have to be backported to Debian, Ubuntu 14.04 LTS, Ubuntu 16.04 LTS, Suse, RedHat, you name it. Also rumor has it that there are kernels beside Linux out there ;-)

Quoted 5 lines
Quoted 3 lines

- Having SCPI gives us simple regulators and sensors (temperature, power) for free (in terms of no Linux code required). It also allows for DVFS support, though this may require more work on the firmware side.

Are you arguing to move PMIC support into SCPI firmware?

Yes. We can abstract this _and_ protect the PMIC from a rogue driver or module. Accidentally setting 3.3V to a 2.5V-only Ethernet PHY would be no longer possible, since firmware knows that his board has a 2.5V PHY.

Quoted 7 lines
Quoted 2 lines

- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

A quick grep through linux-next shows only the Juno platform using "arm,scpi-clocks". Some other consumer oriented vendors, such as mediatek, nvidia, qualcomm, renesas and rockchip have monolithic clock nodes.

Yes, SCPI at the moment is more "the Juno interface put into a spec". But I find it quite useful and think we have to start abstracting those. Also "the other guys do it as well" is not really a good argument, and I mentioned that we should look more at the server SoCs than those various "let's replace the A7s with A53s" SoCs.

Quoted 11 lines
Quoted 5 lines

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

Not really. You still have to write the firmware for the new SoCs, unless you expect Allwinner to adopt our design. And getting the new firmware to work with the existing bootloader (if upstream support isn't done yet) may be tricky, as you already went through for the A64.

But frankly "writing" the firmware is more like adapting an existing version, testing and pushing this out. We don't need to go through a lengthy process and don't have to wait for distributions to eventually pick up the upstream kernel with the fixes merged. Look at how much less changes U-Boot needed to run a (32-bit) version on the Pine64: a few define's here and some ifdef's there. Then we would push this to some firmware repository - which would be controlled by linux-sunxi. People pick up the newest firmware from there and run an _existing_ (distribution) kernel on the board: a few weeks after the board hit some developer. This is how x86 works (apart from that community firmware repo) and I don't see why we shouldn't try to reach the same state for arm (or at least arm64).

Cheers,
Andre

Quoted 101 lines
Quoted 18 lines

So I managed to finish a first prototype this weekend.
SCPI requires a mailbox and a shared memory region to work. The latter is trivial, but we are lacking a proper mailbox driver for sunxi. Besides that the Allwinner mailbox only works between the arisc and the ARM cores, not between ARM cores or within one core in different exception levels. So signalling a mailbox in EL1 and taking the IRQ in EL3 does not work.
As a quick solution I implemented a synchronous "smc" mailbox, which uses the ARM smc instruction to transfer control into firmware. Firmware then reads the payload from the shared memory region, handles the request and returns to EL1. We then advertise this mailbox in the SCPI DT node, and the rest of the SCPI framework can happily work with that. I described the clocks as mentioned above and put the MMC clocks under SCPI control.
I put a draft DT here [2] to illustrate my ideas.

I know this is quite controversial, so what about these following steps:

Quoted 8 lines

- I polish my existing patches and send a prototype this week. We can then discuss the merits and drawbacks of this approach based on the code.
- It it turns out that sunxi-ng is the way to go, I will test and comment on this series.
- If we are not sure yet, we can try to go with an almost clock-less DT for now (drop I2C and make UART0 use osc24M directly, for a start). This would leave the door open for either approach. Or we use the simple-gates only for now.

A clock-less system is quite useless. The only things that work are the peripherals tied to apb2, namely uarts and i2c busses. And maybe simplefb if you get the display pipeline working in the bootloader. This is where A83T has been for some time. :(

Regards
ChenYu

Quoted 65 lines

I am happy to discuss this here on the list.

Cheers,
Andre

[1]
http://infocenter.arm.com/help/topic/com.arm.doc.dui0922g/scp_message_interface_v1_2_DUI0922G_en.pdf
[2] https://gist.github.com/apritzel/faa3dc5cbe7591be8c55a439f725578e

Quoted 55 lines

Let me know what you think,
Maxime

1: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/410338.html

Andre Przywara (5):
arm64: sunxi: Kconfig: add essential pinctrl driver
arm64: Kconfig: sunxi: add PINCTRL
Documentation: devicetree: add vendor prefix for Pine64
arm64: dts: add Allwinner A64 SoC .dtsi
arm64: dts: add Pine64 support

Maxime Ripard (8):
clk: sunxi-ng: mux: Rename mux macro to be consistent
clk: sunxi-ng: mux: Add mux table support
clk: sunxi-ng: sun8i: Rename DDR and video plls
clk: sunxi-ng: sun8i: Fix register offset
clk: sunxi-ng: sun8i: Rename H3 only clocks
clk: sunxi-ng: sun8i: Move fixed factors around
clk: sunxi-ng: sun8i: Prefix clock defines by SoC Name
clk: sunxi-ng: Add A64 clocks

 Documentation/devicetree/bindings/arm/sunxi.txt    |   1 +
 .../devicetree/bindings/clock/sunxi-ccu.txt        |   1 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 MAINTAINERS                                        |   1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  62 +-
 arch/arm64/Kconfig.platforms                       |   2 +
 arch/arm64/boot/dts/Makefile                       |   1 +
 arch/arm64/boot/dts/allwinner/Makefile             |   5 +
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  50 ++
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  70 ++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      | 273 +++++++
 drivers/clk/sunxi-ng/Kconfig                       |  13 +-
 drivers/clk/sunxi-ng/Makefile                      |   2 +-
 drivers/clk/sunxi-ng/ccu-sun50i-a64.h              |  68 ++
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c                | 896 ++++++++++++++++-----
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h                |  44 +-
 drivers/clk/sunxi-ng/ccu_div.h                     |   2 +-
 drivers/clk/sunxi-ng/ccu_mp.h                      |   2 +-
 drivers/clk/sunxi-ng/ccu_mux.c                     |  14 +
 drivers/clk/sunxi-ng/ccu_mux.h                     |  29 +-
 include/dt-bindings/clock/sun50i-a64-ccu.h         | 132 +++
 include/dt-bindings/clock/sun8i-h3-ccu.h           | 188 ++---
 include/dt-bindings/reset/sun50i-a64-ccu.h         |  97 +++
 23 files changed, 1588 insertions(+), 366 deletions(-)
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun50i-a64.h
 create mode 100644 include/dt-bindings/clock/sun50i-a64-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-a64-ccu.h
author NAK
#32 lore raw
In reply to André Przywara

Hi Andre,

Quoted 38 lines · Andr? Przywara

Hi Maxime,

Quoted 11 lines · Maxime Ripard

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Thanks very much for looking into this and compiling this series!

In general this looks good to me - apart from the sunxi-ng clock usage. I think I have some small fixes to the DT (have to compare against my latest local branch), I will comment on this later.

As I think I never officially expressed my concerns about the new sunxi clock system, so I use that opportunity here ;-)

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Now the long part ....

Quoted 15 lines

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.
- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

3 - You never get a complete clock support for any SoC, requirining
for pretty much every driver to create from scratch a new clock driver.

4 - You require for all these clocks drivers some Ack from both the DT
and clocks maintainers, who both said they were fed up with this.

5 - If you realise some day down the road that the parenting
relationship is not right, or that some clock is not doing what you thought it was, you can't really fix it properly because of the DT stability you wanted us to enforce.

Quoted 21 lines

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.
- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.
- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

Quoted 3 lines

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.

But you duplicate the clock framework entirely, both the core code and the data you were complaining about, with all the issues that arise from code duplication. You still have to create that big file you were complaining about, with exactly the same constraints.

Quoted 8 lines

- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.

But no-one would actually be able to use it, because no one upgrades its firmware, including all the major distributions (Debian, Ubuntu, Fedora, OpenWRT, Arch, Gento, you name it). So there's effectively no way to fix a bug that was there.

Quoted 3 lines

- Having SCPI gives us simple regulators and sensors (temperature, power) for free (in terms of no Linux code required). It also allows for DVFS support, though this may require more work on the firmware side.

And ignoring all the other features that the PMIC support, and the board uses out there (GPIO, ADCs, Power supplies, battery charger, USB VBUS monitoring)

Quoted 2 lines

- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

$ git grep -l scpi arch/arm64/boot/dts/**.dtsi
arch/arm64/boot/dts/arm/juno-base.dtsi

Are you saying that only Juno is a serious ARM64 machine?

Quoted 5 lines

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

That's not true and you know it.

What you actually suggest is to implement a minimal set of clocks in ATF (the opposite being, the entire set of clocks, which would of course be untested, so it basically falls down in the exact same category).

What this means is that, since we will obviously not support all the clocks client from day one, any user will be *required* for a new kernel release to operate as it's expected to upgrade the ATF.

Without any help from the distribution (s)he's running, because no one has that kind of scenario in mind. And let's be honest, I don't see Ubuntu changing the dependencies for the kernel for the Allwinner SoCs alone (let alone the fact that it's pretty much impossible in a generic way to know where and how the ATF is installed).

Apart from being a major pain for any user, upgrading the bootloader is also a showstopper for most industries.

So, no, we won't do that. The A64 support is something we actually want to use in real-life products, and our users to be happy with the support they have.

NAK.

Maxime

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

Hi Maxime,

thanks for your answer, much appreciated!

Quoted 57 lines · Maxime Ripard

Hi Andre,

Quoted 38 lines · Andr? Przywara

Hi Maxime,

Quoted 11 lines · Maxime Ripard

Hi,

Here is the previous A64 patches made by Andre [1], reworked to use the new sunxi-ng clock framework.

This uses the current H3 clock code, as both are really similar. The first patches are just meant to rework slightly the H3 code, before introducing the A64-related patches.

Some WiP stuff have been removed, such as the MMC part, but this serie already has a decent amount of devices supported: uart, i2c, rsb, etc.

Thanks very much for looking into this and compiling this series!

In general this looks good to me - apart from the sunxi-ng clock usage. I think I have some small fixes to the DT (have to compare against my latest local branch), I will comment on this later.

As I think I never officially expressed my concerns about the new sunxi clock system, so I use that opportunity here ;-)

As this became quite a long read, here a TL;DR:
- We consider using an SCPI based clock system for the A64, alongside allwinner,simple-gates and fixed clocks. We try to avoid any Allwinner specific clocks (apart from the simple-gates).
- ARM Trusted Firmware provides the SCPI implementation - for now, later we may move this into a possible arisc firmware.
- We upstream some basic DT first, possibly omitting any controversial clock parts at all.

Let me know what you think!

Now the long part ....

Quoted 15 lines

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.
- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

Quoted 3 lines

3 - You never get a complete clock support for any SoC, requirining
for pretty much every driver to create from scratch a new clock driver.

I don't understand this. Are you referring to the old clock system? Or to the proposed SCPI approach? Or to sunxi-ng with DT descriptions?

And why would a *driver* care about a specific clock if it's using the common clock framework?
Confused ...

Quoted 2 lines

4 - You require for all these clocks drivers some Ack from both the DT
and clocks maintainers, who both said they were fed up with this.

Again which new clock drivers? The old sunxi-clks?
For the SCPI version I propose we don't need any ACKs (apart from the new .dtsi, maybe), because the clocks are already there.

Quoted 26 lines

5 - If you realise some day down the road that the parenting
relationship is not right, or that some clock is not doing what you thought it was, you can't really fix it properly because of the DT stability you wanted us to enforce.

Quoted 21 lines

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.
- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.
- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

Quoted 8 lines
Quoted 3 lines

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.

But you duplicate the clock framework entirely, both the core code and the data you were complaining about, with all the issues that arise from code duplication. You still have to create that big file you were complaining about, with exactly the same constraints.

We don't need to comply with some common clock framework in firmware, we just need to provide implementations for specific clocks. From a maintainer's point of view the CCF is nice, but its implementation is quite complicated and hard to understand for mere mortals. Also tweaking a particular clock is not easy, as it has to fit into the framework and we may miss the interfaces.

See the MMC clock implementation for instance: it's just a simple divider clock. My implementation in ATF is probably bad and stupid, but at the end of the day I just have to provide a way to set a frequency of one single clock.
I think we win a lot if we go away from possibly tuning the parent's clocks (AHB, PLL6 & friends), instead leaving them as fixed clocks - my understanding is that Allwinner recommends this anyway. Then the whole complex clock tree degrades into just a bunch of more or less independent clock registers.
Also we can go with a much easier implementation, since we don't need to support all clocks in one image, but just the clocks for one particular SoC. This brings the complexity down, so we can get away with a much simpler implementation (compare U-Boot, though this isn't the best example, admittedly).

Quoted 9 lines
Quoted 8 lines

- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.

Quoted 4 lines

But no-one would actually be able to use it, because no one upgrades its firmware, including all the major distributions (Debian, Ubuntu, Fedora, OpenWRT, Arch, Gento, you name it). So there's effectively no way to fix a bug that was there.

But currently distributions do upgrade U-Boot, don't they? ATF would be part of a FIT image, compiled alongside U-Boot and included in one image with the SPL and the U-Boot proper. In the Allwinner world with firmware on SD cards or in eMMC I don't see big issues.
Also honestly I don't expect frequent updates. Yes: in the beginning we may have changes, but at some point we make a (tested) release and maybe publish updates every now and then. Either these updates fix bugs or provide new features, so there is some incentive for users to update. Or they don't care, in which case it may just work for them and they keep using the old version.

Quoted 7 lines
Quoted 3 lines

- Having SCPI gives us simple regulators and sensors (temperature, power) for free (in terms of no Linux code required). It also allows for DVFS support, though this may require more work on the firmware side.

And ignoring all the other features that the PMIC support, and the board uses out there (GPIO, ADCs, Power supplies, battery charger, USB VBUS monitoring)

Replying to that in that other email ...

Quoted 7 lines
Quoted 2 lines

- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

$ git grep -l scpi arch/arm64/boot/dts/**.dtsi
arch/arm64/boot/dts/arm/juno-base.dtsi

Are you saying that only Juno is a serious ARM64 machine?

I wasn't referring to SCPI in particular (which is indeed used only by Juno at the moment), but about not exposing the actual internal clock layout to Linux. PCs certainly don't, but also AMD Seattle and ThunderX avoid this.

Quoted 8 lines
Quoted 5 lines

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

That's not true and you know it.

Quoted 8 lines

What you actually suggest is to implement a minimal set of clocks in ATF (the opposite being, the entire set of clocks, which would of course be untested, so it basically falls down in the exact same category).

What this means is that, since we will obviously not support all the clocks client from day one, any user will be *required* for a new kernel release to operate as it's expected to upgrade the ATF.

I don't see that these are related - unless you consider the DT part of the kernel - which it clearly isn't (although the current scheme of DT updates suggests this). Actually the firmware should provide the DT, just advertising all the clocks it implements.
And as I don't expect implementing an isolated clock as an SCPI clock to be rocket science, I'd hope for the error rate to be minimal. So we may publish an early firmware version with support for certain devices only and later upgrade this. U-Boot gets also upgraded via the distributions at the moment. We could even introduce some firmware upgrade infrastructure (or use the Linux one) if we find us in dire need for.

Quoted 5 lines

Without any help from the distribution (s)he's running, because no one has that kind of scenario in mind. And let's be honest, I don't see Ubuntu changing the dependencies for the kernel for the Allwinner SoCs alone (let alone the fact that it's pretty much impossible in a generic way to know where and how the ATF is installed).

Again how does this differ from U-Boot, which I consider firmware as well and which is handled by the distributions (although I don't like this approach very much, because it pushes hardware support to Linux vendors).

Quoted 6 lines

Apart from being a major pain for any user, upgrading the bootloader is also a showstopper for most industries.

So, no, we won't do that. The A64 support is something we actually want to use in real-life products, and our users to be happy with the support they have.

I can understand that we can just do what we did in the past: Spoon feed every new SoC as soon as we get our hands on some boards and explicitly add support for it in the Linux kernel.
But I'd like to revisit this approach, as it actually takes quite some time for support to trickle in down the kernel road - especially if we look at major distributions (think LTS).
If we can get closer to a state were new SoCs just require appropriate firmware and a DT - without any new kernel code - I see a big opportunity to get much quicker support for new SoCs - up to a point where the firmware is the only thing that's needed. Maybe some day the board vendors provide these firmware bits even, who knows?

Another thing that strikes me: Currently we have strict per-SoC pinctrl drivers, which is unfortunate. But now we are adding new clock _descriptions_ for new SoCs as well, partly degrading the DT to a mere "board file selector". IIRC Linus complained about those numerous clock updates for ARM boards back then in his big ARM rant, I am just afraid that we go back to this state, bloating the kernel with SoC specific clock details - that it not necessarily needs to know about. In the end the kernel just wants to program this MMC clock to 52 MHz.

Quoted 2 lines

NAK.

Cheers,
Andre.

P.S. I am cowardly leaving for a few days off after hitting the Send button, so don't expect immediate replies.

#34 lore raw
Quoted 18 lines · Andr? Przywara
Quoted 18 lines
Quoted 17 lines

Now the long part ....

Basically I see those issues with the new clocks:
- sunxi-ng requires a complicated SoC specific source file in the kernel. Although that makes the DT pretty easy (and avoids breaking it the future), it ultimately requires an explicit code drop for every new SoC, even if they share 95% of the clocks (as H3 and A64 do, for instance).
- This code file does not actually contain any code, instead it's just data and looks like it should really be presented in DT - which brings us back to something like the old sunxi clock scheme, which is apparently not considered good enough. I still wonder if we could create a generic sunxi-ng user, which explains the needed clocks in the DT instead of in code. I admit that looks like quite some work.
- It makes it quite hard for any other DT user (*BSD, U-Boot) to use the clocks, since they would have to copy quite verbatim the Linux implementation choice. This is admittedly also true for the old clock framework, but still unfortunate.

Quoted 6 lines
Quoted 3 lines

3 - You never get a complete clock support for any SoC, requirining
for pretty much every driver to create from scratch a new clock driver.

I don't understand this. Are you referring to the old clock system? Or to the proposed SCPI approach? Or to sunxi-ng with DT descriptions?

I was referring here to the old clock system.

Quoted 3 lines

And why would a *driver* care about a specific clock if it's using the common clock framework?
Confused ...

Because a driver drives an IP that is fed by a specific clock, and those clocks entirely change from one controller to the other, and from one SoC to the other.

So we were in a situation where you had to write that clock driver before doing something useful, and then debug because obviously it was not written properly. This is not acceptable.

Quoted 4 lines
Quoted 2 lines

4 - You require for all these clocks drivers some Ack from both the DT
and clocks maintainers, who both said they were fed up with this.

Again which new clock drivers? The old sunxi-clks?

Old clks. I was under the impression that you were advocating against sunxi-ng here, and your patches were using the old system. Sorry if I mixed things up. Obviously, that wouldn't happen with SCPI.

Quoted 38 lines

For the SCPI version I propose we don't need any ACKs (apart from the new .dtsi, maybe), because the clocks are already there.

Quoted 26 lines

5 - If you realise some day down the road that the parenting
relationship is not right, or that some clock is not doing what you thought it was, you can't really fix it properly because of the DT stability you wanted us to enforce.

Quoted 21 lines

So as mentioned several times before, I am looking into a more firmware driven clock system using the SCPI[1] framework.
The idea is:
- The basic clocks (OSC24M, OSC32K, AHB1, APB1, APB2, PERIPH0) are expressed as fixed clocks. If I am not mistaken, Allwinner recommends certain frequencies for them anyway, so we just use that and set them up before booting Linux, for instance in ATF.
- The gates clocks are expressed as before, but by defining a generic DT compatible fallback name. I have no idea why every SoC enters its name into the simple_gates.c source file, while just mentioning the compatible string in the DT bindings and using the SoC specific name together with a generic fallback like "allwinner,sunxi-simple-gates" would suffice. This means that we don't need to touch simple-gates.c anymore most of the time.
- Any clock that can (and has to) be programmed with a variable frequency is expressed as an SCPI clock. This interface allows basically querying and setting a frequency - not very powerful, but sufficient for the clocks I checked. Firmware then takes the burden of programming the respective clock register - which is not rocket science if we lock the base clocks to a certain frequency.

Quoted 8 lines
Quoted 3 lines

The advantage of this approach would be:
- The impact to Linux code is minimized. Normally there would be no need to touch the kernel at all when we introduce a new SoC.

But you duplicate the clock framework entirely, both the core code and the data you were complaining about, with all the issues that arise from code duplication. You still have to create that big file you were complaining about, with exactly the same constraints.

Quoted 4 lines

We don't need to comply with some common clock framework in firmware, we just need to provide implementations for specific clocks. From a maintainer's point of view the CCF is nice, but its implementation is quite complicated and hard to understand for mere mortals.

Well, it might just be because "dealing with clocks is hard"? And you would have to reimplement at least part of it anyway.

Quoted 2 lines

Also tweaking a particular clock is not easy, as it has to fit into the framework and we may miss the interfaces.

Then add the interface. We do that on a regular basis, and Mike and Stephen are usually open to it if it's relevant.

Quoted 4 lines

See the MMC clock implementation for instance: it's just a simple divider clock. My implementation in ATF is probably bad and stupid, but at the end of the day I just have to provide a way to set a frequency of one single clock.

For all clock rates that are possible on MMC? With DDR? I seriously doubt this will be stupid.

Quoted 3 lines

I think we win a lot if we go away from possibly tuning the parent's clocks (AHB, PLL6 & friends), instead leaving them as fixed clocks - my understanding is that Allwinner recommends this anyway.

Being a fixed clock doesn't help. We had the issue in the past where we actually had to change those rates to have DMA working (A31's AHB), or simply because the rate was bad (A13's pll5). A fixed clock removes that possibility. However, a clock properly modelled can.

Which doesn't mean that we would change it (and we don't!).

Quoted 8 lines

Then the whole complex clock tree degrades into just a bunch of more or less independent clock registers.

Also we can go with a much easier implementation, since we don't need to support all clocks in one image, but just the clocks for one particular SoC. This brings the complexity down, so we can get away with a much simpler implementation (compare U-Boot, though this isn't the best example, admittedly).

Yeah, ignoring 95% of the problem is usually a very efficient way to simplify it. Now, throw the audio clocks, the pixel clocks, the SPI clocks, the camera clocks, the GPU clocks. Had some frequency change for all of them, with some weird frequencies for the pixel clocks to deal with all the panels out there, and see how it goes.

For example, during the A13 DRM development, we had to support changing from TV-out to the panel output. In order to generate the right frequencies, we had to change the rate of 4 clocks with a direct relationship, and try to come up with a combination of these four clocks that would generate the right frequency.

This is trivial with the CCF. Yes, it's complex, but the complexity is here for a reason. Otherwise no-one would use it (yet everyone does).

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

- Any other DT user can quite easily make use of the clock system without adding tons of complicated Allwinner specific clock code. The simple-gates driver is almost trivial to implement, and chances are SCPI is already around anyway.
- If there are any peculiarities with a certain clock (implementation), we can solve this in firmware. Fixes to code would immediately benefit all users - existing kernels (from distributions), newer kernels and other OSes.

Quoted 6 lines
Quoted 4 lines

But no-one would actually be able to use it, because no one upgrades its firmware, including all the major distributions (Debian, Ubuntu, Fedora, OpenWRT, Arch, Gento, you name it). So there's effectively no way to fix a bug that was there.

But currently distributions do upgrade U-Boot, don't they?

Debian Jessie has a package with U-Boot 2014.10. I don't even know how they can install it, since there's no generic way to do it.

Fedora, Arch, Gentoo don't have a package.
OpenWRT is made to run on whatever bootloader comes on the board.

So no, really, they don't.

Quoted 4 lines

ATF would be part of a FIT image, compiled alongside U-Boot and included in one image with the SPL and the U-Boot proper. In the Allwinner world with firmware on SD cards or in eMMC I don't see big issues.

And on NAND? SPI-NOR? And on which MMC card would you install it?

Quoted 6 lines

Also honestly I don't expect frequent updates. Yes: in the beginning we may have changes, but at some point we make a (tested) release and maybe publish updates every now and then. Either these updates fix bugs or provide new features, so there is some incentive for users to update. Or they don't care, in which case it may just work for them and they keep using the old version.

Judging from the past experience, in 4 years, we haven't been able to complete a single clock tree. And by complete, I mean with all the clocks defined, and tested properly. This will be much easier with sunxi-ng, but really, don't count on having everything that works after a short while.

Even if you have all the clocks exposed quite soon, we don't have any driver to test them.

So what you suggest is to actually upgrade the bootloader each time, for the foreseeable future. And that alone is a showstopper.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

- This approach matches many of the more serious ARM64 machines out there, which refrain from exposing all of their clock framework to Linux.

$ git grep -l scpi arch/arm64/boot/dts/**.dtsi
arch/arm64/boot/dts/arm/juno-base.dtsi
Quoted 6 lines
Quoted 1 line

Are you saying that only Juno is a serious ARM64 machine?

I wasn't referring to SCPI in particular (which is indeed used only by Juno at the moment), but about not exposing the actual internal clock layout to Linux. PCs certainly don't, but also AMD Seattle and ThunderX avoid this.

I don't need to upgrade my BIOS or UEFI on my PC everytime I get a new kernel release to have everything working as it should.

And I'm guessing both ThunderX and Seattle had an army of engineers working on that firmware, and testing every last bit of it.

If we also had such a firmware, I would be all in. But we don't, and we can't in a reasonable (less than a month) timeframe. It really boils down to this. This has been stalled for something like 6 monthes now, waiting for solutions that might or might not happen (and I know I have my share of responsibilities in this). But I don't want to wait any longer.

Quoted 13 lines
Quoted 13 lines
Quoted 5 lines

Also this opens the door to much easier support for new SoCs - up to a point where any new chip would actually run out of the box on existing distributions (thinking of LTS releases here). The pinctrl driver is a nasty guy around here - but let's not make it worse and try to fix that guy later ;-)

That's not true and you know it.

What you actually suggest is to implement a minimal set of clocks in ATF (the opposite being, the entire set of clocks, which would of course be untested, so it basically falls down in the exact same category).

Quoted 8 lines
Quoted 3 lines

What this means is that, since we will obviously not support all the clocks client from day one, any user will be *required* for a new kernel release to operate as it's expected to upgrade the ATF.

I don't see that these are related - unless you consider the DT part of the kernel - which it clearly isn't (although the current scheme of DT updates suggests this). Actually the firmware should provide the DT, just advertising all the clocks it implements.

I consider my firmware just like you consider your DT: I really like the fact that I can go with _one_ known best firmware.

Quoted 2 lines

And as I don't expect implementing an isolated clock as an SCPI clock to be rocket science, I'd hope for the error rate to be minimal.

I'm more pessimistic than you are on this, but even with that assumption, the point still holds: you cannot support all the clocks from day one.

Quoted 3 lines

So we may publish an early firmware version with support for certain devices only and later upgrade this. U-Boot gets also upgraded via the distributions at the moment.

Like I said, this is not true.

Quoted 2 lines

We could even introduce some firmware upgrade infrastructure (or use the Linux one) if we find us in dire need for.

And I want something that works *today*, not some blurry thing that redhat, fedora and debian might or might not help us with at some point in a vague future.

Quoted 10 lines
Quoted 5 lines

Without any help from the distribution (s)he's running, because no one has that kind of scenario in mind. And let's be honest, I don't see Ubuntu changing the dependencies for the kernel for the Allwinner SoCs alone (let alone the fact that it's pretty much impossible in a generic way to know where and how the ATF is installed).

Again how does this differ from U-Boot, which I consider firmware as well and which is handled by the distributions (although I don't like this approach very much, because it pushes hardware support to Linux vendors).

U-boot configuration is mostly static. The video modes are always the same. You don't have to do any arbitration between devices. You don't have audio. It's totally fine for a firmware, but you need something more advanced in the kernel.

Quoted 8 lines
Quoted 7 lines

Apart from being a major pain for any user, upgrading the bootloader is also a showstopper for most industries.

So, no, we won't do that. The A64 support is something we actually want to use in real-life products, and our users to be happy with the support they have.

Quoted 11 lines

I can understand that we can just do what we did in the past: Spoon feed every new SoC as soon as we get our hands on some boards and explicitly add support for it in the Linux kernel.
But I'd like to revisit this approach, as it actually takes quite some time for support to trickle in down the kernel road - especially if we look at major distributions (think LTS).
If we can get closer to a state were new SoCs just require appropriate firmware and a DT - without any new kernel code - I see a big opportunity to get much quicker support for new SoCs - up to a point where the firmware is the only thing that's needed. Maybe some day the board vendors provide these firmware bits even, who knows?

I understand the need for ARM to find a technical showcase platform. What I don't understand is why I should feel the pain of going against the current, and waiting for suffering to (maybe) stop at some point in the future.

That goal is very noble. I'm under the impression that it's the kind of soft-lobbying that Marc wanted to do with PSCI too, that we were basically the first one to implement. And it worked for us because it worked from day one, and it was an all or nothing.

What you suggest is an entire different story.

Please speak to the vendors, make them provide those firmwares. I'll be more than happy to switch to them then.

Maxime

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