Skip to contentSkip to conversation

sunxi: initial upstreamining effort

PATCH Superseded Ian Campbell 4 participants 35 messages Apr 18, 2014 – Apr 28, 2014

Subsystems (5)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover sunxi: initial upstreamining effort

This is my third cut at an upstreamable series based upon the
https://github.com/linux-sunxi/u-boot-sunxi.git#sunxi tree. The intention is to present a minimal starting point for upstreaming to which support for other processors, peripherals, boards etc can be added in the future. Therefore this has been stripped right back and currently supports only sun7i processors (AKA Allwinner A20) and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

The code here is from u-boot-sunxi.git#sunxi[0] changeset based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style" and applies to u-boot v2014.04.

Global changes in v3:
- Rebased onto v2014.04 and resynced with u-boot-sunxi.git c89867dca2e9
- Improved commit messages
- Updated lists of contributors
- Added some CCs
- Lots of cleanup based on review comments.

Global changes in v2:
- Use SPDX-License-Identifier
- Resync with u-boot-sunxi.git
- Lot of updates to the individual patches, see the individual commit messages (checkpatch.pl fixes, magic number removal etc).
- Pulled the Ethernet stuff before the MMC and non-FEL boot stuff. The MMC stuff (which non-FEL boot needs) still needs some more cleanup, but the reordering means that the initial part of the series could in principal go in.

This series can also be found at:

git://gitorious.org/ijc/u-boot.git sunxi-mainlining-v3

There is no SMP here, since that relies on the PSCI support from Marc Zyngier which has yet to land in mainline. Marc has recently rebased and a version based on this series can be found at:

git://gitorious.org/ijc/u-boot.git sunxi-mainlining-v3-smp

I've tried to give corect credit and S-o-b based upon:
git log --pretty='%aN' linux-sunxi/sunxi -- [PATHS] | sort -u git log linux-sunxi/sunxi -- [PATHS] | grep -i signed.off.by | sort -u Manual inspection

This will tend to over credit, since it will include folks who contributed code which has since been removed as well as those who contributed code which is not included in this patch set, but I think it is better to be conservative and include too many rather than incorrectly exclude people. Doing better than this would be IMHO too hard to be worth it (e.g. git blame would prefer a recent whitespace cleanup to the actual author of the code and prefer someone did code motion over the original author, so it would be a massive & manual process).

[0] https://github.com/linux-sunxi/u-boot-sunxi.git

#1 lore raw

PATCH v3 1/9 sunxi: add sun7i clocks and timer support.

This patch adds the basic clocks and timer support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

Some of the code here is common to multiple sunxi subarchtectures, hence files are named sun4i which is the earliest similar variant.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- define magic numbers
- simplify get_tbclk
- correct clock_set_pll1 prototype
- add CONFIG_SUN7I to simplify future SUN?I support.
- defines for MMC AHB clocks

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/Makefile             |  12 ++
 arch/arm/cpu/armv7/sunxi/clock.c              |  35 ++++
 arch/arm/cpu/armv7/sunxi/clock_sun4i.c        | 176 ++++++++++++++++++
 arch/arm/cpu/armv7/sunxi/timer.c              | 110 +++++++++++
 arch/arm/include/asm/arch-sunxi/clock.h       |  29 +++
 arch/arm/include/asm/arch-sunxi/clock_sun4i.h | 256 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/sys_proto.h   |  16 ++
 arch/arm/include/asm/arch-sunxi/timer.h       |  88 +++++++++
 8 files changed, 722 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/sunxi/Makefile
 create mode 100644 arch/arm/cpu/armv7/sunxi/clock.c
 create mode 100644 arch/arm/cpu/armv7/sunxi/clock_sun4i.c
 create mode 100644 arch/arm/cpu/armv7/sunxi/timer.c
 create mode 100644 arch/arm/include/asm/arch-sunxi/clock.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/clock_sun4i.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/sys_proto.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/timer.h
arch/arm/cpu/armv7/sunxi/Makefile new file +12 -0
new file mode 100644
index 0000000..440d266
@@ -0,0 +1,12 @@
+#
+# (C) Copyright 2012 Henrik Nordstrom <[email protected]>
+#
+# Based on some other Makefile
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+obj-y	+= timer.o
+obj-y	+= clock.o
+obj-$(CONFIG_SUN7I)	+= clock_sun4i.o
arch/arm/cpu/armv7/sunxi/clock.c new file +35 -0
new file mode 100644
index 0000000..94ba6e0
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright 2007-2012
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * (C) Copyright 2013 Luke Kenneth Casson Leighton <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/sys_proto.h>
+
+int clock_init(void)
+{
+#ifdef CONFIG_SPL_BUILD
+	clock_init_safe();
+#endif
+	clock_init_uart();
+
+	return 0;
+}
+
+unsigned int clock_get_pll6(void)
+{
+	struct sunxi_ccm_reg *const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	uint32_t rval = readl(&ccm->pll6_cfg);
+	int n = (rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT;
+	int k = ((rval  & CCM_PLL6_CTRL_K_MASK) >> CCM_PLL6_CTRL_K_SHIFT) + 1;
+	return 24000000 * n * k / 2;
+}
arch/arm/cpu/armv7/sunxi/clock_sun4i.c new file +176 -0

176 lines not on this page · raw message

arch/arm/cpu/armv7/sunxi/timer.c new file +110 -0

110 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/clock.h new file +29 -0
new file mode 100644
index 0000000..5d1b6a6
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _SUNXI_CLOCK_H
+#define _SUNXI_CLOCK_H
+
+#include <linux/types.h>
+
+#define CLK_GATE_OPEN			0x1
+#define CLK_GATE_CLOSE			0x0
+
+/* clock control module regs definition */
+#include <asm/arch/clock_sun4i.h>
+
+#ifndef __ASSEMBLY__
+int clock_init(void);
+int clock_twi_onoff(int port, int state);
+void clock_set_pll1(int hz);
+unsigned int clock_get_pll6(void);
+void clock_init_safe(void);
+void clock_init_uart(void);
+#endif
+
+#endif /* _SUNXI_CLOCK_H */
arch/arm/include/asm/arch-sunxi/clock_sun4i.h new file +256 -0

256 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/sys_proto.h new file +16 -0
new file mode 100644
index 0000000..c3e636e
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2007-2012
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _SYS_PROTO_H_
+#define _SYS_PROTO_H_
+
+#include <linux/types.h>
+
+void sdelay(unsigned long);
+
+#endif
arch/arm/include/asm/arch-sunxi/timer.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
1.9.0
#2 lore raw

PATCH v3 1/9 sunxi: add sun7i clocks and timer support.

On Friday, April 18, 2014 at 08:05:42 PM, Ian Campbell wrote:
[...]

arch/arm/cpu/armv7/sunxi/timer.c line 38

Quoted 7 lines
arch/arm/cpu/armv7/sunxi/timer.c new file +7 -0
+static ulong read_timer(void)
+{
+	struct sunxi_timer_reg *timers =
+		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
+	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
+	/* The hardware timer counts down, therefore we invert to
+	 * produce an incrementing timer. */

This comment doesn't follow coding style.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return ~readl(&timer->val);
+}

[...]

Best regards,
Marek Vasut

#3 lore raw

PATCH v3 2/9 sunxi: add sun7i pinmux and gpio support

In reply to Ian Campbell

This patch adds the basic pinmux and gpio support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- Additional pin definitions

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/Makefile      |   1 +
 arch/arm/cpu/armv7/sunxi/pinmux.c      |  61 ++++++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h | 147 +++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/sunxi/pinmux.c
 create mode 100644 arch/arm/include/asm/arch-sunxi/gpio.h
arch/arm/cpu/armv7/sunxi/Makefile +1 -0
index 440d266..529e7ec 100644
@@ -9,4 +9,5 @@
 #
 obj-y	+= timer.o
 obj-y	+= clock.o
+obj-y	+= pinmux.o
 obj-$(CONFIG_SUN7I)	+= clock_sun4i.o
arch/arm/cpu/armv7/sunxi/pinmux.c new file +61 -0

61 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/gpio.h new file +147 -0

147 lines not on this page · raw message

Signature · 1 line
1.9.0
#4 lore raw

PATCH v3 2/9 sunxi: add sun7i pinmux and gpio support

Quoted 5 lines · Ian Campbell

This patch adds the basic pinmux and gpio support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

Quoted 9 lines

Best regards,
Marek Vasut

#5 lore raw

PATCH v3 3/9 sunxi: add sun7i dram setup support

In reply to Ian Campbell

This patch adds DRAM initialisation support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- remove redundant braces in mctl_ddr3_reset
- remove incorrect call to mctl_ddr3_reset.
- add CONFIG_SUN7I to simplify future SUN?I support.
- add a comment about the magic numbers from the a/w code dumps
- fix a bunch of checkpatch.pl issues

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/Makefile      |   1 +
 arch/arm/cpu/armv7/sunxi/dram.c        | 553 +++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/dram.h | 179 +++++++++++
 3 files changed, 733 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/sunxi/dram.c
 create mode 100644 arch/arm/include/asm/arch-sunxi/dram.h
arch/arm/cpu/armv7/sunxi/Makefile +1 -0
index 529e7ec..d81d26c 100644
@@ -11,3 +11,4 @@ obj-y	+= timer.o
 obj-y	+= clock.o
 obj-y	+= pinmux.o
 obj-$(CONFIG_SUN7I)	+= clock_sun4i.o
+obj-$(CONFIG_SUN7I)	+= dram.o
arch/arm/cpu/armv7/sunxi/dram.c new file +553 -0

553 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/dram.h new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.9.0
#6 lore raw

PATCH v3 3/9 sunxi: add sun7i dram setup support

Quoted 4 lines · Ian Campbell

This patch adds DRAM initialisation support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

Quoted 10 lines

There's a lot of unbounded endless loops [ while (cond) ; ] in this patch. Add timeouts and handle them please, otherwise the board would get stuck during boot and you won't know why.

Best regards,
Marek Vasut

#7 lore raw

PATCH v3 4/9 sunxi: add sun7i cpu, board and start of day support

In reply to Ian Campbell

This patch adds generic board, start of day and basic build system support for the Allwinner A20 (sun7i) processor. This code will not been compiled until the build is hooked up in a later patch. It has been split out to keep the patches manageable.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- just init dram once
- remove clock ramping until power control is implemented
- add CONFIG_SUN7I to simplify future SUN?I support.
- fix a typo

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/Makefile                 |   2 +-
 arch/arm/cpu/armv7/sunxi/Makefile           |  11 +++
 arch/arm/cpu/armv7/sunxi/board.c            |  88 +++++++++++++++++
 arch/arm/cpu/armv7/sunxi/cpu_info.c         |  19 ++++
 arch/arm/cpu/armv7/sunxi/start.c            |   1 +
 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds |  77 +++++++++++++++
 arch/arm/include/asm/arch-sunxi/cpu.h       | 122 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/spl.h       |  20 ++++
 board/sunxi/Makefile                        |  11 +++
 board/sunxi/board.c                         |  57 +++++++++++
 include/configs/sun7i.h                     |  24 +++++
 include/configs/sunxi-common.h              | 141 ++++++++++++++++++++++++++++
 12 files changed, 572 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/sunxi/board.c
 create mode 100644 arch/arm/cpu/armv7/sunxi/cpu_info.c
 create mode 100644 arch/arm/cpu/armv7/sunxi/start.c
 create mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
 create mode 100644 arch/arm/include/asm/arch-sunxi/cpu.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/spl.h
 create mode 100644 board/sunxi/Makefile
 create mode 100644 board/sunxi/board.c
 create mode 100644 include/configs/sun7i.h
 create mode 100644 include/configs/sunxi-common.h
arch/arm/cpu/armv7/Makefile +1 -1
index 119ebb3..ddf00f3 100644
@@ -12,7 +12,7 @@ obj-y	+= cache_v7.o
 obj-y	+= cpu.o
 obj-y	+= syslib.o
 
-ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY),)
+ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI),)
 ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
 obj-y	+= lowlevel_init.o
 endif
arch/arm/cpu/armv7/sunxi/Makefile +11 -0
index d81d26c..a64bfa1 100644
@@ -8,7 +8,18 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 obj-y	+= timer.o
+obj-y	+= board.o
 obj-y	+= clock.o
 obj-y	+= pinmux.o
 obj-$(CONFIG_SUN7I)	+= clock_sun4i.o
+
+ifndef CONFIG_SPL_BUILD
+obj-y	+= cpu_info.o
+endif
+
+ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SUN7I)	+= dram.o
+ifdef CONFIG_SPL_FEL
+obj-y	+= start.o
+endif
+endif
arch/arm/cpu/armv7/sunxi/board.c new file +88 -0

88 lines not on this page · raw message

arch/arm/cpu/armv7/sunxi/cpu_info.c new file +19 -0
new file mode 100644
index 0000000..b4c3d5c
@@ -0,0 +1,19 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+int print_cpuinfo(void)
+{
+	puts("CPU:   Allwinner A20 (SUN7I)\n");
+	return 0;
+}
+#endif
arch/arm/cpu/armv7/sunxi/start.c new file +1 -0
new file mode 100644
index 0000000..6b392fa
@@ -0,0 +1 @@
+/* Intentionally empty. Only needed to get FEL SPL link line right */
arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds new file +77 -0

77 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/cpu.h new file +122 -0

122 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/spl.h new file +20 -0
new file mode 100644
index 0000000..ff871bc
@@ -0,0 +1,20 @@
+/*
+ * This is a copy of omap3/spl.h:
+ *
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef	_ASM_ARCH_SPL_H_
+#define	_ASM_SPL_H_
+
+#define BOOT_DEVICE_NONE	0
+#define BOOT_DEVICE_XIP		1
+#define BOOT_DEVICE_NAND	2
+#define BOOT_DEVICE_ONE_NAND	3
+#define BOOT_DEVICE_MMC2	5 /*emmc*/
+#define BOOT_DEVICE_MMC1	6
+#define BOOT_DEVICE_XIPWAIT	7
+#define BOOT_DEVICE_MMC2_2      0xff
+#endif
board/sunxi/Makefile new file +11 -0
new file mode 100644
index 0000000..559112e
@@ -0,0 +1,11 @@
+#
+# (C) Copyright 2012 Henrik Nordstrom <[email protected]>
+#
+# Based on some other board Makefile
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+obj-y	+= board.o
board/sunxi/board.c new file +57 -0

57 lines not on this page · raw message

include/configs/sun7i.h new file +24 -0
new file mode 100644
index 0000000..9b693f7
@@ -0,0 +1,24 @@
+/*
+ * (C) Copyright 2012-2013 Henrik Nordstrom <[email protected]>
+ * (C) Copyright 2013 Luke Kenneth Casson Leighton <[email protected]>
+ *
+ * Configuration settings for the Allwinner A20 (sun7i) CPU
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * A20 specific configuration
+ */
+#define CONFIG_SUN7I		/* sun7i SoC generation */
+
+#define CONFIG_SYS_PROMPT		"sun7i# "
+
+/*
+ * Include common sunxi configuration where most the settings are
+ */
+#include <configs/sunxi-common.h>
+
+#endif /* __CONFIG_H */
include/configs/sunxi-common.h new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
1.9.0
#8 lore raw

PATCH v3 5/9 sunxi: add support for Cubietruck booting in FEL mode

In reply to Ian Campbell

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in.

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 board/sunxi/Makefile          |  1 +
 board/sunxi/dram_cubietruck.c | 31 +++++++++++++++++++++++++++++++
 boards.cfg                    |  1 +
 3 files changed, 33 insertions(+)
 create mode 100644 board/sunxi/dram_cubietruck.c
board/sunxi/Makefile +1 -0
index 559112e..18b1e11 100644
@@ -9,3 +9,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 obj-y	+= board.o
+obj-$(CONFIG_CUBIETRUCK)	+= dram_cubietruck.o
board/sunxi/dram_cubietruck.c new file +31 -0
new file mode 100644
index 0000000..fbcd687
@@ -0,0 +1,31 @@
+/* this file is generated, don't edit it yourself */
+
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+	.clock = 432,
+	.type = 3,
+	.rank_num = 1,
+	.density = 4096,
+	.io_width = 8,
+	.bus_width = 32,
+	.cas = 9,
+	.zq = 0x7f,
+	.odt_en = 0,
+	.size = 2048,
+	.tpr0 = 0x42d899b7,
+	.tpr1 = 0xa090,
+	.tpr2 = 0x22a00,
+	.tpr3 = 0x0,
+	.tpr4 = 0x1,
+	.tpr5 = 0x0,
+	.emr1 = 0x4,
+	.emr2 = 0x10,
+	.emr3 = 0x0,
+};
+
+unsigned long sunxi_dram_init(void)
+{
+	return dramc_init(&dram_para);
+}
boards.cfg +1 -0
index b4203f1..31b02df 100644
@@ -371,6 +371,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                             -                                                                                                                                 Mateusz Zalega <[email protected]>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                             -                                                                                                                                 Minkyu Kang <[email protected]>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                     -                                                                                                                                 -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL                                                                                                          -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <[email protected]>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                           -                                                                                                                                 -
 Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                             vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <[email protected]>
Signature · 1 line
1.9.0
#10 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

In reply to Ian Campbell

Add support for the GMAC Ethernet controller on Allwinner A20 (sun7i) processors. Enable for the Cubietruck.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- drop accidentally doubled hunk
- use gpio setup functions
- moved before mmc patches

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/board.c | 15 +++++++++++++++
 boards.cfg                       |  2 +-
 drivers/net/Makefile             |  1 +
 drivers/net/sunxi_gmac.c         | 34 ++++++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h   | 26 ++++++++++++++++++++++++++
 include/netdev.h                 |  1 +
 6 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sunxi_gmac.c
arch/arm/cpu/armv7/sunxi/board.c +15 -0
index b5c0cb7..9755320 100644
@@ -11,6 +11,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
 #include <serial.h>
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>
@@ -86,3 +88,16 @@ void enable_caches(void)
 	dcache_enable();
 }
 #endif
+
+#if defined(CONFIG_SUNXI_GMAC)
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+	sunxi_gmac_initialize(bis);
+
+	return 0;
+}
+#endif
boards.cfg +1 -1
index 31b02df..b74f8c8 100644
@@ -371,7 +371,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                             -                                                                                                                                 Mateusz Zalega <[email protected]>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                             -                                                                                                                                 Minkyu Kang <[email protected]>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                     -                                                                                                                                 -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL                                                                                                          -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <[email protected]>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                           -                                                                                                                                 -
 Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                             vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <[email protected]>
drivers/net/Makefile +1 -0
index 7f9ce90..2300c00 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_SH_ETHER) += sh_eth.o
 obj-$(CONFIG_SMC91111) += smc91111.o
 obj-$(CONFIG_SMC911X) += smc911x.o
 obj-$(CONFIG_SUNXI_WEMAC) += sunxi_wemac.o
+obj-$(CONFIG_SUNXI_GMAC) += sunxi_gmac.o
 obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
 obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
drivers/net/sunxi_gmac.c new file +34 -0
new file mode 100644
index 0000000..15cd1fb
@@ -0,0 +1,34 @@
+#include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
+#include <asm/gpio.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/gpio.h>
+
+int sunxi_gmac_initialize(bd_t *bis)
+{
+	int pin;
+	struct sunxi_ccm_reg *const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+	/* Set up clock gating */
+	setbits_le32(&ccm->ahb_gate1, 0x1 << AHB_GATE_OFFSET_GMAC);
+
+	/* Set MII clock */
+	setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
+		CCM_GMAC_CTRL_GPIT_RGMII);
+
+	/* Configure pin mux settings for GMAC */
+	for (pin = SUNXI_GPA(0); pin <= SUNXI_GPA(16); pin++) {
+		/* skip unused pins in RGMII mode */
+		if (pin == SUNXI_GPA(9) || pin == SUNXI_GPA(14))
+			continue;
+		sunxi_gpio_set_cfgpin(pin, SUN7I_GPA0_GMAC);
+		sunxi_gpio_set_drv(pin, 3);
+	}
+
+	designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
+
+	return 0;
+}
include/configs/sunxi-common.h +26 -0
index 3f7e314..b76c3b0 100644
@@ -127,6 +127,32 @@
 
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 
+#ifdef CONFIG_SUNXI_GMAC
+#define CONFIG_DESIGNWARE_ETH		/* GMAC can use designware driver */
+#define CONFIG_DW_AUTONEG
+#define CONFIG_PHY_GIGE			/* GMAC can use gigabit PHY	*/
+#define CONFIG_PHY_ADDR		1
+#define CONFIG_MII			/* MII PHY management		*/
+#define CONFIG_PHYLIB
+#endif
+
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_SNTP
+#define CONFIG_TIMESTAMP		/* Needed by SNTP */
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_NISDOMAIN
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_DNS2
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_NTPSERVER
+#define CONFIG_BOOTP_TIMEOFFSET
+#define CONFIG_BOOTP_MAY_FAIL
+#define CONFIG_BOOTP_SERVERIP
+#define CONFIG_BOOTP_DHCP_REQUEST_DELAY		50000
+#endif
+
 #if !defined CONFIG_ENV_IS_IN_MMC && \
     !defined CONFIG_ENV_IS_IN_NAND && \
     !defined CONFIG_ENV_IS_IN_FAT && \
include/netdev.h +1 -0
index 32b5073..fc4a2f8 100644
@@ -79,6 +79,7 @@ int sh_eth_initialize(bd_t *bis);
 int skge_initialize(bd_t *bis);
 int smc91111_initialize(u8 dev_num, int base_addr);
 int smc911x_initialize(u8 dev_num, int base_addr);
+int sunxi_gmac_initialize(bd_t *bis);
 int sunxi_wemac_initialize(bd_t *bis);
 int tsi108_eth_initialize(bd_t *bis);
 int uec_standard_init(bd_t *bis);
Signature · 1 line
1.9.0
#11 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

Quoted 42 lines · Ian Campbell

Add support for the GMAC Ethernet controller on Allwinner A20 (sun7i) processors. Enable for the Cubietruck.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- drop accidentally doubled hunk
- use gpio setup functions
- moved before mmc patches

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/board.c | 15 +++++++++++++++
 boards.cfg                       |  2 +-
 drivers/net/Makefile             |  1 +
 drivers/net/sunxi_gmac.c         | 34 ++++++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h   | 26 ++++++++++++++++++++++++++
 include/netdev.h                 |  1 +
 6 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sunxi_gmac.c
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/sunxi/board.c index b5c0cb7..9755320 100644

arch/arm/cpu/armv7/sunxi/board.c +2 -0
@@ -11,6 +11,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
 #include <serial.h>
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>

arch/arm/cpu/armv7/sunxi/board.c void enable_caches(void) · line 92

Quoted 5 lines
arch/arm/cpu/armv7/sunxi/board.c +2 -0
@@ -86,3 +88,16 @@ void enable_caches(void)
 	dcache_enable();
 }
 #endif
+
+#if defined(CONFIG_SUNXI_GMAC)

This is something line ifdef CONFIG_CMD_NET

arch/arm/cpu/armv7/sunxi/board.c void enable_caches(void) · line 99

Quoted 7 lines
arch/arm/cpu/armv7/sunxi/board.c +7 -0
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+	sunxi_gmac_initialize(bis);

And this is CONFIG_SUNXI_GMAC ... what if I wanted to enable USB ethernet or such ?

arch/arm/cpu/armv7/sunxi/board.c void enable_caches(void) · line 101

Quoted 2 lines
arch/arm/cpu/armv7/sunxi/board.c +2 -0
+
+	return 0;

Handle possible failures of sunxi_gmac_initialize() and propagate the return value please.

[...]

arch/arm/cpu/armv7/sunxi/board.c void enable_caches(void) · line 102

Quoted 1 line
arch/arm/cpu/armv7/sunxi/board.c +1 -0
+int sunxi_gmac_initialize(bd_t *bis)

Stick this into arch/arm/sunxi/... , there's no need to keep it in drivers/net/ as it's no real driver, but just a glue.

Quoted 14 lines
arch/arm/cpu/armv7/sunxi/board.c +14 -0
+{
+	int pin;
+	struct sunxi_ccm_reg *const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+	/* Set up clock gating */
+	setbits_le32(&ccm->ahb_gate1, 0x1 << AHB_GATE_OFFSET_GMAC);
+
+	/* Set MII clock */
+	setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
+		CCM_GMAC_CTRL_GPIT_RGMII);
+
+	/* Configure pin mux settings for GMAC */
+	for (pin = SUNXI_GPA(0); pin <= SUNXI_GPA(16); pin++) {

arch/arm/cpu/armv7/sunxi/board.c void enable_caches(void)

Quoted 10 lines
arch/arm/cpu/armv7/sunxi/board.c +10 -0
+		/* skip unused pins in RGMII mode */
+		if (pin == SUNXI_GPA(9) || pin == SUNXI_GPA(14))
+			continue;
+		sunxi_gpio_set_cfgpin(pin, SUN7I_GPA0_GMAC);
+		sunxi_gpio_set_drv(pin, 3);
+	}
+
+	designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
+
+	return 0;

DTTO here, designware_initialize() might fail ...

include/configs/sunxi-common.h line 131

Quoted 11 lines
arch/arm/cpu/armv7/sunxi/board.c +1 -0
+}
(quoted diff) +0 -0

b/include/configs/sunxi-common.h index 3f7e314..b76c3b0 100644

include/configs/sunxi-common.h +2 -0
@@ -127,6 +127,32 @@
 
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 
+#ifdef CONFIG_SUNXI_GMAC
+#define CONFIG_DESIGNWARE_ETH		/* GMAC can use designware driver 

*/

include/configs/sunxi-common.h line 141

Quoted 10 lines
include/configs/sunxi-common.h +10 -0
+#define CONFIG_DW_AUTONEG
+#define CONFIG_PHY_GIGE			/* GMAC can use gigabit PHY	*/
+#define CONFIG_PHY_ADDR		1
+#define CONFIG_MII			/* MII PHY management		*/
+#define CONFIG_PHYLIB
+#endif
+
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_SNTP

Do you really need this ?

include/configs/sunxi-common.h line 153

Quoted 12 lines
include/configs/sunxi-common.h +12 -0
+#define CONFIG_TIMESTAMP		/* Needed by SNTP */
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_NISDOMAIN
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_DNS2
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_NTPSERVER
+#define CONFIG_BOOTP_TIMEOFFSET
+#define CONFIG_BOOTP_MAY_FAIL
+#define CONFIG_BOOTP_SERVERIP
+#define CONFIG_BOOTP_DHCP_REQUEST_DELAY		50000

Just delete this BOOTP nonsense.

#12 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

Quoted 3 lines · Marek Vasut
Quoted 1 line

+#define CONFIG_CMD_SNTP

Do you really need this ?

Doubtful, sunxi doesn't enable (or support) CONFIG_CMD_DATE so SNTP doesn't even do anything. I'll drop it.

Quoted 6 lines
Quoted 6 lines
include/configs/sunxi-common.h +6 -0
+#define CONFIG_TIMESTAMP             /* Needed by SNTP */
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_NISDOMAIN
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_DNS2
Quoted 8 lines

include/configs/sunxi-common.h line 153

Quoted 6 lines
include/configs/sunxi-common.h +6 -0
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_NTPSERVER
+#define CONFIG_BOOTP_TIMEOFFSET
+#define CONFIG_BOOTP_MAY_FAIL
+#define CONFIG_BOOTP_SERVERIP
+#define CONFIG_BOOTP_DHCP_REQUEST_DELAY              50000

Just delete this BOOTP nonsense.

All of them? I'm thinking of keeping SEND_HOSTNAME which seems useful (surprised it isn't in config_distro_defaults.h) and perhaps DNS2 (I figure why not?).

The only other one I'm not sure about is BOOTFILESIZE -- it's widely enabled but AFAICT is only logged and does nothing useful. I'm erring on the side of dropping it.

Ian.

#13 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

Quoted 23 lines · Ian Campbell
Quoted 3 lines · Marek Vasut
Quoted 1 line

+#define CONFIG_CMD_SNTP

Do you really need this ?

Doubtful, sunxi doesn't enable (or support) CONFIG_CMD_DATE so SNTP doesn't even do anything. I'll drop it.

Quoted 6 lines
Quoted 6 lines
include/configs/sunxi-common.h +6 -0
+#define CONFIG_TIMESTAMP             /* Needed by SNTP */
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_NISDOMAIN
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_DNS2
Quoted 8 lines

include/configs/sunxi-common.h line 153

Quoted 6 lines
include/configs/sunxi-common.h +6 -0
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_NTPSERVER
+#define CONFIG_BOOTP_TIMEOFFSET
+#define CONFIG_BOOTP_MAY_FAIL
+#define CONFIG_BOOTP_SERVERIP
+#define CONFIG_BOOTP_DHCP_REQUEST_DELAY              50000

Just delete this BOOTP nonsense.

Quoted 7 lines

All of them? I'm thinking of keeping SEND_HOSTNAME which seems useful (surprised it isn't in config_distro_defaults.h) and perhaps DNS2 (I figure why not?).

The only other one I'm not sure about is BOOTFILESIZE -- it's widely enabled but AFAICT is only logged and does nothing useful. I'm erring on the side of dropping it.

Do you use BOOTP at all ?

Best regards,
Marek Vasut

#14 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

Quoted 1 line · Marek Vasut

Do you use BOOTP at all ?

Despite the names many of these options are related to both DHCP and BOOTP. I imagine more people are using DHCP than BOOTP these days but I don't know that I would rule out BOOTP.

Ian.

#15 lore raw

PATCH v3 6/9 sunxi: add gmac Ethernet support

Quoted 6 lines · Ian Campbell
Quoted 1 line · Marek Vasut

Do you use BOOTP at all ?

Despite the names many of these options are related to both DHCP and BOOTP. I imagine more people are using DHCP than BOOTP these days but I don't know that I would rule out BOOTP.

I use DHCP boot on all those boards without having any of that BOOTP nonsense enabled, so I believe it's fine. Let's kill it and if someone is complaining, then he can submit a patch to re-enable what he needs.

Best regards,
Marek Vasut

#16 lore raw

PATCH v3 7/9 sunxi: mmc support

In reply to Ian Campbell

This adds support for the MMC controller on the Allwinner A20 (sun7i) processor.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- use proper gpio interfaces, removing awkward casts and some magic numbers.
- remove magic numbers
- other cleanups

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

mmc: drop debug

---
 arch/arm/include/asm/arch-sunxi/mmc.h | 124 ++++++++
 board/sunxi/board.c                   |  13 +
 drivers/mmc/Makefile                  |   1 +
 drivers/mmc/sunxi_mmc.c               | 559 ++++++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h        |  11 +
 5 files changed, 708 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-sunxi/mmc.h
 create mode 100644 drivers/mmc/sunxi_mmc.c
arch/arm/include/asm/arch-sunxi/mmc.h new file +124 -0
new file mode 100644
index 0000000..53196e3
@@ -0,0 +1,124 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Aaron <[email protected]>
+ *
+ * MMC register definition for allwinner sunxi platform.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _SUNXI_MMC_H
+#define _SUNXI_MMC_H
+
+#include <linux/types.h>
+
+struct sunxi_mmc {
+	u32 gctrl;		/* 0x00 global control */
+	u32 clkcr;		/* 0x04 clock control */
+	u32 timeout;		/* 0x08 time out */
+	u32 width;		/* 0x0c bus width */
+	u32 blksz;		/* 0x10 block size */
+	u32 bytecnt;		/* 0x14 byte count */
+	u32 cmd;		/* 0x18 command */
+	u32 arg;		/* 0x1c argument */
+	u32 resp0;		/* 0x20 response 0 */
+	u32 resp1;		/* 0x24 response 1 */
+	u32 resp2;		/* 0x28 response 2 */
+	u32 resp3;		/* 0x2c response 3 */
+	u32 imask;		/* 0x30 interrupt mask */
+	u32 mint;		/* 0x34 masked interrupt status */
+	u32 rint;		/* 0x38 raw interrupt status */
+	u32 status;		/* 0x3c status */
+	u32 ftrglevel;		/* 0x40 FIFO threshold watermark*/
+	u32 funcsel;		/* 0x44 function select */
+	u32 cbcr;		/* 0x48 CIU byte count */
+	u32 bbcr;		/* 0x4c BIU byte count */
+	u32 dbgc;		/* 0x50 debug enable */
+	u32 res0[11];
+	u32 dmac;		/* 0x80 internal DMA control */
+	u32 dlba;		/* 0x84 internal DMA descr list base address */
+	u32 idst;		/* 0x88 internal DMA status */
+	u32 idie;		/* 0x8c internal DMA interrupt enable */
+	u32 chda;		/* 0x90 */
+	u32 cbda;		/* 0x94 */
+	u32 res1[26];
+	u32 fifo;		/* 0x100 FIFO access address */
+};
+
+#define SUNXI_MMC_CLK_POWERSAVE		(0x1 << 17)
+#define SUNXI_MMC_CLK_ENABLE		(0x1 << 16)
+#define SUNXI_MMC_CLK_DIVIDER_MASK	(0xff)
+
+#define SUNXI_MMC_GCTRL_SOFT_RESET	(0x1 << 0)
+#define SUNXI_MMC_GCTRL_FIFO_RESET	(0x1 << 1)
+#define SUNXI_MMC_GCTRL_DMA_RESET	(0x1 << 2)
+#define SUNXI_MMC_GCTRL_RESET		(SUNXI_MMC_GCTRL_SOFT_RESET|\
+					 SUNXI_MMC_GCTRL_FIFO_RESET|\
+					 SUNXI_MMC_GCTRL_DMA_RESET)
+#define SUNXI_MMC_GCTRL_DMA_ENABLE	(0x1 << 5)
+#define SUNXI_MMC_GCTRL_ACCESS_BY_AHB   (0x1 << 31)
+
+#define SUNXI_MMC_CMD_RESP_EXPIRE	(0x1 << 6)
+#define SUNXI_MMC_CMD_LONG_RESPONSE	(0x1 << 7)
+#define SUNXI_MMC_CMD_CHK_RESPONSE_CRC	(0x1 << 8)
+#define SUNXI_MMC_CMD_DATA_EXPIRE	(0x1 << 9)
+#define SUNXI_MMC_CMD_WRITE		(0x1 << 10)
+#define SUNXI_MMC_CMD_AUTO_STOP		(0x1 << 12)
+#define SUNXI_MMC_CMD_WAIT_PRE_OVER	(0x1 << 13)
+#define SUNXI_MMC_CMD_SEND_INIT_SEQ	(0x1 << 15)
+#define SUNXI_MMC_CMD_UPCLK_ONLY	(0x1 << 21)
+#define SUNXI_MMC_CMD_START		(0x1 << 31)
+
+#define SUNXI_MMC_RINT_RESP_ERROR		(0x1 << 1)
+#define SUNXI_MMC_RINT_COMMAND_DONE		(0x1 << 2)
+#define SUNXI_MMC_RINT_DATA_OVER		(0x1 << 3)
+#define SUNXI_MMC_RINT_TX_DATA_REQUEST		(0x1 << 4)
+#define SUNXI_MMC_RINT_RX_DATA_REQUEST		(0x1 << 5)
+#define SUNXI_MMC_RINT_RESP_CRC_ERROR		(0x1 << 6)
+#define SUNXI_MMC_RINT_DATA_CRC_ERROR		(0x1 << 7)
+#define SUNXI_MMC_RINT_RESP_TIMEOUT		(0x1 << 8)
+#define SUNXI_MMC_RINT_DATA_TIMEOUT		(0x1 << 9)
+#define SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE	(0x1 << 10)
+#define SUNXI_MMC_RINT_FIFO_RUN_ERROR		(0x1 << 11)
+#define SUNXI_MMC_RINT_HARD_WARE_LOCKED		(0x1 << 12)
+#define SUNXI_MMC_RINT_START_BIT_ERROR		(0x1 << 13)
+#define SUNXI_MMC_RINT_AUTO_COMMAND_DONE	(0x1 << 14)
+#define SUNXI_MMC_RINT_END_BIT_ERROR		(0x1 << 15)
+#define SUNXI_MMC_RINT_SDIO_INTERRUPT		(0x1 << 16)
+#define SUNXI_MMC_RINT_CARD_INSERT		(0x1 << 30)
+#define SUNXI_MMC_RINT_CARD_REMOVE		(0x1 << 31)
+#define SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT      \
+	(SUNXI_MMC_RINT_RESP_ERROR |		\
+	 SUNXI_MMC_RINT_RESP_CRC_ERROR |	\
+	 SUNXI_MMC_RINT_DATA_CRC_ERROR |	\
+	 SUNXI_MMC_RINT_RESP_TIMEOUT |		\
+	 SUNXI_MMC_RINT_DATA_TIMEOUT |		\
+	 SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE |	\
+	 SUNXI_MMC_RINT_FIFO_RUN_ERROR |	\
+	 SUNXI_MMC_RINT_HARD_WARE_LOCKED |	\
+	 SUNXI_MMC_RINT_START_BIT_ERROR |	\
+	 SUNXI_MMC_RINT_END_BIT_ERROR) /* 0xbfc2 */
+#define SUNXI_MMC_RINT_INTERRUPT_DONE_BIT	\
+	(SUNXI_MMC_RINT_AUTO_COMMAND_DONE |	\
+	 SUNXI_MMC_RINT_DATA_OVER |		\
+	 SUNXI_MMC_RINT_COMMAND_DONE |		\
+	 SUNXI_MMC_RINT_VOLTAGE_CHANGE_DONE)
+
+#define SUNXI_MMC_STATUS_RXWL_FLAG		(0x1 << 0)
+#define SUNXI_MMC_STATUS_TXWL_FLAG		(0x1 << 1)
+#define SUNXI_MMC_STATUS_FIFO_EMPTY		(0x1 << 2)
+#define SUNXI_MMC_STATUS_FIFO_FULL		(0x1 << 3)
+#define SUNXI_MMC_STATUS_CARD_PRESENT		(0x1 << 8)
+#define SUNXI_MMC_STATUS_CARD_DATA_BUSY		(0x1 << 9)
+#define SUNXI_MMC_STATUS_DATA_FSM_BUSY		(0x1 << 10)
+
+#define SUNXI_MMC_IDMAC_RESET		(0x1 << 0)
+#define SUNXI_MMC_IDMAC_FIXBURST	(0x1 << 1)
+#define SUNXI_MMC_IDMAC_ENABLE		(0x1 << 7)
+
+#define SUNXI_MMC_IDIE_TXIRQ		(0x1 << 0)
+#define SUNXI_MMC_IDIE_RXIRQ		(0x1 << 1)
+
+int sunxi_mmc_init(int sdc_no);
+#endif /* _SUNXI_MMC_H */
board/sunxi/board.c +13 -0
index 328334a..06c9264 100644
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/dram.h>
+#include <asm/arch/mmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -43,6 +44,18 @@ int dram_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_GENERIC_MMC
+int board_mmc_init(bd_t *bis)
+{
+	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
+#if !defined (CONFIG_SPL_BUILD) && defined (CONFIG_MMC_SUNXI_SLOT_EXTRA)
+	sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+#endif
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void sunxi_board_init(void)
 {
drivers/mmc/Makefile +1 -0
index 931922b..5e67098 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_SPEAR_SDHCI) += spear_sdhci.o
 obj-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+obj-$(CONFIG_MMC_SUNXI) += sunxi_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
 ifdef CONFIG_SPL_BUILD
drivers/mmc/sunxi_mmc.c new file +559 -0

559 lines not on this page · raw message

include/configs/sunxi-common.h +11 -0
index b76c3b0..ede3d50 100644
@@ -59,6 +59,16 @@
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 
+/* mmc config */
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_MMC
+#define CONFIG_MMC_SUNXI
+#define CONFIG_MMC_SUNXI_SLOT		0
+#define CONFIG_MMC_SUNXI_USE_DMA
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
+
 /* 4MB of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4 << 20))
 
@@ -94,6 +104,7 @@
 #define CONFIG_SYS_MONITOR_LEN		(512 << 10)	/* 512 KiB */
 #define CONFIG_IDENT_STRING		" Allwinner Technology"
 
+#define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
 #define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
Signature · 1 line
1.9.0
#17 lore raw

PATCH v3 7/9 sunxi: mmc support

Quoted 12 lines · Ian Campbell

This adds support for the MMC controller on the Allwinner A20 (sun7i) processor.

[...]

Quoted 11 lines
drivers/mmc/sunxi_mmc.c new file +11 -0
+static int mmc_clk_io_on(int sdc_no)
+{
+	unsigned int pin;
+	unsigned int rval;
+	unsigned int pll_clk;
+	unsigned int divider;
+	struct sunxi_mmc_host *mmchost = &mmc_host[sdc_no];
+	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+	debug("init mmc %d clock and io\n", sdc_no);
+

drivers/mmc/sunxi_mmc.c line 109

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	/* config gpio */
+	switch (sdc_no) {
+	case 0:
+		/* D1-PF0, D0-PF1, CLK-PF2, CMD-PF3, D3-PF4, D4-PF5 */
+		for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
+			sunxi_gpio_set_cfgpin(pin, SUNXI_GPF0_SDC0);
+			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+			sunxi_gpio_set_drv(pin, 2);
+		}
+		break;

Pinmux config is part of board files , not part of driver. [...]

Best regards,
Marek Vasut

#18 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

In reply to Ian Campbell

Add support for booting from an MMC card.

---
v3: Based on c89867dca2e9 "sunxi: clocks: clock_get_pll5 prototype and coding style".

v2: Based on u-boot-sunxi.git#sunxi d9aa5dd3d15c "sunxi: mmc:
checkpatch whitespace fixes" with v2014.04-rc2 merged in:
- mksunxiboot cleanups
- rebase on Kbuild stuff

v1: Based on u-boot-sunxi.git#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 Makefile                                |  10 +++
 arch/arm/cpu/armv7/sunxi/config.mk      |   8 ++
 arch/arm/cpu/armv7/sunxi/u-boot-spl.lds |  52 +++++++++++
 boards.cfg                              |   1 +
 include/configs/sunxi-common.h          |  26 ++++++
 spl/Makefile                            |  13 +++
 tools/.gitignore                        |   1 +
 tools/Makefile                          |   2 +
 tools/mksunxiboot.c                     | 154 ++++++++++++++++++++++++++++++++
 9 files changed, 267 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/sunxi/config.mk
 create mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
 create mode 100644 tools/mksunxiboot.c
Makefile +10 -0
index c91c10e..379731c 100644
@@ -870,6 +870,13 @@ OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
 u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
 	$(call if_changed,pad_cat)
 
+ifneq ($(CONFIG_SUNXI),)
+OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \
+				   --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
+u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE
+	$(call if_changed,pad_cat)
+endif
+
 ifneq ($(CONFIG_TEGRA),)
 OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
 u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
@@ -1081,6 +1088,9 @@ spl/u-boot-spl.bin: spl/u-boot-spl
 spl/u-boot-spl: tools prepare
 	$(Q)$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
 
+spl/sunxi-spl.bin: spl/u-boot-spl
+	@:
+
 tpl/u-boot-tpl.bin: tools prepare
 	$(Q)$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
 
arch/arm/cpu/armv7/sunxi/config.mk new file +8 -0
new file mode 100644
index 0000000..00f5ffc
@@ -0,0 +1,8 @@
+# Build a combined spl + u-boot image
+ifdef CONFIG_SPL
+ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_FEL
+ALL-y += u-boot-sunxi-with-spl.bin
+endif
+endif
+endif
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds new file +52 -0

52 lines not on this page · raw message

boards.cfg +1 -0
index b74f8c8..b6e20ae 100644
@@ -371,6 +371,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                             -                                                                                                                                 Mateusz Zalega <[email protected]>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                             -                                                                                                                                 Minkyu Kang <[email protected]>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                     -                                                                                                                                 -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck                           sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII                                                                                             -
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <[email protected]>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                           -                                                                                                                                 -
include/configs/sunxi-common.h +26 -0
index ede3d50..56a89b9 100644
@@ -17,6 +17,11 @@
  * High Level Configuration Options
  */
 #define CONFIG_SUNXI		/* sunxi family */
+#ifdef CONFIG_SPL_BUILD
+#ifndef CONFIG_SPL_FEL
+#define CONFIG_SYS_THUMB_BUILD	/* Thumbs mode to save space in SPL */
+#endif
+#endif
 
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 
@@ -121,11 +126,32 @@
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 
+#ifdef CONFIG_SPL_FEL
+
 #define CONFIG_SPL
 #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds"
 #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/armv7/sunxi"
 #define CONFIG_SPL_TEXT_BASE		0x2000
 #define CONFIG_SPL_MAX_SIZE		0x4000		/* 16 KiB */
+
+#else /* CONFIG_SPL */
+
+#define CONFIG_SPL_BSS_START_ADDR	0x4ff80000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000		/* 512 KiB */
+
+#define CONFIG_SPL_TEXT_BASE		0x20		/* sram start+header */
+#define CONFIG_SPL_MAX_SIZE		0x5fe0		/* 24KB on sun4i/sun7i */
+
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+
+#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/sunxi/u-boot-spl.lds"
+
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	80	/* 40KiB */
+#define CONFIG_SPL_PAD_TO		32768		/* decimal for 'dd' */
+
+#endif /* CONFIG_SPL */
+
 /* end of 32 KiB in sram */
 #define LOW_LEVEL_SRAM_STACK		0x00008000 /* End of sram */
 #define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
spl/Makefile +13 -0
index 6fec252..e7c7a95 100644
@@ -188,6 +188,12 @@ ifdef CONFIG_SAMSUNG
 ALL-y	+= $(obj)/$(BOARD)-spl.bin
 endif
 
+ifdef CONFIG_SUNXI
+ifndef CONFIG_SPL_FEL
+ALL-y	+= $(obj)/sunxi-spl.bin
+endif
+endif
+
 all:	$(ALL-y)
 
 ifdef CONFIG_SAMSUNG
@@ -215,6 +221,13 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
 
+ifdef CONFIG_SUNXI
+quiet_cmd_mksunxiboot = MKSUNXI $@
+cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
+$(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin
+	$(call if_changed,mksunxiboot)
+endif
+
 quiet_cmd_u-boot-spl = LD      $@
       cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
 		       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
tools/.gitignore +1 -0
index 2a90dfe..3ad5db3 100644
@@ -9,6 +9,7 @@
 /mkexynosspl
 /mpc86x_clk
 /mxsboot
+/mksunxiboot
 /ncb
 /proftool
 /relocate-rela
tools/Makefile +2 -0
index 097cc1d..062a404 100644
@@ -120,6 +120,8 @@ hostprogs-$(CONFIG_MX23) += mxsboot$(SFX)
 hostprogs-$(CONFIG_MX28) += mxsboot$(SFX)
 HOSTCFLAGS_mxsboot$(SFX).o := -pedantic
 
+hostprogs-$(CONFIG_SUNXI) += mksunxiboot$(SFX)
+
 hostprogs-$(CONFIG_NETCONSOLE) += ncb$(SFX)
 hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
 
tools/mksunxiboot.c new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
1.9.0
#19 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 6 lines · Ian Campbell

Add support for booting from an MMC card.

[...]

tools/mksunxiboot.c line 20

Quoted 2 lines
tools/mksunxiboot.c new file +2 -0
+typedef unsigned char u8;
+typedef unsigned int u32;

Uh, really ? Just use uint8_t or uint32_t ...

tools/mksunxiboot.c line 33

Quoted 12 lines
tools/mksunxiboot.c new file +12 -0
+/* boot head definition from sun4i boot code */
+struct boot_file_head {
+	u32 jump_instruction;	/* one intruction jumping to real code */
+	u8 magic[8];		/* ="eGON.BT0" or "eGON.BT1", not C-style str */
+	u32 check_sum;		/* generated by PC */
+	u32 length;		/* generated by PC */
+#if 1
+	/* We use a simplified header, only filling in what is needed by the
+	 * boot ROM. To be compatible with Allwinner tools the larger header
+	 * below should be used, followed by a custom header if desired. */
+	u8 pad[12];		/* align to 32 bytes */
+#else

Please fix or remove dead code.

Quoted 18 lines
tools/mksunxiboot.c new file +18 -0
+	u32 pub_head_size;	/* the size of boot_file_head */
+	u8 pub_head_vsn[4];	/* the version of boot_file_head */
+	u8 file_head_vsn[4];	/* the version of boot0_file_head or
+				   boot1_file_head */
+	u8 Boot_vsn[4];		/* Boot version */
+	u8 eGON_vsn[4];		/* eGON version */
+	u8 platform[8];		/* platform information */
+#endif
+};
+
+#define BOOT0_MAGIC                     "eGON.BT0"
+#define STAMP_VALUE                     0x5F0A6C39
+
+/* check sum functon from sun4i boot code */
+int gen_check_sum(void *boot_buf)
+{
+	struct boot_file_head *head_p;
+	u32 length;

tools/mksunxiboot.c line 61

Quoted 10 lines
tools/mksunxiboot.c new file +10 -0
+	u32 *buf;
+	u32 loop;
+	u32 i;
+	u32 sum;
+
+	head_p = (struct boot_file_head *)boot_buf;
+	length = head_p->length;
+	if ((length & 0x3) != 0)	/* must 4-byte-aligned */
+		return -1;
+	buf = (u32 *)boot_buf;

This will cause unaligned access if ran on ARM and boot_buf is not aligned.

Quoted 5 lines
tools/mksunxiboot.c new file +5 -0
+	head_p->check_sum = STAMP_VALUE;	/* fill stamp */
+	loop = length >> 2;
+
+	/* calculate the sum */
+	for (i = 0, sum = 0; i < loop; i++)

tools/mksunxiboot.c line 76

Quoted 10 lines
tools/mksunxiboot.c new file +10 -0
+		sum += buf[i];
+
+	/* write back check sum */
+	head_p->check_sum = sum;
+
+	return 0;
+}
+
+#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
+#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))

Isn't this already defined in include/common.h ?

Looks like this tool might as well be wrapped into the mkimage toolset ...

#20 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 4 lines · Marek Vasut

tools/mksunxiboot.c line 76

Quoted 2 lines
tools/mksunxiboot.c new file +2 -0
+#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
+#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))

Isn't this already defined in include/common.h ?

Yes but it seems that header isn't usable by tools/* AFAICT. I get a boatload of compiler errors when I try...

Ian.

#21 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 8 lines · Ian Campbell
Quoted 4 lines · Marek Vasut

tools/mksunxiboot.c line 76

Quoted 2 lines
tools/mksunxiboot.c new file +2 -0
+#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
+#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))

Isn't this already defined in include/common.h ?

Yes but it seems that header isn't usable by tools/* AFAICT. I get a boatload of compiler errors when I try...

There are a couple of things which include it even in tools/ :

# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header files and 
outputs the final
tools/updater/cmd_flash.c:#include <common.h>
tools/updater/flash.c:#include <common.h>
tools/updater/flash_hw.c:#include <common.h>
tools/updater/update.c:#include <common.h>
tools/updater/utils.c:#include <common.h>

btw. I should have escaped the dot in common.h pattern, but whatever ...

Best regards,
Marek Vasut

#22 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 5 lines · Marek Vasut
# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header files and 
outputs the final

I only got these three when I looked. I'm on v2014.04, but even with current trunk I only see fit_common.h not the ones which you show below (tools/updater isn't even in trunk). Perhaps this is some newer stuff not yet in trunk?

Quoted 11 lines

tools/updater/cmd_flash.c:#include <common.h>
tools/updater/flash.c:#include <common.h>
tools/updater/flash_hw.c:#include <common.h>
tools/updater/update.c:#include <common.h>
tools/updater/utils.c:#include <common.h>

btw. I should have escaped the dot in common.h pattern, but whatever ...

Best regards,
Marek Vasut

#23 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 11 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header
files and outputs the final

I only got these three when I looked. I'm on v2014.04, but even with current trunk I only see fit_common.h not the ones which you show below (tools/updater isn't even in trunk). Perhaps this is some newer stuff not yet in trunk?

Ah, darn. What errors do you get ?

Best regards,
Marek Vasut

#24 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 8 lines · Marek Vasut
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header
files and outputs the final
Quoted 6 lines
Quoted 4 lines

I only got these three when I looked. I'm on v2014.04, but even with current trunk I only see fit_common.h not the ones which you show below (tools/updater isn't even in trunk). Perhaps this is some newer stuff not yet in trunk?

Ah, darn. What errors do you get ?

All sorts...

HOSTCC tools/mksunxiboot
In file included from include/common.h:20:0,
from tools/mksunxiboot.c:18:
include/linux/bitops.h: In function ?generic_set_bit?:
include/linux/bitops.h:141:23: error: ?BITS_PER_LONG? undeclared (first use in this function)

  unsigned long mask = BIT_MASK(nr);
                       ^
include/linux/bitops.h:141:23: note: each undeclared identifier is reported only once for each function it appears in
include/linux/bitops.h: In function ?generic_clear_bit?:
include/linux/bitops.h:149:23: error: ?BITS_PER_LONG? undeclared (first use in this function)
  unsigned long mask = BIT_MASK(nr);
                       ^

In file included from include/part.h:177:0,
from include/common.h:92,
from tools/mksunxiboot.c:18:
include/part_efi.h: At top level:
include/part_efi.h:62:1: error: unknown type name ?u16?
typedef u16 efi_char16_t;
^
include/part_efi.h:65:2: error: unknown type name ?u8?
u8 b[16];
^
include/part_efi.h:70:2: error: unknown type name ?u8?
u8 boot_ind; /* 0x80 - active */
^
include/part_efi.h:71:2: error: unknown type name ?u8?
u8 head; /* starting head */
^
include/part_efi.h:72:2: error: unknown type name ?u8?
u8 sector; /* starting sector */
^
include/part_efi.h:73:2: error: unknown type name ?u8?
u8 cyl; /* starting cylinder */
^
include/part_efi.h:74:2: error: unknown type name ?u8?
u8 sys_ind; /* What partition type */
^
include/part_efi.h:75:2: error: unknown type name ?u8?
u8 end_head; /* end head */
^
include/part_efi.h:76:2: error: unknown type name ?u8?
u8 end_sector; /* end sector */
^
include/part_efi.h:77:2: error: unknown type name ?u8?
u8 end_cyl; /* end cylinder */
^
include/part_efi.h:98:12: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?gpt_header?

 } __packed gpt_header;
            ^

include/part_efi.h:102:3: error: unknown type name ?u64?
u64 required_to_function:1;
^
include/part_efi.h:103:3: error: unknown type name ?u64?
u64 no_block_io_protocol:1;
^
include/part_efi.h:104:3: error: unknown type name ?u64?
u64 legacy_bios_bootable:1;
^
include/part_efi.h:105:3: error: unknown type name ?u64?
u64 reserved:45;
^
include/part_efi.h:105:3: error: width of ?reserved? exceeds its type include/part_efi.h:106:3: error: unknown type name ?u64?
u64 type_guid_specific:16;
^
include/part_efi.h:109:12: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?gpt_entry_attributes?

 } __packed gpt_entry_attributes;
            ^

include/part_efi.h:117:2: error: unknown type name ?gpt_entry_attributes?
gpt_entry_attributes attributes;
^
include/part_efi.h:119:12: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?gpt_entry?

 } __packed gpt_entry;
            ^

include/part_efi.h:122:2: error: unknown type name ?u8?
u8 boot_code[440];
^
include/part_efi.h:127:12: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?legacy_mbr?

 } __packed legacy_mbr;
            ^
In file included from include/common.h:92:0,
                 from tools/mksunxiboot.c:18:
include/part.h:193:5: error: unknown type name ?gpt_header?
     gpt_header *gpt_h, gpt_entry *gpt_e);
     ^
include/part.h:193:24: error: unknown type name ?gpt_entry?
     gpt_header *gpt_h, gpt_entry *gpt_e);
                        ^
include/part.h:205:18: error: unknown type name ?gpt_header?
 int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
                  ^
include/part.h:205:37: error: unknown type name ?gpt_entry?
 int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
                                     ^
include/part.h:218:49: error: unknown type name ?gpt_header?
 int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
                                                 ^

In file included from include/image.h:49:0,
from include/common.h:94,
from tools/mksunxiboot.c:18:
include/fdt_support.h:15:1: error: unknown type name ?u32?
u32 fdt_getprop_u32_default(const void *fdt, const char *path, ^
include/fdt_support.h:16:5: error: unknown type name ?u32?

     const char *prop, const u32 dflt);
     ^
include/fdt_support.h:22:6: error: unknown type name ?u32?
      u32 val, int create);
      ^
include/fdt_support.h:36:24: error: unknown type name ?u32?
      const char *prop, u32 val, int create);
                        ^
include/fdt_support.h:40:26: error: unknown type name ?u32?
        const char *prop, u32 val, int create);
                          ^
include/fdt_support.h:41:34: error: unknown type name ?u64?
 int fdt_fixup_memory(void *blob, u64 start, u64 size);
                                  ^
include/fdt_support.h:41:45: error: unknown type name ?u64?
 int fdt_fixup_memory(void *blob, u64 start, u64 size);
                                             ^
include/fdt_support.h:42:40: error: unknown type name ?u64?
 int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks);
                                        ^
include/fdt_support.h:42:53: error: unknown type name ?u64?
 int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks);
                                                     ^
include/fdt_support.h:51:49: error: unknown type name ?bd_t?
 static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
                                                 ^
include/fdt_support.h:65:33: error: unknown type name ?bd_t?
 void ft_board_setup(void *blob, bd_t *bd);
                                 ^
include/fdt_support.h:66:31: error: unknown type name ?bd_t?
 void ft_cpu_setup(void *blob, bd_t *bd);
                               ^
include/fdt_support.h:67:31: error: unknown type name ?bd_t?
 void ft_pci_setup(void *blob, bd_t *bd);
                               ^

include/fdt_support.h:77:1: error: unknown type name ?u64?
u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr); ^
include/fdt_support.h:79:6: error: unknown type name ?phys_addr_t?

      phys_addr_t compat_off);
      ^
include/fdt_support.h:86:10: error: unknown type name ?u64?
          u64 addr);
          ^

include/fdt_support.h:87:1: error: unknown type name ?u64?
u64 fdt_get_base_address(void *fdt, int node);
^
In file included from include/common.h:94:0,
from tools/mksunxiboot.c:18:
include/image.h:322:13: error: field ?lmb? has incomplete type
struct lmb lmb; /* for memory mgmt */

             ^
include/image.h: In function ?fit_image_check_target_arch?:
include/image.h:981:41: error: ?IH_ARCH_DEFAULT? undeclared (first use in this function)
  return fit_image_check_arch(fdt, node, IH_ARCH_DEFAULT);
                                         ^
In file included from /home/ijc/devel/u-boot.git/arch/arm/include/asm/u-boot.h:25:0,
                 from include/common.h:153,
                 from tools/mksunxiboot.c:18:

include/asm-generic/u-boot.h: At top level:
include/asm-generic/u-boot.h:29:2: error: unknown type name ?phys_size_t?
phys_size_t bi_memsize; /* size of DRAM memory in bytes */
^
In file included from /home/ijc/devel/u-boot.git/arch/arm/include/asm/global_data.h:45:0,

                 from include/common.h:154,
                 from tools/mksunxiboot.c:18:

include/asm-generic/global_data.h:60:2: error: unknown type name ?phys_size_t?
phys_size_t ram_size; /* RAM size */
^
In file included from tools/mksunxiboot.c:18:0:
include/common.h:267:1: error: unknown type name ?phys_size_t?
phys_size_t initdram (int);
^
include/common.h:306:1: error: unknown type name ?u8?
extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
^
include/common.h:352:14: error: unknown type name ?cmd_tbl_t?
int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);

              ^
include/common.h:355:19: error: unknown type name ?cmd_tbl_t?
 int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
                   ^
include/common.h:358:17: error: unknown type name ?cmd_tbl_t?
 int do_ext2load(cmd_tbl_t *, int, int, char * const []);
                 ^
include/common.h:391:5: error: conflicting types for ?setenv?
 int setenv      (const char *, const char *);
     ^
In file included from /home/ijc/devel/u-boot.git/include/compiler.h:23:0,
                 from /home/ijc/devel/u-boot.git/include/libfdt_env.h:12,
                 from <command-line>:0:
/usr/include/stdlib.h:584:12: note: previous declaration of ?setenv? was here
 extern int setenv (const char *__name, const char *__value, int __replace)
            ^

In file included from tools/mksunxiboot.c:18:0:
include/common.h:471:1: error: unknown type name ?phys_size_t?
phys_size_t get_effective_memsize(void);
^
include/common.h:635:1: error: unknown type name ?u32?
u32 cpu_mask (void);
^
In file included from include/common.h:825:0,
from tools/mksunxiboot.c:18:
include/uuid.h:18:3: error: conflicting types for ?__packed?
} __packed;
^
In file included from include/part.h:177:0,
from include/common.h:92,
from tools/mksunxiboot.c:18:
include/part_efi.h:80:3: note: previous declaration of ?__packed? was here
} __packed;
^
In file included from /home/ijc/devel/u-boot.git/include/compiler.h:25:0,

                 from /home/ijc/devel/u-boot.git/include/libfdt_env.h:12,
                 from <command-line>:0:
include/common.h:860:5: error: conflicting types for ?_IO_getc?
 int getc(void);
     ^
In file included from /usr/include/stdio.h:74:0,
                 from /home/ijc/devel/u-boot.git/include/compiler.h:25,
                 from /home/ijc/devel/u-boot.git/include/libfdt_env.h:12,
                 from <command-line>:0:
/usr/include/libio.h:434:12: note: previous declaration of ?_IO_getc? was here
 extern int _IO_getc (_IO_FILE *__fp);
            ^
In file included from tools/mksunxiboot.c:18:0:
include/common.h:864:23: error: macro "putc" requires 2 arguments, but only 1 given
 void putc(const char c);
                       ^
include/common.h:864:6: error: ?putc? redeclared as different kind of symbol
 void putc(const char c);
      ^
include/common.h:865:6: error: conflicting types for ?puts?
 void puts(const char *s);
      ^
include/common.h:883:5: error: conflicting types for ?fprintf?
 int fprintf(int file, const char *fmt, ...)
     ^
include/common.h:885:6: error: conflicting types for ?fputs?
 void fputs(int file, const char *s);
      ^
include/common.h:886:6: error: conflicting types for ?fputc?
 void fputc(int file, const char c);
      ^
include/common.h:888:5: error: conflicting types for ?fgetc?
 int fgetc(int file);
     ^
In file included from /home/ijc/devel/u-boot.git/include/compiler.h:25:0,
                 from /home/ijc/devel/u-boot.git/include/libfdt_env.h:12,
                 from <command-line>:0:
/usr/include/stdio.h:531:12: note: previous declaration of ?fgetc? was here
 extern int fgetc (FILE *__stream);
            ^

In file included from include/common.h:898:0,
from tools/mksunxiboot.c:18:
include/net.h:632:1: error: unknown type name ?u8?
static inline int is_zero_ether_addr(const u8 *addr)
^
include/net.h:644:1: error: unknown type name ?u8?
static inline int is_multicast_ether_addr(const u8 *addr) ^
include/net.h:655:1: error: unknown type name ?u8?
static inline int is_broadcast_ether_addr(const u8 *addr) ^
include/net.h:670:1: error: unknown type name ?u8?
static inline int is_valid_ether_addr(const u8 *addr)
^
In file included from tools/mksunxiboot.c:18:0:
include/common.h:933:32: error: unknown type name ?phys_addr_t?
static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)

                                ^

include/common.h:942:1: error: unknown type name ?phys_addr_t?
static inline phys_addr_t map_to_sysmem(const void *ptr)
^
include/common.h: In function ?map_to_sysmem?:
include/common.h:944:10: error: ?phys_addr_t? undeclared (first use in this function)

  return (phys_addr_t)(uintptr_t)ptr;
          ^
include/common.h:944:23: error: expected expression before ?uintptr_t?
  return (phys_addr_t)(uintptr_t)ptr;
                       ^
include/common.h:944:33: error: expected ?;? before ?ptr?
  return (phys_addr_t)(uintptr_t)ptr;
                                 ^

make[1]: *** [tools/mksunxiboot] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [tools] Error 2

#25 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 9 lines · Ian Campbell
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header
files and outputs the final
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I only got these three when I looked. I'm on v2014.04, but even with current trunk I only see fit_common.h not the ones which you show below (tools/updater isn't even in trunk). Perhaps this is some newer stuff not yet in trunk?

Ah, darn. What errors do you get ?

All sorts...

Ouch, ok. How come the other files can include this stuff without errors ?

Best regards,
Marek Vasut

#26 lore raw

PATCH v3 8/9 sunxi: non-FEL SPL boot support for sun7i

Quoted 15 lines · Marek Vasut
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
# git grep common.h tools/
tools/patman/test.py: include/common.h    |    8 ++++++
tools/patman/test.py:+#include <common.h>
tools/scripts/define2mk.sed:# which preprocesses the common.h header
files and outputs the final

I only got these three when I looked. I'm on v2014.04, but even with current trunk I only see fit_common.h not the ones which you show below (tools/updater isn't even in trunk). Perhaps this is some newer stuff not yet in trunk?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ah, darn. What errors do you get ?

All sorts...

Ouch, ok. How come the other files can include this stuff without errors ?

AFAIK nothing in the current mainline master does, I think you must have some other branch merged.

Ian.

#27 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

In reply to Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

---
v3: New. cherry-picked from u-boot-sunxi.git tree.

---
 drivers/net/designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/designware.c +1 -1
index c45593b..6ece479 100644
@@ -249,7 +249,7 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
 	rx_descs_init(dev);
 	tx_descs_init(dev);
 
-	writel(FIXEDBURST | PRIORXTX_41 | BURST_16, &dma_p->busmode);
+	writel(FIXEDBURST | PRIORXTX_41 | BURST_8, &dma_p->busmode);
 
 	writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD,
 	       &dma_p->opmode);
Signature · 1 line
1.9.0
#28 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Best regards,
Marek Vasut

#29 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 7 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

Ian.

#30 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 10 lines · Ian Campbell
Quoted 7 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

IIRC, with burst lengths > 8, GMAC doesn't work, no ping, no DHCP. I don't remember if it was TX or RX that suffered, or even both.

Hope this clarifies things a bit.

ChenYu

#31 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 8 lines · Chen-Yu Tsai
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

IIRC, with burst lengths > 8, GMAC doesn't work, no ping, no DHCP. I don't remember if it was TX or RX that suffered, or even both.

Hope this clarifies things a bit.

No, it does not at all, sorry. What you describe are symptoms, but what I want to know is what is the root cause of those symptoms. You did not explain that.

Best regards,
Marek Vasut

#32 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 13 lines · Marek Vasut
Quoted 12 lines · Chen-Yu Tsai
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

Quoted 7 lines
Quoted 4 lines

IIRC, with burst lengths > 8, GMAC doesn't work, no ping, no DHCP. I don't remember if it was TX or RX that suffered, or even both.

Hope this clarifies things a bit.

No, it does not at all, sorry. What you describe are symptoms, but what I want to know is what is the root cause of those symptoms. You did not explain that.

I can not offer much more explanation. The value was hardcoded in Allwinner's code. The datasheets don't offer much, except this line might be related:

(DMA) Descriptor architecture, allowing large blocks of data transfer with minimum CPU intervention; each descriptor can transfer up to 4 KB data.

Also probably related:

4KB TX FIFO for transmission packets and 16KB RX FIFO for reception packets.

I'm not an expert in hardware. We could ask Allwinner, but given past inquiries from the linux-sunxi community, I'd say getting a reply on hardware specifics is unlikely to happen.

So my guess is that this is limited by the DWMAC IP Allwinner licensed from Synopsys.

Cheers
ChenYu

#33 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Quoted 36 lines · Chen-Yu Tsai
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Chen-Yu Tsai
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

Quoted 8 lines
Quoted 4 lines

IIRC, with burst lengths > 8, GMAC doesn't work, no ping, no DHCP. I don't remember if it was TX or RX that suffered, or even both.

Hope this clarifies things a bit.

No, it does not at all, sorry. What you describe are symptoms, but what I want to know is what is the root cause of those symptoms. You did not explain that.

I can not offer much more explanation. The value was hardcoded in Allwinner's code. The datasheets don't offer much, except this line might be related:

(DMA) Descriptor architecture, allowing large blocks of data transfer with minimum CPU intervention; each descriptor can transfer up to 4 KB data.

Also probably related:

4KB TX FIFO for transmission packets and 16KB RX FIFO for reception packets.

Quoted 6 lines

I'm not an expert in hardware. We could ask Allwinner, but given past inquiries from the linux-sunxi community, I'd say getting a reply on hardware specifics is unlikely to happen.

So my guess is that this is limited by the DWMAC IP Allwinner licensed from Synopsys.

+CC Alexey

Best regards,
Marek Vasut

#34 lore raw

PATCH v3 9/9 net/designware: Reduce DMA burst length

Hi Marek,

Quoted 37 lines · Marek Vasut
Quoted 36 lines · Chen-Yu Tsai
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Chen-Yu Tsai
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Marek Vasut
Quoted 4 lines · Ian Campbell

From: Jens Kuske <[email protected]>

The GMAC module in Allwinner sunxi SoCs seems to have problems with burst lengths > 8.

Is there any explanation for the problems please ?

Jens or Wens, can you answer this?

Quoted 8 lines
Quoted 4 lines

IIRC, with burst lengths > 8, GMAC doesn't work, no ping, no DHCP. I don't remember if it was TX or RX that suffered, or even both.

Hope this clarifies things a bit.

No, it does not at all, sorry. What you describe are symptoms, but what I want to know is what is the root cause of those symptoms. You did not explain that.

I can not offer much more explanation. The value was hardcoded in Allwinner's code. The datasheets don't offer much, except this line might be related:

(DMA) Descriptor architecture, allowing large blocks of data transfer with minimum CPU intervention; each descriptor can transfer up to 4 KB data.

Also probably related:

4KB TX FIFO for transmission packets and 16KB RX FIFO for reception packets.

Quoted 6 lines
Quoted 6 lines

I'm not an expert in hardware. We could ask Allwinner, but given past inquiries from the linux-sunxi community, I'd say getting a reply on hardware specifics is unlikely to happen.

So my guess is that this is limited by the DWMAC IP Allwinner licensed from Synopsys.

Even though I'm not an expert in DW GMAC I may confirm that it has tons of settings people may use for fine-tuning performance and I may assume that there're corner cases when some settings may lead to real problems.

And IMHO if different boards may need different configurations why don't we satisfy their needs. But it's good to keep others who used to use existing settings happy too.

If you look in corresponding driver in Linux kernel
(https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/stmicro) you'll see much more complicated code compared to driver in U-Boot. And among other things you may see some GMAC parameters could be set per platform.

And Programmable Burst Length (PBL) is one of them. Look at stmmac_init_dma_engine() in
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

You may see default PBL (DEFAULT_DMA_PBL = 8) is used if other value is not provided by platform.

So I would propose to act this way:

1. Introduce driver-specific config value. Something like "DW_GMAC_DEFAULT_DMA_PBL" and in "designware.h" set it to "BURST_8". I hope driver in Linux was used a lot and this value could be treated as safe.

2. Ask people to try this new setting on existing boards that use DW GMAC. If everybody is happy there's nothing else to do here.

3. Otherwise if people report regressions add mentioned config option in board configuration files for problematic boards.

I think with this approach everybody will be happy.

-Alexey