Skip to contentSkip to conversation

mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

PATCH New Simon Horman 4 participants 8 messages Jan 9, 2011 – Jan 10, 2011

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

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

[ Reposted with correct addresses for arm and Paul ]

This allows a ROM-able zImage to be written to MMC and for SuperH Mobile ARM to boot directly from the MMCIF hardware block.

This is achieved by the MaskROM loading the first portion of the image into MERAM and then jumping to it. This portion contains loader code which copies the entire image to SDRAM and jumps to it. From there the zImage boot code proceeds as normal, uncompressing the image into its final location and then jumping to it.

This patch depends on:
* "ARM: 6514/1: mach-shmobile: Add zboot support for SuperH Mobile ARM" which has been merged into the devel branch of Russell King's linux-2.6-arm tree.
* "mmc, sh: Move MMCIF_PROGRESS_* into sh_mmcif.h"
which has been merged into the common/mmcif branch of
Paul Mundt's sh-2.6 tree
* "mmc, sh: Remove sh_mmcif_boot_slurp()"
which has been merged into the common/mmcif branch of
Paul Mundt's sh-2.6 tree

v2:
Addressed comments by Magnus Damm
* Fix copyright in vrl4.c
* Fix use of #define CONFIG_ZBOOT_ROM_MMCIF in mmcif-sh7372.c
* Initialise LED GPIO lines in head-ap4evb.txt instead of mmcif-sh7372.c as this is considered board-specific.

v3:
Addressed comments made in person by Magnus Damm
* Move mmcif_loader to be earlier in the image and
reduce the number of blocks of boot program loaded by the MaskRom from 40 to 8 accordingly.
* Move LED GPIO initialisation into mmcif_progress_init
- This leaves the partner jet script unbloated
Other
* inline mmcif_update_progress so it is a static inline in a header file

v4
* Use htole16() and htole32() in v4rl.c to ensure
that the output is little endian

---
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 +++++++++++++++++++++
 Documentation/arm/SH-Mobile/zboot-rom-mmcif.txt   |   29 ++++
 arch/arm/Kconfig                                  |   12 ++
 arch/arm/boot/compressed/Makefile                 |   13 ++-
 arch/arm/boot/compressed/head-shmobile.S          |   31 ++++
 arch/arm/boot/compressed/mmcif-sh7372.c           |   87 +++++++++++
 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h |   29 ++++
 arch/arm/mach-shmobile/include/mach/mmcif.h       |   16 ++
 9 files changed, 393 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/arm/SH-Mobile/Makefile
 create mode 100644 Documentation/arm/SH-Mobile/vrl4.c
 create mode 100644 Documentation/arm/SH-Mobile/zboot-rom-mmcif.txt
 create mode 100644 arch/arm/boot/compressed/mmcif-sh7372.c
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmcif.h
Documentation/arm/SH-Mobile/Makefile new file +8 -0
new file mode 100644
index 0000000..8771d83
@@ -0,0 +1,8 @@
+BIN := vrl4
+
+.PHONY: all
+all: $(BIN)
+
+.PHONY: clean
+clean:
+	rm -f *.o $(BIN)
Documentation/arm/SH-Mobile/vrl4.c new file +169 -0

169 lines not on this page · raw message

Documentation/arm/SH-Mobile/zboot-rom-mmcif.txt new file +29 -0
new file mode 100644
index 0000000..efff8ae
@@ -0,0 +1,29 @@
+ROM-able zImage boot from MMC
+-----------------------------
+
+An ROM-able zImage compiled with ZBOOT_ROM_MMCIF may be written to MMC and
+SuperH Mobile ARM will to boot directly from the MMCIF hardware block.
+
+This is achieved by the mask ROM loading the first portion of the image into
+MERAM and then jumping to it. This portion contains loader code which
+copies the entire image to SDRAM and jumps to it. From there the zImage
+boot code proceeds as normal, uncompressing the image into its final
+location and then jumping to it.
+
+This code has been tested on an AP4EB board using the developer 1A eMMC
+boot mode which is configured using the following jumper settings.
+The board used for testing required a patched mask ROM in order for
+this mode to function.
+
+   8 7 6 5 4 3 2 1
+   x|x|x|x|x| |x|
+S4 -+-+-+-+-+-+-+-
+    | | | | |x| |x on
+
+The zImage must be written to the MMC card@sector 1 (512 bytes) in
+vrl4 format. A utility vrl4 is supplied to accomplish this.
+
+e.g.
+	vrl4 < zImage | dd of=/dev/sdX bs=512 seek=1
+
+A dual-voltage MMC 4.0 card was used for testing.
arch/arm/Kconfig +12 -0
index 81c71da..899c77c 100644
@@ -1582,6 +1582,18 @@ config ZBOOT_ROM
 	  Say Y here if you intend to execute your compressed kernel image
 	  (zImage) directly from ROM or flash.  If unsure, say N.
 
+config ZBOOT_ROM_MMCIF
+	bool "Include MMCIF loader in zImage (EXPERIMENTAL)"
+	depends on ZBOOT_ROM && ARCH_SH7372 && EXPERIMENTAL
+	help
+	  Say Y here to include experimental MMCIF loading code in the
+	  ROM-able zImage. With this enabled it is possible to write the
+	  the ROM-able zImage kernel image to an MMC card and boot the
+	  kernel straight from the reset vector. At reset the processor
+	  Mask ROM will load the first part of the the ROM-able zImage
+	  which in turn loads the rest the kernel image to RAM using the
+	  MMCIF hardware block.
+
 config CMDLINE
 	string "Default kernel command string"
 	default ""
arch/arm/boot/compressed/Makefile +12 -1
index 0a8f748..198007d 100644
@@ -4,9 +4,20 @@
 # create a compressed vmlinuz image from the original vmlinux
 #
 
+OBJS		=
+
+# Ensure that mmcif loader code appears early in the image
+# to minimise that number of bocks that have to be read in
+# order to load it.
+ifeq ($(CONFIG_ZBOOT_ROM_MMCIF),y)
+ifeq ($(CONFIG_ARCH_SH7372),y)
+OBJS		+= mmcif-sh7372.o
+endif
+endif
+
 AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
 HEAD	= head.o
-OBJS	= misc.o decompress.o
+OBJS	+= misc.o decompress.o
 FONTC	= $(srctree)/drivers/video/console/font_acorn_8x8.c
 
 #
arch/arm/boot/compressed/head-shmobile.S +31 -0
index 30973b7..de83c5a 100644
@@ -25,6 +25,37 @@
 	/* load board-specific initialization code */
 #include <mach/zboot.h>
 
+#ifdef CONFIG_ZBOOT_ROM_MMCIF
+	/* Load image from MMC */
+	adr	sp, __tmp_stack
+	add	sp, sp, #128
+	ldr	r0, __image_start
+	ldr	r1, __image_end
+	subs	r1, r1, r0
+	ldr	r0, __load_base
+	mov	lr, pc
+	b	mmcif_loader
+
+	/* Jump to loaded code */
+	ldr	r0, __loaded
+	ldr	r1, __image_start
+	sub	r0, r0, r1
+	ldr	r1, __load_base
+	add	pc, r0, r1
+
+__image_start:
+	.long	_start
+__image_end:
+	.long	_got_end
+__load_base:
+	.long	CONFIG_MEMORY_START + 0x02000000 @ Load at 32Mb into SDRAM
+__loaded:
+	.long	__loaded
+	.align
+__tmp_stack:
+	.space	128
+#endif /* CONFIG_ZBOOT_ROM_MMCIF */
+
 	b	1f
 __atags:@ tag #1
 	.long	12			@ tag->hdr.size = tag_size(tag_core);
arch/arm/boot/compressed/mmcif-sh7372.c new file +87 -0

87 lines not on this page · raw message

arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h new file +29 -0
new file mode 100644
index 0000000..c6b10ee
@@ -0,0 +1,29 @@
+#ifndef MMCIF_AP4EB_H
+#define MMCIF_AP4EB_H
+
+#define PORT185CR      0xe60520b9
+#define PORT186CR      0xe60520ba
+#define PORT187CR      0xe60520bb
+#define PORT188CR      0xe60520bc
+
+#define PORTR191_160DR 0xe6056014
+
+static inline void mmcif_init_progress(void)
+{
+       /* Initialise LEDS1-4
+        * registers: PORT185CR-PORT188CR (LED1-LED4 Control)
+        * value:     0x10 - enable output
+        */
+       __raw_writeb(0x10, PORT185CR);
+       __raw_writeb(0x10, PORT186CR);
+       __raw_writeb(0x10, PORT187CR);
+       __raw_writeb(0x10, PORT188CR);
+}
+
+static inline void mmcif_update_progress(int n)
+{
+	__raw_writel((__raw_readl(PORTR191_160DR) & ~(0xf << 25)) |
+		     (1 << (25 + n)), PORTR191_160DR);
+}
+
+#endif /* MMCIF_AP4EB_H */
arch/arm/mach-shmobile/include/mach/mmcif.h new file +16 -0
new file mode 100644
index 0000000..0812f1e
@@ -0,0 +1,16 @@
+#ifndef MMCIF_H
+#define MMCIF_H
+
+/**************************************************
+ *
+ *		board specific settings
+ *
+ **************************************************/
+
+#ifdef CONFIG_MACH_AP4EVB
+#include "mach/mmcif-ap4eb.h"
+#else
+#error "unsupported board."
+#endif
+
+#endif /* MMCIF_H */
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Hi,

Quoted 2 lines
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 +++++++++++++++++++++

How about putting those two into "tools" (in particular "tools/arm") instead of "Documentation"?

Just a thought... ;-)

Cheers!

Pawe?

#2 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Quoted 9 lines · Pawe? Moll

Hi,

Quoted 2 lines
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 +++++++++++++++++++++

How about putting those two into "tools" (in particular "tools/arm") instead of "Documentation"?

Just a thought... ;-)

Thats fine by me except that tools/arm doesn't exist yet. It would be good to get some consensus before creating it.

#3 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Quoted 9 lines · Simon Horman
Quoted 6 lines
Quoted 2 lines
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 

+++++++++++++++++++++
How about putting those two into "tools" (in particular "tools/arm") instead of "Documentation"?
Just a thought... ;-)

Thats fine by me except that tools/arm doesn't exist yet. It would be good to get some consensus before creating it.

I think there is consensus regarding "tools" as a place for user-space tools - eg. perf tools used to live in "Documentation/..." and then were moved to "tools/perf".

Now, whether your stuff should be in "tools/SH-Mobile" or "tools/arm/SH-Mobile", I have no opinion ;-)

Cheers!

Pawe?

#4 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Quoted 12 lines · Pawel Moll
Quoted 9 lines · Simon Horman
Quoted 6 lines
Quoted 2 lines
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 

+++++++++++++++++++++
How about putting those two into "tools" (in particular "tools/arm") instead of "Documentation"?
Just a thought... ;-)

Thats fine by me except that tools/arm doesn't exist yet. It would be good to get some consensus before creating it.

Quoted 7 lines

I think there is consensus regarding "tools" as a place for user-space tools - eg. perf tools used to live in "Documentation/..." and then were moved to "tools/perf".

Now, whether your stuff should be in "tools/SH-Mobile" or "tools/arm/SH-Mobile", I have no opinion ;-)

I agree that this is a worthwhile direction to move to, but we're a long way from a consensus. x86 has traditionally littered scripts/ and others have sunk to arch/<foo>/tools hostprogs abuse and so forth. perf is a bit of a special case in that it's fairly architecture agnostic.

#5 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Quoted 17 lines · Paul Mundt
Quoted 16 lines · Pawel Moll
Quoted 9 lines · Simon Horman
Quoted 6 lines
Quoted 2 lines
 Documentation/arm/SH-Mobile/Makefile              |    8 +
 Documentation/arm/SH-Mobile/vrl4.c                |  169 

+++++++++++++++++++++
How about putting those two into "tools" (in particular "tools/arm") instead of "Documentation"?
Just a thought... ;-)

Thats fine by me except that tools/arm doesn't exist yet. It would be good to get some consensus before creating it.

I think there is consensus regarding "tools" as a place for user-space tools - eg. perf tools used to live in "Documentation/..." and then were moved to "tools/perf".

Quoted 7 lines
Quoted 3 lines

Now, whether your stuff should be in "tools/SH-Mobile" or "tools/arm/SH-Mobile", I have no opinion ;-)

I agree that this is a worthwhile direction to move to, but we're a long way from a consensus. x86 has traditionally littered scripts/ and others have sunk to arch/<foo>/tools hostprogs abuse and so forth. perf is a bit of a special case in that it's fairly architecture agnostic.

I would prefer to leave the code in Documentation/arm/SH-Mobile/ as it complements the document that is in the same directory - weather its more code or documentation is debatable IMHO.

I'm happy to move things later if a consensus is reached.

#6 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

In reply to Simon Horman

arch/arm/boot/compressed/head-shmobile.S line 31

Quoted 12 lines · Simon Horman
arch/arm/boot/compressed/head-shmobile.S +4 -0
index 30973b7..de83c5a 100644
@@ -25,6 +25,37 @@
 	/* load board-specific initialization code */
 #include <mach/zboot.h>
 
+#ifdef CONFIG_ZBOOT_ROM_MMCIF
+	/* Load image from MMC */
+	adr	sp, __tmp_stack
+	add	sp, sp, #128

This can be replaced with:

	adr	sp, __tmp_stack + 128 ?

arch/arm/boot/compressed/head-shmobile.S line 37

Quoted 7 lines
arch/arm/boot/compressed/head-shmobile.S +6 -0
+	ldr	r0, __image_start
+	ldr	r1, __image_end
+	subs	r1, r1, r0
+	ldr	r0, __load_base
 
+	mov	lr, pc
+	b	mmcif_loader

No need for a separate mov instruction - this will do both in one go:
bl mmcif_loader

arch/arm/boot/compressed/head-shmobile.S line 44

Quoted 7 lines
arch/arm/boot/compressed/head-shmobile.S +7 -0
+
+	/* Jump to loaded code */
+	ldr	r0, __loaded
+	ldr	r1, __image_start
+	sub	r0, r0, r1
+	ldr	r1, __load_base
+	add	pc, r0, r1
	*__loaded - *__image_start + *__load_base

	&__loaded - &_start + CONFIG_MEMORY_START + 0x02000000

So this jumps to the '__loaded' label in the just loaded image - are you sure you want to jump to a location that contains an address rather than code? I think you want the two changes below to correct that.

arch/arm/boot/compressed/head-shmobile.S line 53

Quoted 9 lines
arch/arm/boot/compressed/head-shmobile.S +9 -0
+
+__image_start:
+	.long	_start
+__image_end:
+	.long	_got_end
+__load_base:
+	.long	CONFIG_MEMORY_START + 0x02000000 @ Load at 32Mb into SDRAM
+__loaded:
+	.long	__loaded

change to
.long __continue

arch/arm/boot/compressed/head-shmobile.S line 56

Quoted 3 lines
arch/arm/boot/compressed/head-shmobile.S +3 -0
+	.align
+__tmp_stack:
+	.space	128

add __continue

Quoted 29 lines
arch/arm/boot/compressed/head-shmobile.S +2 -0
+#endif /* CONFIG_ZBOOT_ROM_MMCIF */
+
 	b	1f
 __atags:@ tag #1
arch/arm/boot/compressed/head-shmobile.S +0 -0
 	.long	12			@ tag->hdr.size = tag_size(tag_core);
arch/arm/boot/compressed/mmcif-sh7372.c new file +18 -0
new file mode 100644
index 0000000..c54df5c
@@ -0,0 +1,87 @@
+/*
+ * sh7372 MMCIF loader
+ *
+ * Copyright (C) 2010 Magnus Damm
+ * Copyright (C) 2010 Simon Horman
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/mmc/sh_mmcif.h>
+#include <mach/mmcif.h>
+
+#define MMCIF_BASE      (void __iomem *)0xe6bd0000
+
+#define PORT84CR	0xe6050054
+#define PORT85CR	0xe6050055

arch/arm/boot/compressed/mmcif-sh7372.c line 28

Quoted 10 lines
arch/arm/boot/compressed/mmcif-sh7372.c new file +10 -0
+#define PORT86CR	0xe6050056
+#define PORT87CR	0xe6050057
+#define PORT88CR	0xe6050058
+#define PORT89CR	0xe6050059
+#define PORT90CR	0xe605005a
+#define PORT91CR	0xe605005b
+#define PORT92CR	0xe605005c
+#define PORT99CR	0xe6050063
+
+#define SMSTPCR3	0xe615013c

These should also be (void __iomem *).

Quoted 6 lines
arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h new file +0 -0
new file mode 100644
index 0000000..c6b10ee

arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h line 9

Quoted 9 lines
arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h new file +9 -0
@@ -0,0 +1,29 @@
+#ifndef MMCIF_AP4EB_H
+#define MMCIF_AP4EB_H
+
+#define PORT185CR      0xe60520b9
+#define PORT186CR      0xe60520ba
+#define PORT187CR      0xe60520bb
+#define PORT188CR      0xe60520bc
+
+#define PORTR191_160DR 0xe6056014

Ditto.

#7 lore raw

PATCH 1/1 mmc, ARM: Add zboot from MMC support for SuperH Mobile ARM

Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Simon Horman
arch/arm/boot/compressed/head-shmobile.S +0 -0
index 30973b7..de83c5a 100644
@@ -25,6 +25,37 @@
 	/* load board-specific initialization code */
 #include <mach/zboot.h>
 
Quoted 8 lines

arch/arm/boot/compressed/head-shmobile.S line 31

Quoted 4 lines
arch/arm/boot/compressed/head-shmobile.S +4 -0
+#ifdef CONFIG_ZBOOT_ROM_MMCIF
+	/* Load image from MMC */
+	adr	sp, __tmp_stack
+	add	sp, sp, #128

This can be replaced with:

	adr	sp, __tmp_stack + 128 ?

Thanks, changed.

Quoted 10 lines

arch/arm/boot/compressed/head-shmobile.S line 37

Quoted 7 lines
arch/arm/boot/compressed/head-shmobile.S +6 -0
+	ldr	r0, __image_start
+	ldr	r1, __image_end
+	subs	r1, r1, r0
+	ldr	r0, __load_base
 
+	mov	lr, pc
+	b	mmcif_loader

No need for a separate mov instruction - this will do both in one go:
bl mmcif_loader

Also changed.

Quoted 12 lines

arch/arm/boot/compressed/head-shmobile.S line 44

Quoted 7 lines
arch/arm/boot/compressed/head-shmobile.S +7 -0
+
+	/* Jump to loaded code */
+	ldr	r0, __loaded
+	ldr	r1, __image_start
+	sub	r0, r0, r1
+	ldr	r1, __load_base
+	add	pc, r0, r1
	*__loaded - *__image_start + *__load_base

	&__loaded - &_start + CONFIG_MEMORY_START + 0x02000000
Quoted 3 lines

So this jumps to the '__loaded' label in the just loaded image - are you sure you want to jump to a location that contains an address rather than code? I think you want the two changes below to correct that.

Thanks, I have verified that your change is correct.

Actually, I'm rather unsure how my (broken) code got this far. I suspect that I moved __tmp_stack late in the game and forgot to re-test the code. My bad.

Quoted 70 lines

arch/arm/boot/compressed/head-shmobile.S line 53

Quoted 9 lines
arch/arm/boot/compressed/head-shmobile.S +9 -0
+
+__image_start:
+	.long	_start
+__image_end:
+	.long	_got_end
+__load_base:
+	.long	CONFIG_MEMORY_START + 0x02000000 @ Load at 32Mb into SDRAM
+__loaded:
+	.long	__loaded

change to
.long __continue

arch/arm/boot/compressed/head-shmobile.S line 56

Quoted 3 lines
arch/arm/boot/compressed/head-shmobile.S +3 -0
+	.align
+__tmp_stack:
+	.space	128

add __continue

Quoted 29 lines
arch/arm/boot/compressed/head-shmobile.S +2 -0
+#endif /* CONFIG_ZBOOT_ROM_MMCIF */
+
 	b	1f
 __atags:@ tag #1
arch/arm/boot/compressed/head-shmobile.S +0 -0
 	.long	12			@ tag->hdr.size = tag_size(tag_core);
arch/arm/boot/compressed/mmcif-sh7372.c new file +18 -0
new file mode 100644
index 0000000..c54df5c
@@ -0,0 +1,87 @@
+/*
+ * sh7372 MMCIF loader
+ *
+ * Copyright (C) 2010 Magnus Damm
+ * Copyright (C) 2010 Simon Horman
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/mmc/sh_mmcif.h>
+#include <mach/mmcif.h>
+
+#define MMCIF_BASE      (void __iomem *)0xe6bd0000
+
+#define PORT84CR	0xe6050054
+#define PORT85CR	0xe6050055

arch/arm/boot/compressed/mmcif-sh7372.c line 28

Quoted 10 lines
arch/arm/boot/compressed/mmcif-sh7372.c new file +10 -0
+#define PORT86CR	0xe6050056
+#define PORT87CR	0xe6050057
+#define PORT88CR	0xe6050058
+#define PORT89CR	0xe6050059
+#define PORT90CR	0xe605005a
+#define PORT91CR	0xe605005b
+#define PORT92CR	0xe605005c
+#define PORT99CR	0xe6050063
+
+#define SMSTPCR3	0xe615013c

These should also be (void __iomem *).

Quoted 9 lines
arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h new file +3 -0
new file mode 100644
index 0000000..c6b10ee
@@ -0,0 +1,29 @@
+#ifndef MMCIF_AP4EB_H
+#define MMCIF_AP4EB_H
+
Quoted 8 lines

arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h line 9

Quoted 6 lines
arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h new file +6 -0
+#define PORT185CR      0xe60520b9
+#define PORT186CR      0xe60520ba
+#define PORT187CR      0xe60520bb
+#define PORT188CR      0xe60520bc
+
+#define PORTR191_160DR 0xe6056014

Ditto.

Thanks, I've fixed these.