1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Intel PCIC or compatible Controller driver
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*
|
2001-05-25 05:25:43 +00:00
|
|
|
* Copyright (c) 2001 M. Warner Losh. All rights reserved.
|
1995-08-24 08:56:20 +00:00
|
|
|
* Copyright (c) 1995 Andrew McRae. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1999-09-26 21:52:43 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
1995-08-24 08:56:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
2000-09-13 18:33:25 +00:00
|
|
|
#include <sys/bus.h>
|
1995-08-24 08:56:20 +00:00
|
|
|
#include <sys/kernel.h>
|
1999-01-19 00:18:28 +00:00
|
|
|
#include <sys/module.h>
|
2001-07-27 16:07:02 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/systm.h>
|
1995-08-24 08:56:20 +00:00
|
|
|
|
2001-07-28 04:04:05 +00:00
|
|
|
#include <machine/clock.h>
|
1995-11-21 08:27:00 +00:00
|
|
|
#include <pccard/i82365.h>
|
2001-06-04 03:29:06 +00:00
|
|
|
#include <pccard/pcic_pci.h>
|
1997-11-18 21:04:01 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
1995-11-21 08:27:00 +00:00
|
|
|
#include <pccard/slot.h>
|
2001-05-16 07:32:04 +00:00
|
|
|
#include <pccard/pcicvar.h>
|
1999-03-10 15:00:54 +00:00
|
|
|
|
2000-03-10 05:43:29 +00:00
|
|
|
/* Get pnp IDs */
|
|
|
|
#include <isa/isavar.h>
|
|
|
|
#include <dev/pcic/i82365reg.h>
|
|
|
|
|
2001-05-08 23:59:13 +00:00
|
|
|
#include <dev/pccard/pccardvar.h>
|
2000-04-20 08:37:46 +00:00
|
|
|
#include "card_if.h"
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Prototypes for interrupt handler.
|
|
|
|
*/
|
2001-03-22 05:49:18 +00:00
|
|
|
static int pcic_ioctl(struct slot *, int, caddr_t);
|
|
|
|
static int pcic_power(struct slot *);
|
2001-04-19 00:04:08 +00:00
|
|
|
static void pcic_mapirq(struct slot *, int);
|
1995-11-13 08:39:44 +00:00
|
|
|
static timeout_t pcic_reset;
|
1997-01-08 00:22:58 +00:00
|
|
|
static void pcic_resume(struct slot *);
|
2001-03-22 05:49:18 +00:00
|
|
|
static void pcic_disable(struct slot *);
|
1995-11-09 20:44:36 +00:00
|
|
|
static int pcic_memory(struct slot *, int);
|
|
|
|
static int pcic_io(struct slot *, int);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
devclass_t pcic_devclass;
|
1995-11-09 20:44:36 +00:00
|
|
|
|
2001-05-19 06:17:37 +00:00
|
|
|
static struct slot_ctrl pcic_cinfo = {
|
|
|
|
pcic_mapirq,
|
|
|
|
pcic_memory,
|
|
|
|
pcic_io,
|
|
|
|
pcic_reset,
|
|
|
|
pcic_disable,
|
|
|
|
pcic_power,
|
|
|
|
pcic_ioctl,
|
|
|
|
pcic_resume,
|
|
|
|
PCIC_MEM_WIN,
|
|
|
|
PCIC_IO_WIN
|
|
|
|
};
|
1995-11-09 20:44:36 +00:00
|
|
|
|
2001-07-27 16:07:02 +00:00
|
|
|
/* sysctl vars */
|
|
|
|
SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters");
|
|
|
|
|
2001-07-31 06:32:02 +00:00
|
|
|
int pcic_override_irq = 0;
|
|
|
|
TUNABLE_INT("machdep.pccard.pcic_irq", &pcic_override_irq);
|
|
|
|
TUNABLE_INT("hw.pcic.irq", &pcic_override_irq);
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
SYSCTL_INT(_hw_pcic, OID_AUTO, irq, CTLFLAG_RD,
|
|
|
|
&pcic_override_irq, 0,
|
2001-07-31 06:32:02 +00:00
|
|
|
"Override the IRQ configured by the config system for all pcic devices");
|
|
|
|
|
2001-10-23 07:04:03 +00:00
|
|
|
int pcic_boot_deactivated = 0;
|
|
|
|
TUNABLE_INT("hw.pcic.boot_deactivated", &pcic_boot_deactivated);
|
|
|
|
SYSCTL_INT(_hw_pcic, OID_AUTO, boot_deactivated, CTLFLAG_RD,
|
|
|
|
&pcic_boot_deactivated, 0,
|
|
|
|
"Override the automatic powering up of pccards at boot.");
|
|
|
|
|
2001-05-24 04:03:28 +00:00
|
|
|
/*
|
|
|
|
* Read a register from the PCIC.
|
|
|
|
*/
|
|
|
|
unsigned char
|
|
|
|
pcic_getb_io(struct pcic_slot *sp, int reg)
|
|
|
|
{
|
2001-05-24 06:54:48 +00:00
|
|
|
bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg);
|
|
|
|
return (bus_space_read_1(sp->bst, sp->bsh, PCIC_DATA));
|
2001-05-24 04:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a register on the PCIC
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val)
|
|
|
|
{
|
2001-05-24 06:54:48 +00:00
|
|
|
/*
|
|
|
|
* Many datasheets recommend using outw rather than outb to save
|
|
|
|
* a microsecond. Maybe we should do this, but we'd likely only
|
|
|
|
* save 20-30us on card activation.
|
|
|
|
*/
|
|
|
|
bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg);
|
|
|
|
bus_space_write_1(sp->bst, sp->bsh, PCIC_DATA, val);
|
2001-05-24 04:03:28 +00:00
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Clear bit(s) of a register.
|
|
|
|
*/
|
2001-05-19 05:21:23 +00:00
|
|
|
__inline void
|
|
|
|
pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, sp->getb(sp, reg) & ~mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Set bit(s) of a register
|
|
|
|
*/
|
2001-05-19 05:21:23 +00:00
|
|
|
__inline void
|
|
|
|
pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, sp->getb(sp, reg) | mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a 16 bit value to 2 adjacent PCIC registers
|
|
|
|
*/
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_putw(struct pcic_slot *sp, int reg, unsigned short word)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, reg, word & 0xFF);
|
|
|
|
sp->putb(sp, reg + 1, (word >> 8) & 0xff);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
2001-07-01 23:40:41 +00:00
|
|
|
/*
|
|
|
|
* pc98 cbus cards introduce a slight wrinkle here. They route the irq7 pin
|
|
|
|
* from the pcic chip to INT 2 on the cbus. INT 2 is normally mapped to
|
|
|
|
* irq 6 on the pc98 architecture, so if we get a request for irq 6
|
|
|
|
* lie to the hardware and say it is 7. All the other usual mappings for
|
|
|
|
* cbus INT into irq space are the same as the rest of the system.
|
|
|
|
*/
|
2001-06-16 06:18:16 +00:00
|
|
|
static __inline int
|
|
|
|
host_irq_to_pcic(int irq)
|
|
|
|
{
|
|
|
|
#ifdef PC98
|
|
|
|
if (irq == 6)
|
|
|
|
irq = 7;
|
|
|
|
#endif
|
|
|
|
return (irq);
|
|
|
|
}
|
|
|
|
|
2001-05-21 03:22:52 +00:00
|
|
|
/*
|
|
|
|
* Free up resources allocated so far.
|
|
|
|
*/
|
2001-05-21 07:32:46 +00:00
|
|
|
void
|
2001-05-21 03:22:52 +00:00
|
|
|
pcic_dealloc(device_t dev)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc;
|
|
|
|
|
|
|
|
sc = (struct pcic_softc *) device_get_softc(dev);
|
2001-06-04 03:29:06 +00:00
|
|
|
if (sc->slot_poll)
|
|
|
|
untimeout(sc->slot_poll, sc, sc->timeout_ch);
|
2001-05-21 03:22:52 +00:00
|
|
|
if (sc->iores)
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, sc->iorid,
|
|
|
|
sc->iores);
|
|
|
|
if (sc->memres)
|
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->memrid,
|
|
|
|
sc->memres);
|
|
|
|
if (sc->ih)
|
|
|
|
bus_teardown_intr(dev, sc->irqres, sc->ih);
|
|
|
|
if (sc->irqres)
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqrid, sc->irqres);
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* entry point from main code to map/unmap memory context.
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_memory(struct slot *slt, int win)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
|
|
|
struct mem_desc *mp = &slt->mem[win];
|
2001-01-09 23:39:32 +00:00
|
|
|
int reg = win * PCIC_MEMSIZE + PCIC_MEMBASE;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
2001-05-08 23:59:13 +00:00
|
|
|
if (win < 0 || win >= slt->ctrl->maxmem) {
|
|
|
|
printf("Illegal PCIC MEMORY window request %d\n", win);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
1997-01-08 00:22:58 +00:00
|
|
|
if (mp->flags & MDF_ACTIVE) {
|
1998-08-16 01:21:52 +00:00
|
|
|
unsigned long sys_addr = (uintptr_t)(void *)mp->start >> 12;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Write the addresses, card offsets and length.
|
|
|
|
* The values are all stored as the upper 12 bits of the
|
|
|
|
* 24 bit address i.e everything is allocated as 4 Kb chunks.
|
|
|
|
*/
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_putw(sp, reg, sys_addr & 0xFFF);
|
|
|
|
pcic_putw(sp, reg+2, (sys_addr + (mp->size >> 12) - 1) & 0xFFF);
|
|
|
|
pcic_putw(sp, reg+4, ((mp->card >> 12) - sys_addr) & 0x3FFF);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Each 16 bit register has some flags in the upper bits.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_16BITS)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+1, PCIC_DATA16);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_ZEROWS)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+1, PCIC_ZEROWS);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WS0)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+3, PCIC_MW0);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WS1)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+3, PCIC_MW1);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_ATTR)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+5, PCIC_REG);
|
1995-08-24 08:56:20 +00:00
|
|
|
if (mp->flags & MDF_WP)
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, reg+5, PCIC_WP);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Enable the memory window. By experiment, we need a delay.
|
|
|
|
*/
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, PCIC_ADDRWINE, (1<<win) | PCIC_MEMCS16);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(50);
|
1997-01-08 00:22:58 +00:00
|
|
|
} else {
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_clrb(sp, PCIC_ADDRWINE, 1<<win);
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_putw(sp, reg, 0);
|
|
|
|
pcic_putw(sp, reg+2, 0);
|
|
|
|
pcic_putw(sp, reg+4, 0);
|
1997-01-08 00:22:58 +00:00
|
|
|
}
|
2001-05-13 01:44:27 +00:00
|
|
|
return (0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_io - map or unmap I/O context
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_io(struct slot *slt, int win)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int mask, reg;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
|
|
|
struct io_desc *ip = &slt->io[win];
|
2000-02-21 06:52:20 +00:00
|
|
|
if (bootverbose) {
|
|
|
|
printf("pcic: I/O win %d flags %x %x-%x\n", win, ip->flags,
|
2001-11-11 06:58:43 +00:00
|
|
|
ip->start, ip->start + ip->size - 1);
|
2000-02-21 06:52:20 +00:00
|
|
|
}
|
|
|
|
|
1996-02-21 23:20:21 +00:00
|
|
|
switch (win) {
|
|
|
|
case 0:
|
1995-08-24 08:56:20 +00:00
|
|
|
mask = PCIC_IO0_EN;
|
|
|
|
reg = PCIC_IO0;
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1995-08-24 08:56:20 +00:00
|
|
|
mask = PCIC_IO1_EN;
|
|
|
|
reg = PCIC_IO1;
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-05-08 23:59:13 +00:00
|
|
|
printf("Illegal PCIC I/O window request %d\n", win);
|
|
|
|
return (ENXIO);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
|
|
|
if (ip->flags & IODF_ACTIVE) {
|
1996-02-21 23:20:21 +00:00
|
|
|
unsigned char x, ioctlv;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_putw(sp, reg, ip->start);
|
2001-11-11 06:58:43 +00:00
|
|
|
pcic_putw(sp, reg+2, ip->start + ip->size - 1);
|
1996-02-21 23:20:21 +00:00
|
|
|
x = 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
if (ip->flags & IODF_ZEROWS)
|
1996-02-21 23:20:21 +00:00
|
|
|
x |= PCIC_IO_0WS;
|
1995-08-24 08:56:20 +00:00
|
|
|
if (ip->flags & IODF_WS)
|
|
|
|
x |= PCIC_IO_WS;
|
|
|
|
if (ip->flags & IODF_CS16)
|
|
|
|
x |= PCIC_IO_CS16;
|
1996-02-21 23:20:21 +00:00
|
|
|
if (ip->flags & IODF_16BIT)
|
1995-08-24 08:56:20 +00:00
|
|
|
x |= PCIC_IO_16BIT;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Extract the current flags and merge with new flags.
|
|
|
|
* Flags for window 0 in lower nybble, and in upper nybble
|
|
|
|
* for window 1.
|
|
|
|
*/
|
1997-04-20 07:21:12 +00:00
|
|
|
ioctlv = sp->getb(sp, PCIC_IOCTL);
|
1996-02-21 23:20:21 +00:00
|
|
|
DELAY(100);
|
|
|
|
switch (win) {
|
|
|
|
case 0:
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_IOCTL, x | (ioctlv & 0xf0));
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_IOCTL, (x << 4) | (ioctlv & 0xf));
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
DELAY(100);
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, PCIC_ADDRWINE, mask);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(100);
|
1995-11-09 20:44:36 +00:00
|
|
|
} else {
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_clrb(sp, PCIC_ADDRWINE, mask);
|
1996-02-21 23:20:21 +00:00
|
|
|
DELAY(100);
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_putw(sp, reg, 0);
|
|
|
|
pcic_putw(sp, reg + 2, 0);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
2001-05-13 01:44:27 +00:00
|
|
|
return (0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
2001-03-19 07:10:38 +00:00
|
|
|
static void
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_do_mgt_irq(struct pcic_slot *sp, int irq)
|
2001-03-19 07:10:38 +00:00
|
|
|
{
|
2001-06-04 03:29:06 +00:00
|
|
|
u_int32_t reg;
|
|
|
|
|
2001-08-21 20:04:42 +00:00
|
|
|
if (sp->sc->csc_route == pcic_iw_pci) {
|
2001-08-01 19:41:56 +00:00
|
|
|
/* Do the PCI side of things: Enable the Card Change int */
|
2001-06-04 03:29:06 +00:00
|
|
|
reg = CB_SM_CD;
|
|
|
|
bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_MASK, reg);
|
2001-08-01 19:41:56 +00:00
|
|
|
/*
|
|
|
|
* TI Chips need us to set the following. We tell the
|
|
|
|
* controller to route things via PCI interrupts. Also
|
|
|
|
* we clear the interrupt number in the STAT_INT register
|
|
|
|
* as well. The TI-12xx and newer chips require one or the
|
|
|
|
* other of these to happen, depending on what is set in the
|
|
|
|
* diagnostic register. I do both on the theory that other
|
|
|
|
* chips might need one or the other and that no harm will
|
|
|
|
* come from it. If there is harm, then I'll make it a bit
|
|
|
|
* in the tables.
|
|
|
|
*/
|
|
|
|
pcic_setb(sp, PCIC_INT_GEN, PCIC_INTR_ENA);
|
|
|
|
pcic_clrb(sp, PCIC_STAT_INT, PCIC_CSCSELECT);
|
2001-06-04 03:29:06 +00:00
|
|
|
} else {
|
|
|
|
/* Management IRQ changes */
|
2001-08-01 19:41:56 +00:00
|
|
|
/*
|
|
|
|
* The PCIC_INTR_ENA bit means either "tie the function
|
|
|
|
* and csc interrupts together" or "Route csc interrupts
|
|
|
|
* via PCI" or "Reserved". In any case, we want to clear
|
|
|
|
* it since we're using ISA interrupts.
|
|
|
|
*/
|
2001-06-04 03:29:06 +00:00
|
|
|
pcic_clrb(sp, PCIC_INT_GEN, PCIC_INTR_ENA);
|
2001-06-16 06:18:16 +00:00
|
|
|
irq = host_irq_to_pcic(irq);
|
2001-08-01 19:41:56 +00:00
|
|
|
sp->putb(sp, PCIC_STAT_INT, (irq << PCIC_SI_IRQ_SHIFT) |
|
|
|
|
PCIC_CDEN);
|
2001-06-04 03:29:06 +00:00
|
|
|
}
|
2001-03-19 07:10:38 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2000-03-10 05:43:29 +00:00
|
|
|
pcic_attach(device_t dev)
|
|
|
|
{
|
2001-05-13 01:44:27 +00:00
|
|
|
int i;
|
|
|
|
device_t kid;
|
2001-05-14 23:08:58 +00:00
|
|
|
struct pcic_softc *sc;
|
2001-05-13 01:44:27 +00:00
|
|
|
struct slot *slt;
|
2000-03-10 05:43:29 +00:00
|
|
|
struct pcic_slot *sp;
|
|
|
|
|
2001-05-14 23:08:58 +00:00
|
|
|
sc = (struct pcic_softc *) device_get_softc(dev);
|
2001-05-21 03:22:52 +00:00
|
|
|
callout_handle_init(&sc->timeout_ch);
|
2001-05-14 23:08:58 +00:00
|
|
|
sp = &sc->slots[0];
|
2000-03-10 05:43:29 +00:00
|
|
|
for (i = 0; i < PCIC_CARD_SLOTS; i++, sp++) {
|
2001-05-13 01:44:27 +00:00
|
|
|
if (!sp->slt)
|
|
|
|
continue;
|
|
|
|
sp->slt = 0;
|
|
|
|
kid = device_add_child(dev, NULL, -1);
|
|
|
|
if (kid == NULL) {
|
|
|
|
device_printf(dev, "Can't add pccard bus slot %d", i);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
device_probe_and_attach(kid);
|
2001-05-19 06:17:37 +00:00
|
|
|
slt = pccard_init_slot(kid, &pcic_cinfo);
|
2001-05-13 01:44:27 +00:00
|
|
|
if (slt == 0) {
|
|
|
|
device_printf(dev, "Can't get pccard info slot %d", i);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2001-05-21 03:22:52 +00:00
|
|
|
sc->slotmask |= (1 << i);
|
2001-05-13 01:44:27 +00:00
|
|
|
slt->cdata = sp;
|
|
|
|
sp->slt = slt;
|
2001-05-21 04:44:14 +00:00
|
|
|
sp->sc = sc;
|
2000-03-10 05:43:29 +00:00
|
|
|
}
|
|
|
|
|
2001-05-14 23:08:58 +00:00
|
|
|
sp = &sc->slots[0];
|
2000-03-10 05:43:29 +00:00
|
|
|
for (i = 0; i < PCIC_CARD_SLOTS; i++, sp++) {
|
2001-03-19 07:10:38 +00:00
|
|
|
if (sp->slt == NULL)
|
|
|
|
continue;
|
|
|
|
|
2001-06-04 03:29:06 +00:00
|
|
|
pcic_do_mgt_irq(sp, sc->irq);
|
|
|
|
sp->slt->irq = sc->irq;
|
2000-03-10 05:43:29 +00:00
|
|
|
|
2001-05-15 23:50:58 +00:00
|
|
|
/* Check for changes */
|
2001-05-21 04:44:14 +00:00
|
|
|
pcic_setb(sp, PCIC_POWER, PCIC_PCPWRE | PCIC_DISRST);
|
2001-07-27 07:47:35 +00:00
|
|
|
sp->slt->laststate = sp->slt->state = empty;
|
2001-10-23 07:04:03 +00:00
|
|
|
if (pcic_boot_deactivated) {
|
|
|
|
if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) == PCIC_CD) {
|
|
|
|
sp->slt->state = inactive;
|
|
|
|
pccard_event(sp->slt, card_deactivated);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pcic_do_stat_delta(sp);
|
|
|
|
}
|
1999-10-15 17:29:21 +00:00
|
|
|
}
|
2000-03-10 05:43:29 +00:00
|
|
|
|
|
|
|
return (bus_generic_attach(dev));
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
2001-07-31 06:44:37 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
pcic_sresource(struct slot *slt, caddr_t data)
|
|
|
|
{
|
|
|
|
struct pccard_resource *pr;
|
|
|
|
struct resource *r;
|
|
|
|
int flags;
|
|
|
|
int rid = 0;
|
|
|
|
device_t bridgedev = slt->dev;
|
|
|
|
struct pcic_slot *sp = slt->cdata;
|
|
|
|
|
|
|
|
pr = (struct pccard_resource *)data;
|
|
|
|
pr->resource_addr = ~0ul;
|
2001-08-14 19:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're using PCI interrupt routing, then force the IRQ to
|
|
|
|
* use and to heck with what the user requested. If they want
|
|
|
|
* to be able to request IRQs, they must use ISA interrupt
|
|
|
|
* routing. If we don't give them an irq, and it is the
|
|
|
|
* pccardd 0,0 case, then just return (giving the "bad resource"
|
|
|
|
* return in pr->resource_addr).
|
|
|
|
*/
|
|
|
|
if (pr->type == SYS_RES_IRQ) {
|
2001-08-21 20:04:42 +00:00
|
|
|
if (sp->sc->func_route >= pcic_iw_pci) {
|
2001-08-14 19:23:12 +00:00
|
|
|
pr->resource_addr = sp->sc->irq;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (pr->min == 0 && pr->max == 0)
|
|
|
|
return (0);
|
2001-07-31 06:44:37 +00:00
|
|
|
}
|
2001-08-14 19:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we grok this type.
|
|
|
|
*/
|
2001-07-31 06:44:37 +00:00
|
|
|
switch(pr->type) {
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
case SYS_RES_MEMORY:
|
|
|
|
case SYS_RES_IRQ:
|
|
|
|
case SYS_RES_IOPORT:
|
|
|
|
break;
|
|
|
|
}
|
2001-08-14 19:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the resource, and align it to the most natural
|
|
|
|
* size. If we get it, then tell userland what we actually got
|
|
|
|
* in the range they requested.
|
|
|
|
*/
|
2001-07-31 06:44:37 +00:00
|
|
|
flags = rman_make_alignment_flags(pr->size);
|
|
|
|
r = bus_alloc_resource(bridgedev, pr->type, &rid, pr->min, pr->max,
|
|
|
|
pr->size, flags);
|
|
|
|
if (r != NULL) {
|
|
|
|
pr->resource_addr = (u_long)rman_get_start(r);
|
|
|
|
bus_release_resource(bridgedev, pr->type, rid, r);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* ioctl calls - Controller specific ioctls
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_ioctl(struct slot *slt, int cmd, caddr_t data)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
2001-08-14 23:16:01 +00:00
|
|
|
struct pcic_reg *preg = (struct pcic_reg *) data;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(cmd) {
|
1995-08-24 08:56:20 +00:00
|
|
|
default:
|
2001-05-13 01:44:27 +00:00
|
|
|
return (ENOTTY);
|
2001-07-31 06:44:37 +00:00
|
|
|
case PIOCGREG: /* Get pcic register */
|
2001-08-14 23:16:01 +00:00
|
|
|
preg->value = sp->getb(sp, preg->reg);
|
2001-07-31 06:44:37 +00:00
|
|
|
break; /* Set pcic register */
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCSREG:
|
2001-08-14 23:16:01 +00:00
|
|
|
sp->putb(sp, preg->reg, preg->value);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
2001-07-31 06:44:37 +00:00
|
|
|
case PIOCSRESOURCE: /* Can I use this resource? */
|
|
|
|
pcic_sresource(slt, data);
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
2001-05-13 01:44:27 +00:00
|
|
|
return (0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2001-11-11 06:58:43 +00:00
|
|
|
uint32_t power;
|
|
|
|
uint32_t state;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Preserve the clock stop bit of the socket power register.
|
|
|
|
*/
|
2001-11-11 06:58:43 +00:00
|
|
|
power = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_POWER);
|
|
|
|
state = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
|
|
|
printf("old value 0x%x\n", power);
|
|
|
|
power &= ~CB_SP_CLKSTOP;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
|
|
|
|
switch(slt->pwr.vpp) {
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
case 0:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VPP_0V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
case 33:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VPP_3V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
case 50:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VPP_5V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
case 120:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VPP_12V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(slt->pwr.vcc) {
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
case 0:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VCC_0V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
case 33:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VCC_3V;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
case 50:
|
2001-11-11 06:58:43 +00:00
|
|
|
power |= CB_SP_VCC_5V;
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (state & CB_SS_5VCARD)
|
|
|
|
power |= CB_SP_VCC_5V;
|
|
|
|
else if (state & CB_SS_3VCARD)
|
|
|
|
power |= CB_SP_VCC_3V;
|
|
|
|
else if (state & CB_SS_XVCARD)
|
|
|
|
power |= CB_SP_VCC_XV;
|
|
|
|
else if (state & CB_SS_YVCARD)
|
|
|
|
power |= CB_SP_VCC_YV;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-11-11 06:58:43 +00:00
|
|
|
printf("Setting power reg to 0x%x", power);
|
|
|
|
bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_POWER, power);
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_power - Enable the power of the slot according to
|
|
|
|
* the parameters in the power structure(s).
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_power(struct slot *slt)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
2001-05-19 04:53:20 +00:00
|
|
|
unsigned char c;
|
2001-05-21 04:44:14 +00:00
|
|
|
unsigned char reg = PCIC_DISRST | PCIC_PCPWRE;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
2001-11-09 07:33:54 +00:00
|
|
|
struct pcic_slot *sp2;
|
2001-05-21 04:44:14 +00:00
|
|
|
struct pcic_softc *sc = sp->sc;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
/*
|
|
|
|
* Cardbus power registers are completely different.
|
|
|
|
*/
|
|
|
|
if (sc->flags & PCIC_CARDBUS_POWER)
|
|
|
|
return (pcic_cardbus_power(sp, slt));
|
|
|
|
|
2001-11-11 06:58:43 +00:00
|
|
|
/*
|
|
|
|
* If we're automatically detecting what voltage to use, then we need
|
|
|
|
* to ask the bridge what type (voltage-wise) the card is.
|
|
|
|
*/
|
|
|
|
if (slt->pwr.vcc == -1) {
|
|
|
|
if (sc->flags & PCIC_DF_POWER) {
|
|
|
|
/*
|
|
|
|
* Look at the VS[12]# bits on the card. If VS1 is
|
|
|
|
* clear then the card needs 3.3V instead of 5.0V.
|
|
|
|
*/
|
|
|
|
c = sp->getb(sp, PCIC_CDGC);
|
|
|
|
if ((c & PCIC_VS1STAT) == 0)
|
2001-11-09 07:33:54 +00:00
|
|
|
slt->pwr.vcc = 33;
|
2001-11-11 06:58:43 +00:00
|
|
|
else
|
|
|
|
slt->pwr.vcc = 50;
|
|
|
|
}
|
|
|
|
if (sc->flags & PCIC_PD_POWER) {
|
2001-11-09 07:33:54 +00:00
|
|
|
/*
|
2001-11-11 06:58:43 +00:00
|
|
|
* The 6710 does it one way, and the '22 and '29 do it
|
|
|
|
* another. And it appears that the '32 and '33 yet
|
|
|
|
* another way (which I don't know).
|
2001-11-09 07:33:54 +00:00
|
|
|
*/
|
2001-11-11 06:58:43 +00:00
|
|
|
switch (sp->controller) {
|
|
|
|
case PCIC_PD6710:
|
|
|
|
c = sp->getb(sp, PCIC_MISC1);
|
|
|
|
if ((c & PCIC_MISC1_5V_DETECT) == 0)
|
2001-11-09 07:33:54 +00:00
|
|
|
slt->pwr.vcc = 33;
|
2001-11-11 06:58:43 +00:00
|
|
|
else
|
|
|
|
slt->pwr.vcc = 50;
|
|
|
|
break;
|
|
|
|
case PCIC_PD6722:
|
|
|
|
case PCIC_PD6729:
|
|
|
|
/*
|
|
|
|
* VS[12] signals are in slot1's
|
|
|
|
* extended reg 0xa for both slots.
|
|
|
|
*/
|
|
|
|
sp2 = &sc->slots[1];
|
|
|
|
sp2->putb(sp2, PCIC_EXT_IND, PCIC_EXT_DATA);
|
|
|
|
c = sp2->getb(sp2, PCIC_EXTENDED);
|
|
|
|
if (sp == sp2) /* slot 1 */
|
|
|
|
c >>= 2;
|
2001-11-09 07:33:54 +00:00
|
|
|
if ((c & PCIC_VS1A) == 0)
|
|
|
|
slt->pwr.vcc = 33;
|
2001-11-11 06:58:43 +00:00
|
|
|
else
|
|
|
|
slt->pwr.vcc = 50;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* I have no idea how do do this for others */
|
|
|
|
break;
|
2001-11-09 07:33:54 +00:00
|
|
|
}
|
2001-11-09 06:26:57 +00:00
|
|
|
|
2001-11-11 06:58:43 +00:00
|
|
|
/*
|
|
|
|
* Regardless of the above, setting the Auto Power
|
|
|
|
* Switch Enable appears to help.
|
|
|
|
*/
|
|
|
|
reg |= PCIC_APSENA;
|
|
|
|
}
|
|
|
|
/* Other bridges here */
|
|
|
|
if (bootverbose && slt->pwr.vcc != -1)
|
|
|
|
device_printf(sc->dev, "Autodetected %d.%dV card\n",
|
|
|
|
slt->pwr.vcc / 10, slt->pwr.vcc %10);
|
2001-11-09 06:26:57 +00:00
|
|
|
}
|
2001-05-21 04:44:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Note: The Vpp controls varies quit a bit between bridge chips
|
|
|
|
* and the following might not be right in all cases. The Linux
|
|
|
|
* code and wildboar code bases are more complex. However, most
|
|
|
|
* applications want vpp == vcc and the following code does appear
|
|
|
|
* to do that for all bridge sets.
|
|
|
|
*/
|
|
|
|
switch(slt->pwr.vpp) {
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
case 33:
|
|
|
|
reg |= PCIC_VPP_5V;
|
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
reg |= PCIC_VPP_12V;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-21 05:49:15 +00:00
|
|
|
if (slt->pwr.vcc)
|
|
|
|
reg |= PCIC_VCC_ON; /* Turn on Vcc */
|
2001-05-21 04:44:14 +00:00
|
|
|
switch(slt->pwr.vcc) {
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
/*
|
|
|
|
* The wildboar code has comments that state that
|
|
|
|
* the IBM KING controller doesn't support 3.3V
|
|
|
|
* on the "IBM Smart PC card drive". The code
|
|
|
|
* intemates that's the only place they have seen
|
|
|
|
* it used and that there's a boatload of issues
|
|
|
|
* with it. I'm not even sure this is right because
|
|
|
|
* the only docs I've been able to find say this is for
|
|
|
|
* 5V power. Of course, this "doc" is just code comments
|
|
|
|
* so who knows for sure.
|
|
|
|
*/
|
|
|
|
if (sc->flags & PCIC_KING_POWER) {
|
|
|
|
reg |= PCIC_VCC_5V_KING;
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
2001-05-21 04:44:14 +00:00
|
|
|
if (sc->flags & PCIC_VG_POWER) {
|
|
|
|
pcic_setb(sp, PCIC_CVSR, PCIC_CVSR_VS);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
2001-05-21 04:44:14 +00:00
|
|
|
}
|
|
|
|
if (sc->flags & PCIC_PD_POWER) {
|
|
|
|
pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_VCC_33);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-05-23 05:06:04 +00:00
|
|
|
if (sc->flags & PCIC_RICOH_POWER) {
|
|
|
|
pcic_setb(sp, PCIC_RICOH_MCR2, PCIC_MCR2_VCC_33);
|
|
|
|
break;
|
|
|
|
}
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
if (sc->flags & PCIC_DF_POWER)
|
2001-05-21 04:44:14 +00:00
|
|
|
reg |= PCIC_VCC_3V;
|
|
|
|
break;
|
2001-11-11 06:58:43 +00:00
|
|
|
case -1: /* Treat default like 5.0V */
|
2001-05-21 04:44:14 +00:00
|
|
|
case 50:
|
|
|
|
if (sc->flags & PCIC_KING_POWER)
|
|
|
|
reg |= PCIC_VCC_5V_KING;
|
|
|
|
/*
|
2001-07-01 23:40:54 +00:00
|
|
|
* For all of the variant power schemes for 3.3V go
|
|
|
|
* ahead and turn off the 3.3V enable bit. For all
|
2001-05-21 05:49:15 +00:00
|
|
|
* bridges, the setting the Vcc on bit does the rest.
|
2001-07-01 23:40:54 +00:00
|
|
|
* Note that we don't have to turn off the 3.3V bit
|
|
|
|
* for the '365 step D since with the reg assigments
|
|
|
|
* to this point it doesn't get turned on.
|
2001-05-21 04:44:14 +00:00
|
|
|
*/
|
|
|
|
if (sc->flags & PCIC_VG_POWER)
|
|
|
|
pcic_clrb(sp, PCIC_CVSR, PCIC_CVSR_VS);
|
2001-07-01 23:40:54 +00:00
|
|
|
if (sc->flags & PCIC_PD_POWER)
|
2001-05-21 04:44:14 +00:00
|
|
|
pcic_clrb(sp, PCIC_MISC1, PCIC_MISC1_VCC_33);
|
2001-07-01 23:40:54 +00:00
|
|
|
if (sc->flags & PCIC_RICOH_POWER)
|
2001-05-23 05:06:04 +00:00
|
|
|
pcic_clrb(sp, PCIC_RICOH_MCR2, PCIC_MCR2_VCC_33);
|
1996-02-21 23:20:21 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, PCIC_POWER, reg);
|
1995-08-24 08:56:20 +00:00
|
|
|
DELAY(300*1000);
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->pwr.vcc) {
|
1995-08-24 08:56:20 +00:00
|
|
|
reg |= PCIC_OUTENA;
|
1997-10-06 02:46:38 +00:00
|
|
|
sp->putb(sp, PCIC_POWER, reg);
|
|
|
|
DELAY(100*1000);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
2001-05-21 04:44:14 +00:00
|
|
|
|
2001-05-19 04:53:20 +00:00
|
|
|
/*
|
2001-07-01 23:40:54 +00:00
|
|
|
* Some chipsets will attempt to preclude us from supplying
|
|
|
|
* 5.0V to cards that only handle 3.3V. We seem to need to
|
|
|
|
* try 3.3V to paper over some power handling issues in other
|
|
|
|
* parts of the system. I suspect they are in the pccard bus
|
|
|
|
* driver, but may be in pccardd as well.
|
1997-05-22 07:29:24 +00:00
|
|
|
*/
|
2001-11-11 06:58:43 +00:00
|
|
|
if (!(sp->getb(sp, PCIC_STATUS) & PCIC_POW) && slt->pwr.vcc == -1) {
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->pwr.vcc = 33;
|
|
|
|
slt->pwr.vpp = 0;
|
|
|
|
return (pcic_power(slt));
|
1997-05-22 07:29:24 +00:00
|
|
|
}
|
2001-05-13 01:44:27 +00:00
|
|
|
return (0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tell the PCIC which irq we want to use. only the following are legal:
|
2001-03-19 07:10:38 +00:00
|
|
|
* 3, 4, 5, 7, 9, 10, 11, 12, 14, 15. We require the callers of this
|
|
|
|
* routine to do the check for legality.
|
1995-08-24 08:56:20 +00:00
|
|
|
*/
|
|
|
|
static void
|
1997-10-28 20:58:53 +00:00
|
|
|
pcic_mapirq(struct slot *slt, int irq)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
|
|
|
|
sp->sc->chip->map_irq(sp, irq);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_reset - Reset the card and enable initial power.
|
|
|
|
*/
|
|
|
|
static void
|
1995-11-13 08:39:44 +00:00
|
|
|
pcic_reset(void *chan)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = chan;
|
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-11-09 20:44:36 +00:00
|
|
|
|
2001-09-04 20:08:33 +00:00
|
|
|
if (bootverbose)
|
|
|
|
device_printf(sp->sc->dev, "reset %d ", slt->insert_seq);
|
1997-10-26 04:36:24 +00:00
|
|
|
switch (slt->insert_seq) {
|
2001-07-27 07:21:42 +00:00
|
|
|
case 0: /* Something funny happended on the way to the pub... */
|
2001-09-04 20:08:33 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("\n");
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
2001-07-27 07:21:42 +00:00
|
|
|
case 1: /* Assert reset */
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET);
|
2001-09-04 20:08:33 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("int is %x stat is %x\n",
|
|
|
|
sp->getb(sp, PCIC_INT_GEN),
|
|
|
|
sp->getb(sp, PCIC_STATUS));
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 2;
|
2001-05-19 05:50:42 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/4);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
2001-07-27 07:21:42 +00:00
|
|
|
case 2: /* Deassert it again */
|
2001-07-01 23:40:19 +00:00
|
|
|
pcic_setb(sp, PCIC_INT_GEN, PCIC_CARDRESET | PCIC_IOCARD);
|
2001-09-04 20:08:33 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("int is %x stat is %x\n",
|
|
|
|
sp->getb(sp, PCIC_INT_GEN),
|
|
|
|
sp->getb(sp, PCIC_STATUS));
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 3;
|
2001-05-19 05:50:42 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/4);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
2001-07-27 07:21:42 +00:00
|
|
|
case 3: /* Wait if card needs more time */
|
2001-09-04 20:08:33 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("int is %x stat is %x\n",
|
|
|
|
sp->getb(sp, PCIC_INT_GEN),
|
|
|
|
sp->getb(sp, PCIC_STATUS));
|
1997-04-20 07:21:12 +00:00
|
|
|
if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) {
|
2001-05-19 05:50:42 +00:00
|
|
|
timeout(pcic_reset, (void *)slt, hz/10);
|
1995-11-09 20:44:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 0;
|
2001-11-09 07:33:54 +00:00
|
|
|
if (sp->controller == PCIC_PD6722 || sp->controller == PCIC_PD6710) {
|
1997-04-20 07:21:12 +00:00
|
|
|
sp->putb(sp, PCIC_TIME_SETUP0, 0x1);
|
|
|
|
sp->putb(sp, PCIC_TIME_CMD0, 0x6);
|
|
|
|
sp->putb(sp, PCIC_TIME_RECOV0, 0x0);
|
|
|
|
sp->putb(sp, PCIC_TIME_SETUP1, 1);
|
|
|
|
sp->putb(sp, PCIC_TIME_CMD1, 0xf);
|
|
|
|
sp->putb(sp, PCIC_TIME_RECOV1, 0);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
selwakeup(&slt->selp);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pcic_disable - Disable the slot.
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_disable(struct slot *slt)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDTYPE | PCIC_CARDRESET);
|
|
|
|
pcic_mapirq(slt, 0);
|
2001-08-05 07:02:42 +00:00
|
|
|
sp->putb(sp, PCIC_POWER, 0);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
1997-01-08 00:22:58 +00:00
|
|
|
/*
|
|
|
|
* pcic_resume - Suspend/resume support for PCIC
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-26 04:36:24 +00:00
|
|
|
pcic_resume(struct slot *slt)
|
1997-01-08 00:22:58 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pcic_slot *sp = slt->cdata;
|
1999-10-25 02:41:58 +00:00
|
|
|
|
2001-05-25 05:22:00 +00:00
|
|
|
pcic_do_mgt_irq(sp, slt->irq);
|
2001-11-09 07:33:54 +00:00
|
|
|
if (sp->controller == PCIC_PD6722) {
|
2001-05-19 05:21:23 +00:00
|
|
|
pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_SPEAKER);
|
|
|
|
pcic_setb(sp, PCIC_MISC2, PCIC_LPDM_EN);
|
1997-10-06 03:17:36 +00:00
|
|
|
}
|
2001-07-27 07:21:42 +00:00
|
|
|
if (sp->slt->state != inactive)
|
|
|
|
pcic_do_stat_delta(sp);
|
1997-01-08 00:22:58 +00:00
|
|
|
}
|
1999-10-15 17:29:21 +00:00
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
1999-10-25 02:41:58 +00:00
|
|
|
pcic_activate_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *r)
|
|
|
|
{
|
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
int err;
|
|
|
|
|
2001-05-14 04:53:02 +00:00
|
|
|
if (dev != device_get_parent(device_get_parent(child)) || devi == NULL)
|
|
|
|
return (bus_generic_activate_resource(dev, child, type,
|
|
|
|
rid, r));
|
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
switch (type) {
|
2000-04-20 08:37:46 +00:00
|
|
|
case SYS_RES_IOPORT: {
|
2000-02-21 06:52:20 +00:00
|
|
|
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;
|
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
ip->flags |= IODF_ACTIVE;
|
|
|
|
ip->start = rman_get_start(r);
|
|
|
|
ip->size = rman_get_end(r) - rman_get_start(r) + 1;
|
2001-05-19 05:50:42 +00:00
|
|
|
err = pcic_io(devi->slt, rid);
|
1999-10-25 23:17:24 +00:00
|
|
|
if (err)
|
2001-05-13 01:44:27 +00:00
|
|
|
return (err);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
1999-10-25 23:17:24 +00:00
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
case SYS_RES_IRQ:
|
2000-02-21 06:52:20 +00:00
|
|
|
/*
|
|
|
|
* We actually defer the activation of the IRQ resource
|
|
|
|
* until the interrupt is registered to avoid stray
|
|
|
|
* interrupt messages.
|
|
|
|
*/
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
2000-04-20 08:37:46 +00:00
|
|
|
case SYS_RES_MEMORY: {
|
2000-02-21 06:52:20 +00:00
|
|
|
struct mem_desc *mp;
|
|
|
|
if (rid >= NUM_MEM_WINDOWS)
|
2001-05-13 01:44:27 +00:00
|
|
|
return (EINVAL);
|
2000-02-21 06:52:20 +00:00
|
|
|
mp = &devi->slt->mem[rid];
|
|
|
|
mp->flags |= MDF_ACTIVE;
|
1999-10-28 04:51:39 +00:00
|
|
|
mp->start = (caddr_t) rman_get_start(r);
|
1999-10-25 23:17:24 +00:00
|
|
|
mp->size = rman_get_end(r) - rman_get_start(r) + 1;
|
2001-05-19 05:50:42 +00:00
|
|
|
err = pcic_memory(devi->slt, rid);
|
1999-10-25 23:17:24 +00:00
|
|
|
if (err)
|
2001-05-13 01:44:27 +00:00
|
|
|
return (err);
|
1999-10-25 23:17:24 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
err = bus_generic_activate_resource(dev, child, type, rid, r);
|
2001-05-13 01:44:27 +00:00
|
|
|
return (err);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
1999-10-25 02:41:58 +00:00
|
|
|
pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *r)
|
|
|
|
{
|
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
int err;
|
|
|
|
|
2001-05-14 04:53:02 +00:00
|
|
|
if (dev != device_get_parent(device_get_parent(child)) || devi == NULL)
|
|
|
|
return (bus_generic_deactivate_resource(dev, child, type,
|
|
|
|
rid, r));
|
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
switch (type) {
|
2000-04-20 08:37:46 +00:00
|
|
|
case SYS_RES_IOPORT: {
|
1999-10-25 23:17:24 +00:00
|
|
|
struct io_desc *ip = &devi->slt->io[rid];
|
1999-10-25 02:41:58 +00:00
|
|
|
ip->flags &= ~IODF_ACTIVE;
|
2001-05-19 05:50:42 +00:00
|
|
|
err = pcic_io(devi->slt, rid);
|
2001-05-13 01:44:27 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
1999-10-25 23:17:24 +00:00
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
case SYS_RES_IRQ:
|
|
|
|
break;
|
2000-04-20 08:37:46 +00:00
|
|
|
case SYS_RES_MEMORY: {
|
1999-10-25 23:17:24 +00:00
|
|
|
struct mem_desc *mp = &devi->slt->mem[rid];
|
2000-02-21 06:52:20 +00:00
|
|
|
mp->flags &= ~(MDF_ACTIVE | MDF_ATTR);
|
2001-05-19 05:50:42 +00:00
|
|
|
err = pcic_memory(devi->slt, rid);
|
2001-05-13 01:44:27 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
1999-10-25 23:17:24 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
err = bus_generic_deactivate_resource(dev, child, type, rid, r);
|
2001-05-13 01:44:27 +00:00
|
|
|
return (err);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2000-04-25 06:07:27 +00:00
|
|
|
pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
|
1999-10-25 02:41:58 +00:00
|
|
|
int flags, driver_intr_t *intr, void *arg, void **cookiep)
|
|
|
|
{
|
1999-12-10 07:02:41 +00:00
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
int err;
|
|
|
|
|
2001-03-19 07:10:38 +00:00
|
|
|
if (((1 << rman_get_start(irq)) & PCIC_INT_MASK_ALLOWED) == 0) {
|
|
|
|
device_printf(dev, "Hardware does not support irq %ld.\n",
|
|
|
|
rman_get_start(irq));
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
2000-04-25 06:07:27 +00:00
|
|
|
err = bus_generic_setup_intr(dev, child, irq, flags, intr, arg,
|
1999-12-10 07:02:41 +00:00
|
|
|
cookiep);
|
|
|
|
if (err == 0)
|
2001-05-19 05:50:42 +00:00
|
|
|
pcic_mapirq(devi->slt, rman_get_start(irq));
|
1999-12-10 07:02:41 +00:00
|
|
|
else
|
|
|
|
device_printf(dev, "Error %d irq %ld\n", err,
|
|
|
|
rman_get_start(irq));
|
|
|
|
return (err);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
2000-04-25 06:07:27 +00:00
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
1999-10-25 02:41:58 +00:00
|
|
|
pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
|
|
|
|
void *cookie)
|
|
|
|
{
|
1999-12-10 07:02:41 +00:00
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
|
2001-05-19 05:50:42 +00:00
|
|
|
pcic_mapirq(devi->slt, 0);
|
1999-10-25 02:41:58 +00:00
|
|
|
return (bus_generic_teardown_intr(dev, child, irq, cookie));
|
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2000-04-20 08:37:46 +00:00
|
|
|
pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long value)
|
|
|
|
{
|
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
switch (restype) {
|
|
|
|
case SYS_RES_MEMORY: {
|
|
|
|
struct mem_desc *mp = &devi->slt->mem[rid];
|
2000-08-10 17:35:11 +00:00
|
|
|
switch (value) {
|
2001-05-08 23:59:13 +00:00
|
|
|
case PCCARD_A_MEM_COM:
|
2000-04-20 08:37:46 +00:00
|
|
|
mp->flags &= ~MDF_ATTR;
|
2000-08-10 17:35:11 +00:00
|
|
|
break;
|
2001-05-08 23:59:13 +00:00
|
|
|
case PCCARD_A_MEM_ATTR:
|
2000-08-10 17:35:11 +00:00
|
|
|
mp->flags |= MDF_ATTR;
|
|
|
|
break;
|
2001-05-08 23:59:13 +00:00
|
|
|
case PCCARD_A_MEM_8BIT:
|
2000-08-10 17:35:11 +00:00
|
|
|
mp->flags &= ~MDF_16BITS;
|
|
|
|
break;
|
2001-05-08 23:59:13 +00:00
|
|
|
case PCCARD_A_MEM_16BIT:
|
|
|
|
mp->flags |= MDF_16BITS;
|
|
|
|
break;
|
2000-08-10 17:35:11 +00:00
|
|
|
}
|
2001-05-19 05:50:42 +00:00
|
|
|
err = pcic_memory(devi->slt, rid);
|
2000-04-20 08:37:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
err = EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2000-04-25 06:07:27 +00:00
|
|
|
pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long *value)
|
2000-04-20 08:37:46 +00:00
|
|
|
{
|
2000-08-10 17:35:11 +00:00
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (value == 0)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
switch (restype) {
|
|
|
|
case SYS_RES_IOPORT: {
|
|
|
|
struct io_desc *ip = &devi->slt->io[rid];
|
|
|
|
*value = ip->flags;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SYS_RES_MEMORY: {
|
|
|
|
struct mem_desc *mp = &devi->slt->mem[rid];
|
|
|
|
*value = mp->flags;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
err = EOPNOTSUPP;
|
|
|
|
}
|
2001-05-13 04:44:45 +00:00
|
|
|
return (err);
|
2000-04-25 06:07:27 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2001-08-14 23:34:09 +00:00
|
|
|
pcic_set_memory_offset(device_t bus, device_t child, int rid, u_int32_t offset
|
|
|
|
#if __FreeBSD_version >= 500000
|
|
|
|
,u_int32_t *deltap
|
|
|
|
#endif
|
|
|
|
)
|
2000-04-25 06:07:27 +00:00
|
|
|
{
|
2000-08-10 17:35:11 +00:00
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
struct mem_desc *mp = &devi->slt->mem[rid];
|
|
|
|
|
|
|
|
mp->card = offset;
|
2001-08-14 23:34:09 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
2001-01-07 16:31:09 +00:00
|
|
|
if (deltap)
|
|
|
|
*deltap = 0; /* XXX BAD XXX */
|
2001-08-14 23:34:09 +00:00
|
|
|
#endif
|
2001-05-19 05:50:42 +00:00
|
|
|
return (pcic_memory(devi->slt, rid));
|
2000-08-10 17:35:11 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
int
|
2000-08-10 17:35:11 +00:00
|
|
|
pcic_get_memory_offset(device_t bus, device_t child, int rid, u_int32_t *offset)
|
|
|
|
{
|
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
struct mem_desc *mp = &devi->slt->mem[rid];
|
|
|
|
|
|
|
|
if (offset == 0)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
*offset = mp->card;
|
|
|
|
|
|
|
|
return (0);
|
2000-04-20 08:37:46 +00:00
|
|
|
}
|
2001-05-28 02:53:02 +00:00
|
|
|
|
|
|
|
struct resource *
|
|
|
|
pcic_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're routing via pci, we can share.
|
|
|
|
*/
|
2001-08-21 20:04:42 +00:00
|
|
|
if (sc->func_route == pcic_iw_pci && type == SYS_RES_IRQ) {
|
2001-06-16 06:33:01 +00:00
|
|
|
if (bootverbose)
|
|
|
|
device_printf(child, "Forcing IRQ to %d\n", sc->irq);
|
|
|
|
start = end = sc->irq;
|
2001-05-28 02:53:02 +00:00
|
|
|
flags |= RF_SHAREABLE;
|
2001-06-16 06:33:01 +00:00
|
|
|
}
|
2001-05-28 02:53:02 +00:00
|
|
|
|
|
|
|
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
|
|
|
|
count, flags));
|
|
|
|
}
|
2001-07-27 07:21:42 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2001-08-10 06:07:20 +00:00
|
|
|
/*
|
|
|
|
* Wrapper function for pcicintr so that signatures match.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pcic_isa_intr(void *arg)
|
|
|
|
{
|
|
|
|
pcic_isa_intr1(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCIC timer. If the controller doesn't have a free IRQ to use
|
|
|
|
* or if interrupt steering doesn't work, poll the controller for
|
|
|
|
* insertion/removal events.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pcic_timeout(void *chan)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) chan;
|
|
|
|
|
|
|
|
if (pcic_isa_intr1(chan) != 0) {
|
|
|
|
device_printf(sc->dev,
|
|
|
|
"Static bug detected, ignoring hardware.");
|
|
|
|
sc->slot_poll = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->timeout_ch = timeout(sc->slot_poll, chan, hz/2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCIC Interrupt handler.
|
|
|
|
* Check each slot in turn, and read the card status change
|
|
|
|
* register. If this is non-zero, then a change has occurred
|
|
|
|
* on this card, so send an event to the main code.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
pcic_isa_intr1(void *arg)
|
|
|
|
{
|
|
|
|
int slot, s;
|
|
|
|
u_int8_t chg;
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) arg;
|
|
|
|
struct pcic_slot *sp = &sc->slots[0];
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
for (slot = 0; slot < PCIC_CARD_SLOTS; slot++, sp++) {
|
|
|
|
if (sp->slt == NULL)
|
|
|
|
continue;
|
|
|
|
if ((chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) {
|
|
|
|
/*
|
|
|
|
* if chg is 0xff, then we know that we've hit
|
|
|
|
* the famous "static bug" for some desktop
|
|
|
|
* pcmcia cards. This is caused by static
|
|
|
|
* discharge frying the poor card's mind and
|
|
|
|
* it starts return 0xff forever. We return
|
|
|
|
* an error and stop polling the card. When
|
|
|
|
* we're interrupt based, we never see this.
|
|
|
|
* The card just goes away silently.
|
|
|
|
*/
|
|
|
|
if (chg == 0xff) {
|
|
|
|
splx(s);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
if (chg & PCIC_CDTCH)
|
|
|
|
pcic_do_stat_delta(sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return (0);
|
|
|
|
}
|
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.
2001-09-04 04:47:58 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|