1 |
/* |
/* |
2 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_ohci.c,v 1.4 2005/04/11 22:58:46 debug Exp $ |
* $Id: dev_ohci.c,v 1.10 2007/01/28 00:41:17 debug Exp $ |
29 |
* |
* |
30 |
* USB OHCI (Open Host Controller Interface). |
* USB OHCI (Open Host Controller Interface). |
31 |
* |
* |
38 |
|
|
39 |
#include "cpu.h" |
#include "cpu.h" |
40 |
#include "device.h" |
#include "device.h" |
41 |
|
#include "interrupt.h" |
42 |
#include "machine.h" |
#include "machine.h" |
43 |
#include "memory.h" |
#include "memory.h" |
44 |
#include "misc.h" |
#include "misc.h" |
54 |
|
|
55 |
|
|
56 |
struct ohci_data { |
struct ohci_data { |
57 |
int irq_nr; |
struct interrupt irq; |
58 |
|
|
59 |
int port1reset; |
int port1reset; |
60 |
}; |
}; |
61 |
|
|
62 |
|
|
63 |
/* |
/* |
64 |
* dev_ohci_access(): |
* dev_ohci_access(): |
65 |
*/ |
*/ |
66 |
int dev_ohci_access(struct cpu *cpu, struct memory *mem, |
DEVICE_ACCESS(ohci) |
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
67 |
{ |
{ |
68 |
struct ohci_data *d = extra; |
struct ohci_data *d = extra; |
69 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
70 |
char *name = NULL; |
char *name = NULL; |
71 |
|
|
72 |
idata = memory_readmax64(cpu, data, len); |
if (writeflag == MEM_WRITE) |
73 |
|
idata = memory_readmax64(cpu, data, len); |
74 |
|
|
75 |
switch (relative_addr) { |
switch (relative_addr) { |
76 |
case OHCI_REVISION: |
case OHCI_REVISION: |
83 |
name = "COMMAND_STATUS"; |
name = "COMMAND_STATUS"; |
84 |
if (idata == 0x2) { |
if (idata == 0x2) { |
85 |
fatal("URK\n"); |
fatal("URK\n"); |
86 |
cpu_interrupt(cpu, d->irq_nr); |
INTERRUPT_ASSERT(d->irq); |
87 |
} |
} |
88 |
break; |
break; |
89 |
case OHCI_INTERRUPT_STATUS: |
case OHCI_INTERRUPT_STATUS: |
150 |
} |
} |
151 |
|
|
152 |
|
|
153 |
/* |
DEVINIT(ohci) |
|
* devinit_ohci(): |
|
|
*/ |
|
|
int devinit_ohci(struct devinit *devinit) |
|
154 |
{ |
{ |
155 |
struct ohci_data *d; |
struct ohci_data *d; |
156 |
|
|
160 |
exit(1); |
exit(1); |
161 |
} |
} |
162 |
memset(d, 0, sizeof(struct ohci_data)); |
memset(d, 0, sizeof(struct ohci_data)); |
163 |
d->irq_nr = devinit->irq_nr; |
|
164 |
|
INTERRUPT_CONNECT(devinit->interrupt_path, d->irq); |
165 |
|
|
166 |
memory_device_register(devinit->machine->memory, |
memory_device_register(devinit->machine->memory, |
167 |
devinit->name, devinit->addr, |
devinit->name, devinit->addr, |
168 |
DEV_OHCI_LENGTH, dev_ohci_access, d, MEM_DEFAULT, NULL); |
DEV_OHCI_LENGTH, dev_ohci_access, d, DM_DEFAULT, NULL); |
169 |
|
|
170 |
return 1; |
return 1; |
171 |
} |
} |