Skip to contentSkip to conversation

sunxi: Add support for R40 SoC

PATCH Superseded Chen-Yu Tsai 4 participants 29 messages Mar 1, 2017

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover sunxi: Add support for R40 SoC

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
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/12 sunxi: Add initial support for R40

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.

---
 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(-)
arch/arm/mach-sunxi/board.c +7 -3
index 5e03d039433a..5a74c9717d84 100644
@@ -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);
arch/arm/mach-sunxi/cpu_info.c +2 -0
index 85633ccec216..7851de299ab5 100644
@@ -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
board/sunxi/Kconfig +7 -2
index 3e0e2624737e..8e8b9cd0d5fd 100644
@@ -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
board/sunxi/board.c +14 -5
index b9660128e5e7..495cb591a9fb 100644
@@ -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);
Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/12 sunxi: Add initial support for R40

Hi Chen-Yu

Quoted 79 lines · Chen-Yu Tsai

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.

---
 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(-)
arch/arm/mach-sunxi/board.c +7 -3
index 5e03d039433a..5a74c9717d84 100644
@@ -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);
arch/arm/mach-sunxi/cpu_info.c +2 -0
index 85633ccec216..7851de299ab5 100644
@@ -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
board/sunxi/Kconfig +5 -0
index 3e0e2624737e..8e8b9cd0d5fd 100644
@@ -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

board/sunxi/Kconfig endchoice · line 165

Quoted 5 lines
board/sunxi/Kconfig +1 -1
@@ -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

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/36375585/attachment.sig>
#3 lore raw

PATCH 1/12 sunxi: Add initial support for R40

Quoted 73 lines · Maxime Ripard

Hi Chen-Yu

Quoted 70 lines · Chen-Yu Tsai

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.

---
 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(-)
arch/arm/mach-sunxi/board.c +7 -3
index 5e03d039433a..5a74c9717d84 100644
@@ -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);
arch/arm/mach-sunxi/cpu_info.c +2 -0
index 85633ccec216..7851de299ab5 100644
@@ -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
board/sunxi/Kconfig +0 -0
index 3e0e2624737e..8e8b9cd0d5fd 100644
@@ -132,6 +132,11 @@ config MACH_SUN8I_H3
      select MACH_SUNXI_H3_H5
      select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
Quoted 16 lines
Quoted 9 lines
board/sunxi/Kconfig +5 -0
+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

board/sunxi/Kconfig endchoice · line 165

Quoted 5 lines
board/sunxi/Kconfig +1 -1
@@ -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

Quoted 9 lines

Once done, you have my

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

#4 lore raw

PATCH 1/12 sunxi: Add initial support for R40

1;4601;0c

Quoted 92 lines · Chen-Yu Tsai
Quoted 73 lines · Maxime Ripard

Hi Chen-Yu

Quoted 70 lines · Chen-Yu Tsai

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.

---
 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(-)
arch/arm/mach-sunxi/board.c +7 -3
index 5e03d039433a..5a74c9717d84 100644
@@ -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);
arch/arm/mach-sunxi/cpu_info.c +2 -0
index 85633ccec216..7851de299ab5 100644
@@ -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
board/sunxi/Kconfig +0 -0
index 3e0e2624737e..8e8b9cd0d5fd 100644
@@ -132,6 +132,11 @@ config MACH_SUN8I_H3
      select MACH_SUNXI_H3_H5
      select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
Quoted 16 lines
Quoted 9 lines
board/sunxi/Kconfig +5 -0
+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

board/sunxi/Kconfig endchoice · line 165

Quoted 5 lines
board/sunxi/Kconfig +1 -1
@@ -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).

Quoted 2 lines

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

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/bd777471/attachment.sig>
#5 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH 01/12] sunxi: Add initial support for R40

01.03.2017, 22:57, "Maxime Ripard" <[email protected]>:

Quoted 96 lines

1;4601;0c

Quoted 94 lines · Chen-Yu Tsai

 On Wed, Mar 1, 2017 at 6:55 PM, Maxime Ripard <[email protected]> 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 <[email protected]>
 >> ---
 >> 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 \.

Quoted 23 lines

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.

#6 lore raw

PATCH 2/12 sunxi: Enable AXP221s in I2C mode with the R40 SoC

In reply to Chen-Yu Tsai

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.

---
 arch/arm/mach-sunxi/pmic_bus.c |  7 +++++++
 board/sunxi/Kconfig            |  2 +-
 drivers/power/Kconfig          | 16 ++++++++++------
 3 files changed, 18 insertions(+), 7 deletions(-)
arch/arm/mach-sunxi/pmic_bus.c +7 -0
index 7c57f02792b9..f917c3e070a5 100644
@@ -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
board/sunxi/Kconfig +1 -1
index 8e8b9cd0d5fd..e89ddf626289 100644
@@ -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---
drivers/power/Kconfig +10 -6
index 64e5bc2f74b4..911ecb1144a6 100644
@@ -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.
Signature · 1 line
2.11.0
#7 lore raw

PATCH 2/12 sunxi: Enable AXP221s in I2C mode with the R40 SoC

Quoted 6 lines · Chen-Yu Tsai

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/ce5509b1/attachment.sig>
#8 lore raw

PATCH 3/12 sunxi: Fix watchdog reset function for R40

In reply to Chen-Yu Tsai

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

---
 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(-)
arch/arm/include/asm/arch-sunxi/timer.h +2 -3
index a665309803cb..ccdf942534a4 100644
@@ -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
arch/arm/include/asm/arch-sunxi/watchdog.h +4 -1
index 8108be97bab0..ce6d66485609 100644
@@ -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)
arch/arm/mach-sunxi/board.c +2 -3
index 5a74c9717d84..6ce07dfe0fd7 100644
@@ -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;
 
Signature · 1 line
2.11.0
#9 lore raw

PATCH 3/12 sunxi: Fix watchdog reset function for R40

Quoted 4 lines · Chen-Yu Tsai

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

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/5ba40b69/attachment.sig>
#10 lore raw

PATCH 4/12 sunxi: Add mmc[1-3] pinmux settings for R40

In reply to Chen-Yu Tsai

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

---
 board/sunxi/board.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
board/sunxi/board.c +15 -2
index 495cb591a9fb..21ce8348922c 100644
@@ -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);
Signature · 1 line
2.11.0
#11 lore raw

PATCH 4/12 sunxi: Add mmc[1-3] pinmux settings for R40

Quoted 4 lines · Chen-Yu Tsai

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

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/c573c116/attachment.sig>
#12 lore raw

PATCH 5/12 sunxi: Set PLL lock enable bits for R40

In reply to Chen-Yu Tsai

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.

---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 2 ++
 arch/arm/mach-sunxi/clock_sun6i.c             | 5 +++++
 2 files changed, 7 insertions(+)
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +2 -0
index 1bfb48bd52df..1aefd5a64c1f 100644
@@ -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 */
arch/arm/mach-sunxi/clock_sun6i.c +5 -0
index 4762fbf0c3f0..3c8c53fcf76b 100644
@@ -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);
Signature · 1 line
2.11.0
#13 lore raw

PATCH 5/12 sunxi: Set PLL lock enable bits for R40

Quoted 8 lines · Chen-Yu Tsai

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/128f00e3/attachment.sig>
#14 lore raw

PATCH 5/12 sunxi: Set PLL lock enable bits for R40

In reply to Chen-Yu Tsai

Hi!

Dne sreda, 01. marec 2017 ob 08:04:40 CET je Chen-Yu Tsai napisal(a):

Quoted 5 lines

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

Quoted 46 lines

This patch enables it for all the PLLs.

---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 2 ++
 arch/arm/mach-sunxi/clock_sun6i.c             | 5 +++++
 2 files changed, 7 insertions(+)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h index 1bfb48bd52df..1aefd5a64c1f 100644

arch/arm/include/asm/arch-sunxi/clock_sun6i.h +2 -0
@@ -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 */
(quoted diff) +0 -0

b/arch/arm/mach-sunxi/clock_sun6i.c index 4762fbf0c3f0..3c8c53fcf76b 100644

arch/arm/mach-sunxi/clock_sun6i.c +5 -1
@@ -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.

#15 lore raw

PATCH 6/12 sunxi: Provide defaults for R40 DRAM settings

In reply to Chen-Yu Tsai

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.

---
 board/sunxi/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
board/sunxi/Kconfig +3 -0
index e89ddf626289..9854ef0a599e 100644
@@ -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).
Signature · 1 line
2.11.0
#16 lore raw

PATCH 6/12 sunxi: Provide defaults for R40 DRAM settings

Quoted 5 lines · Chen-Yu Tsai

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.

maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/9099b8c8/attachment.sig>
#17 lore raw

PATCH 7/12 gpio: sunxi: Add compatible string for R40 PIO

In reply to Chen-Yu Tsai

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.

---
 drivers/gpio/sunxi_gpio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/sunxi_gpio.c +1 -0
index 8d2bb18504ae..3f40e8383001 100644
@@ -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),
Signature · 1 line
2.11.0
#18 lore raw

PATCH 7/12 gpio: sunxi: Add compatible string for R40 PIO

Quoted 5 lines · Chen-Yu Tsai

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/7ad303fc/attachment.sig>
#19 lore raw

PATCH 8/12 sunxi: Use H3/A64 DRAM initialization code for R40

In reply to Chen-Yu Tsai

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.

---
 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(-)
arch/arm/include/asm/arch-sunxi/cpu.h +1 -0
index e8e670e7e903..caec86526417 100644
@@ -16,5 +16,6 @@
 #define SOCID_A64	0x1689
 #define SOCID_H3	0x1680
 #define SOCID_H5	0x1718
+#define SOCID_R40	0x1701
 
 #endif /* _SUNXI_CPU_H */
arch/arm/include/asm/arch-sunxi/dram.h +3 -1
index 1dc82205b7df..f452f889f928 100644
@@ -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>
arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h +17 -3
index 25d07d9863c9..2770986b613f 100644
@@ -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 */
arch/arm/mach-sunxi/Makefile +1 -0
index efab4811ee54..5510aa54353f 100644
@@ -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
arch/arm/mach-sunxi/clock_sun6i.c +3 -1
index 3c8c53fcf76b..9068c88ab2f8 100644
@@ -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 =
arch/arm/mach-sunxi/dram_sun8i_h3.c +108 -13

252 lines not on this page · raw message

Signature · 1 line
2.11.0
#20 lore raw

PATCH 8/12 sunxi: Use H3/A64 DRAM initialization code for R40

Quoted 6 lines · Chen-Yu Tsai

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/88b03a13/attachment.sig>
#21 lore raw

PATCH 9/12 sunxi: Enable SPL for R40

In reply to Chen-Yu Tsai

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

---
 board/sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)
board/sunxi/Kconfig +1 -0
index 9854ef0a599e..3df9f8197c57 100644
@@ -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)"
Signature · 1 line
2.11.0
#22 lore raw

PATCH 9/12 sunxi: Enable SPL for R40

Quoted 4 lines · Chen-Yu Tsai

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

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/5943e96f/attachment.sig>
#23 lore raw

PATCH 10/12 sunxi: Fix CPUCFG address for R40

In reply to Chen-Yu Tsai

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

---
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +4 -2
index ea672fe8449a..88c3f138173f 100644
@@ -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
 
Signature · 1 line
2.11.0
#24 lore raw

PATCH 10/12 sunxi: Fix CPUCFG address for R40

Quoted 4 lines · Chen-Yu Tsai

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

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/0919354a/attachment.sig>
#25 lore raw

PATCH 11/12 sunxi: Add PSCI support for R40

In reply to Chen-Yu Tsai

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.

---
 arch/arm/cpu/armv7/sunxi/psci.c | 35 ++++++++++++++++++++++++++++++++---
 board/sunxi/Kconfig             |  3 +++
 2 files changed, 35 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/sunxi/psci.c +32 -3
index 104dc909bc53..b3a34de1aafe 100644
@@ -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);
board/sunxi/Kconfig +3 -0
index 3df9f8197c57..1967625f7c4f 100644
@@ -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
 
Signature · 1 line
2.11.0
#26 lore raw

PATCH 11/12 sunxi: Add PSCI support for R40

Quoted 6 lines · Chen-Yu Tsai

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.

Quoted 6 lines

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/66518763/attachment.sig>
#27 lore raw

PATCH 12/12 sunxi: Add support for Bananapi M2 Ultra

In reply to Chen-Yu Tsai

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.

---
 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
arch/arm/dts/Makefile +2 -0
index eeaa9e028457..683cbdca6238 100644
@@ -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) += \
arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts new file +69 -0

69 lines not on this page · raw message

arch/arm/dts/sun8i-r40.dtsi new file +183 -0

183 lines not on this page · raw message

board/sunxi/MAINTAINERS +6 -0
index 3f211293feb6..fa2d4b227d75 100644
@@ -109,6 +109,12 @@ M:	Paul Kocialkowski <[email protected]>
 S:	Maintained
 F:	configs/Ampe_A76_defconfig
 
+BANANAPI M2 ULTRA BOARD
+M:	Chen-Yu Tsai <[email protected]>
+S:	Maintained
+F:	configs/Bananapi_M2_Ultra_defconfig
+F:	arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts
+
 COLOMBUS BOARD
 M:	Maxime Ripard <[email protected]>
 S:	Maintained
configs/Bananapi_M2_Ultra_defconfig new file +15 -0
new file mode 100644
index 000000000000..8f48b8d74d16
@@ -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
Signature · 1 line
2.11.0
#28 lore raw

PATCH 12/12 sunxi: Add support for Bananapi M2 Ultra

Quoted 7 lines · Chen-Yu Tsai

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.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/2e208446/attachment.sig>