summaryrefslogtreecommitdiffstats
path: root/sys/dev/cardbus
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2007-05-16 20:00:36 +0000
committerimp <imp@FreeBSD.org>2007-05-16 20:00:36 +0000
commite1abf0786d50cb84befc4aadaee8f3682c85cec3 (patch)
tree72d8bf2fe8d25677d70e0bb904210a1a077e3429 /sys/dev/cardbus
parent1f805990465b389d8c21f3c4be73c0c92cdc0395 (diff)
downloadFreeBSD-src-e1abf0786d50cb84befc4aadaee8f3682c85cec3.zip
FreeBSD-src-e1abf0786d50cb84befc4aadaee8f3682c85cec3.tar.gz
Write 0 to all the bars in cardbus_cardbus_setup_regs. This is needed
because on at least my dc based cards there's garbage in there. The recent changes in the resource code appears to have unmasked this problem... At least dc now probes/attaches better than it did before. Also, we no longer need to write to the cfg for the other registers.
Diffstat (limited to 'sys/dev/cardbus')
-rw-r--r--sys/dev/cardbus/cardbus.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index bd2b31c..7c02796 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -75,8 +75,7 @@ static int cardbus_attach(device_t cbdev);
static int cardbus_attach_card(device_t cbdev);
static int cardbus_detach(device_t cbdev);
static int cardbus_detach_card(device_t cbdev);
-static void cardbus_device_setup_regs(device_t brdev, int b, int s, int f,
- pcicfgregs *cfg);
+static void cardbus_device_setup_regs(device_t dev);
static void cardbus_driver_added(device_t cbdev, driver_t *driver);
static int cardbus_probe(device_t cbdev);
static int cardbus_read_ivar(device_t cbdev, device_t child, int which,
@@ -137,23 +136,24 @@ cardbus_resume(device_t self)
/************************************************************************/
static void
-cardbus_device_setup_regs(device_t brdev, int b, int s, int f, pcicfgregs *cfg)
+cardbus_device_setup_regs(device_t dev)
{
- PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_INTLINE,
- pci_get_irq(device_get_parent(brdev)), 1);
- cfg->intline = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_INTLINE, 1);
-
- PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_CACHELNSZ, 0x08, 1);
- cfg->cachelnsz = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_CACHELNSZ, 1);
-
- PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_LATTIMER, 0xa8, 1);
- cfg->lattimer = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_LATTIMER, 1);
-
- PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_MINGNT, 0x14, 1);
- cfg->mingnt = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MINGNT, 1);
+ int i;
- PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 0x14, 1);
- cfg->maxlat = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 1);
+ /*
+ * Some cards power up with garbage in their BARs. This
+ * code clears all that junk out.
+ */
+ for (i = 0; i < PCI_MAX_BAR_0; i++)
+ pci_write_config(dev, PCIR_BAR(i), 0, 4);
+
+ /* XXXimp is getting the interrpt like this right? */
+ pci_write_config(dev, PCIR_INTLINE,
+ pci_get_irq(device_get_parent(device_get_parent(dev))), 1);
+ pci_write_config(dev, PCIR_CACHELNSZ, 0x08, 1);
+ pci_write_config(dev, PCIR_LATTIMER, 0xa8, 1);
+ pci_write_config(dev, PCIR_MINGNT, 0x14, 1);
+ pci_write_config(dev, PCIR_MAXLAT, 0x14, 1);
}
static int
@@ -181,8 +181,6 @@ cardbus_attach_card(device_t cbdev)
if (dinfo->pci.cfg.mfdev)
cardbusfunchigh = PCI_FUNCMAX;
- cardbus_device_setup_regs(brdev, bus, slot, func,
- &dinfo->pci.cfg);
child = device_add_child(cbdev, NULL, -1);
if (child == NULL) {
DEVPRINTF((cbdev, "Cannot add child!\n"));
@@ -196,6 +194,7 @@ cardbus_attach_card(device_t cbdev)
DEVPRINTF((cbdev, "Warning: Bogus CIS ignored\n"));
pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 0);
pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci);
+ cardbus_device_setup_regs(dinfo->pci.cfg.dev);
pci_add_resources(cbdev, child, 1, dinfo->mprefetchable);
pci_print_verbose(&dinfo->pci);
if (device_probe_and_attach(child) == 0)
OpenPOWER on IntegriCloud