1997-12-02 21:26:41 +00:00
|
|
|
/*
|
2001-05-25 18:03:07 +00:00
|
|
|
* Copyright (c) 2001 M. Warner Losh. All Rights Reserved.
|
|
|
|
* Copyright (c) 1997 Ted Faber All rights reserved.
|
1997-12-02 21:26:41 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2001-06-04 06:49:46 +00:00
|
|
|
#include <sys/bus.h>
|
1997-12-02 21:26:41 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-06-04 06:49:46 +00:00
|
|
|
#include <sys/module.h>
|
2001-07-27 16:07:02 +00:00
|
|
|
#include <sys/sysctl.h>
|
1997-12-02 21:26:41 +00:00
|
|
|
#include <sys/systm.h>
|
2001-06-04 06:49:46 +00:00
|
|
|
|
2001-07-19 21:43:01 +00:00
|
|
|
#if __FreeBSD_version < 500000
|
|
|
|
#include <pci/pcireg.h>
|
|
|
|
#include <pci/pcivar.h>
|
|
|
|
#else
|
2001-06-04 06:49:46 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
2001-07-19 21:43:01 +00:00
|
|
|
#endif
|
2001-06-04 06:49:46 +00:00
|
|
|
|
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>
|
2001-06-04 06:49:46 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
|
|
|
#include <pccard/slot.h>
|
|
|
|
#include <pccard/pcicvar.h>
|
|
|
|
|
|
|
|
#include <dev/pccard/pccardvar.h>
|
|
|
|
#include "card_if.h"
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2001-07-27 16:07:02 +00:00
|
|
|
#define PRVERB(x) do { \
|
|
|
|
if (bootverbose) { device_printf x; } \
|
|
|
|
} while (0)
|
2000-03-25 20:29:55 +00:00
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
static int pcic_pci_get_memory(device_t dev);
|
|
|
|
|
2001-07-31 06:44:37 +00:00
|
|
|
SYSCTL_DECL(_hw_pcic);
|
|
|
|
|
2001-07-27 16:07:02 +00:00
|
|
|
static int pcic_ignore_function_1 = 0;
|
|
|
|
TUNABLE_INT("hw.pcic.ignore_function_1", &pcic_ignore_function_1);
|
|
|
|
SYSCTL_INT(_hw_pcic, OID_AUTO, ignore_function_1, CTLFLAG_RD,
|
|
|
|
&pcic_ignore_function_1, 0,
|
|
|
|
"When set, driver ignores pci function 1 of the bridge");
|
|
|
|
|
2001-07-31 06:44:37 +00:00
|
|
|
/*
|
|
|
|
* The following should be a hint, so we can do it on a per device
|
|
|
|
* instance, but this is convenient. Do not set this unless pci
|
|
|
|
* routing doesn't work. It is purposely vague and undocumented
|
|
|
|
* at the moment.
|
|
|
|
*/
|
|
|
|
static int pcic_interrupt_route = (int) pci_parallel;
|
|
|
|
TUNABLE_INT("hw.pcic.interrupt_route", &pcic_interrupt_route);
|
|
|
|
SYSCTL_INT(_hw_pcic, OID_AUTO, interrupt_route, CTLFLAG_RD,
|
|
|
|
&pcic_interrupt_route, (int) pci_parallel,
|
|
|
|
"Interrupt routing type for pci cardbus bridges.");
|
|
|
|
|
2001-05-25 19:22:36 +00:00
|
|
|
struct pcic_pci_table
|
|
|
|
{
|
|
|
|
u_int32_t devid;
|
|
|
|
const char *descr;
|
|
|
|
int type;
|
|
|
|
u_int32_t flags;
|
|
|
|
int revision;
|
|
|
|
} pcic_pci_devs[] = {
|
|
|
|
{ PCI_DEVICE_ID_PCIC_CLPD6729,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Cirrus Logic PD6729/6730 PC-Card Controller",
|
|
|
|
PCIC_PD672X, PCIC_PD_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_CLPD6832,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Cirrus Logic PD6832 PCI-CardBus Bridge",
|
|
|
|
PCIC_PD672X, PCIC_PD_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_CLPD6833,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Cirrus Logic PD6833 PCI-CardBus Bridge",
|
|
|
|
PCIC_PD672X, PCIC_PD_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_OZ6729,
|
2001-07-01 23:41:09 +00:00
|
|
|
"O2micro OZ6729 PC-Card Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_OZ6730,
|
2001-07-01 23:41:09 +00:00
|
|
|
"O2micro OZ6730 PC-Card Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_OZ6832,
|
2001-07-01 23:41:09 +00:00
|
|
|
"O2micro 6832/6833 PCI-Cardbus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_OZ6860,
|
2001-07-01 23:41:09 +00:00
|
|
|
"O2micro 6860/6836 PCI-Cardbus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_OZ6872,
|
2001-07-01 23:41:09 +00:00
|
|
|
"O2micro 6812/6872 PCI-Cardbus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_RICOH_RL5C465,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Ricoh RL5C465 PCI-CardBus Bridge",
|
|
|
|
PCIC_RF5C296, PCIC_RICOH_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_RICOH_RL5C475,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Ricoh RL5C475 PCI-CardBus Bridge",
|
|
|
|
PCIC_RF5C296, PCIC_RICOH_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_RICOH_RL5C476,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Ricoh RL5C476 PCI-CardBus Bridge",
|
|
|
|
PCIC_RF5C296, PCIC_RICOH_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_RICOH_RL5C477,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Ricoh RL5C477 PCI-CardBus Bridge",
|
|
|
|
PCIC_RF5C296, PCIC_RICOH_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_RICOH_RL5C478,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Ricoh RL5C478 PCI-CardBus Bridge",
|
|
|
|
PCIC_RF5C296, PCIC_RICOH_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1031,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1031 PCI-PCMCIA Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1130,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1130 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1131,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1131 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1211,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1211 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1220,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1220 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1221,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1221 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1225,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1225 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1250,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1250 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1251,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1251 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1251B,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1251B PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1410,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1410 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1420,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1420 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1450,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1450 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI1451,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-1451 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_PCIC_TI4451,
|
2001-07-01 23:41:09 +00:00
|
|
|
"TI PCI-4451 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365SL_DF, PCIC_DF_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_TOSHIBA_TOPIC95,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Toshiba ToPIC95 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_TOSHIBA_TOPIC97,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Toshiba ToPIC97 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ PCI_DEVICE_ID_TOSHIBA_TOPIC100,
|
2001-07-01 23:41:09 +00:00
|
|
|
"Toshiba ToPIC100 PCI-CardBus Bridge",
|
|
|
|
PCIC_I82365, PCIC_AB_POWER },
|
2001-05-25 19:22:36 +00:00
|
|
|
{ 0, NULL, 0, 0 }
|
|
|
|
};
|
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
/*
|
|
|
|
* Read a register from the PCIC.
|
|
|
|
*/
|
|
|
|
static unsigned char
|
|
|
|
pcic_pci_getb2(struct pcic_slot *sp, int reg)
|
|
|
|
{
|
|
|
|
return (bus_space_read_1(sp->bst, sp->bsh, sp->offset + reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a register on the PCIC
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
pcic_pci_putb2(struct pcic_slot *sp, int reg, unsigned char val)
|
|
|
|
{
|
|
|
|
bus_space_write_1(sp->bst, sp->bsh, sp->offset + reg, val);
|
|
|
|
}
|
|
|
|
|
2001-05-25 19:22:36 +00:00
|
|
|
/*
|
|
|
|
* lookup inside the table
|
|
|
|
*/
|
|
|
|
static struct pcic_pci_table *
|
|
|
|
pcic_pci_lookup(u_int32_t devid, struct pcic_pci_table *tbl)
|
|
|
|
{
|
2001-05-25 19:24:58 +00:00
|
|
|
while (tbl->devid) {
|
2001-05-25 19:22:36 +00:00
|
|
|
if (tbl->devid == devid)
|
|
|
|
return (tbl);
|
|
|
|
tbl++;
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2000-02-02 16:49:21 +00:00
|
|
|
/*
|
2001-06-04 06:49:46 +00:00
|
|
|
* Set up the CL-PD6832
|
2000-02-02 16:49:21 +00:00
|
|
|
*/
|
|
|
|
static void
|
2001-08-14 05:31:56 +00:00
|
|
|
pcic_pci_pd683x_init(device_t dev)
|
2000-02-02 16:49:21 +00:00
|
|
|
{
|
2001-07-31 06:44:37 +00:00
|
|
|
struct pcic_softc *sc = device_get_softc(dev);
|
2001-08-14 05:31:56 +00:00
|
|
|
u_int32_t device_id = pci_get_devid(dev);
|
|
|
|
u_long bcr;
|
|
|
|
u_long cm1;
|
2000-03-25 20:29:55 +00:00
|
|
|
|
2001-07-31 06:44:37 +00:00
|
|
|
/*
|
2001-08-14 05:31:56 +00:00
|
|
|
* CLPD6832 management interrupt enable bit is bit 11 (MGMT_IRQ_ENA)
|
|
|
|
* in bridge control register(offset 0x3d).
|
2001-07-31 06:44:37 +00:00
|
|
|
* When this bit is turned on, card status change interrupt sets
|
|
|
|
* on ISA IRQ interrupt.
|
2001-08-14 05:31:56 +00:00
|
|
|
* Bit 7 controls the function interrupts and appears to be stanard.
|
|
|
|
*
|
|
|
|
* The CLPD6833 does things differently. It has bit 7, but not bit
|
|
|
|
* 11. Bit 11's functionality appears to be in the "Configuration
|
|
|
|
* Miscellaneous 1" register bit 1.
|
2000-02-02 16:49:21 +00:00
|
|
|
*/
|
2001-06-04 06:49:46 +00:00
|
|
|
bcr = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2);
|
2001-08-14 05:31:56 +00:00
|
|
|
if (device_id == PCI_DEVICE_ID_PCIC_CLPD6832) {
|
|
|
|
if (sc->csc_route >= pci_parallel)
|
|
|
|
bcr &= ~CLPD6832_BCR_MGMT_IRQ_ENA;
|
|
|
|
else
|
|
|
|
bcr |= CLPD6832_BCR_MGMT_IRQ_ENA;
|
|
|
|
}
|
|
|
|
if (sc->func_route >= pci_parallel)
|
|
|
|
bcr &= ~CB_BCR_INT_EXCA;
|
2001-07-31 06:44:37 +00:00
|
|
|
else
|
2001-08-14 05:31:56 +00:00
|
|
|
bcr |= CB_BCR_INT_EXCA;
|
2001-06-04 06:49:46 +00:00
|
|
|
pci_write_config(dev, CB_PCI_BRIDGE_CTRL, bcr, 2);
|
2001-08-14 05:31:56 +00:00
|
|
|
if (device_id == PCI_DEVICE_ID_PCIC_CLPD6833) {
|
|
|
|
cm1 = pci_read_config(dev, CLPD6833_CFG_MISC_1, 4);
|
|
|
|
if (sc->csc_route >= pci_parallel)
|
|
|
|
cm1 &= ~CLPD6833_CM1_MGMT_EXCA_ENA;
|
|
|
|
else
|
|
|
|
cm1 |= CLPD6833_CM1_MGMT_EXCA_ENA;
|
|
|
|
pci_write_config(dev, CLPD6833_CFG_MISC_1, cm1, 4);
|
|
|
|
}
|
2000-02-02 16:49:21 +00:00
|
|
|
}
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
/*
|
2001-06-04 06:49:46 +00:00
|
|
|
* TI PCI-CardBus Host Adapter specific function code.
|
2000-03-25 20:29:55 +00:00
|
|
|
* This function is separated from pcic_pci_attach().
|
|
|
|
* Takeshi Shibagaki(shiba@jp.freebsd.org).
|
|
|
|
*/
|
|
|
|
static void
|
2001-06-04 06:49:46 +00:00
|
|
|
pcic_pci_ti_init(device_t dev)
|
2000-03-25 20:29:55 +00:00
|
|
|
{
|
2001-08-01 19:41:56 +00:00
|
|
|
u_int32_t syscntl, diagctl, devcntl, cardcntl;
|
|
|
|
u_int32_t device_id = pci_get_devid(dev);
|
2001-06-04 06:49:46 +00:00
|
|
|
struct pcic_softc *sc = device_get_softc(dev);
|
2001-08-01 19:41:56 +00:00
|
|
|
int ti113x = (device_id == PCI_DEVICE_ID_PCIC_TI1031) ||
|
2001-06-08 07:16:56 +00:00
|
|
|
(device_id == PCI_DEVICE_ID_PCIC_TI1130) ||
|
|
|
|
(device_id == PCI_DEVICE_ID_PCIC_TI1131);
|
2000-03-25 20:29:55 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2001-08-14 07:31:47 +00:00
|
|
|
if (ti113x) {
|
2001-07-30 07:17:40 +00:00
|
|
|
device_printf(dev, "TI113X PCI Config Reg: ");
|
2001-08-14 07:31:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The TI-1130 (and 1030 and 1131) have a different
|
|
|
|
* interrupt routing control than the newer cards. The
|
|
|
|
* newer cards also use offset 0x3e (the Bridge Control
|
|
|
|
* register).
|
2000-03-25 20:29:55 +00:00
|
|
|
*/
|
2001-08-14 05:31:56 +00:00
|
|
|
if (sc->func_route >= pci_parallel) {
|
2001-06-04 06:49:46 +00:00
|
|
|
cardcntl |= TI113X_CARDCNTL_PCI_IRQ_ENA;
|
|
|
|
cardcntl &= ~TI113X_CARDCNTL_PCI_IREQ;
|
|
|
|
} else {
|
|
|
|
cardcntl |= TI113X_CARDCNTL_PCI_IREQ;
|
|
|
|
}
|
2001-08-14 05:31:56 +00:00
|
|
|
if (sc->csc_route >= pci_parallel)
|
2001-06-04 06:49:46 +00:00
|
|
|
cardcntl |= TI113X_CARDCNTL_PCI_CSC;
|
|
|
|
else
|
|
|
|
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);
|
2001-06-04 06:49:46 +00:00
|
|
|
if (syscntl & TI113X_SYSCNTL_CLKRUN_ENA) {
|
2000-03-25 20:29:55 +00:00
|
|
|
if (syscntl & TI113X_SYSCNTL_CLKRUN_SEL)
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[clkrun irq 12]");
|
2000-03-25 20:29:55 +00:00
|
|
|
else
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[clkrun irq 10]");
|
2000-03-25 20:29:55 +00:00
|
|
|
}
|
2001-08-14 07:31:47 +00:00
|
|
|
} else {
|
|
|
|
device_printf(dev, "TI12XX PCI Config Reg: ");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn on async CSC interrupts. This appears to
|
|
|
|
* be the default, but the old, pre pci-aware, code
|
|
|
|
* did this and it appears PAO does as well.
|
|
|
|
*/
|
|
|
|
diagctl = pci_read_config(dev, TI12XX_PCI_DIAGNOSTIC, 1);
|
|
|
|
diagctl |= TI12XX_DIAG_CSC_INTR;
|
|
|
|
pci_write_config(dev, TI12XX_PCI_DIAGNOSTIC, diagctl, 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn off Zoom Video. Some cards have this enabled,
|
|
|
|
* some do not but it causes problems when enabled. This
|
|
|
|
* register doesn't exist on the 1130 (and likely the 1131,
|
|
|
|
* but without a datasheet it is impossible to know).
|
|
|
|
* Some 12xx chips may not have it, but setting it is
|
|
|
|
* believed to be harmless.
|
|
|
|
*/
|
|
|
|
pci_write_config(dev, TI12XX_PCI_MULTIMEDIA_CONTROL, 0, 4);
|
2000-03-25 20:29:55 +00:00
|
|
|
}
|
2001-08-14 07:31:47 +00:00
|
|
|
/*
|
|
|
|
* Default card control register setting is 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)
|
|
|
|
*/
|
2001-08-14 05:31:56 +00:00
|
|
|
if (sc->func_route >= pci_parallel) {
|
2001-08-21 07:38:13 +00:00
|
|
|
#ifdef PCI_CARDBUS_CARD
|
2001-06-04 06:49:46 +00:00
|
|
|
devcntl &= ~TI113X_DEVCNTL_INTR_MASK;
|
|
|
|
pci_write_config(dev, TI113X_PCI_DEVICE_CONTROL, devcntl, 1);
|
|
|
|
devcntl = pci_read_config(dev, TI113X_PCI_DEVICE_CONTROL, 1);
|
|
|
|
syscntl |= TI113X_SYSCNTL_INTRTIE;
|
2001-08-21 07:38:13 +00:00
|
|
|
#endif
|
2001-06-04 06:49:46 +00:00
|
|
|
syscntl &= ~TI113X_SYSCNTL_SMIENB;
|
|
|
|
pci_write_config(dev, TI113X_PCI_SYSTEM_CONTROL, syscntl, 1);
|
|
|
|
}
|
2000-03-25 20:29:55 +00:00
|
|
|
if (cardcntl & TI113X_CARDCNTL_RING_ENA)
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[ring enable]");
|
2000-03-25 20:29:55 +00:00
|
|
|
if (cardcntl & TI113X_CARDCNTL_SPKR_ENA)
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[speaker enable]");
|
2000-03-25 20:29:55 +00:00
|
|
|
if (syscntl & TI113X_SYSCNTL_PWRSAVINGS)
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[pwr save]");
|
2001-08-01 19:41:56 +00:00
|
|
|
switch(devcntl & TI113X_DEVCNTL_INTR_MASK){
|
2000-03-25 20:29:55 +00:00
|
|
|
case TI113X_DEVCNTL_INTR_ISA :
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[CSC parallel isa irq]");
|
2000-03-25 20:29:55 +00:00
|
|
|
break;
|
|
|
|
case TI113X_DEVCNTL_INTR_SERIAL :
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[CSC serial isa irq]");
|
2000-03-25 20:29:55 +00:00
|
|
|
break;
|
|
|
|
case TI113X_DEVCNTL_INTR_NONE :
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[pci only]");
|
2000-03-25 20:29:55 +00:00
|
|
|
break;
|
|
|
|
case TI12XX_DEVCNTL_INTR_ALLSERIAL :
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("[FUNC pci int + CSC serial isa irq]");
|
2000-03-25 20:29:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-07-30 07:17:40 +00:00
|
|
|
printf("\n");
|
2000-03-25 20:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-04 06:49:46 +00:00
|
|
|
pcic_pci_cardbus_init(device_t dev)
|
2000-03-25 20:29:55 +00:00
|
|
|
{
|
|
|
|
u_int16_t brgcntl;
|
|
|
|
int unit;
|
2001-06-04 06:49:46 +00:00
|
|
|
struct pcic_softc *sc = device_get_softc(dev);
|
2000-03-25 20:29:55 +00:00
|
|
|
|
|
|
|
unit = device_get_unit(dev);
|
|
|
|
|
2001-08-14 05:31:56 +00:00
|
|
|
if (sc->func_route >= pci_parallel) {
|
2001-06-04 06:49:46 +00:00
|
|
|
/* Use INTA for routing interrupts via pci bus */
|
|
|
|
brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2);
|
|
|
|
brgcntl &= ~CB_BCR_INT_EXCA;
|
|
|
|
brgcntl |= CB_BCR_WRITE_POST_EN | CB_BCR_MASTER_ABORT;
|
|
|
|
pci_write_config(dev, CB_PCI_BRIDGE_CTRL, brgcntl, 2);
|
|
|
|
} else {
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn off legacy address */
|
|
|
|
pci_write_config(dev, CB_PCI_LEGACY16_IOADDR, 0, 2);
|
2001-07-01 23:41:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write zeros into the remaining BARs. This seems to turn off
|
|
|
|
* the pci configuration of these things and make the cardbus
|
|
|
|
* bridge use the values for memory programmed into the pcic
|
|
|
|
* registers.
|
|
|
|
*/
|
|
|
|
pci_write_config(dev, CB_PCI_MEMBASE0, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_MEMLIMIT0, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_MEMBASE1, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_MEMLIMIT1, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_IOBASE0, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_IOLIMIT0, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_IOBASE1, 0, 4);
|
|
|
|
pci_write_config(dev, CB_PCI_IOLIMIT1, 0, 4);
|
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pcic_pci_ricoh_init(device_t dev, int old)
|
|
|
|
{
|
2001-07-31 06:44:37 +00:00
|
|
|
u_int16_t brgcntl;
|
2001-06-04 06:49:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
if (old) {
|
|
|
|
brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2);
|
|
|
|
brgcntl &= ~(CB_BCR_RL_3E2_EN | CB_BCR_RL_3E0_EN);
|
|
|
|
pci_write_config(dev, CB_PCI_BRIDGE_CTRL, brgcntl, 2);
|
|
|
|
}
|
|
|
|
}
|
2000-03-25 20:29:55 +00:00
|
|
|
|
2001-07-27 07:14:12 +00:00
|
|
|
static const char *
|
|
|
|
pcic_pci_cardtype(u_int32_t stat)
|
|
|
|
{
|
|
|
|
if (stat & CB_SS_NOTCARD)
|
|
|
|
return ("Cardtype unrecognized by bridge");
|
|
|
|
if ((stat & (CB_SS_16BIT | CB_SS_CB)) == (CB_SS_16BIT | CB_SS_CB))
|
|
|
|
return ("16-bit and 32-bit (can't happen)");
|
|
|
|
if (stat & CB_SS_16BIT)
|
|
|
|
return ("16-bit pccard");
|
|
|
|
if (stat & CB_SS_CB)
|
|
|
|
return ("32-bit cardbus");
|
|
|
|
return ("none (can't happen)");
|
|
|
|
}
|
|
|
|
|
2001-08-19 05:01:18 +00:00
|
|
|
/*
|
|
|
|
* Card insertion and removal code. The insertion events need to be
|
|
|
|
* debounced so that the noisy insertion/removal events don't result
|
|
|
|
* in the hardware being initialized many times, only to be torn down
|
|
|
|
* as well. This may also cause races with pccardd. Instead, we wait
|
|
|
|
* for the insertion signal to be stable for 0.5 seconds before we declare
|
|
|
|
* it to be a real insertion event. Removal is done right away.
|
|
|
|
*
|
|
|
|
* Note: We only handle the card detect change events. We don't handle
|
|
|
|
* power events and status change events.
|
|
|
|
*/
|
2001-06-04 06:49:46 +00:00
|
|
|
static void
|
2001-08-19 05:01:18 +00:00
|
|
|
pcic_cd_insert(void *arg)
|
2001-06-04 06:49:46 +00:00
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) arg;
|
|
|
|
struct pcic_slot *sp = &sc->slots[0];
|
|
|
|
u_int32_t stat;
|
2001-08-19 05:01:18 +00:00
|
|
|
|
|
|
|
sc->cd_pending = 0;
|
2001-06-04 06:49:46 +00:00
|
|
|
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
2001-08-19 05:01:18 +00:00
|
|
|
|
|
|
|
/* Just return if the interrupt handler missed a remove transition. */
|
|
|
|
if ((stat & CB_SS_CD) != 0)
|
|
|
|
return;
|
|
|
|
sc->cd_present = 1;
|
|
|
|
if ((stat & CB_SS_16BIT) == 0)
|
|
|
|
device_printf(sp->sc->dev, "Card type %s is unsupported\n",
|
|
|
|
pcic_pci_cardtype(stat));
|
|
|
|
else
|
|
|
|
pccard_event(sp->slt, card_inserted);
|
2000-03-25 20:29:55 +00:00
|
|
|
}
|
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
static void
|
|
|
|
pcic_pci_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) arg;
|
|
|
|
struct pcic_slot *sp = &sc->slots[0];
|
|
|
|
u_int32_t event;
|
2001-07-01 23:41:43 +00:00
|
|
|
u_int32_t stat;
|
2001-08-19 05:01:18 +00:00
|
|
|
int present;
|
2001-06-04 06:49:46 +00:00
|
|
|
|
|
|
|
event = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_EVENT);
|
2001-07-01 23:41:43 +00:00
|
|
|
if (event != 0) {
|
2001-08-19 05:01:18 +00:00
|
|
|
stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE);
|
|
|
|
if (bootverbose)
|
|
|
|
device_printf(sc->dev, "Event mask 0x%x stat 0x%x\n",
|
|
|
|
event, stat);
|
|
|
|
|
|
|
|
present = (stat & CB_SS_CD) == 0;
|
|
|
|
if (present != sc->cd_present) {
|
|
|
|
if (sc->cd_pending) {
|
|
|
|
untimeout(pcic_cd_insert, arg, sc->cd_ch);
|
|
|
|
sc->cd_pending = 0;
|
|
|
|
}
|
|
|
|
/* Delay insert events to debounce noisy signals. */
|
|
|
|
if (present) {
|
|
|
|
sc->cd_ch = timeout(pcic_cd_insert, arg, hz/2);
|
|
|
|
sc->cd_pending = 1;
|
|
|
|
} else {
|
|
|
|
sc->cd_present = 0;
|
|
|
|
sp->intr = NULL;
|
|
|
|
pccard_event(sp->slt, card_removed);
|
|
|
|
}
|
2001-06-04 06:49:46 +00:00
|
|
|
}
|
2001-08-19 05:01:18 +00:00
|
|
|
/* Ack the interrupt */
|
|
|
|
bus_space_write_4(sp->bst, sp->bsh, 0, event);
|
2001-06-04 06:49:46 +00:00
|
|
|
}
|
2001-07-01 23:41:43 +00:00
|
|
|
|
2001-08-01 19:41:56 +00:00
|
|
|
/*
|
2001-08-19 05:01:18 +00:00
|
|
|
* Some TI chips also require us to read the old ExCA register for
|
2001-08-01 19:41:56 +00:00
|
|
|
* card status change when we route CSC via PCI! So, we go ahead
|
|
|
|
* and read it to clear the bits. Maybe we should check the status
|
|
|
|
* ala the ISA interrupt handler, but those changes should be caught
|
|
|
|
* in the CD change.
|
|
|
|
*/
|
|
|
|
sp->getb(sp, PCIC_STAT_CHG);
|
|
|
|
|
2001-08-19 05:01:18 +00:00
|
|
|
/*
|
|
|
|
* If we have a card in the slot with an interrupt handler, then
|
|
|
|
* call it. Note: This means that each card can have at most one
|
|
|
|
* interrupt handler for it. Since multifunction cards aren't
|
|
|
|
* supported, this shouldn't cause a problem in practice.
|
|
|
|
*/
|
|
|
|
if (sc->cd_present && sp->intr != NULL)
|
|
|
|
sp->intr(sp->argp);
|
2001-06-04 06:49:46 +00:00
|
|
|
}
|
2000-03-25 20:29:55 +00:00
|
|
|
|
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
|
|
|
{
|
2001-06-04 06:49:46 +00:00
|
|
|
u_int8_t subclass;
|
|
|
|
u_int8_t progif;
|
|
|
|
const char *desc;
|
|
|
|
u_int32_t device_id;
|
2001-05-25 19:22:36 +00:00
|
|
|
struct pcic_pci_table *itm;
|
2001-06-04 06:49:46 +00:00
|
|
|
struct resource *res;
|
|
|
|
int rid;
|
2000-02-02 16:49:21 +00:00
|
|
|
|
2001-07-27 16:07:02 +00:00
|
|
|
if (pcic_ignore_function_1 && pci_get_function(dev) == 1) {
|
|
|
|
PRVERB((dev, "Ignoring function 1\n"));
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
2000-03-25 20:29:55 +00:00
|
|
|
device_id = pci_get_devid(dev);
|
2000-02-02 16:49:21 +00:00
|
|
|
desc = NULL;
|
2001-05-25 19:22:36 +00:00
|
|
|
itm = pcic_pci_lookup(device_id, &pcic_pci_devs[0]);
|
|
|
|
if (itm != NULL)
|
|
|
|
desc = itm->descr;
|
2001-07-01 23:41:57 +00:00
|
|
|
if (desc == NULL && 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
|
|
|
}
|
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);
|
1997-12-02 22:13:59 +00:00
|
|
|
|
2001-07-27 07:47:35 +00:00
|
|
|
#if __FreeBSD_version >= 430002
|
2001-06-04 17:14:28 +00:00
|
|
|
/*
|
|
|
|
* Take us out of power down mode.
|
|
|
|
*/
|
|
|
|
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
|
|
|
|
/* Reset the power state. */
|
|
|
|
device_printf(dev, "chip is in D%d power mode "
|
|
|
|
"-- setting to D0\n", pci_get_powerstate(dev));
|
|
|
|
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
|
|
|
|
}
|
2001-07-19 21:43:01 +00:00
|
|
|
#endif
|
2001-06-04 17:14:28 +00:00
|
|
|
|
2001-04-17 23:15:00 +00:00
|
|
|
/*
|
2001-06-04 06:49:46 +00:00
|
|
|
* Allocated/deallocate interrupt. This forces the PCI BIOS or
|
|
|
|
* other MD method to route the interrupts to this card.
|
2001-06-04 17:14:28 +00:00
|
|
|
* This so we get the interrupt number in the probe message.
|
2001-07-31 06:44:37 +00:00
|
|
|
* We only need to route interrupts when we're doing pci
|
|
|
|
* parallel interrupt routing.
|
2001-04-17 23:15:00 +00:00
|
|
|
*/
|
2001-08-14 05:31:56 +00:00
|
|
|
if (pcic_interrupt_route >= pci_parallel) {
|
2001-07-31 06:44:37 +00:00
|
|
|
rid = 0;
|
|
|
|
res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
|
|
|
RF_ACTIVE);
|
|
|
|
if (res)
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, rid, res);
|
|
|
|
}
|
2001-06-04 06:49:46 +00:00
|
|
|
|
|
|
|
return (0);
|
2001-04-17 23:15:00 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2001-06-04 06:49:46 +00:00
|
|
|
struct pcic_slot *sp;
|
|
|
|
struct pcic_softc *sc;
|
|
|
|
u_int32_t sockbase;
|
|
|
|
struct pcic_pci_table *itm;
|
|
|
|
int rid;
|
|
|
|
struct resource *r;
|
|
|
|
int error;
|
2001-07-31 06:44:37 +00:00
|
|
|
u_long start;
|
|
|
|
u_long end;
|
2000-03-25 20:29:55 +00:00
|
|
|
|
|
|
|
/*
|
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).
|
|
|
|
*/
|
2001-07-31 06:44:37 +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
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
sc = (struct pcic_softc *) device_get_softc(dev);
|
|
|
|
sp = &sc->slots[0];
|
|
|
|
sp->sc = sc;
|
|
|
|
sockbase = pci_read_config(dev, 0x10, 4);
|
|
|
|
if (sockbase & 0x1) {
|
2001-06-16 06:33:01 +00:00
|
|
|
device_printf(dev, "I/O mapped device, might not work.\n");
|
2001-06-09 07:34:17 +00:00
|
|
|
sc->iorid = CB_PCI_SOCKET_BASE;
|
|
|
|
sc->iores = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
|
|
|
&sc->iorid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
|
|
|
|
if (sc->iores == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
sp->getb = pcic_getb_io;
|
|
|
|
sp->putb = pcic_putb_io;
|
2001-07-31 15:53:17 +00:00
|
|
|
sp->bst = rman_get_bustag(sc->iores);
|
|
|
|
sp->bsh = rman_get_bushandle(sc->iores);
|
2001-07-31 06:44:37 +00:00
|
|
|
sp->offset = pci_get_function(dev) * PCIC_SLOT_SIZE;
|
2001-06-09 07:34:17 +00:00
|
|
|
sp->controller = PCIC_PD672X;
|
|
|
|
sp->revision = 0;
|
|
|
|
sc->flags = PCIC_PD_POWER;
|
2001-06-04 06:49:46 +00:00
|
|
|
} else {
|
|
|
|
sc->memrid = CB_PCI_SOCKET_BASE;
|
|
|
|
sc->memres = bus_alloc_resource(dev, SYS_RES_MEMORY,
|
|
|
|
&sc->memrid, 0, ~0, 1, RF_ACTIVE);
|
|
|
|
if (sc->memres == NULL && pcic_pci_get_memory(dev) != 0)
|
|
|
|
return (ENOMEM);
|
|
|
|
sp->getb = pcic_pci_getb2;
|
|
|
|
sp->putb = pcic_pci_putb2;
|
|
|
|
sp->offset = CB_EXCA_OFFSET;
|
2001-07-31 15:53:17 +00:00
|
|
|
sp->bst = rman_get_bustag(sc->memres);
|
|
|
|
sp->bsh = rman_get_bushandle(sc->memres);
|
2001-06-04 06:49:46 +00:00
|
|
|
itm = pcic_pci_lookup(device_id, &pcic_pci_devs[0]);
|
|
|
|
if (itm != NULL) {
|
|
|
|
sp->controller = itm->type;
|
|
|
|
sp->revision = itm->revision;
|
|
|
|
sc->flags = itm->flags;
|
|
|
|
} else {
|
|
|
|
/* By default, assume we're a D step compatible */
|
|
|
|
sp->controller = PCIC_I82365SL_DF;
|
|
|
|
sp->revision = 0;
|
|
|
|
sc->flags = PCIC_DF_POWER;
|
|
|
|
}
|
|
|
|
}
|
2001-07-31 06:44:37 +00:00
|
|
|
sp->slt = (struct slot *) 1;
|
2001-06-04 06:49:46 +00:00
|
|
|
sc->dev = dev;
|
2001-07-31 06:44:37 +00:00
|
|
|
sc->csc_route = pcic_interrupt_route;
|
|
|
|
sc->func_route = pcic_interrupt_route;
|
2001-06-04 06:49:46 +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:
|
2001-06-04 06:49:46 +00:00
|
|
|
pcic_pci_ricoh_init(dev, 1);
|
2001-07-31 06:44:37 +00:00
|
|
|
pcic_pci_cardbus_init(dev);
|
2001-06-04 06:49:46 +00:00
|
|
|
break;
|
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C475:
|
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C476:
|
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C477:
|
|
|
|
case PCI_DEVICE_ID_RICOH_RL5C478:
|
|
|
|
pcic_pci_ricoh_init(dev, 0);
|
2001-07-31 06:44:37 +00:00
|
|
|
pcic_pci_cardbus_init(dev);
|
2001-04-17 23:15:00 +00:00
|
|
|
break;
|
2001-06-04 06:49:46 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI1031:
|
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:
|
2001-06-04 06:49:46 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_TI4451:
|
2001-07-31 06:44:37 +00:00
|
|
|
pcic_pci_ti_init(dev);
|
|
|
|
pcic_pci_cardbus_init(dev);
|
2001-06-04 06:49:46 +00:00
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6832:
|
2001-08-14 05:31:56 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6833:
|
|
|
|
pcic_pci_pd683x_init(dev);
|
|
|
|
pcic_pci_cardbus_init(dev);
|
2000-08-29 04:40:17 +00:00
|
|
|
break;
|
2001-08-14 07:31:47 +00:00
|
|
|
#ifdef notyet
|
2001-08-14 05:31:56 +00:00
|
|
|
case PCI_DEVICE_ID_PCIC_CLPD6729:
|
|
|
|
pcic_pci_pd6729_init(dev);
|
2001-08-14 07:31:47 +00:00
|
|
|
#endif
|
2001-06-04 06:49:46 +00:00
|
|
|
default:
|
2001-07-31 06:44:37 +00:00
|
|
|
pcic_pci_cardbus_init(dev);
|
|
|
|
break;
|
1997-12-02 22:13:59 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 05:31:56 +00:00
|
|
|
if (sc->csc_route >= pci_parallel) {
|
2001-07-31 06:44:37 +00:00
|
|
|
start = 0;
|
|
|
|
end = ~0;
|
|
|
|
} else {
|
|
|
|
start = pcic_override_irq;
|
|
|
|
end = pcic_override_irq;
|
|
|
|
}
|
2001-06-04 06:49:46 +00:00
|
|
|
rid = 0;
|
|
|
|
r = NULL;
|
2001-07-31 06:44:37 +00:00
|
|
|
r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, start, end, 1,
|
2001-06-04 06:49:46 +00:00
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
|
|
|
if (r == NULL) {
|
|
|
|
device_printf(dev, "Failed to allocate managment irq\n");
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
sc->irqrid = rid;
|
|
|
|
sc->irqres = r;
|
2001-06-16 06:33:01 +00:00
|
|
|
sc->irq = rman_get_start(r);
|
2001-07-10 04:43:21 +00:00
|
|
|
error = bus_setup_intr(dev, r, INTR_TYPE_AV, pcic_pci_intr,
|
2001-06-04 06:49:46 +00:00
|
|
|
(void *) sc, &sc->ih);
|
|
|
|
if (error) {
|
|
|
|
pcic_dealloc(dev);
|
|
|
|
return (error);
|
1997-12-02 21:26:41 +00:00
|
|
|
}
|
1998-01-20 21:11:03 +00:00
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
return (pcic_attach(dev));
|
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
|
|
|
}
|
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
/*
|
|
|
|
* The PCI bus should do this for us. However, it doesn't quite yet, so
|
|
|
|
* we cope by doing it ourselves. If it ever does, this code can go quietly
|
|
|
|
* into that good night.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
pcic_pci_get_memory(device_t dev)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc;
|
|
|
|
u_int32_t sockbase;
|
|
|
|
|
|
|
|
sc = (struct pcic_softc *) device_get_softc(dev);
|
|
|
|
sockbase = pci_read_config(dev, sc->memrid, 4);
|
|
|
|
if (sockbase >= 0x100000 && sockbase < 0xfffffff0) {
|
|
|
|
device_printf(dev, "Could not map register memory\n");
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
pci_write_config(dev, sc->memrid, 0xffffffff, 4);
|
|
|
|
sockbase = pci_read_config(dev, sc->memrid, 4);
|
|
|
|
sockbase = (sockbase & 0xfffffff0) & -(sockbase & 0xfffffff0);
|
|
|
|
#define CARDBUS_SYS_RES_MEMORY_START 0x44000000
|
2001-07-31 06:44:37 +00:00
|
|
|
#define CARDBUS_SYS_RES_MEMORY_END 0xFFFFFFFF
|
2001-06-04 06:49:46 +00:00
|
|
|
sc->memres = bus_generic_alloc_resource(device_get_parent(dev),
|
|
|
|
dev, SYS_RES_MEMORY, &sc->memrid,
|
|
|
|
CARDBUS_SYS_RES_MEMORY_START, CARDBUS_SYS_RES_MEMORY_END,
|
|
|
|
sockbase, RF_ACTIVE | rman_make_alignment_flags(sockbase));
|
|
|
|
if (sc->memres == NULL) {
|
|
|
|
device_printf(dev, "Could not grab register memory\n");
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
sockbase = rman_get_start(sc->memres);
|
|
|
|
pci_write_config(dev, sc->memrid, sockbase, 4);
|
|
|
|
device_printf(dev, "PCI Memory allocated: 0x%08x\n", sockbase);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-07-01 23:41:43 +00:00
|
|
|
static int
|
|
|
|
pcic_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
|
|
|
|
int flags, driver_intr_t *intr, void *arg, void **cookiep)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) device_get_softc(dev);
|
|
|
|
struct pcic_slot *sp = &sc->slots[0];
|
|
|
|
|
2001-07-25 15:09:54 +00:00
|
|
|
if (sp->intr) {
|
|
|
|
device_printf(dev,
|
|
|
|
"Interrupt already established, possible multiple attach bug.\n");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2001-07-01 23:41:43 +00:00
|
|
|
sp->intr = intr;
|
|
|
|
sp->argp = arg;
|
|
|
|
*cookiep = sc;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pcic_pci_teardown_intr(device_t dev, device_t child, struct resource *irq,
|
|
|
|
void *cookie)
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (struct pcic_softc *) device_get_softc(dev);
|
|
|
|
struct pcic_slot *sp = &sc->slots[0];
|
|
|
|
|
|
|
|
sp->intr = NULL;
|
|
|
|
sp->argp = NULL;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, bus_generic_print_child),
|
|
|
|
DEVMETHOD(bus_alloc_resource, pcic_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
|
|
|
|
DEVMETHOD(bus_activate_resource, pcic_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource),
|
2001-07-01 23:41:43 +00:00
|
|
|
DEVMETHOD(bus_setup_intr, pcic_pci_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, pcic_pci_teardown_intr),
|
2001-06-04 06:49:46 +00:00
|
|
|
|
|
|
|
/* Card interface */
|
|
|
|
DEVMETHOD(card_set_res_flags, pcic_set_res_flags),
|
|
|
|
DEVMETHOD(card_get_res_flags, pcic_get_res_flags),
|
|
|
|
DEVMETHOD(card_set_memory_offset, pcic_set_memory_offset),
|
|
|
|
DEVMETHOD(card_get_memory_offset, pcic_get_memory_offset),
|
|
|
|
|
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 = {
|
2001-06-04 06:49:46 +00:00
|
|
|
"pcic",
|
2000-02-02 16:49:21 +00:00
|
|
|
pcic_pci_methods,
|
2001-06-04 06:49:46 +00:00
|
|
|
sizeof(struct pcic_softc)
|
2000-02-02 16:49:21 +00:00
|
|
|
};
|
1997-12-02 21:26:41 +00:00
|
|
|
|
2001-06-04 06:49:46 +00:00
|
|
|
DRIVER_MODULE(pcic, pci, pcic_pci_driver, pcic_devclass, 0, 0);
|