summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-11-26 15:35:18 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-11-26 15:35:18 +0000
commit522370568a7e1ff9f9c84cf277a796ca18a945df (patch)
tree5e7987626740c4b1ab8a063af3f8ea89b3be934a /sys/dev/pci
parent3dc2115b1effca39cdb1a9e361df7b7f444f7816 (diff)
correct newlines surrounding the sub-bus configuration, and unify
pchb's further ok reyk oga
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/agp.c6
-rw-r--r--sys/dev/pci/agp_ali.c8
-rw-r--r--sys/dev/pci/agp_amd.c8
-rw-r--r--sys/dev/pci/agp_i810.c20
-rw-r--r--sys/dev/pci/agp_intel.c13
-rw-r--r--sys/dev/pci/agp_sis.c8
-rw-r--r--sys/dev/pci/agp_via.c14
-rw-r--r--sys/dev/pci/pccbb.c38
8 files changed, 63 insertions, 52 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index 9b0dc719337..dec6f753e09 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.9 2007/11/26 10:35:42 reyk Exp $ */
+/* $OpenBSD: agp.c,v 1.10 2007/11/26 15:35:15 deraadt Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -177,14 +177,14 @@ agp_attach(struct device *parent, struct device *self, void *aux)
pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP,
&sc->sc_capoff, NULL);
+ printf(": ");
ret = (*ap->ap_attach)(sc, pa);
if (ret == 0)
- printf(": aperture at 0x%lx, size 0x%lx",
+ printf("aperture at 0x%lx, size 0x%lx\n",
(u_long)sc->sc_apaddr,
(u_long)AGP_GET_APERTURE(sc));
else {
sc->sc_chipc = NULL;
- printf(": AGP GART");
}
}
}
diff --git a/sys/dev/pci/agp_ali.c b/sys/dev/pci/agp_ali.c
index 21380406163..f6ed191562c 100644
--- a/sys/dev/pci/agp_ali.c
+++ b/sys/dev/pci/agp_ali.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_ali.c,v 1.4 2007/11/25 17:11:12 oga Exp $ */
+/* $OpenBSD: agp_ali.c,v 1.5 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_ali.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */
@@ -83,14 +83,14 @@ agp_ali_attach(struct agp_softc *sc, struct pci_attach_args *pa)
asc = malloc(sizeof *asc, M_AGP, M_NOWAIT);
if (asc == NULL) {
- printf(": failed to allocate softc\n");
+ printf("failed to allocate softc\n");
return (ENOMEM);
}
sc->sc_chipc = asc;
sc->sc_methods = &agp_ali_methods;
if (agp_map_aperture(pa, sc, AGP_APBASE, PCI_MAPREG_TYPE_MEM) != 0) {
- printf(": failed to map aperture\n");
+ printf("failed to map aperture\n");
free(asc, M_AGP);
return (ENXIO);
}
@@ -108,7 +108,7 @@ agp_ali_attach(struct agp_softc *sc, struct pci_attach_args *pa)
*/
if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
agp_generic_detach(sc);
- printf(": failed to set aperture\n");
+ printf("failed to set aperture\n");
return (ENOMEM);
}
}
diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c
index ce9c3b2f850..361a1ad1cde 100644
--- a/sys/dev/pci/agp_amd.c
+++ b/sys/dev/pci/agp_amd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_amd.c,v 1.5 2007/11/25 17:11:12 oga Exp $ */
+/* $OpenBSD: agp_amd.c,v 1.6 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */
@@ -164,7 +164,7 @@ agp_amd_attach(struct agp_softc *sc, struct pci_attach_args *pa)
asc = malloc(sizeof *asc, M_AGP, M_NOWAIT | M_ZERO);
if (asc == NULL) {
- printf(": can't allocate softc\n");
+ printf("can't allocate softc\n");
/* agp_generic_detach(sc) */
return (ENOMEM);
}
@@ -172,13 +172,13 @@ agp_amd_attach(struct agp_softc *sc, struct pci_attach_args *pa)
error = pci_mapreg_map(pa, AGP_AMD751_REGISTERS,
PCI_MAPREG_TYPE_MEM, 0, &asc->iot, &asc->ioh, NULL, NULL, 0);
if (error != 0) {
- printf(": can't map AGP registers\n");
+ printf("can't map AGP registers\n");
agp_generic_detach(sc);
return (error);
}
if (agp_map_aperture(pa, sc, AGP_APBASE, PCI_MAPREG_TYPE_MEM) != 0) {
- printf(": can't map aperture\n");
+ printf("can't map aperture\n");
agp_generic_detach(sc);
free(asc, M_AGP);
return (ENXIO);
diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c
index e4565aba04b..7b28b46382e 100644
--- a/sys/dev/pci/agp_i810.c
+++ b/sys/dev/pci/agp_i810.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_i810.c,v 1.20 2007/11/26 10:35:42 reyk Exp $ */
+/* $OpenBSD: agp_i810.c,v 1.21 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $ */
/*-
@@ -169,7 +169,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
isc = malloc(sizeof *isc, M_AGP, M_NOWAIT | M_ZERO);
if (isc == NULL) {
- printf(": can't allocate chipset-specific softc\n");
+ printf("can't allocate chipset-specific softc\n");
return (ENOMEM);
}
sc->sc_chipc = isc;
@@ -186,7 +186,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
return (agp_intel_attach(sc, pa));
}
#endif
- printf(": can't find internal VGA device config space\n");
+ printf("can't find internal VGA device config space\n");
free(isc, M_AGP);
return (ENOENT);
}
@@ -246,7 +246,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
error = agp_map_aperture(&isc->vga_pa, sc, gmaddr, memtype);
if (error != 0) {
- printf(": can't map aperture\n");
+ printf("can't map aperture\n");
free(isc, M_AGP);
return (error);
}
@@ -254,7 +254,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
error = pci_mapreg_map(&isc->vga_pa, mmaddr, memtype, 0,
&isc->bst, &isc->bsh, NULL, &isc->bsz, 0);
if (error != 0) {
- printf(": can't map mmadr registers\n");
+ printf("can't map mmadr registers\n");
agp_generic_detach(sc);
return (error);
}
@@ -263,7 +263,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
error = pci_mapreg_map(&isc->vga_pa, AGP_I915_GTTADR, memtype,
0, &isc->gtt_bst, &isc->gtt_bsh, NULL, NULL, 0);
if (error != 0) {
- printf(": can't map gatt registers\n");
+ printf("can't map gatt registers\n");
agp_generic_detach(sc);
return (error);
}
@@ -323,8 +323,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
break;
default:
isc->stolen = 0;
- printf(
- ": unknown memory configuration, disabling\n");
+ printf("unknown memory configuration, disabling\n");
agp_generic_detach(sc);
return (EINVAL);
}
@@ -376,7 +375,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
}
break;
default:
- printf(": bad chiptype\n");
+ printf("bad chiptype\n");
agp_generic_detach(sc);
return (EINVAL);
}
@@ -413,8 +412,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
break;
default:
isc->stolen = 0;
- printf(
- ": unknown memory configuration, disabling\n");
+ printf("unknown memory configuration, disabling\n");
agp_generic_detach(sc);
return (EINVAL);
}
diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c
index 8b799ef4162..931f29c8bee 100644
--- a/sys/dev/pci/agp_intel.c
+++ b/sys/dev/pci/agp_intel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_intel.c,v 1.6 2007/11/25 17:11:12 oga Exp $ */
+/* $OpenBSD: agp_intel.c,v 1.7 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_intel.c,v 1.3 2001/09/15 00:25:00 thorpej Exp $ */
/*-
@@ -112,24 +112,21 @@ agp_intel_attach(struct agp_softc *sc, struct pci_attach_args *pa)
isc = malloc(sizeof *isc, M_AGP, M_NOWAIT | M_ZERO);
if (isc == NULL) {
- printf(": can't allocate chipset-specific softc\n");
+ printf("can't allocate chipset-specific softc\n");
return (ENOMEM);
}
sc->sc_methods = &agp_intel_methods;
sc->sc_chipc = isc;
- if (pci_find_device(&isc->vga_pa, agp_intel_vgamatch) == 0) {
- printf(": using generic initialization for Intel AGP\n");
- printf("agp");
+ if (pci_find_device(&isc->vga_pa, agp_intel_vgamatch) == 0)
isc->chiptype = CHIP_INTEL;
- }
pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP, &sc->sc_capoff,
NULL);
if (agp_map_aperture(pa, sc, AGP_APBASE, PCI_MAPREG_TYPE_MEM) != 0) {
- printf(": can't map aperture\n");
+ printf("can't map aperture\n");
free(isc, M_AGP);
sc->sc_chipc = NULL;
return (ENXIO);
@@ -177,7 +174,7 @@ agp_intel_attach(struct agp_softc *sc, struct pci_attach_args *pa)
*/
if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
agp_generic_detach(sc);
- printf(": failed to set aperture\n");
+ printf("failed to set aperture\n");
return (ENOMEM);
}
}
diff --git a/sys/dev/pci/agp_sis.c b/sys/dev/pci/agp_sis.c
index 41d68b1552e..871dea45816 100644
--- a/sys/dev/pci/agp_sis.c
+++ b/sys/dev/pci/agp_sis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_sis.c,v 1.4 2007/11/25 17:11:12 oga Exp $ */
+/* $OpenBSD: agp_sis.c,v 1.5 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_sis.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */
/*-
@@ -82,14 +82,14 @@ agp_sis_attach(struct agp_softc *sc, struct pci_attach_args *pa)
ssc = malloc(sizeof *ssc, M_AGP, M_NOWAIT);
if (ssc == NULL) {
- printf(": can't allocate chipset-specific softc\n");
+ printf("can't allocate chipset-specific softc\n");
return (ENOMEM);
}
sc->sc_methods = &agp_sis_methods;
sc->sc_chipc = ssc;
if (agp_map_aperture(pa, sc, AGP_APBASE, PCI_MAPREG_TYPE_MEM) != 0) {
- printf(": can't map aperture\n");
+ printf("can't map aperture\n");
free(ssc, M_AGP);
return (ENXIO);
}
@@ -107,7 +107,7 @@ agp_sis_attach(struct agp_softc *sc, struct pci_attach_args *pa)
*/
if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
agp_generic_detach(sc);
- printf(": failed to set aperture\n");
+ printf("failed to set aperture\n");
return (ENOMEM);
}
}
diff --git a/sys/dev/pci/agp_via.c b/sys/dev/pci/agp_via.c
index f5007bae856..feb0c32e889 100644
--- a/sys/dev/pci/agp_via.c
+++ b/sys/dev/pci/agp_via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_via.c,v 1.5 2007/11/25 17:11:12 oga Exp $ */
+/* $OpenBSD: agp_via.c,v 1.6 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: agp_via.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */
/*-
@@ -91,7 +91,7 @@ agp_via_attach(struct agp_softc *sc, struct pci_attach_args *pa)
asc = malloc(sizeof *asc, M_AGP, M_NOWAIT | M_ZERO);
if (asc == NULL) {
- printf(": can't allocate chipset-specific softc\n");
+ printf("can't allocate chipset-specific softc\n");
return (ENOMEM);
}
sc->sc_chipc = asc;
@@ -103,18 +103,18 @@ agp_via_attach(struct agp_softc *sc, struct pci_attach_args *pa)
agpsel = pci_conf_read(pa->pa_pc, pa->pa_tag, AGP_VIA_AGPSEL);
if ((agpsel & (1 << 1)) == 0) {
asc->regs = via_v3_regs;
- printf(" (v3)");
+ printf("v3, ");
} else {
asc->regs = via_v2_regs;
- printf(" (v2 compat mode)");
+ printf("v2 compat mode, ");
}
} else {
asc->regs = via_v2_regs;
- printf(" (v2)");
+ printf("v2, ");
}
if (agp_map_aperture(pa ,sc, AGP_APBASE, PCI_MAPREG_TYPE_MEM) != 0) {
- printf(": can't map aperture\n");
+ printf("can't map aperture\n");
free(asc, M_AGP);
return (ENXIO);
}
@@ -132,7 +132,7 @@ agp_via_attach(struct agp_softc *sc, struct pci_attach_args *pa)
*/
if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
agp_generic_detach(sc);
- printf(": can't set aperture size\n");
+ printf("can't set aperture size\n");
return (ENOMEM);
}
}
diff --git a/sys/dev/pci/pccbb.c b/sys/dev/pci/pccbb.c
index f82c2dd6ab4..faff048bcca 100644
--- a/sys/dev/pci/pccbb.c
+++ b/sys/dev/pci/pccbb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pccbb.c,v 1.52 2007/11/25 22:35:21 deraadt Exp $ */
+/* $OpenBSD: pccbb.c,v 1.53 2007/11/26 15:35:15 deraadt Exp $ */
/* $NetBSD: pccbb.c,v 1.96 2004/03/28 09:49:31 nakayama Exp $ */
/*
@@ -53,6 +53,7 @@
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/malloc.h>
+#include <sys/proc.h>
#include <machine/intr.h>
#include <machine/bus.h>
@@ -219,6 +220,19 @@ static struct cardbus_functions pccbb_funcs = {
pccbb_conf_write,
};
+/*
+ * delay_ms() is wait in milliseconds. It should be used instead
+ * of delay() if you want to wait more than 1 ms.
+ */
+static inline void
+delay_ms(int millis, void *param)
+{
+ if (cold)
+ delay(millis * 1000);
+ else
+ tsleep(param, PWAIT, "pccbb", MAX(2, hz * millis / 1000));
+}
+
int
pcicbbmatch(parent, match, aux)
struct device *parent;
@@ -970,7 +984,7 @@ pccbbintr(arg)
if (sockevent & CB_SOCKET_EVENT_CD) {
sockstate = bus_space_read_4(memt, memh, CB_SOCKET_STAT);
- if (CB_SOCKET_STAT_CD == (sockstate & CB_SOCKET_STAT_CD)) {
+ if ((sockstate & CB_SOCKET_STAT_CD) != 0) {
/* A card should be removed. */
if (sc->sc_flags & CBB_CARDEXIST) {
DPRINTF(("%s: 0x%08x", sc->sc_dev.dv_xname,
@@ -997,7 +1011,7 @@ pccbbintr(arg)
CARDSLOT_EVENT_REMOVAL_CB);
}
}
- } else if (0x00 == (sockstate & CB_SOCKET_STAT_CD) &&
+ } else if ((sockstate & CB_SOCKET_STAT_CD) == 0 &&
/*
* The pccbbintr may called from powerdown hook when
* the system resumed, to detect the card
@@ -1438,20 +1452,19 @@ cb_reset(sc)
* Reset Assert at least 20 ms
* Some machines request longer duration.
*/
- int reset_duration =
- (sc->sc_chipset == CB_RX5C47X ? 400 * 1000 : 40 * 1000);
+ int reset_duration = (sc->sc_chipset == CB_RX5C47X ? 400 : 50);
u_int32_t bcr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_BCR_INTR);
/* Reset bit Assert (bit 6 at 0x3E) */
bcr |= CB_BCR_RESET_ENABLE;
pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_BCR_INTR, bcr);
- delay(reset_duration);
+ delay_ms(reset_duration, sc);
if (CBB_CARDEXIST & sc->sc_flags) { /* A card exists. Reset it! */
/* Reset bit Deassert (bit 6 at 0x3E) */
bcr &= ~CB_BCR_RESET_ENABLE;
pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_BCR_INTR, bcr);
- delay(reset_duration);
+ delay_ms(reset_duration, sc);
}
/* No card found on the slot. Keep Reset. */
return 1;
@@ -2164,7 +2177,7 @@ pccbb_pcmcia_socket_enable(pch)
DPRINTF(("3V card\n"));
voltage = CARDBUS_VCC_3V | CARDBUS_VPP_VCC;
} else {
- printf("?V card, 0x%x\n", spsr); /* XXX */
+ DPRINTF(("?V card, 0x%x\n", spsr)); /* XXX */
return;
}
@@ -2188,12 +2201,15 @@ pccbb_pcmcia_socket_enable(pch)
intr &= ~(PCIC_INTR_RESET | PCIC_INTR_CARDTYPE_MASK);
Pcic_write(ph, PCIC_INTR, intr);
- /* power up the socket and output enable */
+ /* Power up the socket. */
power = Pcic_read(ph, PCIC_PWRCTL);
- power |= PCIC_PWRCTL_OE;
- Pcic_write(ph, PCIC_PWRCTL, power);
+ Pcic_write(ph, PCIC_PWRCTL, (power & ~PCIC_PWRCTL_OE));
pccbb_power(sc, voltage);
+ /* Now output enable */
+ power = Pcic_read(ph, PCIC_PWRCTL);
+ Pcic_write(ph, PCIC_PWRCTL, power | PCIC_PWRCTL_OE);
+
/*
* hold RESET at least 10us.
*/