Re: [U-Boot] [PATCH v3 05/10] sunxi: Add sun4i support

2014-07-23 Thread Siarhei Siamashka
On Mon,  9 Jun 2014 11:36:57 +0200
Hans de Goede hdego...@redhat.com wrote:

 Add support for the Allwinner A10 SoC also known as the Allwinner sun4i 
 family,
 and add the Cubieboard board which uses the A10 SoC.
 
 Compared to sun7 only the DRAM controller is a bit different:
 -Controller reset bits are inverted, but only for Rev. A
 -Different hpcr values
 -No MBUS on sun4i
 -Various other initialization changes
 
 Signed-off-by: Henrik Nordstrom hen...@henriknordstrom.net
 Signed-off-by: Stefan Roese s...@denx.de
 Signed-off-by: Oliver Schinagl oli...@schinagl.nl
 Signed-off-by: Hans de Goede hdego...@redhat.com
 Acked-by: Ian Campbell i...@hellion.org.uk

 ---
  arch/arm/cpu/armv7/sunxi/Makefile   |  2 +
  arch/arm/cpu/armv7/sunxi/cpu_info.c |  7 
  arch/arm/cpu/armv7/sunxi/dram.c | 81 
 +++--
  board/sunxi/Makefile|  1 +
  board/sunxi/dram_cubieboard.c   | 31 ++
  boards.cfg  |  1 +
  include/configs/sun4i.h | 23 +++
  7 files changed, 143 insertions(+), 3 deletions(-)
  create mode 100644 board/sunxi/dram_cubieboard.c
  create mode 100644 include/configs/sun4i.h

This patch is piling up a lot of various loosely related changes.
Isn't the addition of Cubieboard to boards.cfg kind of orthogonal
to the sun4i SoC variant support? This makes cherry picking or
reverting the patch unnecessarily difficult.

-- 
Best regards,
Siarhei Siamashka
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 05/10] sunxi: Add sun4i support

2014-06-09 Thread Hans de Goede
Add support for the Allwinner A10 SoC also known as the Allwinner sun4i family,
and add the Cubieboard board which uses the A10 SoC.

Compared to sun7 only the DRAM controller is a bit different:
-Controller reset bits are inverted, but only for Rev. A
-Different hpcr values
-No MBUS on sun4i
-Various other initialization changes

Signed-off-by: Henrik Nordstrom hen...@henriknordstrom.net
Signed-off-by: Stefan Roese s...@denx.de
Signed-off-by: Oliver Schinagl oli...@schinagl.nl
Signed-off-by: Hans de Goede hdego...@redhat.com
Acked-by: Ian Campbell i...@hellion.org.uk
---
 arch/arm/cpu/armv7/sunxi/Makefile   |  2 +
 arch/arm/cpu/armv7/sunxi/cpu_info.c |  7 
 arch/arm/cpu/armv7/sunxi/dram.c | 81 +++--
 board/sunxi/Makefile|  1 +
 board/sunxi/dram_cubieboard.c   | 31 ++
 boards.cfg  |  1 +
 include/configs/sun4i.h | 23 +++
 7 files changed, 143 insertions(+), 3 deletions(-)
 create mode 100644 board/sunxi/dram_cubieboard.c
 create mode 100644 include/configs/sun4i.h

diff --git a/arch/arm/cpu/armv7/sunxi/Makefile 
b/arch/arm/cpu/armv7/sunxi/Makefile
index a64bfa1..856d353 100644
--- a/arch/arm/cpu/armv7/sunxi/Makefile
+++ b/arch/arm/cpu/armv7/sunxi/Makefile
@@ -11,6 +11,7 @@ obj-y += timer.o
 obj-y  += board.o
 obj-y  += clock.o
 obj-y  += pinmux.o
+obj-$(CONFIG_SUN4I)+= clock_sun4i.o
 obj-$(CONFIG_SUN7I)+= clock_sun4i.o
 
 ifndef CONFIG_SPL_BUILD
@@ -18,6 +19,7 @@ obj-y += cpu_info.o
 endif
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SUN4I)+= dram.o
 obj-$(CONFIG_SUN7I)+= dram.o
 ifdef CONFIG_SPL_FEL
 obj-y  += start.o
diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c 
b/arch/arm/cpu/armv7/sunxi/cpu_info.c
index b4c3d5c..b4b5089 100644
--- a/arch/arm/cpu/armv7/sunxi/cpu_info.c
+++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c
@@ -13,7 +13,14 @@
 #ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
 {
+#ifdef CONFIG_SUN4I
+   puts(CPU:   Allwinner A10 (SUN4I)\n);
+#elif defined CONFIG_SUN7I
puts(CPU:   Allwinner A20 (SUN7I)\n);
+#else
+#warning Please update cpu_info.c with correct CPU information
+   puts(CPU:   SUNXI Family\n);
+#endif
return 0;
 }
 #endif
diff --git a/arch/arm/cpu/armv7/sunxi/dram.c b/arch/arm/cpu/armv7/sunxi/dram.c
index b43c4b4..1de7529 100644
--- a/arch/arm/cpu/armv7/sunxi/dram.c
+++ b/arch/arm/cpu/armv7/sunxi/dram.c
@@ -53,16 +53,37 @@ static void mctl_ddr3_reset(void)
struct sunxi_dram_reg *dram =
(struct sunxi_dram_reg *)SUNXI_DRAMC_BASE;
 
-   clrbits_le32(dram-mcr, DRAM_MCR_RESET);
-   udelay(2);
-   setbits_le32(dram-mcr, DRAM_MCR_RESET);
+#ifdef CONFIG_SUN4I
+   struct sunxi_timer_reg *timer =
+   (struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
+   u32 reg_val;
+
+   writel(0, timer-cpu_cfg);
+   reg_val = readl(timer-cpu_cfg);
+
+   if ((reg_val  CPU_CFG_CHIP_VER_MASK) !=
+   CPU_CFG_CHIP_VER(CPU_CFG_CHIP_REV_A)) {
+   setbits_le32(dram-mcr, DRAM_MCR_RESET);
+   udelay(2);
+   clrbits_le32(dram-mcr, DRAM_MCR_RESET);
+   } else
+#endif
+   {
+   clrbits_le32(dram-mcr, DRAM_MCR_RESET);
+   udelay(2);
+   setbits_le32(dram-mcr, DRAM_MCR_RESET);
+   }
 }
 
 static void mctl_set_drive(void)
 {
struct sunxi_dram_reg *dram = (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE;
 
+#ifdef CONFIG_SUN7I
clrsetbits_le32(dram-mcr, DRAM_MCR_MODE_NORM(0x3) | (0x3  28),
+#else
+   clrsetbits_le32(dram-mcr, DRAM_MCR_MODE_NORM(0x3),
+#endif
DRAM_MCR_MODE_EN(0x3) |
0xffc);
 }
@@ -134,6 +155,16 @@ static void mctl_enable_dllx(u32 phase)
 }
 
 static u32 hpcr_value[32] = {
+#ifdef CONFIG_SUN4I
+   0x0301, 0x0301, 0x0301, 0x0301,
+   0x0301, 0x0301, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0x1031, 0x1031, 0x0735, 0x5031,
+   0x1035, 0x0731, 0x1031, 0x0735,
+   0x1035, 0x1031, 0x0731, 0x1035,
+   0x1031, 0x0301, 0x0301, 0x0731
+#endif
 #ifdef CONFIG_SUN7I
0x0301, 0x0301, 0x0301, 0x0301,
0x0301, 0x0301, 0x0301, 0x0301,
@@ -223,22 +254,32 @@ static void mctl_setup_dram_clock(u32 clk)
clrbits_le32(ccm-ahb_gate0, CCM_AHB_GATE_GPS);
 #endif
 
+#if defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
/* setup MBUS clock */
reg_val = CCM_MBUS_CTRL_GATE |
  CCM_MBUS_CTRL_CLK_SRC(CCM_MBUS_CTRL_CLK_SRC_PLL6) |
  CCM_MBUS_CTRL_N(CCM_MBUS_CTRL_N_X(2)) |
  CCM_MBUS_CTRL_M(CCM_MBUS_CTRL_M_X(2));
writel(reg_val, ccm-mbus_clk_cfg);
+#endif
 
/*
 * open DRAMC AHB  DLL register clock
 * close it first
 */
+#if defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
clrbits_le32(ccm-ahb_gate0, CCM_AHB_GATE_SDRAM | CCM_AHB_GATE_DLL);
+#else
+   clrbits_le32(ccm-ahb_gate0, CCM_AHB_GATE_SDRAM);