summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/adc.c129
-rw-r--r--firmware/drivers/ata.c16
2 files changed, 0 insertions, 145 deletions
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
112static unsigned char adcdata[NUM_ADC_CHANNELS];
113
114#ifdef IRIVER_H300_SERIES
115static 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
123unsigned 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
149unsigned 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
206unsigned short adc_read(int channel)
207{
208 return adcdata[channel];
209}
210
211static int adc_counter;
212
213static 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
224void 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