mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
Subsystems (6)
PATCH v6 1/1 mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
Hi Magnus,
could I get an Ack or otherwise from you on this change? All the pre-requisites are in 2.6.39-rc1.
Note that if you are inclined to build a 2.6.39-rc1 kernel for mackerel you will also need "sh: intc: fix build error in interrupts.h"
(https://patchwork.kernel.org/patch/672972/) or similar. That change is unrelated to my work.
PATCH 1/1 mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
This allows a ROM-able zImage to be written to eSD and for SuperH Mobile ARM to boot directly from the SDHI 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 is based on Linus's tree, commit
f741a79 ("Merge branch 'for-linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse")
It also has the following prerequisite patches:
mmc: tmio_mmc: Move some defines into a shared header mmc, ARM: Rename SuperH Mobile ARM zboot helpers
mmc: Add MMC_PROGRESS_*
v2
* Consistently use __raw_readw(). As pointed out by Paul Mundt
v3
* Remove mmcif_update_progress2(), it was for debugging during development
* Move CPU specific code into mach/sdhi.h
As requested by Magnus Damm
* Use linux/mmc/tmio.h now that it exists
* Remove SDHI_EXT_SWAP, it is unused
* Replace use of MMCIF_PROGRESS_* with MMC_PROGRESS_*
* Don't include linux/mmc/sh_mmcif.h
+ Replace use of MMCIF_CE_RESP_CMD12 with RESP_CMD12
+ Include linux/io.h
v4
* Move definition of SDHI_BASE into CPU-specific code. Thanks to Magnus Damm.
v5
* Move mmc_loader into board-specific code
As suggested by Magnus Damm.
v6
* Don't change the name of mmcif_loader to mmc_loader in arch/sh/boot/romimage/mmcif-sh7724.c
That code is unrelated to this change and changing the name without updating the caller introduces a build failure.
* Fix shdi -> sdhi typos
--- Documentation/arm/SH-Mobile/zboot-rom-sdhi.txt | 43 ++ arch/arm/Kconfig | 33 ++- arch/arm/boot/compressed/Makefile | 10 +- arch/arm/boot/compressed/head-shmobile.S | 12 +- arch/arm/boot/compressed/mmcif-sh7372.c | 2 +- arch/arm/boot/compressed/sdhi-sh7372.c | 95 +++++ arch/arm/boot/compressed/sdhi-shmobile.c | 449 +++++++++++++++++++++ arch/arm/boot/compressed/sdhi-shmobile.h | 11 + arch/arm/mach-shmobile/include/mach/sdhi-sh7372.h | 21 + arch/arm/mach-shmobile/include/mach/sdhi.h | 16 + 10 files changed, 675 insertions(+), 17 deletions(-) create mode 100644 Documentation/arm/SH-Mobile/zboot-rom-sdhi.txt create mode 100644 arch/arm/boot/compressed/sdhi-sh7372.c create mode 100644 arch/arm/boot/compressed/sdhi-shmobile.c create mode 100644 arch/arm/boot/compressed/sdhi-shmobile.h create mode 100644 arch/arm/mach-shmobile/include/mach/sdhi-sh7372.h create mode 100644 arch/arm/mach-shmobile/include/mach/sdhi.h
Documentation/arm/SH-Mobile/zboot-rom-sdhi.txt new file +43 -0
@@ -0,0 +1,43 @@ +ROM-able zImage boot from eSD +----------------------------- + +An ROM-able zImage compiled with ZBOOT_ROM_SDHI may be written to eSD and +SuperH Mobile ARM will to boot directly from the SDHI 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 mackerel board using the developer 1A eSD +boot mode which is configured using the following jumper settings. + + 8 7 6 5 4 3 2 1 + x|x|x|x| |x|x| +S4 -+-+-+-+-+-+-+- + | | | |x| | |x on + +The eSD card needs to be present in SDHI slot 1 (CN7). +As such S1 and S33 also need to be configured as per +the notes in arch/arm/mach-shmobile/board-mackerel.c. + +A partial zImage must be written to physical partition #1 (boot) +of the eSD at sector 0 in vrl4 format. A utility vrl4 is supplied to +accomplish this. + +e.g. + vrl4 < zImage | dd of=/dev/sdX bs=512 count=17 + +A full copy of _the same_ zImage should be written to physical partition #1 +(boot) of the eSD@sector 0. This should _not_ be in vrl4 format. + + vrl4 < zImage | dd of=/dev/sdX bs=512 + +Note: The commands above assume that the physical partition has been +switched. No such facility currently exists in the Linux Kernel. + +Physical partitions are described in the eSD specification. At the time of +writing they are not the same as partitions that are typically configured +using fdisk and visible through /proc/partitions +
arch/arm/Kconfig +25 -8
@@ -1720,17 +1720,34 @@ 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. +choice + prompt "Include SD/MMC loader in zImage (EXPERIMENTAL)" + depends on ZBOOT_ROM && ARCH_SH7372 && EXPERIMENTAL + default ZBOOT_ROM_NONE + help + Include experimental SD/MMC 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 or SD 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. + +config ZBOOT_ROM_NONE + bool "No SD/MMC loader in zImage (EXPERIMENTAL)" + help + Do not load image from SD or MMC + 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. + Load image from MMCIF hardware block. + +config ZBOOT_ROM_SH_MOBILE_SDHI + bool "Include SuperH Mobile SDHI loader in zImage (EXPERIMENTAL)" + help + Load image from SDHI hardware block + +endchoice config CMDLINE string "Default kernel command string"
arch/arm/boot/compressed/Makefile +8 -2
@@ -6,13 +6,19 @@ OBJS = -# Ensure that mmcif loader code appears early in the image +# 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 + +# Ensure that SDHI 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_SH_MOBILE_SDHI),y) +OBJS += sdhi-shmobile.o +OBJS += sdhi-sh7372.o endif AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
arch/arm/boot/compressed/head-shmobile.S +6 -6
@@ -25,14 +25,14 @@ /* load board-specific initialization code */ #include <mach/zboot.h> -#ifdef CONFIG_ZBOOT_ROM_MMCIF - /* Load image from MMC */ - adr sp, __tmp_stack + 128 +#if defined(CONFIG_ZBOOT_ROM_MMCIF) || defined(CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI) + /* Load image from MMC/SD */ + adr sp, __tmp_stack + 256 ldr r0, __image_start ldr r1, __image_end subs r1, r1, r0 ldr r0, __load_base - bl mmcif_loader + bl mmc_loader /* Jump to loaded code */ ldr r0, __loaded
@@ -51,9 +51,9 @@ __loaded: .long __continue .align __tmp_stack: - .space 128 + .space 256 __continue: -#endif /* CONFIG_ZBOOT_ROM_MMCIF */ +#endif /* CONFIG_ZBOOT_ROM_MMC || CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI */ b 1f __atags:@ tag #1
arch/arm/boot/compressed/mmcif-sh7372.c +1 -1
@@ -40,7 +40,7 @@* to an MMC card * # dd if=vrl4.out of=/dev/sdx bs=512 seek=1 */ -asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len) +asmlinkage void mmc_loader(unsigned char *buf, unsigned long len) {mmc_init_progress ();mmc_update_progress (MMC_PROGRESS_ENTER );
arch/arm/boot/compressed/sdhi-sh7372.c new file +95 -0
95 lines not on this page · raw message
arch/arm/boot/compressed/sdhi-shmobile.c new file +449 -0
449 lines not on this page · raw message
arch/arm/boot/compressed/sdhi-shmobile.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef SDHI_MOBILE_H +#define SDHI_MOBILE_H + +#include <linux/compiler.h> + +int sdhi_boot_do_read (void __iomem *base,int high_capacity, +unsigned long offset,unsigned short count, +unsigned short *buf); +int sdhi_boot_init (void __iomem *base); + +#endif
arch/arm/mach-shmobile/include/mach/sdhi-sh7372.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef SDHI_SH7372_H +#define SDHI_SH7372_H + +#define SDGENCNTA 0xfe40009c + +/* The countdown of SDGENCNTA is controlled by +* ZB3D2CLK which runs at 149.5MHz. +* That is 149.5ticks/us. Approximate this as 150ticks/us. +*/ +static void udelay (int us) +{ +__raw_writel (us *150 ,SDGENCNTA ); +while (__raw_readl (SDGENCNTA )) ; +} + +static void msleep (int ms) +{ +udelay (ms *1000 ); +} + +#endif
arch/arm/mach-shmobile/include/mach/sdhi.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef SDHI_H +#define SDHI_H + +/************************************************** +* +* CPU specific settings +* +**************************************************/ + +#ifdef CONFIG_ARCH_SH7372 +#include "mach/sdhi-sh7372.h" +#else +#error "unsupported CPU." +#endif + +#endif /* SDHI_H */
Signature · 1 line
1.7.4.1
Magnus Damm
maintainerPATCH 1/1 mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
Quoted 9 lines · Simon Horman
This allows a ROM-able zImage to be written to eSD and for SuperH Mobile ARM to boot directly from the SDHI 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.
Quoted 4 lines
Cc Paul Mundt <[email protected]>Cc Magnus Damm <[email protected]>Cc Kuninori Morimoto <[email protected]>Signed-off-by Simon Horman <[email protected]>
Hi Simon,
Thanks for your work on this. v6 of this patch looks good to me!
PATCH 1/1 mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
Quoted 15 lines · Magnus Damm
Quoted 9 lines · Simon Horman
This allows a ROM-able zImage to be written to eSD and for SuperH Mobile ARM to boot directly from the SDHI 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.
Quoted 4 lines
Cc Paul Mundt <[email protected]>Cc Magnus Damm <[email protected]>Cc Kuninori Morimoto <[email protected]>Signed-off-by Simon Horman <[email protected]>
Quoted 5 lines
Hi Simon,
Thanks for your work on this. v6 of this patch looks good to me!
Acked-by Magnus Damm <[email protected]>
Likewise. Feel free to shovel it in to the patch tracker at your leisure.
PATCH 1/1 mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM
Quoted 18 lines · Paul Mundt
Quoted 17 lines · Magnus Damm
Quoted 9 lines · Simon Horman
This allows a ROM-able zImage to be written to eSD and for SuperH Mobile ARM to boot directly from the SDHI 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.
Quoted 4 lines
Cc Paul Mundt <[email protected]>Cc Magnus Damm <[email protected]>Cc Kuninori Morimoto <[email protected]>Signed-off-by Simon Horman <[email protected]>Hi Simon,
Quoted 7 lines
Quoted 3 lines
Thanks for your work on this. v6 of this patch looks good to me!
Acked-by Magnus Damm <[email protected]>Likewise. Feel free to shovel it in to the patch tracker at your leisure.
Acked-by Paul Mundt <[email protected]>
Thanks, will do.