Skip to contentSkip to conversation

sunxi: Add H6 DDR3 DRAM support

PATCH New Andre Przywara 2 participants 14 messages Jul 15, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover sunxi: Add H6 DDR3 DRAM support

A tiny update, dropping "1333" from the LPDDR3 timings filename, because it actually isn't 1333, as Icenowy pointed out correctly. Also adding Jernej's review tags. For more details see the Changelog below.
----------------

So far the SPL DRAM driver for the Allwinner H6 SoC only supports LPDDR3 DRAM chips, which are used on most single board computers with this SoC.
There are some TV boxes with the H6 out now, but most of them are using DDR3 DRAM instead of LPDDR3.

This series extends the existing H6 DRAM driver to cover DDR3 DRAMs as well. The information used in these patches is from:
- register dumps after Allwinner's boot0 (libdram) has initialised the DRAM
- some disassembly of the libdram library
- timing parameters as found in the boot0 binary
- comparison with Xilinx ZynqMP DRAM controller documentation

The box I played with (Eachlink H6 Mini) has 3GB of DDR3-1600 chips and runs at 840 MHz, however I couldn't get it to work with these parameters. Instead Jernej suggested to use a lower clock and adjust some timing parameters, which made it work for me as well.

Many thanks to Jernej Skrabec for his help, also to others who helped with testing and experiments.

The first two patches contain some fixes for the existing driver. Patch 3 moves the existing LPDDR3 timing parameters into a separate file, patch 5 introduces the respective DDR3 timings, patch 6 adds some generic delay lines values.
Patch 4 enhances the DRAM controller driver to program DDR3 specific registers as well and use different settings on other registers. The final patch introduces support for the Eachlink H6 Mini TV box, with the usual device tree and defconfig file.

Please have a look and comment!

Cheers,
Andre.

Changelog v2..v3:
- rebased against origin/master
- drop 1333 from LPDDR3 timings filename
- cosmetic change to comment
- adding Jernej's Reviewed-by: and Tested-by: tags
- updating defconfigs for two new boards

Changelog v1..v2:
- name DDR2T mode bit
- explain bonding ID bit
- generalise message about non-supported DRAM types
- update comments about JEDEC values to match DDR3-1333 timings
- use recommended max(ns, cycles) timing formulas where appropriate
- add MAINTAINERS entry for the Eachlink H6 Mini box

Andre Przywara (6):
sunxi: H6: DRAM: avoid memcpy() on MMIO registers
sunxi: H6: DRAM: follow recommended PHY init algorithm
sunxi: H6: move LPDDR3 timing definition into separate file
sunxi: H6: Add DDR3 support to DRAM controller driver
sunxi: H6: Add DDR3-1333 timings
sunxi: H6: Add basic Eachlink H6 Mini support

Jernej Skrabec (1):
sunxi: H6: Add DDR3 DRAM delay values

 arch/arm/dts/Makefile                            |   1 +
 arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts      | 116 +++++++++++
 arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h |  35 ++++
 arch/arm/mach-sunxi/Kconfig                      |  18 +-
 arch/arm/mach-sunxi/Makefile                     |   1 +
 arch/arm/mach-sunxi/dram_sun50i_h6.c             | 251 +++++++----------------
 arch/arm/mach-sunxi/dram_timings/Makefile        |   2 +
 arch/arm/mach-sunxi/dram_timings/h6_ddr3_1333.c  | 144 +++++++++++++
 arch/arm/mach-sunxi/dram_timings/h6_lpddr3.c     | 132 ++++++++++++
 board/sunxi/MAINTAINERS                          |   6 +
 configs/beelink_gs1_defconfig                    |   1 +
 configs/eachlink_h6_mini_defconfig               |  17 ++
 configs/orangepi_lite2_defconfig                 |   1 +
 configs/orangepi_one_plus_defconfig              |   1 +
 configs/pine_h64_defconfig                       |   1 +
 15 files changed, 549 insertions(+), 178 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts
 create mode 100644 arch/arm/mach-sunxi/dram_timings/h6_ddr3_1333.c
 create mode 100644 arch/arm/mach-sunxi/dram_timings/h6_lpddr3.c
 create mode 100644 configs/eachlink_h6_mini_defconfig
Signature · 1 line
2.14.5
#1 lore raw

PATCH v3 1/7 sunxi: H6: DRAM: avoid memcpy() on MMIO registers

Using memcpy() is, however tempting, not a good idea: It depends on the specific implementation of memcpy, also lacks barriers. In this particular case the first registers were written using 64-bit writes, and the last register using four separate single-byte writes.

Replace the memcpy with a proper loop using the writel() accessor.

---
 arch/arm/mach-sunxi/dram_sun50i_h6.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-sunxi/dram_sun50i_h6.c +4 -2
index 5da90a2835..e2f141eb9b 100644
@@ -182,6 +182,7 @@ static void mctl_set_timing_lpddr3(struct dram_para *para)
 			(struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
 	struct sunxi_mctl_phy_reg * const mctl_phy =
 			(struct sunxi_mctl_phy_reg *)SUNXI_DRAM_PHY0_BASE;
+	int i;
 
 	u8 tccd		= 2;
 	u8 tfaw		= max(ns_to_t(50), 4);
@@ -237,8 +238,9 @@ static void mctl_set_timing_lpddr3(struct dram_para *para)
 	u8 twr2rd	= tcwl + 4 + 1 + twtr;
 	u8 trd2wr	= tcl + 4 + (tcksrea >> 1) - tcwl + 1;
 
-	/* set mode register */
-	memcpy(mctl_phy->mr, mr_lpddr3, sizeof(mr_lpddr3));
+	/* set mode registers */
+	for (i = 0; i < ARRAY_SIZE(mr_lpddr3); i++)
+		writel(mr_lpddr3[i], &mctl_phy->mr[i]);
 
 	/* set DRAM timing */
 	writel((twtp << 24) | (tfaw << 16) | (trasmax << 8) | tras,
Signature · 1 line
2.14.5
#2 lore raw

PATCH v3 2/7 sunxi: H6: DRAM: follow recommended PHY init algorithm

In reply to Andre Przywara

The DRAM controller manual suggests to first program the PHY initialisation parameters to the PHY_PIR register, and then set bit 0 to trigger the initialisation. This is also used in boot0.

Follow this recommendation by setting bit 0 in a separate step.

---
 arch/arm/mach-sunxi/dram_sun50i_h6.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/dram_sun50i_h6.c +3 -1
index e2f141eb9b..7a8b724f08 100644
@@ -75,12 +75,14 @@ static void mctl_core_init(struct dram_para *para)
 	mctl_channel_init(para);
 }
 
+/* PHY initialisation */
 static void mctl_phy_pir_init(u32 val)
 {
 	struct sunxi_mctl_phy_reg * const mctl_phy =
 			(struct sunxi_mctl_phy_reg *)SUNXI_DRAM_PHY0_BASE;
 
-	writel(val | BIT(0), &mctl_phy->pir);
+	writel(val, &mctl_phy->pir);
+	writel(val | BIT(0), &mctl_phy->pir);	/* Start initialisation. */
 	mctl_await_completion(&mctl_phy->pgsr[0], BIT(0), BIT(0));
 }
 
Signature · 1 line
2.14.5
#3 lore raw

PATCH v3 3/7 sunxi: H6: move LPDDR3 timing definition into separate file

In reply to Andre Przywara

Currently the H6 DRAM driver only supports one kind of LPDDR3 DRAM. Split the timing parameters for this LPDDR3 configuration into a separate file, to allow selecting an alternative later at compile time (as the sunxi-dw driver does).

---
 arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h |  27 ++++
 arch/arm/mach-sunxi/Kconfig                      |  10 +-
 arch/arm/mach-sunxi/Makefile                     |   1 +
 arch/arm/mach-sunxi/dram_sun50i_h6.c             | 150 +----------------------
 arch/arm/mach-sunxi/dram_timings/Makefile        |   1 +
 arch/arm/mach-sunxi/dram_timings/h6_lpddr3.c     | 132 ++++++++++++++++++++
 configs/beelink_gs1_defconfig                    |   1 +
 configs/orangepi_lite2_defconfig                 |   1 +
 configs/orangepi_one_plus_defconfig              |   1 +
 configs/pine_h64_defconfig                       |   1 +
 10 files changed, 177 insertions(+), 148 deletions(-)
 create mode 100644 arch/arm/mach-sunxi/dram_timings/h6_lpddr3.c
arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h +27 -0
index eeb4da5c3f..54c4755556 100644
@@ -287,6 +287,31 @@ check_member(sunxi_mctl_phy_reg, dx[3].reserved_0xf0, 0xaf0);
 #define DCR_DDR4	(4 << 0)
 #define DCR_DDR8BANK	BIT(3)
 
+/*
+ * The delay parameters allow to allegedly specify delay times of some
+ * unknown unit for each individual bit trace in each of the four data bytes
+ * the 32-bit wide access consists of. Also three control signals can be
+ * adjusted individually.
+ */
+#define NR_OF_BYTE_LANES	(32 / BITS_PER_BYTE)
+/* The eight data lines (DQn) plus DM, DQS, DQS/DM/DQ Output Enable and DQSN */
+#define WR_LINES_PER_BYTE_LANE	(BITS_PER_BYTE + 4)
+/*
+ * The eight data lines (DQn) plus DM, DQS, DQS/DM/DQ Output Enable, DQSN,
+ * Termination and Power down
+ */
+#define RD_LINES_PER_BYTE_LANE	(BITS_PER_BYTE + 6)
+struct dram_para {
+	u32 clk;
+	enum sunxi_dram_type type;
+	u8 cols;
+	u8 rows;
+	u8 ranks;
+	const u8 dx_read_delays[NR_OF_BYTE_LANES][RD_LINES_PER_BYTE_LANE];
+	const u8 dx_write_delays[NR_OF_BYTE_LANES][WR_LINES_PER_BYTE_LANE];
+};
+
+
 static inline int ns_to_t(int nanoseconds)
 {
 	const unsigned int ctrl_freq = CONFIG_DRAM_CLK / 2;
@@ -294,4 +319,6 @@ static inline int ns_to_t(int nanoseconds)
 	return DIV_ROUND_UP(ctrl_freq * nanoseconds, 1000);
 }
 
+void mctl_set_timing_params(struct dram_para *para);
+
 #endif /* _SUNXI_DRAM_SUN50I_H6_H */
arch/arm/mach-sunxi/Kconfig +9 -1
index 1669e62a6d..d588936850 100644
@@ -340,7 +340,7 @@ config ARM_BOOT_HOOK_RMR
 	This allows both the SPL and the U-Boot proper to be entered in
 	either mode and switch to AArch64 if needed.
 
-if SUNXI_DRAM_DW
+if SUNXI_DRAM_DW || DRAM_SUN50I_H6
 config SUNXI_DRAM_DDR3
 	bool
 
@@ -370,6 +370,14 @@ config SUNXI_DRAM_LPDDR3_STOCK
 	This option is the LPDDR3 timing used by the stock boot0 by
 	Allwinner.
 
+config SUNXI_DRAM_H6_LPDDR3
+	bool "LPDDR3 DRAM chips on the H6 DRAM controller"
+	select SUNXI_DRAM_LPDDR3
+	depends on DRAM_SUN50I_H6
+	---help---
+	This option is the LPDDR3 timing used by the stock boot0 by
+	Allwinner.
+
 config SUNXI_DRAM_DDR2_V3S
 	bool "DDR2 found in V3s chip"
 	select SUNXI_DRAM_DDR2
arch/arm/mach-sunxi/Makefile +1 -0
index 43a93e3085..d129f33479 100644
@@ -39,4 +39,5 @@ obj-$(CONFIG_SPL_SPI_SUNXI)	+= spl_spi_sunxi.o
 obj-$(CONFIG_SUNXI_DRAM_DW)	+= dram_sunxi_dw.o
 obj-$(CONFIG_SUNXI_DRAM_DW)	+= dram_timings/
 obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_sun50i_h6.o
+obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_timings/
 endif
arch/arm/mach-sunxi/dram_sun50i_h6.c +3 -147

182 lines not on this page · raw message

arch/arm/mach-sunxi/dram_timings/Makefile +1 -0
index 278a8a14cc..0886a95968 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_SUNXI_DRAM_DDR3_1333)	+= ddr3_1333.o
 obj-$(CONFIG_SUNXI_DRAM_LPDDR3_STOCK)	+= lpddr3_stock.o
 obj-$(CONFIG_SUNXI_DRAM_DDR2_V3S)	+= ddr2_v3s.o
+obj-$(CONFIG_SUNXI_DRAM_H6_LPDDR3)	+= h6_lpddr3.o
arch/arm/mach-sunxi/dram_timings/h6_lpddr3.c new file +132 -0

132 lines not on this page · raw message

configs/beelink_gs1_defconfig +1 -0
index f16d0fee22..e970abd0ec 100644
@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I_H6=y
+CONFIG_SUNXI_DRAM_H6_LPDDR3=y
 CONFIG_MMC0_CD_PIN="PF6"
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_PSCI_RESET is not set
configs/orangepi_lite2_defconfig +1 -0
index e5c2846eaa..dc0a38ebe5 100644
@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I_H6=y
+CONFIG_SUNXI_DRAM_H6_LPDDR3=y
 CONFIG_MMC0_CD_PIN="PF6"
 # CONFIG_PSCI_RESET is not set
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/orangepi_one_plus_defconfig +1 -0
index 65537c422f..e4b9f3a1c8 100644
@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I_H6=y
+CONFIG_SUNXI_DRAM_H6_LPDDR3=y
 CONFIG_MMC0_CD_PIN="PF6"
 # CONFIG_PSCI_RESET is not set
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/pine_h64_defconfig +1 -0
index 5ac89b462c..d88a6b1fd8 100644
@@ -3,6 +3,7 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I_H6=y
+CONFIG_SUNXI_DRAM_H6_LPDDR3=y
 CONFIG_MMC0_CD_PIN="PF6"
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_PSCI_RESET is not set
Signature · 1 line
2.14.5
#4 lore raw

PATCH v3 4/7 sunxi: H6: Add DDR3 support to DRAM controller driver

In reply to Andre Przywara

At the moment the H6 DRAM driver only supports LPDDR3 DRAM.

Extend the driver to cover DDR3 DRAM as well.

The changes are partly motivated by looking at the ZynqMP register documentation, partly by looking at register dumps after boot0/libdram has initialised the controller.

Many thanks to Jernej for contributing some fixes!

---
 arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h |  8 +++
 arch/arm/mach-sunxi/dram_sun50i_h6.c             | 82 ++++++++++++++++--------
 2 files changed, 62 insertions(+), 28 deletions(-)
arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h +8 -0
index 54c4755556..0a1da02376 100644
@@ -9,6 +9,8 @@
 #ifndef _SUNXI_DRAM_SUN50I_H6_H
 #define _SUNXI_DRAM_SUN50I_H6_H
 
+#include <stdbool.h>
+
 enum sunxi_dram_type {
 	SUNXI_DRAM_TYPE_DDR3 = 3,
 	SUNXI_DRAM_TYPE_DDR4,
@@ -16,6 +18,11 @@ enum sunxi_dram_type {
 	SUNXI_DRAM_TYPE_LPDDR3,
 };
 
+static inline bool sunxi_dram_is_lpddr(int type)
+{
+	return type >= SUNXI_DRAM_TYPE_LPDDR2;
+}
+
 /*
  * The following information is mainly retrieved by disassembly and some FPGA
  * test code of sun50iw3 platform.
@@ -286,6 +293,7 @@ check_member(sunxi_mctl_phy_reg, dx[3].reserved_0xf0, 0xaf0);
 #define DCR_DDR3	(3 << 0)
 #define DCR_DDR4	(4 << 0)
 #define DCR_DDR8BANK	BIT(3)
+#define DCR_DDR2T	BIT(28)
 
 /*
  * The delay parameters allow to allegedly specify delay times of some
arch/arm/mach-sunxi/dram_sun50i_h6.c +54 -28

147 lines not on this page · raw message

Signature · 1 line
2.14.5
#5 lore raw

PATCH v3 5/7 sunxi: H6: Add DDR3-1333 timings

In reply to Andre Przywara

Add a routine to program the timing parameters for DDR3-1333 DRAM chips connected to the H6 DRAM controller.

The values were gathered from doing back-calculations from a register dump, trying to match them up with the official JEDEC DDDR3 spec. If in doubt, the register dump values were taken for now, but the JEDEC recommendation were added as a comment.

Many thanks to Jernej for contributing fixes!

---
 arch/arm/mach-sunxi/Kconfig                     |   8 ++
 arch/arm/mach-sunxi/dram_timings/Makefile       |   1 +
 arch/arm/mach-sunxi/dram_timings/h6_ddr3_1333.c | 144 ++++++++++++++++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 arch/arm/mach-sunxi/dram_timings/h6_ddr3_1333.c
arch/arm/mach-sunxi/Kconfig +8 -0
index d588936850..d4e7d89e9e 100644
@@ -378,6 +378,14 @@ config SUNXI_DRAM_H6_LPDDR3
 	This option is the LPDDR3 timing used by the stock boot0 by
 	Allwinner.
 
+config SUNXI_DRAM_H6_DDR3_1333
+	bool "DDR3-1333 boot0 timings on the H6 DRAM controller"
+	select SUNXI_DRAM_DDR3
+	depends on DRAM_SUN50I_H6
+	---help---
+	This option is the DDR3 timing used by the boot0 on H6 TV boxes
+	which use a DDR3-1333 timing.
+
 config SUNXI_DRAM_DDR2_V3S
 	bool "DDR2 found in V3s chip"
 	select SUNXI_DRAM_DDR2
arch/arm/mach-sunxi/dram_timings/Makefile +1 -0
index 0886a95968..0deb9911fd 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_SUNXI_DRAM_DDR3_1333)	+= ddr3_1333.o
 obj-$(CONFIG_SUNXI_DRAM_LPDDR3_STOCK)	+= lpddr3_stock.o
 obj-$(CONFIG_SUNXI_DRAM_DDR2_V3S)	+= ddr2_v3s.o
 obj-$(CONFIG_SUNXI_DRAM_H6_LPDDR3)	+= h6_lpddr3.o
+obj-$(CONFIG_SUNXI_DRAM_H6_DDR3_1333)	+= h6_ddr3_1333.o
arch/arm/mach-sunxi/dram_timings/h6_ddr3_1333.c new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.14.5
#6 lore raw

PATCH v3 6/7 sunxi: H6: Add DDR3 DRAM delay values

In reply to Andre Przywara

From: Jernej Skrabec <[email protected]>

Add some basic line delay values to be used with DDR3 DRAM chips on some H6 TV boxes.
Taken from a register dump after boot0 initialised the DRAM. Put them as the default delay values for DDR3 DRAM until we know better.

---
 arch/arm/mach-sunxi/dram_sun50i_h6.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
arch/arm/mach-sunxi/dram_sun50i_h6.c +17 -6
index 17649ffbf9..2a8275da3a 100644
@@ -594,17 +594,28 @@ unsigned long mctl_calc_size(struct dram_para *para)
 	return (1ULL << (para->cols + para->rows + 3)) * 4 * para->ranks;
 }
 
-#define SUN50I_H6_DX_WRITE_DELAYS				\
+#define SUN50I_H6_LPDDR3_DX_WRITE_DELAYS			\
 	{{  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,  0,  0,  0,  0,  0,  4,  4,  0 },	\
 	 {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }}
-#define SUN50I_H6_DX_READ_DELAYS					\
+#define SUN50I_H6_LPDDR3_DX_READ_DELAYS					\
 	{{  4,  4,  4,  4,  4,  4,  4,  4,  4,  0,  0,  0,  0,  0 },	\
 	 {  4,  4,  4,  4,  4,  4,  4,  4,  4,  0,  0,  0,  0,  0 },	\
 	 {  4,  4,  4,  4,  4,  4,  4,  4,  4,  0,  0,  0,  0,  0 },	\
 	 {  4,  4,  4,  4,  4,  4,  4,  4,  4,  0,  0,  0,  0,  0 }}
 
+#define SUN50I_H6_DDR3_DX_WRITE_DELAYS				\
+	{{  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,  0,  0,  0,  0,  0,  0,  0,  0 },	\
+	 {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }}
+#define SUN50I_H6_DDR3_DX_READ_DELAYS					\
+	{{  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 },	\
+	 {  4,  4,  4,  4,  4,  4,  4,  4,  4,  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,  0,  0,  0,  0,  0 }}
+
 unsigned long sunxi_dram_init(void)
 {
 	struct sunxi_mctl_com_reg * const mctl_com =
@@ -616,12 +627,12 @@ unsigned long sunxi_dram_init(void)
 		.rows = 14,
 #ifdef CONFIG_SUNXI_DRAM_H6_LPDDR3
 		.type = SUNXI_DRAM_TYPE_LPDDR3,
-		.dx_read_delays  = SUN50I_H6_DX_READ_DELAYS,
-		.dx_write_delays = SUN50I_H6_DX_WRITE_DELAYS,
+		.dx_read_delays  = SUN50I_H6_LPDDR3_DX_READ_DELAYS,
+		.dx_write_delays = SUN50I_H6_LPDDR3_DX_WRITE_DELAYS,
 #elif defined(CONFIG_SUNXI_DRAM_H6_DDR3_1333)
 		.type = SUNXI_DRAM_TYPE_DDR3,
-		.dx_read_delays  = SUN50I_H6_DX_READ_DELAYS,
-		.dx_write_delays = SUN50I_H6_DX_WRITE_DELAYS,
+		.dx_read_delays  = SUN50I_H6_DDR3_DX_READ_DELAYS,
+		.dx_write_delays = SUN50I_H6_DDR3_DX_WRITE_DELAYS,
 #endif
 	};
 
Signature · 1 line
2.14.5
#7 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

In reply to Andre Przywara

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

This adds a basic device tree and defconfig for it.

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

---
 arch/arm/dts/Makefile                       |   1 +
 arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts | 116 ++++++++++++++++++++++++++++
 board/sunxi/MAINTAINERS                     |   6 ++
 configs/eachlink_h6_mini_defconfig          |  17 ++++
 4 files changed, 140 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts
 create mode 100644 configs/eachlink_h6_mini_defconfig
arch/arm/dts/Makefile +1 -0
index 39cf4c3b3d..dd676ac090 100644
@@ -511,6 +511,7 @@ dtb-$(CONFIG_MACH_SUN50I_H5) += \
 	sun50i-h5-orangepi-zero-plus2.dtb
 dtb-$(CONFIG_MACH_SUN50I_H6) += \
 	sun50i-h6-beelink-gs1.dtb \
+	sun50i-h6-eachlink-h6-mini.dtb \
 	sun50i-h6-orangepi-lite2.dtb \
 	sun50i-h6-orangepi-one-plus.dtb \
 	sun50i-h6-pine-h64.dtb
arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts new file +116 -0

116 lines not on this page · raw message

board/sunxi/MAINTAINERS +6 -0
index bdd1854197..fa8c2ef181 100644
@@ -195,6 +195,12 @@ M:	Chen-Yu Tsai <[email protected]>
 S:	Maintained
 F:	configs/Cubietruck_plus_defconfig
 
+EACHLINK H6 MINI
+M:	Andre Przywara <[email protected]>
+S:	Maintained
+F:	configs/eachlink_h6_mini_defconfig
+F:	arch/arm/dts/sun50i-h6-eachlink-h6-mini.dts
+
 EMLID NEUTIS N5 DEV BOARD
 M:	Aleksandr Aleksandrov <[email protected]>
 S:	Maintained
configs/eachlink_h6_mini_defconfig new file +17 -0
new file mode 100644
index 0000000000..d471a24dd5
@@ -0,0 +1,17 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I_H6=y
+CONFIG_DRAM_CLK=660
+CONFIG_DRAM_ZQ=3881979
+CONFIG_SUNXI_DRAM_H6_DDR3_1333=y
+CONFIG_MMC0_CD_PIN="PF6"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+# CONFIG_PSCI_RESET is not set
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_TEXT_BASE=0x20060
+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-eachlink-h6-mini"
Signature · 1 line
2.14.5
#8 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

Quoted 9 lines · Andre Przywara

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

This adds a basic device tree and defconfig for it.

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

Send the linux sync commit, rest seems to fine for me. will update the commit while applying.

#9 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

On Mon, 15 Jul 2019 12:41:34 +0530
Jagan Teki <[email protected]> wrote:

Hi Jagan!

Quoted 6 lines · Andre Przywara
Quoted 5 lines

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

Quoted 7 lines
Quoted 4 lines

This adds a basic device tree and defconfig for it.

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

Send the linux sync commit, rest seems to fine for me. will update the commit while applying.

Which sync commit? I haven't send a device tree for Linux yet, if that is what you mean. Reason is I don't have much working beyond MMC and USB(2.0). I was hoping for at least HDMI to work, because this is a TV box and requires opening and soldering to get serial output.
Also I guess it's a bit of a chicken and egg problem, a Linux DT wouldn't make much sense without U-Boot support, especially if it's more than just a defconfig as in this case.

So can we just merge this patch as well? Then people can at least start to play with it. We can sync and update the DT later.

Cheers,
Andre.

P.S. I will try to send a sunxi64 Linux->U-Boot DT sync later this week. I have the patches ready, just need to test them with several kernels.

#10 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

Quoted 14 lines · Andre Przywara

On Mon, 15 Jul 2019 12:41:34 +0530
Jagan Teki <[email protected]> wrote:

Hi Jagan!

Quoted 8 lines · Andre Przywara
Quoted 7 lines

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

This adds a basic device tree and defconfig for it.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

Send the linux sync commit, rest seems to fine for me. will update the commit while applying.

Which sync commit? I haven't send a device tree for Linux yet, if that is

sun50i-h6-eachlink-h6-mini.dts this was synced from Linux right? need head commit id of this dts.

#11 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

On Mon, 15 Jul 2019 15:43:10 +0530
Jagan Teki <[email protected]> wrote:

Hi,

Quoted 18 lines · Andre Przywara
Quoted 17 lines

On Mon, 15 Jul 2019 12:41:34 +0530
Jagan Teki <[email protected]> wrote:

Hi Jagan!

Quoted 11 lines · Andre Przywara
Quoted 9 lines

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

This adds a basic device tree and defconfig for it.

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Send the linux sync commit, rest seems to fine for me. will update the commit while applying.

Which sync commit? I haven't send a device tree for Linux yet, if that is

sun50i-h6-eachlink-h6-mini.dts this was synced from Linux right? need head commit id of this dts.

As I was trying to say in the line above: There is no sun50i-h6-eachlink-h6-mini.dts in Linux (yet), for the said reasons.

Cheers,
Andre.

#12 lore raw

PATCH v3 7/7 sunxi: H6: Add basic Eachlink H6 Mini support

Quoted 27 lines · Andre Przywara

On Mon, 15 Jul 2019 15:43:10 +0530
Jagan Teki <[email protected]> wrote:

Hi,

Quoted 21 lines · Andre Przywara
Quoted 20 lines

On Mon, 15 Jul 2019 12:41:34 +0530
Jagan Teki <[email protected]> wrote:

Hi Jagan!

Quoted 13 lines · Andre Przywara
Quoted 9 lines

The Eachlink H6 Mini is a modestly priced TV box, using the Allwinner H6 SoC. It comes with 3GB of DRAM and 32GB of eMMC in the typical TV box enclosure.

This adds a basic device tree and defconfig for it.

It contrast to the other supported H6 boards the H6 Mini uses DDR3 DRAM chips (not LPDDR3), which require a different DRAM controller setup.

Send the linux sync commit, rest seems to fine for me. will update the commit while applying.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Which sync commit? I haven't send a device tree for Linux yet, if that is

sun50i-h6-eachlink-h6-mini.dts this was synced from Linux right? need head commit id of this dts.

As I was trying to say in the line above: There is no sun50i-h6-eachlink-h6-mini.dts in Linux (yet), for the said reasons.

Ohh. Sorry for overlook. Will skip this patch for now.

#13 lore raw

v3 cover sunxi: Add H6 DDR3 DRAM support

In reply to Andre Przywara
Quoted 57 lines · Andre Przywara

A tiny update, dropping "1333" from the LPDDR3 timings filename, because it actually isn't 1333, as Icenowy pointed out correctly. Also adding Jernej's review tags. For more details see the Changelog below.
----------------

So far the SPL DRAM driver for the Allwinner H6 SoC only supports LPDDR3 DRAM chips, which are used on most single board computers with this SoC.
There are some TV boxes with the H6 out now, but most of them are using DDR3 DRAM instead of LPDDR3.

This series extends the existing H6 DRAM driver to cover DDR3 DRAMs as well. The information used in these patches is from:
- register dumps after Allwinner's boot0 (libdram) has initialised the DRAM
- some disassembly of the libdram library
- timing parameters as found in the boot0 binary
- comparison with Xilinx ZynqMP DRAM controller documentation

The box I played with (Eachlink H6 Mini) has 3GB of DDR3-1600 chips and runs at 840 MHz, however I couldn't get it to work with these parameters. Instead Jernej suggested to use a lower clock and adjust some timing parameters, which made it work for me as well.

Many thanks to Jernej Skrabec for his help, also to others who helped with testing and experiments.

The first two patches contain some fixes for the existing driver. Patch 3 moves the existing LPDDR3 timing parameters into a separate file, patch 5 introduces the respective DDR3 timings, patch 6 adds some generic delay lines values.
Patch 4 enhances the DRAM controller driver to program DDR3 specific registers as well and use different settings on other registers. The final patch introduces support for the Eachlink H6 Mini TV box, with the usual device tree and defconfig file.

Please have a look and comment!

Cheers,
Andre.

Changelog v2..v3:
- rebased against origin/master
- drop 1333 from LPDDR3 timings filename
- cosmetic change to comment
- adding Jernej's Reviewed-by: and Tested-by: tags
- updating defconfigs for two new boards

Changelog v1..v2:
- name DDR2T mode bit
- explain bonding ID bit
- generalise message about non-supported DRAM types
- update comments about JEDEC values to match DDR3-1333 timings
- use recommended max(ns, cycles) timing formulas where appropriate
- add MAINTAINERS entry for the Eachlink H6 Mini box

Quoted 6 lines

Andre Przywara (6):
sunxi: H6: DRAM: avoid memcpy() on MMIO registers
sunxi: H6: DRAM: follow recommended PHY init algorithm
sunxi: H6: move LPDDR3 timing definition into separate file
sunxi: H6: Add DDR3 support to DRAM controller driver
sunxi: H6: Add DDR3-1333 timings

Applied to u-boot-sunxi/master