All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC
@ 2017-03-01  7:04 Chen-Yu Tsai
  2017-03-01  7:04 ` [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40 Chen-Yu Tsai
                   ` (11 more replies)
  0 siblings, 12 replies; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

Hi everyone,

This series adds support for the new R40 SoC. The R40 is marketed as the
successor to the A20. It is mostly pin compatible (in software) with the
A20. It has a somewhat similar memory layout, a hybrid of A20 and newer
sun6i gen.. Like the A20, it does not have a PRCM block.

This series makes checkpatch throw out a lot of errors, mostly "no spaces
at the start of a line" or "space prohibited after that open parenthesis
'('", but fixing them does not improve the readability of the code.

Patch 1 introduces the R40 to U-boot, by adding a Kconfig symbol, fixing
up any SoC depends on in Kconfig to disable unsupported features, and
reworking board level pinmuxes.

Patch 2 enables using the AXP221s PMIC in I2C mode. The R40 is paired
with this PMIC, but it does not have a P2WI controller.

Patch 3 fixes the watchdog reset function for R40. The R40's watchdog
register layout is like the A10/A20.

Patch 4 adds mmc pinmux settings for R40.

Patch 5 fixes the PLL lock settings for the R40. The R40's CCU has a
new mode for PLL lock, which can be configured and also switched back
to the old mode. Here we just use the old mode, which is the same as
the other sun6i gen. SoCs.

Patch 6 provides some default DRAM settings for the R40. These were
taken from the Bananapi M2 Ultra, the only R40 board available.

Patch 7 adds the compatible string for the R40 PIO. It is mostly
compatible with the A20, with a few functions gone, and a few new
ones.

Patch 8 adds DRAM initialization support for the R40. The DRAM
controller is very similar to the A64 and H5, however the A15 line
and CSC1 line are muxed on the same pin. Also the PIR_QSGATE bit
must not be set, or DRAM init fails.

Patch 9 enables SPL for R40.

Patch 10 fixes the address of the CPUCFG block on the R40. It is
the same as on the A20.

Patch 11 adds a PSCI implementation for the R40. As the register
layout is slightly erratic, we just use a macro for the ones that
can't fit into the cpucfg register definition structure.

Patch 12 adds a board dts and defconfig for the Bananapi M2 Ultra.

Please have a look.

Regards
ChenYu

Chen-Yu Tsai (12):
  sunxi: Add initial support for R40
  sunxi: Enable AXP221s in I2C mode with the R40 SoC
  sunxi: Fix watchdog reset function for R40
  sunxi: Add mmc[1-3] pinmux settings for R40
  sunxi: Set PLL lock enable bits for R40
  sunxi: Provide defaults for R40 DRAM settings
  gpio: sunxi: Add compatible string for R40 PIO
  sunxi: Use H3/A64 DRAM initialization code for R40
  sunxi: Enable SPL for R40
  sunxi: Fix CPUCFG address for R40
  sunxi: Add PSCI support for R40
  sunxi: Add support for Bananapi M2 Ultra

 arch/arm/cpu/armv7/sunxi/psci.c                 |  35 ++++-
 arch/arm/dts/Makefile                           |   2 +
 arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts    |  69 +++++++++
 arch/arm/dts/sun8i-r40.dtsi                     | 183 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h   |   2 +
 arch/arm/include/asm/arch-sunxi/cpu.h           |   1 +
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h     |   6 +-
 arch/arm/include/asm/arch-sunxi/dram.h          |   4 +-
 arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h |  20 ++-
 arch/arm/include/asm/arch-sunxi/timer.h         |   5 +-
 arch/arm/include/asm/arch-sunxi/watchdog.h      |   5 +-
 arch/arm/mach-sunxi/Makefile                    |   1 +
 arch/arm/mach-sunxi/board.c                     |  15 +-
 arch/arm/mach-sunxi/clock_sun6i.c               |   9 +-
 arch/arm/mach-sunxi/cpu_info.c                  |   2 +
 arch/arm/mach-sunxi/dram_sun8i_h3.c             | 121 ++++++++++++++--
 arch/arm/mach-sunxi/pmic_bus.c                  |   7 +
 board/sunxi/Kconfig                             |  18 ++-
 board/sunxi/MAINTAINERS                         |   6 +
 board/sunxi/board.c                             |  36 ++++-
 configs/Bananapi_M2_Ultra_defconfig             |  15 ++
 drivers/gpio/sunxi_gpio.c                       |   1 +
 drivers/power/Kconfig                           |  16 ++-
 23 files changed, 530 insertions(+), 49 deletions(-)
 create mode 100644 arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
 create mode 100644 arch/arm/dts/sun8i-r40.dtsi
 create mode 100644 configs/Bananapi_M2_Ultra_defconfig

-- 
2.11.0

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

* [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 10:55   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC Chen-Yu Tsai
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The R40 is the successor to the A20. It is a hybrid of the A20, A33
and the H3.

The R40's PIO controller is compatible with the A20,
Reuse the A20 UART and I2C muxing code by adding the R40's macro.

The display pipeline is the newer DE 2.0 variant.
Block enabling video on R40 for now.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/mach-sunxi/board.c    | 10 +++++++---
 arch/arm/mach-sunxi/cpu_info.c |  2 ++
 board/sunxi/Kconfig            |  9 +++++++--
 board/sunxi/board.c            | 19 ++++++++++++++-----
 4 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 5e03d039433a..5a74c9717d84 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -69,12 +69,14 @@ struct mm_region *mem_map = sunxi_mem_map;
 static int gpio_init(void)
 {
 #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || \
+    defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 	/* disable GPB22,23 as uart0 tx,rx to avoid conflict */
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
 #endif
-#if defined(CONFIG_MACH_SUN8I)
+#if defined(CONFIG_MACH_SUN8I) && !defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUN8I_GPF_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUN8I_GPF_UART0);
 #else
@@ -82,7 +84,9 @@ static int gpio_init(void)
 	sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF_UART0);
 #endif
 	sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
-#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I))
+#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || \
+				 defined(CONFIG_MACH_SUN7I) || \
+				 defined(CONFIG_MACH_SUN8I_R40))
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB_UART0);
 	sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
index 85633ccec216..7851de299ab5 100644
--- a/arch/arm/mach-sunxi/cpu_info.c
+++ b/arch/arm/mach-sunxi/cpu_info.c
@@ -87,6 +87,8 @@ int print_cpuinfo(void)
 	printf("CPU:   Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id());
 #elif defined CONFIG_MACH_SUN8I_H3
 	printf("CPU:   Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id());
+#elif defined CONFIG_MACH_SUN8I_R40
+	printf("CPU:   Allwinner R40 (SUN8I %04x)\n", sunxi_get_sram_id());
 #elif defined CONFIG_MACH_SUN9I
 	puts("CPU:   Allwinner A80 (SUN9I)\n");
 #elif defined CONFIG_MACH_SUN50I
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 3e0e2624737e..8e8b9cd0d5fd 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -132,6 +132,11 @@ config MACH_SUN8I_H3
 	select MACH_SUNXI_H3_H5
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
+config MACH_SUN8I_R40
+	bool "sun8i (Allwinner R40)"
+	select CPU_V7
+	select SUNXI_GEN_SUN6I
+
 config MACH_SUN9I
 	bool "sun9i (Allwinner A80)"
 	select CPU_V7
@@ -157,7 +162,7 @@ endchoice
 # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
 config MACH_SUN8I
 	bool
-	default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T
+	default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T || MACH_SUN8I_R40
 
 config RESERVE_ALLWINNER_BOOT0_HEADER
 	bool "reserve space for Allwinner boot0 header"
@@ -510,7 +515,7 @@ config AXP_GPIO
 
 config VIDEO
 	bool "Enable graphical uboot console on HDMI, LCD or VGA"
-	depends on !MACH_SUN8I_A83T && !MACH_SUNXI_H3_H5 && !MACH_SUN9I && !MACH_SUN50I
+	depends on !MACH_SUN8I_A83T && !MACH_SUNXI_H3_H5 && !MACH_SUN8I_R40 && !MACH_SUN9I && !MACH_SUN50I
 	default y
 	---help---
 	Say Y here to add support for using a cfb console on the HDMI, LCD
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index b9660128e5e7..495cb591a9fb 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -394,7 +394,10 @@ int board_mmc_init(bd_t *bis)
 void i2c_init_board(void)
 {
 #ifdef CONFIG_I2C0_ENABLE
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || \
+    defined(CONFIG_MACH_SUN5I) || \
+    defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUN4I_GPB_TWI0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUN4I_GPB_TWI0);
 	clock_twi_onoff(0, 1);
@@ -410,7 +413,9 @@ void i2c_init_board(void)
 #endif
 
 #ifdef CONFIG_I2C1_ENABLE
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || \
+    defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(18), SUN4I_GPB_TWI1);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(19), SUN4I_GPB_TWI1);
 	clock_twi_onoff(1, 1);
@@ -430,7 +435,9 @@ void i2c_init_board(void)
 #endif
 
 #ifdef CONFIG_I2C2_ENABLE
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || \
+    defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(20), SUN4I_GPB_TWI2);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(21), SUN4I_GPB_TWI2);
 	clock_twi_onoff(2, 1);
@@ -454,7 +461,8 @@ void i2c_init_board(void)
 	sunxi_gpio_set_cfgpin(SUNXI_GPG(10), SUN6I_GPG_TWI3);
 	sunxi_gpio_set_cfgpin(SUNXI_GPG(11), SUN6I_GPG_TWI3);
 	clock_twi_onoff(3, 1);
-#elif defined(CONFIG_MACH_SUN7I)
+#elif defined(CONFIG_MACH_SUN7I) || \
+      defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPI(0), SUN7I_GPI_TWI3);
 	sunxi_gpio_set_cfgpin(SUNXI_GPI(1), SUN7I_GPI_TWI3);
 	clock_twi_onoff(3, 1);
@@ -462,7 +470,8 @@ void i2c_init_board(void)
 #endif
 
 #ifdef CONFIG_I2C4_ENABLE
-#if defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 	sunxi_gpio_set_cfgpin(SUNXI_GPI(2), SUN7I_GPI_TWI4);
 	sunxi_gpio_set_cfgpin(SUNXI_GPI(3), SUN7I_GPI_TWI4);
 	clock_twi_onoff(4, 1);
-- 
2.11.0

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

* [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
  2017-03-01  7:04 ` [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40 Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 10:55   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40 Chen-Yu Tsai
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The R40 SoC uses the AXP221s in I2C mode to supply power.

Some regulator's common usages have changed, and also the recommended
voltage for existing usages have changed. Update the defaults to match.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/mach-sunxi/pmic_bus.c |  7 +++++++
 board/sunxi/Kconfig            |  2 +-
 drivers/power/Kconfig          | 16 ++++++++++------
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
index 7c57f02792b9..f917c3e070a5 100644
--- a/arch/arm/mach-sunxi/pmic_bus.c
+++ b/arch/arm/mach-sunxi/pmic_bus.c
@@ -41,6 +41,9 @@ int pmic_bus_init(void)
 	p2wi_init();
 	ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR,
 				       AXP221_INIT_DATA);
+# elif defined CONFIG_MACH_SUN8I_R40
+	/* Nothing. R40 uses the AXP221s in I2C mode */
+	ret = 0;
 # else
 	ret = rsb_init();
 	if (ret)
@@ -65,6 +68,8 @@ int pmic_bus_read(u8 reg, u8 *data)
 #elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 # ifdef CONFIG_MACH_SUN6I
 	return p2wi_read(reg, data);
+# elif defined CONFIG_MACH_SUN8I_R40
+	return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1);
 # else
 	return rsb_read(AXP223_RUNTIME_ADDR, reg, data);
 # endif
@@ -80,6 +85,8 @@ int pmic_bus_write(u8 reg, u8 data)
 #elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 # ifdef CONFIG_MACH_SUN6I
 	return p2wi_write(reg, data);
+# elif defined CONFIG_MACH_SUN8I_R40
+	return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1);
 # else
 	return rsb_write(AXP223_RUNTIME_ADDR, reg, data);
 # endif
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 8e8b9cd0d5fd..e89ddf626289 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -456,7 +456,7 @@ config USB3_VBUS_PIN
 
 config I2C0_ENABLE
 	bool "Enable I2C/TWI controller 0"
-	default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+	default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUN8I_R40
 	default n if MACH_SUN6I || MACH_SUN8I
 	select CMD_I2C
 	---help---
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 64e5bc2f74b4..911ecb1144a6 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -10,7 +10,7 @@ choice
 	prompt "Select Sunxi PMIC Variant"
 	depends on ARCH_SUNXI
 	default AXP209_POWER if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
-	default AXP221_POWER if MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33
+	default AXP221_POWER if MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_R40
 	default AXP818_POWER if MACH_SUN8I_A83T
 	default SUNXI_NO_PMIC if MACH_SUNXI_H3_H5 || MACH_SUN50I
 
@@ -37,7 +37,7 @@ config AXP209_POWER
 
 config AXP221_POWER
 	bool "axp221 / axp223 pmic support"
-	depends on MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33
+	depends on MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_R40
 	select CMD_POWEROFF
 	---help---
 	Select this to enable support for the axp221/axp223 pmic found on most
@@ -70,7 +70,7 @@ endchoice
 config AXP_DCDC1_VOLT
 	int "axp pmic dcdc1 voltage"
 	depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 3300 if AXP818_POWER
+	default 3300 if AXP818_POWER || MACH_SUN8I_R40
 	default 3000 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I
 	---help---
 	Set the voltage (mV) to program the axp pmic dcdc1 at, set to 0 to
@@ -97,6 +97,7 @@ config AXP_DCDC2_VOLT
 	On A23/A33 boards dcdc2 is used for VDD-SYS and should be 1.1V.
 	On A80 boards dcdc2 powers the GPU and can be left off.
 	On A83T boards dcdc2 is used for VDD-CPUA(cluster 0) and should be 0.9V.
+	On R40 boards dcdc2 is VDD-CPU and should be 1.1V
 
 config AXP_DCDC3_VOLT
 	int "axp pmic dcdc3 voltage"
@@ -104,6 +105,7 @@ config AXP_DCDC3_VOLT
 	default 900 if AXP809_POWER || AXP818_POWER
 	default 1500 if AXP152_POWER
 	default 1250 if AXP209_POWER
+	default 1100 if MACH_SUN8I_R40
 	default 1200 if MACH_SUN6I || MACH_SUN8I
 	---help---
 	Set the voltage (mV) to program the axp pmic dcdc3 at, set to 0 to
@@ -114,6 +116,7 @@ config AXP_DCDC3_VOLT
 	On A23 / A31 / A33 boards dcdc3 is VDD-CPU and should be 1.2V.
 	On A80 boards dcdc3 is used for VDD-CPUA(cluster 0) and should be 0.9V.
 	On A83T boards dcdc3 is used for VDD-CPUB(cluster 1) and should be 0.9V.
+	On R40 boards dcdc3 is VDD-SYS and VDD-GPU and should be 1.1V.
 
 config AXP_DCDC4_VOLT
 	int "axp pmic dcdc4 voltage"
@@ -138,13 +141,13 @@ config AXP_DCDC5_VOLT
 	---help---
 	Set the voltage (mV) to program the axp pmic dcdc5 at, set to 0 to
 	disable dcdc5.
-	On A23 / A31 / A33 / A80 / A83T boards dcdc5 is VCC-DRAM and
+	On A23 / A31 / A33 / A80 / A83T / R40 boards dcdc5 is VCC-DRAM and
 	should be 1.5V, 1.35V if DDR3L is used.
 
 config AXP_ALDO1_VOLT
 	int "axp pmic (a)ldo1 voltage"
 	depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 0 if MACH_SUN6I
+	default 0 if MACH_SUN6I || MACH_SUN8I_R40
 	default 1800 if MACH_SUN8I_A83T
 	default 3000 if MACH_SUN8I || MACH_SUN9I
 	---help---
@@ -183,7 +186,8 @@ config AXP_ALDO3_VOLT
 	Set the voltage (mV) to program the axp pmic aldo3 at, set to 0 to
 	disable aldo3.
 	On A10(s) / A13 / A20 boards aldo3 should be 2.8V.
-	On A23 / A31 / A33 boards aldo3 is VCC-PLL and AVCC and should be 3.0V.
+	On A23 / A31 / A33 / R40 boards aldo3 is VCC-PLL and AVCC and should
+	be 3.0V.
 	On A80 boards aldo3 is normally not used.
 	On A83T / H8 boards aldo3 is AVCC, VCC-PL, and VCC-LED, and should be
 	3.0V.
-- 
2.11.0

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

* [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
  2017-03-01  7:04 ` [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40 Chen-Yu Tsai
  2017-03-01  7:04 ` [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 10:56   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings " Chen-Yu Tsai
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The watchdog found on the R40 SoC is the older variant found on the A20.
Add the proper "#if defines" to make it work.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/include/asm/arch-sunxi/timer.h    | 5 ++---
 arch/arm/include/asm/arch-sunxi/watchdog.h | 5 ++++-
 arch/arm/mach-sunxi/board.c                | 5 ++---
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/timer.h b/arch/arm/include/asm/arch-sunxi/timer.h
index a665309803cb..ccdf942534a4 100644
--- a/arch/arm/include/asm/arch-sunxi/timer.h
+++ b/arch/arm/include/asm/arch-sunxi/timer.h
@@ -67,7 +67,7 @@ struct sunxi_timer_reg {
 	struct sunxi_timer timer[6];	/* We have 6 timers */
 	u8 res2[16];
 	struct sunxi_avs avs;
-#ifdef CONFIG_SUNXI_GEN_SUN4I
+#if defined(CONFIG_SUNXI_GEN_SUN4I) || defined(CONFIG_MACH_SUN8I_R40)
 	struct sunxi_wdog wdog;	/* 0x90 */
 	/* XXX the following is not accurate for sun5i/sun7i */
 	struct sunxi_64cnt cnt64;	/* 0xa0 */
@@ -77,8 +77,7 @@ struct sunxi_timer_reg {
 	struct sunxi_tgp tgp[4];
 	u8 res5[8];
 	u32 cpu_cfg;
-#endif
-#ifdef CONFIG_SUNXI_GEN_SUN6I
+#elif defined(CONFIG_SUNXI_GEN_SUN6I)
 	u8 res3[16];
 	struct sunxi_wdog wdog[5];	/* We have 5 watchdogs */
 #endif
diff --git a/arch/arm/include/asm/arch-sunxi/watchdog.h b/arch/arm/include/asm/arch-sunxi/watchdog.h
index 8108be97bab0..ce6d66485609 100644
--- a/arch/arm/include/asm/arch-sunxi/watchdog.h
+++ b/arch/arm/include/asm/arch-sunxi/watchdog.h
@@ -13,7 +13,10 @@
 #define WDT_CTRL_RESTART	(0x1 << 0)
 #define WDT_CTRL_KEY		(0x0a57 << 1)
 
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || \
+    defined(CONFIG_MACH_SUN5I) || \
+    defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 
 #define WDT_MODE_EN		(0x1 << 0)
 #define WDT_MODE_RESET_EN	(0x1 << 1)
diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 5a74c9717d84..6ce07dfe0fd7 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -270,7 +270,7 @@ void board_init_f(ulong dummy)
 
 void reset_cpu(ulong addr)
 {
-#ifdef CONFIG_SUNXI_GEN_SUN4I
+#if defined(CONFIG_SUNXI_GEN_SUN4I) || defined(CONFIG_MACH_SUN8I_R40)
 	static const struct sunxi_wdog *wdog =
 		 &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
 
@@ -282,8 +282,7 @@ void reset_cpu(ulong addr)
 		/* sun5i sometimes gets stuck without this */
 		writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
 	}
-#endif
-#ifdef CONFIG_SUNXI_GEN_SUN6I
+#elif defined(CONFIG_SUNXI_GEN_SUN6I)
 	static const struct sunxi_wdog *wdog =
 		 ((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
 
-- 
2.11.0

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

* [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (2 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40 Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 10:56   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The PIO is generally compatible with the A20, except that it routes the
full 8 bits and eMMC reset pins for mmc2.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 board/sunxi/board.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 495cb591a9fb..21ce8348922c 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -199,7 +199,8 @@ static void mmc_pinmux_setup(int sdc)
 	case 1:
 		pins = sunxi_name_to_gpio_bank(CONFIG_MMC1_PINS);
 
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 		if (pins == SUNXI_GPIO_H) {
 			/* SDC1: PH22-PH-27 */
 			for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
@@ -294,6 +295,17 @@ static void mmc_pinmux_setup(int sdc)
 			sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
 			sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
 		}
+#elif defined(CONFIG_MACH_SUN8I_R40)
+		/* SDC2: PC6-PC15, PC24 */
+		for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
+			sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
+			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+			sunxi_gpio_set_drv(pin, 2);
+		}
+
+		sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_SDC2);
+		sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
+		sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
 #elif defined(CONFIG_MACH_SUN8I) || defined(CONFIG_MACH_SUN50I)
 		/* SDC2: PC5-PC6, PC8-PC16 */
 		for (pin = SUNXI_GPC(5); pin <= SUNXI_GPC(6); pin++) {
@@ -320,7 +332,8 @@ static void mmc_pinmux_setup(int sdc)
 	case 3:
 		pins = sunxi_name_to_gpio_bank(CONFIG_MMC3_PINS);
 
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
+#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I_R40)
 		/* SDC3: PI4-PI9 */
 		for (pin = SUNXI_GPI(4); pin <= SUNXI_GPI(9); pin++) {
 			sunxi_gpio_set_cfgpin(pin, SUNXI_GPI_SDC3);
-- 
2.11.0

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

* [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (3 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings " Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:53   ` Maxime Ripard
  2017-03-01 18:16   ` [U-Boot] [linux-sunxi] " Jernej Škrabec
  2017-03-01  7:04 ` [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings Chen-Yu Tsai
                   ` (6 subsequent siblings)
  11 siblings, 2 replies; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

According to the BSP released by Banana Pi, the R40 (sun8iw11p1) has
an extra "PLL lock control" register in the CCU, which controls whether
the individual PLL lock status bits in each PLL's control register work
or not.

This patch enables it for all the PLLs.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 2 ++
 arch/arm/mach-sunxi/clock_sun6i.c             | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index 1bfb48bd52df..1aefd5a64c1f 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -142,6 +142,8 @@ struct sunxi_ccm_reg {
 	u32 apb2_reset_cfg;	/* 0x2d8 APB2 Reset config */
 	u32 reserved25[5];
 	u32 ccu_sec_switch;	/* 0x2f0 CCU Security Switch, H3 only */
+	u32 reserved26[11];
+	u32 pll_lock_ctrl;	/* 0x320 PLL lock control, R40 only */
 };
 
 /* apb2 bit field */
diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c
index 4762fbf0c3f0..3c8c53fcf76b 100644
--- a/arch/arm/mach-sunxi/clock_sun6i.c
+++ b/arch/arm/mach-sunxi/clock_sun6i.c
@@ -35,6 +35,11 @@ void clock_init_safe(void)
 	clrbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK);
 #endif
 
+#ifdef CONFIG_MACH_SUN8I_R40
+	/* Set PLL lock enable bits and switch to old lock mode */
+	writel(GENMASK(12, 0), &ccm->pll_lock_ctrl);
+#endif
+
 	clock_set_pll1(408000000);
 
 	writel(PLL6_CFG_DEFAULT, &ccm->pll6_cfg);
-- 
2.11.0

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

* [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (4 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:53   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO Chen-Yu Tsai
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

These values were taken from the Banana Pi M2 Ultra fex file
found in the released vendor BSP. This is the only publicly
available R40 device at the time of this writing.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 board/sunxi/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index e89ddf626289..9854ef0a599e 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -197,6 +197,7 @@ config DRAM_TYPE
 config DRAM_CLK
 	int "sunxi dram clock speed"
 	default 792 if MACH_SUN9I
+	default 648 if MACH_SUN8I_R40
 	default 312 if MACH_SUN6I || MACH_SUN8I
 	default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
 	default 672 if MACH_SUN50I
@@ -218,6 +219,7 @@ config DRAM_ZQ
 	int "sunxi dram zq value"
 	default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
 	default 127 if MACH_SUN7I
+	default 3881979 if MACH_SUN8I_R40
 	default 4145117 if MACH_SUN9I
 	default 3881915 if MACH_SUN50I
 	---help---
@@ -227,6 +229,7 @@ config DRAM_ODT_EN
 	bool "sunxi dram odt enable"
 	default n if !MACH_SUN8I_A23
 	default y if MACH_SUN8I_A23
+	default y if MACH_SUN8I_R40
 	default y if MACH_SUN50I
 	---help---
 	Select this to enable dram odt (on die termination).
-- 
2.11.0

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

* [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (5 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:54   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40 Chen-Yu Tsai
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The PIO on the R40 SoC is mostly compatible with the A20.
Only a few pin functions for mmc2 were added to the PC
pingroup, to support 8 bit eMMCs.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/gpio/sunxi_gpio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 8d2bb18504ae..3f40e8383001 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -352,6 +352,7 @@ static const struct udevice_id sunxi_gpio_ids[] = {
 	ID("allwinner,sun8i-a33-pinctrl",	a_all),
 	ID("allwinner,sun8i-a83t-pinctrl",	a_all),
 	ID("allwinner,sun8i-h3-pinctrl",	a_all),
+	ID("allwinner,sun8i-r40-pinctrl",	a_all),
 	ID("allwinner,sun9i-a80-pinctrl",	a_all),
 	ID("allwinner,sun6i-a31-r-pinctrl",	l_2),
 	ID("allwinner,sun8i-a23-r-pinctrl",	l_1),
-- 
2.11.0

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

* [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (6 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:54   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 09/12] sunxi: Enable SPL " Chen-Yu Tsai
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The R40 seems to have a variant of the memory controller found in
the H3 and A64 SoCs. Adapt the code for use on the R40. The changes
are based on released DRAM code and comparing register dumps from
boot0.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/include/asm/arch-sunxi/cpu.h           |   1 +
 arch/arm/include/asm/arch-sunxi/dram.h          |   4 +-
 arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h |  20 +++-
 arch/arm/mach-sunxi/Makefile                    |   1 +
 arch/arm/mach-sunxi/clock_sun6i.c               |   4 +-
 arch/arm/mach-sunxi/dram_sun8i_h3.c             | 121 +++++++++++++++++++++---
 6 files changed, 133 insertions(+), 18 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/cpu.h b/arch/arm/include/asm/arch-sunxi/cpu.h
index e8e670e7e903..caec86526417 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu.h
@@ -16,5 +16,6 @@
 #define SOCID_A64	0x1689
 #define SOCID_H3	0x1680
 #define SOCID_H5	0x1718
+#define SOCID_R40	0x1701
 
 #endif /* _SUNXI_CPU_H */
diff --git a/arch/arm/include/asm/arch-sunxi/dram.h b/arch/arm/include/asm/arch-sunxi/dram.h
index 1dc82205b7df..f452f889f928 100644
--- a/arch/arm/include/asm/arch-sunxi/dram.h
+++ b/arch/arm/include/asm/arch-sunxi/dram.h
@@ -24,7 +24,9 @@
 #include <asm/arch/dram_sun8i_a33.h>
 #elif defined(CONFIG_MACH_SUN8I_A83T)
 #include <asm/arch/dram_sun8i_a83t.h>
-#elif defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+#elif defined(CONFIG_MACH_SUNXI_H3_H5) || \
+      defined(CONFIG_MACH_SUN8I_R40) || \
+      defined(CONFIG_MACH_SUN50I)
 #include <asm/arch/dram_sun8i_h3.h>
 #elif defined(CONFIG_MACH_SUN9I)
 #include <asm/arch/dram_sun9i.h>
diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h b/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
index 25d07d9863c9..2770986b613f 100644
--- a/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
+++ b/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
@@ -15,7 +15,8 @@
 
 struct sunxi_mctl_com_reg {
 	u32 cr;			/* 0x00 control register */
-	u8 res0[0x8];		/* 0x04 */
+	u32 cr_r1;		/* 0x04 rank 1 control register (R40 only) */
+	u8 res0[0x4];		/* 0x08 */
 	u32 tmr;		/* 0x0c (unused on H3) */
 	u32 mcr[16][2];		/* 0x10 */
 	u32 bwcr;		/* 0x90 bandwidth control register */
@@ -63,6 +64,17 @@ struct sunxi_mctl_com_reg {
 #define MCTL_CR_DUAL_RANK	(0x1 << 0)
 #define MCTL_CR_SINGLE_RANK	(0x0 << 0)
 
+/*
+ * CR_R1 is a register found in the R40's DRAM controller. It sets various
+ * parameters for rank 1. Bits [11:0] have the same meaning as the bits in
+ * MCTL_CR, but they apply to rank 1 only. This implies we can have
+ * different chips for rank 1 than rank 0.
+ *
+ * As address line A15 and CS1 chip select for rank 1 are muxed on the same
+ * pin, if single rank is used, A15 must be muxed in.
+ */
+#define MCTL_CR_R1_MUX_A15	(0x1 << 21)
+
 #define PROTECT_MAGIC		(0x94be6fa3)
 
 struct sunxi_mctl_ctl_reg {
@@ -72,7 +84,8 @@ struct sunxi_mctl_ctl_reg {
 	u32 clken;		/* 0x0c */
 	u32 pgsr[2];		/* 0x10 PHY general status registers */
 	u32 statr;		/* 0x18 */
-	u8 res1[0x14];		/* 0x1c */
+	u8 res1[0x10];		/* 0x1c */
+	u32 lp3mr11;		/* 0x2c */
 	u32 mr[4];		/* 0x30 mode registers */
 	u32 pllgcr;		/* 0x40 */
 	u32 ptr[5];		/* 0x44 PHY timing registers */
@@ -120,7 +133,8 @@ struct sunxi_mctl_ctl_reg {
 	struct {		/* 0x300 DATX8 modules*/
 		u32 mdlr;		/* 0x00 master delay line register */
 		u32 lcdlr[3];		/* 0x04 local calibrated delay line registers */
-		u32 bdlr[12];		/* 0x10 bit delay line registers */
+		u32 bdlr[11];		/* 0x10 bit delay line registers */
+		u32 sdlr;		/* 0x3c output enable bit delay registers */
 		u32 gtr;		/* 0x40 general timing register */
 		u32 gcr;		/* 0x44 general configuration register */
 		u32 gsr[3];		/* 0x48 general status registers */
diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
index efab4811ee54..5510aa54353f 100644
--- a/arch/arm/mach-sunxi/Makefile
+++ b/arch/arm/mach-sunxi/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_MACH_SUN8I_A23)	+= dram_sun8i_a23.o
 obj-$(CONFIG_MACH_SUN8I_A33)	+= dram_sun8i_a33.o
 obj-$(CONFIG_MACH_SUN8I_A83T)	+= dram_sun8i_a83t.o
 obj-$(CONFIG_MACH_SUNXI_H3_H5)	+= dram_sun8i_h3.o
+obj-$(CONFIG_MACH_SUN8I_R40)	+= dram_sun8i_h3.o
 obj-$(CONFIG_MACH_SUN9I)	+= dram_sun9i.o
 obj-$(CONFIG_MACH_SUN50I)	+= dram_sun8i_h3.o
 endif
diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c
index 3c8c53fcf76b..9068c88ab2f8 100644
--- a/arch/arm/mach-sunxi/clock_sun6i.c
+++ b/arch/arm/mach-sunxi/clock_sun6i.c
@@ -222,7 +222,9 @@ done:
 }
 #endif
 
-#if defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN50I)
+#if defined(CONFIG_MACH_SUN8I_A33) || \
+    defined(CONFIG_MACH_SUN8I_R40) || \
+    defined(CONFIG_MACH_SUN50I)
 void clock_set_pll11(unsigned int clk, bool sigma_delta_enable)
 {
 	struct sunxi_ccm_reg * const ccm =
diff --git a/arch/arm/mach-sunxi/dram_sun8i_h3.c b/arch/arm/mach-sunxi/dram_sun8i_h3.c
index d681a9df8be2..2d12661a14d3 100644
--- a/arch/arm/mach-sunxi/dram_sun8i_h3.c
+++ b/arch/arm/mach-sunxi/dram_sun8i_h3.c
@@ -70,6 +70,12 @@ static void mctl_set_bit_delays(struct dram_para *para)
 		writel(ACBDLR_WRITE_DELAY(para->ac_delays[i]),
 		       &mctl_ctl->acbdlr[i]);
 
+#ifdef CONFIG_MACH_SUN8I_R40
+	/* DQSn, DMn, DQn output enable bit delay */
+	for (i = 0; i < 4; i++)
+		writel(0x6 << 24, &mctl_ctl->dx[i].sdlr);
+#endif
+
 	setbits_le32(&mctl_ctl->pgcr[0], 1 << 26);
 }
 
@@ -86,6 +92,9 @@ enum {
 	MBUS_PORT_DI            = 9,
 	MBUS_PORT_DE            = 10,
 	MBUS_PORT_DE_CFD        = 11,
+	MBUS_PORT_UNKNOWN1	= 12,
+	MBUS_PORT_UNKNOWN2	= 13,
+	MBUS_PORT_UNKNOWN3	= 14,
 };
 
 enum {
@@ -205,6 +214,42 @@ static void mctl_set_master_priority_h5(void)
 	MBUS_CONF(DE_CFD, true, HIGHEST, 0,  600,  400,  200);
 }
 
+static void mctl_set_master_priority_r40(void)
+{
+	struct sunxi_mctl_com_reg * const mctl_com =
+			(struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
+
+	/* enable bandwidth limit windows and set windows size 1us */
+	writel(399, &mctl_com->tmr);
+	writel((1 << 16), &mctl_com->bwcr);
+
+	/* set cpu high priority */
+	writel(0x00000001, &mctl_com->mapr);
+
+	/* Port 2 is reserved per Allwinner's linux-3.10 source, yet
+	 * they initialise it */
+	MBUS_CONF(     CPU, true, HIGHEST, 0,  300,  260,  150);
+	MBUS_CONF(     GPU, true, HIGHEST, 0,  600,  400,  200);
+	MBUS_CONF(  UNUSED, true, HIGHEST, 0,  512,  256,   96);
+	MBUS_CONF(     DMA, true, HIGHEST, 0,  256,  128,   32);
+	MBUS_CONF(      VE, true, HIGHEST, 0, 1900, 1500, 1000);
+	MBUS_CONF(     CSI, true, HIGHEST, 0,  150,  120,  100);
+	MBUS_CONF(    NAND, true,    HIGH, 0,  256,  128,   64);
+	MBUS_CONF(      SS, true, HIGHEST, 0,  256,  128,   64);
+	MBUS_CONF(      TS, true, HIGHEST, 0,  256,  128,   64);
+	MBUS_CONF(      DI, true,    HIGH, 0, 1024,  256,   64);
+
+	/*
+	 * The port names are probably wrong, but no correct sources
+	 * are available.
+	 */
+	MBUS_CONF(      DE, true,    HIGH, 0,  128,   48,    0);
+	MBUS_CONF(  DE_CFD, true,    HIGH, 0,  384,  256,    0);
+	MBUS_CONF(UNKNOWN1, true, HIGHEST, 0,  512,  384,  256);
+	MBUS_CONF(UNKNOWN2, true, HIGHEST, 2, 8192, 6144, 1024);
+	MBUS_CONF(UNKNOWN3, true,    HIGH, 0, 1280,  144,   64);
+}
+
 static void mctl_set_master_priority(uint16_t socid)
 {
 	switch (socid) {
@@ -217,6 +262,9 @@ static void mctl_set_master_priority(uint16_t socid)
 	case SOCID_H5:
 		mctl_set_master_priority_h5();
 		return;
+	case SOCID_R40:
+		mctl_set_master_priority_r40();
+		return;
 	}
 }
 
@@ -268,6 +316,9 @@ static void mctl_set_timing_params(uint16_t socid, struct dram_para *para)
 	writel(0x18, &mctl_ctl->mr[2]);		/* CWL=8 */
 	writel(0x0, &mctl_ctl->mr[3]);
 
+	if (socid == SOCID_R40)
+		writel(0x3, &mctl_ctl->lp3mr11);	/* odt_en[7:4] */
+
 	/* set DRAM timing */
 	writel(DRAMTMG0_TWTP(twtp) | DRAMTMG0_TFAW(tfaw) |
 	       DRAMTMG0_TRAS_MAX(trasmax) | DRAMTMG0_TRAS(tras),
@@ -383,7 +434,7 @@ static void mctl_h3_zq_calibration_quirk(struct dram_para *para)
 	}
 }
 
-static void mctl_set_cr(struct dram_para *para)
+static void mctl_set_cr(uint16_t socid, struct dram_para *para)
 {
 	struct sunxi_mctl_com_reg * const mctl_com =
 			(struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
@@ -393,6 +444,14 @@ static void mctl_set_cr(struct dram_para *para)
 	       (para->dual_rank ? MCTL_CR_DUAL_RANK : MCTL_CR_SINGLE_RANK) |
 	       MCTL_CR_PAGE_SIZE(para->page_size) |
 	       MCTL_CR_ROW_BITS(para->row_bits), &mctl_com->cr);
+
+	if (socid == SOCID_R40) {
+		if (para->dual_rank)
+			panic("Dual rank memory not supported\n");
+
+		/* Mux pin to A15 address line for single rank memory. */
+		setbits_le32(&mctl_com->cr_r1, MCTL_CR_R1_MUX_A15);
+	}
 }
 
 static void mctl_sys_init(uint16_t socid, struct dram_para *para)
@@ -407,14 +466,14 @@ static void mctl_sys_init(uint16_t socid, struct dram_para *para)
 	clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_MCTL);
 	clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_MCTL);
 	clrbits_le32(&ccm->pll5_cfg, CCM_PLL5_CTRL_EN);
-	if (socid == SOCID_A64)
+	if (socid == SOCID_A64 || socid == SOCID_R40)
 		clrbits_le32(&ccm->pll11_cfg, CCM_PLL11_CTRL_EN);
 	udelay(10);
 
 	clrbits_le32(&ccm->dram_clk_cfg, CCM_DRAMCLK_CFG_RST);
 	udelay(1000);
 
-	if (socid == SOCID_A64) {
+	if (socid == SOCID_A64 || socid == SOCID_R40) {
 		clock_set_pll11(CONFIG_DRAM_CLK * 2 * 1000000, false);
 		clrsetbits_le32(&ccm->dram_clk_cfg,
 				CCM_DRAMCLK_CFG_DIV_MASK |
@@ -459,7 +518,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 
 	unsigned int i;
 
-	mctl_set_cr(para);
+	mctl_set_cr(socid, para);
 	mctl_set_timing_params(socid, para);
 	mctl_set_master_priority(socid);
 
@@ -509,6 +568,13 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 		/* dphy & aphy phase select ? */
 		clrsetbits_le32(&mctl_ctl->pgcr[2], (0x3 << 10) | (0x3 << 8),
 				(0x0 << 10) | (0x3 << 8));
+	} else if (socid == SOCID_R40) {
+		/* dx ddr_clk & hdr_clk dynamic mode (tpr13[9] == 0) */
+		clrbits_le32(&mctl_ctl->pgcr[0], (0x3 << 14) | (0x3 << 12));
+
+		/* dphy & aphy phase select ? */
+		clrsetbits_le32(&mctl_ctl->pgcr[2], (0x3 << 10) | (0x3 << 8),
+				(0x0 << 10) | (0x3 << 8));
 	}
 
 	/* set half DQ */
@@ -535,6 +601,11 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 		mctl_phy_init(PIR_ZCAL | PIR_PLLINIT | PIR_DCAL | PIR_PHYRST |
 			      PIR_DRAMRST | PIR_DRAMINIT | PIR_QSGATE);
 		/* no PIR_QSGATE for H5 ???? */
+	} else if (socid == SOCID_R40) {
+		clrsetbits_le32(&mctl_ctl->zqcr, 0xffffff, CONFIG_DRAM_ZQ);
+
+		mctl_phy_init(PIR_ZCAL | PIR_PLLINIT | PIR_DCAL | PIR_PHYRST |
+			      PIR_DRAMRST | PIR_DRAMINIT);
 	}
 
 	/* detect ranks and bus width */
@@ -554,7 +625,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 			para->bus_width = 16;
 		}
 
-		mctl_set_cr(para);
+		mctl_set_cr(socid, para);
 		udelay(20);
 
 		/* re-train */
@@ -575,7 +646,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 	/* set PGCR3, CKE polarity */
 	if (socid == SOCID_H3)
 		writel(0x00aa0060, &mctl_ctl->pgcr[3]);
-	else if (socid == SOCID_A64 || socid == SOCID_H5)
+	else if (socid == SOCID_A64 || socid == SOCID_H5 || socid == SOCID_R40)
 		writel(0xc0aa0060, &mctl_ctl->pgcr[3]);
 
 	/* power down zq calibration module for power save */
@@ -587,12 +658,12 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
 	return 0;
 }
 
-static void mctl_auto_detect_dram_size(struct dram_para *para)
+static void mctl_auto_detect_dram_size(uint16_t socid, struct dram_para *para)
 {
 	/* detect row address bits */
 	para->page_size = 512;
 	para->row_bits = 16;
-	mctl_set_cr(para);
+	mctl_set_cr(socid, para);
 
 	for (para->row_bits = 11; para->row_bits < 16; para->row_bits++)
 		if (mctl_mem_matches((1 << (para->row_bits + 3)) * para->page_size))
@@ -600,7 +671,7 @@ static void mctl_auto_detect_dram_size(struct dram_para *para)
 
 	/* detect page size */
 	para->page_size = 8192;
-	mctl_set_cr(para);
+	mctl_set_cr(socid, para);
 
 	for (para->page_size = 512; para->page_size < 8192; para->page_size *= 2)
 		if (mctl_mem_matches(para->page_size))
@@ -630,6 +701,22 @@ static void mctl_auto_detect_dram_size(struct dram_para *para)
 	   0,  0,  0,  0,  0,  0,  0,  0,			\
 	   0,  0,  0,  0,  0,  0,  0      }
 
+#define SUN8I_R40_DX_READ_DELAYS				\
+	{{ 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 },	\
+	 { 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 },	\
+	 { 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 },	\
+	 { 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 } }
+#define SUN8I_R40_DX_WRITE_DELAYS				\
+	{{  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  0 },	\
+	 {  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  0 },	\
+	 {  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  0 },	\
+	 {  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  0 } }
+#define SUN8I_R40_AC_DELAYS					\
+	{  0,  0,  3,  0,  0,  0,  0,  0,			\
+	   0,  0,  0,  0,  0,  0,  0,  0,			\
+	   0,  0,  0,  0,  0,  0,  0,  0,			\
+	   0,  0,  0,  0,  0,  0,  0      }
+
 #define SUN50I_A64_DX_READ_DELAYS				\
 	{{ 16, 16, 16, 16, 17, 16, 16, 17, 16,  1,  0 },	\
 	 { 17, 17, 17, 17, 17, 17, 17, 17, 17,  1,  0 },	\
@@ -679,6 +766,10 @@ unsigned long sunxi_dram_init(void)
 		.dx_read_delays  = SUN8I_H3_DX_READ_DELAYS,
 		.dx_write_delays = SUN8I_H3_DX_WRITE_DELAYS,
 		.ac_delays	 = SUN8I_H3_AC_DELAYS,
+#elif defined(CONFIG_MACH_SUN8I_R40)
+		.dx_read_delays  = SUN8I_R40_DX_READ_DELAYS,
+		.dx_write_delays = SUN8I_R40_DX_WRITE_DELAYS,
+		.ac_delays	 = SUN8I_R40_AC_DELAYS,
 #elif defined(CONFIG_MACH_SUN50I)
 		.dx_read_delays  = SUN50I_A64_DX_READ_DELAYS,
 		.dx_write_delays = SUN50I_A64_DX_WRITE_DELAYS,
@@ -696,6 +787,8 @@ unsigned long sunxi_dram_init(void)
  */
 #if defined(CONFIG_MACH_SUN8I_H3)
 	uint16_t socid = SOCID_H3;
+#elif defined(CONFIG_MACH_SUN8I_R40)
+	uint16_t socid = SOCID_R40;
 #elif defined(CONFIG_MACH_SUN50I)
 	uint16_t socid = SOCID_A64;
 #elif defined(CONFIG_MACH_SUN50I_H5)
@@ -716,9 +809,11 @@ unsigned long sunxi_dram_init(void)
 	if (socid == SOCID_H3)
 		writel(0x0c000400, &mctl_ctl->odtcfg);
 
-	if (socid == SOCID_A64 || socid == SOCID_H5) {
+	if (socid == SOCID_A64 || socid == SOCID_H5 || socid == SOCID_R40) {
+		/* VTF enable (tpr13[8] == 1) */
 		setbits_le32(&mctl_ctl->vtfcr,
-			     (socid == SOCID_H5 ? 3 : 2) << 8);
+			     (socid != SOCID_A64 ? 3 : 2) << 8);
+		/* DQ hold disable (tpr13[26] == 1) */
 		clrbits_le32(&mctl_ctl->pgcr[2], (1 << 13));
 	}
 
@@ -726,8 +821,8 @@ unsigned long sunxi_dram_init(void)
 	setbits_le32(&mctl_com->cccr, 1 << 31);
 	udelay(10);
 
-	mctl_auto_detect_dram_size(&para);
-	mctl_set_cr(&para);
+	mctl_auto_detect_dram_size(socid, &para);
+	mctl_set_cr(socid, &para);
 
 	return (1UL << (para.row_bits + 3)) * para.page_size *
 						(para.dual_rank ? 2 : 1);
-- 
2.11.0

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

* [U-Boot] [PATCH 09/12] sunxi: Enable SPL for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (7 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40 Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:54   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address " Chen-Yu Tsai
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

Now that we can do DRAM initialization for the R40, we can enable
SPL support for it.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 board/sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 9854ef0a599e..3df9f8197c57 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -136,6 +136,7 @@ config MACH_SUN8I_R40
 	bool "sun8i (Allwinner R40)"
 	select CPU_V7
 	select SUNXI_GEN_SUN6I
+	select SUPPORT_SPL
 
 config MACH_SUN9I
 	bool "sun9i (Allwinner A80)"
-- 
2.11.0

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

* [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (8 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 09/12] sunxi: Enable SPL " Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:55   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 11/12] sunxi: Add PSCI support " Chen-Yu Tsai
  2017-03-01  7:04 ` [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra Chen-Yu Tsai
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The R40 has the CPUCFG block at the same address as the A20.
Fix it.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
index ea672fe8449a..88c3f138173f 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
@@ -108,7 +108,7 @@ defined(CONFIG_MACH_SUN50I)
 #define SUNXI_TP_BASE			0x01c25000
 #define SUNXI_PMU_BASE			0x01c25400
 
-#ifdef CONFIG_MACH_SUN7I
+#if defined CONFIG_MACH_SUN7I || defined CONFIG_MACH_SUN8I_R40
 #define SUNXI_CPUCFG_BASE		0x01c25c00
 #endif
 
@@ -167,7 +167,9 @@ defined(CONFIG_MACH_SUN50I)
 #define SUNXI_RTC_BASE			0x01f00000
 #define SUNXI_PRCM_BASE			0x01f01400
 
-#if defined CONFIG_SUNXI_GEN_SUN6I && !defined CONFIG_MACH_SUN8I_A83T
+#if defined CONFIG_SUNXI_GEN_SUN6I && \
+    !defined CONFIG_MACH_SUN8I_A83T && \
+    !defined CONFIG_MACH_SUN8I_R40
 #define SUNXI_CPUCFG_BASE		0x01f01c00
 #endif
 
-- 
2.11.0

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

* [U-Boot] [PATCH 11/12] sunxi: Add PSCI support for R40
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (9 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address " Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:55   ` Maxime Ripard
  2017-03-01  7:04 ` [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra Chen-Yu Tsai
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The R40's CPU controls are a combination of sun6i and sun7i.

All controls are in the CPUCFG block, and it seems the R40 does not
have a PRCM block. The core reset, power gating and clamp controls
are grouped like sun6i.

Last, the R40 does not have a secure SRAM block.

This patch adds a PSCI implementation for CPU bring-up and hotplug
for the R40.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/cpu/armv7/sunxi/psci.c | 35 ++++++++++++++++++++++++++++++++---
 board/sunxi/Kconfig             |  3 +++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/psci.c b/arch/arm/cpu/armv7/sunxi/psci.c
index 104dc909bc53..b3a34de1aafe 100644
--- a/arch/arm/cpu/armv7/sunxi/psci.c
+++ b/arch/arm/cpu/armv7/sunxi/psci.c
@@ -27,6 +27,17 @@
 #define	GICD_BASE	(SUNXI_GIC400_BASE + GIC_DIST_OFFSET)
 #define	GICC_BASE	(SUNXI_GIC400_BASE + GIC_CPU_OFFSET_A15)
 
+/*
+ * R40 is different from other single cluster SoCs.
+ *
+ * The power clamps are located in the unused space after the per-core
+ * reset controls for core 3. The secondary core entry address register
+ * is in the SRAM controller address range.
+ */
+#define SUN8I_R40_PWROFF			(0x110)
+#define SUN8I_R40_PWR_CLAMP(cpu)		(0x120 + (cpu) * 0x4)
+#define SUN8I_R40_SRAMC_SOFT_ENTRY_REG0		(0xbc)
+
 static void __secure cp15_write_cntp_tval(u32 tval)
 {
 	asm volatile ("mcr p15, 0, %0, c14, c2, 0" : : "r" (tval));
@@ -68,7 +79,8 @@ static void __secure __mdelay(u32 ms)
 static void __secure clamp_release(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
-	defined(CONFIG_MACH_SUN8I_H3)
+	defined(CONFIG_MACH_SUN8I_H3) || \
+	defined(CONFIG_MACH_SUN8I_R40)
 	u32 tmp = 0x1ff;
 	do {
 		tmp >>= 1;
@@ -82,7 +94,8 @@ static void __secure clamp_release(u32 __maybe_unused *clamp)
 static void __secure clamp_set(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
-	defined(CONFIG_MACH_SUN8I_H3)
+	defined(CONFIG_MACH_SUN8I_H3) || \
+	defined(CONFIG_MACH_SUN8I_R40)
 	writel(0xff, clamp);
 #endif
 }
@@ -115,7 +128,17 @@ static void __secure sunxi_cpu_set_power(int __always_unused cpu, bool on)
 	sunxi_power_switch(&cpucfg->cpu1_pwr_clamp, &cpucfg->cpu1_pwroff,
 			   on, 0);
 }
-#else /* ! CONFIG_MACH_SUN7I */
+#elif defined CONFIG_MACH_SUN8I_R40
+static void __secure sunxi_cpu_set_power(int cpu, bool on)
+{
+	struct sunxi_cpucfg_reg *cpucfg =
+		(struct sunxi_cpucfg_reg *)SUNXI_CPUCFG_BASE;
+
+	sunxi_power_switch((void *)cpucfg + SUN8I_R40_PWR_CLAMP(cpu),
+			   (void *)cpucfg + SUN8I_R40_PWROFF,
+			   on, 0);
+}
+#else /* ! CONFIG_MACH_SUN7I && ! CONFIG_MACH_SUN8I_R40 */
 static void __secure sunxi_cpu_set_power(int cpu, bool on)
 {
 	struct sunxi_prcm_reg *prcm =
@@ -213,7 +236,13 @@ int __secure psci_cpu_on(u32 __always_unused unused, u32 mpidr, u32 pc)
 	psci_save_target_pc(cpu, pc);
 
 	/* Set secondary core power on PC */
+#ifdef CONFIG_MACH_SUN8I_R40
+	/* secondary core entry address is programmed differently */
+	writel((u32)&psci_cpu_entry,
+	       SUNXI_SRAMC_BASE + SUN8I_R40_SRAMC_SOFT_ENTRY_REG0);
+#else
 	writel((u32)&psci_cpu_entry, &cpucfg->priv0);
+#endif
 
 	/* Assert reset on target CPU */
 	writel(0, &cpucfg->cpu[cpu].rst);
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 3df9f8197c57..1967625f7c4f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -135,6 +135,9 @@ config MACH_SUN8I_H3
 config MACH_SUN8I_R40
 	bool "sun8i (Allwinner R40)"
 	select CPU_V7
+	select CPU_V7_HAS_NONSEC
+	select CPU_V7_HAS_VIRT
+	select ARCH_SUPPORT_PSCI
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 
-- 
2.11.0

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

* [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra
  2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
                   ` (10 preceding siblings ...)
  2017-03-01  7:04 ` [U-Boot] [PATCH 11/12] sunxi: Add PSCI support " Chen-Yu Tsai
@ 2017-03-01  7:04 ` Chen-Yu Tsai
  2017-03-01 14:56   ` Maxime Ripard
  11 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01  7:04 UTC (permalink / raw)
  To: u-boot

The Bananapi M2 Ultra is the first publicly available development board
featuring the R40 SoC.

This patch add barebone dtsi/dts files for the R40 and Bananapi M2 Ultra,
as well as a defconfig for it.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/dts/Makefile                        |   2 +
 arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts |  69 ++++++++++
 arch/arm/dts/sun8i-r40.dtsi                  | 183 +++++++++++++++++++++++++++
 board/sunxi/MAINTAINERS                      |   6 +
 configs/Bananapi_M2_Ultra_defconfig          |  15 +++
 5 files changed, 275 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
 create mode 100644 arch/arm/dts/sun8i-r40.dtsi
 create mode 100644 configs/Bananapi_M2_Ultra_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index eeaa9e028457..683cbdca6238 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -295,6 +295,8 @@ dtb-$(CONFIG_MACH_SUN8I_H3) += \
 	sun8i-h3-orangepi-plus2e.dtb \
 	sun8i-h3-nanopi-neo.dtb \
 	sun8i-h3-nanopi-neo-air.dtb
+dtb-$(CONFIG_MACH_SUN8I_R40) += \
+	sun8i-r40-bananapi-m2-ultra.dtb
 dtb-$(CONFIG_MACH_SUN50I_H5) += \
 	sun50i-h5-orangepi-pc2.dtb
 dtb-$(CONFIG_MACH_SUN50I) += \
diff --git a/arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
new file mode 100644
index 000000000000..ab471ab0bffb
--- /dev/null
+++ b/arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 Chen-Yu Tsai <wens@csie.org>
+ *
+ * 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.
+ */
+
+/dts-v1/;
+#include "sun8i-r40.dtsi"
+
+/ {
+	model = "Banana Pi BPI-M2-Ultra";
+	compatible = "sinovoip,bpi-m2-ultra", "allwinner,sun8i-r40";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&i2c0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c0_pins>;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pb_pins>;
+	status = "okay";
+};
diff --git a/arch/arm/dts/sun8i-r40.dtsi b/arch/arm/dts/sun8i-r40.dtsi
new file mode 100644
index 000000000000..48ec2e855a2c
--- /dev/null
+++ b/arch/arm/dts/sun8i-r40.dtsi
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai <wens@csie.org>
+ *
+ * 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/interrupt-controller/arm-gic.h>
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	interrupt-parent = <&gic>;
+
+	aliases {
+	};
+
+	chosen {
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		osc24M: osc24M_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <24000000>;
+		};
+
+		osc32k: osc32k_clk {
+			#clock-cells = <0>;
+			compatible = "fixed-clock";
+			clock-frequency = <32768>;
+			clock-output-names = "osc32k";
+		};
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu at 0 {
+			compatible = "arm,cortex-a7";
+			device_type = "cpu";
+			reg = <0>;
+		};
+
+		cpu at 1 {
+			compatible = "arm,cortex-a7";
+			device_type = "cpu";
+			reg = <1>;
+		};
+
+		cpu at 2 {
+			compatible = "arm,cortex-a7";
+			device_type = "cpu";
+			reg = <2>;
+		};
+
+		cpu at 3 {
+			compatible = "arm,cortex-a7";
+			device_type = "cpu";
+			reg = <3>;
+		};
+	};
+
+	memory at 40000000 {
+		device_type = "memory";
+		reg = <0x40000000 0x80000000>;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		pio: pinctrl at 1c20800 {
+			compatible = "allwinner,sun8i-r40-pinctrl";
+			reg = <0x01c20800 0x400>;
+			interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
+			/* apb should be replaced once CCU is implemented */
+			clocks = <&osc24M>, <&osc24M>, <&osc32k>;
+			clock-names = "apb", "hosc", "losc";
+			gpio-controller;
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			#gpio-cells = <3>;
+
+			i2c0_pins: i2c0_pins {
+				pins = "PB0", "PB1";
+				function = "i2c0";
+				bias-pull-up;
+			};
+
+			uart0_pb_pins: uart0_pb_pins {
+				pins = "PB22", "PB23";
+				function = "uart0";
+				bias-pull-up;
+			};
+		};
+
+		uart0: serial at 1c28000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x01c28000 0x400>;
+			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&osc24M>;
+			status = "disabled";
+		};
+
+		i2c0: i2c at 1c2ac00 {
+			compatible = "allwinner,sun6i-a31-i2c";
+			reg = <0x01c2ac00 0x400>;
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&osc24M>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		gic: interrupt-controller at 1c81000 {
+			compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
+			reg = <0x01c81000 0x1000>,
+			      <0x01c82000 0x1000>,
+			      <0x01c84000 0x2000>,
+			      <0x01c86000 0x2000>;
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+		};
+	};
+
+	timer {
+		compatible = "arm,armv7-timer";
+		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+		clock-frequency = <24000000>;
+		arm,cpu-registers-not-fw-configured;
+	};
+};
diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index 3f211293feb6..fa2d4b227d75 100644
--- a/board/sunxi/MAINTAINERS
+++ b/board/sunxi/MAINTAINERS
@@ -109,6 +109,12 @@ M:	Paul Kocialkowski <contact@paulk.fr>
 S:	Maintained
 F:	configs/Ampe_A76_defconfig
 
+BANANAPI M2 ULTRA BOARD
+M:	Chen-Yu Tsai <wens@csie.org>
+S:	Maintained
+F:	configs/Bananapi_M2_Ultra_defconfig
+F:	arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
+
 COLOMBUS BOARD
 M:	Maxime Ripard <maxime.ripard@free-electrons.com>
 S:	Maintained
diff --git a/configs/Bananapi_M2_Ultra_defconfig b/configs/Bananapi_M2_Ultra_defconfig
new file mode 100644
index 000000000000..8f48b8d74d16
--- /dev/null
+++ b/configs/Bananapi_M2_Ultra_defconfig
@@ -0,0 +1,15 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_MACH_SUN8I_R40=y
+CONFIG_DRAM_CLK=576
+CONFIG_DRAM_ZQ=3881979
+CONFIG_DRAM_ODT_EN=y
+CONFIG_MMC0_CD_PIN="PH13"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-r40-bananapi-m2-ultra"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
-- 
2.11.0

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

* [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40 Chen-Yu Tsai
@ 2017-03-01 10:55   ` Maxime Ripard
  2017-03-01 12:10     ` Chen-Yu Tsai
  0 siblings, 1 reply; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 10:55 UTC (permalink / raw)
  To: u-boot

Hi Chen-Yu

On Wed, Mar 01, 2017 at 03:04:36PM +0800, Chen-Yu Tsai wrote:
> The R40 is the successor to the A20. It is a hybrid of the A20, A33
> and the H3.
> 
> The R40's PIO controller is compatible with the A20,
> Reuse the A20 UART and I2C muxing code by adding the R40's macro.
> 
> The display pipeline is the newer DE 2.0 variant.
> Block enabling video on R40 for now.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  arch/arm/mach-sunxi/board.c    | 10 +++++++---
>  arch/arm/mach-sunxi/cpu_info.c |  2 ++
>  board/sunxi/Kconfig            |  9 +++++++--
>  board/sunxi/board.c            | 19 ++++++++++++++-----
>  4 files changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> index 5e03d039433a..5a74c9717d84 100644
> --- a/arch/arm/mach-sunxi/board.c
> +++ b/arch/arm/mach-sunxi/board.c
> @@ -69,12 +69,14 @@ struct mm_region *mem_map = sunxi_mem_map;
>  static int gpio_init(void)
>  {
>  #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
> +#if defined(CONFIG_MACH_SUN4I) || \
> +    defined(CONFIG_MACH_SUN7I) || \
> +    defined(CONFIG_MACH_SUN8I_R40)
>  	/* disable GPB22,23 as uart0 tx,rx to avoid conflict */
>  	sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
>  	sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
>  #endif
> -#if defined(CONFIG_MACH_SUN8I)
> +#if defined(CONFIG_MACH_SUN8I) && !defined(CONFIG_MACH_SUN8I_R40)
>  	sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUN8I_GPF_UART0);
>  	sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUN8I_GPF_UART0);
>  #else
> @@ -82,7 +84,9 @@ static int gpio_init(void)
>  	sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF_UART0);
>  #endif
>  	sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
> -#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I))
> +#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || \
> +				 defined(CONFIG_MACH_SUN7I) || \
> +				 defined(CONFIG_MACH_SUN8I_R40))
>  	sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB_UART0);
>  	sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB_UART0);
>  	sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
> diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
> index 85633ccec216..7851de299ab5 100644
> --- a/arch/arm/mach-sunxi/cpu_info.c
> +++ b/arch/arm/mach-sunxi/cpu_info.c
> @@ -87,6 +87,8 @@ int print_cpuinfo(void)
>  	printf("CPU:   Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id());
>  #elif defined CONFIG_MACH_SUN8I_H3
>  	printf("CPU:   Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id());
> +#elif defined CONFIG_MACH_SUN8I_R40
> +	printf("CPU:   Allwinner R40 (SUN8I %04x)\n", sunxi_get_sram_id());
>  #elif defined CONFIG_MACH_SUN9I
>  	puts("CPU:   Allwinner A80 (SUN9I)\n");
>  #elif defined CONFIG_MACH_SUN50I
> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> index 3e0e2624737e..8e8b9cd0d5fd 100644
> --- a/board/sunxi/Kconfig
> +++ b/board/sunxi/Kconfig
> @@ -132,6 +132,11 @@ config MACH_SUN8I_H3
>  	select MACH_SUNXI_H3_H5
>  	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
>  
> +config MACH_SUN8I_R40
> +	bool "sun8i (Allwinner R40)"
> +	select CPU_V7
> +	select SUNXI_GEN_SUN6I
> +
>  config MACH_SUN9I
>  	bool "sun9i (Allwinner A80)"
>  	select CPU_V7
> @@ -157,7 +162,7 @@ endchoice
>  # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
>  config MACH_SUN8I
>  	bool
> -	default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T
> +	default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T || MACH_SUN8I_R40

You should really wrap that line too (and CONFIG_VIDEO below).

Once done, you have my
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime
-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/36375585/attachment.sig>

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

* [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC
  2017-03-01  7:04 ` [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC Chen-Yu Tsai
@ 2017-03-01 10:55   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 10:55 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:37PM +0800, Chen-Yu Tsai wrote:
> The R40 SoC uses the AXP221s in I2C mode to supply power.
> 
> Some regulator's common usages have changed, and also the recommended
> voltage for existing usages have changed. Update the defaults to match.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/ce5509b1/attachment.sig>

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

* [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40 Chen-Yu Tsai
@ 2017-03-01 10:56   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 10:56 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:38PM +0800, Chen-Yu Tsai wrote:
> The watchdog found on the R40 SoC is the older variant found on the A20.
> Add the proper "#if defines" to make it work.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/5ba40b69/attachment.sig>

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

* [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings " Chen-Yu Tsai
@ 2017-03-01 10:56   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 10:56 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:39PM +0800, Chen-Yu Tsai wrote:
> The PIO is generally compatible with the A20, except that it routes the
> full 8 bits and eMMC reset pins for mmc2.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/c573c116/attachment.sig>

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

* [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40
  2017-03-01 10:55   ` Maxime Ripard
@ 2017-03-01 12:10     ` Chen-Yu Tsai
  2017-03-01 14:57       ` Maxime Ripard
  0 siblings, 1 reply; 29+ messages in thread
From: Chen-Yu Tsai @ 2017-03-01 12:10 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 1, 2017 at 6:55 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi Chen-Yu
>
> On Wed, Mar 01, 2017 at 03:04:36PM +0800, Chen-Yu Tsai wrote:
>> The R40 is the successor to the A20. It is a hybrid of the A20, A33
>> and the H3.
>>
>> The R40's PIO controller is compatible with the A20,
>> Reuse the A20 UART and I2C muxing code by adding the R40's macro.
>>
>> The display pipeline is the newer DE 2.0 variant.
>> Block enabling video on R40 for now.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>>  arch/arm/mach-sunxi/board.c    | 10 +++++++---
>>  arch/arm/mach-sunxi/cpu_info.c |  2 ++
>>  board/sunxi/Kconfig            |  9 +++++++--
>>  board/sunxi/board.c            | 19 ++++++++++++++-----
>>  4 files changed, 30 insertions(+), 10 deletions(-)
>>
>> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
>> index 5e03d039433a..5a74c9717d84 100644
>> --- a/arch/arm/mach-sunxi/board.c
>> +++ b/arch/arm/mach-sunxi/board.c
>> @@ -69,12 +69,14 @@ struct mm_region *mem_map = sunxi_mem_map;
>>  static int gpio_init(void)
>>  {
>>  #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
>> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
>> +#if defined(CONFIG_MACH_SUN4I) || \
>> +    defined(CONFIG_MACH_SUN7I) || \
>> +    defined(CONFIG_MACH_SUN8I_R40)
>>       /* disable GPB22,23 as uart0 tx,rx to avoid conflict */
>>       sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
>>       sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
>>  #endif
>> -#if defined(CONFIG_MACH_SUN8I)
>> +#if defined(CONFIG_MACH_SUN8I) && !defined(CONFIG_MACH_SUN8I_R40)
>>       sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUN8I_GPF_UART0);
>>       sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUN8I_GPF_UART0);
>>  #else
>> @@ -82,7 +84,9 @@ static int gpio_init(void)
>>       sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF_UART0);
>>  #endif
>>       sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
>> -#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I))
>> +#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || \
>> +                              defined(CONFIG_MACH_SUN7I) || \
>> +                              defined(CONFIG_MACH_SUN8I_R40))
>>       sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB_UART0);
>>       sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB_UART0);
>>       sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
>> diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
>> index 85633ccec216..7851de299ab5 100644
>> --- a/arch/arm/mach-sunxi/cpu_info.c
>> +++ b/arch/arm/mach-sunxi/cpu_info.c
>> @@ -87,6 +87,8 @@ int print_cpuinfo(void)
>>       printf("CPU:   Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id());
>>  #elif defined CONFIG_MACH_SUN8I_H3
>>       printf("CPU:   Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id());
>> +#elif defined CONFIG_MACH_SUN8I_R40
>> +     printf("CPU:   Allwinner R40 (SUN8I %04x)\n", sunxi_get_sram_id());
>>  #elif defined CONFIG_MACH_SUN9I
>>       puts("CPU:   Allwinner A80 (SUN9I)\n");
>>  #elif defined CONFIG_MACH_SUN50I
>> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>> index 3e0e2624737e..8e8b9cd0d5fd 100644
>> --- a/board/sunxi/Kconfig
>> +++ b/board/sunxi/Kconfig
>> @@ -132,6 +132,11 @@ config MACH_SUN8I_H3
>>       select MACH_SUNXI_H3_H5
>>       select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
>>
>> +config MACH_SUN8I_R40
>> +     bool "sun8i (Allwinner R40)"
>> +     select CPU_V7
>> +     select SUNXI_GEN_SUN6I
>> +
>>  config MACH_SUN9I
>>       bool "sun9i (Allwinner A80)"
>>       select CPU_V7
>> @@ -157,7 +162,7 @@ endchoice
>>  # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
>>  config MACH_SUN8I
>>       bool
>> -     default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T
>> +     default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T || MACH_SUN8I_R40
>
> You should really wrap that line too (and CONFIG_VIDEO below).

Kconfig doesn't seem to like line wrapping. I can split both into
1 symbol per line though. Would that be taking it to far?

ChenYu

> Once done, you have my
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>
> Thanks!
> Maxime
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

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

* [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
@ 2017-03-01 14:53   ` Maxime Ripard
  2017-03-01 18:16   ` [U-Boot] [linux-sunxi] " Jernej Škrabec
  1 sibling, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:53 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:40PM +0800, Chen-Yu Tsai wrote:
> According to the BSP released by Banana Pi, the R40 (sun8iw11p1) has
> an extra "PLL lock control" register in the CCU, which controls whether
> the individual PLL lock status bits in each PLL's control register work
> or not.
> 
> This patch enables it for all the PLLs.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/128f00e3/attachment.sig>

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

* [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings
  2017-03-01  7:04 ` [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings Chen-Yu Tsai
@ 2017-03-01 14:53   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:53 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:41PM +0800, Chen-Yu Tsai wrote:
> These values were taken from the Banana Pi M2 Ultra fex file
> found in the released vendor BSP. This is the only publicly
> available R40 device at the time of this writing.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/9099b8c8/attachment.sig>

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

* [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO
  2017-03-01  7:04 ` [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO Chen-Yu Tsai
@ 2017-03-01 14:54   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:54 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:42PM +0800, Chen-Yu Tsai wrote:
> The PIO on the R40 SoC is mostly compatible with the A20.
> Only a few pin functions for mmc2 were added to the PC
> pingroup, to support 8 bit eMMCs.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/7ad303fc/attachment.sig>

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

* [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40 Chen-Yu Tsai
@ 2017-03-01 14:54   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:54 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:43PM +0800, Chen-Yu Tsai wrote:
> The R40 seems to have a variant of the memory controller found in
> the H3 and A64 SoCs. Adapt the code for use on the R40. The changes
> are based on released DRAM code and comparing register dumps from
> boot0.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/88b03a13/attachment.sig>

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

* [U-Boot] [PATCH 09/12] sunxi: Enable SPL for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 09/12] sunxi: Enable SPL " Chen-Yu Tsai
@ 2017-03-01 14:54   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:54 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:44PM +0800, Chen-Yu Tsai wrote:
> Now that we can do DRAM initialization for the R40, we can enable
> SPL support for it.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/5943e96f/attachment.sig>

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

* [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address " Chen-Yu Tsai
@ 2017-03-01 14:55   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:55 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:45PM +0800, Chen-Yu Tsai wrote:
> The R40 has the CPUCFG block at the same address as the A20.
> Fix it.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/0919354a/attachment.sig>

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

* [U-Boot] [PATCH 11/12] sunxi: Add PSCI support for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 11/12] sunxi: Add PSCI support " Chen-Yu Tsai
@ 2017-03-01 14:55   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:55 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:46PM +0800, Chen-Yu Tsai wrote:
> The R40's CPU controls are a combination of sun6i and sun7i.
> 
> All controls are in the CPUCFG block, and it seems the R40 does not
> have a PRCM block. The core reset, power gating and clamp controls
> are grouped like sun6i.
> 
> Last, the R40 does not have a secure SRAM block.
> 
> This patch adds a PSCI implementation for CPU bring-up and hotplug
> for the R40.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/66518763/attachment.sig>

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

* [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra
  2017-03-01  7:04 ` [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra Chen-Yu Tsai
@ 2017-03-01 14:56   ` Maxime Ripard
  0 siblings, 0 replies; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:56 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 01, 2017 at 03:04:47PM +0800, Chen-Yu Tsai wrote:
> The Bananapi M2 Ultra is the first publicly available development board
> featuring the R40 SoC.
> 
> This patch add barebone dtsi/dts files for the R40 and Bananapi M2 Ultra,
> as well as a defconfig for it.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/2e208446/attachment.sig>

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

* [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40
  2017-03-01 12:10     ` Chen-Yu Tsai
@ 2017-03-01 14:57       ` Maxime Ripard
  2017-03-01 15:22         ` [U-Boot] [linux-sunxi] " Icenowy Zheng
  0 siblings, 1 reply; 29+ messages in thread
From: Maxime Ripard @ 2017-03-01 14:57 UTC (permalink / raw)
  To: u-boot

1;4601;0c
On Wed, Mar 01, 2017 at 08:10:55PM +0800, Chen-Yu Tsai wrote:
> On Wed, Mar 1, 2017 at 6:55 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > Hi Chen-Yu
> >
> > On Wed, Mar 01, 2017 at 03:04:36PM +0800, Chen-Yu Tsai wrote:
> >> The R40 is the successor to the A20. It is a hybrid of the A20, A33
> >> and the H3.
> >>
> >> The R40's PIO controller is compatible with the A20,
> >> Reuse the A20 UART and I2C muxing code by adding the R40's macro.
> >>
> >> The display pipeline is the newer DE 2.0 variant.
> >> Block enabling video on R40 for now.
> >>
> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >> ---
> >>  arch/arm/mach-sunxi/board.c    | 10 +++++++---
> >>  arch/arm/mach-sunxi/cpu_info.c |  2 ++
> >>  board/sunxi/Kconfig            |  9 +++++++--
> >>  board/sunxi/board.c            | 19 ++++++++++++++-----
> >>  4 files changed, 30 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> >> index 5e03d039433a..5a74c9717d84 100644
> >> --- a/arch/arm/mach-sunxi/board.c
> >> +++ b/arch/arm/mach-sunxi/board.c
> >> @@ -69,12 +69,14 @@ struct mm_region *mem_map = sunxi_mem_map;
> >>  static int gpio_init(void)
> >>  {
> >>  #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
> >> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
> >> +#if defined(CONFIG_MACH_SUN4I) || \
> >> +    defined(CONFIG_MACH_SUN7I) || \
> >> +    defined(CONFIG_MACH_SUN8I_R40)
> >>       /* disable GPB22,23 as uart0 tx,rx to avoid conflict */
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
> >>  #endif
> >> -#if defined(CONFIG_MACH_SUN8I)
> >> +#if defined(CONFIG_MACH_SUN8I) && !defined(CONFIG_MACH_SUN8I_R40)
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUN8I_GPF_UART0);
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUN8I_GPF_UART0);
> >>  #else
> >> @@ -82,7 +84,9 @@ static int gpio_init(void)
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF_UART0);
> >>  #endif
> >>       sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
> >> -#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I))
> >> +#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || \
> >> +                              defined(CONFIG_MACH_SUN7I) || \
> >> +                              defined(CONFIG_MACH_SUN8I_R40))
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB_UART0);
> >>       sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB_UART0);
> >>       sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
> >> diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
> >> index 85633ccec216..7851de299ab5 100644
> >> --- a/arch/arm/mach-sunxi/cpu_info.c
> >> +++ b/arch/arm/mach-sunxi/cpu_info.c
> >> @@ -87,6 +87,8 @@ int print_cpuinfo(void)
> >>       printf("CPU:   Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id());
> >>  #elif defined CONFIG_MACH_SUN8I_H3
> >>       printf("CPU:   Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id());
> >> +#elif defined CONFIG_MACH_SUN8I_R40
> >> +     printf("CPU:   Allwinner R40 (SUN8I %04x)\n", sunxi_get_sram_id());
> >>  #elif defined CONFIG_MACH_SUN9I
> >>       puts("CPU:   Allwinner A80 (SUN9I)\n");
> >>  #elif defined CONFIG_MACH_SUN50I
> >> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> >> index 3e0e2624737e..8e8b9cd0d5fd 100644
> >> --- a/board/sunxi/Kconfig
> >> +++ b/board/sunxi/Kconfig
> >> @@ -132,6 +132,11 @@ config MACH_SUN8I_H3
> >>       select MACH_SUNXI_H3_H5
> >>       select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
> >>
> >> +config MACH_SUN8I_R40
> >> +     bool "sun8i (Allwinner R40)"
> >> +     select CPU_V7
> >> +     select SUNXI_GEN_SUN6I
> >> +
> >>  config MACH_SUN9I
> >>       bool "sun9i (Allwinner A80)"
> >>       select CPU_V7
> >> @@ -157,7 +162,7 @@ endchoice
> >>  # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
> >>  config MACH_SUN8I
> >>       bool
> >> -     default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T
> >> +     default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T || MACH_SUN8I_R40
> >
> > You should really wrap that line too (and CONFIG_VIDEO below).
> 
> Kconfig doesn't seem to like line wrapping. I can split both into
> 1 symbol per line though. Would that be taking it to far?

Something like:

default y if MACH_SUN8I_A23
default y if MACH_SUN8I_A33

?

I didn't know it was possible.. But if it works, yes, please that will
even be easier to review / extend.

Thanks!
Maxime

-- 
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: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/bd777471/attachment.sig>

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

* [U-Boot] [linux-sunxi] Re: [PATCH 01/12] sunxi: Add initial support for R40
  2017-03-01 14:57       ` Maxime Ripard
@ 2017-03-01 15:22         ` Icenowy Zheng
  0 siblings, 0 replies; 29+ messages in thread
From: Icenowy Zheng @ 2017-03-01 15:22 UTC (permalink / raw)
  To: u-boot



01.03.2017, 22:57, "Maxime Ripard" <maxime.ripard@free-electrons.com>:
> 1;4601;0c
> On Wed, Mar 01, 2017 at 08:10:55PM +0800, Chen-Yu Tsai wrote:
>>  On Wed, Mar 1, 2017 at 6:55 PM, Maxime Ripard
>>  <maxime.ripard@free-electrons.com> wrote:
>>  > Hi Chen-Yu
>>  >
>>  > On Wed, Mar 01, 2017 at 03:04:36PM +0800, Chen-Yu Tsai wrote:
>>  >> The R40 is the successor to the A20. It is a hybrid of the A20, A33
>>  >> and the H3.
>>  >>
>>  >> The R40's PIO controller is compatible with the A20,
>>  >> Reuse the A20 UART and I2C muxing code by adding the R40's macro.
>>  >>
>>  >> The display pipeline is the newer DE 2.0 variant.
>>  >> Block enabling video on R40 for now.
>>  >>
>>  >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>>  >> ---
>>  >> arch/arm/mach-sunxi/board.c | 10 +++++++---
>>  >> arch/arm/mach-sunxi/cpu_info.c | 2 ++
>>  >> board/sunxi/Kconfig | 9 +++++++--
>>  >> board/sunxi/board.c | 19 ++++++++++++++-----
>>  >> 4 files changed, 30 insertions(+), 10 deletions(-)
>>  >>
>>  >> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
>>  >> index 5e03d039433a..5a74c9717d84 100644
>>  >> --- a/arch/arm/mach-sunxi/board.c
>>  >> +++ b/arch/arm/mach-sunxi/board.c
>>  >> @@ -69,12 +69,14 @@ struct mm_region *mem_map = sunxi_mem_map;
>>  >> static int gpio_init(void)
>>  >> {
>>  >> #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
>>  >> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
>>  >> +#if defined(CONFIG_MACH_SUN4I) || \
>>  >> + defined(CONFIG_MACH_SUN7I) || \
>>  >> + defined(CONFIG_MACH_SUN8I_R40)
>>  >> /* disable GPB22,23 as uart0 tx,rx to avoid conflict */
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
>>  >> #endif
>>  >> -#if defined(CONFIG_MACH_SUN8I)
>>  >> +#if defined(CONFIG_MACH_SUN8I) && !defined(CONFIG_MACH_SUN8I_R40)
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUN8I_GPF_UART0);
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUN8I_GPF_UART0);
>>  >> #else
>>  >> @@ -82,7 +84,9 @@ static int gpio_init(void)
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF_UART0);
>>  >> #endif
>>  >> sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
>>  >> -#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I))
>>  >> +#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_MACH_SUN4I) || \
>>  >> + defined(CONFIG_MACH_SUN7I) || \
>>  >> + defined(CONFIG_MACH_SUN8I_R40))
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB_UART0);
>>  >> sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB_UART0);
>>  >> sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
>>  >> diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
>>  >> index 85633ccec216..7851de299ab5 100644
>>  >> --- a/arch/arm/mach-sunxi/cpu_info.c
>>  >> +++ b/arch/arm/mach-sunxi/cpu_info.c
>>  >> @@ -87,6 +87,8 @@ int print_cpuinfo(void)
>>  >> printf("CPU: Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id());
>>  >> #elif defined CONFIG_MACH_SUN8I_H3
>>  >> printf("CPU: Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id());
>>  >> +#elif defined CONFIG_MACH_SUN8I_R40
>>  >> + printf("CPU: Allwinner R40 (SUN8I %04x)\n", sunxi_get_sram_id());
>>  >> #elif defined CONFIG_MACH_SUN9I
>>  >> puts("CPU: Allwinner A80 (SUN9I)\n");
>>  >> #elif defined CONFIG_MACH_SUN50I
>>  >> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>>  >> index 3e0e2624737e..8e8b9cd0d5fd 100644
>>  >> --- a/board/sunxi/Kconfig
>>  >> +++ b/board/sunxi/Kconfig
>>  >> @@ -132,6 +132,11 @@ config MACH_SUN8I_H3
>>  >> select MACH_SUNXI_H3_H5
>>  >> select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
>>  >>
>>  >> +config MACH_SUN8I_R40
>>  >> + bool "sun8i (Allwinner R40)"
>>  >> + select CPU_V7
>>  >> + select SUNXI_GEN_SUN6I
>>  >> +
>>  >> config MACH_SUN9I
>>  >> bool "sun9i (Allwinner A80)"
>>  >> select CPU_V7
>>  >> @@ -157,7 +162,7 @@ endchoice
>>  >> # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
>>  >> config MACH_SUN8I
>>  >> bool
>>  >> - default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T
>>  >> + default y if MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUNXI_H3_H5 || MACH_SUN8I_A83T || MACH_SUN8I_R40
>>  >
>>  > You should really wrap that line too (and CONFIG_VIDEO below).
>>
>>  Kconfig doesn't seem to like line wrapping. I can split both into
>>  1 symbol per line though. Would that be taking it to far?

Kconfig can accept line wrapping. But you need \.

>
> Something like:
>
> default y if MACH_SUN8I_A23
> default y if MACH_SUN8I_A33
>
> ?
>
> I didn't know it was possible.. But if it works, yes, please that will
> even be easier to review / extend.
>
> Thanks!
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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

* [U-Boot] [linux-sunxi] [PATCH 05/12] sunxi: Set PLL lock enable bits for R40
  2017-03-01  7:04 ` [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
  2017-03-01 14:53   ` Maxime Ripard
@ 2017-03-01 18:16   ` Jernej Škrabec
  1 sibling, 0 replies; 29+ messages in thread
From: Jernej Škrabec @ 2017-03-01 18:16 UTC (permalink / raw)
  To: u-boot

Hi!

Dne sreda, 01. marec 2017 ob 08:04:40 CET je Chen-Yu Tsai napisal(a):
> According to the BSP released by Banana Pi, the R40 (sun8iw11p1) has
> an extra "PLL lock control" register in the CCU, which controls whether
> the individual PLL lock status bits in each PLL's control register work
> or not.
> 

This register is also present on A64, but I'm not sure if it is needed there.

Best regards,
Jernej

> This patch enables it for all the PLLs.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 2 ++
>  arch/arm/mach-sunxi/clock_sun6i.c             | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
> b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h index
> 1bfb48bd52df..1aefd5a64c1f 100644
> --- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
> +++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
> @@ -142,6 +142,8 @@ struct sunxi_ccm_reg {
>  	u32 apb2_reset_cfg;	/* 0x2d8 APB2 Reset config */
>  	u32 reserved25[5];
>  	u32 ccu_sec_switch;	/* 0x2f0 CCU Security Switch, H3 only */
> +	u32 reserved26[11];
> +	u32 pll_lock_ctrl;	/* 0x320 PLL lock control, R40 only */
>  };
> 
>  /* apb2 bit field */
> diff --git a/arch/arm/mach-sunxi/clock_sun6i.c
> b/arch/arm/mach-sunxi/clock_sun6i.c index 4762fbf0c3f0..3c8c53fcf76b 100644
> --- a/arch/arm/mach-sunxi/clock_sun6i.c
> +++ b/arch/arm/mach-sunxi/clock_sun6i.c
> @@ -35,6 +35,11 @@ void clock_init_safe(void)
>  	clrbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK);
>  #endif
> 
> +#ifdef CONFIG_MACH_SUN8I_R40
> +	/* Set PLL lock enable bits and switch to old lock mode */
> +	writel(GENMASK(12, 0), &ccm->pll_lock_ctrl);
> +#endif
> +
>  	clock_set_pll1(408000000);
> 
>  	writel(PLL6_CFG_DEFAULT, &ccm->pll6_cfg);
> --
> 2.11.0
> 
> --
> You received this message because you are subscribed to the Google Groups
> "linux-sunxi" group. To unsubscribe from this group and stop receiving
> emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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

end of thread, other threads:[~2017-03-01 18:16 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01  7:04 [U-Boot] [PATCH 00/12] sunxi: Add support for R40 SoC Chen-Yu Tsai
2017-03-01  7:04 ` [U-Boot] [PATCH 01/12] sunxi: Add initial support for R40 Chen-Yu Tsai
2017-03-01 10:55   ` Maxime Ripard
2017-03-01 12:10     ` Chen-Yu Tsai
2017-03-01 14:57       ` Maxime Ripard
2017-03-01 15:22         ` [U-Boot] [linux-sunxi] " Icenowy Zheng
2017-03-01  7:04 ` [U-Boot] [PATCH 02/12] sunxi: Enable AXP221s in I2C mode with the R40 SoC Chen-Yu Tsai
2017-03-01 10:55   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 03/12] sunxi: Fix watchdog reset function for R40 Chen-Yu Tsai
2017-03-01 10:56   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 04/12] sunxi: Add mmc[1-3] pinmux settings " Chen-Yu Tsai
2017-03-01 10:56   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 05/12] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
2017-03-01 14:53   ` Maxime Ripard
2017-03-01 18:16   ` [U-Boot] [linux-sunxi] " Jernej Škrabec
2017-03-01  7:04 ` [U-Boot] [PATCH 06/12] sunxi: Provide defaults for R40 DRAM settings Chen-Yu Tsai
2017-03-01 14:53   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 07/12] gpio: sunxi: Add compatible string for R40 PIO Chen-Yu Tsai
2017-03-01 14:54   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 08/12] sunxi: Use H3/A64 DRAM initialization code for R40 Chen-Yu Tsai
2017-03-01 14:54   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 09/12] sunxi: Enable SPL " Chen-Yu Tsai
2017-03-01 14:54   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 10/12] sunxi: Fix CPUCFG address " Chen-Yu Tsai
2017-03-01 14:55   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 11/12] sunxi: Add PSCI support " Chen-Yu Tsai
2017-03-01 14:55   ` Maxime Ripard
2017-03-01  7:04 ` [U-Boot] [PATCH 12/12] sunxi: Add support for Bananapi M2 Ultra Chen-Yu Tsai
2017-03-01 14:56   ` Maxime Ripard

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