diff options
author | imp <imp@FreeBSD.org> | 2001-09-04 04:47:58 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-09-04 04:47:58 +0000 |
commit | b2ea2b171b8f6407d574462ca2013565079904ec (patch) | |
tree | debe7561bea176c6e277b8af756d91eb8d3640e5 /sys/pccard/pcic.c | |
parent | e24b3c902b4e4c09d5da29badc6a2760db5f0100 (diff) | |
download | FreeBSD-src-b2ea2b171b8f6407d574462ca2013565079904ec.zip FreeBSD-src-b2ea2b171b8f6407d574462ca2013565079904ec.tar.gz |
Move to using a chip function + function pointers to deal with the
function and csc interrupt routing path (eg, ISA or PCI) so that we
can more easily switch between the two.
When we don't have a card ISR, put the function interrupt into ISA
mode. This effectively masks the interrupt since it happens once, and
not again until we have an ISR. This should help hangs, and might
help people that unwisely update the kernel w/o updating pccardd.
This is done at mapirq time.
Force CL-PD6729/30 to use ISA interrupt routing and maybe even detect
the number of pccard slots properly (this is still WIP). We aren't
going to support PCI interrupts for this release. A future release
should support them, however. Shibata-san's 3.3V fixes are not
included.
Add a hack which should, in i386, rewrite IRQ 0 cardbus bridges to be
IRQ 255, which should cause interrupts to be routed. This is mostly
untested since my one tester disappeared after reporting nothing
changed.
Implement, but do not use, a power method called cardbus. It looked
like a great way to get around the 3.3V problem, but it seems that you
can only use it to power cardbus cards (I get no CIS when I enable it,
so maybe we're programming things bogusly).
GC the intr and argp stuff from the slot database.
Improve the ToPIC support with the power hacks that Nakagawa-san
published in FreeBSD Press and that Hiroyuki Aizu-san ported to
-stable. The ToPIC hacks were for 3.3V support in ToPIC 100, but it
looks like the '97 also has identical registers, so use them too.
Add some #defines for the cardbus power stuff.
Finally implement making CSC on the Ricoh chips ISA or PCI. This will
allow polling mode to work on vaios, I think.
Add some minor debugging. This should likely be cleaned up or put
behing a bootverbose.
Some of this work, and earlier work, was influanced by Chiharu
Shibata-san's power handing patches posted to bsd-nomads:15866.
MFC: Soon, if possible.
Diffstat (limited to 'sys/pccard/pcic.c')
-rw-r--r-- | sys/pccard/pcic.c | 118 |
1 files changed, 97 insertions, 21 deletions
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 793c445..c1ce023 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -84,7 +84,8 @@ SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters"); int pcic_override_irq = 0; TUNABLE_INT("machdep.pccard.pcic_irq", &pcic_override_irq); TUNABLE_INT("hw.pcic.irq", &pcic_override_irq); -SYSCTL_INT(_hw_pcic, OID_AUTO, irq, CTLFLAG_RD, &pcic_override_irq, 0, +SYSCTL_INT(_hw_pcic, OID_AUTO, irq, CTLFLAG_RD, + &pcic_override_irq, 0, "Override the IRQ configured by the config system for all pcic devices"); /* @@ -472,6 +473,69 @@ pcic_ioctl(struct slot *slt, int cmd, caddr_t data) } /* + * pcic_cardbus_power + * + * Power the card up, as specified, using the cardbus power + * registers to control power. Microsoft recommends that cardbus + * vendors support powering the card via cardbus registers because + * there is no standard for 3.3V cards. Since at least a few of the + * cardbus bridges have minor issues with power via the ExCA registers, + * go ahead and do it all via cardbus registers. + * + * An expamination of the code will show the relative + * ease that we do Vpp as well. + * + * Too bad it appears to not work. + */ +static int +pcic_cardbus_power(struct pcic_slot *sp, struct slot *slt) +{ + uint32_t reg; + + /* + * Preserve the clock stop bit of the socket power register. + */ + reg = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_POWER); + printf("old value 0x%x\n", reg); + reg &= CB_SP_CLKSTOP; + + switch(slt->pwr.vpp) { + default: + return (EINVAL); + case 0: + reg |= CB_SP_VPP_0V; + break; + case 33: + reg |= CB_SP_VPP_3V; + break; + case 50: + reg |= CB_SP_VPP_5V; + break; + case 120: + reg |= CB_SP_VPP_12V; + break; + } + + switch(slt->pwr.vcc) { + default: + return (EINVAL); + case 0: + reg |= CB_SP_VCC_0V; + break; + case 33: + reg |= CB_SP_VCC_3V; + break; + case 50: + reg |= CB_SP_VCC_5V; + break; + } + printf("Setting power reg to 0x%x", reg); + bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_POWER, reg); + + return (EIO); +} + +/* * pcic_power - Enable the power of the slot according to * the parameters in the power structure(s). */ @@ -483,7 +547,13 @@ pcic_power(struct slot *slt) struct pcic_slot *sp = slt->cdata; struct pcic_softc *sc = sp->sc; - if (sc->flags & (PCIC_DF_POWER | PCIC_AB_POWER)) { + /* + * Cardbus power registers are completely different. + */ + if (sc->flags & PCIC_CARDBUS_POWER) + return (pcic_cardbus_power(sp, slt)); + + if (sc->flags & PCIC_DF_POWER) { /* * Look at the VS[12]# bits on the card. If VS1 is clear * then we should apply 3.3 volts. @@ -549,16 +619,7 @@ pcic_power(struct slot *slt) pcic_setb(sp, PCIC_RICOH_MCR2, PCIC_MCR2_VCC_33); break; } - - /* - * Technically, The A, B, C stepping didn't support - * the 3.3V cards. However, many cardbus bridges are - * identified as B step cards by our probe routine, so - * we do both. It won't hurt the A, B, C bridges that - * don't support this bit since it is one of the - * reserved bits. - */ - if (sc->flags & (PCIC_AB_POWER | PCIC_DF_POWER)) + if (sc->flags & PCIC_DF_POWER) reg |= PCIC_VCC_3V; break; case 50: @@ -612,14 +673,8 @@ static void pcic_mapirq(struct slot *slt, int irq) { struct pcic_slot *sp = slt->cdata; - if (sp->sc->csc_route == pcic_iw_pci) - return; - irq = host_irq_to_pcic(irq); - if (irq == 0) - pcic_clrb(sp, PCIC_INT_GEN, 0xF); - else - sp->putb(sp, PCIC_INT_GEN, - (sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq); + + sp->sc->chip->map_irq(sp, irq); } /* @@ -631,20 +686,27 @@ pcic_reset(void *chan) struct slot *slt = chan; struct pcic_slot *sp = slt->cdata; + printf("reset %d\n", slt->insert_seq); switch (slt->insert_seq) { case 0: /* Something funny happended on the way to the pub... */ return; case 1: /* Assert reset */ pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET); + printf("int is %x stat is %x\n", sp->getb(sp, PCIC_INT_GEN), + sp->getb(sp, PCIC_STATUS)); slt->insert_seq = 2; timeout(pcic_reset, (void *)slt, hz/4); return; case 2: /* Deassert it again */ pcic_setb(sp, PCIC_INT_GEN, PCIC_CARDRESET | PCIC_IOCARD); + printf("int is %x stat is %x\n", sp->getb(sp, PCIC_INT_GEN), + sp->getb(sp, PCIC_STATUS)); slt->insert_seq = 3; timeout(pcic_reset, (void *)slt, hz/4); return; case 3: /* Wait if card needs more time */ + printf("int is %x stat is %x\n", sp->getb(sp, PCIC_INT_GEN), + sp->getb(sp, PCIC_STATUS)); if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) { timeout(pcic_reset, (void *)slt, hz/10); return; @@ -670,7 +732,8 @@ pcic_disable(struct slot *slt) { struct pcic_slot *sp = slt->cdata; - pcic_clrb(sp, PCIC_INT_GEN, 0xf | PCIC_CARDTYPE | PCIC_CARDRESET); + pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDTYPE | PCIC_CARDRESET); + pcic_mapirq(slt, 0); sp->putb(sp, PCIC_POWER, 0); } @@ -1013,3 +1076,16 @@ pcic_isa_intr1(void *arg) splx(s); return (0); } + +int +pcic_isa_mapirq(struct pcic_slot *sp, int irq) +{ + irq = host_irq_to_pcic(irq); + sp->sc->chip->func_intr_way(sp, pcic_iw_isa); + if (irq == 0) + pcic_clrb(sp, PCIC_INT_GEN, 0xF); + else + sp->putb(sp, PCIC_INT_GEN, + (sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq); + return (0); +} |