1997-12-02 21:26:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997 Ted Faber
|
|
|
|
* 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 immediately at the beginning of the file, without modification,
|
|
|
|
* 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. Absolutely no warranty of function or purpose is made by the author
|
|
|
|
* Ted Faber.
|
|
|
|
*
|
|
|
|
* 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.
|
1998-02-07 20:41:20 +00:00
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1997-12-02 21:26:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
2000-02-02 16:49:21 +00:00
|
|
|
#include <sys/bus.h>
|
1997-12-02 21:26:41 +00:00
|
|
|
#include <pci/pcireg.h>
|
|
|
|
#include <pci/pcivar.h>
|
2001-05-13 01:52:55 +00:00
|
|
|
#include <pccard/pcic_pci.h>
|
1998-01-20 21:11:03 +00:00
|
|
|
#include <pccard/i82365.h>
|
1997-12-02 22:27:58 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
#define PRVERB(x) if (bootverbose) device_printf x
|
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
/*
|
|
|
|
* Set up the CL-PD6832 to look like a ISA based PCMCIA chip (a
|
|
|
|
* PD672X). This routine is called once per PCMCIA socket.
|
|
|
|
*/
|
|
|
|
static void
|
2000-03-25 20:29:55 +00:00
|
|
|
pd6832_legacy_init(device_t dev)
|
2000-02-02 16:49:21 +00:00
|
|
|
{
|
|
|
|
u_long bcr; /* to set interrupts */
|
|
|
|
u_short io_port; /* the io_port to map this slot on */
|
|
|
|
static int num6832; /* The number of 6832s initialized */
|
|
|
|
int unit;
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
num6832 = 0;
|
2000-03-25 20:29:55 +00:00
|
|
|
unit = device_get_unit(dev);
|
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
/*
|
|
|
|
* Some BIOS leave the legacy address uninitialized. This
|
|
|
|
* insures that the PD6832 puts itself where the driver will
|
|
|
|
* look. We assume that multiple 6832's should be laid out
|
|
|
|
* sequentially. We only initialize the first socket's legacy port,
|
|
|
|
* the other is a dummy.
|
|
|
|
*/
|
2001-05-24 06:54:48 +00:00
|
|
|
io_port = PCIC_PORT_0 + num6832 * CLPD6832_NUM_REGS;
|
2000-02-02 16:49:21 +00:00
|
|
|
if (unit == 0)
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CLPD6832_LEGACY_16BIT_IOADDR,
|
2000-05-28 16:31:35 +00:00
|
|
|
io_port & ~CLPD6832_LEGACY_16BIT_IOENABLE, 4);
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
/*
|
|
|
|
* I think this should be a call to pci_map_port, but that
|
|
|
|
* routine won't map regiaters above 0x28, and the register we
|
|
|
|
* need to map is 0x44.
|
|
|
|
*/
|
2000-03-25 20:29:55 +00:00
|
|
|
io_port = pci_read_config(dev, CLPD6832_LEGACY_16BIT_IOADDR, 4) &
|
2000-05-28 16:31:35 +00:00
|
|
|
~CLPD6832_LEGACY_16BIT_IOENABLE;
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
/*
|
|
|
|
* Configure the first I/O window to contain CLPD6832_NUM_REGS
|
|
|
|
* words and deactivate the second by setting the limit lower
|
|
|
|
* than the base.
|
|
|
|
*/
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CLPD6832_IO_BASE0, io_port | 1, 4);
|
|
|
|
pci_write_config(dev, CLPD6832_IO_LIMIT0,
|
|
|
|
(io_port + CLPD6832_NUM_REGS) | 1, 4);
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CLPD6832_IO_BASE1, (io_port + 0x20) | 1, 4);
|
|
|
|
pci_write_config(dev, CLPD6832_IO_LIMIT1, io_port | 1, 4);
|
2000-02-02 16:49:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set default operating mode (I/O port space) and allocate
|
|
|
|
* this socket to the current unit.
|
|
|
|
*/
|
2000-05-28 16:31:35 +00:00
|
|
|
pci_write_config(dev, PCIR_COMMAND, CLPD6832_COMMAND_DEFAULTS, 4);
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CLPD6832_SOCKET, unit, 4);
|
2000-02-02 16:49:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the card inserted/card removed interrupts to come
|
|
|
|
* through the isa IRQ.
|
|
|
|
*/
|
2000-03-25 20:29:55 +00:00
|
|
|
bcr = pci_read_config(dev, CLPD6832_BRIDGE_CONTROL, 4);
|
2000-02-02 16:49:21 +00:00
|
|
|
bcr |= (CLPD6832_BCR_ISA_IRQ|CLPD6832_BCR_MGMT_IRQ_ENA);
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CLPD6832_BRIDGE_CONTROL, bcr, 4);
|
2000-02-02 16:49:21 +00:00
|
|
|
|
|
|
|
/* After initializing 2 sockets, the chip is fully configured */
|
|
|
|
if (unit == 1)
|
|
|
|
num6832++;
|
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
PRVERB((dev, "CardBus: Legacy PC-card 16bit I/O address [0x%x]\n",
|
|
|
|
io_port));
|
2000-02-02 16:49:21 +00:00
|
|
|
}
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
/*
|
|
|
|
* TI1XXX PCI-CardBus Host Adapter specific function code.
|
|
|
|
* This function is separated from pcic_pci_attach().
|
|
|
|
* Support Device: TI1130,TI1131,TI1250,TI1220.
|
|
|
|
* Test Device: TI1221.
|
|
|
|
* Takeshi Shibagaki(shiba@jp.freebsd.org).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ti1xxx_pci_init(device_t dev)
|
|
|
|
{
|
|
|
|
u_long syscntl,devcntl,cardcntl;
|
|
|
|
u_int32_t device_id = pci_get_devid(dev);
|
|
|
|
char buf[128];
|
|
|
|
int ti113x = (device_id == PCI_DEVICE_ID_PCIC_TI1130)
|
|
|
|
|| (device_id == PCI_DEVICE_ID_PCIC_TI1131);
|
|
|
|
|
|
|
|
syscntl = pci_read_config(dev, TI113X_PCI_SYSTEM_CONTROL, 4);
|
|
|
|
devcntl = pci_read_config(dev, TI113X_PCI_DEVICE_CONTROL, 1);
|
|
|
|
cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1);
|
|
|
|
|
|
|
|
switch(ti113x){
|
|
|
|
case 0 :
|
|
|
|
strcpy(buf, "TI12XX PCI Config Reg: ");
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
strcpy(buf, "TI113X PCI Config Reg: ");
|
|
|
|
/*
|
2000-09-29 21:14:05 +00:00
|
|
|
* Default card control register setting is
|
2000-03-25 20:29:55 +00:00
|
|
|
* PCI interrupt. The method of this code
|
|
|
|
* switches PCI INT and ISA IRQ by bit 7 of
|
|
|
|
* Bridge Control Register(Offset:0x3e,0x13e).
|
|
|
|
* Takeshi Shibagaki(shiba@jp.freebsd.org)
|
|
|
|
*/
|
|
|
|
cardcntl |= TI113X_CARDCNTL_PCI_IREQ;
|
|
|
|
cardcntl |= TI113X_CARDCNTL_PCI_CSC;
|
2001-04-17 23:56:12 +00:00
|
|
|
pci_write_config(dev, TI113X_PCI_CARD_CONTROL, cardcntl, 1);
|
|
|
|
cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1);
|
2000-03-25 20:29:55 +00:00
|
|
|
if (syscntl & TI113X_SYSCNTL_CLKRUN_ENA){
|
|
|
|
if (syscntl & TI113X_SYSCNTL_CLKRUN_SEL)
|
|
|
|
strcat(buf, "[clkrun irq 12]");
|
|
|
|
else
|
|
|
|
strcat(buf, "[clkrun irq 10]");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cardcntl & TI113X_CARDCNTL_RING_ENA)
|
|
|
|
strcat(buf, "[ring enable]");
|
|
|
|
if (cardcntl & TI113X_CARDCNTL_SPKR_ENA)
|
|
|
|
strcat(buf, "[speaker enable]");
|
|
|
|
if (syscntl & TI113X_SYSCNTL_PWRSAVINGS)
|
|
|
|
strcat(buf, "[pwr save]");
|
|
|
|
switch(devcntl & TI113X_DEVCNTL_INTR_MASK){
|
|
|
|
case TI113X_DEVCNTL_INTR_ISA :
|
|
|
|
strcat(buf, "[CSC parallel isa irq]");
|
|
|
|
break;
|
|
|
|
case TI113X_DEVCNTL_INTR_SERIAL :
|
|
|
|
strcat(buf, "[CSC serial isa irq]");
|
|
|
|
break;
|
|
|
|
case TI113X_DEVCNTL_INTR_NONE :
|
|
|
|
strcat(buf, "[pci only]");
|
|
|
|
break;
|
|
|
|
case TI12XX_DEVCNTL_INTR_ALLSERIAL :
|
|
|
|
strcat(buf, "[FUNC pci int + CSC serial isa irq]");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
device_printf(dev, "%s\n",buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
generic_cardbus_attach(device_t dev)
|
|
|
|
{
|
|
|
|
u_int16_t brgcntl;
|
|
|
|
u_int32_t iobase;
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = device_get_unit(dev);
|
|
|
|
|
|
|
|
/* Output ISA IRQ indicated in ExCA register(0x03). */
|
|
|
|
brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2);
|
|
|
|
brgcntl |= CB_BCR_INT_EXCA;
|
|
|
|
pci_write_config(dev, CB_PCI_BRIDGE_CTRL, brgcntl, 2);
|
|
|
|
|
|
|
|
/* 16bit Legacy Mode Base Address */
|
|
|
|
if (unit != 0)
|
|
|
|
return;
|
|
|
|
|
2000-05-28 16:31:35 +00:00
|
|
|
iobase = pci_read_config(dev, CB_PCI_LEGACY16_IOADDR, 2) &
|
|
|
|
~CB_PCI_LEGACY16_IOENABLE;
|
2000-03-25 20:29:55 +00:00
|
|
|
if (!iobase) {
|
2000-05-28 16:31:35 +00:00
|
|
|
iobase = 0x3e0 | CB_PCI_LEGACY16_IOENABLE;
|
2000-03-25 20:29:55 +00:00
|
|
|
pci_write_config(dev, CB_PCI_LEGACY16_IOADDR, iobase, 2);
|
|
|
|
iobase = pci_read_config(dev, CB_PCI_LEGACY16_IOADDR, 2)
|
2000-05-28 16:31:35 +00:00
|
|
|
& ~CB_PCI_LEGACY16_IOENABLE;
|
2000-03-25 20:29:55 +00:00
|
|
|
}
|
|
|
|
PRVERB((dev, "Legacy address set to %#x\n", iobase));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-12-02 21:26:41 +00:00
|
|
|
/*
|
1997-12-02 22:13:59 +00:00
|
|
|
* Return the ID string for the controller if the vendor/product id
|
|
|
|
* matches, NULL otherwise.
|
1997-12-02 21:26:41 +00:00
|
|
|
*/
|
2000-02-02 16:49:21 +00:00
|
|
|
static int
|
2000-03-25 20:29:55 +00:00
|
|
|
pcic_pci_probe(device_t dev)
|
1997-12-02 21:26:41 +00:00
|
|
|
{
|
2000-02-02 16:49:21 +00:00
|
|
|
u_int32_t device_id;
|
2001-05-24 04:24:22 +00:00
|
|
|
u_int8_t subclass;
|
|
|
|
u_int8_t progif;
|
2000-02-02 16:49:21 +00:00
|
|
|
char *desc;
|
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
device_id = pci_get_devid(dev);
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = NULL;
|
|
|
|
|
|
|
|
switch (device_id) {
|
1997-12-02 22:13:59 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6832:
|
2000-03-30 18:47:00 +00:00
|
|
|
desc = "Cirrus Logic PD6832 PCI-CardBus Bridge";
|
2000-02-02 16:49:21 +00:00
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1130:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1130 PCI-CardBus Bridge";
|
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1131:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1131 PCI-CardBus Bridge";
|
|
|
|
break;
|
2000-04-20 03:16:49 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1211:
|
|
|
|
desc = "TI PCI-1211 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1220:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1220 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1221:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1221 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-12-31 07:22:24 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1225:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1225 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-01-25 12:59:31 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1250:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1250 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-05-02 05:53:50 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1251:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1251 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-11-28 13:37:35 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1251B:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1251B PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-12-29 13:33:37 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1410:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1410 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-12-29 13:33:37 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1420:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1420 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-12-31 07:22:24 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1450:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1450 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-12-29 13:33:37 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1451:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "TI PCI-1451 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_TOSHIBA_TOPIC95:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Toshiba ToPIC95 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_TOSHIBA_TOPIC97:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Toshiba ToPIC97 PCI-CardBus Bridge";
|
|
|
|
break;
|
2001-05-23 04:37:00 +00:00
|
|
|
case PCI_DEVICE_ID_TOSHIBA_TOPIC100:
|
|
|
|
desc = "Toshiba ToPIC100 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C465:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Ricoh RL5C465 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C475:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Ricoh RL5C475 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C476:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Ricoh RL5C476 PCI-CardBus Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C478:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Ricoh RL5C478 PCI-CardBus Bridge";
|
|
|
|
break;
|
2001-01-02 21:42:48 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_OZ6832:
|
|
|
|
desc = "O2micro 6832 PCI-Cardbus Bridge";
|
|
|
|
break;
|
2000-03-25 20:29:55 +00:00
|
|
|
|
1999-04-01 15:28:10 +00:00
|
|
|
/* 16bit PC-card bridges */
|
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6729:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "Cirrus Logic PD6729/6730 PC-Card Controller";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_OZ6729:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "O2micro OZ6729 PC-Card Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_OZ6730:
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = "O2micro OZ6730 PC-Card Bridge";
|
|
|
|
break;
|
2001-02-07 01:16:40 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1031:
|
|
|
|
desc = "TI PCI-1031 PCI-PCMCIA Bridge";
|
|
|
|
break;
|
1999-04-01 15:28:10 +00:00
|
|
|
|
1997-12-02 22:13:59 +00:00
|
|
|
default:
|
2001-05-24 04:24:22 +00:00
|
|
|
if (pci_get_class(dev) == PCIC_BRIDGE) {
|
|
|
|
subclass = pci_get_subclass(dev);
|
|
|
|
progif = pci_get_progif(dev);
|
|
|
|
if (subclass == PCIS_BRIDGE_PCMCIA && progif == 0)
|
|
|
|
desc = "Generic PCI-PCMCIA Bridge";
|
|
|
|
if (subclass == PCIS_BRIDGE_CARDBUS && progif == 0)
|
|
|
|
desc = "YENTA PCI-CARDBUS Bridge";
|
|
|
|
}
|
1997-12-02 22:13:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-02-02 16:49:21 +00:00
|
|
|
|
|
|
|
if (desc == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
device_set_desc(dev, desc);
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0); /* exact match */
|
1997-12-02 22:13:59 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 23:15:00 +00:00
|
|
|
static void
|
|
|
|
ricoh_init(device_t dev)
|
|
|
|
{
|
|
|
|
u_int16_t brgcntl;
|
|
|
|
/*
|
|
|
|
* Ricoh chips have a legacy bridge enable different than most
|
|
|
|
* Code cribbed from NEWBUS's bridge code since I can't find a
|
|
|
|
* datasheet for them that has register definitions.
|
|
|
|
*/
|
|
|
|
brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2);
|
|
|
|
brgcntl |= CB_BCR_RL_3E0_EN;
|
|
|
|
brgcntl &= ~CB_BCR_RL_3E2_EN;
|
|
|
|
pci_write_config(dev, CLPD6832_BRIDGE_CONTROL, brgcntl, 4);
|
|
|
|
}
|
|
|
|
|
1997-12-02 22:13:59 +00:00
|
|
|
/*
|
|
|
|
* General PCI based card dispatch routine. Right now
|
2001-04-17 23:15:00 +00:00
|
|
|
* it only understands the Ricoh, CL-PD6832 and TI parts. It does
|
2001-01-02 21:42:48 +00:00
|
|
|
* try to do generic things with other parts.
|
1997-12-02 22:13:59 +00:00
|
|
|
*/
|
2000-02-02 16:49:21 +00:00
|
|
|
static int
|
2000-03-25 20:29:55 +00:00
|
|
|
pcic_pci_attach(device_t dev)
|
1997-12-02 22:13:59 +00:00
|
|
|
{
|
2000-03-25 20:29:55 +00:00
|
|
|
u_int32_t device_id = pci_get_devid(dev);
|
|
|
|
u_long command;
|
|
|
|
|
|
|
|
/* Init. CardBus/PC-card controllers as 16-bit PC-card controllers */
|
|
|
|
|
|
|
|
/* Place any per "slot" initialization here */
|
|
|
|
|
|
|
|
/*
|
2000-05-28 16:31:35 +00:00
|
|
|
* In sys/pci/pcireg.h, PCIR_COMMAND must be separated
|
2000-03-25 20:29:55 +00:00
|
|
|
* PCI_COMMAND_REG(0x04) and PCI_STATUS_REG(0x06).
|
|
|
|
* Takeshi Shibagaki(shiba@jp.freebsd.org).
|
|
|
|
*/
|
2000-05-28 16:31:35 +00:00
|
|
|
command = pci_read_config(dev, PCIR_COMMAND, 4);
|
|
|
|
command |= PCIM_CMD_PORTEN | PCIM_CMD_MEMEN;
|
|
|
|
pci_write_config(dev, PCIR_COMMAND, command, 4);
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
switch (device_id) {
|
2001-04-17 23:15:00 +00:00
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C465:
|
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C466:
|
|
|
|
ricoh_init(dev);
|
|
|
|
generic_cardbus_attach(dev);
|
|
|
|
break;
|
2000-03-25 20:29:55 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1130:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1131:
|
2000-04-20 03:16:49 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1211:
|
2000-03-25 20:29:55 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1220:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1221:
|
2000-04-20 03:16:49 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1225:
|
2000-03-25 20:29:55 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1250:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1251:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1251B:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1410:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1420:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1450:
|
|
|
|
case PCI_DEVICE_ID_PCIC_TI1451:
|
|
|
|
ti1xxx_pci_init(dev);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
|
|
|
generic_cardbus_attach(dev);
|
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6832:
|
2001-04-17 23:50:24 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1031: /* 1031 is like 6832 */
|
2001-04-17 23:15:00 +00:00
|
|
|
pd6832_legacy_init(dev);
|
2000-08-29 04:40:17 +00:00
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bootverbose) {
|
|
|
|
int i, j;
|
|
|
|
u_char *p;
|
|
|
|
u_long *pl;
|
|
|
|
|
|
|
|
printf("PCI Config space:\n");
|
|
|
|
for (j = 0; j < 0x98; j += 16) {
|
|
|
|
printf("%02x: ", j);
|
|
|
|
for (i = 0; i < 16; i += 4)
|
2000-03-25 20:29:55 +00:00
|
|
|
printf(" %08x", pci_read_config(dev, i+j, 4));
|
1997-12-02 22:13:59 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
2000-03-25 20:29:55 +00:00
|
|
|
p = (u_char *)pmap_mapdev(pci_read_config(dev, 0x10, 4),
|
1997-12-02 22:27:58 +00:00
|
|
|
0x1000);
|
1997-12-02 22:13:59 +00:00
|
|
|
pl = (u_long *)p;
|
|
|
|
printf("Cardbus Socket registers:\n");
|
|
|
|
printf("00: ");
|
|
|
|
for (i = 0; i < 4; i += 1)
|
1998-08-18 00:32:50 +00:00
|
|
|
printf(" %08lx:", pl[i]);
|
1997-12-02 22:13:59 +00:00
|
|
|
printf("\n10: ");
|
|
|
|
for (i = 4; i < 8; i += 1)
|
1998-08-18 00:32:50 +00:00
|
|
|
printf(" %08lx:", pl[i]);
|
1997-12-02 22:13:59 +00:00
|
|
|
printf("\nExCa registers:\n");
|
|
|
|
for (i = 0; i < 0x40; i += 16)
|
|
|
|
printf("%02x: %16D\n", i, p + 0x800 + i, " ");
|
1997-12-02 21:26:41 +00:00
|
|
|
}
|
1998-01-20 21:11:03 +00:00
|
|
|
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0);
|
2000-02-02 16:49:21 +00:00
|
|
|
}
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-08-30 06:57:38 +00:00
|
|
|
static int
|
|
|
|
pcic_pci_detach(device_t dev)
|
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0);
|
2000-08-30 06:57:38 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
static device_method_t pcic_pci_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, pcic_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, pcic_pci_attach),
|
2000-08-30 06:57:38 +00:00
|
|
|
DEVMETHOD(device_detach, pcic_pci_detach),
|
2000-02-02 16:49:21 +00:00
|
|
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
|
|
|
DEVMETHOD(device_resume, bus_generic_resume),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
{0, 0}
|
|
|
|
};
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
static driver_t pcic_pci_driver = {
|
|
|
|
"pcic-pci",
|
|
|
|
pcic_pci_methods,
|
|
|
|
0 /* no softc */
|
|
|
|
};
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
static devclass_t pcic_pci_devclass;
|
1998-01-20 21:11:03 +00:00
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
DRIVER_MODULE(pcic_pci, pci, pcic_pci_driver, pcic_pci_devclass, 0, 0);
|