* switch to PCI register IO

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29440 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2009-03-08 14:29:45 +00:00
parent 37a89eb4e9
commit 81201a4349
2 changed files with 14 additions and 36 deletions
@@ -42,6 +42,7 @@ enum {
struct geode_stream; struct geode_stream;
struct geode_multi; struct geode_multi;
extern pci_module_info* gPci;
/*! This structure describes a controller. /*! This structure describes a controller.
*/ */
@@ -50,8 +51,7 @@ struct geode_controller {
vint32 opened; vint32 opened;
const char* devfs_path; const char* devfs_path;
area_id regs_area; uint32 nabmbar;
vuint8* regs;
uint32 irq; uint32 irq;
uint32 num_streams; uint32 num_streams;
@@ -67,32 +67,32 @@ struct geode_controller {
uint8 Read8(uint32 reg) uint8 Read8(uint32 reg)
{ {
return *(regs + reg); return gPci->read_io_8(nabmbar + reg);
} }
uint16 Read16(uint32 reg) uint16 Read16(uint32 reg)
{ {
return *(vuint16*)(regs + reg); return gPci->read_io_16(nabmbar + reg);
} }
uint32 Read32(uint32 reg) uint32 Read32(uint32 reg)
{ {
return *(vuint32*)(regs + reg); return gPci->read_io_32(nabmbar + reg);
} }
void Write8(uint32 reg, uint8 value) void Write8(uint32 reg, uint8 value)
{ {
*(regs + reg) = value; gPci->write_io_8(nabmbar + reg, value);
} }
void Write16(uint32 reg, uint16 value) void Write16(uint32 reg, uint16 value)
{ {
*(vuint16*)(regs + reg) = value; gPci->write_io_16(nabmbar + reg, value);
} }
void Write32(uint32 reg, uint32 value) void Write32(uint32 reg, uint32 value)
{ {
*(vuint32*)(regs + reg) = value; gPci->write_io_32(nabmbar + reg, value);
} }
}; };
@@ -194,7 +194,6 @@ struct geode_multi {
/* driver.cpp */ /* driver.cpp */
extern device_hooks gDriverHooks; extern device_hooks gDriverHooks;
extern pci_module_info* gPci;
extern geode_controller gCards[MAX_CARDS]; extern geode_controller gCards[MAX_CARDS];
extern uint32 gNumCards; extern uint32 gNumCards;
@@ -59,7 +59,7 @@ geode_codec_read(geode_controller *controller, uint8 regno)
if (geode_codec_wait(controller) != B_OK) { if (geode_codec_wait(controller) != B_OK) {
dprintf("codec busy (2)\n"); dprintf("codec busy (2)\n");
return -1; return 0xffff;
} }
#define GCSCAUDIO_READ_CODEC_TIMEOUT 50 #define GCSCAUDIO_READ_CODEC_TIMEOUT 50
@@ -74,7 +74,7 @@ geode_codec_read(geode_controller *controller, uint8 regno)
if (i < 0) { if (i < 0) {
dprintf("codec busy (3)\n"); dprintf("codec busy (3)\n");
return -1; return 0xffff;
} }
return v; return v;
@@ -363,7 +363,7 @@ geode_stream_setup_buffers(geode_stream* stream, const char* desc)
bufferDescriptors->address = stream->physical_buffer_descriptors; bufferDescriptors->address = stream->physical_buffer_descriptors;
bufferDescriptors->ctrlsize = ACC_BMx_PRD_CTRL_JMP; bufferDescriptors->ctrlsize = ACC_BMx_PRD_CTRL_JMP;
for (uint32 index = 0; index < sizeof(kRates) / sizeof(kRates[0]); index++) { for (index = 0; index < sizeof(kRates) / sizeof(kRates[0]); index++) {
if (kRates[index].multi_rate == stream->sample_rate) { if (kRates[index].multi_rate == stream->sample_rate) {
stream->rate = kRates[index].rate; stream->rate = kRates[index].rate;
break; break;
@@ -391,16 +391,6 @@ geode_hw_init(geode_controller* controller)
uint16 cmd; uint16 cmd;
status_t status; status_t status;
/* Map MMIO registers */
controller->regs_area = map_physical_memory("geode_hw_regs",
(void*)controller->pci_info.u.h0.base_registers[0],
controller->pci_info.u.h0.base_register_sizes[0], B_ANY_KERNEL_ADDRESS,
0, (void**)&controller->regs);
if (controller->regs_area < B_OK) {
status = controller->regs_area;
goto error;
}
cmd = (gPci->read_pci_config)(controller->pci_info.bus, cmd = (gPci->read_pci_config)(controller->pci_info.bus,
controller->pci_info.device, controller->pci_info.function, PCI_command, 2); controller->pci_info.device, controller->pci_info.function, PCI_command, 2);
if (!(cmd & PCI_command_master)) { if (!(cmd & PCI_command_master)) {
@@ -410,12 +400,14 @@ geode_hw_init(geode_controller* controller)
dprintf("geode: enabling PCI bus mastering\n"); dprintf("geode: enabling PCI bus mastering\n");
} }
controller->nabmbar = controller->pci_info.u.h0.base_registers[0];
/* Absolute minimum hw is online; we can now install interrupt handler */ /* Absolute minimum hw is online; we can now install interrupt handler */
controller->irq = controller->pci_info.u.h0.interrupt_line; controller->irq = controller->pci_info.u.h0.interrupt_line;
status = install_io_interrupt_handler(controller->irq, status = install_io_interrupt_handler(controller->irq,
(interrupt_handler)geode_interrupt_handler, controller, 0); (interrupt_handler)geode_interrupt_handler, controller, 0);
if (status != B_OK) if (status != B_OK)
goto no_irq; goto error;
/* Get controller into valid state */ /* Get controller into valid state */
status = reset_controller(controller); status = reset_controller(controller);
@@ -444,12 +436,6 @@ geode_hw_init(geode_controller* controller)
reset_failed: reset_failed:
remove_io_interrupt_handler(controller->irq, remove_io_interrupt_handler(controller->irq,
(interrupt_handler)geode_interrupt_handler, controller); (interrupt_handler)geode_interrupt_handler, controller);
no_irq:
delete_area(controller->regs_area);
controller->regs_area = B_ERROR;
controller->regs = NULL;
error: error:
dprintf("geode: ERROR: %s(%ld)\n", strerror(status), status); dprintf("geode: ERROR: %s(%ld)\n", strerror(status), status);
@@ -486,13 +472,6 @@ geode_hw_uninit(geode_controller* controller)
remove_io_interrupt_handler(controller->irq, remove_io_interrupt_handler(controller->irq,
(interrupt_handler)geode_interrupt_handler, controller); (interrupt_handler)geode_interrupt_handler, controller);
/* Unmap registers */
if (controller->regs_area >= 0) {
delete_area(controller->regs_area);
controller->regs_area = B_ERROR;
controller->regs = NULL;
}
free(controller->multi); free(controller->multi);
geode_stream_delete(controller->playback_stream); geode_stream_delete(controller->playback_stream);