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:
@@ -35,6 +35,8 @@
|
||||
#include "config.h"
|
||||
#include "ich.h"
|
||||
|
||||
extern pci_module_info *pci;
|
||||
|
||||
device_config c;
|
||||
device_config *config = &c;
|
||||
|
||||
@@ -76,7 +78,6 @@ struct device_item {
|
||||
status_t
|
||||
probe_device(void)
|
||||
{
|
||||
pci_module_info *pcimodule;
|
||||
struct pci_info info;
|
||||
struct pci_info *pciinfo = &info;
|
||||
int index;
|
||||
@@ -89,12 +90,7 @@ probe_device(void)
|
||||
|
||||
result = B_OK;
|
||||
|
||||
if (get_module(B_PCI_MODULE_NAME,(module_info **)&pcimodule) < 0) {
|
||||
PRINT(("ERROR: couldn't load PCI module\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
for (index = 0; B_OK == pcimodule->get_nth_pci_info(index, pciinfo); index++) {
|
||||
for (index = 0; B_OK == pci->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",
|
||||
pciinfo->vendor_id, pciinfo->device_id, pciinfo->bus, pciinfo->device, pciinfo->function,
|
||||
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 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)
|
||||
value |= PCI_PCICMD_MSE | PCI_PCICMD_BME;
|
||||
else
|
||||
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
|
||||
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
|
||||
*/
|
||||
config->nambar = pcimodule->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->mmbar = pcimodule->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->irq = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3C, 1);
|
||||
config->nambar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x10, 4);
|
||||
config->nabmbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x14, 4);
|
||||
config->mmbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x18, 4);
|
||||
config->mbbar = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x1C, 4);
|
||||
config->irq = pci->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3C, 1);
|
||||
|
||||
if (config->irq == 0 || config->irq == 0xff) {
|
||||
PRINT(("WARNING: no interrupt configured\n"));
|
||||
@@ -182,6 +178,5 @@ probe_ok:
|
||||
LOG(("irq = %d\n", config->irq));
|
||||
|
||||
probe_done:
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <Drivers.h>
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <PCI.h>
|
||||
#include <malloc.h>
|
||||
#include "debug.h"
|
||||
#include "config.h"
|
||||
@@ -42,6 +43,7 @@
|
||||
#include "ac97.h"
|
||||
|
||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||
pci_module_info *pci;
|
||||
|
||||
volatile bool int_thread_exit = false;
|
||||
thread_id int_thread_id = -1;
|
||||
@@ -472,10 +474,14 @@ init_driver(void)
|
||||
LOG(("init_driver\n"));
|
||||
|
||||
ASSERT(sizeof(ich_bd) == 8);
|
||||
|
||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci))
|
||||
return ENOSYS;
|
||||
|
||||
rv = probe_device();
|
||||
if (rv != B_OK) {
|
||||
LOG(("No supported audio hardware found.\n"));
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -487,6 +493,7 @@ init_driver(void)
|
||||
rv = map_io_memory();
|
||||
if (rv != B_OK) {
|
||||
PRINT(("mapping of memory IO space failed\n"));
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -524,6 +531,7 @@ init_driver(void)
|
||||
if (i == 20) {
|
||||
LOG(("reset failed, ICH_REG_GLOB_CNT = 0x%08x\n", val));
|
||||
unmap_io_memory();
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
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) {
|
||||
PRINT(("compatible chipset found, but no codec ready!\n"));
|
||||
unmap_io_memory();
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -622,6 +631,7 @@ init_driver(void)
|
||||
PRINT(("couldn't allocate memory for channel descriptors!\n"));
|
||||
chan_free_resources();
|
||||
unmap_io_memory();
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -644,6 +654,7 @@ init_driver(void)
|
||||
PRINT(("couldn't allocate memory for DMA buffers!\n"));
|
||||
chan_free_resources();
|
||||
unmap_io_memory();
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -656,6 +667,7 @@ init_driver(void)
|
||||
PRINT(("couldn't create semaphores!\n"));
|
||||
chan_free_resources();
|
||||
unmap_io_memory();
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -787,6 +799,8 @@ uninit_driver(void)
|
||||
/* the very last thing to do is unmap the io memory */
|
||||
unmap_io_memory();
|
||||
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
|
||||
LOG(("uninit_driver() finished\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,22 +27,13 @@
|
||||
*/
|
||||
#include <KernelExport.h>
|
||||
#include <OS.h>
|
||||
#include <PCI.h>
|
||||
#include "debug.h"
|
||||
#include "io.h"
|
||||
#include "ich.h"
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
extern pci_module_info *pci;
|
||||
|
||||
status_t ich_codec_wait(void);
|
||||
|
||||
@@ -54,7 +45,7 @@ ich_reg_read_8(int regno)
|
||||
if (config->type & TYPE_ICH4)
|
||||
return *(uint8 *)(((char *)config->log_mbbar) + regno);
|
||||
else
|
||||
return read_io_8(config->nabmbar + regno);
|
||||
return pci->read_io_8(config->nabmbar + regno);
|
||||
}
|
||||
|
||||
uint16
|
||||
@@ -65,7 +56,7 @@ ich_reg_read_16(int regno)
|
||||
if (config->type & TYPE_ICH4)
|
||||
return *(uint16 *)(((char *)config->log_mbbar) + regno);
|
||||
else
|
||||
return read_io_16(config->nabmbar + regno);
|
||||
return pci->read_io_16(config->nabmbar + regno);
|
||||
}
|
||||
|
||||
uint32
|
||||
@@ -76,7 +67,7 @@ ich_reg_read_32(int regno)
|
||||
if (config->type & TYPE_ICH4)
|
||||
return *(uint32 *)(((char *)config->log_mbbar) + regno);
|
||||
else
|
||||
return read_io_32(config->nabmbar + regno);
|
||||
return pci->read_io_32(config->nabmbar + regno);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -87,7 +78,7 @@ ich_reg_write_8(int regno, uint8 value)
|
||||
if (config->type & TYPE_ICH4)
|
||||
*(uint8 *)(((char *)config->log_mbbar) + regno) = value;
|
||||
else
|
||||
write_io_8(config->nabmbar + regno, value);
|
||||
pci->write_io_8(config->nabmbar + regno, value);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -98,7 +89,7 @@ ich_reg_write_16(int regno, uint16 value)
|
||||
if (config->type & TYPE_ICH4)
|
||||
*(uint16 *)(((char *)config->log_mbbar) + regno) = value;
|
||||
else
|
||||
write_io_16(config->nabmbar + regno, value);
|
||||
pci->write_io_16(config->nabmbar + regno, value);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -109,7 +100,7 @@ ich_reg_write_32(int regno, uint32 value)
|
||||
if (config->type & TYPE_ICH4)
|
||||
*(uint32 *)(((char *)config->log_mbbar) + regno) = value;
|
||||
else
|
||||
write_io_32(config->nabmbar + regno, value);
|
||||
pci->write_io_32(config->nabmbar + regno, value);
|
||||
}
|
||||
|
||||
status_t
|
||||
@@ -140,7 +131,7 @@ ich_codec_read(int regno)
|
||||
if (config->type & TYPE_ICH4)
|
||||
return *(uint16 *)(((char *)config->log_mmbar) + regno);
|
||||
else
|
||||
return read_io_16(config->nambar + regno);
|
||||
return pci->read_io_16(config->nambar + regno);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -158,5 +149,5 @@ ich_codec_write(int regno, uint16 value)
|
||||
if (config->type & TYPE_ICH4)
|
||||
*(uint16 *)(((char *)config->log_mmbar) + regno) = value;
|
||||
else
|
||||
write_io_16(config->nambar + regno, value);
|
||||
pci->write_io_16(config->nambar + regno, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user