This commit is contained in:
Warner Losh 2000-02-21 06:52:20 +00:00
parent c39bcb3078
commit da144b9373
4 changed files with 35 additions and 33 deletions

View file

@ -71,12 +71,7 @@
SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
static int pcic_resume_reset =
#ifdef PCIC_RESUME_RESET /* opt_pcic.h */
1;
#else
0;
#endif
static int pcic_resume_reset = 1;
SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
&pcic_resume_reset, 0, "");
@ -88,8 +83,7 @@ SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
static int allocate_driver(struct slot *, struct dev_desc *);
static void inserted(void *);
static void disable_slot(struct slot *);
static void disable_slot_spl0(struct slot *);
static void disable_slot_to(void *);
static void disable_slot_to(struct slot *);
static int invalid_io_memory(unsigned long, int);
static void power_off_slot(void *);
@ -185,10 +179,8 @@ disable_slot(struct slot *slt)
}
static void
disable_slot_to(void *argp)
disable_slot_to(struct slot *slt)
{
struct slot *slt = (struct slot *) argp;
slt->state = empty;
disable_slot(slt);
printf("pccard: card removed, slot %d\n", slt->slotnum);
@ -196,15 +188,6 @@ disable_slot_to(void *argp)
selwakeup(&slt->selp);
}
/*
* Disables the slot later when we drop to spl0 via a timeout.
*/
static void
disable_slot_spl0(struct slot *slt)
{
slt->disable_ch = timeout(disable_slot_to, (caddr_t) slt, 0);
}
/*
* pccard_alloc_slot - Called from controller probe
* routine, this function allocates a new PC-CARD slot
@ -232,7 +215,6 @@ pccard_alloc_slot(struct slot_ctrl *ctrl)
pccard_slots[slotno] = slt;
callout_handle_init(&slt->insert_ch);
callout_handle_init(&slt->poff_ch);
callout_handle_init(&slt->disable_ch);
return(slt);
}
@ -301,12 +283,12 @@ inserted(void *arg)
*/
slt->pwr.vcc = 50;
slt->pwr.vpp = 0;
/*
* Disable any pending timeouts for this slot, and explicitly
* power it off right now. Then, re-enable the power using
* the (possibly new) power settings.
*/
untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
power_off_slot(slt);
slt->ctrl->power(slt);
@ -338,7 +320,7 @@ pccard_event(struct slot *slt, enum card_event event)
*/
if (slt->state == filled) {
slt->state = empty;
disable_slot_spl0(slt);
disable_slot_to(slt);
}
break;
case card_inserted:
@ -705,7 +687,6 @@ pccard_suspend(device_t dev)
* Disable any pending timeouts for this slot since we're
* powering it down/disabling now.
*/
untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
slt->ctrl->disable(slt);
return (0);

View file

@ -167,7 +167,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;
}
@ -212,7 +212,8 @@ pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
struct pccard_devinfo *devi = device_get_ivars(child);
struct resource_list *rl = &devi->resources;
struct resource_list_entry *rle;
struct resource *res;
if (!passthrough && !isdefault) {
rle = resource_list_find(rl, type, *rid);
if (!rle) {
@ -242,8 +243,9 @@ pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
}
return resource_list_alloc(rl, bus, child, type, rid,
start, end, count, flags);
res = resource_list_alloc(rl, bus, child, type, rid, start, end,
count, flags);
return res;
}
static int

View file

@ -189,6 +189,11 @@ pcic_io(struct slot *slt, int win)
int mask, reg;
struct pcic_slot *sp = slt->cdata;
struct io_desc *ip = &slt->io[win];
if (bootverbose) {
printf("pcic: I/O win %d flags %x %x-%x\n", win, ip->flags,
ip->start, ip->start+ip->size-1);
}
switch (win) {
case 0:
mask = PCIC_IO0_EN;
@ -765,7 +770,14 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
switch (type) {
case SYS_RES_IOPORT:
{
struct io_desc *ip = &devi->slt->io[rid];
struct io_desc *ip;
ip = &devi->slt->io[rid];
if (ip->flags == 0) {
if (rid == 0)
ip->flags = IODF_WS | IODF_16BIT | IODF_CS16;
else
ip->flags = devi->slt->io[0].flags;
}
ip->flags |= IODF_ACTIVE;
ip->start = rman_get_start(r);
ip->size = rman_get_end(r) - rman_get_start(r) + 1;
@ -775,11 +787,19 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
break;
}
case SYS_RES_IRQ:
/*
* We actually defer the activation of the IRQ resource
* until the interrupt is registered to avoid stray
* interrupt messages.
*/
break;
case SYS_RES_MEMORY:
{
struct mem_desc *mp = &devi->slt->mem[rid];
mp->flags |= IODF_ACTIVE;
struct mem_desc *mp;
if (rid >= NUM_MEM_WINDOWS)
return EINVAL;
mp = &devi->slt->mem[rid];
mp->flags |= MDF_ACTIVE;
mp->start = (caddr_t) rman_get_start(r);
mp->size = rman_get_end(r) - rman_get_start(r) + 1;
err = pcic_memory(devi->slt, rid);
@ -817,7 +837,7 @@ pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
case SYS_RES_MEMORY:
{
struct mem_desc *mp = &devi->slt->mem[rid];
mp->flags &= ~IODF_ACTIVE;
mp->flags &= ~(MDF_ACTIVE | MDF_ATTR);
err = pcic_memory(devi->slt, rid);
if (err) {
return err;

View file

@ -110,7 +110,6 @@ struct slot {
unsigned int insert_seq; /* Firing up under the card */
struct callout_handle insert_ch;/* Insert event timeout handle */
struct callout_handle poff_ch; /* Power Off timeout handle */
struct callout_handle disable_ch; /* Disable spl0 kludge */
enum cardstate state, laststate; /* Current/last card states */
struct selinfo selp; /* Info for select */