Improve interlocking for card removal. We now can remove the card in
the ISR. We keep track of the card state and don't call the IRS when the card isn't inserted. This helps quite a bit with card ejection problems that Ian was seeing. Submitted by: Ian Dowse MFC upon: re approvel.
This commit is contained in:
parent
c51d4d8eee
commit
33c3c53a53
@ -438,25 +438,36 @@ pcic_pci_cardtype(u_int32_t stat)
|
|||||||
return ("none (can't happen)");
|
return ("none (can't happen)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Card insertion and removal code. The insertion events need to be
|
||||||
|
* debounced so that the noisy insertion/removal events don't result
|
||||||
|
* in the hardware being initialized many times, only to be torn down
|
||||||
|
* as well. This may also cause races with pccardd. Instead, we wait
|
||||||
|
* for the insertion signal to be stable for 0.5 seconds before we declare
|
||||||
|
* it to be a real insertion event. Removal is done right away.
|
||||||
|
*
|
||||||
|
* Note: We only handle the card detect change events. We don't handle
|
||||||
|
* power events and status change events.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
pcic_cd_event(void *arg)
|
pcic_cd_insert(void *arg)
|
||||||
{
|
{
|
||||||
struct pcic_softc *sc = (struct pcic_softc *) arg;
|
struct pcic_softc *sc = (struct pcic_softc *) arg;
|
||||||
struct pcic_slot *sp = &sc->slots[0];
|
struct pcic_slot *sp = &sc->slots[0];
|
||||||
u_int32_t stat;
|
u_int32_t stat;
|
||||||
|
|
||||||
|
sc->cd_pending = 0;
|
||||||
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
||||||
device_printf(sc->dev, "debounced state is 0x%x\n", stat);
|
|
||||||
if ((stat & CB_SS_CD) == 0) {
|
/* Just return if the interrupt handler missed a remove transition. */
|
||||||
if ((stat & CB_SS_16BIT) == 0)
|
if ((stat & CB_SS_CD) != 0)
|
||||||
device_printf(sp->sc->dev, "Unsupported card: %s\n",
|
return;
|
||||||
pcic_pci_cardtype(stat));
|
sc->cd_present = 1;
|
||||||
else
|
if ((stat & CB_SS_16BIT) == 0)
|
||||||
pccard_event(sp->slt, card_inserted);
|
device_printf(sp->sc->dev, "Card type %s is unsupported\n",
|
||||||
} else {
|
pcic_pci_cardtype(stat));
|
||||||
pccard_event(sp->slt, card_removed);
|
else
|
||||||
}
|
pccard_event(sp->slt, card_inserted);
|
||||||
sc->cd_pending = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -466,20 +477,37 @@ pcic_pci_intr(void *arg)
|
|||||||
struct pcic_slot *sp = &sc->slots[0];
|
struct pcic_slot *sp = &sc->slots[0];
|
||||||
u_int32_t event;
|
u_int32_t event;
|
||||||
u_int32_t stat;
|
u_int32_t stat;
|
||||||
|
int present;
|
||||||
|
|
||||||
event = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_EVENT);
|
event = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_EVENT);
|
||||||
if (event != 0) {
|
if (event != 0) {
|
||||||
device_printf(sc->dev, "Event mask 0x%x\n", event);
|
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
||||||
if ((event & CB_SE_CD) != 0 && !sc->cd_pending) {
|
if (bootverbose)
|
||||||
sc->cd_pending = 1;
|
device_printf(sc->dev, "Event mask 0x%x stat 0x%x\n",
|
||||||
timeout(pcic_cd_event, arg, hz/2);
|
event, stat);
|
||||||
|
|
||||||
|
present = (stat & CB_SS_CD) == 0;
|
||||||
|
if (present != sc->cd_present) {
|
||||||
|
if (sc->cd_pending) {
|
||||||
|
untimeout(pcic_cd_insert, arg, sc->cd_ch);
|
||||||
|
sc->cd_pending = 0;
|
||||||
|
}
|
||||||
|
/* Delay insert events to debounce noisy signals. */
|
||||||
|
if (present) {
|
||||||
|
sc->cd_ch = timeout(pcic_cd_insert, arg, hz/2);
|
||||||
|
sc->cd_pending = 1;
|
||||||
|
} else {
|
||||||
|
sc->cd_present = 0;
|
||||||
|
sp->intr = NULL;
|
||||||
|
pccard_event(sp->slt, card_removed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Ack the interrupt, all of them to be safe */
|
/* Ack the interrupt */
|
||||||
bus_space_write_4(sp->bst, sp->bsh, 0, 0xffffffff);
|
bus_space_write_4(sp->bst, sp->bsh, 0, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TI chips also require us to read the old ExCA register for
|
* Some TI chips also require us to read the old ExCA register for
|
||||||
* card status change when we route CSC via PCI! So, we go ahead
|
* card status change when we route CSC via PCI! So, we go ahead
|
||||||
* and read it to clear the bits. Maybe we should check the status
|
* and read it to clear the bits. Maybe we should check the status
|
||||||
* ala the ISA interrupt handler, but those changes should be caught
|
* ala the ISA interrupt handler, but those changes should be caught
|
||||||
@ -487,12 +515,14 @@ pcic_pci_intr(void *arg)
|
|||||||
*/
|
*/
|
||||||
sp->getb(sp, PCIC_STAT_CHG);
|
sp->getb(sp, PCIC_STAT_CHG);
|
||||||
|
|
||||||
/* Now call children interrupts if any */
|
/*
|
||||||
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
* If we have a card in the slot with an interrupt handler, then
|
||||||
if ((stat & CB_SS_CD) == 0) {
|
* call it. Note: This means that each card can have at most one
|
||||||
if (sp->intr != NULL)
|
* interrupt handler for it. Since multifunction cards aren't
|
||||||
sp->intr(sp->argp);
|
* supported, this shouldn't cause a problem in practice.
|
||||||
}
|
*/
|
||||||
|
if (sc->cd_present && sp->intr != NULL)
|
||||||
|
sp->intr(sp->argp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -144,8 +144,8 @@
|
|||||||
#define CB_SOCKET_POWER 0x14
|
#define CB_SOCKET_POWER 0x14
|
||||||
#define CB_EXCA_OFFSET 0x800 /* Offset for ExCA registers */
|
#define CB_EXCA_OFFSET 0x800 /* Offset for ExCA registers */
|
||||||
|
|
||||||
#define CB_SM_CD 0x6 /* Socket MASK Card detect */
|
|
||||||
#define CB_SE_CD 0x6 /* Socket Event Card detect */
|
#define CB_SE_CD 0x6 /* Socket Event Card detect */
|
||||||
|
#define CB_SM_CD 0x6 /* Socket MASK Card detect */
|
||||||
|
|
||||||
#define CB_SS_CARDSTS 0x00000001 /* Card Status Change */
|
#define CB_SS_CARDSTS 0x00000001 /* Card Status Change */
|
||||||
#define CB_SS_CD1 0x00000002 /* Card Detect 1 */
|
#define CB_SS_CD1 0x00000002 /* Card Detect 1 */
|
||||||
|
@ -67,7 +67,9 @@ struct pcic_softc
|
|||||||
void (*slot_poll)(void *);
|
void (*slot_poll)(void *);
|
||||||
struct callout_handle timeout_ch;
|
struct callout_handle timeout_ch;
|
||||||
struct pcic_slot slots[PCIC_MAX_SLOTS];
|
struct pcic_slot slots[PCIC_MAX_SLOTS];
|
||||||
int cd_pending;
|
int cd_pending; /* debounce timeout active */
|
||||||
|
int cd_present; /* debounced card-present state */
|
||||||
|
struct callout_handle cd_ch; /* handle for pcic_cd_insert */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern devclass_t pcic_devclass;
|
extern devclass_t pcic_devclass;
|
||||||
|
Loading…
Reference in New Issue
Block a user