diff options
Diffstat (limited to 'utils/hwstub/stub/pp/target.c')
-rw-r--r-- | utils/hwstub/stub/pp/target.c | 65 |
1 files changed, 61 insertions, 4 deletions
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) |