diff options
Diffstat (limited to 'utils/hwstub/stub')
-rw-r--r-- | utils/hwstub/stub/pp/Makefile | 2 | ||||
-rw-r--r-- | utils/hwstub/stub/pp/crt0.S | 31 | ||||
-rw-r--r-- | utils/hwstub/stub/pp/target-config.h | 6 | ||||
-rw-r--r-- | utils/hwstub/stub/pp/target.c | 65 |
4 files changed, 85 insertions, 19 deletions
diff --git a/utils/hwstub/stub/pp/Makefile b/utils/hwstub/stub/pp/Makefile index 6e79a2b1c8..73d5838f49 100644 --- a/utils/hwstub/stub/pp/Makefile +++ b/utils/hwstub/stub/pp/Makefile | |||
@@ -7,7 +7,7 @@ AS=arm-elf-eabi-gcc | |||
7 | OC=arm-elf-eabi-objcopy | 7 | OC=arm-elf-eabi-objcopy |
8 | DEFINES= | 8 | DEFINES= |
9 | INCLUDES=-I$(CURDIR) | 9 | INCLUDES=-I$(CURDIR) |
10 | GCCOPTS=-mcpu=arm926ej-s | 10 | GCCOPTS=-mcpu=arm7tdmi |
11 | BUILD_DIR=$(CURDIR)/build/ | 11 | BUILD_DIR=$(CURDIR)/build/ |
12 | ROOT_DIR=$(CURDIR)/.. | 12 | ROOT_DIR=$(CURDIR)/.. |
13 | 13 | ||
diff --git a/utils/hwstub/stub/pp/crt0.S b/utils/hwstub/stub/pp/crt0.S index 38b6f18ac5..a128391286 100644 --- a/utils/hwstub/stub/pp/crt0.S +++ b/utils/hwstub/stub/pp/crt0.S | |||
@@ -5,9 +5,25 @@ | |||
5 | start: | 5 | start: |
6 | sub r7, pc, #8 /* Copy running address */ | 6 | sub r7, pc, #8 /* Copy running address */ |
7 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ | 7 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ |
8 | /* The stub could be located at a virtual address so killing the MMU at | 8 | |
9 | * this point would be mere suicide. We assume that the remap location | 9 | /* Get processor ID */ |
10 | * is identically mapped and kill the MMU after the copy */ | 10 | ldr r0, =0x60000000 /* PROC_ID */ |
11 | ldrb r4, [r0] | ||
12 | |||
13 | /* Halt the COP */ | ||
14 | ldr r6, =0x60007004 /* COP_CTL */ | ||
15 | cmp r4, #0x55 /* CPU_ID */ | ||
16 | 1: | ||
17 | ldrne r1, [r6] | ||
18 | orrne r1, #0x80000000 /* PROC_SLEEP */ | ||
19 | strne r1, [r6] | ||
20 | bne 1b | ||
21 | |||
22 | /* Wait for the COP to be stopped */ | ||
23 | 1: | ||
24 | ldr r0, [r6] | ||
25 | tst r0, #0x80000000 /* PROC_SLEEP */ | ||
26 | beq 1b | ||
11 | 27 | ||
12 | /* Relocate to right address */ | 28 | /* Relocate to right address */ |
13 | mov r2, r7 | 29 | mov r2, r7 |
@@ -19,16 +35,11 @@ start: | |||
19 | strhi r5, [r3], #4 | 35 | strhi r5, [r3], #4 |
20 | bhi 1b | 36 | bhi 1b |
21 | mov r2, #0 | 37 | mov r2, #0 |
22 | mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache | 38 | /* FIXME invalid Icache here ? */ |
23 | /* Jump to real location */ | 39 | /* Jump to real location */ |
24 | ldr pc, =remap | 40 | ldr pc, =remap |
25 | remap: | 41 | remap: |
26 | /* Disable MMU, disable caching and buffering; | 42 | /* NOTE on PP611x, we should make sure the MMU is disabled at this point */ |
27 | * use low exception range address */ | ||
28 | mrc p15, 0, r0, c1, c0, 0 | ||
29 | ldr r1, =0x3005 | ||
30 | bic r0, r1 | ||
31 | mcr p15, 0, r0, c1, c0, 0 | ||
32 | /* clear bss */ | 43 | /* clear bss */ |
33 | ldr r2, =bss_start | 44 | ldr r2, =bss_start |
34 | ldr r3, =bss_end | 45 | ldr r3, =bss_end |
diff --git a/utils/hwstub/stub/pp/target-config.h b/utils/hwstub/stub/pp/target-config.h index 0774137277..0cd7c0ccc7 100644 --- a/utils/hwstub/stub/pp/target-config.h +++ b/utils/hwstub/stub/pp/target-config.h | |||
@@ -1,9 +1,7 @@ | |||
1 | #define CONFIG_PP | 1 | #define CONFIG_PP |
2 | #define IRAM_ORIG 0x40000000 | 2 | #define IRAM_ORIG 0x40000000 |
3 | #define IRAM_SIZE 0x20000 | 3 | #define IRAM_SIZE 0xc000 |
4 | #define DRAM_ORIG 0x10f00000 | ||
5 | #define DRAM_SIZE (MEMORYSIZE * 0x100000) | ||
6 | #define CPU_ARM | 4 | #define CPU_ARM |
7 | #define ARM_ARCH 5 | 5 | #define ARM_ARCH 4 |
8 | #define USB_BASE 0xc5000000 | 6 | #define USB_BASE 0xc5000000 |
9 | #define USB_NUM_ENDPOINTS 2 \ No newline at end of file | 7 | #define USB_NUM_ENDPOINTS 2 \ No newline at end of file |
diff --git a/utils/hwstub/stub/pp/target.c b/utils/hwstub/stub/pp/target.c index 14eab80080..5e3a819114 100644 --- a/utils/hwstub/stub/pp/target.c +++ b/utils/hwstub/stub/pp/target.c | |||
@@ -30,28 +30,85 @@ | |||
30 | * | 30 | * |
31 | */ | 31 | */ |
32 | 32 | ||
33 | /* FIXME wrong for PP500x */ | 33 | enum pp_family_t |
34 | #define USEC_TIMER (*(volatile unsigned long *)(0x60005010)) | 34 | { |
35 | UNKNOWN, | ||
36 | PP502x, | ||
37 | PP611x | ||
38 | }; | ||
39 | |||
40 | static enum pp_family_t g_pp_family = UNKNOWN; | ||
41 | |||
42 | #define USEC_TIMER (*(volatile unsigned long *)(0x60005010)) | ||
43 | |||
44 | // NOTE only valid for PP502x and above */ | ||
45 | #define PP_VER1 (*(volatile unsigned long *)(0x70000000)) | ||
46 | #define PP_VER2 (*(volatile unsigned long *)(0x70000004)) | ||
35 | 47 | ||
36 | struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor = | 48 | struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor = |
37 | { | 49 | { |
38 | sizeof(struct hwstub_target_desc_t), | 50 | sizeof(struct hwstub_target_desc_t), |
39 | HWSTUB_DT_TARGET, | 51 | HWSTUB_DT_TARGET, |
40 | HWSTUB_TARGET_PP, | 52 | HWSTUB_TARGET_PP, |
41 | "PP500x / PP502x / PP610x" | 53 | "PP502x / PP611x" |
42 | }; | 54 | }; |
43 | 55 | ||
56 | static struct hwstub_pp_desc_t __attribute__((aligned(2))) pp_descriptor = | ||
57 | { | ||
58 | sizeof(struct hwstub_pp_desc_t), | ||
59 | HWSTUB_DT_PP, | ||
60 | 0, {' ', ' '}, | ||
61 | }; | ||
62 | |||
63 | static uint16_t char2hex(uint8_t c) | ||
64 | { | ||
65 | if(c >= '0' && c <= '9') | ||
66 | return c - '0'; | ||
67 | else | ||
68 | return 0xf; | ||
69 | } | ||
70 | |||
44 | void target_init(void) | 71 | void target_init(void) |
45 | { | 72 | { |
73 | /* try to read version for PP502x */ | ||
74 | if(PP_VER2 >> 16 != ('P' | 'P' << 8)) | ||
75 | { | ||
76 | logf("unidentified PP family"); | ||
77 | g_pp_family = UNKNOWN; | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | pp_descriptor.wChipID = char2hex((PP_VER2 >> 8) & 0xff) << 12 | | ||
82 | char2hex(PP_VER2 & 0xff) << 8 | | ||
83 | char2hex((PP_VER1 >> 24) & 0xff) << 4 | | ||
84 | char2hex((PP_VER1 >> 16) & 0xff); | ||
85 | pp_descriptor.bRevision[0] = (PP_VER1 >> 8) & 0xff; | ||
86 | pp_descriptor.bRevision[1] = PP_VER1 & 0xff; | ||
87 | if(pp_descriptor.wChipID >= 0x6110) | ||
88 | { | ||
89 | logf("identified PP611x family"); | ||
90 | g_pp_family = PP611x; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | logf("identified PP502x family"); | ||
95 | g_pp_family = PP502x; | ||
96 | } | ||
97 | } | ||
46 | } | 98 | } |
47 | 99 | ||
48 | void target_get_desc(int desc, void **buffer) | 100 | void target_get_desc(int desc, void **buffer) |
49 | { | 101 | { |
50 | *buffer = NULL; | 102 | if(desc == HWSTUB_DT_PP) |
103 | *buffer = &pp_descriptor; | ||
104 | else | ||
105 | *buffer = NULL; | ||
51 | } | 106 | } |
52 | 107 | ||
53 | void target_get_config_desc(void *buffer, int *size) | 108 | void target_get_config_desc(void *buffer, int *size) |
54 | { | 109 | { |
110 | memcpy(buffer, &pp_descriptor, sizeof(pp_descriptor)); | ||
111 | *size += sizeof(pp_descriptor); | ||
55 | } | 112 | } |
56 | 113 | ||
57 | void target_udelay(int us) | 114 | void target_udelay(int us) |