Checkin my first batch of New Mexico changes:

o minor whitespace things (bad because this is also a functional commit)
o Backport reading in of CIS entries from the driver level.
This commit is contained in:
Warner Losh 2000-04-25 06:07:27 +00:00
parent 6e478b8154
commit da05ca010e
4 changed files with 48 additions and 43 deletions

View File

@ -73,8 +73,8 @@ SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
static int pcic_resume_reset = 1;
SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
&pcic_resume_reset, 0, "");
SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
&pcic_resume_reset, 0, "");
#define PCCARD_MEMSIZE (4*1024)
@ -132,10 +132,10 @@ power_off_slot(void *arg)
struct slot *slt = (struct slot *)arg;
int s;
/*
/*
* The following will generate an interrupt. So, to hold off
* the interrupt unitl after disable runs so that we can get rid
* rid of the interrupt before it becomes unsafe to touch the
* rid of the interrupt before it becomes unsafe to touch the
* device.
*/
s = splhigh();
@ -251,12 +251,12 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
goto err;
if (irq)
err = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
if (err)
if (err)
goto err;
if (desc->memsize) {
err = bus_set_resource(child, SYS_RES_MEMORY, 0, desc->mem,
err = bus_set_resource(child, SYS_RES_MEMORY, 0, desc->mem,
desc->memsize);
if (err)
if (err)
goto err;
}
err = device_probe_and_attach(child);

View File

@ -28,7 +28,7 @@
/*
* This file contains various kludges to allow the legacy pccard system to
* work in the newbus system until the pccard system can be converted
* work in the newbus system until the pccard system can be converted
* wholesale to newbus. As that is a while off, I'm providing this glue to
* allow newbus drivers to have pccard attachments.
*
@ -136,7 +136,7 @@ pccard_print_child(device_t dev, device_t child)
PCCARD_NMEM, "%#lx");
pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ,
"%ld");
pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ,
pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ,
"%ld");
retval += printf(" slot %d", devi->slt->slotnum);
}
@ -148,7 +148,7 @@ pccard_print_child(device_t dev, device_t child)
static int
pccard_set_resource(device_t dev, device_t child, int type, int rid,
u_long start, u_long count)
u_long start, u_long count)
{
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
struct resource_list *rl = &devi->resources;
@ -168,7 +168,7 @@ pccard_set_resource(device_t dev, device_t child, int type, int rid,
return EINVAL;
resource_list_add(rl, type, rid, start, start + count - 1, count);
return 0;
}
@ -209,14 +209,17 @@ pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
* irq, 0-3 for memory and 0-1 for ports
*/
int passthrough = (device_get_parent(child) != bus);
int isdefault = (start == 0UL && end == ~0UL);
int isdefault;
struct pccard_devinfo *devi = device_get_ivars(child);
struct resource_list *rl = &devi->resources;
struct resource_list_entry *rle;
struct resource *res;
/* XXX Do I need to add a special case here for the cis memory? XXX */
if (start == 0 && end == ~0 && type == SYS_RES_MEMORY && count != 1) {
start = 0xd0000;
end = 0xdffff;
}
isdefault = (start == 0UL && end == ~0UL);
if (!passthrough && !isdefault) {
rle = resource_list_find(rl, type, *rid);
if (!rle) {
@ -245,10 +248,9 @@ pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
resource_list_add(rl, type, *rid, start, end, count);
}
}
res = resource_list_alloc(rl, bus, child, type, rid, start, end,
res = resource_list_alloc(rl, bus, child, type, rid, start, end,
count, flags);
return res;
return (res);
}
static int
@ -295,8 +297,8 @@ static int
pccard_set_memory_offset(device_t bus, device_t child, int rid,
u_int32_t offset)
{
return CARD_SET_MEMORY_OFFSET(device_get_parent(bus), child, rid,
offset);
return CARD_SET_MEMORY_OFFSET(device_get_parent(bus), child, rid,
offset);
}
static device_method_t pccard_methods[] = {

View File

@ -270,9 +270,9 @@ pcic_io(struct slot *slt, int win)
*/
/*
* VLSI 82C146 has incompatibilities about the I/O address
* of slot 1. Assume it's the only PCIC whose vendor ID is 0x84,
* contact Nate Williams <nate@FreeBSD.org> if incorrect.
* VLSI 82C146 has incompatibilities about the I/O address of slot 1.
* Assume it's the only PCIC whose vendor ID is 0x84,
* contact Warner Losh <imp@freebsd.org> if correct.
*/
static int
pcic_probe(device_t dev)
@ -326,7 +326,7 @@ pcic_probe(device_t dev)
sp->index = rman_get_start(r);
sp->data = sp->index + 1;
sp->offset = slotnum * PCIC_SLOT_SIZE;
/*
/*
* XXX - Screwed up slot 1 on the VLSI chips. According to
* the Linux PCMCIA code from David Hinds, working chipsets
* return 0x84 from their (correct) ID ports, while the broken
@ -521,7 +521,7 @@ pcic_attach(device_t dev)
rid = 0;
r = 0;
if (irq >= 0) {
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq,
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq,
~0, 1, RF_ACTIVE);
}
if (r) {
@ -537,8 +537,7 @@ pcic_attach(device_t dev)
irq = 0;
}
if (irq == 0) {
pcictimeout_ch = timeout(pcictimeout, (void *) GET_UNIT(dev),
hz/2);
pcictimeout_ch = timeout(pcictimeout, (void *) GET_UNIT(dev), hz/2);
device_printf(dev, "Polling mode\n");
}
@ -687,8 +686,7 @@ pcic_mapirq(struct slot *slt, int irq)
if (irq == 0)
clrb(sp, PCIC_INT_GEN, 0xF);
else
sp->putb(sp, PCIC_INT_GEN,
(sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq);
sp->putb(sp, PCIC_INT_GEN, (sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq);
}
/*
@ -888,13 +886,13 @@ pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
}
static int
pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
int flags, driver_intr_t *intr, void *arg, void **cookiep)
{
struct pccard_devinfo *devi = device_get_ivars(child);
int err;
err = bus_generic_setup_intr(dev, child, irq, flags, intr, arg,
err = bus_generic_setup_intr(dev, child, irq, flags, intr, arg,
cookiep);
if (err == 0)
pcic_mapirq(devi->slt, rman_get_start(irq));
@ -903,7 +901,7 @@ pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
rman_get_start(irq));
return (err);
}
static int
pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
void *cookie)
@ -937,16 +935,17 @@ pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
return (err);
}
static struct resource *
pcic_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
static int
pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
u_long *value)
{
if (start == 0 && end == ~0 && type == SYS_RES_MEMORY && count != 1) {
start = 0xd0000;
end = 0xdffff;
}
return bus_generic_alloc_resource(bus, child, type, rid, start, end,
count, flags);
return (EOPNOTSUPP);
}
static int
pcic_set_memory_offset(device_t bus, device_t child, int rid, u_int32_t offset)
{
return (EOPNOTSUPP);
}
static device_method_t pcic_methods[] = {
@ -960,13 +959,18 @@ static device_method_t pcic_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_alloc_resource, pcic_alloc_resource),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, pcic_activate_resource),
DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource),
DEVMETHOD(bus_setup_intr, pcic_setup_intr),
DEVMETHOD(bus_teardown_intr, pcic_teardown_intr),
/* Card interface */
DEVMETHOD(card_set_res_flags, pcic_set_res_flags),
DEVMETHOD(card_get_res_flags, pcic_get_res_flags),
DEVMETHOD(card_set_memory_offset, pcic_set_memory_offset),
{ 0, 0 }
};

View File

@ -1,5 +1,4 @@
/*
* Prototypes for APIC compatible interrupt register and unregister.
* PCMCIA Card Interface Controller
*
* Copyright (c) 1999 Roger Hardiman
@ -28,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
* $FreeBSD$
*/
#define PCIC_RF_IODF_WS (0x01 << 16)