diff options
25 files changed, 1055 insertions, 366 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 95e8450d00..e506a1bcf6 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -253,18 +253,30 @@ target/coldfire/iaudio/x5/lcd-remote-x5.c | |||
253 | #endif | 253 | #endif |
254 | #endif | 254 | #endif |
255 | 255 | ||
256 | #ifdef IRIVER_H100_SERIES | 256 | #ifdef IRIVER_H300_SERIES |
257 | target/coldfire/iriver/h300/power-h300.c | ||
257 | #ifndef SIMULATOR | 258 | #ifndef SIMULATOR |
258 | target/coldfire/iriver/h100/button-h100.c | 259 | target/coldfire/pcf50606-coldfire.c |
260 | target/coldfire/iriver/ata-iriver.c | ||
261 | target/coldfire/iriver/system-iriver.c | ||
262 | target/coldfire/iriver/h300/adc-h300.c | ||
263 | target/coldfire/iriver/h300/backlight-h300.c | ||
264 | target/coldfire/iriver/h300/button-h300.c | ||
265 | target/coldfire/iriver/h300/lcd-as-h300.S | ||
266 | target/coldfire/iriver/h300/pcf50606-h300.c | ||
267 | target/coldfire/iriver/h300/usb-h300.c | ||
259 | #endif | 268 | #endif |
260 | #endif | 269 | #endif |
261 | 270 | ||
262 | #ifdef IRIVER_H300_SERIES | 271 | #ifdef IRIVER_H100_SERIES |
272 | target/coldfire/iriver/h100/power-h100.c | ||
263 | #ifndef SIMULATOR | 273 | #ifndef SIMULATOR |
264 | target/coldfire/iriver/h300/lcd-as-h300.S | 274 | target/coldfire/iriver/ata-iriver.c |
265 | target/coldfire/iriver/h300/button-h300.c | 275 | target/coldfire/iriver/system-iriver.c |
266 | target/coldfire/pcf50606-coldfire.c | 276 | target/coldfire/iriver/h100/adc-h100.c |
267 | target/coldfire/iriver/h300/pcf50606-h300.c | 277 | target/coldfire/iriver/h100/backlight-h100.c |
278 | target/coldfire/iriver/h100/button-h100.c | ||
279 | target/coldfire/iriver/h100/usb-h100.c | ||
268 | #endif | 280 | #endif |
269 | #endif | 281 | #endif |
270 | 282 | ||
diff --git a/firmware/backlight.c b/firmware/backlight.c index 997e26daa7..46e28824d3 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -61,13 +61,7 @@ static inline void __backlight_off(void) | |||
61 | #ifndef TARGET_TREE | 61 | #ifndef TARGET_TREE |
62 | static inline void __backlight_on(void) | 62 | static inline void __backlight_on(void) |
63 | { | 63 | { |
64 | #if CONFIG_BACKLIGHT == BL_IRIVER_H100 | 64 | #if CONFIG_BACKLIGHT == BL_RTC |
65 | and_l(~0x00020000, &GPIO1_OUT); | ||
66 | #elif CONFIG_BACKLIGHT == BL_IRIVER_H300 | ||
67 | lcd_enable(true); | ||
68 | sleep(HZ/100); /* lcd needs time - avoid flashing for dark screens */ | ||
69 | or_l(0x00020000, &GPIO1_OUT); | ||
70 | #elif CONFIG_BACKLIGHT == BL_RTC | ||
71 | /* Enable square wave */ | 65 | /* Enable square wave */ |
72 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); | 66 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); |
73 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ | 67 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ |
@@ -84,12 +78,7 @@ static inline void __backlight_on(void) | |||
84 | 78 | ||
85 | static inline void __backlight_off(void) | 79 | static inline void __backlight_off(void) |
86 | { | 80 | { |
87 | #if CONFIG_BACKLIGHT == BL_IRIVER_H100 | 81 | #if CONFIG_BACKLIGHT == BL_RTC |
88 | or_l(0x00020000, &GPIO1_OUT); | ||
89 | #elif CONFIG_BACKLIGHT == BL_IRIVER_H300 | ||
90 | and_l(~0x00020000, &GPIO1_OUT); | ||
91 | lcd_enable(false); | ||
92 | #elif CONFIG_BACKLIGHT == BL_RTC | ||
93 | /* Disable square wave */ | 82 | /* Disable square wave */ |
94 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | 83 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); |
95 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ | 84 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ |
@@ -162,7 +151,7 @@ static int lcd_sleep_timeout = 10*HZ; | |||
162 | 151 | ||
163 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) | 152 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) |
164 | /* backlight fading */ | 153 | /* backlight fading */ |
165 | #define BL_PWM_INTERVAL 5000 /* Cycle interval in µs */ | 154 | #define BL_PWM_INTERVAL 5000 /* Cycle interval in s */ |
166 | #define BL_PWM_COUNT 100 | 155 | #define BL_PWM_COUNT 100 |
167 | static const char backlight_fade_value[8] = { 0, 1, 2, 4, 6, 8, 10, 20 }; | 156 | static const char backlight_fade_value[8] = { 0, 1, 2, 4, 6, 8, 10, 20 }; |
168 | static int fade_in_count = 1; | 157 | static int fade_in_count = 1; |
@@ -352,26 +341,6 @@ static void __remote_backlight_off(void) | |||
352 | { | 341 | { |
353 | sim_remote_backlight(0); | 342 | sim_remote_backlight(0); |
354 | } | 343 | } |
355 | #else | ||
356 | #ifndef TARGET_TREE | ||
357 | static void __remote_backlight_on(void) | ||
358 | { | ||
359 | #if defined(IRIVER_H300_SERIES) | ||
360 | and_l(~0x00000002, &GPIO1_OUT); | ||
361 | #else | ||
362 | and_l(~0x00000800, &GPIO_OUT); | ||
363 | #endif | ||
364 | } | ||
365 | |||
366 | static void __remote_backlight_off(void) | ||
367 | { | ||
368 | #if defined(IRIVER_H300_SERIES) | ||
369 | or_l(0x00000002, &GPIO1_OUT); | ||
370 | #else | ||
371 | or_l(0x00000800, &GPIO_OUT); | ||
372 | #endif | ||
373 | } | ||
374 | #endif /* TARGET_TREE */ | ||
375 | #endif /* SIMULATOR */ | 344 | #endif /* SIMULATOR */ |
376 | #endif /* HAVE_REMOTE_LCD */ | 345 | #endif /* HAVE_REMOTE_LCD */ |
377 | 346 | ||
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index 646509b8a8..388ff66d5f 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c | |||
@@ -108,135 +108,6 @@ void adc_init(void) | |||
108 | 108 | ||
109 | sleep(2); /* Ensure valid readings when adc_init returns */ | 109 | sleep(2); /* Ensure valid readings when adc_init returns */ |
110 | } | 110 | } |
111 | #elif CONFIG_CPU == MCF5249 | ||
112 | static unsigned char adcdata[NUM_ADC_CHANNELS]; | ||
113 | |||
114 | #ifdef IRIVER_H300_SERIES | ||
115 | static int adcc2_parms[] = | ||
116 | { | ||
117 | [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ | ||
118 | [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */ | ||
119 | [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */ | ||
120 | [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* ADCIN1, resistive divider */ | ||
121 | }; | ||
122 | |||
123 | unsigned short adc_scan(int channel) | ||
124 | { | ||
125 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
126 | unsigned char data; | ||
127 | |||
128 | pcf50606_write(0x2f, adcc2_parms[channel]); | ||
129 | data = pcf50606_read(0x30); | ||
130 | |||
131 | adcdata[channel] = data; | ||
132 | |||
133 | set_irq_level(level); | ||
134 | return data; | ||
135 | } | ||
136 | #else | ||
137 | |||
138 | #define CS_LO and_l(~0x80, &GPIO_OUT) | ||
139 | #define CS_HI or_l(0x80, &GPIO_OUT) | ||
140 | #define CLK_LO and_l(~0x00400000, &GPIO_OUT) | ||
141 | #define CLK_HI or_l(0x00400000, &GPIO_OUT) | ||
142 | #define DO (GPIO_READ & 0x80000000) | ||
143 | #define DI_LO and_l(~0x00200000, &GPIO_OUT) | ||
144 | #define DI_HI or_l(0x00200000, &GPIO_OUT) | ||
145 | |||
146 | /* delay loop */ | ||
147 | #define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0) | ||
148 | |||
149 | unsigned short adc_scan(int channel) | ||
150 | { | ||
151 | unsigned char data = 0; | ||
152 | int i; | ||
153 | |||
154 | CS_LO; | ||
155 | |||
156 | DI_HI; /* Start bit */ | ||
157 | DELAY; | ||
158 | CLK_HI; | ||
159 | DELAY; | ||
160 | CLK_LO; | ||
161 | |||
162 | DI_HI; /* Single channel */ | ||
163 | DELAY; | ||
164 | CLK_HI; | ||
165 | DELAY; | ||
166 | CLK_LO; | ||
167 | |||
168 | if(channel & 1) /* LSB of channel number */ | ||
169 | DI_HI; | ||
170 | else | ||
171 | DI_LO; | ||
172 | DELAY; | ||
173 | CLK_HI; | ||
174 | DELAY; | ||
175 | CLK_LO; | ||
176 | |||
177 | if(channel & 2) /* MSB of channel number */ | ||
178 | DI_HI; | ||
179 | else | ||
180 | DI_LO; | ||
181 | DELAY; | ||
182 | CLK_HI; | ||
183 | DELAY; | ||
184 | CLK_LO; | ||
185 | |||
186 | DELAY; | ||
187 | |||
188 | for(i = 0;i < 8;i++) /* 8 bits of data */ | ||
189 | { | ||
190 | CLK_HI; | ||
191 | DELAY; | ||
192 | CLK_LO; | ||
193 | DELAY; | ||
194 | data <<= 1; | ||
195 | data |= DO?1:0; | ||
196 | } | ||
197 | |||
198 | CS_HI; | ||
199 | |||
200 | adcdata[channel] = data; | ||
201 | |||
202 | return data; | ||
203 | } | ||
204 | #endif | ||
205 | |||
206 | unsigned short adc_read(int channel) | ||
207 | { | ||
208 | return adcdata[channel]; | ||
209 | } | ||
210 | |||
211 | static int adc_counter; | ||
212 | |||
213 | static void adc_tick(void) | ||
214 | { | ||
215 | if(++adc_counter == HZ) | ||
216 | { | ||
217 | adc_counter = 0; | ||
218 | adc_scan(ADC_BATTERY); | ||
219 | adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote | ||
220 | detection feels stable. */ | ||
221 | } | ||
222 | } | ||
223 | |||
224 | void adc_init(void) | ||
225 | { | ||
226 | #ifndef IRIVER_H300_SERIES | ||
227 | or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS | ||
228 | GPIO21: Data In (to the ADC) | ||
229 | GPIO22: CLK | ||
230 | GPIO31: Data Out (from the ADC) */ | ||
231 | or_l(0x00600080, &GPIO_ENABLE); | ||
232 | or_l(0x80, &GPIO_OUT); /* CS high */ | ||
233 | and_l(~0x00400000, &GPIO_OUT); /* CLK low */ | ||
234 | #endif | ||
235 | |||
236 | adc_scan(ADC_BATTERY); | ||
237 | |||
238 | tick_add_task(adc_tick); | ||
239 | } | ||
240 | 111 | ||
241 | #elif CONFIG_CPU == TCC730 | 112 | #elif CONFIG_CPU == TCC730 |
242 | 113 | ||
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index babbab016a..39827f7188 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -1476,12 +1476,6 @@ int ata_hard_reset(void) | |||
1476 | /* state HRR1 */ | 1476 | /* state HRR1 */ |
1477 | or_b(0x02, &PADRH); /* negate _RESET */ | 1477 | or_b(0x02, &PADRH); /* negate _RESET */ |
1478 | sleep(1); /* > 2ms */ | 1478 | sleep(1); /* > 2ms */ |
1479 | #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
1480 | and_l(~0x00080000, &GPIO_OUT); | ||
1481 | sleep(1); /* > 25us */ | ||
1482 | |||
1483 | or_l(0x00080000, &GPIO_OUT); | ||
1484 | sleep(1); /* > 25us */ | ||
1485 | #elif CONFIG_CPU == TCC730 | 1479 | #elif CONFIG_CPU == TCC730 |
1486 | 1480 | ||
1487 | P6 &= ~0x40; | 1481 | P6 &= ~0x40; |
@@ -1627,14 +1621,6 @@ void ata_enable(bool on) | |||
1627 | or_b(0x80, &PADRL); /* disable ATA */ | 1621 | or_b(0x80, &PADRL); /* disable ATA */ |
1628 | 1622 | ||
1629 | or_b(0x80, &PAIORL); | 1623 | or_b(0x80, &PAIORL); |
1630 | #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
1631 | if(on) | ||
1632 | and_l(~0x0040000, &GPIO_OUT); | ||
1633 | else | ||
1634 | or_l(0x0040000, &GPIO_OUT); | ||
1635 | |||
1636 | or_l(0x00040000, &GPIO_ENABLE); | ||
1637 | or_l(0x00040000, &GPIO_FUNCTION); | ||
1638 | #elif CONFIG_CPU == TCC730 | 1624 | #elif CONFIG_CPU == TCC730 |
1639 | 1625 | ||
1640 | #endif | 1626 | #endif |
@@ -1788,8 +1774,6 @@ int ata_init(void) | |||
1788 | bool coldstart = ata_is_coldstart(); | 1774 | bool coldstart = ata_is_coldstart(); |
1789 | #elif CONFIG_CPU == TCC730 | 1775 | #elif CONFIG_CPU == TCC730 |
1790 | bool coldstart = (P1 & 0x80) == 0; | 1776 | bool coldstart = (P1 & 0x80) == 0; |
1791 | #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
1792 | bool coldstart = (GPIO_FUNCTION & 0x00080000) == 0; | ||
1793 | #else | 1777 | #else |
1794 | bool coldstart = (PACR2 & 0x4000) != 0; | 1778 | bool coldstart = (PACR2 & 0x4000) != 0; |
1795 | #endif | 1779 | #endif |
diff --git a/firmware/export/adc.h b/firmware/export/adc.h index 95728d432f..4dced55f09 100644 --- a/firmware/export/adc.h +++ b/firmware/export/adc.h | |||
@@ -24,28 +24,6 @@ | |||
24 | #ifdef TARGET_TREE | 24 | #ifdef TARGET_TREE |
25 | #include "adc-target.h" | 25 | #include "adc-target.h" |
26 | 26 | ||
27 | #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
28 | #define NUM_ADC_CHANNELS 4 | ||
29 | |||
30 | #define ADC_BUTTONS 0 | ||
31 | #define ADC_REMOTE 1 | ||
32 | #define ADC_BATTERY 2 | ||
33 | #define ADC_REMOTEDETECT 3 | ||
34 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
35 | |||
36 | /* ADC values for different remote control types */ | ||
37 | #ifdef IRIVER_H100_SERIES | ||
38 | #define ADCVAL_H300_LCD_REMOTE 0x5E | ||
39 | #define ADCVAL_H100_LCD_REMOTE 0x96 | ||
40 | #define ADCVAL_H300_LCD_REMOTE_HOLD 0xCC | ||
41 | #define ADCVAL_H100_LCD_REMOTE_HOLD 0xEA | ||
42 | #else /* H300 series */ | ||
43 | #define ADCVAL_H300_LCD_REMOTE 0x35 | ||
44 | #define ADCVAL_H100_LCD_REMOTE 0x54 | ||
45 | #define ADCVAL_H300_LCD_REMOTE_HOLD 0x72 | ||
46 | #define ADCVAL_H100_LCD_REMOTE_HOLD 0x83 | ||
47 | #endif | ||
48 | |||
49 | #elif defined(IRIVER_IFP7XX) | 27 | #elif defined(IRIVER_IFP7XX) |
50 | 28 | ||
51 | #define NUM_ADC_CHANNELS 5 | 29 | #define NUM_ADC_CHANNELS 5 |
@@ -100,9 +78,4 @@ | |||
100 | unsigned short adc_read(int channel); | 78 | unsigned short adc_read(int channel); |
101 | void adc_init(void); | 79 | void adc_init(void); |
102 | 80 | ||
103 | #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
104 | /* Force a scan now */ | ||
105 | unsigned short adc_scan(int channel); | ||
106 | #endif | ||
107 | |||
108 | #endif /* _ADC_H_ */ | 81 | #endif /* _ADC_H_ */ |
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 12f1066d3a..6f74078e1e 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h | |||
@@ -2,6 +2,8 @@ | |||
2 | #error "re-run configure this just so wrong" | 2 | #error "re-run configure this just so wrong" |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #define TARGET_TREE /* this target is using the target tree system */ | ||
6 | |||
5 | /* | 7 | /* |
6 | * This config file is for iriver iHP-100, iHP-110, iHP-115 | 8 | * This config file is for iriver iHP-100, iHP-110, iHP-115 |
7 | */ | 9 | */ |
@@ -145,6 +147,13 @@ | |||
145 | 147 | ||
146 | #endif /* !SIMULATOR */ | 148 | #endif /* !SIMULATOR */ |
147 | 149 | ||
150 | #define DEFAULT_CONTRAST_SETTING 40 | ||
151 | #define MIN_CONTRAST_SETTING 5 | ||
152 | #define MAX_CONTRAST_SETTING 63 | ||
153 | #define DEFAULT_REMOTE_CONTRAST_SETTING 42 | ||
154 | #define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING | ||
155 | #define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING | ||
156 | |||
148 | /* Define this for S/PDIF input available */ | 157 | /* Define this for S/PDIF input available */ |
149 | #define HAVE_SPDIF_IN | 158 | #define HAVE_SPDIF_IN |
150 | 159 | ||
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h index 21451dcdac..1476102100 100644 --- a/firmware/export/config-h120.h +++ b/firmware/export/config-h120.h | |||
@@ -1,3 +1,4 @@ | |||
1 | #define TARGET_TREE /* this target is using the target tree system */ | ||
1 | /* | 2 | /* |
2 | * This config file is for iriver H120 and H140 | 3 | * This config file is for iriver H120 and H140 |
3 | */ | 4 | */ |
@@ -142,6 +143,13 @@ | |||
142 | 143 | ||
143 | #endif /* !SIMULATOR */ | 144 | #endif /* !SIMULATOR */ |
144 | 145 | ||
146 | #define DEFAULT_CONTRAST_SETTING 40 | ||
147 | #define MIN_CONTRAST_SETTING 5 | ||
148 | #define MAX_CONTRAST_SETTING 63 | ||
149 | #define DEFAULT_REMOTE_CONTRAST_SETTING 42 | ||
150 | #define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING | ||
151 | #define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING | ||
152 | |||
145 | /* Define this for S/PDIF input available */ | 153 | /* Define this for S/PDIF input available */ |
146 | #define HAVE_SPDIF_IN | 154 | #define HAVE_SPDIF_IN |
147 | 155 | ||
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index c9aad436f1..31f0f6729f 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h | |||
@@ -1,3 +1,4 @@ | |||
1 | #define TARGET_TREE /* this target is using the target tree system */ | ||
1 | /* | 2 | /* |
2 | * This config file is for iriver H320, H340 | 3 | * This config file is for iriver H320, H340 |
3 | */ | 4 | */ |
@@ -144,8 +145,15 @@ | |||
144 | #define HAVE_EEPROM | 145 | #define HAVE_EEPROM |
145 | 146 | ||
146 | #endif /* SIMULATOR */ | 147 | #endif /* SIMULATOR */ |
147 | 148 | /* Main LCD contrast range and defaults */ | |
148 | #define DEFAULT_REMOTE_CONTRAST_SETTING 42 | 149 | #define MIN_CONTRAST_SETTING 5 |
150 | #define MAX_CONTRAST_SETTING 63 | ||
151 | #define DEFAULT_CONTRAST_SETTING 40 | ||
152 | |||
153 | /* Remote LCD contrast range and defaults */ | ||
154 | #define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING | ||
155 | #define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING | ||
156 | #define DEFAULT_REMOTE_CONTRAST_SETTING 42 | ||
149 | 157 | ||
150 | /* Define this for FM radio input available */ | 158 | /* Define this for FM radio input available */ |
151 | #define HAVE_FMRADIO_IN | 159 | #define HAVE_FMRADIO_IN |
diff --git a/firmware/system.c b/firmware/system.c index c597fc5995..4dbc41b515 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -376,7 +376,7 @@ void system_init(void) | |||
376 | /* IRQ12 SIO INT */ | 376 | /* IRQ12 SIO INT */ |
377 | /* IRQ13 IIS0 INT */ | 377 | /* IRQ13 IIS0 INT */ |
378 | /* IRQ14 IIS1 INT */ | 378 | /* IRQ14 IIS1 INT */ |
379 | /* IRQ15 */ | 379 | /* IRQ15 */ |
380 | 380 | ||
381 | extra_init(); | 381 | extra_init(); |
382 | } | 382 | } |
@@ -667,115 +667,8 @@ int system_memory_guard(int newmode) | |||
667 | return oldmode; | 667 | return oldmode; |
668 | } | 668 | } |
669 | 669 | ||
670 | #ifndef TARGET_TREE | 670 | /* void set_cpu_frequency(long frequency) is in |
671 | #if MEM < 32 | 671 | target tree for all 3 coldfire targets */ |
672 | #define MAX_REFRESH_TIMER 59 | ||
673 | #define NORMAL_REFRESH_TIMER 21 | ||
674 | #define DEFAULT_REFRESH_TIMER 4 | ||
675 | #else | ||
676 | #define MAX_REFRESH_TIMER 29 | ||
677 | #define NORMAL_REFRESH_TIMER 10 | ||
678 | #define DEFAULT_REFRESH_TIMER 1 | ||
679 | #endif | ||
680 | |||
681 | #ifdef IRIVER_H300_SERIES | ||
682 | #define RECALC_DELAYS(f) \ | ||
683 | pcf50606_i2c_recalc_delay(f) | ||
684 | #else | ||
685 | #define RECALC_DELAYS(f) | ||
686 | #endif | ||
687 | |||
688 | #ifdef HAVE_SERIAL | ||
689 | #define BAUD_RATE 57600 | ||
690 | #define BAUDRATE_DIV_DEFAULT (CPUFREQ_DEFAULT/(BAUD_RATE*32*2)) | ||
691 | #define BAUDRATE_DIV_NORMAL (CPUFREQ_NORMAL/(BAUD_RATE*32*2)) | ||
692 | #define BAUDRATE_DIV_MAX (CPUFREQ_MAX/(BAUD_RATE*32*2)) | ||
693 | #endif | ||
694 | |||
695 | void set_cpu_frequency (long) __attribute__ ((section (".icode"))); | ||
696 | void set_cpu_frequency(long frequency) | ||
697 | { | ||
698 | switch(frequency) | ||
699 | { | ||
700 | case CPUFREQ_MAX: | ||
701 | DCR = (0x8200 | DEFAULT_REFRESH_TIMER); | ||
702 | /* Refresh timer for bypass frequency */ | ||
703 | PLLCR &= ~1; /* Bypass mode */ | ||
704 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); | ||
705 | RECALC_DELAYS(CPUFREQ_MAX); | ||
706 | PLLCR = 0x11c56005; | ||
707 | CSCR0 = 0x00001180; /* Flash: 4 wait states */ | ||
708 | CSCR1 = 0x00000980; /* LCD: 2 wait states */ | ||
709 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
710 | CSCR3 = 0x00002180; /* USBOTG: 8 wait states */ | ||
711 | #endif | ||
712 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
713 | This may take up to 10ms! */ | ||
714 | timers_adjust_prescale(CPUFREQ_MAX_MULT, true); | ||
715 | DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */ | ||
716 | cpu_frequency = CPUFREQ_MAX; | ||
717 | IDECONFIG1 = 0x10100000 | (1 << 13) | (2 << 10); | ||
718 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
719 | IDECONFIG2 = 0x40000 | (2 << 8); /* TA enable + CS2wait */ | ||
720 | |||
721 | #ifdef HAVE_SERIAL | ||
722 | UBG10 = BAUDRATE_DIV_MAX >> 8; | ||
723 | UBG20 = BAUDRATE_DIV_MAX & 0xff; | ||
724 | #endif | ||
725 | break; | ||
726 | |||
727 | case CPUFREQ_NORMAL: | ||
728 | DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; | ||
729 | /* Refresh timer for bypass frequency */ | ||
730 | PLLCR &= ~1; /* Bypass mode */ | ||
731 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); | ||
732 | RECALC_DELAYS(CPUFREQ_NORMAL); | ||
733 | PLLCR = 0x13c5e005; | ||
734 | CSCR0 = 0x00000580; /* Flash: 1 wait state */ | ||
735 | CSCR1 = 0x00000180; /* LCD: 0 wait states */ | ||
736 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
737 | CSCR3 = 0x00000580; /* USBOTG: 1 wait state */ | ||
738 | #endif | ||
739 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
740 | This may take up to 10ms! */ | ||
741 | timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true); | ||
742 | DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */ | ||
743 | cpu_frequency = CPUFREQ_NORMAL; | ||
744 | IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10); | ||
745 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
746 | IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ | ||
747 | |||
748 | #ifdef HAVE_SERIAL | ||
749 | UBG10 = BAUDRATE_DIV_NORMAL >> 8; | ||
750 | UBG20 = BAUDRATE_DIV_NORMAL & 0xff; | ||
751 | #endif | ||
752 | break; | ||
753 | default: | ||
754 | DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; | ||
755 | /* Refresh timer for bypass frequency */ | ||
756 | PLLCR &= ~1; /* Bypass mode */ | ||
757 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true); | ||
758 | RECALC_DELAYS(CPUFREQ_DEFAULT); | ||
759 | PLLCR = 0x10c00200; /* Power down PLL, but keep CLSEL and CRSEL */ | ||
760 | CSCR0 = 0x00000180; /* Flash: 0 wait states */ | ||
761 | CSCR1 = 0x00000180; /* LCD: 0 wait states */ | ||
762 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
763 | CSCR3 = 0x00000180; /* USBOTG: 0 wait states */ | ||
764 | #endif | ||
765 | DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */ | ||
766 | cpu_frequency = CPUFREQ_DEFAULT; | ||
767 | IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10); | ||
768 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
769 | IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ | ||
770 | |||
771 | #ifdef HAVE_SERIAL | ||
772 | UBG10 = BAUDRATE_DIV_DEFAULT >> 8; | ||
773 | UBG20 = BAUDRATE_DIV_DEFAULT & 0xff; | ||
774 | #endif | ||
775 | break; | ||
776 | } | ||
777 | } | ||
778 | #endif | ||
779 | 672 | ||
780 | #elif CONFIG_CPU == SH7034 | 673 | #elif CONFIG_CPU == SH7034 |
781 | #include "led.h" | 674 | #include "led.h" |
diff --git a/firmware/target/coldfire/iriver/ata-iriver.c b/firmware/target/coldfire/iriver/ata-iriver.c new file mode 100644 index 0000000000..82dae32a97 --- /dev/null +++ b/firmware/target/coldfire/iriver/ata-iriver.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | #include "pcf50606.h" | ||
26 | |||
27 | void ata_reset(void) | ||
28 | { | ||
29 | and_l(~0x00080000, &GPIO_OUT); | ||
30 | sleep(1); /* > 25us */ | ||
31 | |||
32 | or_l(0x00080000, &GPIO_OUT); | ||
33 | sleep(1); /* > 25us */ | ||
34 | } | ||
35 | |||
36 | void ata_enable(bool on) | ||
37 | { | ||
38 | if(on) | ||
39 | and_l(~0x0040000, &GPIO_OUT); | ||
40 | else | ||
41 | or_l(0x0040000, &GPIO_OUT); | ||
42 | |||
43 | or_l(0x00040000, &GPIO_ENABLE); | ||
44 | or_l(0x00040000, &GPIO_FUNCTION); | ||
45 | } | ||
46 | |||
47 | bool ata_is_coldstart(void) | ||
48 | { | ||
49 | return (GPIO_FUNCTION & 0x00080000) == 0; | ||
50 | } | ||
51 | |||
52 | void ata_device_init(void) | ||
53 | { | ||
54 | #ifdef HAVE_ATA_LED_CTRL | ||
55 | /* Enable disk LED & ISD chip power control */ | ||
56 | and_l(~0x0000240, &GPIO_OUT); | ||
57 | or_l(0x00000240, &GPIO_ENABLE); | ||
58 | or_l(0x00000200, &GPIO_FUNCTION); | ||
59 | #endif | ||
60 | |||
61 | /* ATA reset */ | ||
62 | or_l(0x00080000, &GPIO_OUT); | ||
63 | or_l(0x00080000, &GPIO_ENABLE); | ||
64 | or_l(0x00080000, &GPIO_FUNCTION); | ||
65 | |||
66 | } | ||
diff --git a/firmware/target/coldfire/iriver/ata-target.h b/firmware/target/coldfire/iriver/ata-target.h new file mode 100644 index 0000000000..1801a7d376 --- /dev/null +++ b/firmware/target/coldfire/iriver/ata-target.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef ATA_TARGET_H | ||
20 | #define ATA_TARGET_H | ||
21 | |||
22 | void ata_reset(void); | ||
23 | void ata_device_init(void); | ||
24 | bool ata_is_coldstart(void); | ||
25 | |||
26 | #endif | ||
diff --git a/firmware/target/coldfire/iriver/backlight-target.h b/firmware/target/coldfire/iriver/backlight-target.h new file mode 100644 index 0000000000..262650ae24 --- /dev/null +++ b/firmware/target/coldfire/iriver/backlight-target.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef BACKLIGHT_TARGET_H | ||
20 | #define BACKLIGHT_TARGET_H | ||
21 | |||
22 | void __backlight_on(void); | ||
23 | void __backlight_off(void); | ||
24 | void __remote_backlight_on(void); | ||
25 | void __remote_backlight_off(void); | ||
26 | |||
27 | #endif | ||
diff --git a/firmware/target/coldfire/iriver/h100/adc-h100.c b/firmware/target/coldfire/iriver/h100/adc-h100.c new file mode 100644 index 0000000000..b29a2247ad --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/adc-h100.c | |||
@@ -0,0 +1,117 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "adc.h" | ||
25 | static unsigned char adcdata[NUM_ADC_CHANNELS]; | ||
26 | |||
27 | |||
28 | #define CS_LO and_l(~0x80, &GPIO_OUT) | ||
29 | #define CS_HI or_l(0x80, &GPIO_OUT) | ||
30 | #define CLK_LO and_l(~0x00400000, &GPIO_OUT) | ||
31 | #define CLK_HI or_l(0x00400000, &GPIO_OUT) | ||
32 | #define DO (GPIO_READ & 0x80000000) | ||
33 | #define DI_LO and_l(~0x00200000, &GPIO_OUT) | ||
34 | #define DI_HI or_l(0x00200000, &GPIO_OUT) | ||
35 | |||
36 | /* delay loop */ | ||
37 | #define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0) | ||
38 | |||
39 | unsigned short adc_scan(int channel) | ||
40 | { | ||
41 | unsigned char data = 0; | ||
42 | int i; | ||
43 | |||
44 | CS_LO; | ||
45 | |||
46 | DI_HI; /* Start bit */ | ||
47 | DELAY; | ||
48 | CLK_HI; | ||
49 | DELAY; | ||
50 | CLK_LO; | ||
51 | |||
52 | DI_HI; /* Single channel */ | ||
53 | DELAY; | ||
54 | CLK_HI; | ||
55 | DELAY; | ||
56 | CLK_LO; | ||
57 | |||
58 | if(channel & 1) /* LSB of channel number */ | ||
59 | DI_HI; | ||
60 | else | ||
61 | DI_LO; | ||
62 | DELAY; | ||
63 | CLK_HI; | ||
64 | DELAY; | ||
65 | CLK_LO; | ||
66 | |||
67 | if(channel & 2) /* MSB of channel number */ | ||
68 | DI_HI; | ||
69 | else | ||
70 | DI_LO; | ||
71 | DELAY; | ||
72 | CLK_HI; | ||
73 | DELAY; | ||
74 | CLK_LO; | ||
75 | |||
76 | DELAY; | ||
77 | |||
78 | for(i = 0;i < 8;i++) /* 8 bits of data */ | ||
79 | { | ||
80 | CLK_HI; | ||
81 | DELAY; | ||
82 | CLK_LO; | ||
83 | DELAY; | ||
84 | data <<= 1; | ||
85 | data |= DO?1:0; | ||
86 | } | ||
87 | |||
88 | CS_HI; | ||
89 | |||
90 | adcdata[channel] = data; | ||
91 | |||
92 | return data; | ||
93 | } | ||
94 | unsigned short adc_read(int channel) | ||
95 | { | ||
96 | return adcdata[channel]; | ||
97 | } | ||
98 | |||
99 | static int adc_counter; | ||
100 | |||
101 | static void adc_tick(void) | ||
102 | { | ||
103 | if(++adc_counter == HZ) | ||
104 | { | ||
105 | adc_counter = 0; | ||
106 | adc_scan(ADC_BATTERY); | ||
107 | adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote | ||
108 | detection feels stable. */ | ||
109 | } | ||
110 | } | ||
111 | |||
112 | void adc_init(void) | ||
113 | { | ||
114 | adc_scan(ADC_BATTERY); | ||
115 | |||
116 | tick_add_task(adc_tick); | ||
117 | } | ||
diff --git a/firmware/target/coldfire/iriver/h100/adc-target.h b/firmware/target/coldfire/iriver/h100/adc-target.h new file mode 100644 index 0000000000..54e7bc936a --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/adc-target.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | /* for the iriver h1x0 */ | ||
20 | |||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 4 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | #define ADC_REMOTE 1 | ||
28 | #define ADC_BATTERY 2 | ||
29 | #define ADC_REMOTEDETECT 3 | ||
30 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
31 | |||
32 | /* ADC values for different remote control types */ | ||
33 | #define ADCVAL_H300_LCD_REMOTE 0x5E | ||
34 | #define ADCVAL_H100_LCD_REMOTE 0x96 | ||
35 | #define ADCVAL_H300_LCD_REMOTE_HOLD 0xCC | ||
36 | #define ADCVAL_H100_LCD_REMOTE_HOLD 0xEA | ||
37 | |||
38 | /* Force a scan now */ | ||
39 | unsigned short adc_scan(int channel); | ||
40 | |||
41 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/coldfire/iriver/h100/backlight-h100.c b/firmware/target/coldfire/iriver/h100/backlight-h100.c new file mode 100644 index 0000000000..8ceac8a6ff --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/backlight-h100.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "kernel.h" | ||
22 | #include "thread.h" | ||
23 | #include "system.h" | ||
24 | #include "backlight.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | void __backlight_on(void) | ||
28 | { | ||
29 | and_l(~0x00020000, &GPIO1_OUT); | ||
30 | } | ||
31 | |||
32 | void __backlight_off(void) | ||
33 | { | ||
34 | or_l(0x00020000, &GPIO1_OUT); | ||
35 | } | ||
36 | |||
37 | void __remote_backlight_on(void) | ||
38 | { | ||
39 | and_l(~0x00000800, &GPIO_OUT); | ||
40 | } | ||
41 | |||
42 | void __remote_backlight_off(void) | ||
43 | { | ||
44 | or_l(0x00000800, &GPIO_OUT); | ||
45 | } | ||
diff --git a/firmware/target/coldfire/iriver/h100/power-h100.c b/firmware/target/coldfire/iriver/h100/power-h100.c new file mode 100644 index 0000000000..0714ab2d3f --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/power-h100.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | |||
26 | |||
27 | #ifdef CONFIG_TUNER | ||
28 | |||
29 | static bool powered = false; | ||
30 | |||
31 | bool radio_powered(void) | ||
32 | { | ||
33 | return powered; | ||
34 | } | ||
35 | |||
36 | bool radio_power(bool status) | ||
37 | { | ||
38 | bool old_status = powered; | ||
39 | powered = status; | ||
40 | return old_status; | ||
41 | } | ||
42 | |||
43 | #endif /* #ifdef CONFIG_TUNER */ | ||
44 | |||
45 | #ifndef SIMULATOR | ||
46 | |||
47 | void power_init(void) | ||
48 | { | ||
49 | or_l(0x00080000, &GPIO1_OUT); | ||
50 | or_l(0x00080000, &GPIO1_ENABLE); | ||
51 | or_l(0x00080000, &GPIO1_FUNCTION); | ||
52 | |||
53 | #ifndef BOOTLOADER | ||
54 | /* The boot loader controls the power */ | ||
55 | ide_power_enable(true); | ||
56 | #endif | ||
57 | or_l(0x80000000, &GPIO_ENABLE); | ||
58 | or_l(0x80000000, &GPIO_FUNCTION); | ||
59 | #ifdef HAVE_SPDIF_POWER | ||
60 | spdif_power_enable(false); | ||
61 | #endif | ||
62 | } | ||
63 | |||
64 | |||
65 | bool charger_inserted(void) | ||
66 | { | ||
67 | return (GPIO1_READ & 0x00400000)?true:false; | ||
68 | } | ||
69 | /* Returns true if the unit is charging the batteries. */ | ||
70 | bool charging_state(void) { | ||
71 | return charger_inserted(); | ||
72 | } | ||
73 | |||
74 | #ifdef HAVE_SPDIF_POWER | ||
75 | void spdif_power_enable(bool on) | ||
76 | { | ||
77 | or_l(0x01000000, &GPIO1_FUNCTION); | ||
78 | or_l(0x01000000, &GPIO1_ENABLE); | ||
79 | |||
80 | #ifdef SPDIF_POWER_INVERTED | ||
81 | if(!on) | ||
82 | #else | ||
83 | if(on) | ||
84 | #endif | ||
85 | and_l(~0x01000000, &GPIO1_OUT); | ||
86 | else | ||
87 | or_l(0x01000000, &GPIO1_OUT); | ||
88 | } | ||
89 | #endif | ||
90 | |||
91 | void ide_power_enable(bool on) | ||
92 | { | ||
93 | if(on) | ||
94 | and_l(~0x80000000, &GPIO_OUT); | ||
95 | else | ||
96 | or_l(0x80000000, &GPIO_OUT); | ||
97 | } | ||
98 | |||
99 | |||
100 | bool ide_powered(void) | ||
101 | { | ||
102 | return (GPIO_OUT & 0x80000000)?false:true; | ||
103 | } | ||
104 | |||
105 | |||
106 | void power_off(void) | ||
107 | { | ||
108 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
109 | and_l(~0x00080000, &GPIO1_OUT); | ||
110 | asm("halt"); | ||
111 | while(1) | ||
112 | yield(); | ||
113 | } | ||
114 | |||
115 | #else | ||
116 | |||
117 | bool charger_inserted(void) | ||
118 | { | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | void charger_enable(bool on) | ||
123 | { | ||
124 | (void)on; | ||
125 | } | ||
126 | |||
127 | void power_off(void) | ||
128 | { | ||
129 | } | ||
130 | |||
131 | void ide_power_enable(bool on) | ||
132 | { | ||
133 | (void)on; | ||
134 | } | ||
135 | |||
136 | #ifdef HAVE_SPDIF_POWER | ||
137 | void spdif_power_enable(bool on) | ||
138 | { | ||
139 | (void)on; | ||
140 | } | ||
141 | #endif | ||
142 | |||
143 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/coldfire/iriver/h100/usb-h100.c b/firmware/target/coldfire/iriver/h100/usb-h100.c new file mode 100644 index 0000000000..3b00e967da --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/usb-h100.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include <stdbool.h> | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "kernel.h" | ||
24 | |||
25 | void usb_init_device(void) | ||
26 | { | ||
27 | or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */ | ||
28 | and_l(~0x01000040, &GPIO_OUT); /* GPIO24 is the Cypress chip power */ | ||
29 | or_l(0x01000040, &GPIO_ENABLE); | ||
30 | or_l(0x01000040, &GPIO_FUNCTION); | ||
31 | } | ||
32 | |||
33 | bool usb_detect(void) | ||
34 | { | ||
35 | return (GPIO1_READ & 0x80)?true:false; | ||
36 | } | ||
37 | |||
38 | void usb_enable(bool on) | ||
39 | { | ||
40 | if(on) | ||
41 | { | ||
42 | /* Power on the Cypress chip */ | ||
43 | or_l(0x01000040, &GPIO_OUT); | ||
44 | sleep(2); | ||
45 | } | ||
46 | else | ||
47 | { | ||
48 | /* Power off the Cypress chip */ | ||
49 | and_l(~0x01000040, &GPIO_OUT); | ||
50 | } | ||
51 | } | ||
diff --git a/firmware/target/coldfire/iriver/h300/adc-h300.c b/firmware/target/coldfire/iriver/h300/adc-h300.c new file mode 100644 index 0000000000..31702eaef1 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/adc-h300.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "adc.h" | ||
25 | #include "pcf50606.h" | ||
26 | |||
27 | static unsigned char adcdata[NUM_ADC_CHANNELS]; | ||
28 | |||
29 | static int adcc2_parms[] = | ||
30 | { | ||
31 | [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ | ||
32 | [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */ | ||
33 | [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */ | ||
34 | [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* ADCIN1, resistive divider */ | ||
35 | }; | ||
36 | |||
37 | unsigned short adc_scan(int channel) | ||
38 | { | ||
39 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
40 | unsigned char data; | ||
41 | |||
42 | pcf50606_write(0x2f, adcc2_parms[channel]); | ||
43 | data = pcf50606_read(0x30); | ||
44 | |||
45 | adcdata[channel] = data; | ||
46 | |||
47 | set_irq_level(level); | ||
48 | return data; | ||
49 | } | ||
50 | |||
51 | |||
52 | unsigned short adc_read(int channel) | ||
53 | { | ||
54 | return adcdata[channel]; | ||
55 | } | ||
56 | |||
57 | static int adc_counter; | ||
58 | |||
59 | static void adc_tick(void) | ||
60 | { | ||
61 | if(++adc_counter == HZ) | ||
62 | { | ||
63 | adc_counter = 0; | ||
64 | adc_scan(ADC_BATTERY); | ||
65 | adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote | ||
66 | detection feels stable. */ | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void adc_init(void) | ||
71 | { | ||
72 | or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS | ||
73 | GPIO21: Data In (to the ADC) | ||
74 | GPIO22: CLK | ||
75 | GPIO31: Data Out (from the ADC) */ | ||
76 | or_l(0x00600080, &GPIO_ENABLE); | ||
77 | or_l(0x80, &GPIO_OUT); /* CS high */ | ||
78 | and_l(~0x00400000, &GPIO_OUT); /* CLK low */ | ||
79 | |||
80 | adc_scan(ADC_BATTERY); | ||
81 | |||
82 | tick_add_task(adc_tick); | ||
83 | } | ||
diff --git a/firmware/target/coldfire/iriver/h300/adc-target.h b/firmware/target/coldfire/iriver/h300/adc-target.h new file mode 100644 index 0000000000..04200904a2 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/adc-target.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | /* for the iriver h3x0 */ | ||
20 | |||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 4 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | #define ADC_REMOTE 1 | ||
28 | #define ADC_BATTERY 2 | ||
29 | #define ADC_REMOTEDETECT 3 | ||
30 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
31 | |||
32 | /* ADC values for different remote control types */ | ||
33 | #define ADCVAL_H300_LCD_REMOTE 0x35 | ||
34 | #define ADCVAL_H100_LCD_REMOTE 0x54 | ||
35 | #define ADCVAL_H300_LCD_REMOTE_HOLD 0x72 | ||
36 | #define ADCVAL_H100_LCD_REMOTE_HOLD 0x83 | ||
37 | |||
38 | /* Force a scan now */ | ||
39 | unsigned short adc_scan(int channel); | ||
40 | |||
41 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/coldfire/iriver/h300/backlight-h300.c b/firmware/target/coldfire/iriver/h300/backlight-h300.c new file mode 100644 index 0000000000..d5322c2cf7 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/backlight-h300.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "kernel.h" | ||
22 | #include "thread.h" | ||
23 | #include "system.h" | ||
24 | #include "backlight.h" | ||
25 | #include "pcf50606.h" | ||
26 | #include "lcd.h" | ||
27 | |||
28 | void __backlight_on(void) | ||
29 | { | ||
30 | lcd_enable(true); | ||
31 | sleep(HZ/100); /* lcd needs time - avoid flashing for dark screens */ | ||
32 | or_l(0x00020000, &GPIO1_OUT); | ||
33 | } | ||
34 | |||
35 | void __backlight_off(void) | ||
36 | { | ||
37 | and_l(~0x00020000, &GPIO1_OUT); | ||
38 | lcd_enable(false); | ||
39 | } | ||
40 | |||
41 | void __remote_backlight_on(void) | ||
42 | { | ||
43 | and_l(~0x00000002, &GPIO1_OUT); | ||
44 | } | ||
45 | |||
46 | void __remote_backlight_off(void) | ||
47 | { | ||
48 | or_l(0x00000002, &GPIO1_OUT); | ||
49 | } | ||
diff --git a/firmware/target/coldfire/iriver/h300/power-h300.c b/firmware/target/coldfire/iriver/h300/power-h300.c new file mode 100644 index 0000000000..7c95aaf200 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/power-h300.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | #include "pcf50606.h" | ||
26 | |||
27 | |||
28 | #ifdef CONFIG_TUNER | ||
29 | |||
30 | static bool powered = false; | ||
31 | |||
32 | bool radio_powered(void) | ||
33 | { | ||
34 | return powered; | ||
35 | } | ||
36 | |||
37 | bool radio_power(bool status) | ||
38 | { | ||
39 | bool old_status = powered; | ||
40 | powered = status; | ||
41 | return old_status; | ||
42 | } | ||
43 | |||
44 | #endif /* #ifdef CONFIG_TUNER */ | ||
45 | |||
46 | #ifndef SIMULATOR | ||
47 | |||
48 | void power_init(void) | ||
49 | { | ||
50 | or_l(0x00080000, &GPIO1_OUT); | ||
51 | or_l(0x00080000, &GPIO1_ENABLE); | ||
52 | or_l(0x00080000, &GPIO1_FUNCTION); | ||
53 | |||
54 | #ifndef BOOTLOADER | ||
55 | /* The boot loader controls the power */ | ||
56 | ide_power_enable(true); | ||
57 | #endif | ||
58 | or_l(0x80000000, &GPIO_ENABLE); | ||
59 | or_l(0x80000000, &GPIO_FUNCTION); | ||
60 | pcf50606_init(); | ||
61 | } | ||
62 | |||
63 | |||
64 | #ifdef CONFIG_CHARGING | ||
65 | bool charger_inserted(void) | ||
66 | { | ||
67 | return (GPIO1_READ & 0x00400000)?true:false; | ||
68 | } | ||
69 | #endif /* CONFIG_CHARGING */ | ||
70 | |||
71 | /* Returns true if the unit is charging the batteries. */ | ||
72 | bool charging_state(void) { | ||
73 | return (GPIO_READ & 0x00800000)?true:false; | ||
74 | } | ||
75 | |||
76 | |||
77 | void ide_power_enable(bool on) | ||
78 | { | ||
79 | if(on) | ||
80 | and_l(~0x80000000, &GPIO_OUT); | ||
81 | else | ||
82 | or_l(0x80000000, &GPIO_OUT); | ||
83 | } | ||
84 | |||
85 | |||
86 | bool ide_powered(void) | ||
87 | { | ||
88 | return (GPIO_OUT & 0x80000000)?false:true; | ||
89 | } | ||
90 | |||
91 | |||
92 | void power_off(void) | ||
93 | { | ||
94 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
95 | and_l(~0x00080000, &GPIO1_OUT); | ||
96 | asm("halt"); | ||
97 | while(1) | ||
98 | yield(); | ||
99 | } | ||
100 | |||
101 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/coldfire/iriver/h300/usb-h300.c b/firmware/target/coldfire/iriver/h300/usb-h300.c new file mode 100644 index 0000000000..d08cc24dba --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/usb-h300.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include <stdbool.h> | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "kernel.h" | ||
24 | |||
25 | void usb_init_device(void) | ||
26 | { | ||
27 | or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */ | ||
28 | /* ISD300 3.3V ON */ | ||
29 | or_l(8,&GPIO1_FUNCTION); | ||
30 | or_l(8,&GPIO1_OUT); | ||
31 | or_l(8,&GPIO1_ENABLE); | ||
32 | |||
33 | /* Tristate the SCK/SDA to the ISD300 config EEPROM */ | ||
34 | and_l(~0x03000000, &GPIO_ENABLE); | ||
35 | or_l(0x03000000, &GPIO_FUNCTION); | ||
36 | } | ||
37 | |||
38 | bool usb_detect(void) | ||
39 | { | ||
40 | return (GPIO1_READ & 0x80)?true:false; | ||
41 | } | ||
42 | |||
43 | void usb_enable(bool on) | ||
44 | { | ||
45 | if(on) | ||
46 | { | ||
47 | /* Power on the Cypress chip */ | ||
48 | and_l(~0x00000008,&GPIO1_OUT); | ||
49 | sleep(2); | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | /* Power off the Cypress chip */ | ||
54 | or_l(0x00000008,&GPIO1_OUT); | ||
55 | } | ||
56 | } | ||
diff --git a/firmware/target/coldfire/iriver/system-iriver.c b/firmware/target/coldfire/iriver/system-iriver.c new file mode 100644 index 0000000000..5f404fb8cf --- /dev/null +++ b/firmware/target/coldfire/iriver/system-iriver.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "kernel.h" | ||
22 | #include "system.h" | ||
23 | #include "power.h" | ||
24 | #include "timer.h" | ||
25 | #include "pcf50606.h" | ||
26 | |||
27 | #if MEM < 32 | ||
28 | #define MAX_REFRESH_TIMER 59 | ||
29 | #define NORMAL_REFRESH_TIMER 21 | ||
30 | #define DEFAULT_REFRESH_TIMER 4 | ||
31 | #else | ||
32 | #define MAX_REFRESH_TIMER 29 | ||
33 | #define NORMAL_REFRESH_TIMER 10 | ||
34 | #define DEFAULT_REFRESH_TIMER 1 | ||
35 | #endif | ||
36 | |||
37 | #ifdef IRIVER_H300_SERIES | ||
38 | #define RECALC_DELAYS(f) \ | ||
39 | pcf50606_i2c_recalc_delay(f) | ||
40 | #else | ||
41 | #define RECALC_DELAYS(f) | ||
42 | #endif | ||
43 | |||
44 | #ifdef HAVE_SERIAL | ||
45 | #define BAUD_RATE 57600 | ||
46 | #define BAUDRATE_DIV_DEFAULT (CPUFREQ_DEFAULT/(BAUD_RATE*32*2)) | ||
47 | #define BAUDRATE_DIV_NORMAL (CPUFREQ_NORMAL/(BAUD_RATE*32*2)) | ||
48 | #define BAUDRATE_DIV_MAX (CPUFREQ_MAX/(BAUD_RATE*32*2)) | ||
49 | #endif | ||
50 | |||
51 | void set_cpu_frequency (long) __attribute__ ((section (".icode"))); | ||
52 | void set_cpu_frequency(long frequency) | ||
53 | { | ||
54 | switch(frequency) | ||
55 | { | ||
56 | case CPUFREQ_MAX: | ||
57 | DCR = (0x8200 | DEFAULT_REFRESH_TIMER); | ||
58 | /* Refresh timer for bypass frequency */ | ||
59 | PLLCR &= ~1; /* Bypass mode */ | ||
60 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); | ||
61 | RECALC_DELAYS(CPUFREQ_MAX); | ||
62 | PLLCR = 0x11c56005; | ||
63 | CSCR0 = 0x00001180; /* Flash: 4 wait states */ | ||
64 | CSCR1 = 0x00000980; /* LCD: 2 wait states */ | ||
65 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
66 | CSCR3 = 0x00002180; /* USBOTG: 8 wait states */ | ||
67 | #endif | ||
68 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
69 | This may take up to 10ms! */ | ||
70 | timers_adjust_prescale(CPUFREQ_MAX_MULT, true); | ||
71 | DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */ | ||
72 | cpu_frequency = CPUFREQ_MAX; | ||
73 | IDECONFIG1 = 0x10100000 | (1 << 13) | (2 << 10); | ||
74 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
75 | IDECONFIG2 = 0x40000 | (2 << 8); /* TA enable + CS2wait */ | ||
76 | |||
77 | #ifdef HAVE_SERIAL | ||
78 | UBG10 = BAUDRATE_DIV_MAX >> 8; | ||
79 | UBG20 = BAUDRATE_DIV_MAX & 0xff; | ||
80 | #endif | ||
81 | break; | ||
82 | |||
83 | case CPUFREQ_NORMAL: | ||
84 | DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; | ||
85 | /* Refresh timer for bypass frequency */ | ||
86 | PLLCR &= ~1; /* Bypass mode */ | ||
87 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); | ||
88 | RECALC_DELAYS(CPUFREQ_NORMAL); | ||
89 | PLLCR = 0x13c5e005; | ||
90 | CSCR0 = 0x00000580; /* Flash: 1 wait state */ | ||
91 | CSCR1 = 0x00000180; /* LCD: 0 wait states */ | ||
92 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
93 | CSCR3 = 0x00000580; /* USBOTG: 1 wait state */ | ||
94 | #endif | ||
95 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
96 | This may take up to 10ms! */ | ||
97 | timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true); | ||
98 | DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */ | ||
99 | cpu_frequency = CPUFREQ_NORMAL; | ||
100 | IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10); | ||
101 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
102 | IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ | ||
103 | |||
104 | #ifdef HAVE_SERIAL | ||
105 | UBG10 = BAUDRATE_DIV_NORMAL >> 8; | ||
106 | UBG20 = BAUDRATE_DIV_NORMAL & 0xff; | ||
107 | #endif | ||
108 | break; | ||
109 | default: | ||
110 | DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; | ||
111 | /* Refresh timer for bypass frequency */ | ||
112 | PLLCR &= ~1; /* Bypass mode */ | ||
113 | timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true); | ||
114 | RECALC_DELAYS(CPUFREQ_DEFAULT); | ||
115 | PLLCR = 0x10c00200; /* Power down PLL, but keep CLSEL and CRSEL */ | ||
116 | CSCR0 = 0x00000180; /* Flash: 0 wait states */ | ||
117 | CSCR1 = 0x00000180; /* LCD: 0 wait states */ | ||
118 | #if CONFIG_USBOTG == USBOTG_ISP1362 | ||
119 | CSCR3 = 0x00000180; /* USBOTG: 0 wait states */ | ||
120 | #endif | ||
121 | DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */ | ||
122 | cpu_frequency = CPUFREQ_DEFAULT; | ||
123 | IDECONFIG1 = 0x10100000 | (0 << 13) | (1 << 10); | ||
124 | /* SRE active on write (H300 USBOTG) | BUFEN2 enable | CS2Post | CS2Pre */ | ||
125 | IDECONFIG2 = 0x40000 | (0 << 8); /* TA enable + CS2wait */ | ||
126 | |||
127 | #ifdef HAVE_SERIAL | ||
128 | UBG10 = BAUDRATE_DIV_DEFAULT >> 8; | ||
129 | UBG20 = BAUDRATE_DIV_DEFAULT & 0xff; | ||
130 | #endif | ||
131 | break; | ||
132 | } | ||
133 | } | ||
diff --git a/firmware/target/coldfire/iriver/usb-target.h b/firmware/target/coldfire/iriver/usb-target.h new file mode 100644 index 0000000000..ab8cac6f99 --- /dev/null +++ b/firmware/target/coldfire/iriver/usb-target.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef USB_TARGET_H | ||
20 | #define USB_TARGET_H | ||
21 | |||
22 | bool usb_init_device(void); | ||
23 | |||
24 | #endif | ||
diff --git a/firmware/usb.c b/firmware/usb.c index f83cb44e17..a0ffef1011 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -155,26 +155,6 @@ void usb_enable(bool on) | |||
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
158 | #elif defined(USB_IRIVERSTYLE) | ||
159 | if(on) | ||
160 | { | ||
161 | /* Power on the Cypress chip */ | ||
162 | #ifdef IRIVER_H100_SERIES | ||
163 | or_l(0x01000040, &GPIO_OUT); | ||
164 | #else | ||
165 | and_l(~0x00000008,&GPIO1_OUT); | ||
166 | #endif | ||
167 | sleep(2); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | /* Power off the Cypress chip */ | ||
172 | #ifdef IRIVER_H100_SERIES | ||
173 | and_l(~0x01000040, &GPIO_OUT); | ||
174 | #else | ||
175 | or_l(0x00000008,&GPIO1_OUT); | ||
176 | #endif | ||
177 | } | ||
178 | #elif defined(USB_ISP1582) | 158 | #elif defined(USB_ISP1582) |
179 | /* TODO: Implement USB_ISP1582 */ | 159 | /* TODO: Implement USB_ISP1582 */ |
180 | (void) on; | 160 | (void) on; |
@@ -391,9 +371,6 @@ bool usb_detect(void) | |||
391 | #ifdef USB_PLAYERSTYLE | 371 | #ifdef USB_PLAYERSTYLE |
392 | current_status = (PADR & 0x8000)?false:true; | 372 | current_status = (PADR & 0x8000)?false:true; |
393 | #endif | 373 | #endif |
394 | #ifdef USB_IRIVERSTYLE | ||
395 | current_status = (GPIO1_READ & 0x80)?true:false; | ||
396 | #endif | ||
397 | #ifdef USB_GMINISTYLE | 374 | #ifdef USB_GMINISTYLE |
398 | current_status = (P5 & 0x10)?true:false; | 375 | current_status = (P5 & 0x10)?true:false; |
399 | #endif | 376 | #endif |
@@ -481,24 +458,6 @@ void usb_init(void) | |||
481 | 458 | ||
482 | #ifdef TARGET_TREE | 459 | #ifdef TARGET_TREE |
483 | usb_init_device(); | 460 | usb_init_device(); |
484 | #elif defined USB_IRIVERSTYLE | ||
485 | or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */ | ||
486 | |||
487 | #ifdef IRIVER_H300_SERIES | ||
488 | /* ISD300 3.3V ON */ | ||
489 | or_l(8,&GPIO1_FUNCTION); | ||
490 | or_l(8,&GPIO1_OUT); | ||
491 | or_l(8,&GPIO1_ENABLE); | ||
492 | |||
493 | /* Tristate the SCK/SDA to the ISD300 config EEPROM */ | ||
494 | and_l(~0x03000000, &GPIO_ENABLE); | ||
495 | or_l(0x03000000, &GPIO_FUNCTION); | ||
496 | #else | ||
497 | and_l(~0x01000040, &GPIO_OUT); /* GPIO24 is the Cypress chip power */ | ||
498 | or_l(0x01000040, &GPIO_ENABLE); | ||
499 | or_l(0x01000040, &GPIO_FUNCTION); | ||
500 | #endif | ||
501 | |||
502 | #endif | 461 | #endif |
503 | 462 | ||
504 | usb_enable(false); | 463 | usb_enable(false); |