diff options
author | imp <imp@FreeBSD.org> | 2001-07-27 07:21:42 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-07-27 07:21:42 +0000 |
commit | 5323d94f5056a1cff6da3a58669e5415800777c0 (patch) | |
tree | 5b691587f87ab221ca6af7189cb77ce890ed6ca1 /sys/pccard/pcic.c | |
parent | 3e6aed8fdce718dceb09e51b82d2eec614603224 (diff) | |
download | FreeBSD-src-5323d94f5056a1cff6da3a58669e5415800777c0.zip FreeBSD-src-5323d94f5056a1cff6da3a58669e5415800777c0.tar.gz |
Attempt to fix and document interactions between suspend/resume and pccardc
power x 0.
pccardc power x 0 used to disable the slot. But a suspend/resume
would reactivate the pccard. It no longer does that. Now the
disabling of the slot is sticy until it is reset with power x 1 or the
card is ejected. This seems closer to correct behavior to me.
o Process all card state changes the same using pccard_do_stat_change().
o Cleanup disabling the card so that we can preserve the state after
the change. Basically, don't set it to empty as often as we do.
o On suspend, the new state is "empty" and the laststate is "suspend"
o Document state machine with a diagram of states and edges. The
edges are labeld to tell the reader what event causes the external
state changes.
o "machdep.pccard.pcic_resume_reset" may be obsolete now. We always
call the bridge driver's resume method on resume now. Otherwise cards
won't automatically show up. If it needs to stay, I'll add it back.
Diffstat (limited to 'sys/pccard/pcic.c')
-rw-r--r-- | sys/pccard/pcic.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 2ee54df6..460f123 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -314,7 +314,6 @@ pcic_attach(device_t dev) struct pcic_softc *sc; struct slot *slt; struct pcic_slot *sp; - u_int8_t stat; sc = (struct pcic_softc *) device_get_softc(dev); callout_handle_init(&sc->timeout_ch); @@ -350,15 +349,7 @@ pcic_attach(device_t dev) /* Check for changes */ pcic_setb(sp, PCIC_POWER, PCIC_PCPWRE | PCIC_DISRST); - stat = sp->getb(sp, PCIC_STATUS); - if (bootverbose) - printf("stat is %x\n", stat); - if ((stat & PCIC_CD) != PCIC_CD) { - sp->slt->laststate = sp->slt->state = empty; - } else { - sp->slt->laststate = sp->slt->state = filled; - pccard_event(sp->slt, card_inserted); - } + pcic_do_stat_delta(sp); } return (bus_generic_attach(dev)); @@ -551,19 +542,19 @@ pcic_reset(void *chan) struct pcic_slot *sp = slt->cdata; switch (slt->insert_seq) { - case 0: /* Something funny happended on the way to the pub... */ + case 0: /* Something funny happended on the way to the pub... */ return; - case 1: /* Assert reset */ + case 1: /* Assert reset */ pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET); slt->insert_seq = 2; timeout(pcic_reset, (void *)slt, hz/4); return; - case 2: /* Deassert it again */ + case 2: /* Deassert it again */ pcic_setb(sp, PCIC_INT_GEN, PCIC_CARDRESET | PCIC_IOCARD); slt->insert_seq = 3; timeout(pcic_reset, (void *)slt, hz/4); return; - case 3: /* Wait if card needs more time */ + case 3: /* Wait if card needs more time */ if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) { timeout(pcic_reset, (void *)slt, hz/10); return; @@ -600,16 +591,14 @@ static void pcic_resume(struct slot *slt) { struct pcic_slot *sp = slt->cdata; - u_int8_t stat; pcic_do_mgt_irq(sp, slt->irq); if (sp->controller == PCIC_PD672X) { pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_SPEAKER); pcic_setb(sp, PCIC_MISC2, PCIC_LPDM_EN); } - stat = sp->getb(sp, PCIC_STATUS); - if ((stat & PCIC_CD) != PCIC_CD) - sp->slt->laststate = sp->slt->state = empty; + if (sp->slt->state != inactive) + pcic_do_stat_delta(sp); } int @@ -848,3 +837,13 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, return (bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags)); } + +void +pcic_do_stat_delta(struct pcic_slot *sp) +{ + if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) + pccard_event(sp->slt, card_removed); + else + pccard_event(sp->slt, card_inserted); +} + |