Skip to contentSkip to conversation

sunxi: initial upstreamining effort

PATCH In review Ian Campbell 13 participants 65 messages Mar 14, 2014 – Mar 21, 2014

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

cover sunxi: initial upstreamining effort

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

The code here is from sunxi.git#sunxi[0] changeset d854c4de2f57 "arm:
Handle .gnu.hash section in ldscripts" and applied to u-boot v2014.01.

This series can also be found at:

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

There is no SMP here, since that relies on the PSCI support from Marc Zyngier which has yet to land in mainline AFAIK.

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).

I considered using the sunxi.git#sunxi-patchqueue branch but it was 151 patches and there didn't seem to be a small enough set of prefix patches which I was comfortable starting from.

Cheers,
Ian.

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

#1 lore raw

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

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Alejandro Mery
Carl van Schaik
Stefan Roese
Tom Cubie
yemao

---
Contributors:
git log --pretty='%aN' linux-sunxi/sunxi -- [PATHS] | sort -u

---
 arch/arm/cpu/armv7/sunxi/Makefile           |  28 ++++
 arch/arm/cpu/armv7/sunxi/clock.c            | 177 +++++++++++++++++++++
 arch/arm/cpu/armv7/sunxi/timer.c            | 120 ++++++++++++++
 arch/arm/include/asm/arch-sunxi/clock.h     | 238 ++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/sys_proto.h |  33 ++++
 arch/arm/include/asm/arch-sunxi/timer.h     | 104 ++++++++++++
 6 files changed, 700 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/timer.c
 create mode 100644 arch/arm/include/asm/arch-sunxi/clock.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 +28 -0
new file mode 100644
index 0000000..b56c32b
@@ -0,0 +1,28 @@
+#
+# (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.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+obj-y	+= timer.o
+obj-y	+= clock.o
arch/arm/cpu/armv7/sunxi/clock.c new file +177 -0

177 lines not on this page · raw message

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

120 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/clock.h new file +238 -0

238 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/sys_proto.h new file +33 -0
new file mode 100644
index 0000000..78a2b39
@@ -0,0 +1,33 @@
+/*
+ * (C) Copyright 2007-2012
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SYS_PROTO_H_
+#define _SYS_PROTO_H_
+
+#include <linux/types.h>
+
+void sr32(u32 *, u32, u32, u32);
+void sdelay(unsigned long);
+
+#endif
arch/arm/include/asm/arch-sunxi/timer.h new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#2 lore raw

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

On Fri, Mar 14, 2014 at 10:33:43AM +0000, Ian Campbell wrote:

[snip]

arch/arm/cpu/armv7/sunxi/clock.c line 47

Quoted 6 lines
arch/arm/cpu/armv7/sunxi/clock.c new file +6 -0
+	writel(0xa1005000, &ccm->pll1_cfg);
+	sdelay(200);
+	writel(AXI_DIV_1 << 0 | AHB_DIV_2 << 4 | APB0_DIV_1 << 8 |
+	       CPU_CLK_SRC_PLL1 << 16, &ccm->cpu_ahb_apb0_cfg);
+	writel(0x1 << 6 | readl(&ccm->ahb_gate0), &ccm->ahb_gate0);
+	writel(0x1 << 31 | readl(&ccm->pll6_cfg), &ccm->pll6_cfg);

All magic bits and shifts need defining.

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

Quoted 10 lines
arch/arm/cpu/armv7/sunxi/timer.c new file +10 -0
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	ulong tbclk;
+	tbclk = CONFIG_SYS_HZ;
+	return tbclk;
+}

So, just return CONFIG_SYS_HZ ?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/ba50648b/attachment.pgp>
#3 lore raw

PATCH 2/9 sunxi: initial sun7i pinmux and gpio support

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Carl van Schaik
Henrik Nordstrom
Stefan Roese
Tom Cubie

---
 arch/arm/cpu/armv7/sunxi/Makefile      |   1 +
 arch/arm/cpu/armv7/sunxi/pinmux.c      |  96 ++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h | 179 +++++++++++++++++++++++++++++++++
 3 files changed, 276 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 b56c32b..b4298c0 100644
@@ -26,3 +26,4 @@
 
 obj-y	+= timer.o
 obj-y	+= clock.o
+obj-y	+= pinmux.o
arch/arm/cpu/armv7/sunxi/pinmux.c new file +96 -0

96 lines not on this page · raw message

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

179 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#4 lore raw

PATCH 2/9 sunxi: initial sun7i pinmux and gpio support

Quoted 14 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Carl van Schaik
Henrik Nordstrom
Stefan Roese
Tom Cubie

Quoted 5 lines

Aside from the global comments:

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/3635dd4f/attachment.pgp>
#5 lore raw

PATCH 3/9 sunxi: initial sun7i dram setup support

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Alejandro Mery
Carl van Schaik
Tom Cubie

---
 arch/arm/cpu/armv7/sunxi/Makefile      |   1 +
 arch/arm/cpu/armv7/sunxi/dram.c        | 530 +++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/dram.h | 191 ++++++++++++
 3 files changed, 722 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 b4298c0..41d843f 100644
@@ -25,5 +25,6 @@
 #
 
 obj-y	+= timer.o
+obj-y	+= dram.o
 obj-y	+= clock.o
 obj-y	+= pinmux.o
arch/arm/cpu/armv7/sunxi/dram.c new file +530 -0

530 lines not on this page · raw message

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

191 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#6 lore raw

PATCH 3/9 sunxi: initial sun7i dram setup support

On Fri, Mar 14, 2014 at 10:33:45AM +0000, Ian Campbell wrote:

[snip]

arch/arm/cpu/armv7/sunxi/dram.c line 56

Quoted 10 lines
arch/arm/cpu/armv7/sunxi/dram.c new file +10 -0
+static void mctl_ddr3_reset(void)
+{
+	struct sunxi_dram_reg *dram =
+			(struct sunxi_dram_reg *)SUNXI_DRAMC_BASE;
+
+	{
+		clrbits_le32(&dram->mcr, DRAM_MCR_RESET);
+		udelay(2);
+		setbits_le32(&dram->mcr, DRAM_MCR_RESET);
+	}

That seems like an odd construction, why the extra braces?

And as for the rest of the code, lots of magic numbers to #define what/why (why udelay(2) and 22?)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/87cb5bdc/attachment.pgp>
#7 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH v1 3/9] sunxi: initial sun7i dram setup support

fre 2014-03-14 klockan 10:17 -0400 skrev Tom Rini:

Quoted 2 lines

And as for the rest of the code, lots of magic numbers to #define what/why (why udelay(2) and 22?)

Unfortunately the only documentation we have on the sun7i DRAM controller is Allwinner boot0 + boot1 code, and that code uses.. magic numbers & shifts with no explanations.

We have guessed some small bits, but a lot is completely unknown.

Regards
Henriki

#8 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH v1 3/9] sunxi: initial sun7i dram setup support

Quoted 8 lines · Henrik Nordstr?m

fre 2014-03-14 klockan 10:17 -0400 skrev Tom Rini:

Quoted 2 lines

And as for the rest of the code, lots of magic numbers to #define what/why (why udelay(2) and 22?)

Unfortunately the only documentation we have on the sun7i DRAM controller is Allwinner boot0 + boot1 code, and that code uses.. magic numbers & shifts with no explanations.

a terse comment at the top to that effect would likely be worthwhile.

l.

#9 lore raw

PATCH 3/9 sunxi: initial sun7i dram setup support

In reply to Henrik Nordström
Quoted 3 lines

Unfortunately the only documentation we have on the sun7i DRAM controller is Allwinner boot0 + boot1 code, and that code uses.. magic numbers & shifts with no explanations.

To avoid having to explain this over-and-over again, the code could include some comment(s) pointing out that these are unexplained magic constants from Allwinner's code.

Stefan

#10 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH v1 3/9] sunxi: initial sun7i dram setup support

Quoted 7 lines · Stefan
Quoted 3 lines

Unfortunately the only documentation we have on the sun7i DRAM controller is Allwinner boot0 + boot1 code, and that code uses.. magic numbers & shifts with no explanations.

To avoid having to explain this over-and-over again, the code could include some comment(s) pointing out that these are unexplained magic constants from Allwinner's code.

This is what I plan to do.

Ian.

#11 lore raw

PATCH 3/9 sunxi: initial sun7i dram setup support

In reply to Tom Rini

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 10 lines · Tom Rini

On Fri, Mar 14, 2014 at 10:33:45AM +0000, Ian Campbell wrote:

[snip]

Quoted 4 lines

+static void mctl_ddr3_reset(void) +{ + struct sunxi_dram_reg
*dram = + (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE; + + { +
clrbits_le32(&dram->mcr, DRAM_MCR_RESET); + udelay(2); +
setbits_le32(&dram->mcr, DRAM_MCR_RESET); + }

That seems like an odd construction, why the extra braces?

This originally had a conditional depending on the SoC family. (Yeah, they need to reset the ram differently). It seems it wasn't removed properly.

Quoted 3 lines

And as for the rest of the code, lots of magic numbers to #define what/why (why udelay(2) and 22?)

Before going into more detail, remember this is ram initialization code. That's always going to be a pain :(.
There's nothing magic here. It's just a fact of life. Every step is going to need a different delay. No need to bloat the headers by #defining each. It also makes raminit code more unreadable.

We got these numbers from allwinner code dumps. We used to have these as sdelay() numbers, which usually meant units of 2 clock cycles. So we had to convert them to udelay() to at least make the delays independent of CPU clock. The old sdelay() numbers made no sense either.

Alex
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTIzsgAAoJEL0kPHNPXJJKasUQAKygf9UpJc6IINH41LKOFnBf fBEVB8ECIu96JWUDE9r0BQw0l6Pc82Mqx+XUZdbNhhZNhhVf8EJ/9koHQrP/X8By J8MninT7pgDi7IH9Y+U5GfuHEA1nDQT0kf+nYMNrUIx1b9cuv5vLvhpeKL0AJotb DE8miBRCcuRcAivCjERjlVFKCicMERKx1cTrris7+aQyNAxPEGrFj0pS8RBpSgBF j+NkRSjbdnAOKHOfpXZi7VMqhHIt6NDxsuSrM0roSJz1v79+J5TGqUdPFKvGVZro BbsWB3pRq8zSdO6OYvojUjyWPG95PfhDQvLSlvKA5Z1AlgNHu32YGkFWGbUve/z7 8dn057RjY4KtrAn+jVOL8+sBAj6yr0VIJmxqa1xPqGOMBAn0Cn+JJZ6auCNPZGqx yt5glg0B5lHsVgCnmDGvoKs8SAv7n7IQfmiF+gvD8Pn0/NC31UQ2WA3khJoPt6Gp 9G5q+sn6BRrUpQOiQmhJTPX4W3g3nmXFqWYkd+VAWEHeEfHTIuqOlcfgdwMmP4Ti hrhrk/CWSOPjtYuI5yByA6RCZ93smb4uexSmrzzafzuYrdwK/DmP+TumFrE8pycT cMsxAx40UEElJ5OHN7YaWtt6NNhCT6BVlo76awqFY/vGme0cef74SQqB8EdyVYSE PDoq+Sog13y4A8OjQ5rT
=e7kN
-----END PGP SIGNATURE-----

#12 lore raw

PATCH 3/9 sunxi: initial sun7i dram setup support

Quoted 27 lines · Alex G.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 10 lines · Tom Rini

On Fri, Mar 14, 2014 at 10:33:45AM +0000, Ian Campbell wrote:

[snip]

Quoted 4 lines

+static void mctl_ddr3_reset(void) +{ + struct sunxi_dram_reg
*dram = + (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE; + + { +
clrbits_le32(&dram->mcr, DRAM_MCR_RESET); + udelay(2); +
setbits_le32(&dram->mcr, DRAM_MCR_RESET); + }

That seems like an odd construction, why the extra braces?

This originally had a conditional depending on the SoC family. (Yeah, they need to reset the ram differently). It seems it wasn't removed properly.

Quoted 3 lines

And as for the rest of the code, lots of magic numbers to #define what/why (why udelay(2) and 22?)

Before going into more detail, remember this is ram initialization code. That's always going to be a pain :(.
There's nothing magic here. It's just a fact of life. Every step is going to need a different delay. No need to bloat the headers by #defining each. It also makes raminit code more unreadable.

Quoted 4 lines

We got these numbers from allwinner code dumps. We used to have these as sdelay() numbers, which usually meant units of 2 clock cycles. So we had to convert them to udelay() to at least make the delays independent of CPU clock. The old sdelay() numbers made no sense either.

Yeah, I can accept a certain amount of black magic here. We need to make sure things are commented as much as it can be.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/adb8dfb7/attachment.pgp>
#13 lore raw

PATCH 4/9 sunxi: initial generic sun7i cpu, board and start of day support

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Almo Nito
Carl van Schaik
FUKAUMI Naoki
hehopmajieh
j
Sergey Lapin
Tom Cubie

---
 arch/arm/cpu/armv7/sunxi/Makefile     |  11 +++
 arch/arm/cpu/armv7/sunxi/board.c      | 104 +++++++++++++++++++++++++
 arch/arm/cpu/armv7/sunxi/cpu_info.c   |  35 +++++++++
 arch/arm/cpu/armv7/sunxi/start.c      |   1 +
 arch/arm/include/asm/arch-sunxi/cpu.h | 138 ++++++++++++++++++++++++++++++++++
 board/sunxi/Makefile                  |  28 +++++++
 board/sunxi/board.c                   |  91 ++++++++++++++++++++++
 7 files changed, 408 insertions(+)
 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/include/asm/arch-sunxi/cpu.h
 create mode 100644 board/sunxi/Makefile
 create mode 100644 board/sunxi/board.c
arch/arm/cpu/armv7/sunxi/Makefile +11 -0
index 41d843f..3e8a36c 100644
@@ -26,5 +26,16 @@
 
 obj-y	+= timer.o
 obj-y	+= dram.o
+obj-y	+= board.o
 obj-y	+= clock.o
 obj-y	+= pinmux.o
+
+ifndef CONFIG_SPL_BUILD
+obj-y	+= cpu_info.o
+endif
+
+ifdef CONFIG_SPL_BUILD
+ifdef CONFIG_SPL_FEL
+obj-y	+= start.o
+endif
+endif
arch/arm/cpu/armv7/sunxi/board.c new file +104 -0

104 lines not on this page · raw message

arch/arm/cpu/armv7/sunxi/cpu_info.c new file +35 -0
new file mode 100644
index 0000000..14093dd
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#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/include/asm/arch-sunxi/cpu.h new file +138 -0

138 lines not on this page · raw message

board/sunxi/Makefile new file +28 -0
new file mode 100644
index 0000000..b8c26ab
@@ -0,0 +1,28 @@
+#
+# (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.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+obj-y	+= board.o
board/sunxi/board.c new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#14 lore raw

PATCH 4/9 sunxi: initial generic sun7i cpu, board and start of day support

On Fri, Mar 14, 2014 at 10:33:46AM +0000, Ian Campbell wrote:

[snip]

Quoted 2 lines

+/* The sunxi internal brom will try to loader external bootloader
+ * from mmc0, nannd flash, mmc2.

Typo.

Quoted 6 lines
board/sunxi/board.c new file +6 -0
+#ifdef CONFIG_SPL_BUILD
+void sunxi_board_init(void)
+{
+	int power_failed = 0;
+	unsigned long ramsize;
+

board/sunxi/board.c line 77

Quoted 10 lines
board/sunxi/board.c new file +10 -0
+	printf("DRAM:");
+	ramsize = sunxi_dram_init();
+	if (!ramsize) {
+		printf(" ?");
+		ramsize = sunxi_dram_init();
+	}
+	if (!ramsize) {
+		printf(" ?");
+		ramsize = sunxi_dram_init();
+	}

We have to try 3 times? What?

board/sunxi/board.c line 87

Quoted 6 lines
board/sunxi/board.c new file +6 -0
+	/*
+	 * Only clock up the CPU to full speed if we are reasonably
+	 * assured it's being powered with suitable core voltage
+	 */
+	if (!power_failed)
+		clock_set_pll1(912000000);

Define that please.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/262967db/attachment.pgp>
#15 lore raw

PATCH 4/9 sunxi: initial generic sun7i cpu, board and start of day support

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 9 lines · Tom Rini
Quoted 5 lines · Ian Campbell

+#ifdef CONFIG_SPL_BUILD +void sunxi_board_init(void) +{ + int
power_failed = 0; + unsigned long ramsize; + + printf("DRAM:"); +
ramsize = sunxi_dram_init(); + if (!ramsize) { + printf(" ?"); +
ramsize = sunxi_dram_init(); + } + if (!ramsize) { + printf("
?"); + ramsize = sunxi_dram_init(); + }

We have to try 3 times? What?

TLDR: only needs to be called once.

I have no idea why this is here. We use the same raminit code in coreboot, and it works when we call it the first time.
The raminit code we had when this was written was not tuned to use proper delays. I imagine whoever initially wrote this triple-play, was dealing with finicky raminit code, and found out that calling it a few times worked.
I think it's safe to remove tries 2 and 3.

Quoted 6 lines
Quoted 3 lines
(quoted diff) +1 -0
+	/* +	 * Only clock up the CPU to full speed if we are

reasonably + * assured it's being powered with suitable core
voltage + */ + if (!power_failed) + clock_set_pll1(912000000);

Define that please.

TLDR: This does not belong in this patch

power_failed was a flag returned by the Power Manager Unit code (PMU). The PMU on these boards is used to ramp up the CPU voltage. You need that to be able to get to full clock without hanging. power_failed lets us know if something went wrong with the PMU setup and we should leave the clocks the way they were.
I think this should be added in the patch which adds the power setup.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTJHhiAAoJEL0kPHNPXJJKHeQP/ia4JHyieDyrY36hq/ocC/79 DwHxgf9CkvlHP4nBGdGuAiidyJpXbMtLUijbYgvrxIiaUwg831C+AakcZv4KnUTx r7qQceAL6Yw9YReuPquEn/sj43LiOgOC4oRmwIq6UiUz0MeOwuXWTWa4KxYtG9LR dkuauOU52EJlg7WJiSF96TainrZ89pADcuUxaq9YNEcZKmcn1SoiHivm6SBB8HBd q0hDd+cd6ZKIY/YbSdlGctCaZbUfR7qAJSKMksCCecrpyg/eiEdEoYhsm2e30nZU 3LXcM+tJdUxGmlFMkWZYgDRi8nLywr7Lfmmrs+jUDj7BYewOyZNlQhyMROyr6SPP YmBMDZbF4bDLRnZICCcyqDQbS5vSM1xSSucl6A4upmOBe5DpBbwSWpRCHQ2X8Lhq L7Si4+JsnHB5zLrjlLwyFHMTHG6Ty2R7DZeRM3SjhPhp93b3mBw2K+wGCp6QG+sv riGSCjKkBhbQG8UQYAEkwtwfws+pOmkwnkRwdBNy9jxi/xXL4J1E7hgEBbc3pY5E AVmJEO8Eov9w78E1Tnxr3OMXMltjS4I1BJvwJFADJcS5/PZ9hJCBcA/oLqFXcTH1 lKklPGKGHpSdPxBcpZGMQ4ipP2IVhhz7MFuVWhI7qjUWRNfFG4GmpauqZc6qrceW qjjxb2PEixZvb4yxLacH
=P4vd
-----END PGP SIGNATURE-----

#16 lore raw

PATCH 5/9 sunxi: generic sun7i build infrastructure.

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

This has been stripped back for mainlining and supports only sun7i booting via FEL mode. These changes are not useful by themselves but are split out to make the patch sizes more manageable.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Almo Nito
Carl van Schaik
FUKAUMI Naoki
hehopmajieh
j
Sergey Lapin
Tom Cubie

---
 arch/arm/cpu/armv7/Makefile                 |   2 +-
 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds |  59 +++++++++++
 arch/arm/include/asm/arch-sunxi/spl.h       |  36 +++++++
 board/sunxi/Makefile                        |   1 +
 include/configs/sun7i.h                     |  41 ++++++++
 include/configs/sunxi-common.h              | 154 ++++++++++++++++++++++++++++
 6 files changed, 292 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
 create mode 100644 arch/arm/include/asm/arch-sunxi/spl.h
 create mode 100644 include/configs/sun7i.h
 create mode 100644 include/configs/sunxi-common.h
arch/arm/cpu/armv7/Makefile +1 -1
index 0467d00..71c233c 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/u-boot-spl-fel.lds new file +59 -0

59 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/spl.h new file +36 -0
new file mode 100644
index 0000000..6a47d14
@@ -0,0 +1,36 @@
+/*
+ * This is a copy of omap3/spl.h:
+ *
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#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 +1 -0
index b8c26ab..180adc9 100644
@@ -26,3 +26,4 @@
 #
 
 obj-y	+= board.o
+obj-y	+= dram_cubietruck.o
include/configs/sun7i.h new file +41 -0

41 lines not on this page · raw message

include/configs/sunxi-common.h new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#17 lore raw

PATCH 5/9 sunxi: generic sun7i build infrastructure.

On Fri, Mar 14, 2014 at 10:33:47AM +0000, Ian Campbell wrote:

[snip]

Quoted 1 line

+#define CONFIG_SUN7I /* sun7i SoC generation */

[snip]

include/configs/sunxi-common.h line 36

Quoted 2 lines
include/configs/sunxi-common.h new file +2 -0
+#define CONFIG_ALLWINNER	/* It's a Allwinner chip */
+#define CONFIG_SUNXI		/* which is sunxi family */

Please make sure we end up using all 3 of these. I know I spotted a CONFIG_SUNXI in use, but I don't know about ALLWINNER or SUN7I.

include/configs/sunxi-common.h line 81

Quoted 5 lines
include/configs/sunxi-common.h new file +5 -0
+/*
+ * Size of malloc() pool
+ * 1MB = 0x100000, 0x100000 = 1024 * 1024
+ */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))

This is really really small, and precludes using UBI on NAND for example.

Quoted 1 line

+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "

Not needed.

include/configs/sunxi-common.h line 99

Quoted 3 lines
include/configs/sunxi-common.h new file +3 -0
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START	CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_SDRAM_BASE + (256 << 20))

Please see doc/README.memory-test

Quoted 1 line

+#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }

Please use the default table.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/254376ab/attachment.pgp>
#18 lore raw

PATCH 5/9 sunxi: generic sun7i build infrastructure.

Quoted 10 lines · Tom Rini

include/configs/sunxi-common.h line 81

Quoted 5 lines · Ian Campbell
include/configs/sunxi-common.h new file +5 -0
+/*
+ * Size of malloc() pool
+ * 1MB = 0x100000, 0x100000 = 1024 * 1024
+ */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))

This is really really small, and precludes using UBI on NAND for example.

What is a suitable value? I see a lots of boards using 128kB or <1MB and only a handful using more. Tegra uses 4MB -- is that a reasonable value?

Ian.

#19 lore raw

PATCH 5/9 sunxi: generic sun7i build infrastructure.

Quoted 12 lines · Ian Campbell
Quoted 10 lines · Tom Rini

include/configs/sunxi-common.h line 81

Quoted 5 lines · Ian Campbell
include/configs/sunxi-common.h new file +5 -0
+/*
+ * Size of malloc() pool
+ * 1MB = 0x100000, 0x100000 = 1024 * 1024
+ */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))

This is really really small, and precludes using UBI on NAND for example.

Quoted 2 lines

What is a suitable value? I see a lots of boards using 128kB or <1MB and only a handful using more. Tegra uses 4MB -- is that a reasonable value?

4MB is reasonable when you start having to worry about 4KB page NAND and UBI. I might have been a little harsh saying "really really small" and 1MB might be just enough to work with smaller page size NAND.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140317/38184e92/attachment.pgp>
#20 lore raw

PATCH 5/9 sunxi: generic sun7i build infrastructure.

Quoted 13 lines · Tom Rini
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Tom Rini

include/configs/sunxi-common.h line 81

Quoted 5 lines · Ian Campbell
include/configs/sunxi-common.h new file +5 -0
+/*
+ * Size of malloc() pool
+ * 1MB = 0x100000, 0x100000 = 1024 * 1024
+ */
+#define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))

This is really really small, and precludes using UBI on NAND for example.

Quoted 6 lines
Quoted 2 lines

What is a suitable value? I see a lots of boards using 128kB or <1MB and only a handful using more. Tegra uses 4MB -- is that a reasonable value?

4MB is reasonable when you start having to worry about 4KB page NAND and UBI. I might have been a little harsh saying "really really small" and 1MB might be just enough to work with smaller page size NAND.

Thanks, I'll go with 4MB then.

Ian.

#21 lore raw

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

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 board/sunxi/dram_cubietruck.c | 31 +++++++++++++++++++++++++++++++
 boards.cfg                    |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 board/sunxi/dram_cubietruck.c
board/sunxi/dram_cubietruck.c new file +31 -0
new file mode 100644
index 0000000..1e7c94a
@@ -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 = 8192,
+	.io_width = 16,
+	.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 a8336cc..6c35a40 100644
@@ -353,6 +353,7 @@ Active  arm         armv7          rmobile     renesas         koelsch
 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.8.5.3
#22 lore raw

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

Quoted 5 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/a43b8764/attachment.pgp>
#23 lore raw

PATCH 7/9 sunxi: mmc support

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Stefan Roese
Tom Cubie
yemao

---
 arch/arm/include/asm/arch-sunxi/mmc.h |  66 ++++
 board/sunxi/board.c                   |  13 +
 drivers/mmc/Makefile                  |   1 +
 drivers/mmc/sunxi_mmc.c               | 650 ++++++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h        |  11 +
 5 files changed, 741 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-sunxi/mmc.h
 create mode 100755 drivers/mmc/sunxi_mmc.c
arch/arm/include/asm/arch-sunxi/mmc.h new file +66 -0
new file mode 100644
index 0000000..639a7fc
@@ -0,0 +1,66 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Aaron <[email protected]>
+ *
+ * MMC register definition for allwinner sunxi platform.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SUNXI_MMC_H
+#define _SUNXI_MMC_H
+
+#include <linux/types.h>
+
+struct sunxi_mmc {
+	u32 gctrl;		/* (0x00) SMC Global Control Register */
+	u32 clkcr;		/* (0x04) SMC Clock Control Register */
+	u32 timeout;		/* (0x08) SMC Time Out Register */
+	u32 width;		/* (0x0c) SMC Bus Width Register */
+	u32 blksz;		/* (0x10) SMC Block Size Register */
+	u32 bytecnt;		/* (0x14) SMC Byte Count Register */
+	u32 cmd;		/* (0x18) SMC Command Register */
+	u32 arg;		/* (0x1c) SMC Argument Register */
+	u32 resp0;		/* (0x20) SMC Response Register 0 */
+	u32 resp1;		/* (0x24) SMC Response Register 1 */
+	u32 resp2;		/* (0x28) SMC Response Register 2 */
+	u32 resp3;		/* (0x2c) SMC Response Register 3 */
+	u32 imask;		/* (0x30) SMC Interrupt Mask Register */
+	u32 mint;		/* (0x34) SMC Masked Interrupt Status Reg */
+	u32 rint;		/* (0x38) SMC Raw Interrupt Status Register */
+	u32 status;		/* (0x3c) SMC Status Register */
+	u32 ftrglevel;		/* (0x40) SMC FIFO Threshold Watermark Reg */
+	u32 funcsel;		/* (0x44) SMC Function Select Register */
+	u32 cbcr;		/* (0x48) SMC CIU Byte Count Register */
+	u32 bbcr;		/* (0x4c) SMC BIU Byte Count Register */
+	u32 dbgc;		/* (0x50) SMC Debug Enable Register */
+	u32 res0[11];		/* (0x54~0x7c) */
+	u32 dmac;		/* (0x80) SMC IDMAC Control Register */
+	u32 dlba;		/* (0x84) SMC IDMAC Descr List Base Addr Reg */
+	u32 idst;		/* (0x88) SMC IDMAC Status Register */
+	u32 idie;		/* (0x8c) SMC IDMAC Interrupt Enable Register */
+	u32 chda;		/* (0x90) */
+	u32 cbda;		/* (0x94) */
+	u32 res1[26];		/* (0x98~0xff) */
+	u32 fifo;		/* (0x100) SMC FIFO Access Address */
+};
+
+int sunxi_mmc_init(int sdc_no);
+#endif /* _SUNXI_MMC_H */
board/sunxi/board.c +13 -0
index bffef4f..5dbcf2a 100644
@@ -30,6 +30,7 @@
 #include <common.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/dram.h>
+#include <asm/arch/mmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -59,6 +60,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 e793ed9..c695841 100644
@@ -27,6 +27,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 +650 -0

650 lines not on this page · raw message

include/configs/sunxi-common.h +11 -0
index bdfc169..1afdeb2 100644
@@ -74,6 +74,16 @@
 #define CONFIG_INITRD_TAG
 #define CONFIG_CMDLINE_EDITING
 
+/* 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 */
+
 /*
  * Size of malloc() pool
  * 1MB = 0x100000, 0x100000 = 1024 * 1024
@@ -118,6 +128,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_BOOTDELAY	3
Signature · 1 line
1.8.5.3
#24 lore raw

PATCH 7/9 sunxi: mmc support

Quoted 9 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Stefan Roese
Tom Cubie
yemao

Quoted 5 lines

Just the general problems. Pantelis?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/738311a5/attachment.pgp>
#25 lore raw

PATCH 7/9 sunxi: mmc support

In reply to Ian Campbell

Hi Ian,

Quoted 209 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Stefan Roese
Tom Cubie
yemao

---

arch/arm/include/asm/arch-sunxi/mmc.h |  66 ++++
board/sunxi/board.c                   |  13 +
drivers/mmc/Makefile                  |   1 +
drivers/mmc/sunxi_mmc.c               | 650 ++++++++++++++++++++++++++++++++++
include/configs/sunxi-common.h        |  11 +
5 files changed, 741 insertions(+)

create mode 100644 arch/arm/include/asm/arch-sunxi/mmc.h create mode 100755 drivers/mmc/sunxi_mmc.c

arch/arm/include/asm/arch-sunxi/mmc.h new file +66 -0
new file mode 100644
index 0000000..639a7fc
@@ -0,0 +1,66 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Aaron <[email protected]>
+ *
+ * MMC register definition for allwinner sunxi platform.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SUNXI_MMC_H
+#define _SUNXI_MMC_H
+
+#include <linux/types.h>
+
+struct sunxi_mmc {
+	u32 gctrl;		/* (0x00) SMC Global Control Register */
+	u32 clkcr;		/* (0x04) SMC Clock Control Register */
+	u32 timeout;		/* (0x08) SMC Time Out Register */
+	u32 width;		/* (0x0c) SMC Bus Width Register */
+	u32 blksz;		/* (0x10) SMC Block Size Register */
+	u32 bytecnt;		/* (0x14) SMC Byte Count Register */
+	u32 cmd;		/* (0x18) SMC Command Register */
+	u32 arg;		/* (0x1c) SMC Argument Register */
+	u32 resp0;		/* (0x20) SMC Response Register 0 */
+	u32 resp1;		/* (0x24) SMC Response Register 1 */
+	u32 resp2;		/* (0x28) SMC Response Register 2 */
+	u32 resp3;		/* (0x2c) SMC Response Register 3 */
+	u32 imask;		/* (0x30) SMC Interrupt Mask Register */
+	u32 mint;		/* (0x34) SMC Masked Interrupt Status Reg */
+	u32 rint;		/* (0x38) SMC Raw Interrupt Status Register */
+	u32 status;		/* (0x3c) SMC Status Register */
+	u32 ftrglevel;		/* (0x40) SMC FIFO Threshold Watermark Reg */
+	u32 funcsel;		/* (0x44) SMC Function Select Register */
+	u32 cbcr;		/* (0x48) SMC CIU Byte Count Register */
+	u32 bbcr;		/* (0x4c) SMC BIU Byte Count Register */
+	u32 dbgc;		/* (0x50) SMC Debug Enable Register */
+	u32 res0[11];		/* (0x54~0x7c) */
+	u32 dmac;		/* (0x80) SMC IDMAC Control Register */
+	u32 dlba;		/* (0x84) SMC IDMAC Descr List Base Addr Reg */
+	u32 idst;		/* (0x88) SMC IDMAC Status Register */
+	u32 idie;		/* (0x8c) SMC IDMAC Interrupt Enable Register */
+	u32 chda;		/* (0x90) */
+	u32 cbda;		/* (0x94) */
+	u32 res1[26];		/* (0x98~0xff) */
+	u32 fifo;		/* (0x100) SMC FIFO Access Address */
+};
+
+int sunxi_mmc_init(int sdc_no);
+#endif /* _SUNXI_MMC_H */
board/sunxi/board.c +13 -0
index bffef4f..5dbcf2a 100644
@@ -30,6 +30,7 @@
 #include <common.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/dram.h>
+#include <asm/arch/mmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -59,6 +60,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 +0 -0
index e793ed9..c695841 100644
@@ -27,6 +27,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 +64 -0
new file mode 100755
index 0000000..13eba76
@@ -0,0 +1,650 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Aaron <[email protected]>
+ *
+ * MMC driver for allwinner sunxi platform.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <mmc.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/mmc.h>
+
+static void dumphex32(char *name, char *base, int len)
+{
+	__u32 i;
+
+	debug("dump %s registers:", name);
+	for (i = 0; i < len; i += 4) {
+		if (!(i & 0xf))
+			debug("\n0x%p : ", base + i);
+		debug("0x%08x ", readl(base + i));
+	}
+	debug("\n");
+}
+
+static void dumpmmcreg(struct sunxi_mmc *reg)
+{
+	debug("dump mmc registers:\n");
+	debug("gctrl     0x%08x\n", reg->gctrl);
+	debug("clkcr     0x%08x\n", reg->clkcr);
+	debug("timeout   0x%08x\n", reg->timeout);
+	debug("width     0x%08x\n", reg->width);
+	debug("blksz     0x%08x\n", reg->blksz);
+	debug("bytecnt   0x%08x\n", reg->bytecnt);
+	debug("cmd       0x%08x\n", reg->cmd);
+	debug("arg       0x%08x\n", reg->arg);
+	debug("resp0     0x%08x\n", reg->resp0);
+	debug("resp1     0x%08x\n", reg->resp1);
+	debug("resp2     0x%08x\n", reg->resp2);
+	debug("resp3     0x%08x\n", reg->resp3);
+	debug("imask     0x%08x\n", reg->imask);

drivers/mmc/sunxi_mmc.c line 74

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	debug("mint      0x%08x\n", reg->mint);
+	debug("rint      0x%08x\n", reg->rint);
+	debug("status    0x%08x\n", reg->status);
+	debug("ftrglevel 0x%08x\n", reg->ftrglevel);
+	debug("funcsel   0x%08x\n", reg->funcsel);
+	debug("dmac      0x%08x\n", reg->dmac);
+	debug("dlba      0x%08x\n", reg->dlba);
+	debug("idst      0x%08x\n", reg->idst);
+	debug("idie      0x%08x\n", reg->idie);
+}

^^^ #ifdef DEBUG here?

Quoted 26 lines
drivers/mmc/sunxi_mmc.c new file +26 -0
+
+struct sunxi_mmc_des {
+	u32 reserved1_1:1;
+	u32 dic:1;		/* disable interrupt on completion */
+	u32 last_des:1;		/* 1-this data buffer is the last buffer */
+	u32 first_des:1;		/* 1-data buffer is the first buffer,
+				   0-data buffer contained in the next
+				   descriptor is 1st buffer */
+	u32 des_chain:1;	/* 1-the 2nd address in the descriptor is the
+				   next descriptor address */
+	u32 end_of_ring:1;	/* 1-last descriptor flag when using dual
+				   data buffer in descriptor */
+	u32 reserved1_2:24;
+	u32 card_err_sum:1;	/* transfer error flag */
+	u32 own:1;		/* des owner:1-idma owns it, 0-host owns it */
+#define SDXC_DES_NUM_SHIFT 16
+#define SDXC_DES_BUFFER_MAX_LEN	(1 << SDXC_DES_NUM_SHIFT)
+	u32 data_buf1_sz:16;
+	u32 data_buf2_sz:16;
+	u32 buf_addr_ptr1;
+	u32 buf_addr_ptr2;
+};
+
+struct sunxi_mmc_host {
+	unsigned mmc_no;
+	uint32_t *mclkreg;

drivers/mmc/sunxi_mmc.c line 110

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	unsigned database;
+	unsigned fatal_err;
+	unsigned mod_clk;
+	struct sunxi_mmc *reg;
+};
+
+/* support 4 mmc hosts */
+struct mmc mmc_dev[4];
+struct sunxi_mmc_host mmc_host[4];
+

^ hosts & mmc structs can be allocated even for SPL now

Quoted 44 lines
drivers/mmc/sunxi_mmc.c new file +44 -0
+static int mmc_resource_init(int sdc_no)
+{
+	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 resource\n", sdc_no);
+
+	switch (sdc_no) {
+	case 0:
+		mmchost->reg = (struct sunxi_mmc *)SUNXI_MMC0_BASE;
+		mmchost->mclkreg = &ccm->sd0_clk_cfg;
+		break;
+	case 1:
+		mmchost->reg = (struct sunxi_mmc *)SUNXI_MMC1_BASE;
+		mmchost->mclkreg = &ccm->sd1_clk_cfg;
+		break;
+	case 2:
+		mmchost->reg = (struct sunxi_mmc *)SUNXI_MMC2_BASE;
+		mmchost->mclkreg = &ccm->sd2_clk_cfg;
+		break;
+	case 3:
+		mmchost->reg = (struct sunxi_mmc *)SUNXI_MMC3_BASE;
+		mmchost->mclkreg = &ccm->sd3_clk_cfg;
+		break;
+	default:
+		printf("Wrong mmc number %d\n", sdc_no);
+		return -1;
+	}
+	mmchost->database = (unsigned int)mmchost->reg + 0x100;
+	mmchost->mmc_no = sdc_no;
+
+	return 0;
+}
+
+static int mmc_clk_io_on(int sdc_no)
+{
+	unsigned int rval;
+	unsigned int pll5_clk;
+	unsigned int divider;
+	struct sunxi_mmc_host *mmchost = &mmc_host[sdc_no];
+	static struct sunxi_gpio *gpio_c =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_C];
+	static struct sunxi_gpio *gpio_f =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_F];

drivers/mmc/sunxi_mmc.c line 164

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+#if CONFIG_MMC1_PG
+	static struct sunxi_gpio *gpio_g =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_G];
+#endif
+	static struct sunxi_gpio *gpio_h =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_H];
+	static struct sunxi_gpio *gpio_i =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_I];
+	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+

^ Castings are ugly; rework with a temporary variable.

Quoted 36 lines
drivers/mmc/sunxi_mmc.c new file +36 -0
+	debug("init mmc %d clock and io\n", sdc_no);
+
+	/* config gpio */
+	switch (sdc_no) {
+	case 0:
+		/* D1-PF0, D0-PF1, CLK-PF2, CMD-PF3, D3-PF4, D4-PF5 */
+		writel(0x222222, &gpio_f->cfg[0]);
+		writel(0x555, &gpio_f->pull[0]);
+		writel(0xaaa, &gpio_f->drv[0]);
+		break;
+
+	case 1:
+#if CONFIG_MMC1_PG
+		/* PG0-CMD, PG1-CLK, PG2~5-D0~3 : 4 */
+		writel(0x444444, &gpio_g->cfg[0]);
+		writel(0x555, &gpio_g->pull[0]);
+		writel(0xaaa, &gpio_g->drv[0]);
+#else
+		/* PH22-CMD, PH23-CLK, PH24~27-D0~D3 : 5 */
+		writel(0x55 << 24, &gpio_h->cfg[2]);
+		writel(0x5555, &gpio_h->cfg[3]);
+		writel(0x555 << 12, &gpio_h->pull[1]);
+		writel(0xaaa << 12, &gpio_h->drv[1]);
+#endif
+		break;
+
+	case 2:
+		/* CMD-PC6, CLK-PC7, D0-PC8, D1-PC9, D2-PC10, D3-PC11 */
+		writel(0x33 << 24, &gpio_c->cfg[0]);
+		writel(0x3333, &gpio_c->cfg[1]);
+		writel(0x555 << 12, &gpio_c->pull[0]);
+		writel(0xaaa << 12, &gpio_c->drv[0]);
+		break;
+
+	case 3:
+		/* PI4-CMD, PI5-CLK, PI6~9-D0~D3 : 2 */

drivers/mmc/sunxi_mmc.c line 210

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+		writel(0x2222 << 16, &gpio_i->cfg[0]);
+		writel(0x22, &gpio_i->cfg[1]);
+		writel(0x555 << 8, &gpio_i->pull[0]);
+		writel(0x555 << 8, &gpio_i->drv[0]);
+		break;
+
+	default:
+		return -1;
+	}
+

Lots of magic constants. I have no idea what's going on here. Use a few defines.

Quoted 24 lines
drivers/mmc/sunxi_mmc.c new file +24 -0
+	/* config ahb clock */
+	rval = readl(&ccm->ahb_gate0);
+	rval |= (1 << (8 + sdc_no));
+	writel(rval, &ccm->ahb_gate0);
+
+	/* config mod clock */
+	pll5_clk = clock_get_pll5();
+	if (pll5_clk > 400000000)
+		divider = 4;
+	else
+		divider = 3;
+	writel((0x1 << 31) | (0x2 << 24) | divider, mmchost->mclkreg);
+	mmchost->mod_clk = pll5_clk / (divider + 1);
+
+	dumphex32("ccmu", (char *)SUNXI_CCM_BASE, 0x100);
+	dumphex32("gpio", (char *)SUNXI_PIO_BASE, 0x100);
+	dumphex32("mmc", (char *)mmchost->reg, 0x100);
+	dumpmmcreg(mmchost->reg);
+
+	return 0;
+}
+
+static int mmc_update_clk(struct mmc *mmc)
+{

drivers/mmc/sunxi_mmc.c line 244

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned int cmd;
+	unsigned timeout = 0xfffff;
+
+	cmd = (0x1 << 31) | (0x1 << 21) | (0x1 << 13);
+	writel(cmd, &mmchost->reg->cmd);
+	while ((readl(&mmchost->reg->cmd) & (0x1 << 31)) && timeout--);
+	if (!timeout)
+		return -1;
+

^ Eeek! Use udelay and a time based timeout.

drivers/mmc/sunxi_mmc.c line 246

Quoted 2 lines
drivers/mmc/sunxi_mmc.c new file +2 -0
+	writel(readl(&mmchost->reg->rint), &mmchost->reg->rint);
+

^ Same here - Not even a timeout?

Quoted 17 lines
drivers/mmc/sunxi_mmc.c new file +17 -0
+	return 0;
+}
+
+static int mmc_config_clock(struct mmc *mmc, unsigned div)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned rval = readl(&mmchost->reg->clkcr);
+
+	/*
+	 * CLKCREG[7:0]: divider
+	 * CLKCREG[16]:  on/off
+	 * CLKCREG[17]:  power save
+	 */
+	/* Disable Clock */
+	rval &= ~(0x1 << 16);
+	writel(rval, &mmchost->reg->clkcr);
+	if (mmc_update_clk(mmc))

drivers/mmc/sunxi_mmc.c line 273

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+		return -1;
+
+	/* Change Divider Factor */
+	rval &= ~(0xff);
+	rval |= div;
+	writel(rval, &mmchost->reg->clkcr);
+	if (mmc_update_clk(mmc))
+		return -1;
+	/* Re-enable Clock */
+	rval |= (0x1 << 16);

#define ?

Quoted 14 lines
drivers/mmc/sunxi_mmc.c new file +14 -0
+	writel(rval, &mmchost->reg->clkcr);
+
+	if (mmc_update_clk(mmc))
+		return -1;
+
+	return 0;
+}
+
+static void mmc_set_ios(struct mmc *mmc)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned int clkdiv = 0;
+
+	debug("set ios: bus_width: %x, clock: %d, mod_clk: %d\n",

drivers/mmc/sunxi_mmc.c line 297

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	      mmc->bus_width, mmc->clock, mmchost->mod_clk);
+
+	/* Change clock first */
+	clkdiv = (mmchost->mod_clk + (mmc->clock >> 1)) / mmc->clock / 2;
+	if (mmc->clock)
+		if (mmc_config_clock(mmc, clkdiv)) {
+			mmchost->fatal_err = 1;
+			return;
+		}
+

Ambiguous formatting. Use { }

Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+	/* Change bus width */
+	if (mmc->bus_width == 8)
+		writel(0x2, &mmchost->reg->width);
+	else if (mmc->bus_width == 4)
+		writel(0x1, &mmchost->reg->width);
+	else

drivers/mmc/sunxi_mmc.c line 313

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+		writel(0x0, &mmchost->reg->width);
+}
+
+static int mmc_core_init(struct mmc *mmc)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+
+	/* Reset controller */
+	writel(0x7, &mmchost->reg->gctrl);
+

Magic value again.

Quoted 23 lines
drivers/mmc/sunxi_mmc.c new file +23 -0
+	return 0;
+}
+
+static int mmc_trans_data_by_cpu(struct mmc *mmc, struct mmc_data *data)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned i;
+	unsigned byte_cnt = data->blocksize * data->blocks;
+	unsigned *buff;
+	unsigned timeout = 0xfffff;
+
+	if (data->flags & MMC_DATA_READ) {
+		buff = (unsigned int *)data->dest;
+		for (i = 0; i < (byte_cnt >> 2); i++) {
+			while (--timeout &&
+				 (readl(&mmchost->reg->status) & (0x1 << 2)));
+			if (timeout <= 0)
+				goto out;
+			buff[i] = readl(mmchost->database);
+			timeout = 0xfffff;
+		}
+	} else {
+		buff = (unsigned int *)data->src;

drivers/mmc/sunxi_mmc.c line 346

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+		for (i = 0; i < (byte_cnt >> 2); i++) {
+			while (--timeout &&
+				 (readl(&mmchost->reg->status) & (0x1 << 3)));
+			if (timeout <= 0)
+				goto out;
+			writel(buff[i], mmchost->database);
+			timeout = 0xfffff;
+		}
+	}
+

^ Timeouts using time values? udelay? See above.

Quoted 83 lines
drivers/mmc/sunxi_mmc.c new file +83 -0
+out:
+	if (timeout <= 0)
+		return -1;
+
+	return 0;
+}
+
+static int mmc_trans_data_by_dma(struct mmc *mmc, struct mmc_data *data)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned byte_cnt = data->blocksize * data->blocks;
+	unsigned char *buff;
+	unsigned des_idx = 0;
+	unsigned buff_frag_num =
+		(byte_cnt + SDXC_DES_BUFFER_MAX_LEN - 1) >> SDXC_DES_NUM_SHIFT;
+	unsigned remain;
+	unsigned i, rval;
+	ALLOC_CACHE_ALIGN_BUFFER(struct sunxi_mmc_des, pdes, buff_frag_num);
+
+	buff = data->flags & MMC_DATA_READ ?
+	    (unsigned char *)data->dest : (unsigned char *)data->src;
+	remain = byte_cnt & (SDXC_DES_BUFFER_MAX_LEN - 1);
+	if (!remain)
+		remain = SDXC_DES_BUFFER_MAX_LEN;
+
+	flush_cache((unsigned long)buff, (unsigned long)byte_cnt);
+	for (i = 0; i < buff_frag_num; i++, des_idx++) {
+		memset((void *)&pdes[des_idx], 0, sizeof(struct sunxi_mmc_des));
+		pdes[des_idx].des_chain = 1;
+		pdes[des_idx].own = 1;
+		pdes[des_idx].dic = 1;
+		if (buff_frag_num > 1 && i != buff_frag_num - 1)
+			pdes[des_idx].data_buf1_sz =
+			    (SDXC_DES_BUFFER_MAX_LEN -
+			     1) & SDXC_DES_BUFFER_MAX_LEN;
+		else
+			pdes[des_idx].data_buf1_sz = remain;
+
+		pdes[des_idx].buf_addr_ptr1 =
+		    (u32) buff + i * SDXC_DES_BUFFER_MAX_LEN;
+		if (i == 0)
+			pdes[des_idx].first_des = 1;
+
+		if (i == buff_frag_num - 1) {
+			pdes[des_idx].dic = 0;
+			pdes[des_idx].last_des = 1;
+			pdes[des_idx].end_of_ring = 1;
+			pdes[des_idx].buf_addr_ptr2 = 0;
+		} else {
+			pdes[des_idx].buf_addr_ptr2 = (u32)&pdes[des_idx + 1];
+		}
+		debug("frag %d, remain %d, des[%d](%08x): ",
+		      i, remain, des_idx, (u32)&pdes[des_idx]);
+		debug("[0] = %08x, [1] = %08x, [2] = %08x, [3] = %08x\n",
+		      (u32)((u32 *)&pdes[des_idx])[0],
+		      (u32)((u32 *)&pdes[des_idx])[1],
+		      (u32)((u32 *)&pdes[des_idx])[2],
+		      (u32)((u32 *)&pdes[des_idx])[3]);
+	}
+	flush_cache((unsigned long)pdes,
+		    sizeof(struct sunxi_mmc_des) * (des_idx + 1));
+
+	/*
+	 * GCTRLREG
+	 * GCTRL[2]     : DMA reset
+	 * GCTRL[5]     : DMA enable
+	 *
+	 * IDMACREG
+	 * IDMAC[0]     : IDMA soft reset
+	 * IDMAC[1]     : IDMA fix burst flag
+	 * IDMAC[7]     : IDMA on
+	 *
+	 * IDIECREG
+	 * IDIE[0]      : IDMA transmit interrupt flag
+	 * IDIE[1]      : IDMA receive interrupt flag
+	 */
+	rval = readl(&mmchost->reg->gctrl);
+	/* Enable DMA */
+	writel(rval | (0x1 << 5) | (0x1 << 2), &mmchost->reg->gctrl);
+	/* Reset iDMA */
+	writel((0x1 << 0), &mmchost->reg->dmac);
+	/* Enable iDMA */
+	writel((0x1 << 1) | (1 << 7), &mmchost->reg->dmac);

drivers/mmc/sunxi_mmc.c line 439

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	rval = readl(&mmchost->reg->idie) & (~3);
+	if (data->flags & MMC_DATA_WRITE)
+		rval |= (0x1 << 0);
+	else
+		rval |= (0x1 << 1);
+	writel(rval, &mmchost->reg->idie);
+	writel((u32) pdes, &mmchost->reg->dlba);
+	writel((0x2 << 28) | (0x7 << 16) | (0x01 << 3),
+	       &mmchost->reg->ftrglevel);
+

^ #define again?

Quoted 100 lines
drivers/mmc/sunxi_mmc.c new file +100 -0
+	return 0;
+}
+
+static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+			struct mmc_data *data)
+{
+	struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
+	unsigned int cmdval = 0x80000000;
+	signed int timeout = 0;
+	int error = 0;
+	unsigned int status = 0;
+	unsigned int usedma = 0;
+	unsigned int bytecnt = 0;
+
+	if (mmchost->fatal_err)
+		return -1;
+	if (cmd->resp_type & MMC_RSP_BUSY)
+		debug("mmc cmd %d check rsp busy\n", cmd->cmdidx);
+	if (cmd->cmdidx == 12)
+		return 0;
+
+	/*
+	 * CMDREG
+	 * CMD[5:0]     : Command index
+	 * CMD[6]       : Has response
+	 * CMD[7]       : Long response
+	 * CMD[8]       : Check response CRC
+	 * CMD[9]       : Has data
+	 * CMD[10]      : Write
+	 * CMD[11]      : Steam mode
+	 * CMD[12]      : Auto stop
+	 * CMD[13]      : Wait previous over
+	 * CMD[14]      : About cmd
+	 * CMD[15]      : Send initialization
+	 * CMD[21]      : Update clock
+	 * CMD[31]      : Load cmd
+	 */
+	if (!cmd->cmdidx)
+		cmdval |= (0x1 << 15);
+	if (cmd->resp_type & MMC_RSP_PRESENT)
+		cmdval |= (0x1 << 6);
+	if (cmd->resp_type & MMC_RSP_136)
+		cmdval |= (0x1 << 7);
+	if (cmd->resp_type & MMC_RSP_CRC)
+		cmdval |= (0x1 << 8);
+
+	if (data) {
+		if ((u32) data->dest & 0x3) {
+			error = -1;
+			goto out;
+		}
+
+		cmdval |= (0x1 << 9) | (0x1 << 13);
+		if (data->flags & MMC_DATA_WRITE)
+			cmdval |= (0x1 << 10);
+		if (data->blocks > 1)
+			cmdval |= (0x1 << 12);
+		writel(data->blocksize, &mmchost->reg->blksz);
+		writel(data->blocks * data->blocksize, &mmchost->reg->bytecnt);
+	}
+
+	debug("mmc %d, cmd %d(0x%08x), arg 0x%08x\n", mmchost->mmc_no,
+	      cmd->cmdidx, cmdval | cmd->cmdidx, cmd->cmdarg);
+	writel(cmd->cmdarg, &mmchost->reg->arg);
+
+	if (!data)
+		writel(cmdval | cmd->cmdidx, &mmchost->reg->cmd);
+
+	/*
+	 * transfer data and check status
+	 * STATREG[2] : FIFO empty
+	 * STATREG[3] : FIFO full
+	 */
+	if (data) {
+		int ret = 0;
+
+		bytecnt = data->blocksize * data->blocks;
+		debug("trans data %d bytes\n", bytecnt);
+#if defined(CONFIG_MMC_SUNXI_USE_DMA) && !defined(CONFIG_SPL_BUILD)
+		if (bytecnt > 64) {
+#else
+		if (0) {
+#endif
+			usedma = 1;
+			writel(readl(&mmchost->reg->gctrl) & ~(0x1 << 31),
+			       &mmchost->reg->gctrl);
+			ret = mmc_trans_data_by_dma(mmc, data);
+			writel(cmdval | cmd->cmdidx, &mmchost->reg->cmd);
+		} else {
+			writel(readl(&mmchost->reg->gctrl) | 0x1 << 31,
+			       &mmchost->reg->gctrl);
+			writel(cmdval | cmd->cmdidx, &mmchost->reg->cmd);
+			ret = mmc_trans_data_by_cpu(mmc, data);
+		}
+		if (ret) {
+			error = readl(&mmchost->reg->rint) & 0xbfc2;
+			error = TIMEOUT;
+			goto out;
+		}
+	}

drivers/mmc/sunxi_mmc.c line 549

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+
+	timeout = 0xfffff;
+	do {
+		status = readl(&mmchost->reg->rint);
+		if (!timeout-- || (status & 0xbfc2)) {
+			error = status & 0xbfc2;
+			debug("cmd timeout %x\n", error);
+			error = TIMEOUT;
+			goto out;
+		}

^ Again timeouts without using time values.

Quoted 8 lines
drivers/mmc/sunxi_mmc.c new file +8 -0
+	} while (!(status & 0x4));
+
+	if (data) {
+		unsigned done = 0;
+		timeout = usedma ? 0xffff * bytecnt : 0xffff;
+		debug("cacl timeout %x\n", timeout);
+		do {
+			status = readl(&mmchost->reg->rint);

drivers/mmc/sunxi_mmc.c line 567

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+			if (!timeout-- || (status & 0xbfc2)) {
+				error = status & 0xbfc2;
+				debug("data timeout %x\n", error);
+				error = TIMEOUT;
+				goto out;
+			}
+			if (data->blocks > 1)
+				done = status & (0x1 << 14);
+			else
+				done = status & (0x1 << 3);

^ Timeouts?

drivers/mmc/sunxi_mmc.c line 580

Quoted 13 lines
drivers/mmc/sunxi_mmc.c new file +13 -0
+		} while (!done);
+	}
+
+	if (cmd->resp_type & MMC_RSP_BUSY) {
+		timeout = 0xfffff;
+		do {
+			status = readl(&mmchost->reg->status);
+			if (!timeout--) {
+				debug("busy timeout\n");
+				error = TIMEOUT;
+				goto out;
+			}
+		} while (status & (1 << 9));

^ You get the idea... Timeouts. And #defines

Quoted 58 lines
drivers/mmc/sunxi_mmc.c new file +58 -0
+	}
+
+	if (cmd->resp_type & MMC_RSP_136) {
+		cmd->response[0] = readl(&mmchost->reg->resp3);
+		cmd->response[1] = readl(&mmchost->reg->resp2);
+		cmd->response[2] = readl(&mmchost->reg->resp1);
+		cmd->response[3] = readl(&mmchost->reg->resp0);
+		debug("mmc resp 0x%08x 0x%08x 0x%08x 0x%08x\n",
+		      cmd->response[3], cmd->response[2],
+		      cmd->response[1], cmd->response[0]);
+	} else {
+		cmd->response[0] = readl(&mmchost->reg->resp0);
+		debug("mmc resp 0x%08x\n", cmd->response[0]);
+	}
+out:
+	if (data && usedma) {
+		/* IDMASTAREG
+		 * IDST[0] : idma tx int
+		 * IDST[1] : idma rx int
+		 * IDST[2] : idma fatal bus error
+		 * IDST[4] : idma descriptor invalid
+		 * IDST[5] : idma error summary
+		 * IDST[8] : idma normal interrupt sumary
+		 * IDST[9] : idma abnormal interrupt sumary
+		 */
+		status = readl(&mmchost->reg->idst);
+		writel(status, &mmchost->reg->idst);
+		writel(0, &mmchost->reg->idie);
+		writel(0, &mmchost->reg->dmac);
+		writel(readl(&mmchost->reg->gctrl) & ~(0x1 << 5),
+		       &mmchost->reg->gctrl);
+	}
+	if (error < 0) {
+		writel(0x7, &mmchost->reg->gctrl);
+		mmc_update_clk(mmc);
+	}
+	writel(0xffffffff, &mmchost->reg->rint);
+	writel(readl(&mmchost->reg->gctrl) | (1 << 1), &mmchost->reg->gctrl);
+
+	return error;
+}
+
+int sunxi_mmc_init(int sdc_no)
+{
+	struct mmc *mmc;
+
+	memset(&mmc_dev[sdc_no], 0, sizeof(struct mmc));
+	memset(&mmc_host[sdc_no], 0, sizeof(struct sunxi_mmc_host));
+	mmc = &mmc_dev[sdc_no];
+
+	sprintf(mmc->name, "SUNXI SD/MMC");
+	mmc->priv = &mmc_host[sdc_no];
+	mmc->send_cmd = mmc_send_cmd;
+	mmc->set_ios = mmc_set_ios;
+	mmc->init = mmc_core_init;
+
+	mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mmc->host_caps = MMC_MODE_4BIT;

drivers/mmc/sunxi_mmc.c line 648

Quoted 10 lines
drivers/mmc/sunxi_mmc.c new file +10 -0
+	mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
+
+	mmc->f_min = 400000;
+	mmc->f_max = 52000000;
+
+	mmc_resource_init(sdc_no);
+	mmc_clk_io_on(sdc_no);
+
+	mmc_register(mmc);
+

^ The mmc_registeration sequence has changed, but not landed at master yet.

Quoted 38 lines
drivers/mmc/sunxi_mmc.c new file +2 -0
+	return 0;
+}
include/configs/sunxi-common.h +11 -0
index bdfc169..1afdeb2 100644
@@ -74,6 +74,16 @@
 #define CONFIG_INITRD_TAG
 #define CONFIG_CMDLINE_EDITING
 
+/* 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 */
+
 /*
 * Size of malloc() pool
 * 1MB = 0x100000, 0x100000 = 1024 * 1024
@@ -118,6 +128,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_BOOTDELAY	3
Signature · 6 lines
1.8.5.3

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards

-- Pantelis

#26 lore raw

PATCH 7/9 sunxi: mmc support

Quoted 1 line · Pantelis Antoniou

[...]

Thanks for your review. It seems there are still quite a few issues dating back to the original allwinner dumps here.

@linux-sunxi: if anyone wants to volunteer to help cleanup this particular driver I'd be very happy -- there's a lot of it!

Quoted 10 lines

+

drivers/mmc/sunxi_mmc.c line 56

Quoted 8 lines
drivers/mmc/sunxi_mmc.c new file +8 -0
+static void dumpmmcreg(struct sunxi_mmc *reg)
+{
+	debug("dump mmc registers:\n");
+	debug("gctrl     0x%08x\n", reg->gctrl);
+	debug("clkcr     0x%08x\n", reg->clkcr);
+	debug("timeout   0x%08x\n", reg->timeout);
+	debug("width     0x%08x\n", reg->width);
+	debug("blksz     0x%08x\n", reg->blksz);

[...] lots more debug(foo)

Quoted 3 lines
Quoted 1 line

+}

^^^ #ifdef DEBUG here?

I can if you prefer but debug() itself effectively includes the same ifdef so the end result is already the same.

Quoted 8 lines

[...]

drivers/mmc/sunxi_mmc.c line 110

Quoted 4 lines
drivers/mmc/sunxi_mmc.c new file +4 -0
+/* support 4 mmc hosts */
+struct mmc mmc_dev[4];
+struct sunxi_mmc_host mmc_host[4];
+

^ hosts & mmc structs can be allocated even for SPL now

Can be or must be?

Quoted 9 lines
Quoted 9 lines
drivers/mmc/sunxi_mmc.c new file +9 -0
+	struct sunxi_mmc_host *mmchost = &mmc_host[sdc_no];
+	static struct sunxi_gpio *gpio_c =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_C];
+	static struct sunxi_gpio *gpio_f =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_F];
+#if CONFIG_MMC1_PG
+	static struct sunxi_gpio *gpio_g =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_G];
+#endif
Quoted 8 lines

drivers/mmc/sunxi_mmc.c line 164

Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+	static struct sunxi_gpio *gpio_h =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_H];
+	static struct sunxi_gpio *gpio_i =
+	    &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_I];
+	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+

^ Castings are ugly; rework with a temporary variable.

Ack.

The static's here are odd too and date back to the original alwinner code dumps. I'll get rid of them too.

Quoted 16 lines

[...]

drivers/mmc/sunxi_mmc.c line 210

Quoted 12 lines
drivers/mmc/sunxi_mmc.c new file +12 -0
+	case 3:
+		/* PI4-CMD, PI5-CLK, PI6~9-D0~D3 : 2 */
+		writel(0x2222 << 16, &gpio_i->cfg[0]);
+		writel(0x22, &gpio_i->cfg[1]);
+		writel(0x555 << 8, &gpio_i->pull[0]);
+		writel(0x555 << 8, &gpio_i->drv[0]);
+		break;
+
+	default:
+		return -1;
+	}
+

Lots of magic constants. I have no idea what's going on here. Use a few defines.

Right. These came from the original allwinner dumps so I was worried that they might be undocumented magic, but actually since the are gpio frobbing I reckon I can figure them out.

Quoted 8 lines

[...]> + cmd = (0x1 << 31) | (0x1 << 21) | (0x1 << 13);

drivers/mmc/sunxi_mmc.c line 244

Quoted 5 lines
drivers/mmc/sunxi_mmc.c new file +5 -0
+	writel(cmd, &mmchost->reg->cmd);
+	while ((readl(&mmchost->reg->cmd) & (0x1 << 31)) && timeout--);
+	if (!timeout)
+		return -1;
+

^ Eeek! Use udelay and a time based timeout.

Ack.

Quoted 4 lines

drivers/mmc/sunxi_mmc.c line 246

Quoted 2 lines
drivers/mmc/sunxi_mmc.c new file +2 -0
+	writel(readl(&mmchost->reg->rint), &mmchost->reg->rint);
+

^ Same here - Not even a timeout?

No loop here though?
[...]

Quoted 3 lines

drivers/mmc/sunxi_mmc.c line 273

Quoted 1 line
drivers/mmc/sunxi_mmc.c new file +1 -0
+	rval |= (0x1 << 16);

#define ?

Ack

[...]

Quoted 1 line

Ambiguous formatting. Use { }

Ack

Quoted 6 lines

[...]

drivers/mmc/sunxi_mmc.c line 313

Quoted 3 lines
drivers/mmc/sunxi_mmc.c new file +3 -0
+	/* Reset controller */
+	writel(0x7, &mmchost->reg->gctrl);
+

Magic value again.

The sum total of the docs for this one are:
* GCTRLREG
* GCTRL[2] : DMA reset
* GCTRL[5] : DMA enable

But I'll see what I can do.

[...]

Quoted 6 lines
Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+	} else {
+		buff = (unsigned int *)data->src;
+		for (i = 0; i < (byte_cnt >> 2); i++) {
+			while (--timeout &&
+				 (readl(&mmchost->reg->status) & (0x1 << 3)));
+			if (timeout <= 0)
Quoted 8 lines

drivers/mmc/sunxi_mmc.c line 346

Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+				goto out;
+			writel(buff[i], mmchost->database);
+			timeout = 0xfffff;
+		}
+	}
+

^ Timeouts using time values? udelay? See above.

Ack.

Quoted 8 lines

[....]

drivers/mmc/sunxi_mmc.c line 439

Quoted 5 lines
drivers/mmc/sunxi_mmc.c new file +5 -0
+	writel(rval, &mmchost->reg->idie);
+	writel((u32) pdes, &mmchost->reg->dlba);
+	writel((0x2 << 28) | (0x7 << 16) | (0x01 << 3),
+	       &mmchost->reg->ftrglevel);
+

^ #define again?

Some of these (ftrgllevel) have no docs whatsoever, but I'll do what I can.

Quoted 13 lines

[...]

drivers/mmc/sunxi_mmc.c line 549

Quoted 9 lines
drivers/mmc/sunxi_mmc.c new file +9 -0
+	timeout = 0xfffff;
+	do {
+		status = readl(&mmchost->reg->rint);
+		if (!timeout-- || (status & 0xbfc2)) {
+			error = status & 0xbfc2;
+			debug("cmd timeout %x\n", error);
+			error = TIMEOUT;
+			goto out;
+		}

^ Again timeouts without using time values.

I'm getting the picture ;-)

Quoted 21 lines

[...]

Quoted 20 lines
drivers/mmc/sunxi_mmc.c new file +20 -0
+int sunxi_mmc_init(int sdc_no)
+{
+	struct mmc *mmc;
+
+	memset(&mmc_dev[sdc_no], 0, sizeof(struct mmc));
+	memset(&mmc_host[sdc_no], 0, sizeof(struct sunxi_mmc_host));
+	mmc = &mmc_dev[sdc_no];
+
+	sprintf(mmc->name, "SUNXI SD/MMC");
+	mmc->priv = &mmc_host[sdc_no];
+	mmc->send_cmd = mmc_send_cmd;
+	mmc->set_ios = mmc_set_ios;
+	mmc->init = mmc_core_init;
+
+	mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mmc->host_caps = MMC_MODE_4BIT;
+	mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
+
+	mmc->f_min = 400000;
+	mmc->f_max = 52000000;
Quoted 8 lines

drivers/mmc/sunxi_mmc.c line 648

Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+
+	mmc_resource_init(sdc_no);
+	mmc_clk_io_on(sdc_no);
+
+	mmc_register(mmc);
+

^ The mmc_registeration sequence has changed, but not landed at master yet.

Do you have a reference handy for this?

Thanks again, sorry this driver is such a mess (I must confess I didn't look at it that closely when I cherry picked it).

Ian.

#27 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH v1 7/9] sunxi: mmc support

Quoted 55 lines · Ian Campbell
Quoted 1 line · Pantelis Antoniou

[...]

Thanks for your review. It seems there are still quite a few issues dating back to the original allwinner dumps here.

@linux-sunxi: if anyone wants to volunteer to help cleanup this particular driver I'd be very happy -- there's a lot of it!

Quoted 10 lines

+

drivers/mmc/sunxi_mmc.c line 56

Quoted 8 lines
drivers/mmc/sunxi_mmc.c new file +8 -0
+static void dumpmmcreg(struct sunxi_mmc *reg)
+{
+   debug("dump mmc registers:\n");
+   debug("gctrl     0x%08x\n", reg->gctrl);
+   debug("clkcr     0x%08x\n", reg->clkcr);
+   debug("timeout   0x%08x\n", reg->timeout);
+   debug("width     0x%08x\n", reg->width);
+   debug("blksz     0x%08x\n", reg->blksz);

[...] lots more debug(foo)

Quoted 3 lines
Quoted 1 line

+}

^^^ #ifdef DEBUG here?

I can if you prefer but debug() itself effectively includes the same ifdef so the end result is already the same.

Quoted 8 lines

[...]

drivers/mmc/sunxi_mmc.c line 110

Quoted 4 lines
drivers/mmc/sunxi_mmc.c new file +4 -0
+/* support 4 mmc hosts */
+struct mmc mmc_dev[4];
+struct sunxi_mmc_host mmc_host[4];
+

^ hosts & mmc structs can be allocated even for SPL now

Can be or must be?

Quoted 9 lines
Quoted 9 lines
drivers/mmc/sunxi_mmc.c new file +9 -0
+   struct sunxi_mmc_host *mmchost = &mmc_host[sdc_no];
+   static struct sunxi_gpio *gpio_c =
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_C];
+   static struct sunxi_gpio *gpio_f =
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_F];
+#if CONFIG_MMC1_PG
+   static struct sunxi_gpio *gpio_g =
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_G];
+#endif
Quoted 8 lines

drivers/mmc/sunxi_mmc.c line 164

Quoted 6 lines
drivers/mmc/sunxi_mmc.c new file +6 -0
+   static struct sunxi_gpio *gpio_h =
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_H];
+   static struct sunxi_gpio *gpio_i =
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[SUNXI_GPIO_I];
+   struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+

^ Castings are ugly; rework with a temporary variable.

Quoted 4 lines

Ack.

The static's here are odd too and date back to the original alwinner code dumps. I'll get rid of them too.

You can drop the gpio ones in favor of using the sunxi gpio driver.

Quoted 17 lines
Quoted 16 lines

[...]

drivers/mmc/sunxi_mmc.c line 210

Quoted 12 lines
drivers/mmc/sunxi_mmc.c new file +12 -0
+   case 3:
+           /* PI4-CMD, PI5-CLK, PI6~9-D0~D3 : 2 */
+           writel(0x2222 << 16, &gpio_i->cfg[0]);
+           writel(0x22, &gpio_i->cfg[1]);
+           writel(0x555 << 8, &gpio_i->pull[0]);
+           writel(0x555 << 8, &gpio_i->drv[0]);
+           break;
+
+   default:
+           return -1;
+   }
+

Lots of magic constants. I have no idea what's going on here. Use a few defines.

Quoted 3 lines

Right. These came from the original allwinner dumps so I was worried that they might be undocumented magic, but actually since the are gpio frobbing I reckon I can figure them out.

Should be something like this:

        for (pin = SUNXI_GPI(4); pin <= SUNXI_GPI(9); pin++) {
                sunxi_gpio_set_cfgpin(pin, SUNXI_GPI_SDC3);
                sunxi_gpio_set_drv(pin, 1);
                sunxi_gpio_set_pull(pin, SUNXI_PULL_UP);
        }

Note that SUNXI_GPI_* and SUNXI_PULL_* have not been defined.

I will send a patch for both the macros and MMC pinmux setting.

[..]

Thanks for working on this!

Cheers
ChenYu

#28 lore raw

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

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

As well as the following signed-off-by the sunxi branch shows commits to these files authored by the following:
Henrik Nordstrom
Tom Cubie

---
 Makefile                                |  15 +++
 arch/arm/cpu/armv7/sunxi/config.mk      |   8 ++
 arch/arm/cpu/armv7/sunxi/u-boot-spl.lds |  69 ++++++++++++++
 boards.cfg                              |   1 +
 include/configs/sunxi-common.h          |  45 +++++++++
 spl/Makefile                            |  12 +++
 tools/.gitignore                        |   1 +
 tools/Makefile                          |   6 ++
 tools/mksunxiboot.README                |  13 +++
 tools/mksunxiboot.c                     | 163 ++++++++++++++++++++++++++++++++
 10 files changed, 333 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.README
 create mode 100644 tools/mksunxiboot.c
Makefile +15 -0
index 47a03e3..ff1f64e 100644
@@ -491,6 +491,16 @@ $(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
 			--pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
 		cat $(obj)u-boot.img >> $@
 
+# sunxi: Combined object with SPL U-Boot with sunxi header (sunxi-spl.bin)
+# and the full-blown U-Boot attached to it
+$(obj)u-boot-sunxi-with-spl.bin: $(obj)spl/sunxi-spl.bin $(obj)u-boot.img
+		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
+			of=$(obj)spl/sunxi-spl-pad.bin 2>/dev/null
+		dd if=$(obj)spl/sunxi-spl.bin of=$(obj)spl/sunxi-spl-pad.bin \
+			conv=notrunc 2>/dev/null
+		cat $(obj)spl/sunxi-spl-pad.bin $(obj)u-boot.img > $@
+		rm $(obj)spl/sunxi-spl-pad.bin
+
 ifneq ($(CONFIG_TEGRA),)
 $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
@@ -578,6 +588,9 @@ $(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
 $(obj)tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend
 		$(MAKE) -C spl all CONFIG_TPL_BUILD=y
 
+$(obj)spl/sunxi-spl.bin:	$(SUBDIR_TOOLS) depend
+		$(MAKE) -C spl all
+
 # Explicitly make _depend in subdirs containing multiple targets to prevent
 # parallel sub-makes creating .depend files simultaneously.
 depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
@@ -799,6 +812,7 @@ clean:
 	       $(obj)tools/dump{env,}image		  \
 	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
 	       $(obj)tools/mk{$(BOARD),}spl				  \
+	       $(obj)tools/mksunxiboot					  \
 	       $(obj)tools/mxsboot					  \
 	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
 	       $(obj)tools/kernel-doc/docproc				  \
@@ -855,6 +869,7 @@ clobber:	tidy
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
 	@rm -f $(obj)dts/*.tmp
 	@rm -f $(obj)spl/u-boot-spl{,-pad}.ais
+	@rm -f $(obj)spl/sun?i-spl.bin
 
 mrproper \
 distclean:	clobber unconfig
arch/arm/cpu/armv7/sunxi/config.mk new file +8 -0
new file mode 100644
index 0000000..9ce48b4
@@ -0,0 +1,8 @@
+# Build a combined spl + u-boot image
+ifdef CONFIG_SPL
+ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_FEL
+ALL-y = $(obj)u-boot-sunxi-with-spl.bin
+endif
+endif
+endif
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds new file +69 -0

69 lines not on this page · raw message

boards.cfg +1 -0
index 6c35a40..a513376 100644
@@ -353,6 +353,7 @@ Active  arm         armv7          rmobile     renesas         koelsch
 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                                                                                                              -
 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                           -                                                                                                                                 -
include/configs/sunxi-common.h +45 -0

84 lines not on this page · raw message

spl/Makefile +12 -0
index 5e5472d..436b952 100644
@@ -152,6 +152,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
@@ -164,6 +170,12 @@ $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
 	$(OBJTREE)/tools/mk$(BOARD)spl $(VAR_SIZE_PARAM) $< $@
 endif
 
+ifdef CONFIG_SUNXI
+$(obj)sunxi-spl.bin: $(obj)u-boot-spl.bin
+	$(OBJTREE)/tools/mksunxiboot \
+		$(obj)u-boot-spl.bin $(obj)sunxi-spl.bin
+endif
+
 $(obj)$(SPL_BIN).bin:	$(obj)$(SPL_BIN)
 	$(OBJCOPY) $(OBJCFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
 
tools/.gitignore +1 -0
index cd2f041..2fdc9bd 100644
@@ -8,6 +8,7 @@
 /mkimage
 /mpc86x_clk
 /mxsboot
+/mksunxiboot
 /ncb
 /proftool
 /relocate-rela
tools/Makefile +6 -0
index 328cea3..3eb46e6 100644
@@ -56,6 +56,7 @@ BIN_FILES-y += mkimage$(SFX)
 BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
 BIN_FILES-$(CONFIG_EXYNOS5420) += mk$(BOARD)spl$(SFX)
 BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
+BIN_FILES-$(CONFIG_SUNXI) += mksunxiboot$(SFX)
 BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
@@ -97,6 +98,7 @@ OBJ_FILES-$(CONFIG_EXYNOS_SPL) += mkexynosspl.o
 OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
 OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
+OBJ_FILES-$(CONFIG_SUNXI) += mksunxiboot.o
 OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
@@ -266,6 +268,10 @@ $(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
 
+$(obj)mksunxiboot$(SFX):	$(obj)mksunxiboot.o
+	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+	$(HOSTSTRIP) $@
+
 $(obj)mxsboot$(SFX):	$(obj)mxsboot.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
tools/mksunxiboot.README new file +13 -0
new file mode 100644
index 0000000..5838778
@@ -0,0 +1,13 @@
+This program make a arm binary file can be loaded by Allwinner A10 and related
+chips from storage media such as nand and mmc.
+
+More information about A10 boot, please refer to
+http://rhombus-tech.net/allwinner_a10/a10_boot_process/
+
+To compile this program, just type make, you will get 'mksunxiboot'.
+
+To use it,
+$./mksunxiboot u-boot.bin u-boot-mmc.bin
+then you can write it to a mmc card with dd.
+$sudo dd if=u-boot-mmc.bin of=/dev/sdb bs=1024 seek=8
+then insert your mmc card to your A10 tablet, you can boot from mmc card.
tools/mksunxiboot.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#29 lore raw

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

Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/5861c94f/attachment.pgp>
#30 lore raw

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

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Regards,

Hans

#31 lore raw

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTI1J0AAoJENk4IS6UOR1WUocP/Aojl084qj0+sibvo6r7xb0T 23QaTqoGo+0i48mssFhiCo3KY1RMTiokQ0VgE0r29GQSipc5y75nIj24p0SpFD9N H2e2hWoTTQ106+MFx4upK61KLvmDA7LUJIHkVYWmgyOP7qL1wdwB5/5hqHuLkSlF Osz37r2JSbrWgYG+hs8Yby5D/fVizOTpf8f8F5GHrDA+3qlsOOHxUogfPGQeTPpk 9EhrLPSWWIN5l6qnykiiYz0QHDotJvrKoCVm2DJ4APnsIBS3/QyFNkePjVRRrmIT 1zob5wmprYywOjVNeBZ10HjPM8AHuyO2xBr+H3ZwcjfgI4MYiTJiG3eSJ1lTcveY FGbQa7HFzpnp9vwvvpWtT720D58WYdkjYQRarYHBWpXn+i2xKf4zGggX14jytUXU dFrqSDQ1hIEZd6uWj/jQMqHuZWDvnJ46ySqlE37UCZwcO1dQ/6WkNrve+XK1+HGQ EQlTlfRD64a+U2Plh2qoU/xadb+cWNV3fOppUgiwjdvx/+H/8TXsj6h0euaUe7JG ej+xqeH1a5HoVg5g30Ihn/KHNHwefG6ap3/vsdGH6hq5euodNxIzfBNZAEJ+dY58 tUkfuB3G5OeKV6JvbfD2vOJOl7AHRgqabXNHcNDS3AWAFnodcsgRO2E0od1ao7Ii n6pN0HAAzINC4y1kR/tJ
=6IRY
-----END PGP SIGNATURE-----

#32 lore raw

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

Quoted 20 lines · Tom Rini
Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

AFAICS none of the existing platforms in u-boot.git are setting bootm_low in their default environment.

README suggests that bootm_low is the lowest address allowed for use by bootm/z rather than the limit, from the docs it seems that CONFIG_SYS_BOOTMAPSZ (overridden by env bootm_mapsize) is the limit

bootm_low defaults to CONFIG_SYS_SDRAM_BASE, which sunxi sets, and this seems logical to me since kernel's lowmem mapping starts at offset 0 into RAM.

I think we probably do want to set BOOTMAPSZ to something like 256MB, which seems to be the highest in tree (although the vast majority use 8MB...). But I'm not sure that explains why fdt_high is needed today. I'll have a play.

Ian.

#33 lore raw

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

Quoted 37 lines · Ian Campbell
Quoted 20 lines · Tom Rini
Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

AFAICS none of the existing platforms in u-boot.git are setting bootm_low in their default environment.

README suggests that bootm_low is the lowest address allowed for use by bootm/z rather than the limit, from the docs it seems that CONFIG_SYS_BOOTMAPSZ (overridden by env bootm_mapsize) is the limit

Quoted 8 lines

bootm_low defaults to CONFIG_SYS_SDRAM_BASE, which sunxi sets, and this seems logical to me since kernel's lowmem mapping starts at offset 0 into RAM.

I think we probably do want to set BOOTMAPSZ to something like 256MB, which seems to be the highest in tree (although the vast majority use 8MB...). But I'm not sure that explains why fdt_high is needed today. I'll have a play.

So setting BOOTMAPSZ to e.g. 256MB limits the fdt load address as you would expect.

But it seems to not make any difference for the initramfs which still gets loaded to the top of RAM. This is consistent with README which says that unless initrd_high is set the ramdisk will be loaded as high as possible, without reference to BOOTMAPSZ. Supposedly setting initrd_high to "no", "off" or "0" should cause initrd relocation to obey BOOTMAPSZ -- but at least in my experiments it does not seem to do so.

boot_ramdisk_high() doesn't seem to make any reference to bootm_{low,size,etc} like I would expect and with initrd_high==0 it calls lmb_alloc which allocates anywhere. This is in contrast with boot_relocate_fdt which uses getenv_bootm_mapsize() and getenv_bootm_low().

It looks to me like the initrd reloc logic is wrong -- but it's been that way for such a long time I think I must be mistaken.

Ian.

#34 lore raw

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

Quoted 29 lines · Ian Campbell
Quoted 28 lines · Ian Campbell
Quoted 26 lines · Tom Rini
Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

Quoted 4 lines
Quoted 4 lines

So, I'm confused about what to do here ;-)

AFAICS none of the existing platforms in u-boot.git are setting bootm_low in their default environment.

Yes. http://patchwork.ozlabs.org/patch/329210/ gets things right for some subset of TI platforms and I'll be picking that up soon. Or maybe a v2.

Quoted 23 lines
Quoted 4 lines

README suggests that bootm_low is the lowest address allowed for use by bootm/z rather than the limit, from the docs it seems that CONFIG_SYS_BOOTMAPSZ (overridden by env bootm_mapsize) is the limit

Quoted 8 lines

bootm_low defaults to CONFIG_SYS_SDRAM_BASE, which sunxi sets, and this seems logical to me since kernel's lowmem mapping starts at offset 0 into RAM.

I think we probably do want to set BOOTMAPSZ to something like 256MB, which seems to be the highest in tree (although the vast majority use 8MB...). But I'm not sure that explains why fdt_high is needed today. I'll have a play.

So setting BOOTMAPSZ to e.g. 256MB limits the fdt load address as you would expect.

But it seems to not make any difference for the initramfs which still gets loaded to the top of RAM. This is consistent with README which says that unless initrd_high is set the ramdisk will be loaded as high as possible, without reference to BOOTMAPSZ. Supposedly setting initrd_high to "no", "off" or "0" should cause initrd relocation to obey BOOTMAPSZ -- but at least in my experiments it does not seem to do so.

Quoted 8 lines

boot_ramdisk_high() doesn't seem to make any reference to bootm_{low,size,etc} like I would expect and with initrd_high==0 it calls lmb_alloc which allocates anywhere. This is in contrast with boot_relocate_fdt which uses getenv_bootm_mapsize() and getenv_bootm_low().

It looks to me like the initrd reloc logic is wrong -- but it's been that way for such a long time I think I must be mistaken.

I think after reading what you're saying, things are very unclear, unfortunately. What you can do, but is very odd after thinking about it is if you set bootm_low only and not any of the size things, it works as a constraint on the upper bounds so initrd nor fdt are put above that. But that's really seeming like a side effect rather than an intent. I'm going to whack at this more..

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140317/4386b7e9/attachment.pgp>
#35 lore raw

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

Quoted 30 lines · Tom Rini
Quoted 29 lines · Ian Campbell
Quoted 28 lines · Ian Campbell
Quoted 26 lines · Tom Rini
Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

Review

Quoted 3 lines
(quoted diff) +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

So, I'm confused about what to do here ;-)

AFAICS none of the existing platforms in u-boot.git are setting bootm_low in their default environment.

Yes. http://patchwork.ozlabs.org/patch/329210/ gets things right for some subset of TI platforms and I'll be picking that up soon. Or maybe a v2.

You are dropping fdt_high=0xffffffff here, is that deliberate?

I suppose this is offset by the addition of bootm_size which keeps things working? (or does it, I'm very confused now...)

Quoted 29 lines
Quoted 29 lines
Quoted 4 lines

README suggests that bootm_low is the lowest address allowed for use by bootm/z rather than the limit, from the docs it seems that CONFIG_SYS_BOOTMAPSZ (overridden by env bootm_mapsize) is the limit

Quoted 8 lines

bootm_low defaults to CONFIG_SYS_SDRAM_BASE, which sunxi sets, and this seems logical to me since kernel's lowmem mapping starts at offset 0 into RAM.

I think we probably do want to set BOOTMAPSZ to something like 256MB, which seems to be the highest in tree (although the vast majority use 8MB...). But I'm not sure that explains why fdt_high is needed today. I'll have a play.

So setting BOOTMAPSZ to e.g. 256MB limits the fdt load address as you would expect.

But it seems to not make any difference for the initramfs which still gets loaded to the top of RAM. This is consistent with README which says that unless initrd_high is set the ramdisk will be loaded as high as possible, without reference to BOOTMAPSZ. Supposedly setting initrd_high to "no", "off" or "0" should cause initrd relocation to obey BOOTMAPSZ -- but at least in my experiments it does not seem to do so.

boot_ramdisk_high() doesn't seem to make any reference to bootm_{low,size,etc} like I would expect and with initrd_high==0 it calls lmb_alloc which allocates anywhere. This is in contrast with boot_relocate_fdt which uses getenv_bootm_mapsize() and getenv_bootm_low().

Quoted 5 lines
Quoted 2 lines

It looks to me like the initrd reloc logic is wrong -- but it's been that way for such a long time I think I must be mistaken.

I think after reading what you're saying, things are very unclear, unfortunately.

I'm glad it's not just me!

Quoted 4 lines

What you can do, but is very odd after thinking about it
is if you set bootm_low only and not any of the size things, it works as a constraint on the upper bounds so initrd nor fdt are put above that. But that's really seeming like a side effect rather than an intent.

Right, I don't think I want to add any weirdness, unless all the cool kids are going to be doing it of course ;-)

Quoted 1 line

I'm going to whack at this more..

Thanks. I think for now with this series I can just set BOOTMAPSZ to 256MB without making this problem any better or worse and we can fixup things later in whatever is determined to be the right solution. Is that OK with you?

Ian.

#36 lore raw

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

Quoted 36 lines · Ian Campbell
Quoted 35 lines · Tom Rini
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Ian Campbell
Quoted 20 lines · Tom Rini
Quoted 15 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

Review

Quoted 3 lines
(quoted diff) +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Quoted 3 lines

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

AFAICS none of the existing platforms in u-boot.git are setting bootm_low in their default environment.

Quoted 8 lines
Quoted 3 lines

Yes. http://patchwork.ozlabs.org/patch/329210/ gets things right for some subset of TI platforms and I'll be picking that up soon. Or maybe a v2.

You are dropping fdt_high=0xffffffff here, is that deliberate?

I suppose this is offset by the addition of bootm_size which keeps things working? (or does it, I'm very confused now...)

Intentional and confusing.

Quoted 45 lines
Quoted 29 lines
Quoted 29 lines
Quoted 4 lines

README suggests that bootm_low is the lowest address allowed for use by bootm/z rather than the limit, from the docs it seems that CONFIG_SYS_BOOTMAPSZ (overridden by env bootm_mapsize) is the limit

Quoted 8 lines

bootm_low defaults to CONFIG_SYS_SDRAM_BASE, which sunxi sets, and this seems logical to me since kernel's lowmem mapping starts at offset 0 into RAM.

I think we probably do want to set BOOTMAPSZ to something like 256MB, which seems to be the highest in tree (although the vast majority use 8MB...). But I'm not sure that explains why fdt_high is needed today. I'll have a play.

So setting BOOTMAPSZ to e.g. 256MB limits the fdt load address as you would expect.

But it seems to not make any difference for the initramfs which still gets loaded to the top of RAM. This is consistent with README which says that unless initrd_high is set the ramdisk will be loaded as high as possible, without reference to BOOTMAPSZ. Supposedly setting initrd_high to "no", "off" or "0" should cause initrd relocation to obey BOOTMAPSZ -- but at least in my experiments it does not seem to do so.

boot_ramdisk_high() doesn't seem to make any reference to bootm_{low,size,etc} like I would expect and with initrd_high==0 it calls lmb_alloc which allocates anywhere. This is in contrast with boot_relocate_fdt which uses getenv_bootm_mapsize() and getenv_bootm_low().

Quoted 5 lines
Quoted 2 lines

It looks to me like the initrd reloc logic is wrong -- but it's been that way for such a long time I think I must be mistaken.

I think after reading what you're saying, things are very unclear, unfortunately.

I'm glad it's not just me!

Quoted 4 lines

What you can do, but is very odd after thinking about it
is if you set bootm_low only and not any of the size things, it works as a constraint on the upper bounds so initrd nor fdt are put above that. But that's really seeming like a side effect rather than an intent.

Right, I don't think I want to add any weirdness, unless all the cool kids are going to be doing it of course ;-)

Quoted 6 lines
Quoted 1 line

I'm going to whack at this more..

Thanks. I think for now with this series I can just set BOOTMAPSZ to 256MB without making this problem any better or worse and we can fixup things later in whatever is determined to be the right solution. Is that OK with you?

Yes, you can do that for now and I'll bounce ideas off you in v2 of the TI series at least..

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140317/420930fc/attachment.pgp>
#37 lore raw

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

In reply to Ian Campbell
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Tom Rini
Quoted 18 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 8 lines
Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

And I've not made things clearer with a mis-recollection of things. I don't know why I keep saying "bootm_low" when I mean "bootm_size" like I've done in later patches (and thankfully, when poking people on G+).

There's three ways to say "Please ensure that the FDT and if passed initrd do not relocate above a certain location".
1) In the environment, set bootm_size to kernel lowmem. This means that boot_start_lmb restricts the pool used by both fdt and initrd to that value at the top.
2) In the environment, set fdt_high (and if using initrd, initrd_high) to the top of lowmem. This means that we'll make sure they don't get relocated above that value.
3) In the environment set initrd_high to top of lowmem and set bootm_mapsize to lowmem.

In all of the above, lowmem can be replaced with any valid size that's also smaller than lowmem, such as 256MB. Another option, in the environment, is to set initrd_high and fdt_high to 0xffffffff and then relocation is disabled. I would _not_ recommend this in the general case as one of the points of relocation is to ensure we don't get overwritten by the kernel BSS.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140317/9f81a1ff/attachment.pgp>
#38 lore raw

[U-Boot] [linux-sunxi] Re: [PATCH v1 8/9] sunxi: non-FEL SPL boot support for sun7i

Quoted 46 lines · Tom Rini
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Tom Rini
Quoted 18 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

include/configs/sunxi-common.h line 103

Quoted 3 lines
include/configs/sunxi-common.h +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 8 lines
Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

And I've not made things clearer with a mis-recollection of things. I don't know why I keep saying "bootm_low" when I mean "bootm_size" like I've done in later patches (and thankfully, when poking people on G+).

There's three ways to say "Please ensure that the FDT and if passed initrd do not relocate above a certain location".
1) In the environment, set bootm_size to kernel lowmem. This means that boot_start_lmb restricts the pool used by both fdt and initrd to that value at the top.
2) In the environment, set fdt_high (and if using initrd, initrd_high) to the top of lowmem. This means that we'll make sure they don't get relocated above that value.
3) In the environment set initrd_high to top of lowmem and set bootm_mapsize to lowmem.

Quoted 6 lines

In all of the above, lowmem can be replaced with any valid size that's also smaller than lowmem, such as 256MB. Another option, in the environment, is to set initrd_high and fdt_high to 0xffffffff and then relocation is disabled. I would _not_ recommend this in the general case as one of the points of relocation is to ensure we don't get overwritten by the kernel BSS.

IIRC, we added it not to make sure that it was in lowmem, but because we had issues with large enough kernels (multi_v7_defconfig + embedded initramfs) that would overwrite the relocated DTB whenever it was decompressing itself.

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

[U-Boot] [linux-sunxi] Re: [PATCH v1 8/9] sunxi: non-FEL SPL boot support for sun7i

Quoted 54 lines · Maxime Ripard
Quoted 46 lines · Tom Rini
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Tom Rini
Quoted 18 lines · Hans de Goede

Hi,

Quoted 11 lines · Tom Rini
Quoted 2 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

[snip]

Review

Quoted 3 lines
(quoted diff) +3 -0
+/* Flat Device Tree (FDT/DT) support */
+#define CONFIG_OF_LIBFDT
+#define CONFIG_SYS_BOOTMAPSZ		(16 << 20)

This seems pretty small. This is to keep things from being relocated into highmem right?

Hmm, this reminds me that we currently need to do a "env set fdt_high ffffffff" in our boot scripts to get ftd to work at all. Would be nice to fix this for upstream. I'm afraid I'm clueless as to why we (sunxi) need it, but we do.

Quoted 8 lines
Quoted 6 lines

You want to be setting bootm_low (even for bootz, it's about the underlying boot mechanics that bootz and bootelf and ... hook into) to the amount of lowmem the kernel will have. We do this because we do want to make sure that the device tree isn't overwritten by the kernel BSS or similar. Everyone with more DDR than kernel lowmem needs to be doing something along these lines.

So, I'm confused about what to do here ;-)

And I've not made things clearer with a mis-recollection of things. I don't know why I keep saying "bootm_low" when I mean "bootm_size" like I've done in later patches (and thankfully, when poking people on G+).

There's three ways to say "Please ensure that the FDT and if passed initrd do not relocate above a certain location".
1) In the environment, set bootm_size to kernel lowmem. This means that boot_start_lmb restricts the pool used by both fdt and initrd to that value at the top.
2) In the environment, set fdt_high (and if using initrd, initrd_high) to the top of lowmem. This means that we'll make sure they don't get relocated above that value.
3) In the environment set initrd_high to top of lowmem and set bootm_mapsize to lowmem.

Quoted 6 lines

In all of the above, lowmem can be replaced with any valid size that's also smaller than lowmem, such as 256MB. Another option, in the environment, is to set initrd_high and fdt_high to 0xffffffff and then relocation is disabled. I would _not_ recommend this in the general case as one of the points of relocation is to ensure we don't get overwritten by the kernel BSS.

Quoted 4 lines

IIRC, we added it not to make sure that it was in lowmem, but because we had issues with large enough kernels (multi_v7_defconfig + embedded initramfs) that would overwrite the relocated DTB whenever it was decompressing itself.

Right. The series of problems often goes:
1) Oops, DTB moved into high mem, set fdt_high 0xffffffff to stop that
2) Oops, DTB overwritten by kernel, change fdt load addr.

Which is why relocation is a good thing (at least on the device tree which tends to be small enough to not be a noticable thing) in the default case.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140321/dcddf5d4/attachment.pgp>
#40 lore raw

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

In reply to Tom Rini
Quoted 5 lines · Tom Rini
Quoted 1 line

So, I'm confused about what to do here ;-)

And I've not made things clearer with a mis-recollection of things. I don't know why I keep saying "bootm_low" when I mean "bootm_size" like I've done in later patches (and thankfully, when poking people on G+).

Ah, making that substitution makes things make a lot more sense!

Quoted 10 lines

There's three ways to say "Please ensure that the FDT and if passed initrd do not relocate above a certain location".
1) In the environment, set bootm_size to kernel lowmem. This means that boot_start_lmb restricts the pool used by both fdt and initrd to that value at the top.
2) In the environment, set fdt_high (and if using initrd, initrd_high) to the top of lowmem. This means that we'll make sure they don't get relocated above that value.
3) In the environment set initrd_high to top of lowmem and set bootm_mapsize to lowmem.

Looking at http://patchwork.ozlabs.org/patch/329210/ it seems that you went for #1 on TI stuff -- so I am going to follow suite.

Quoted 2 lines

In all of the above, lowmem can be replaced with any valid size that's also smaller than lowmem, such as 256MB.

256MB sounds like a good value to be starting with.

Quoted 5 lines

Another option, in the
environment, is to set initrd_high and fdt_high to 0xffffffff and then relocation is disabled. I would _not_ recommend this in the general case as one of the points of relocation is to ensure we don't get overwritten by the kernel BSS.

Sure.

Thanks,
Ian.

#41 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

In reply to Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/board.c | 15 +++++++++
 boards.cfg                       |  4 +--
 drivers/net/Makefile             |  1 +
 drivers/net/sunxi_gmac.c         | 34 ++++++++++++++++++++
 include/configs/sunxi-common.h   | 68 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/sunxi_gmac.c
arch/arm/cpu/armv7/sunxi/board.c +15 -0
index 98cad43..73b4cf0 100644
@@ -27,6 +27,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
 #include <serial.h>
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>
@@ -102,3 +104,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 +2 -2
index a513376..090e956 100644
@@ -353,8 +353,8 @@ Active  arm         armv7          rmobile     renesas         koelsch
 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                                                                                                              -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL                                                                                                          -
+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                           -                                                                                                                                 -
 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..432d7b2
@@ -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, 5);
+		sunxi_gpio_set_drv(pin, 3);
+	}
+
+	designware_initialize(0, SUNXI_GMAC_BASE, 0x1, PHY_INTERFACE_MODE_RGMII);
+
+	return 0;
+}
include/configs/sunxi-common.h +68 -0

74 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#42 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

Quoted 14 lines · Ian Campbell

Based linux-sunxi#sunxi commit d854c4de2f57 "arm: Handle .gnu.hash section in ldscripts" vs v2014.01.

---
 arch/arm/cpu/armv7/sunxi/board.c | 15 +++++++++
 boards.cfg                       |  4 +--
 drivers/net/Makefile             |  1 +
 drivers/net/sunxi_gmac.c         | 34 ++++++++++++++++++++
 include/configs/sunxi-common.h   | 68 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/sunxi_gmac.c

[..]

Quoted 27 lines
drivers/net/sunxi_gmac.c new file +21 -0
new file mode 100644
index 0000000..432d7b2
@@ -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);
+

drivers/net/sunxi_gmac.c line 31

Quoted 10 lines
drivers/net/sunxi_gmac.c new file +10 -0
+       /* 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, 5);
+               sunxi_gpio_set_drv(pin, 3);
+       }
+
+       designware_initialize(0, SUNXI_GMAC_BASE, 0x1, PHY_INTERFACE_MODE_RGMII);

Hi,

Thanks for working on this!

I see you left out all the CONFIG_RGMII ifdefs from this file. Not sure if it's because you're aiming to support only the Cubietruck first. I think you should keep them in the same patch. You can then just add the appropriate config options when support of other A20 boards roll in.

There are 3 changes to the designware driver since u-boot-sunxi's last merge (2014.1-rc1):

50b0df8 net/designware: make driver compatible with data cache 92a190a net/designware - switch driver to phylib usage 74cb708 net/designware: add explicit reset of {tx|rx}_currdescnum

The move to phylib will likely break the current code. Maybe we could merge 2014.4-rc1 in to fix it first.

Also, GMAC support depends on

5a51af3 net/designware: Reduce DMA burst length

by Jens Kuske (jemk). Neither of us bothered to send this upstream yet.

Cheers
ChenYu

Quoted 3 lines
drivers/net/sunxi_gmac.c new file +3 -0
+
+       return 0;
+}

[..]

#43 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

Quoted 1 line · Chen-Yu Tsai

Thanks for working on this!

No problem.

Quoted 3 lines

I see you left out all the CONFIG_RGMII ifdefs from this file. Not sure if it's because you're aiming to support only the Cubietruck first.

Yes, exactly.

Quoted 3 lines

I think you should keep them in the same patch. You can then just add the appropriate config options when support of other A20 boards roll in.

I don't have any boards which require this, so I cannot test it. I'd prefer to leave it to whoever adds support for the first such board to put this stuff back in, it's a pretty trivial git diff invocation to spot the needed bits.

Quoted 9 lines

There are 3 changes to the designware driver since u-boot-sunxi's last merge (2014.1-rc1):

50b0df8 net/designware: make driver compatible with data cache 92a190a net/designware - switch driver to phylib usage 74cb708 net/designware: add explicit reset of {tx|rx}_currdescnum

The move to phylib will likely break the current code. Maybe we could merge 2014.4-rc1 in to fix it first.

I'm happy to track any merges updates etc, sounds like at least this patch will need some rebasing. Since this one is last I think it needn't stop the rest going in (although I anticipate at least some review and rebasing for all of it).

Quoted 5 lines

Also, GMAC support depends on

5a51af3 net/designware: Reduce DMA burst length

by Jens Kuske (jemk). Neither of us bothered to send this upstream yet.

I think I saw that in the sunxi tree but since it touched core code I punted on it for now since I wasn't sure how to reconcile it with non-sunxi platforms (i.e. what is the downside for other boards? Worse performance?)

Thanks for your feedback.

Ian.

#44 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

Quoted 1 line · Ian Campbell

On Fri, 2014-03-14 at 19:11 +0800, Chen-Yu Tsai wrote:

[snip]

Quoted 8 lines
Quoted 3 lines

I think you should keep them in the same patch. You can then just add the appropriate config options when support of other A20 boards roll in.

I don't have any boards which require this, so I cannot test it. I'd prefer to leave it to whoever adds support for the first such board to put this stuff back in, it's a pretty trivial git diff invocation to spot the needed bits.

I agree with this as well.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/b230c310/attachment.pgp>
#45 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

Quoted 7 lines · Tom Rini
Quoted 1 line · Ian Campbell

On Fri, 2014-03-14 at 19:11 +0800, Chen-Yu Tsai wrote:

[snip]

Quoted 4 lines
Quoted 3 lines

I think you should keep them in the same patch. You can then just add the appropriate config options when support of other A20 boards roll in.

Quoted 6 lines
Quoted 4 lines

I don't have any boards which require this, so I cannot test it. I'd prefer to leave it to whoever adds support for the first such board to put this stuff back in, it's a pretty trivial git diff invocation to spot the needed bits.

I agree with this as well.

With the request to add RGMII here or my reasons for not doing so? (sorry if I'm being dense)

Ian.

#46 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

Quoted 13 lines · Ian Campbell
Quoted 12 lines · Tom Rini
Quoted 1 line · Ian Campbell

On Fri, 2014-03-14 at 19:11 +0800, Chen-Yu Tsai wrote:

[snip]

Quoted 8 lines
Quoted 3 lines

I think you should keep them in the same patch. You can then just add the appropriate config options when support of other A20 boards roll in.

I don't have any boards which require this, so I cannot test it. I'd prefer to leave it to whoever adds support for the first such board to put this stuff back in, it's a pretty trivial git diff invocation to spot the needed bits.

Quoted 4 lines
Quoted 1 line

I agree with this as well.

With the request to add RGMII here or my reasons for not doing so? (sorry if I'm being dense)

Sorry, I agree with your reason for not doing so. Lets just add in what we can test within the series and let the board(s) that needs it, add it.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140317/04f731ba/attachment.pgp>
#47 lore raw

PATCH 9/9 sunxi: add gmac Ethernet support

In reply to Ian Campbell

On Fri, Mar 14, 2014 at 10:33:51AM +0000, Ian Campbell wrote:

[snip]

include/configs/sunxi-common.h line 207

Quoted 5 lines
include/configs/sunxi-common.h +5 -0
+#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_SYS_DCACHE_OFF		/* dw driver doesn't support dcache */

I think that was fixed recently..

Quoted 15 lines
include/configs/sunxi-common.h +15 -0
+
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_SNTP
+#define CONFIG_TIMESTAMP		/* Needed by SNTP */
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_SUBNETMASK
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+#define CONFIG_BOOTP_NISDOMAIN
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_BOOTFILESIZE

include/configs/sunxi-common.h line 236

Quoted 10 lines
include/configs/sunxi-common.h +10 -0
+#define CONFIG_BOOTP_DNS
+#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
+#define CONFIG_CMD_ELF
+#endif

We end up duplicating this in the next part of the hunk.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/833e4582/attachment.pgp>
#48 lore raw

cover sunxi: initial upstreamining effort

In reply to Ian Campbell
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

First of all, yay. Second, how hard would it be to add sun5i / a13-olinuxino-micro support on top of this? I ask since I've got one of those sitting around here. Would we be talking just board level things or is sun5i vs sun7i a big deal? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/45620b95/attachment.pgp>
#49 lore raw

cover sunxi: initial upstreamining effort

Quoted 12 lines · Tom Rini
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 5 lines

First of all, yay. Second, how hard would it be to add sun5i / a13-olinuxino-micro support on top of this? I ask since I've got one of those sitting around here. Would we be talking just board level things or is sun5i vs sun7i a big deal? Thanks!

I think it would be pretty small, if you fetch my tree and git diff it against the sunxi.git tree the diff bits with sun5i in them stand out reasonably clearly.

I don't have such a platform myself though which is why I've not just done it.

Ian.

#50 lore raw

cover sunxi: initial upstreamining effort

Quoted 18 lines · Ian Campbell
Quoted 12 lines · Tom Rini
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 4 lines

First of all, yay. Second, how hard would it be to add sun5i / a13-olinuxino-micro support on top of this? I ask since I've got one of those sitting around here. Would we be talking just board level things or is sun5i vs sun7i a big deal? Thanks!

Quoted 6 lines

I think it would be pretty small, if you fetch my tree and git diff it against the sunxi.git tree the diff bits with sun5i in them stand out reasonably clearly.

I don't have such a platform myself though which is why I've not just done it.

OK good, I think Albert and I might end up starting the sun4i/sun5i stuff as those are the boards we've got sitting around.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/1bb0f398/attachment.pgp>
#51 lore raw

cover sunxi: initial upstreamining effort

Hi Tom,

Quoted 2 lines · Tom Rini

OK good, I think Albert and I might end up starting the sun4i/sun5i stuff as those are the boards we've got sitting around.

As I have a Mele A1000G (A31), that would be sun6i, not sun4i/sun5i -- and yes, I would like to contribute support for it.

Amicalement,

Signature · 1 line
Albert.
#52 lore raw

cover sunxi: initial upstreamining effort

Hi,

First of all: Ian: Many many thanks for working on this, you rock!

Quoted 8 lines · Albert ARIBAUD

Hi Tom,

Quoted 2 lines · Tom Rini

OK good, I think Albert and I might end up starting the sun4i/sun5i stuff as those are the boards we've got sitting around.

As I have a Mele A1000G (A31), that would be sun6i, not sun4i/sun5i

So I'm very interested in getting sunxi support in upstream u-boot too, and I've a ton of sunxi devices. I'll start working on doing a sun4i patch-set on top of Ian's sun7i patch-set. Then Tom can start working on sun5i.

Tom, since I've started working on sunxi stuff 2 years ago I've gained a lot of experience with these little SoCs so let me know if you hit some roadblock and I can take a look.

Disclaimer I'm more of a kernel / device driver guy, all the low-level RAM init (and having to think about where in memory to put all the bits) is mostly new, so have some patience with me please :)

Quoted 1 line

and yes, I would like to contribute support for it.

If someone can start working on sun6i support that would be awesome.

My sunxi-next u-boot branch:
https://github.com/jwrdegoede/u-boot-sunxi/commits/sunxi-next

Has some minimal patches by Maxime to get u-boot to run as a secondary boot-loader, using allwinner's boot0 and boot1 as primary loader.

What we really want is to get a working SPL for sun6i, there are 2 ways to get to a working SPL:

1) Use allwinners special USB boot mode called FEL, this way no MMC / NAND reading code is necessary.
2) First get MMC to work using uboot as a secondary loader only, and once we've working MMC code try to get a SPL which can read the real u-boot directly from MMC.

And then for 2, there is the option to first get MMC for sun6i working in the upstream Linux kernel, so that we know exactly what changes are needed compared to sun5i / sun7i MMC (which are identical).

I've done a lot of work on the upstream kernel mmc host driver, and I actually wanted to start looking into MMC for sun6i in the upstream kernel one of these days. But now that Ian has published his awesome work to get sunxi support upstream, my first priority is to get sun4i + sun5i support added on top of Ian's patches.

Regards,

Hans

#53 lore raw

cover sunxi: initial upstreamining effort

Hi,

<snip>

Quoted 3 lines
Quoted 1 line

and yes, I would like to contribute support for it.

If someone can start working on sun6i support that would be awesome.

p.s. One thing I forgot about sun6i / A31 support Oliver Schinagl has some preliminary u-boot patches for it here:
https://github.com/oliv3r/u-boot-sunxi/commits/wip/a31

AFAIK these are based on various allwinner source dumps, and are untested as Oliver does not have an A31 device.

Regards,

Hans

#54 lore raw

cover sunxi: initial upstreamining effort

In reply to Ian Campbell

Hi Ian,

Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

I am not familiar with all of AllWinner's CPUs, so please forgive me if I'm saying something stupid. Does sun7i support mean that A31 might be supported as well? From what I understand, UART and Eth should be somewhat common between A20 and A31, but MMC won't.

In any case, I am willing to try and add Mele A1000G U-Boot support based on your series if that makes any sense. :)

Amicalement,

Signature · 1 line
Albert.
#55 lore raw

cover sunxi: initial upstreamining effort

Hi Albert,

Quoted 15 lines · Albert ARIBAUD

Hi Ian,

Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 7 lines

I am not familiar with all of AllWinner's CPUs, so please forgive me if I'm saying something stupid. Does sun7i support mean that A31 might be supported as well? From what I understand, UART and Eth should be somewhat common between A20 and A31, but MMC won't.

In any case, I am willing to try and add Mele A1000G U-Boot support based on your series if that makes any sense. :)

Actually, between A20 and A31, a lot are common, but some IPs that are of particular interest to u-boot aren't.

Most notably, the A20 and A31 share the same CPUs, interrupt controller (GIC), timers (that are also shared with all the other Allwinner SoCs), UART (designware's), ethernet (designware's GMAC IP). MMC should be common too.

However, the A31 introduces a new RAM controller, a new DMA controller, a new bus to interact with the PMIC, most notably.

So while we will be able to reuse some of that code, the A31 needs a significant additional effort. The good news is that the newer Allwinner SoCs seem to drop the old (and by old I mean A10/A10s/A13/A20) IPs in favour of the one introduced in the A31. So it's definitely worth doing this effort.

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

cover sunxi: initial upstreamining effort

In reply to Albert ARIBAUD
Quoted 15 lines · Albert ARIBAUD

Hi Ian,

Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 2 lines

I am not familiar with all of AllWinner's CPUs, so please forgive me if I'm saying something stupid.

I probably should have included some context here anyway, since I guess a lot of folks aren't familiar with Allwinner/sunxi.

Quoted 2 lines

Does sun7i support mean that A31 might be
supported as well?

sun7i == A20 processors while A31 is sun6i (yes, this seems somewhat backwards to me as well), so there is no A31 support present in this series. As Maxime says sun6i shares some but not all stuff with sun7i and the bits which aren't still require work (which I believe people are doing).

Ian.

Quoted 7 lines

From what I understand, UART and Eth should be
somewhat common between A20 and A31, but MMC won't.

In any case, I am willing to try and add Mele A1000G U-Boot support based on your series if that makes any sense. :)

Amicalement,

#57 lore raw

cover sunxi: initial upstreamining effort

In reply to Ian Campbell
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Some global comments:
- If you haven't already, make sure it's all checkpatch clean.
- Use the SPDX tags rather than including the GPL boilerplate.
- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.
- Magic numbers need to be defined.

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/fa2fc396/attachment.pgp>
#58 lore raw

cover sunxi: initial upstreamining effort

Quoted 12 lines · Tom Rini
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 2 lines

Some global comments:
- If you haven't already, make sure it's all checkpatch clean.

I hadn't realised u-boot had a checkpatch. I shall do this.

Quoted 1 line

- Use the SPDX tags rather than including the GPL boilerplate.

Agreed, I already sent out a patch to sunxi.git to make this happen there so I could sync it to this tree (so sunxi guys consider this a ping on <[email protected]> ;-))

I suppose I don't need to wait, but it was convenient to have a diff which always shrank...

Quoted 2 lines

- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.

OK, that was mostly for my own reference. Mind if I put it at the end after "---" so git am will strip it?

Quoted 1 line

- Magic numbers need to be defined.

Will do.

Thanks,
Ian.

#59 lore raw

cover sunxi: initial upstreamining effort

Quoted 14 lines · Ian Campbell
Quoted 13 lines · Tom Rini
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Some global comments:

[snip]

Quoted 5 lines
Quoted 2 lines

- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.

OK, that was mostly for my own reference. Mind if I put it at the end after "---" so git am will strip it?

Yeah, that's a good idea.

Quoted 3 lines
Quoted 1 line

- Magic numbers need to be defined.

Will do.

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140314/ca3755ca/attachment.pgp>
#60 lore raw

cover sunxi: initial upstreamining effort

In reply to Tom Rini
Quoted 12 lines · On Fri, 14 Mar 2014 10:16:42 -0400 Tom Rini <[email protected]> wrote:
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 6 lines

Some global comments:
- If you haven't already, make sure it's all checkpatch clean.
- Use the SPDX tags rather than including the GPL boilerplate.
- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.
- Magic numbers need to be defined.

I have a quick request also, Please incorporate the ongoing generic distro work as most if not all of the sunxi systems I know of are targets for generic distros.

Dennis

#61 lore raw

cover sunxi: initial upstreamining effort

Hi Dennis,

Quoted 22 lines · Dennis Gilmore
Quoted 12 lines · On Fri, 14 Mar 2014 10:16:42 -0400 Tom Rini <[email protected]> wrote:
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 6 lines

Some global comments:
- If you haven't already, make sure it's all checkpatch clean.
- Use the SPDX tags rather than including the GPL boilerplate.
- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.
- Magic numbers need to be defined.

Quoted 3 lines

I have a quick request also, Please incorporate the ongoing generic distro work as most if not all of the sunxi systems I know of are targets for generic distros.

No worries, I'll be following this closely (and contributing to it) and I'll make sure this gets added. Do you've some pointers for docs about this, or example patches for other boards ?

Regards,

Hans

#62 lore raw

cover sunxi: initial upstreamining effort

In reply to Dennis Gilmore
Quoted 22 lines · Dennis Gilmore
Quoted 12 lines · On Fri, 14 Mar 2014 10:16:42 -0400 Tom Rini <[email protected]> wrote:
Quoted 9 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 6 lines

Some global comments:
- If you haven't already, make sure it's all checkpatch clean.
- Use the SPDX tags rather than including the GPL boilerplate.
- Please re-word the commit messages. The "how we got here / where this is from" is fine for the cover letter.
- Magic numbers need to be defined.

Quoted 3 lines

I have a quick request also, Please incorporate the ongoing generic distro work as most if not all of the sunxi systems I know of are targets for generic distros.

This: http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/180540 ?

Sure.

Ian.

#63 lore raw

cover sunxi: initial upstreamining effort

In reply to Ian Campbell
Quoted 10 lines · Ian Campbell

Hi,

This is my first 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 and the cubietruck board. Supported peripherals are UART, MMC and Ethernet.

Quoted 6 lines

The code here is from sunxi.git#sunxi[0] changeset d854c4de2f57 "arm:
Handle .gnu.hash section in ldscripts" and applied to u-boot v2014.01.

This series can also be found at:

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

Nice, finally!

Best regards,
Marek Vasut