now uses pci module instead of read_io* and write_io*, untested

(hopes Marcus won't mind :))


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13533 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-07-07 13:59:14 +00:00
parent df95d6c124
commit ab8594e073
3 changed files with 34 additions and 34 deletions
@@ -35,6 +35,8 @@
#include "config.h" #include "config.h"
#include "ich.h" #include "ich.h"
extern pci_module_info *pci;
device_config c; device_config c;
device_config *config = &c; device_config *config = &c;
@@ -76,7 +78,6 @@ struct device_item {
status_t status_t
probe_device(void) probe_device(void)
{ {
pci_module_info *pcimodule;
struct pci_info info; struct pci_info info;
struct pci_info *pciinfo = &info; struct pci_info *pciinfo = &info;
int index; int index;
@@ -89,12 +90,7 @@ probe_device(void)
result = B_OK; result = B_OK;
if (get_module(B_PCI_MODULE_NAME,(module_info **)&pcimodule) < 0) { for (index = 0; B_OK == pci->get_nth_pci_info(index, pciinfo); index++) {
PRINT(("ERROR: couldn't load PCI module\n"));
return B_ERROR;
}
for (index = 0; B_OK == pcimodule->get_nth_pci_info(index, pciinfo); index++) {
LOG(("Checking PCI device, vendor 0x%04x, id 0x%04x, bus 0x%02x, dev 0x%02x, func 0x%02x, rev 0x%02x, api 0x%02x, sub 0x%02x, base 0x%02x\n", LOG(("Checking PCI device, vendor 0x%04x, id 0x%04x, bus 0x%02x, dev 0x%02x, func 0x%02x, rev 0x%02x, api 0x%02x, sub 0x%02x, base 0x%02x\n",
pciinfo->vendor_id, pciinfo->device_id, pciinfo->bus, pciinfo->device, pciinfo->function, pciinfo->vendor_id, pciinfo->device_id, pciinfo->bus, pciinfo->device, pciinfo->function,
pciinfo->revision, pciinfo->class_api, pciinfo->class_sub, pciinfo->class_base)); pciinfo->revision, pciinfo->class_api, pciinfo->class_sub, pciinfo->class_base));
@@ -135,12 +131,12 @@ probe_ok:
/* for ICH4 enable memory mapped IO and busmaster access, /* for ICH4 enable memory mapped IO and busmaster access,
* for old ICHs enable programmed IO and busmaster access * for old ICHs enable programmed IO and busmaster access
*/ */
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2); value = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2);
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
value |= PCI_PCICMD_MSE | PCI_PCICMD_BME; value |= PCI_PCICMD_MSE | PCI_PCICMD_BME;
else else
value |= PCI_PCICMD_IOS | PCI_PCICMD_BME; value |= PCI_PCICMD_IOS | PCI_PCICMD_BME;
pcimodule->write_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2, value); pci->write_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2, value);
#if DEBUG #if DEBUG
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2); value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2);
@@ -149,11 +145,11 @@ probe_ok:
/* read memory-io and port-io bars /* read memory-io and port-io bars
*/ */
config->nambar = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x10, 4); config->nambar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x10, 4);
config->nabmbar = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x14, 4); config->nabmbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x14, 4);
config->mmbar = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x18, 4); config->mmbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x18, 4);
config->mbbar = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x1C, 4); config->mbbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x1C, 4);
config->irq = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3C, 1); config->irq = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3C, 1);
if (config->irq == 0 || config->irq == 0xff) { if (config->irq == 0 || config->irq == 0xff) {
PRINT(("WARNING: no interrupt configured\n")); PRINT(("WARNING: no interrupt configured\n"));
@@ -182,6 +178,5 @@ probe_ok:
LOG(("irq = %d\n", config->irq)); LOG(("irq = %d\n", config->irq));
probe_done: probe_done:
put_module(B_PCI_MODULE_NAME);
return result; return result;
} }
@@ -32,6 +32,7 @@
#include <Drivers.h> #include <Drivers.h>
#include <Errors.h> #include <Errors.h>
#include <OS.h> #include <OS.h>
#include <PCI.h>
#include <malloc.h> #include <malloc.h>
#include "debug.h" #include "debug.h"
#include "config.h" #include "config.h"
@@ -42,6 +43,7 @@
#include "ac97.h" #include "ac97.h"
int32 api_version = B_CUR_DRIVER_API_VERSION; int32 api_version = B_CUR_DRIVER_API_VERSION;
pci_module_info *pci;
volatile bool int_thread_exit = false; volatile bool int_thread_exit = false;
thread_id int_thread_id = -1; thread_id int_thread_id = -1;
@@ -472,10 +474,14 @@ init_driver(void)
LOG(("init_driver\n")); LOG(("init_driver\n"));
ASSERT(sizeof(ich_bd) == 8); ASSERT(sizeof(ich_bd) == 8);
if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci))
return ENOSYS;
rv = probe_device(); rv = probe_device();
if (rv != B_OK) { if (rv != B_OK) {
LOG(("No supported audio hardware found.\n")); LOG(("No supported audio hardware found.\n"));
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -487,6 +493,7 @@ init_driver(void)
rv = map_io_memory(); rv = map_io_memory();
if (rv != B_OK) { if (rv != B_OK) {
PRINT(("mapping of memory IO space failed\n")); PRINT(("mapping of memory IO space failed\n"));
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -524,6 +531,7 @@ init_driver(void)
if (i == 20) { if (i == 20) {
LOG(("reset failed, ICH_REG_GLOB_CNT = 0x%08x\n", val)); LOG(("reset failed, ICH_REG_GLOB_CNT = 0x%08x\n", val));
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
LOG(("reset finished after %Ld, ICH_REG_GLOB_CNT = 0x%08x\n", system_time() - start, val)); LOG(("reset finished after %Ld, ICH_REG_GLOB_CNT = 0x%08x\n", system_time() - start, val));
@@ -563,6 +571,7 @@ init_driver(void)
if (!s0cr && !s1cr && !s2cr) { if (!s0cr && !s1cr && !s2cr) {
PRINT(("compatible chipset found, but no codec ready!\n")); PRINT(("compatible chipset found, but no codec ready!\n"));
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -622,6 +631,7 @@ init_driver(void)
PRINT(("couldn't allocate memory for channel descriptors!\n")); PRINT(("couldn't allocate memory for channel descriptors!\n"));
chan_free_resources(); chan_free_resources();
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -644,6 +654,7 @@ init_driver(void)
PRINT(("couldn't allocate memory for DMA buffers!\n")); PRINT(("couldn't allocate memory for DMA buffers!\n"));
chan_free_resources(); chan_free_resources();
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -656,6 +667,7 @@ init_driver(void)
PRINT(("couldn't create semaphores!\n")); PRINT(("couldn't create semaphores!\n"));
chan_free_resources(); chan_free_resources();
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
return B_ERROR; return B_ERROR;
} }
@@ -787,6 +799,8 @@ uninit_driver(void)
/* the very last thing to do is unmap the io memory */ /* the very last thing to do is unmap the io memory */
unmap_io_memory(); unmap_io_memory();
put_module(B_PCI_MODULE_NAME);
LOG(("uninit_driver() finished\n")); LOG(("uninit_driver() finished\n"));
} }
+10 -19
View File
@@ -27,22 +27,13 @@
*/ */
#include <KernelExport.h> #include <KernelExport.h>
#include <OS.h> #include <OS.h>
#include <PCI.h>
#include "debug.h" #include "debug.h"
#include "io.h" #include "io.h"
#include "ich.h" #include "ich.h"
#include "config.h" #include "config.h"
/* extern pci_module_info *pci;
* from BeOS R3 KernelExport.h
* should be replaced by PCI bus manager functions
*/
uint8 read_io_8(int mapped_io_addr);
void write_io_8(int mapped_io_addr, uint8 value);
uint16 read_io_16(int mapped_io_addr);
void write_io_16(int mapped_io_addr, uint16 value);
uint32 read_io_32(int mapped_io_addr);
void write_io_32(int mapped_io_addr, uint32 value);
status_t ich_codec_wait(void); status_t ich_codec_wait(void);
@@ -54,7 +45,7 @@ ich_reg_read_8(int regno)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
return *(uint8 *)(((char *)config->log_mbbar) + regno); return *(uint8 *)(((char *)config->log_mbbar) + regno);
else else
return read_io_8(config->nabmbar + regno); return pci->read_io_8(config->nabmbar + regno);
} }
uint16 uint16
@@ -65,7 +56,7 @@ ich_reg_read_16(int regno)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
return *(uint16 *)(((char *)config->log_mbbar) + regno); return *(uint16 *)(((char *)config->log_mbbar) + regno);
else else
return read_io_16(config->nabmbar + regno); return pci->read_io_16(config->nabmbar + regno);
} }
uint32 uint32
@@ -76,7 +67,7 @@ ich_reg_read_32(int regno)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
return *(uint32 *)(((char *)config->log_mbbar) + regno); return *(uint32 *)(((char *)config->log_mbbar) + regno);
else else
return read_io_32(config->nabmbar + regno); return pci->read_io_32(config->nabmbar + regno);
} }
void void
@@ -87,7 +78,7 @@ ich_reg_write_8(int regno, uint8 value)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
*(uint8 *)(((char *)config->log_mbbar) + regno) = value; *(uint8 *)(((char *)config->log_mbbar) + regno) = value;
else else
write_io_8(config->nabmbar + regno, value); pci->write_io_8(config->nabmbar + regno, value);
} }
void void
@@ -98,7 +89,7 @@ ich_reg_write_16(int regno, uint16 value)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
*(uint16 *)(((char *)config->log_mbbar) + regno) = value; *(uint16 *)(((char *)config->log_mbbar) + regno) = value;
else else
write_io_16(config->nabmbar + regno, value); pci->write_io_16(config->nabmbar + regno, value);
} }
void void
@@ -109,7 +100,7 @@ ich_reg_write_32(int regno, uint32 value)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
*(uint32 *)(((char *)config->log_mbbar) + regno) = value; *(uint32 *)(((char *)config->log_mbbar) + regno) = value;
else else
write_io_32(config->nabmbar + regno, value); pci->write_io_32(config->nabmbar + regno, value);
} }
status_t status_t
@@ -140,7 +131,7 @@ ich_codec_read(int regno)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
return *(uint16 *)(((char *)config->log_mmbar) + regno); return *(uint16 *)(((char *)config->log_mmbar) + regno);
else else
return read_io_16(config->nambar + regno); return pci->read_io_16(config->nambar + regno);
} }
void void
@@ -158,5 +149,5 @@ ich_codec_write(int regno, uint16 value)
if (config->type & TYPE_ICH4) if (config->type & TYPE_ICH4)
*(uint16 *)(((char *)config->log_mmbar) + regno) = value; *(uint16 *)(((char *)config->log_mmbar) + regno) = value;
else else
write_io_16(config->nambar + regno, value); pci->write_io_16(config->nambar + regno, value);
} }