diff options
Diffstat (limited to 'utils/hwstub/stub/rk27xx/target.c')
-rw-r--r-- | utils/hwstub/stub/rk27xx/target.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/utils/hwstub/stub/rk27xx/target.c b/utils/hwstub/stub/rk27xx/target.c index f9efccaef0..ff2e952909 100644 --- a/utils/hwstub/stub/rk27xx/target.c +++ b/utils/hwstub/stub/rk27xx/target.c | |||
@@ -33,7 +33,6 @@ enum rk27xx_family_t | |||
33 | }; | 33 | }; |
34 | 34 | ||
35 | static enum rk27xx_family_t g_rk27xx_family = UNKNOWN; | 35 | static enum rk27xx_family_t g_rk27xx_family = UNKNOWN; |
36 | static int g_atexit = HWSTUB_ATEXIT_OFF; | ||
37 | 36 | ||
38 | static void _enable_irq(void) | 37 | static void _enable_irq(void) |
39 | { | 38 | { |
@@ -43,23 +42,6 @@ static void _enable_irq(void) | |||
43 | ); | 42 | ); |
44 | } | 43 | } |
45 | 44 | ||
46 | static void power_off(void) | ||
47 | { | ||
48 | GPIO_PCCON &= ~(1<<0); | ||
49 | while(1); | ||
50 | } | ||
51 | |||
52 | static void rk27xx_reset(void) | ||
53 | { | ||
54 | /* use Watchdog to reset */ | ||
55 | SCU_CLKCFG &= ~CLKCFG_WDT; | ||
56 | WDTLR = 1; | ||
57 | WDTCON = (1<<4) | (1<<3); | ||
58 | |||
59 | /* Wait for reboot to kick in */ | ||
60 | while(1); | ||
61 | } | ||
62 | |||
63 | /* us may be at most 2^31/200 (~10 seconds) for 200MHz max cpu freq */ | 45 | /* us may be at most 2^31/200 (~10 seconds) for 200MHz max cpu freq */ |
64 | void target_udelay(int us) | 46 | void target_udelay(int us) |
65 | { | 47 | { |
@@ -132,41 +114,22 @@ void target_init(void) | |||
132 | } | 114 | } |
133 | } | 115 | } |
134 | 116 | ||
135 | static struct usb_resp_info_target_t g_target = | 117 | struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor = |
136 | { | 118 | { |
137 | .id = HWSTUB_TARGET_RK27, | 119 | sizeof(struct hwstub_target_desc_t), |
138 | .name = "Rockchip RK27XX" | 120 | HWSTUB_DT_TARGET, |
121 | HWSTUB_TARGET_RK27, | ||
122 | "Rockchip RK27XX" | ||
139 | }; | 123 | }; |
140 | 124 | ||
141 | int target_get_info(int info, void **buffer) | 125 | void target_get_desc(int desc, void **buffer) |
142 | { | 126 | { |
143 | if(info == HWSTUB_INFO_TARGET) | 127 | (void) desc; |
144 | { | 128 | *buffer = NULL; |
145 | *buffer = &g_target; | ||
146 | return sizeof(g_target); | ||
147 | } | ||
148 | else | ||
149 | return -1; | ||
150 | } | 129 | } |
151 | 130 | ||
152 | int target_atexit(int method) | 131 | void target_get_config_desc(void *buffer, int *size) |
153 | { | 132 | { |
154 | g_atexit = method; | 133 | (void) buffer; |
155 | return 0; | 134 | (void) size; |
156 | } | ||
157 | |||
158 | void target_exit(void) | ||
159 | { | ||
160 | switch(g_atexit) | ||
161 | { | ||
162 | case HWSTUB_ATEXIT_OFF: | ||
163 | power_off(); | ||
164 | // fallthrough in case of return | ||
165 | case HWSTUB_ATEXIT_REBOOT: | ||
166 | rk27xx_reset(); | ||
167 | // fallthrough in case of return | ||
168 | case HWSTUB_ATEXIT_NOP: | ||
169 | default: | ||
170 | return; | ||
171 | } | ||
172 | } | 135 | } |