25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_footbridge.c,v 1.55 2007/02/03 16:18:56 debug Exp $ |
* $Id: dev_footbridge.c,v 1.57 2007/06/15 19:11:15 debug Exp $ |
29 |
* |
* |
30 |
* Footbridge. Used in Netwinder and Cats. |
* COMMENT: DC21285 "Footbridge" controller; used in Netwinder and Cats |
31 |
* |
* |
32 |
* TODO: |
* TODO: |
33 |
* o) Add actual support for the fcom serial port. |
* o) Add actual support for the fcom serial port. |
125 |
|
|
126 |
|
|
127 |
/* |
/* |
|
* dev_footbridge_tick(): |
|
|
* |
|
128 |
* The 4 footbridge timers should decrease and cause interrupts. Periodic |
* The 4 footbridge timers should decrease and cause interrupts. Periodic |
129 |
* interrupts restart as soon as they are acknowledged, non-periodic |
* interrupts restart as soon as they are acknowledged, non-periodic |
130 |
* interrupts need to be "reloaded" to restart. |
* interrupts need to be "reloaded" to restart. |
132 |
* TODO: Hm. I thought I had solved this, but it didn't quite work. |
* TODO: Hm. I thought I had solved this, but it didn't quite work. |
133 |
* This needs to be re-checked against documentation, sometime. |
* This needs to be re-checked against documentation, sometime. |
134 |
*/ |
*/ |
135 |
void dev_footbridge_tick(struct cpu *cpu, void *extra) |
DEVICE_TICK(footbridge) |
136 |
{ |
{ |
137 |
|
struct footbridge_data *d = extra; |
138 |
int i; |
int i; |
|
struct footbridge_data *d = (struct footbridge_data *) extra; |
|
139 |
|
|
140 |
for (i=0; i<N_FOOTBRIDGE_TIMERS; i++) { |
for (i=0; i<N_FOOTBRIDGE_TIMERS; i++) { |
141 |
if (d->timer_control[i] & TIMER_ENABLE) { |
if (d->timer_control[i] & TIMER_ENABLE) { |
179 |
|
|
180 |
|
|
181 |
/* |
/* |
|
* dev_footbridge_isa_access(): |
|
|
* |
|
182 |
* Reading the byte at 0x79000000 is a quicker way to figure out which ISA |
* Reading the byte at 0x79000000 is a quicker way to figure out which ISA |
183 |
* interrupt has occurred (and acknowledging it at the same time), than |
* interrupt has occurred (and acknowledging it at the same time), than |
184 |
* dealing with the legacy 0x20/0xa0 ISA ports. |
* dealing with the legacy 0x20/0xa0 ISA ports. |
230 |
|
|
231 |
|
|
232 |
/* |
/* |
|
* dev_footbridge_pci_access(): |
|
|
* |
|
233 |
* The Footbridge PCI configuration space is implemented as a direct memory |
* The Footbridge PCI configuration space is implemented as a direct memory |
234 |
* space (i.e. not one port for addr and one port for data). This function |
* space (i.e. not one port for addr and one port for data). This function |
235 |
* translates that into bus_pci calls. |
* translates that into bus_pci calls. |
267 |
} |
} |
268 |
|
|
269 |
|
|
|
/* |
|
|
* dev_footbridge_access(): |
|
|
* |
|
|
* The DC21285 registers. |
|
|
*/ |
|
270 |
DEVICE_ACCESS(footbridge) |
DEVICE_ACCESS(footbridge) |
271 |
{ |
{ |
272 |
struct footbridge_data *d = extra; |
struct footbridge_data *d = extra; |
480 |
uint64_t pci_addr = 0x7b000000; |
uint64_t pci_addr = 0x7b000000; |
481 |
int i; |
int i; |
482 |
|
|
483 |
d = malloc(sizeof(struct footbridge_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct footbridge_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
484 |
memset(d, 0, sizeof(struct footbridge_data)); |
memset(d, 0, sizeof(struct footbridge_data)); |
485 |
|
|
486 |
/* Connect to the CPU which this footbridge will interrupt: */ |
/* Connect to the CPU which this footbridge will interrupt: */ |
579 |
d->timer_control[i] = TIMER_MODE_PERIODIC; |
d->timer_control[i] = TIMER_MODE_PERIODIC; |
580 |
d->timer_load[i] = TIMER_MAX_VAL; |
d->timer_load[i] = TIMER_MAX_VAL; |
581 |
} |
} |
582 |
|
|
583 |
machine_add_tickfunction(devinit->machine, |
machine_add_tickfunction(devinit->machine, |
584 |
dev_footbridge_tick, d, DEV_FOOTBRIDGE_TICK_SHIFT, 0.0); |
dev_footbridge_tick, d, DEV_FOOTBRIDGE_TICK_SHIFT); |
585 |
|
|
586 |
devinit->return_ptr = d->pcibus; |
devinit->return_ptr = d->pcibus; |
587 |
return 1; |
return 1; |