diff options
author | Magnus Damm <damm@opensource.se> | 2010-05-18 10:43:15 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-05-31 00:11:54 -0400 |
commit | 4705b2e8047221142af2ed5e37f54ac4c7f80a7d (patch) | |
tree | 5e0d52a2f3ffebfd56f1f2d69f6be3b7ac72d7ad /arch/sh/boot | |
parent | 8a768952ca8cb5cad98cfa343e6fb131e3bbdc3e (diff) |
sh: add romImage MMCIF boot for sh7724 and Ecovec V2
This patch is V2 of the MMCIF romImage boot support
for sh7724 and the Ecovec board. With this patch
applied and CONFIG_ROMIMAGE_MMCIF selected the
romImage kernel image can be written to a MMC card
and booted directly by the sh7724 cpu.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boot')
-rw-r--r-- | arch/sh/boot/romimage/Makefile | 13 | ||||
-rw-r--r-- | arch/sh/boot/romimage/head.S | 30 | ||||
-rw-r--r-- | arch/sh/boot/romimage/mmcif-sh7724.c | 72 | ||||
-rw-r--r-- | arch/sh/boot/romimage/vmlinux.scr | 1 |
4 files changed, 112 insertions, 4 deletions
diff --git a/arch/sh/boot/romimage/Makefile b/arch/sh/boot/romimage/Makefile index f473a24a2d92..2216ee57f251 100644 --- a/arch/sh/boot/romimage/Makefile +++ b/arch/sh/boot/romimage/Makefile | |||
@@ -1,16 +1,21 @@ | |||
1 | # | 1 | # |
2 | # linux/arch/sh/boot/romimage/Makefile | 2 | # linux/arch/sh/boot/romimage/Makefile |
3 | # | 3 | # |
4 | # create an image suitable for burning to flash from zImage | 4 | # create an romImage file suitable for burning to flash/mmc from zImage |
5 | # | 5 | # |
6 | 6 | ||
7 | targets := vmlinux head.o zeropage.bin piggy.o | 7 | targets := vmlinux head.o zeropage.bin piggy.o |
8 | load-y := 0 | ||
8 | 9 | ||
9 | OBJECTS = $(obj)/head.o | 10 | mmcif-load-$(CONFIG_CPU_SUBTYPE_SH7724) := 0xe5200000 # ILRAM |
10 | LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext 0 -e romstart \ | 11 | mmcif-obj-$(CONFIG_CPU_SUBTYPE_SH7724) := $(obj)/mmcif-sh7724.o |
12 | load-$(CONFIG_ROMIMAGE_MMCIF) := $(mmcif-load-y) | ||
13 | obj-$(CONFIG_ROMIMAGE_MMCIF) := $(mmcif-obj-y) | ||
14 | |||
15 | LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(load-y) -e romstart \ | ||
11 | -T $(obj)/../../kernel/vmlinux.lds | 16 | -T $(obj)/../../kernel/vmlinux.lds |
12 | 17 | ||
13 | $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE | 18 | $(obj)/vmlinux: $(obj)/head.o $(obj-y) $(obj)/piggy.o FORCE |
14 | $(call if_changed,ld) | 19 | $(call if_changed,ld) |
15 | @: | 20 | @: |
16 | 21 | ||
diff --git a/arch/sh/boot/romimage/head.S b/arch/sh/boot/romimage/head.S index 65b8256d81cb..4671d1b82150 100644 --- a/arch/sh/boot/romimage/head.S +++ b/arch/sh/boot/romimage/head.S | |||
@@ -12,6 +12,36 @@ romstart: | |||
12 | /* include board specific setup code */ | 12 | /* include board specific setup code */ |
13 | #include <mach/romimage.h> | 13 | #include <mach/romimage.h> |
14 | 14 | ||
15 | #ifdef CONFIG_ROMIMAGE_MMCIF | ||
16 | /* load the romImage to above the empty zero page */ | ||
17 | mov.l empty_zero_page_dst, r4 | ||
18 | mov.l empty_zero_page_dst_adj, r5 | ||
19 | add r5, r4 | ||
20 | mov.l bytes_to_load, r5 | ||
21 | mov.l loader_function, r7 | ||
22 | jsr @r7 | ||
23 | mov r4, r15 | ||
24 | |||
25 | mov.l empty_zero_page_dst, r4 | ||
26 | mov.l empty_zero_page_dst_adj, r5 | ||
27 | add r5, r4 | ||
28 | mov.l loaded_code_offs, r5 | ||
29 | add r5, r4 | ||
30 | jmp @r4 | ||
31 | nop | ||
32 | |||
33 | .balign 4 | ||
34 | empty_zero_page_dst_adj: | ||
35 | .long PAGE_SIZE | ||
36 | bytes_to_load: | ||
37 | .long end_data - romstart | ||
38 | loader_function: | ||
39 | .long mmcif_loader | ||
40 | loaded_code_offs: | ||
41 | .long loaded_code - romstart | ||
42 | loaded_code: | ||
43 | #endif /* CONFIG_ROMIMAGE_MMCIF */ | ||
44 | |||
15 | /* copy the empty_zero_page contents to where vmlinux expects it */ | 45 | /* copy the empty_zero_page contents to where vmlinux expects it */ |
16 | mova extra_data_pos, r0 | 46 | mova extra_data_pos, r0 |
17 | mov.l extra_data_size, r1 | 47 | mov.l extra_data_size, r1 |
diff --git a/arch/sh/boot/romimage/mmcif-sh7724.c b/arch/sh/boot/romimage/mmcif-sh7724.c new file mode 100644 index 000000000000..14863d7292cb --- /dev/null +++ b/arch/sh/boot/romimage/mmcif-sh7724.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * sh7724 MMCIF loader | ||
3 | * | ||
4 | * Copyright (C) 2010 Magnus Damm | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/mmc/sh_mmcif.h> | ||
12 | #include <mach/romimage.h> | ||
13 | |||
14 | #define MMCIF_BASE (void __iomem *)0xa4ca0000 | ||
15 | |||
16 | #define MSTPCR2 0xa4150038 | ||
17 | #define PTWCR 0xa4050146 | ||
18 | #define PTXCR 0xa4050148 | ||
19 | #define PSELA 0xa405014e | ||
20 | #define PSELE 0xa4050156 | ||
21 | #define HIZCRC 0xa405015c | ||
22 | #define DRVCRA 0xa405018a | ||
23 | |||
24 | enum { MMCIF_PROGRESS_ENTER, MMCIF_PROGRESS_INIT, | ||
25 | MMCIF_PROGRESS_LOAD, MMCIF_PROGRESS_DONE }; | ||
26 | |||
27 | /* SH7724 specific MMCIF loader | ||
28 | * | ||
29 | * loads the romImage from an MMC card starting from block 512 | ||
30 | * use the following line to write the romImage to an MMC card | ||
31 | * # dd if=arch/sh/boot/romImage of=/dev/sdx bs=512 seek=512 | ||
32 | */ | ||
33 | asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes) | ||
34 | { | ||
35 | mmcif_update_progress(MMCIF_PROGRESS_ENTER); | ||
36 | |||
37 | /* enable clock to the MMCIF hardware block */ | ||
38 | __raw_writel(__raw_readl(MSTPCR2) & ~0x20000000, MSTPCR2); | ||
39 | |||
40 | /* setup pins D7-D0 */ | ||
41 | __raw_writew(0x0000, PTWCR); | ||
42 | |||
43 | /* setup pins MMC_CLK, MMC_CMD */ | ||
44 | __raw_writew(__raw_readw(PTXCR) & ~0x000f, PTXCR); | ||
45 | |||
46 | /* select D3-D0 pin function */ | ||
47 | __raw_writew(__raw_readw(PSELA) & ~0x2000, PSELA); | ||
48 | |||
49 | /* select D7-D4 pin function */ | ||
50 | __raw_writew(__raw_readw(PSELE) & ~0x3000, PSELE); | ||
51 | |||
52 | /* disable Hi-Z for the MMC pins */ | ||
53 | __raw_writew(__raw_readw(HIZCRC) & ~0x0620, HIZCRC); | ||
54 | |||
55 | /* high drive capability for MMC pins */ | ||
56 | __raw_writew(__raw_readw(DRVCRA) | 0x3000, DRVCRA); | ||
57 | |||
58 | mmcif_update_progress(MMCIF_PROGRESS_INIT); | ||
59 | |||
60 | /* setup MMCIF hardware */ | ||
61 | sh_mmcif_boot_init(MMCIF_BASE); | ||
62 | |||
63 | mmcif_update_progress(MMCIF_PROGRESS_LOAD); | ||
64 | |||
65 | /* load kernel via MMCIF interface */ | ||
66 | sh_mmcif_boot_slurp(MMCIF_BASE, buf, no_bytes); | ||
67 | |||
68 | /* disable clock to the MMCIF hardware block */ | ||
69 | __raw_writel(__raw_readl(MSTPCR2) | 0x20000000, MSTPCR2); | ||
70 | |||
71 | mmcif_update_progress(MMCIF_PROGRESS_DONE); | ||
72 | } | ||
diff --git a/arch/sh/boot/romimage/vmlinux.scr b/arch/sh/boot/romimage/vmlinux.scr index ea27298a99a7..590394e2f5f2 100644 --- a/arch/sh/boot/romimage/vmlinux.scr +++ b/arch/sh/boot/romimage/vmlinux.scr | |||
@@ -3,5 +3,6 @@ SECTIONS | |||
3 | .text : { | 3 | .text : { |
4 | zero_page_pos = .; | 4 | zero_page_pos = .; |
5 | *(.data) | 5 | *(.data) |
6 | end_data = .; | ||
6 | } | 7 | } |
7 | } | 8 | } |