2000-10-18 03:25:13 +00:00
|
|
|
/*
|
2004-01-04 22:10:00 +00:00
|
|
|
* Copyright (c) 2002-2004 M. Warner Losh.
|
|
|
|
* Copyright (c) 2000-2001 Jonathan Chen.
|
2000-10-18 03:25:13 +00:00
|
|
|
* 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,
|
|
|
|
* without modification, immediately at the beginning of the file.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
|
|
|
*/
|
|
|
|
|
2002-04-13 04:07:07 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1998, 1999 and 2000
|
|
|
|
* HAYAKAWA Koichi. 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by HAYAKAWA Koichi.
|
|
|
|
* 4. 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.
|
|
|
|
*/
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/*
|
2002-10-11 04:30:59 +00:00
|
|
|
* Driver for PCI to CardBus Bridge chips
|
2000-10-18 03:25:13 +00:00
|
|
|
*
|
|
|
|
* References:
|
|
|
|
* TI Datasheets:
|
|
|
|
* http://www-s.ti.com/cgi-bin/sc/generic2.cgi?family=PCI+CARDBUS+CONTROLLERS
|
|
|
|
*
|
|
|
|
* Written by Jonathan Chen <jon@freebsd.org>
|
|
|
|
* The author would like to acknowledge:
|
|
|
|
* * HAYAKAWA Koichi: Author of the NetBSD code for the same thing
|
|
|
|
* * Warner Losh: Newbus/newcard guru and author of the pccard side of things
|
|
|
|
* * YAMAMOTO Shigeru: Author of another FreeBSD cardbus driver
|
|
|
|
* * David Cross: Author of the initial ugly hack for a specific cardbus card
|
|
|
|
*/
|
|
|
|
|
2003-11-12 05:21:06 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2002-06-13 07:19:31 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/condvar.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-05-30 17:57:46 +00:00
|
|
|
#include <sys/module.h>
|
2001-03-29 10:23:45 +00:00
|
|
|
#include <sys/lock.h>
|
2001-03-30 16:05:50 +00:00
|
|
|
#include <sys/malloc.h>
|
2000-11-28 00:05:20 +00:00
|
|
|
#include <sys/mutex.h>
|
2001-11-26 07:17:09 +00:00
|
|
|
#include <sys/sysctl.h>
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
#include <sys/kthread.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
2003-08-22 06:42:59 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
#include <machine/clock.h>
|
|
|
|
|
|
|
|
#include <dev/pccard/pccardreg.h>
|
|
|
|
#include <dev/pccard/pccardvar.h>
|
2002-01-29 06:50:18 +00:00
|
|
|
|
|
|
|
#include <dev/exca/excareg.h>
|
|
|
|
#include <dev/exca/excavar.h>
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
#include <dev/pccbb/pccbbreg.h>
|
|
|
|
#include <dev/pccbb/pccbbvar.h>
|
|
|
|
|
|
|
|
#include "power_if.h"
|
|
|
|
#include "card_if.h"
|
|
|
|
#include "pcib_if.h"
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
#define DPRINTF(x) do { if (cbb_debug) printf x; } while (0)
|
|
|
|
#define DEVPRINTF(x) do { if (cbb_debug) device_printf x; } while (0)
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
#define PCI_MASK_CONFIG(DEV,REG,MASK,SIZE) \
|
2000-10-18 03:25:13 +00:00
|
|
|
pci_write_config(DEV, REG, pci_read_config(DEV, REG, SIZE) MASK, SIZE)
|
|
|
|
#define PCI_MASK2_CONFIG(DEV,REG,MASK1,MASK2,SIZE) \
|
|
|
|
pci_write_config(DEV, REG, ( \
|
|
|
|
pci_read_config(DEV, REG, SIZE) MASK1) MASK2, SIZE)
|
|
|
|
|
2003-08-20 06:13:01 +00:00
|
|
|
#define CBB_CARD_PRESENT(s) ((s & CBB_STATE_CD) == 0)
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
#define CBB_START_MEM 0x88000000
|
|
|
|
#define CBB_START_32_IO 0x1000
|
|
|
|
#define CBB_START_16_IO 0x100
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
struct yenta_chipinfo {
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t yc_id;
|
2001-08-26 23:55:34 +00:00
|
|
|
const char *yc_name;
|
|
|
|
int yc_chiptype;
|
2000-10-18 03:25:13 +00:00
|
|
|
} yc_chipsets[] = {
|
|
|
|
/* Texas Instruments chips */
|
2002-07-26 08:05:25 +00:00
|
|
|
{PCIC_ID_TI1031, "TI1031 PCI-PC Card Bridge", CB_TI113X},
|
|
|
|
{PCIC_ID_TI1130, "TI1130 PCI-CardBus Bridge", CB_TI113X},
|
|
|
|
{PCIC_ID_TI1131, "TI1131 PCI-CardBus Bridge", CB_TI113X},
|
|
|
|
|
|
|
|
{PCIC_ID_TI1210, "TI1210 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1211, "TI1211 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1220, "TI1220 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1221, "TI1221 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1225, "TI1225 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1250, "TI1250 PCI-CardBus Bridge", CB_TI125X},
|
|
|
|
{PCIC_ID_TI1251, "TI1251 PCI-CardBus Bridge", CB_TI125X},
|
|
|
|
{PCIC_ID_TI1251B,"TI1251B PCI-CardBus Bridge",CB_TI125X},
|
|
|
|
{PCIC_ID_TI1260, "TI1260 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1260B,"TI1260B PCI-CardBus Bridge",CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1410, "TI1410 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1420, "TI1420 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1421, "TI1421 PCI-CardBus Bridge", CB_TI12XX},
|
2002-10-07 23:11:29 +00:00
|
|
|
{PCIC_ID_TI1450, "TI1450 PCI-CardBus Bridge", CB_TI125X}, /*SIC!*/
|
2002-07-26 08:05:25 +00:00
|
|
|
{PCIC_ID_TI1451, "TI1451 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1510, "TI1510 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI1520, "TI1520 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI4410, "TI4410 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI4450, "TI4450 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI4451, "TI4451 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_TI4510, "TI4510 PCI-CardBus Bridge", CB_TI12XX},
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-08-22 08:49:56 +00:00
|
|
|
/* ENE */
|
2003-12-22 06:09:35 +00:00
|
|
|
{PCIC_ID_ENE_CB710, "ENE CB710 PCI-CardBus Bridge", CB_TI12XX},
|
2003-08-22 08:49:56 +00:00
|
|
|
{PCIC_ID_ENE_CB720, "ENE CB720 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_ENE_CB1211, "ENE CB1211 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_ENE_CB1225, "ENE CB1225 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_ENE_CB1410, "ENE CB1410 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
{PCIC_ID_ENE_CB1420, "ENE CB1420 PCI-CardBus Bridge", CB_TI12XX},
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/* Ricoh chips */
|
2002-07-26 08:05:25 +00:00
|
|
|
{PCIC_ID_RICOH_RL5C465, "RF5C465 PCI-CardBus Bridge", CB_RF5C46X},
|
|
|
|
{PCIC_ID_RICOH_RL5C466, "RF5C466 PCI-CardBus Bridge", CB_RF5C46X},
|
|
|
|
{PCIC_ID_RICOH_RL5C475, "RF5C475 PCI-CardBus Bridge", CB_RF5C47X},
|
|
|
|
{PCIC_ID_RICOH_RL5C476, "RF5C476 PCI-CardBus Bridge", CB_RF5C47X},
|
|
|
|
{PCIC_ID_RICOH_RL5C477, "RF5C477 PCI-CardBus Bridge", CB_RF5C47X},
|
|
|
|
{PCIC_ID_RICOH_RL5C478, "RF5C478 PCI-CardBus Bridge", CB_RF5C47X},
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* Toshiba products */
|
2002-07-26 08:05:25 +00:00
|
|
|
{PCIC_ID_TOPIC95, "ToPIC95 PCI-CardBus Bridge", CB_TOPIC95},
|
|
|
|
{PCIC_ID_TOPIC95B, "ToPIC95B PCI-CardBus Bridge", CB_TOPIC95},
|
|
|
|
{PCIC_ID_TOPIC97, "ToPIC97 PCI-CardBus Bridge", CB_TOPIC97},
|
|
|
|
{PCIC_ID_TOPIC100, "ToPIC100 PCI-CardBus Bridge", CB_TOPIC97},
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* Cirrus Logic */
|
2002-07-26 08:05:25 +00:00
|
|
|
{PCIC_ID_CLPD6832, "CLPD6832 PCI-CardBus Bridge", CB_CIRRUS},
|
|
|
|
{PCIC_ID_CLPD6833, "CLPD6833 PCI-CardBus Bridge", CB_CIRRUS},
|
|
|
|
{PCIC_ID_CLPD6834, "CLPD6834 PCI-CardBus Bridge", CB_CIRRUS},
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-04-11 06:40:35 +00:00
|
|
|
/* 02Micro */
|
2003-06-06 06:00:49 +00:00
|
|
|
{PCIC_ID_OZ6832, "O2Micro OZ6832/6833 PCI-CardBus Bridge", CB_O2MICRO},
|
|
|
|
{PCIC_ID_OZ6860, "O2Micro OZ6836/6860 PCI-CardBus Bridge", CB_O2MICRO},
|
|
|
|
{PCIC_ID_OZ6872, "O2Micro OZ6812/6872 PCI-CardBus Bridge", CB_O2MICRO},
|
|
|
|
{PCIC_ID_OZ6912, "O2Micro OZ6912/6972 PCI-CardBus Bridge", CB_O2MICRO},
|
|
|
|
{PCIC_ID_OZ6922, "O2Micro OZ6922 PCI-CardBus Bridge", CB_O2MICRO},
|
|
|
|
{PCIC_ID_OZ6933, "O2Micro OZ6933 PCI-CardBus Bridge", CB_O2MICRO},
|
2004-01-04 22:10:00 +00:00
|
|
|
{PCIC_ID_OZ711E1, "O2Micro OZ711E1 PCI-CardBus Bridge", CB_O2MICRO},
|
2001-04-11 06:40:35 +00:00
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/* sentinel */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
{0 /* null id */, "unknown", CB_UNKNOWN},
|
2000-10-18 03:25:13 +00:00
|
|
|
};
|
|
|
|
|
2001-11-26 07:17:09 +00:00
|
|
|
/* sysctl vars */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters");
|
2001-11-26 07:17:09 +00:00
|
|
|
|
|
|
|
/* There's no way to say TUNEABLE_LONG to get the right types */
|
2002-08-15 08:01:24 +00:00
|
|
|
u_long cbb_start_mem = CBB_START_MEM;
|
|
|
|
TUNABLE_INT("hw.cbb.start_memory", (int *)&cbb_start_mem);
|
2002-04-29 07:41:58 +00:00
|
|
|
SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RW,
|
2002-08-15 08:01:24 +00:00
|
|
|
&cbb_start_mem, CBB_START_MEM,
|
2001-11-26 07:17:09 +00:00
|
|
|
"Starting address for memory allocations");
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
u_long cbb_start_16_io = CBB_START_16_IO;
|
|
|
|
TUNABLE_INT("hw.cbb.start_16_io", (int *)&cbb_start_16_io);
|
2002-04-29 07:37:09 +00:00
|
|
|
SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW,
|
2002-08-15 08:01:24 +00:00
|
|
|
&cbb_start_16_io, CBB_START_16_IO,
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
"Starting ioport for 16-bit cards");
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
u_long cbb_start_32_io = CBB_START_32_IO;
|
|
|
|
TUNABLE_INT("hw.cbb.start_32_io", (int *)&cbb_start_32_io);
|
2002-04-29 07:37:09 +00:00
|
|
|
SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RW,
|
2002-08-15 08:01:24 +00:00
|
|
|
&cbb_start_32_io, CBB_START_32_IO,
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
"Starting ioport for 32-bit cards");
|
|
|
|
|
|
|
|
int cbb_debug = 0;
|
|
|
|
TUNABLE_INT("hw.cbb.debug", &cbb_debug);
|
2002-04-29 07:37:09 +00:00
|
|
|
SYSCTL_ULONG(_hw_cbb, OID_AUTO, debug, CTLFLAG_RW, &cbb_debug, 0,
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
"Verbose cardbus bridge debugging");
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_chipset(uint32_t pci_id, const char **namep);
|
|
|
|
static int cbb_probe(device_t brdev);
|
|
|
|
static void cbb_chipinit(struct cbb_softc *sc);
|
|
|
|
static int cbb_attach(device_t brdev);
|
|
|
|
static int cbb_detach(device_t brdev);
|
|
|
|
static int cbb_shutdown(device_t brdev);
|
|
|
|
static void cbb_driver_added(device_t brdev, driver_t *driver);
|
|
|
|
static void cbb_child_detached(device_t brdev, device_t child);
|
|
|
|
static void cbb_event_thread(void *arg);
|
|
|
|
static void cbb_insert(struct cbb_softc *sc);
|
|
|
|
static void cbb_removal(struct cbb_softc *sc);
|
|
|
|
static void cbb_intr(void *arg);
|
|
|
|
static int cbb_detect_voltage(device_t brdev);
|
|
|
|
static int cbb_power(device_t brdev, int volts);
|
|
|
|
static void cbb_cardbus_reset(device_t brdev);
|
|
|
|
static int cbb_cardbus_power_enable_socket(device_t brdev,
|
2001-08-26 23:55:34 +00:00
|
|
|
device_t child);
|
2002-08-15 08:01:24 +00:00
|
|
|
static void cbb_cardbus_power_disable_socket(device_t brdev,
|
2001-08-26 23:55:34 +00:00
|
|
|
device_t child);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_cardbus_io_open(device_t brdev, int win, uint32_t start,
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t end);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_cardbus_mem_open(device_t brdev, int win,
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t start, uint32_t end);
|
2002-08-15 08:01:24 +00:00
|
|
|
static void cbb_cardbus_auto_open(struct cbb_softc *sc, int type);
|
|
|
|
static int cbb_cardbus_activate_resource(device_t brdev, device_t child,
|
2001-08-27 00:09:42 +00:00
|
|
|
int type, int rid, struct resource *res);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_cardbus_deactivate_resource(device_t brdev,
|
2001-08-27 00:09:42 +00:00
|
|
|
device_t child, int type, int rid, struct resource *res);
|
2002-08-15 08:01:24 +00:00
|
|
|
static struct resource *cbb_cardbus_alloc_resource(device_t brdev,
|
2001-08-26 23:55:34 +00:00
|
|
|
device_t child, int type, int *rid, u_long start,
|
2003-08-07 15:04:27 +00:00
|
|
|
u_long end, u_long count, u_int flags);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_cardbus_release_resource(device_t brdev, device_t child,
|
2001-08-27 00:09:42 +00:00
|
|
|
int type, int rid, struct resource *res);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_power_enable_socket(device_t brdev, device_t child);
|
|
|
|
static void cbb_power_disable_socket(device_t brdev, device_t child);
|
|
|
|
static int cbb_activate_resource(device_t brdev, device_t child,
|
2001-08-26 23:55:34 +00:00
|
|
|
int type, int rid, struct resource *r);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_deactivate_resource(device_t brdev, device_t child,
|
2001-08-26 23:55:34 +00:00
|
|
|
int type, int rid, struct resource *r);
|
2002-08-15 08:01:24 +00:00
|
|
|
static struct resource *cbb_alloc_resource(device_t brdev, device_t child,
|
2001-08-27 00:09:42 +00:00
|
|
|
int type, int *rid, u_long start, u_long end, u_long count,
|
2003-08-07 15:04:27 +00:00
|
|
|
u_int flags);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_release_resource(device_t brdev, device_t child,
|
2001-08-26 23:55:34 +00:00
|
|
|
int type, int rid, struct resource *r);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_read_ivar(device_t brdev, device_t child, int which,
|
2001-08-26 23:55:34 +00:00
|
|
|
uintptr_t *result);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_write_ivar(device_t brdev, device_t child, int which,
|
2001-08-26 23:55:34 +00:00
|
|
|
uintptr_t value);
|
2002-08-15 08:01:24 +00:00
|
|
|
static int cbb_maxslots(device_t brdev);
|
|
|
|
static uint32_t cbb_read_config(device_t brdev, int b, int s, int f,
|
2001-08-26 23:55:34 +00:00
|
|
|
int reg, int width);
|
2002-08-15 08:01:24 +00:00
|
|
|
static void cbb_write_config(device_t brdev, int b, int s, int f,
|
2002-01-14 02:59:06 +00:00
|
|
|
int reg, uint32_t val, int width);
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
static __inline void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(struct cbb_softc *sc, uint32_t reg, uint32_t val)
|
2002-01-14 02:59:06 +00:00
|
|
|
{
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
bus_space_write_4(sc->bst, sc->bsh, reg, val);
|
2002-01-14 02:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline uint32_t
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_get(struct cbb_softc *sc, uint32_t reg)
|
2002-01-14 02:59:06 +00:00
|
|
|
{
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
return (bus_space_read_4(sc->bst, sc->bsh, reg));
|
2002-01-14 02:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_setb(struct cbb_softc *sc, uint32_t reg, uint32_t bits)
|
2002-01-14 02:59:06 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, reg, cbb_get(sc, reg) | bits);
|
2002-01-14 02:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_clrb(struct cbb_softc *sc, uint32_t reg, uint32_t bits)
|
2002-01-14 02:59:06 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, reg, cbb_get(sc, reg) & ~bits);
|
2002-01-14 02:59:06 +00:00
|
|
|
}
|
|
|
|
|
2002-01-29 06:50:18 +00:00
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_remove_res(struct cbb_softc *sc, struct resource *res)
|
2002-01-29 06:50:18 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_reslist *rle;
|
2002-01-29 06:50:18 +00:00
|
|
|
|
|
|
|
SLIST_FOREACH(rle, &sc->rl, link) {
|
|
|
|
if (rle->res == res) {
|
2002-08-15 08:01:24 +00:00
|
|
|
SLIST_REMOVE(&sc->rl, rle, cbb_reslist, link);
|
2002-01-29 06:50:18 +00:00
|
|
|
free(rle, M_DEVBUF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource *
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_find_res(struct cbb_softc *sc, int type, int rid)
|
2002-01-14 02:59:06 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_reslist *rle;
|
2002-01-29 06:50:18 +00:00
|
|
|
|
|
|
|
SLIST_FOREACH(rle, &sc->rl, link)
|
|
|
|
if (SYS_RES_MEMORY == rle->type && rid == rle->rid)
|
|
|
|
return (rle->res);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_insert_res(struct cbb_softc *sc, struct resource *res, int type,
|
2002-01-29 06:50:18 +00:00
|
|
|
int rid)
|
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_reslist *rle;
|
2002-01-29 06:50:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Need to record allocated resource so we can iterate through
|
|
|
|
* it later.
|
|
|
|
*/
|
2002-08-15 08:01:24 +00:00
|
|
|
rle = malloc(sizeof(struct cbb_reslist), M_DEVBUF, M_NOWAIT);
|
2003-11-12 05:21:06 +00:00
|
|
|
if (rle == NULL)
|
2002-08-15 08:01:24 +00:00
|
|
|
panic("cbb_cardbus_alloc_resource: can't record entry!");
|
2002-01-29 06:50:18 +00:00
|
|
|
rle->res = res;
|
|
|
|
rle->type = type;
|
|
|
|
rle->rid = rid;
|
|
|
|
SLIST_INSERT_HEAD(&sc->rl, rle, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_destroy_res(struct cbb_softc *sc)
|
2002-01-29 06:50:18 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_reslist *rle;
|
2002-01-29 06:50:18 +00:00
|
|
|
|
|
|
|
while ((rle = SLIST_FIRST(&sc->rl)) != NULL) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
device_printf(sc->dev, "Danger Will Robinson: Resource "
|
2002-01-29 06:50:18 +00:00
|
|
|
"left allocated! This is a bug... "
|
|
|
|
"(rid=%x, type=%d, addr=%lx)\n", rle->rid, rle->type,
|
|
|
|
rman_get_start(rle->res));
|
|
|
|
SLIST_REMOVE_HEAD(&sc->rl, link);
|
|
|
|
free(rle, M_DEVBUF);
|
|
|
|
}
|
2002-01-14 02:59:06 +00:00
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* Probe/Attach */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_chipset(uint32_t pci_id, const char **namep)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
struct yenta_chipinfo *ycp;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
for (ycp = yc_chipsets; ycp->yc_id != 0 && pci_id != ycp->yc_id; ++ycp)
|
2002-01-15 20:41:39 +00:00
|
|
|
continue;
|
2002-01-29 06:50:18 +00:00
|
|
|
if (namep != NULL)
|
2000-10-18 03:25:13 +00:00
|
|
|
*namep = ycp->yc_name;
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ycp->yc_chiptype);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_probe(device_t brdev)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
const char *name;
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
uint32_t progif;
|
|
|
|
uint32_t subclass;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
|
|
|
* Do we know that we support the chipset? If so, then we
|
|
|
|
* accept the device.
|
|
|
|
*/
|
2002-08-15 08:01:24 +00:00
|
|
|
if (cbb_chipset(pci_get_devid(brdev), &name) != CB_UNKNOWN) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
device_set_desc(brdev, name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We do support generic CardBus bridges. All that we've seen
|
|
|
|
* to date have progif 0 (the Yenta spec, and successors mandate
|
|
|
|
* this). We do not support PCI PCMCIA bridges (with one exception)
|
|
|
|
* with this driver since they generally are I/O mapped. Those
|
|
|
|
* are supported by the pcic driver. This should help us be more
|
|
|
|
* future proof.
|
|
|
|
*/
|
|
|
|
subclass = pci_get_subclass(brdev);
|
|
|
|
progif = pci_get_progif(brdev);
|
|
|
|
if (subclass == PCIS_BRIDGE_CARDBUS && progif == 0) {
|
|
|
|
device_set_desc(brdev, "PCI-CardBus Bridge");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (ENXIO);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
|
2003-08-10 02:40:49 +00:00
|
|
|
/*
|
|
|
|
* Disable function interrupts by telling the bridge to generate IRQ1
|
|
|
|
* interrupts. These interrupts aren't really generated by the chip, since
|
|
|
|
* IRQ1 is reserved. Some chipsets assert INTA# inappropriately during
|
|
|
|
* initialization, so this helps to work around the problem.
|
2003-11-07 23:12:59 +00:00
|
|
|
*
|
|
|
|
* XXX We can't do this workaround for all chipsets, because this
|
|
|
|
* XXX causes interference with the keyboard because somechipsets will
|
|
|
|
* XXX actually signal IRQ1 over their serial interrupt connections to
|
|
|
|
* XXX the south bridge. Disable it it for now.
|
2003-08-10 02:40:49 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
cbb_disable_func_intr(struct cbb_softc *sc)
|
|
|
|
{
|
2003-11-08 03:28:43 +00:00
|
|
|
#if 0
|
2003-08-10 02:40:49 +00:00
|
|
|
uint8_t reg;
|
|
|
|
|
|
|
|
reg = (exca_getb(&sc->exca, EXCA_INTR) & ~EXCA_INTR_IRQ_MASK) |
|
|
|
|
EXCA_INTR_IRQ_RESERVED1;
|
|
|
|
exca_putb(&sc->exca, EXCA_INTR, reg);
|
2003-11-07 23:12:59 +00:00
|
|
|
#endif
|
2003-08-10 02:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable function interrupts. We turn on function interrupts when the card
|
|
|
|
* requests an interrupt. The PCMCIA standard says that we should set
|
|
|
|
* the lower 4 bits to 0 to route via PCI. Note: we call this for both
|
|
|
|
* CardBus and R2 (PC Card) cases, but it should have no effect on CardBus
|
|
|
|
* cards.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
cbb_enable_func_intr(struct cbb_softc *sc)
|
|
|
|
{
|
|
|
|
uint8_t reg;
|
|
|
|
|
|
|
|
reg = (exca_getb(&sc->exca, EXCA_INTR) & ~EXCA_INTR_IRQ_MASK) |
|
|
|
|
EXCA_INTR_IRQ_NONE;
|
|
|
|
exca_putb(&sc->exca, EXCA_INTR, reg);
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_chipinit(struct cbb_softc *sc)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2003-06-06 06:00:49 +00:00
|
|
|
uint32_t mux, sysctrl, reg;
|
2002-07-26 08:05:25 +00:00
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/* Set CardBus latency timer */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (pci_read_config(sc->dev, PCIR_SECLAT_1, 1) < 0x20)
|
|
|
|
pci_write_config(sc->dev, PCIR_SECLAT_1, 0x20, 1);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* Set PCI latency timer */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (pci_read_config(sc->dev, PCIR_LATTIMER, 1) < 0x20)
|
|
|
|
pci_write_config(sc->dev, PCIR_LATTIMER, 0x20, 1);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* Enable memory access */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(sc->dev, PCIR_COMMAND,
|
2001-08-26 23:55:34 +00:00
|
|
|
| PCIM_CMD_MEMEN
|
|
|
|
| PCIM_CMD_PORTEN
|
|
|
|
| PCIM_CMD_BUSMASTEREN, 2);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* disable Legacy IO */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
switch (sc->chipset) {
|
2000-10-18 03:25:13 +00:00
|
|
|
case CB_RF5C46X:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(sc->dev, CBBR_BRIDGECTRL,
|
|
|
|
& ~(CBBM_BRIDGECTRL_RL_3E0_EN |
|
|
|
|
CBBM_BRIDGECTRL_RL_3E2_EN), 2);
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
pci_write_config(sc->dev, CBBR_LEGACY, 0x0, 4);
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use PCI interrupt for interrupt routing */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK2_CONFIG(sc->dev, CBBR_BRIDGECTRL,
|
|
|
|
& ~(CBBM_BRIDGECTRL_MASTER_ABORT |
|
|
|
|
CBBM_BRIDGECTRL_INTR_IREQ_EN),
|
|
|
|
| CBBM_BRIDGECTRL_WRITE_POST_EN,
|
2001-08-26 23:55:34 +00:00
|
|
|
2);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
|
|
|
* XXX this should be a function table, ala OLDCARD. This means
|
|
|
|
* that we could more easily support ISA interrupts for pccard
|
|
|
|
* cards if we had to.
|
|
|
|
*/
|
|
|
|
switch (sc->chipset) {
|
2000-10-18 03:25:13 +00:00
|
|
|
case CB_TI113X:
|
2001-08-29 20:33:08 +00:00
|
|
|
/*
|
2002-01-15 20:21:43 +00:00
|
|
|
* The TI 1031, TI 1130 and TI 1131 all require another bit
|
2001-08-29 20:33:08 +00:00
|
|
|
* be set to enable PCI routing of interrupts, and then
|
|
|
|
* a bit for each of the CSC and Function interrupts we
|
|
|
|
* want routed.
|
|
|
|
*/
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(sc->dev, CBBR_CBCTRL,
|
|
|
|
| CBBM_CBCTRL_113X_PCI_INTR |
|
|
|
|
CBBM_CBCTRL_113X_PCI_CSC | CBBM_CBCTRL_113X_PCI_IRQ_EN,
|
2001-08-29 20:33:08 +00:00
|
|
|
1);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(sc->dev, CBBR_DEVCTRL,
|
|
|
|
& ~(CBBM_DEVCTRL_INT_SERIAL |
|
|
|
|
CBBM_DEVCTRL_INT_PCI), 1);
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
2002-07-26 08:05:25 +00:00
|
|
|
case CB_TI12XX:
|
|
|
|
/*
|
|
|
|
* Some TI 12xx (and [14][45]xx) based pci cards
|
|
|
|
* sometimes have issues with the MFUNC register not
|
|
|
|
* being initialized due to a bad EEPROM on board.
|
|
|
|
* Laptops that this matters on have this register
|
|
|
|
* properly initialized.
|
|
|
|
*
|
|
|
|
* The TI125X parts have a different register.
|
|
|
|
*/
|
|
|
|
mux = pci_read_config(sc->dev, CBBR_MFUNC, 4);
|
|
|
|
sysctrl = pci_read_config(sc->dev, CBBR_SYSCTRL, 4);
|
|
|
|
if (mux == 0) {
|
|
|
|
mux = (mux & ~CBBM_MFUNC_PIN0) |
|
|
|
|
CBBM_MFUNC_PIN0_INTA;
|
|
|
|
if ((sysctrl & CBBM_SYSCTRL_INTRTIE) == 0)
|
|
|
|
mux = (mux & ~CBBM_MFUNC_PIN1) |
|
|
|
|
CBBM_MFUNC_PIN1_INTB;
|
|
|
|
pci_write_config(sc->dev, CBBR_MFUNC, mux, 4);
|
|
|
|
}
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
case CB_TI125X:
|
|
|
|
/*
|
|
|
|
* Disable zoom video. Some machines initialize this
|
|
|
|
* improperly and exerpience has shown that this helps
|
2003-08-09 20:31:25 +00:00
|
|
|
* prevent strange behavior.
|
2002-07-26 08:05:25 +00:00
|
|
|
*/
|
|
|
|
pci_write_config(sc->dev, CBBR_MMCTRL, 0, 4);
|
2003-06-06 06:00:49 +00:00
|
|
|
break;
|
|
|
|
case CB_O2MICRO:
|
|
|
|
/*
|
|
|
|
* Issue #1: INT# generated at the same time as
|
|
|
|
* selected ISA IRQ. When IREQ# or STSCHG# is active,
|
|
|
|
* in addition to the ISA IRQ being generated, INT#
|
|
|
|
* will also be generated at the same time.
|
|
|
|
*
|
2003-08-09 20:31:25 +00:00
|
|
|
* Some of the older controllers have an issue in
|
2003-06-06 06:00:49 +00:00
|
|
|
* which the slot's PCI INT# will be asserted whenever
|
|
|
|
* IREQ# or STSCGH# is asserted even if ExCA registers
|
|
|
|
* 03h or 05h have an ISA IRQ selected.
|
|
|
|
*
|
|
|
|
* The fix for this issue, which will work for any
|
|
|
|
* controller (old or new), is to set ExCA registers
|
|
|
|
* 3Ah (slot 0) & 7Ah (slot 1) bits 7:4 = 1010b.
|
|
|
|
* These bits are undocumented. By setting this
|
|
|
|
* register (of each slot) to '1010xxxxb' a routing of
|
|
|
|
* IREQ# to INTC# and STSCHG# to INTC# is selected.
|
|
|
|
* Since INTC# isn't connected there will be no
|
|
|
|
* unexpected PCI INT when IREQ# or STSCHG# is active.
|
|
|
|
* However, INTA# (slot 0) or INTB# (slot 1) will
|
|
|
|
* still be correctly generated if NO ISA IRQ is
|
|
|
|
* selected (ExCA regs 03h or 05h are cleared).
|
|
|
|
*/
|
|
|
|
reg = exca_getb(&sc->exca, EXCA_O2MICRO_CTRL_C);
|
|
|
|
reg = (reg & 0x0f) |
|
|
|
|
EXCA_O2CC_IREQ_INTC | EXCA_O2CC_STSCHG_INTC;
|
|
|
|
exca_putb(&sc->exca, EXCA_O2MICRO_CTRL_C, reg);
|
|
|
|
|
2002-07-26 08:05:25 +00:00
|
|
|
break;
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
case CB_TOPIC97:
|
|
|
|
/*
|
|
|
|
* Disable Zoom Video, ToPIC 97, 100.
|
|
|
|
*/
|
|
|
|
pci_write_config(sc->dev, CBBR_TOPIC_ZV_CONTROL, 0, 1);
|
|
|
|
/*
|
|
|
|
* ToPIC 97, 100
|
|
|
|
* At offset 0xa1: INTERRUPT CONTROL register
|
|
|
|
* 0x1: Turn on INT interrupts.
|
|
|
|
*/
|
|
|
|
PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_INTCTRL,
|
|
|
|
| CBBM_TOPIC_INTCTRL_INTIRQSEL, 1);
|
|
|
|
goto topic_common;
|
|
|
|
case CB_TOPIC95:
|
|
|
|
/*
|
|
|
|
* SOCKETCTRL appears to be TOPIC 95/B specific
|
|
|
|
*/
|
|
|
|
PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_SOCKETCTRL,
|
|
|
|
| CBBM_TOPIC_SOCKETCTRL_SCR_IRQSEL, 4);
|
|
|
|
|
|
|
|
topic_common:;
|
|
|
|
/*
|
|
|
|
* At offset 0xa0: SLOT CONTROL
|
2002-10-11 04:30:59 +00:00
|
|
|
* 0x80 Enable CardBus Functionality
|
|
|
|
* 0x40 Enable CardBus and PC Card registers
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
* 0x20 Lock ID in exca regs
|
|
|
|
* 0x10 Write protect ID in config regs
|
|
|
|
* Clear the rest of the bits, which defaults the slot
|
|
|
|
* in legacy mode to 0x3e0 and offset 0. (legacy
|
|
|
|
* mode is determined elsewhere)
|
|
|
|
*/
|
|
|
|
pci_write_config(sc->dev, CBBR_TOPIC_SLOTCTRL,
|
|
|
|
CBBM_TOPIC_SLOTCTRL_SLOTON |
|
|
|
|
CBBM_TOPIC_SLOTCTRL_SLOTEN |
|
|
|
|
CBBM_TOPIC_SLOTCTRL_ID_LOCK |
|
|
|
|
CBBM_TOPIC_SLOTCTRL_ID_WP, 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At offset 0xa3 Card Detect Control Register
|
|
|
|
* 0x80 CARDBUS enbale
|
|
|
|
* 0x01 Cleared for hardware change detect
|
|
|
|
*/
|
|
|
|
PCI_MASK2_CONFIG(sc->dev, CBBR_TOPIC_CDC,
|
|
|
|
| CBBM_TOPIC_CDC_CARDBUS,
|
|
|
|
& ~CBBM_TOPIC_CDC_SWDETECT, 4);
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
2003-08-10 02:40:49 +00:00
|
|
|
* Need to tell ExCA registers to CSC interrupts route via PCI
|
|
|
|
* interrupts. There are two ways to do this. Once is to set
|
|
|
|
* INTR_ENABLE and the other is to set CSC to 0. Since both
|
|
|
|
* methods are mutually compatible, we do both.
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
*/
|
2003-02-14 06:21:51 +00:00
|
|
|
exca_putb(&sc->exca, EXCA_INTR, EXCA_INTR_ENABLE);
|
|
|
|
exca_putb(&sc->exca, EXCA_CSC_INTR, 0);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
|
2003-08-10 02:40:49 +00:00
|
|
|
cbb_disable_func_intr(sc);
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/* close all memory and io windows */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
pci_write_config(sc->dev, CBBR_MEMBASE0, 0xffffffff, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_MEMLIMIT0, 0, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_MEMBASE1, 0xffffffff, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_MEMLIMIT1, 0, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_IOBASE0, 0xffffffff, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_IOLIMIT0, 0, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_IOBASE1, 0xffffffff, 4);
|
|
|
|
pci_write_config(sc->dev, CBBR_IOLIMIT1, 0, 4);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-03 14:00:57 +00:00
|
|
|
#ifndef BURN_BRIDGES
|
2004-05-21 06:10:13 +00:00
|
|
|
/*
|
|
|
|
* Still need this because the pci code only does power for type 0
|
|
|
|
* header devices.
|
|
|
|
*/
|
2003-06-06 06:00:49 +00:00
|
|
|
static void
|
|
|
|
cbb_powerstate_d0(device_t dev)
|
|
|
|
{
|
|
|
|
u_int32_t membase, irq;
|
|
|
|
|
|
|
|
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
|
|
|
|
/* Save important PCI config data. */
|
|
|
|
membase = pci_read_config(dev, CBBR_SOCKBASE, 4);
|
|
|
|
irq = pci_read_config(dev, PCIR_INTLINE, 4);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* Restore PCI config data. */
|
|
|
|
pci_write_config(dev, CBBR_SOCKBASE, membase, 4);
|
|
|
|
pci_write_config(dev, PCIR_INTLINE, irq, 4);
|
|
|
|
}
|
|
|
|
}
|
2003-07-03 14:00:57 +00:00
|
|
|
#endif
|
2003-06-06 06:00:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Print out the config space
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
cbb_print_config(device_t dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
device_printf(dev, "PCI Configuration space:");
|
|
|
|
for (i = 0; i < 256; i += 4) {
|
|
|
|
if (i % 16 == 0)
|
|
|
|
printf("\n 0x%02x: ", i);
|
|
|
|
printf("0x%08x ", pci_read_config(dev, i, 4));
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_attach(device_t brdev)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2004-05-21 06:10:13 +00:00
|
|
|
static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
|
2004-04-23 05:25:13 +00:00
|
|
|
int rid, bus, pribus;
|
|
|
|
device_t parent;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2004-04-23 05:25:13 +00:00
|
|
|
parent = device_get_parent(brdev);
|
2002-08-15 08:01:24 +00:00
|
|
|
mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF);
|
|
|
|
cv_init(&sc->cv, "cbb cv");
|
|
|
|
sc->chipset = cbb_chipset(pci_get_devid(brdev), NULL);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
sc->dev = brdev;
|
|
|
|
sc->cbdev = NULL;
|
2003-06-07 20:47:35 +00:00
|
|
|
sc->exca.pccarddev = NULL;
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
|
|
|
|
sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
|
2000-10-18 03:25:13 +00:00
|
|
|
SLIST_INIT(&sc->rl);
|
2002-10-07 23:11:29 +00:00
|
|
|
STAILQ_INIT(&sc->intr_handlers);
|
2003-07-03 14:00:57 +00:00
|
|
|
#ifndef BURN_BRIDGES
|
2003-06-06 06:00:49 +00:00
|
|
|
cbb_powerstate_d0(brdev);
|
2002-08-15 08:01:24 +00:00
|
|
|
#endif
|
2004-05-21 06:10:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
rid = CBBR_SOCKBASE;
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->base_res = bus_alloc_resource_any(brdev, SYS_RES_MEMORY, &rid,
|
|
|
|
RF_ACTIVE);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (!sc->base_res) {
|
2002-08-15 08:01:24 +00:00
|
|
|
device_printf(brdev, "Could not map register memory\n");
|
|
|
|
mtx_destroy(&sc->mtx);
|
|
|
|
cv_destroy(&sc->cv);
|
|
|
|
return (ENOMEM);
|
2003-06-06 06:00:49 +00:00
|
|
|
} else {
|
|
|
|
DEVPRINTF((brdev, "Found memory at %08lx\n",
|
|
|
|
rman_get_start(sc->base_res)));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2003-06-06 06:00:49 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
sc->bst = rman_get_bustag(sc->base_res);
|
|
|
|
sc->bsh = rman_get_bushandle(sc->base_res);
|
2002-07-26 08:05:25 +00:00
|
|
|
exca_init(&sc->exca, brdev, sc->bst, sc->bsh, CBB_EXCA_OFFSET);
|
|
|
|
sc->exca.flags |= EXCA_HAS_MEMREG_WIN;
|
2003-02-14 06:21:51 +00:00
|
|
|
sc->exca.chipset = EXCA_CARDBUS;
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_chipinit(sc);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2004-04-23 05:25:13 +00:00
|
|
|
/*
|
|
|
|
* This is a gross hack. We should be scanning the entire pci
|
|
|
|
* tree, assigning bus numbers in a way such that we (1) can
|
|
|
|
* reserve 1 extra bus just in case and (2) all sub busses
|
|
|
|
* are in an appropriate range.
|
|
|
|
*/
|
|
|
|
bus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
|
|
|
|
pribus = pcib_get_bus(parent);
|
|
|
|
DEVPRINTF((brdev, "Secondary bus is %d\n", bus));
|
|
|
|
if (bus == 0) {
|
|
|
|
if (curr_bus_number < pribus)
|
|
|
|
curr_bus_number = pribus + 1;
|
|
|
|
if (pci_read_config(brdev, PCIR_PRIBUS_2, 1) != pribus) {
|
|
|
|
DEVPRINTF((brdev, "Setting primary bus to %d\n", pribus));
|
|
|
|
pci_write_config(brdev, PCIR_PRIBUS_2, pribus, 1);
|
|
|
|
}
|
|
|
|
bus = curr_bus_number;
|
|
|
|
DEVPRINTF((brdev, "Secondary bus set to %d subbus %d\n", bus,
|
|
|
|
bus + 1));
|
|
|
|
sc->secbus = bus;
|
|
|
|
sc->subbus = bus + 1;
|
|
|
|
pci_write_config(brdev, PCIR_SECBUS_2, bus, 1);
|
|
|
|
pci_write_config(brdev, PCIR_SUBBUS_2, bus + 1, 1);
|
|
|
|
curr_bus_number += 2;
|
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* attach children */
|
|
|
|
sc->cbdev = device_add_child(brdev, "cardbus", -1);
|
|
|
|
if (sc->cbdev == NULL)
|
|
|
|
DEVPRINTF((brdev, "WARNING: cannot add cardbus bus.\n"));
|
2004-05-21 06:11:47 +00:00
|
|
|
else if (device_probe_and_attach(sc->cbdev) != 0)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
DEVPRINTF((brdev, "WARNING: cannot attach cardbus bus!\n"));
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-06-07 20:47:35 +00:00
|
|
|
sc->exca.pccarddev = device_add_child(brdev, "pccard", -1);
|
|
|
|
if (sc->exca.pccarddev == NULL)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
DEVPRINTF((brdev, "WARNING: cannot add pccard bus.\n"));
|
2004-05-21 06:11:47 +00:00
|
|
|
else if (device_probe_and_attach(sc->exca.pccarddev) != 0)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
DEVPRINTF((brdev, "WARNING: cannot attach pccard bus.\n"));
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* Map and establish the interrupt. */
|
2002-01-29 06:50:18 +00:00
|
|
|
rid = 0;
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->irq_res = bus_alloc_resource_any(brdev, SYS_RES_IRQ, &rid,
|
2001-08-26 23:55:34 +00:00
|
|
|
RF_SHAREABLE | RF_ACTIVE);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (sc->irq_res == NULL) {
|
2002-08-15 08:01:24 +00:00
|
|
|
printf("cbb: Unable to map IRQ...\n");
|
2002-08-10 06:37:32 +00:00
|
|
|
goto err;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-12 03:37:28 +00:00
|
|
|
if (bus_setup_intr(brdev, sc->irq_res, INTR_TYPE_AV | INTR_MPSAFE,
|
|
|
|
cbb_intr, sc, &sc->intrhand)) {
|
2001-08-26 23:55:34 +00:00
|
|
|
device_printf(brdev, "couldn't establish interrupt");
|
2002-08-10 06:37:32 +00:00
|
|
|
goto err;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2002-07-21 04:23:11 +00:00
|
|
|
/* reset 16-bit pcmcia bus */
|
|
|
|
exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET);
|
|
|
|
|
|
|
|
/* turn off power */
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_OFF);
|
2002-07-21 04:23:11 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* CSC Interrupt: Card detect interrupt on */
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* reset interrupt */
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, CBB_SOCKET_EVENT, cbb_get(sc, CBB_SOCKET_EVENT));
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
|
2003-06-06 06:00:49 +00:00
|
|
|
if (bootverbose)
|
|
|
|
cbb_print_config(brdev);
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* Start the thread */
|
2002-10-02 07:44:29 +00:00
|
|
|
if (kthread_create(cbb_event_thread, sc, &sc->event_thread, 0, 0,
|
2003-08-14 07:15:19 +00:00
|
|
|
"%s", device_get_nameunit(brdev))) {
|
2003-06-06 06:00:49 +00:00
|
|
|
device_printf(brdev, "unable to create event thread.\n");
|
|
|
|
panic("cbb_create_event_thread");
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2002-08-10 06:37:32 +00:00
|
|
|
err:
|
|
|
|
if (sc->irq_res)
|
|
|
|
bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res);
|
|
|
|
if (sc->base_res) {
|
2004-05-21 06:10:13 +00:00
|
|
|
bus_release_resource(brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
|
|
|
|
sc->base_res);
|
2002-08-10 06:37:32 +00:00
|
|
|
}
|
|
|
|
mtx_destroy(&sc->mtx);
|
|
|
|
cv_destroy(&sc->cv);
|
|
|
|
return (ENOMEM);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2000-11-28 00:05:20 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_detach(device_t brdev)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-11-28 00:05:20 +00:00
|
|
|
int numdevs;
|
|
|
|
device_t *devlist;
|
|
|
|
int tmp;
|
|
|
|
int error;
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
device_get_children(brdev, &devlist, &numdevs);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
|
|
|
error = 0;
|
|
|
|
for (tmp = 0; tmp < numdevs; tmp++) {
|
|
|
|
if (device_detach(devlist[tmp]) == 0)
|
2001-08-26 23:55:34 +00:00
|
|
|
device_delete_child(brdev, devlist[tmp]);
|
2000-11-28 00:05:20 +00:00
|
|
|
else
|
|
|
|
error++;
|
|
|
|
}
|
2001-02-08 22:14:27 +00:00
|
|
|
free(devlist, M_TEMP);
|
2000-11-28 00:05:20 +00:00
|
|
|
if (error > 0)
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENXIO);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
mtx_lock(&sc->mtx);
|
|
|
|
bus_teardown_intr(brdev, sc->irq_res, sc->intrhand);
|
2002-08-15 08:01:24 +00:00
|
|
|
sc->flags |= CBB_KTHREAD_DONE;
|
|
|
|
if (sc->flags & CBB_KTHREAD_RUNNING) {
|
2002-10-07 23:11:29 +00:00
|
|
|
cv_broadcast(&sc->cv);
|
2002-10-08 03:53:52 +00:00
|
|
|
msleep(sc->event_thread, &sc->mtx, PWAIT, "cbbun", 0);
|
2001-11-26 05:42:45 +00:00
|
|
|
}
|
2002-10-08 03:53:52 +00:00
|
|
|
mtx_unlock(&sc->mtx);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res);
|
2004-05-21 06:10:13 +00:00
|
|
|
bus_release_resource(brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
|
|
|
|
sc->base_res);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
mtx_destroy(&sc->mtx);
|
2002-06-13 07:19:31 +00:00
|
|
|
cv_destroy(&sc->cv);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_shutdown(device_t brdev)
|
2001-08-27 00:09:42 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
|
2001-08-27 00:09:42 +00:00
|
|
|
/* properly reset everything at shutdown */
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, |CBBM_BRIDGECTRL_RESET, 2);
|
2002-01-29 06:50:18 +00:00
|
|
|
exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET);
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, CBB_SOCKET_MASK, 0);
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_OFF);
|
2001-08-27 00:09:42 +00:00
|
|
|
|
2003-02-14 06:21:51 +00:00
|
|
|
exca_putb(&sc->exca, EXCA_ADDRWIN_ENABLE, 0);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
pci_write_config(brdev, CBBR_MEMBASE0, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_MEMLIMIT0, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_MEMBASE1, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_MEMLIMIT1, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_IOBASE0, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_IOLIMIT0, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_IOBASE1, 0, 4);
|
|
|
|
pci_write_config(brdev, CBBR_IOLIMIT1, 0, 4);
|
2001-08-27 00:09:42 +00:00
|
|
|
pci_write_config(brdev, PCIR_COMMAND, 0, 2);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
|
|
|
|
2002-02-10 03:28:37 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
|
2002-02-10 03:28:37 +00:00
|
|
|
int flags, driver_intr_t *intr, void *arg, void **cookiep)
|
|
|
|
{
|
2002-10-07 23:11:29 +00:00
|
|
|
struct cbb_intrhand *ih;
|
|
|
|
struct cbb_softc *sc = device_get_softc(dev);
|
2002-02-10 03:28:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* You aren't allowed to have fast interrupts for pccard/cardbus
|
|
|
|
* things since those interrupts are PCI and shared. Since we use
|
|
|
|
* the PCI interrupt for the status change interrupts, it can't be
|
|
|
|
* free for use by the driver. Fast interrupts must not be shared.
|
|
|
|
*/
|
|
|
|
if ((flags & INTR_FAST) != 0)
|
|
|
|
return (EINVAL);
|
2002-10-07 23:11:29 +00:00
|
|
|
ih = malloc(sizeof(struct cbb_intrhand), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (ih == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
*cookiep = ih;
|
|
|
|
ih->intr = intr;
|
|
|
|
ih->arg = arg;
|
2003-06-12 03:37:28 +00:00
|
|
|
ih->flags = flags & INTR_MPSAFE;
|
2002-10-07 23:11:29 +00:00
|
|
|
STAILQ_INSERT_TAIL(&sc->intr_handlers, ih, entries);
|
2003-08-10 02:40:49 +00:00
|
|
|
cbb_enable_func_intr(sc);
|
2002-02-10 03:28:37 +00:00
|
|
|
/*
|
|
|
|
* XXX need to turn on ISA interrupts, if we ever support them, but
|
|
|
|
* XXX for now that's all we need to do.
|
|
|
|
*/
|
2002-10-07 23:11:29 +00:00
|
|
|
return (0);
|
2002-02-10 03:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_teardown_intr(device_t dev, device_t child, struct resource *irq,
|
2002-02-10 03:28:37 +00:00
|
|
|
void *cookie)
|
|
|
|
{
|
2002-10-07 23:11:29 +00:00
|
|
|
struct cbb_intrhand *ih;
|
|
|
|
struct cbb_softc *sc = device_get_softc(dev);
|
|
|
|
|
2002-02-10 03:28:37 +00:00
|
|
|
/* XXX Need to do different things for ISA interrupts. */
|
2002-10-07 23:11:29 +00:00
|
|
|
ih = (struct cbb_intrhand *) cookie;
|
|
|
|
STAILQ_REMOVE(&sc->intr_handlers, ih, cbb_intrhand, entries);
|
|
|
|
free(ih, M_DEVBUF);
|
|
|
|
return (0);
|
2002-02-10 03:28:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-28 00:05:20 +00:00
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_driver_added(device_t brdev, driver_t *driver)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-11-28 00:05:20 +00:00
|
|
|
device_t *devlist;
|
2003-04-08 06:52:16 +00:00
|
|
|
device_t dev;
|
2000-11-28 00:05:20 +00:00
|
|
|
int tmp;
|
|
|
|
int numdevs;
|
2003-04-08 06:52:16 +00:00
|
|
|
int wake = 0;
|
2001-01-06 18:04:55 +00:00
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
DEVICE_IDENTIFY(driver, brdev);
|
|
|
|
device_get_children(brdev, &devlist, &numdevs);
|
2000-11-28 00:05:20 +00:00
|
|
|
for (tmp = 0; tmp < numdevs; tmp++) {
|
2003-04-08 06:52:16 +00:00
|
|
|
dev = devlist[tmp];
|
|
|
|
if (device_get_state(dev) == DS_NOTPRESENT &&
|
|
|
|
device_probe_and_attach(dev) == 0)
|
|
|
|
wake++;
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
2001-02-08 22:14:27 +00:00
|
|
|
free(devlist, M_TEMP);
|
2001-08-27 00:09:42 +00:00
|
|
|
|
|
|
|
if (wake > 0) {
|
2003-04-08 06:52:16 +00:00
|
|
|
mtx_lock(&sc->mtx);
|
|
|
|
cv_signal(&sc->cv);
|
|
|
|
mtx_unlock(&sc->mtx);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_child_detached(device_t brdev, device_t child)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-11-26 05:42:45 +00:00
|
|
|
|
2003-06-07 20:47:35 +00:00
|
|
|
if (child != sc->cbdev && child != sc->exca.pccarddev)
|
2003-04-08 06:52:16 +00:00
|
|
|
device_printf(brdev, "Unknown child detached: %s\n",
|
|
|
|
device_get_nameunit(child));
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* Kthreads */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_event_thread(void *arg)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = arg;
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t status;
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
int err;
|
2003-08-09 21:05:54 +00:00
|
|
|
int not_a_card = 0;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
sc->flags |= CBB_KTHREAD_RUNNING;
|
2003-06-12 03:37:28 +00:00
|
|
|
while ((sc->flags & CBB_KTHREAD_DONE) == 0) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
2003-06-12 03:37:28 +00:00
|
|
|
* We take out Giant here because we need it deep,
|
|
|
|
* down in the bowels of the vm system for mapping the
|
|
|
|
* memory we need to read the CIS. In addition, since
|
|
|
|
* we are adding/deleting devices from the dev tree,
|
|
|
|
* and that code isn't MP safe, we have to hold Giant.
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
*/
|
2002-10-08 03:53:52 +00:00
|
|
|
mtx_lock(&Giant);
|
2003-06-12 03:37:28 +00:00
|
|
|
status = cbb_get(sc, CBB_SOCKET_STATE);
|
2003-08-09 21:05:54 +00:00
|
|
|
DPRINTF(("Status is 0x%x\n", status));
|
2003-08-20 06:13:01 +00:00
|
|
|
if (!CBB_CARD_PRESENT(status)) {
|
2003-08-10 02:40:49 +00:00
|
|
|
not_a_card = 0; /* We know card type */
|
|
|
|
cbb_removal(sc);
|
|
|
|
} else if (status & CBB_STATE_NOT_A_CARD) {
|
2003-08-09 21:05:54 +00:00
|
|
|
/*
|
|
|
|
* Up to 20 times, try to rescan the card when we
|
|
|
|
* see NOT_A_CARD.
|
|
|
|
*/
|
|
|
|
if (not_a_card++ < 20) {
|
|
|
|
DEVPRINTF((sc->dev,
|
|
|
|
"Not a card bit set, rescanning\n"));
|
|
|
|
cbb_setb(sc, CBB_SOCKET_FORCE, CBB_FORCE_CV_TEST);
|
|
|
|
} else {
|
|
|
|
device_printf(sc->dev,
|
|
|
|
"Can't determine card type\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
not_a_card = 0; /* We know card type */
|
2003-08-10 02:40:49 +00:00
|
|
|
cbb_insert(sc);
|
2003-08-09 21:05:54 +00:00
|
|
|
}
|
2002-10-08 03:53:52 +00:00
|
|
|
mtx_unlock(&Giant);
|
|
|
|
|
2002-02-20 16:20:27 +00:00
|
|
|
/*
|
|
|
|
* Wait until it has been 1s since the last time we
|
|
|
|
* get an interrupt. We handle the rest of the interrupt
|
2003-06-12 03:37:28 +00:00
|
|
|
* at the top of the loop. Although we clear the bit in the
|
|
|
|
* ISR, we signal sc->cv from the detach path after we've
|
|
|
|
* set the CBB_KTHREAD_DONE bit, so we can't do a simple
|
|
|
|
* 1s sleep here.
|
2003-08-18 03:15:44 +00:00
|
|
|
*
|
|
|
|
* In our ISR, we turn off the card changed interrupt. Turn
|
|
|
|
* them back on here before we wait for them to happen. We
|
|
|
|
* turn them on/off so that we can tolerate a large latency
|
|
|
|
* between the time we signal cbb_event_thread and it gets
|
|
|
|
* a chance to run.
|
2002-02-20 16:20:27 +00:00
|
|
|
*/
|
2002-06-13 07:19:31 +00:00
|
|
|
mtx_lock(&sc->mtx);
|
2003-08-18 03:15:44 +00:00
|
|
|
cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
|
2002-06-13 07:19:31 +00:00
|
|
|
cv_wait(&sc->cv, &sc->mtx);
|
2002-10-07 23:11:29 +00:00
|
|
|
err = 0;
|
2003-06-12 03:37:28 +00:00
|
|
|
while (err != EWOULDBLOCK &&
|
2002-10-07 23:11:29 +00:00
|
|
|
(sc->flags & CBB_KTHREAD_DONE) == 0)
|
2002-06-13 07:19:31 +00:00
|
|
|
err = cv_timedwait(&sc->cv, &sc->mtx, 1 * hz);
|
|
|
|
mtx_unlock(&sc->mtx);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-08-15 08:01:24 +00:00
|
|
|
sc->flags &= ~CBB_KTHREAD_RUNNING;
|
2000-10-18 03:25:13 +00:00
|
|
|
kthread_exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* Insert/removal */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_insert(struct cbb_softc *sc)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t sockevent, sockstate;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-10-07 23:11:29 +00:00
|
|
|
sockevent = cbb_get(sc, CBB_SOCKET_EVENT);
|
|
|
|
sockstate = cbb_get(sc, CBB_SOCKET_STATE);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
DEVPRINTF((sc->dev, "card inserted: event=0x%08x, state=%08x\n",
|
2001-08-26 23:55:34 +00:00
|
|
|
sockevent, sockstate));
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-08-09 20:49:22 +00:00
|
|
|
if (sockstate & CBB_STATE_R2_CARD) {
|
2003-06-07 20:47:35 +00:00
|
|
|
if (sc->exca.pccarddev)
|
|
|
|
sc->flags |= CBB_16BIT_CARD | CBB_CARD_OK;
|
|
|
|
exca_insert(&sc->exca);
|
2003-08-09 20:49:22 +00:00
|
|
|
} else if (sockstate & CBB_STATE_CB_CARD) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (sc->cbdev != NULL) {
|
2002-08-15 08:01:24 +00:00
|
|
|
sc->flags &= ~CBB_16BIT_CARD;
|
2002-10-11 04:30:59 +00:00
|
|
|
sc->flags |= CBB_CARD_OK;
|
2003-02-14 06:21:51 +00:00
|
|
|
if (CARD_ATTACH_CARD(sc->cbdev) != 0)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"CardBus card activation failed\n");
|
|
|
|
} else {
|
|
|
|
device_printf(sc->dev,
|
2002-10-11 04:30:59 +00:00
|
|
|
"CardBus card inserted, but no cardbus bus.\n");
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
} else {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
|
|
|
* We should power the card down, and try again a couple of
|
|
|
|
* times if this happens. XXX
|
|
|
|
*/
|
2003-02-14 06:21:51 +00:00
|
|
|
device_printf(sc->dev, "Unsupported card type detected\n");
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_removal(struct cbb_softc *sc)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-11-14 05:18:53 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD) {
|
2003-06-07 20:47:35 +00:00
|
|
|
exca_removal(&sc->exca);
|
2002-11-14 05:18:53 +00:00
|
|
|
} else {
|
|
|
|
if (sc->cbdev != NULL)
|
|
|
|
CARD_DETACH_CARD(sc->cbdev);
|
|
|
|
}
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_destroy_res(sc);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* Interrupt Handler */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_intr(void *arg)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = arg;
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t sockevent;
|
2002-10-07 23:11:29 +00:00
|
|
|
struct cbb_intrhand *ih;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
|
|
|
* This ISR needs work XXX
|
|
|
|
*/
|
2002-08-15 08:01:24 +00:00
|
|
|
sockevent = cbb_get(sc, CBB_SOCKET_EVENT);
|
2003-08-09 21:05:54 +00:00
|
|
|
if (sockevent != 0) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* ack the interrupt */
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_setb(sc, CBB_SOCKET_EVENT, sockevent);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-10-07 23:11:29 +00:00
|
|
|
/*
|
|
|
|
* If anything has happened to the socket, we assume that
|
|
|
|
* the card is no longer OK, and we shouldn't call its
|
|
|
|
* ISR. We set CARD_OK as soon as we've attached the
|
|
|
|
* card. This helps in a noisy eject, which happens
|
|
|
|
* all too often when users are ejecting their PC Cards.
|
|
|
|
*
|
|
|
|
* We use this method in preference to checking to see if
|
|
|
|
* the card is still there because the check suffers from
|
|
|
|
* a race condition in the bouncing case. Prior versions
|
|
|
|
* of the pccard software used a similar trick and achieved
|
|
|
|
* excellent results.
|
|
|
|
*/
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (sockevent & CBB_SOCKET_EVENT_CD) {
|
|
|
|
mtx_lock(&sc->mtx);
|
2003-08-18 03:15:44 +00:00
|
|
|
cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
|
2002-10-07 23:11:29 +00:00
|
|
|
sc->flags &= ~CBB_CARD_OK;
|
2003-08-10 02:40:49 +00:00
|
|
|
cbb_disable_func_intr(sc);
|
2002-06-13 07:19:31 +00:00
|
|
|
cv_signal(&sc->cv);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
mtx_unlock(&sc->mtx);
|
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2003-08-09 21:05:54 +00:00
|
|
|
/*
|
|
|
|
* Some chips also require us to read the old ExCA registe for
|
|
|
|
* card status change when we route CSC vis PCI. This isn't supposed
|
|
|
|
* to be required, but it clears the interrupt state on some chipsets.
|
|
|
|
* Maybe there's a setting that would obviate its need. Maybe we
|
|
|
|
* should test the status bits and deal with them, but so far we've
|
|
|
|
* not found any machines that don't also give us the socket status
|
|
|
|
* indication above.
|
|
|
|
*
|
|
|
|
* We have to call this unconditionally because some bridges deliver
|
|
|
|
* the even independent of the CBB_SOCKET_EVENT_CD above.
|
|
|
|
*/
|
|
|
|
exca_getb(&sc->exca, EXCA_CSC);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the card is OK, call all the interrupt handlers.
|
|
|
|
*/
|
2002-10-07 23:11:29 +00:00
|
|
|
if (sc->flags & CBB_CARD_OK) {
|
|
|
|
STAILQ_FOREACH(ih, &sc->intr_handlers, entries) {
|
2003-10-24 07:20:13 +00:00
|
|
|
if ((ih->flags & INTR_MPSAFE) == 0)
|
2003-06-12 03:37:28 +00:00
|
|
|
mtx_lock(&Giant);
|
2002-10-07 23:11:29 +00:00
|
|
|
(*ih->intr)(ih->arg);
|
2003-10-24 07:20:13 +00:00
|
|
|
if ((ih->flags & INTR_MPSAFE) == 0)
|
2003-06-12 06:06:14 +00:00
|
|
|
mtx_unlock(&Giant);
|
2002-10-07 23:11:29 +00:00
|
|
|
}
|
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
2000-11-28 00:05:20 +00:00
|
|
|
/* Generic Power functions */
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_detect_voltage(device_t brdev)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t psr;
|
2000-10-18 03:25:13 +00:00
|
|
|
int vol = CARD_UKN_CARD;
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
psr = cbb_get(sc, CBB_SOCKET_STATE);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-08-09 20:49:22 +00:00
|
|
|
if (psr & CBB_STATE_5VCARD)
|
2000-10-18 03:25:13 +00:00
|
|
|
vol |= CARD_5V_CARD;
|
2003-08-09 20:49:22 +00:00
|
|
|
if (psr & CBB_STATE_3VCARD)
|
2000-10-18 03:25:13 +00:00
|
|
|
vol |= CARD_3V_CARD;
|
2003-08-09 20:49:22 +00:00
|
|
|
if (psr & CBB_STATE_XVCARD)
|
2000-10-18 03:25:13 +00:00
|
|
|
vol |= CARD_XV_CARD;
|
2003-08-09 20:49:22 +00:00
|
|
|
if (psr & CBB_STATE_YVCARD)
|
2000-10-18 03:25:13 +00:00
|
|
|
vol |= CARD_YV_CARD;
|
|
|
|
|
2001-11-26 05:42:45 +00:00
|
|
|
return (vol);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-06 06:00:49 +00:00
|
|
|
static uint8_t
|
|
|
|
cbb_o2micro_power_hack(struct cbb_softc *sc)
|
|
|
|
{
|
|
|
|
uint8_t reg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Issue #2: INT# not qualified with IRQ Routing Bit. An
|
|
|
|
* unexpected PCI INT# may be generated during PC-Card
|
|
|
|
* initialization even with the IRQ Routing Bit Set with some
|
|
|
|
* PC-Cards.
|
|
|
|
*
|
|
|
|
* This is a two part issue. The first part is that some of
|
|
|
|
* our older controllers have an issue in which the slot's PCI
|
|
|
|
* INT# is NOT qualified by the IRQ routing bit (PCI reg. 3Eh
|
|
|
|
* bit 7). Regardless of the IRQ routing bit, if NO ISA IRQ
|
|
|
|
* is selected (ExCA register 03h bits 3:0, of the slot, are
|
|
|
|
* cleared) we will generate INT# if IREQ# is asserted. The
|
|
|
|
* second part is because some PC-Cards prematurally assert
|
|
|
|
* IREQ# before the ExCA registers are fully programmed. This
|
|
|
|
* in turn asserts INT# because ExCA register 03h bits 3:0
|
|
|
|
* (ISA IRQ Select) are not yet programmed.
|
|
|
|
*
|
|
|
|
* The fix for this issue, which will work for any controller
|
|
|
|
* (old or new), is to set ExCA register 03h bits 3:0 = 0001b
|
|
|
|
* (select IRQ1), of the slot, before turning on slot power.
|
|
|
|
* Selecting IRQ1 will result in INT# NOT being asserted
|
|
|
|
* (because IRQ1 is selected), and IRQ1 won't be asserted
|
|
|
|
* because our controllers don't generate IRQ1.
|
|
|
|
*/
|
|
|
|
reg = exca_getb(&sc->exca, EXCA_INTR);
|
|
|
|
exca_putb(&sc->exca, EXCA_INTR, (reg & 0xf0) | 1);
|
|
|
|
return (reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the damage that cbb_o2micro_power_hack does to EXCA_INTR so
|
|
|
|
* we don't have an interrupt storm on power on. This has the efect of
|
|
|
|
* disabling card status change interrupts for the duration of poweron.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
cbb_o2micro_power_hack2(struct cbb_softc *sc, uint8_t reg)
|
|
|
|
{
|
|
|
|
exca_putb(&sc->exca, EXCA_INTR, reg);
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_power(device_t brdev, int volts)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t status, sock_ctrl;
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-11-26 05:42:45 +00:00
|
|
|
int timeout;
|
2003-06-06 06:00:49 +00:00
|
|
|
int retval = 0;
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t sockevent;
|
2003-06-06 06:00:49 +00:00
|
|
|
uint8_t reg = 0;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
status = cbb_get(sc, CBB_SOCKET_STATE);
|
|
|
|
sock_ctrl = cbb_get(sc, CBB_SOCKET_CONTROL);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2003-06-07 20:18:45 +00:00
|
|
|
sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK;
|
2000-10-18 03:25:13 +00:00
|
|
|
switch (volts & CARD_VCCMASK) {
|
2003-06-07 20:18:45 +00:00
|
|
|
case 5:
|
|
|
|
sock_ctrl |= CBB_SOCKET_CTRL_VCC_5V;
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
2003-06-07 20:18:45 +00:00
|
|
|
case 3:
|
|
|
|
sock_ctrl |= CBB_SOCKET_CTRL_VCC_3V;
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
2003-06-07 20:18:45 +00:00
|
|
|
case XV:
|
|
|
|
sock_ctrl |= CBB_SOCKET_CTRL_VCC_XV;
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
2003-06-07 20:18:45 +00:00
|
|
|
case YV:
|
|
|
|
sock_ctrl |= CBB_SOCKET_CTRL_VCC_YV;
|
|
|
|
break;
|
|
|
|
case 0:
|
2000-10-18 03:25:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0); /* power NEVER changed */
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2003-06-07 20:18:45 +00:00
|
|
|
/* VPP == VCC */
|
|
|
|
sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK;
|
|
|
|
sock_ctrl |= ((sock_ctrl >> 4) & 0x07);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (cbb_get(sc, CBB_SOCKET_CONTROL) == sock_ctrl)
|
2001-11-26 05:42:45 +00:00
|
|
|
return (1); /* no change necessary */
|
2003-06-07 20:18:45 +00:00
|
|
|
DEVPRINTF((sc->dev, "cbb_power: %dV\n", volts));
|
2003-06-06 06:00:49 +00:00
|
|
|
if (volts != 0 && sc->chipset == CB_O2MICRO)
|
|
|
|
reg = cbb_o2micro_power_hack(sc);
|
2001-01-06 18:04:55 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, CBB_SOCKET_CONTROL, sock_ctrl);
|
|
|
|
status = cbb_get(sc, CBB_SOCKET_STATE);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-09-06 20:43:12 +00:00
|
|
|
/*
|
|
|
|
* XXX This busy wait is bogus. We should wait for a power
|
|
|
|
* interrupt and then whine if the status is bad. If we're
|
|
|
|
* worried about the card not coming up, then we should also
|
2003-06-07 20:18:45 +00:00
|
|
|
* schedule a timeout which we can cancel in the power interrupt.
|
2001-09-06 20:43:12 +00:00
|
|
|
*/
|
2001-11-26 05:42:45 +00:00
|
|
|
timeout = 20;
|
|
|
|
do {
|
|
|
|
DELAY(20*1000);
|
2002-08-15 08:01:24 +00:00
|
|
|
sockevent = cbb_get(sc, CBB_SOCKET_EVENT);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
} while (!(sockevent & CBB_SOCKET_EVENT_POWER) && --timeout > 0);
|
2001-11-26 05:42:45 +00:00
|
|
|
/* reset event status */
|
|
|
|
/* XXX should only reset EVENT_POWER */
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_set(sc, CBB_SOCKET_EVENT, sockevent);
|
2001-11-26 05:42:45 +00:00
|
|
|
if (timeout < 0) {
|
|
|
|
printf ("VCC supply failed.\n");
|
2003-06-06 06:00:49 +00:00
|
|
|
goto done;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2001-11-26 05:42:45 +00:00
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/* XXX
|
|
|
|
* delay 400 ms: thgough the standard defines that the Vcc set-up time
|
|
|
|
* is 20 ms, some PC-Card bridge requires longer duration.
|
2001-09-06 20:43:12 +00:00
|
|
|
* XXX Note: We should check the stutus AFTER the delay to give time
|
|
|
|
* for things to stabilize.
|
2000-10-18 03:25:13 +00:00
|
|
|
*/
|
|
|
|
DELAY(400*1000);
|
|
|
|
|
2003-08-09 20:49:22 +00:00
|
|
|
if (status & CBB_STATE_BAD_VCC_REQ) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
device_printf(sc->dev,
|
2001-08-26 23:55:34 +00:00
|
|
|
"bad Vcc request. ctrl=0x%x, status=0x%x\n",
|
|
|
|
sock_ctrl ,status);
|
2003-06-07 20:18:45 +00:00
|
|
|
printf("cbb_power: %dV\n", volts);
|
2003-06-06 06:00:49 +00:00
|
|
|
goto done;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2003-06-06 06:00:49 +00:00
|
|
|
retval = 1;
|
|
|
|
done:;
|
|
|
|
if (volts != 0 && sc->chipset == CB_O2MICRO)
|
|
|
|
cbb_o2micro_power_hack2(sc, reg);
|
|
|
|
return (retval);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/*
|
|
|
|
* detect the voltage for the card, and set it. Since the power
|
|
|
|
* used is the square of the voltage, lower voltages is a big win
|
|
|
|
* and what Windows does (and what Microsoft prefers). The MS paper
|
2004-04-06 20:13:29 +00:00
|
|
|
* also talks about preferring the CIS entry as well. In addition,
|
|
|
|
* we power up with OE disabled. We'll set it later in the power
|
|
|
|
* up sequence.
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
*/
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_do_power(device_t brdev)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
{
|
2004-04-06 22:41:14 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
int voltage;
|
|
|
|
|
2004-04-06 20:13:29 +00:00
|
|
|
/* Don't enable OE */
|
|
|
|
exca_clrb(&sc->exca, EXCA_PWRCTL, EXCA_PWRCTL_OE);
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* Prefer lowest voltage supported */
|
2002-08-15 08:01:24 +00:00
|
|
|
voltage = cbb_detect_voltage(brdev);
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_OFF);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (voltage & CARD_YV_CARD)
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_VCC(YV));
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
else if (voltage & CARD_XV_CARD)
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_VCC(XV));
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
else if (voltage & CARD_3V_CARD)
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_VCC(3));
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
else if (voltage & CARD_5V_CARD)
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_VCC(5));
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
else {
|
|
|
|
device_printf(brdev, "Unknown card voltage\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
2002-10-11 04:30:59 +00:00
|
|
|
/* CardBus power functions */
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
2000-11-28 00:05:20 +00:00
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_reset(device_t brdev)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
int delay_us;
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
delay_us = sc->chipset == CB_RF5C47X ? 400*1000 : 20*1000;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, |CBBM_BRIDGECTRL_RESET, 2);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
DELAY(delay_us);
|
|
|
|
|
|
|
|
/* If a card exists, unreset it! */
|
2003-08-20 11:27:58 +00:00
|
|
|
if (CBB_CARD_PRESENT(cbb_get(sc, CBB_SOCKET_STATE))) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL,
|
|
|
|
&~CBBM_BRIDGECTRL_RESET, 2);
|
2000-10-18 03:25:13 +00:00
|
|
|
DELAY(delay_us);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-28 00:05:20 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_power_enable_socket(device_t brdev, device_t child)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
int err;
|
2001-01-06 18:04:55 +00:00
|
|
|
|
2003-08-20 23:43:20 +00:00
|
|
|
if (!CBB_CARD_PRESENT(cbb_get(sc, CBB_SOCKET_STATE)))
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENODEV);
|
2001-01-06 18:04:55 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
err = cbb_do_power(brdev);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_reset(brdev);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_power_disable_socket(device_t brdev, device_t child)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_OFF);
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_reset(brdev);
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/************************************************************************/
|
2002-10-11 04:30:59 +00:00
|
|
|
/* CardBus Resource */
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_io_open(device_t brdev, int win, uint32_t start, uint32_t end)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
int basereg;
|
|
|
|
int limitreg;
|
|
|
|
|
|
|
|
if ((win < 0) || (win > 1)) {
|
2001-08-26 23:55:34 +00:00
|
|
|
DEVPRINTF((brdev,
|
2002-08-15 08:01:24 +00:00
|
|
|
"cbb_cardbus_io_open: window out of range %d\n", win));
|
2001-11-26 05:42:45 +00:00
|
|
|
return (EINVAL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
basereg = win * 8 + CBBR_IOBASE0;
|
|
|
|
limitreg = win * 8 + CBBR_IOLIMIT0;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
pci_write_config(brdev, basereg, start, 4);
|
|
|
|
pci_write_config(brdev, limitreg, end, 4);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_mem_open(device_t brdev, int win, uint32_t start, uint32_t end)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
int basereg;
|
|
|
|
int limitreg;
|
|
|
|
|
|
|
|
if ((win < 0) || (win > 1)) {
|
2001-08-26 23:55:34 +00:00
|
|
|
DEVPRINTF((brdev,
|
2002-08-15 08:01:24 +00:00
|
|
|
"cbb_cardbus_mem_open: window out of range %d\n", win));
|
2001-11-26 05:42:45 +00:00
|
|
|
return (EINVAL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
basereg = win*8 + CBBR_MEMBASE0;
|
|
|
|
limitreg = win*8 + CBBR_MEMLIMIT0;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
pci_write_config(brdev, basereg, start, 4);
|
|
|
|
pci_write_config(brdev, limitreg, end, 4);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2002-01-15 20:41:39 +00:00
|
|
|
/*
|
|
|
|
* XXX The following function belongs in the pci bus layer.
|
|
|
|
*/
|
2000-10-18 03:25:13 +00:00
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_auto_open(struct cbb_softc *sc, int type)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t starts[2];
|
|
|
|
uint32_t ends[2];
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_reslist *rle;
|
2000-10-18 03:25:13 +00:00
|
|
|
int align;
|
2001-08-27 00:09:42 +00:00
|
|
|
int prefetchable[2];
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t reg;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
starts[0] = starts[1] = 0xffffffff;
|
|
|
|
ends[0] = ends[1] = 0;
|
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
if (type == SYS_RES_MEMORY)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
align = CBB_MEMALIGN;
|
2001-08-27 00:09:42 +00:00
|
|
|
else if (type == SYS_RES_IOPORT)
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
align = CBB_IOALIGN;
|
2001-08-27 00:09:42 +00:00
|
|
|
else
|
|
|
|
align = 1;
|
|
|
|
|
2003-08-09 20:33:53 +00:00
|
|
|
/*
|
|
|
|
* This looks somewhat bogus, and doesn't seem to really respect
|
|
|
|
* alignment. The alignment stuff is happening too late (it
|
|
|
|
* should happen at allocation time, not activation time) and
|
|
|
|
* this code looks generally to be too complex for the purpose
|
|
|
|
* it surves.
|
|
|
|
*/
|
2001-08-27 00:09:42 +00:00
|
|
|
SLIST_FOREACH(rle, &sc->rl, link) {
|
2000-10-18 03:25:13 +00:00
|
|
|
if (rle->type != type)
|
|
|
|
;
|
2001-08-27 00:09:42 +00:00
|
|
|
else if (rle->res == NULL) {
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
device_printf(sc->dev, "WARNING: Resource not reserved? "
|
2001-08-27 00:09:42 +00:00
|
|
|
"(type=%d, addr=%lx)\n",
|
|
|
|
rle->type, rman_get_start(rle->res));
|
|
|
|
} else if (!(rman_get_flags(rle->res) & RF_ACTIVE)) {
|
2001-11-26 05:42:45 +00:00
|
|
|
/* XXX */
|
2001-08-27 00:09:42 +00:00
|
|
|
} else if (starts[0] == 0xffffffff) {
|
|
|
|
starts[0] = rman_get_start(rle->res);
|
|
|
|
ends[0] = rman_get_end(rle->res);
|
|
|
|
prefetchable[0] =
|
|
|
|
rman_get_flags(rle->res) & RF_PREFETCHABLE;
|
|
|
|
} else if (rman_get_end(rle->res) > ends[0] &&
|
|
|
|
rman_get_start(rle->res) - ends[0] <
|
2002-08-15 08:01:24 +00:00
|
|
|
CBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] ==
|
2001-08-27 00:09:42 +00:00
|
|
|
(rman_get_flags(rle->res) & RF_PREFETCHABLE)) {
|
|
|
|
ends[0] = rman_get_end(rle->res);
|
|
|
|
} else if (rman_get_start(rle->res) < starts[0] &&
|
|
|
|
starts[0] - rman_get_end(rle->res) <
|
2002-08-15 08:01:24 +00:00
|
|
|
CBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] ==
|
2001-08-27 00:09:42 +00:00
|
|
|
(rman_get_flags(rle->res) & RF_PREFETCHABLE)) {
|
|
|
|
starts[0] = rman_get_start(rle->res);
|
2000-10-18 03:25:13 +00:00
|
|
|
} else if (starts[1] == 0xffffffff) {
|
2001-08-27 00:09:42 +00:00
|
|
|
starts[1] = rman_get_start(rle->res);
|
|
|
|
ends[1] = rman_get_end(rle->res);
|
|
|
|
prefetchable[1] =
|
|
|
|
rman_get_flags(rle->res) & RF_PREFETCHABLE;
|
|
|
|
} else if (rman_get_end(rle->res) > ends[1] &&
|
|
|
|
rman_get_start(rle->res) - ends[1] <
|
2002-08-15 08:01:24 +00:00
|
|
|
CBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] ==
|
2001-08-27 00:09:42 +00:00
|
|
|
(rman_get_flags(rle->res) & RF_PREFETCHABLE)) {
|
|
|
|
ends[1] = rman_get_end(rle->res);
|
|
|
|
} else if (rman_get_start(rle->res) < starts[1] &&
|
|
|
|
starts[1] - rman_get_end(rle->res) <
|
2002-08-15 08:01:24 +00:00
|
|
|
CBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] ==
|
2001-08-27 00:09:42 +00:00
|
|
|
(rman_get_flags(rle->res) & RF_PREFETCHABLE)) {
|
|
|
|
starts[1] = rman_get_start(rle->res);
|
2000-10-18 03:25:13 +00:00
|
|
|
} else {
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t diffs[2];
|
2001-08-27 00:09:42 +00:00
|
|
|
int win;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
diffs[0] = diffs[1] = 0xffffffff;
|
2001-08-27 00:09:42 +00:00
|
|
|
if (rman_get_start(rle->res) > ends[0])
|
|
|
|
diffs[0] = rman_get_start(rle->res) - ends[0];
|
|
|
|
else if (rman_get_end(rle->res) < starts[0])
|
|
|
|
diffs[0] = starts[0] - rman_get_end(rle->res);
|
|
|
|
if (rman_get_start(rle->res) > ends[1])
|
|
|
|
diffs[1] = rman_get_start(rle->res) - ends[1];
|
|
|
|
else if (rman_get_end(rle->res) < starts[1])
|
|
|
|
diffs[1] = starts[1] - rman_get_end(rle->res);
|
|
|
|
|
|
|
|
win = (diffs[0] <= diffs[1])?0:1;
|
|
|
|
if (rman_get_start(rle->res) > ends[win])
|
|
|
|
ends[win] = rman_get_end(rle->res);
|
|
|
|
else if (rman_get_end(rle->res) < starts[win])
|
|
|
|
starts[win] = rman_get_start(rle->res);
|
|
|
|
if (!(rman_get_flags(rle->res) & RF_PREFETCHABLE))
|
|
|
|
prefetchable[win] = 0;
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
if (starts[0] != 0xffffffff)
|
|
|
|
starts[0] -= starts[0] % align;
|
|
|
|
if (starts[1] != 0xffffffff)
|
|
|
|
starts[1] -= starts[1] % align;
|
|
|
|
if (ends[0] % align != 0)
|
2003-08-09 20:33:53 +00:00
|
|
|
ends[0] += align - ends[0] % align - 1;
|
2001-08-27 00:09:42 +00:00
|
|
|
if (ends[1] % align != 0)
|
2003-08-09 20:33:53 +00:00
|
|
|
ends[1] += align - ends[1] % align - 1;
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
if (type == SYS_RES_MEMORY) {
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_mem_open(sc->dev, 0, starts[0], ends[0]);
|
|
|
|
cbb_cardbus_mem_open(sc->dev, 1, starts[1], ends[1]);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
reg = pci_read_config(sc->dev, CBBR_BRIDGECTRL, 2);
|
|
|
|
reg &= ~(CBBM_BRIDGECTRL_PREFETCH_0|
|
|
|
|
CBBM_BRIDGECTRL_PREFETCH_1);
|
|
|
|
reg |= (prefetchable[0]?CBBM_BRIDGECTRL_PREFETCH_0:0)|
|
|
|
|
(prefetchable[1]?CBBM_BRIDGECTRL_PREFETCH_1:0);
|
|
|
|
pci_write_config(sc->dev, CBBR_BRIDGECTRL, reg, 2);
|
2000-10-18 03:25:13 +00:00
|
|
|
} else if (type == SYS_RES_IOPORT) {
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_io_open(sc->dev, 0, starts[0], ends[0]);
|
|
|
|
cbb_cardbus_io_open(sc->dev, 1, starts[1], ends[1]);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_activate_resource(device_t brdev, device_t child, int type,
|
2001-08-27 00:09:42 +00:00
|
|
|
int rid, struct resource *res)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-08-27 00:09:42 +00:00
|
|
|
int ret;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
ret = BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child,
|
|
|
|
type, rid, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
if (ret != 0)
|
|
|
|
return (ret);
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_auto_open(device_get_softc(brdev), type);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_deactivate_resource(device_t brdev, device_t child, int type,
|
2001-08-27 00:09:42 +00:00
|
|
|
int rid, struct resource *res)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-08-27 00:09:42 +00:00
|
|
|
int ret;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
ret = BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child,
|
|
|
|
type, rid, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
if (ret != 0)
|
|
|
|
return (ret);
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_auto_open(device_get_softc(brdev), type);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
static struct resource *
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type,
|
2003-08-07 15:04:27 +00:00
|
|
|
int *rid, u_long start, u_long end, u_long count, u_int flags)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-08-27 00:09:42 +00:00
|
|
|
int tmp;
|
|
|
|
struct resource *res;
|
2004-04-06 22:41:14 +00:00
|
|
|
u_long align;
|
2001-08-27 00:09:42 +00:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IRQ:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
tmp = rman_get_start(sc->irq_res);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (start > tmp || end < tmp || count != 1) {
|
|
|
|
device_printf(child, "requested interrupt %ld-%ld,"
|
2002-08-15 08:01:24 +00:00
|
|
|
"count = %ld not supported by cbb\n",
|
2001-08-27 00:09:42 +00:00
|
|
|
start, end, count);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2001-08-27 00:09:42 +00:00
|
|
|
start = end = tmp;
|
2003-04-28 18:50:59 +00:00
|
|
|
flags |= RF_SHAREABLE;
|
2001-08-27 00:09:42 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IOPORT:
|
2002-08-15 08:01:24 +00:00
|
|
|
if (start <= cbb_start_32_io)
|
|
|
|
start = cbb_start_32_io;
|
2001-08-27 00:09:42 +00:00
|
|
|
if (end < start)
|
|
|
|
end = start;
|
|
|
|
break;
|
|
|
|
case SYS_RES_MEMORY:
|
2002-08-15 08:01:24 +00:00
|
|
|
if (start <= cbb_start_mem)
|
|
|
|
start = cbb_start_mem;
|
2001-08-27 00:09:42 +00:00
|
|
|
if (end < start)
|
|
|
|
end = start;
|
2004-04-06 22:50:50 +00:00
|
|
|
if (count < CBB_MEMALIGN)
|
|
|
|
align = CBB_MEMALIGN;
|
|
|
|
else
|
|
|
|
align = count;
|
|
|
|
if (align > (1 << RF_ALIGNMENT(flags)))
|
|
|
|
flags = (flags & ~RF_ALIGNMENT_MASK) |
|
2004-04-06 22:41:14 +00:00
|
|
|
rman_make_alignment_flags(align);
|
2001-08-27 00:09:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid,
|
|
|
|
start, end, count, flags & ~RF_ACTIVE);
|
|
|
|
if (res == NULL) {
|
2002-08-15 08:01:24 +00:00
|
|
|
printf("cbb alloc res fail\n");
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_insert_res(sc, res, type, *rid);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (flags & RF_ACTIVE)
|
|
|
|
if (bus_activate_resource(child, type, *rid, res) != 0) {
|
|
|
|
bus_release_resource(child, type, *rid, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
|
|
|
|
2001-11-26 05:42:45 +00:00
|
|
|
return (res);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_release_resource(device_t brdev, device_t child, int type,
|
2001-08-27 00:09:42 +00:00
|
|
|
int rid, struct resource *res)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-11-26 05:42:45 +00:00
|
|
|
int error;
|
2001-08-27 00:09:42 +00:00
|
|
|
|
|
|
|
if (rman_get_flags(res) & RF_ACTIVE) {
|
|
|
|
error = bus_deactivate_resource(child, type, rid, res);
|
|
|
|
if (error != 0)
|
2001-11-26 05:42:45 +00:00
|
|
|
return (error);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_remove_res(sc, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child,
|
|
|
|
type, rid, res));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
2000-11-28 00:05:20 +00:00
|
|
|
/* PC Card Power Functions */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_power_enable_socket(device_t brdev, device_t child)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
int err;
|
2000-11-28 00:05:20 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
DPRINTF(("cbb_pcic_socket_enable:\n"));
|
2000-11-28 00:05:20 +00:00
|
|
|
|
|
|
|
/* power down/up the socket to reset */
|
2002-08-15 08:01:24 +00:00
|
|
|
err = cbb_do_power(brdev);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
2002-01-29 06:50:18 +00:00
|
|
|
exca_reset(&sc->exca, child);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-11-28 00:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_power_disable_socket(device_t brdev, device_t child)
|
2000-11-28 00:05:20 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
DPRINTF(("cbb_pcic_socket_disable\n"));
|
2000-11-28 00:05:20 +00:00
|
|
|
|
|
|
|
/* reset signal asserting... */
|
2002-01-29 06:50:18 +00:00
|
|
|
exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET);
|
2000-11-28 00:05:20 +00:00
|
|
|
DELAY(2*1000);
|
|
|
|
|
|
|
|
/* power down the socket */
|
2003-06-07 20:18:45 +00:00
|
|
|
cbb_power(brdev, CARD_OFF);
|
2002-01-29 06:50:18 +00:00
|
|
|
exca_clrb(&sc->exca, EXCA_PWRCTL, EXCA_PWRCTL_OE);
|
2000-11-28 00:05:20 +00:00
|
|
|
|
|
|
|
/* wait 300ms until power fails (Tpf). */
|
|
|
|
DELAY(300 * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
2002-01-29 06:50:18 +00:00
|
|
|
/* POWER methods */
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_power_enable_socket(device_t brdev, device_t child)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
return (cbb_pcic_power_enable_socket(brdev, child));
|
2002-01-29 06:50:18 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
return (cbb_cardbus_power_enable_socket(brdev, child));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_power_disable_socket(device_t brdev, device_t child)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
cbb_pcic_power_disable_socket(brdev, child);
|
2002-01-29 06:50:18 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_cardbus_power_disable_socket(brdev, child);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2003-06-07 20:47:35 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid,
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res)
|
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2003-06-07 20:47:35 +00:00
|
|
|
return (exca_activate_resource(&sc->exca, child, type, rid, res));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_deactivate_resource(device_t brdev, device_t child, int type,
|
2001-08-27 00:09:42 +00:00
|
|
|
int rid, struct resource *res)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2003-06-07 20:47:35 +00:00
|
|
|
return (exca_deactivate_resource(&sc->exca, child, type, rid, res));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
static struct resource *
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid,
|
2003-08-07 15:04:27 +00:00
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res = NULL;
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2004-04-12 21:04:54 +00:00
|
|
|
int align;
|
2001-08-27 00:09:42 +00:00
|
|
|
int tmp;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2000-10-22 04:37:57 +00:00
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_MEMORY:
|
2002-08-15 08:01:24 +00:00
|
|
|
if (start < cbb_start_mem)
|
|
|
|
start = cbb_start_mem;
|
2001-08-27 00:09:42 +00:00
|
|
|
if (end < start)
|
|
|
|
end = start;
|
2004-04-12 21:04:54 +00:00
|
|
|
if (count < CBB_MEMALIGN)
|
|
|
|
align = CBB_MEMALIGN;
|
|
|
|
else
|
|
|
|
align = count;
|
|
|
|
if (align > (1 << RF_ALIGNMENT(flags)))
|
|
|
|
flags = (flags & ~RF_ALIGNMENT_MASK) |
|
|
|
|
rman_make_alignment_flags(align);
|
2000-10-22 04:37:57 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IOPORT:
|
2002-08-15 08:01:24 +00:00
|
|
|
if (start < cbb_start_16_io)
|
|
|
|
start = cbb_start_16_io;
|
2000-10-22 04:37:57 +00:00
|
|
|
if (end < start)
|
|
|
|
end = start;
|
|
|
|
break;
|
|
|
|
case SYS_RES_IRQ:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
tmp = rman_get_start(sc->irq_res);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (start > tmp || end < tmp || count != 1) {
|
|
|
|
device_printf(child, "requested interrupt %ld-%ld,"
|
2002-08-15 08:01:24 +00:00
|
|
|
"count = %ld not supported by cbb\n",
|
2001-08-27 00:09:42 +00:00
|
|
|
start, end, count);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2000-10-22 04:37:57 +00:00
|
|
|
flags |= RF_SHAREABLE;
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
start = end = rman_get_start(sc->irq_res);
|
2000-10-22 04:37:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-08-27 00:09:42 +00:00
|
|
|
res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid,
|
|
|
|
start, end, count, flags & ~RF_ACTIVE);
|
|
|
|
if (res == NULL)
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_insert_res(sc, res, type, *rid);
|
2000-10-18 03:25:13 +00:00
|
|
|
if (flags & RF_ACTIVE) {
|
2001-08-27 00:09:42 +00:00
|
|
|
if (bus_activate_resource(child, type, *rid, res) != 0) {
|
|
|
|
bus_release_resource(child, type, *rid, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (NULL);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-26 05:42:45 +00:00
|
|
|
return (res);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_release_resource(device_t brdev, device_t child, int type,
|
2001-08-26 23:55:34 +00:00
|
|
|
int rid, struct resource *res)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-11-26 05:42:45 +00:00
|
|
|
int error;
|
2001-01-06 18:04:55 +00:00
|
|
|
|
|
|
|
if (rman_get_flags(res) & RF_ACTIVE) {
|
|
|
|
error = bus_deactivate_resource(child, type, rid, res);
|
|
|
|
if (error != 0)
|
2001-11-26 05:42:45 +00:00
|
|
|
return (error);
|
2001-01-06 18:04:55 +00:00
|
|
|
}
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_remove_res(sc, res);
|
2001-11-26 05:42:45 +00:00
|
|
|
return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child,
|
|
|
|
type, rid, res));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* PC Card methods */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_set_res_flags(device_t brdev, device_t child, int type, int rid,
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t flags)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res;
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
if (type != SYS_RES_MEMORY)
|
|
|
|
return (EINVAL);
|
2002-08-15 08:01:24 +00:00
|
|
|
res = cbb_find_res(sc, type, rid);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (res == NULL) {
|
|
|
|
device_printf(brdev,
|
|
|
|
"set_res_flags: specified rid not found\n");
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENOENT);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2002-01-29 06:50:18 +00:00
|
|
|
return (exca_mem_set_flags(&sc->exca, res, flags));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid,
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t cardaddr, uint32_t *deltap)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-08-27 00:09:42 +00:00
|
|
|
struct resource *res;
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
res = cbb_find_res(sc, SYS_RES_MEMORY, rid);
|
2001-08-27 00:09:42 +00:00
|
|
|
if (res == NULL) {
|
|
|
|
device_printf(brdev,
|
|
|
|
"set_memory_offset: specified rid not found\n");
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENOENT);
|
2001-08-27 00:09:42 +00:00
|
|
|
}
|
2002-01-29 06:50:18 +00:00
|
|
|
return (exca_mem_set_offset(&sc->exca, res, cardaddr, deltap));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
2000-11-28 00:05:20 +00:00
|
|
|
/* BUS Methods */
|
2000-10-18 03:25:13 +00:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_activate_resource(device_t brdev, device_t child, int type, int rid,
|
2001-08-26 23:55:34 +00:00
|
|
|
struct resource *r)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
return (cbb_pcic_activate_resource(brdev, child, type, rid, r));
|
2000-10-18 03:25:13 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
return (cbb_cardbus_activate_resource(brdev, child, type, rid,
|
2001-11-26 05:42:45 +00:00
|
|
|
r));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_deactivate_resource(device_t brdev, device_t child, int type,
|
2001-08-26 23:55:34 +00:00
|
|
|
int rid, struct resource *r)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
return (cbb_pcic_deactivate_resource(brdev, child, type,
|
2001-11-26 05:42:45 +00:00
|
|
|
rid, r));
|
2000-10-18 03:25:13 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
return (cbb_cardbus_deactivate_resource(brdev, child, type,
|
2001-11-26 05:42:45 +00:00
|
|
|
rid, r));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 23:55:34 +00:00
|
|
|
static struct resource *
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_alloc_resource(device_t brdev, device_t child, int type, int *rid,
|
2003-08-07 15:04:27 +00:00
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
return (cbb_pcic_alloc_resource(brdev, child, type, rid,
|
2001-11-26 05:42:45 +00:00
|
|
|
start, end, count, flags));
|
2000-10-18 03:25:13 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
return (cbb_cardbus_alloc_resource(brdev, child, type, rid,
|
2001-11-26 05:42:45 +00:00
|
|
|
start, end, count, flags));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_release_resource(device_t brdev, device_t child, int type, int rid,
|
2001-08-26 23:55:34 +00:00
|
|
|
struct resource *r)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
if (sc->flags & CBB_16BIT_CARD)
|
|
|
|
return (cbb_pcic_release_resource(brdev, child, type,
|
2001-11-26 05:42:45 +00:00
|
|
|
rid, r));
|
2000-10-18 03:25:13 +00:00
|
|
|
else
|
2002-08-15 08:01:24 +00:00
|
|
|
return (cbb_cardbus_release_resource(brdev, child, type,
|
2001-11-26 05:42:45 +00:00
|
|
|
rid, r));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2000-12-13 01:28:00 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_read_ivar(device_t brdev, device_t child, int which, uintptr_t *result)
|
2000-12-13 01:28:00 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2001-01-06 18:04:55 +00:00
|
|
|
|
2000-12-13 01:28:00 +00:00
|
|
|
switch (which) {
|
|
|
|
case PCIB_IVAR_BUS:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
*result = sc->secbus;
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-12-13 01:28:00 +00:00
|
|
|
}
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENOENT);
|
2000-12-13 01:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_write_ivar(device_t brdev, device_t child, int which, uintptr_t value)
|
2000-12-13 01:28:00 +00:00
|
|
|
{
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(brdev);
|
2000-12-13 01:28:00 +00:00
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case PCIB_IVAR_BUS:
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
sc->secbus = value;
|
2000-12-13 01:28:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-11-26 05:42:45 +00:00
|
|
|
return (ENOENT);
|
2000-12-13 01:28:00 +00:00
|
|
|
}
|
|
|
|
|
2000-11-28 00:05:20 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* PCI compat methods */
|
|
|
|
/************************************************************************/
|
|
|
|
|
2000-10-18 03:25:13 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_maxslots(device_t brdev)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
2001-11-26 05:42:45 +00:00
|
|
|
return (0);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2002-01-14 02:59:06 +00:00
|
|
|
static uint32_t
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_read_config(device_t brdev, int b, int s, int f, int reg, int width)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Pass through to the next ppb up the chain (i.e. our grandparent).
|
|
|
|
*/
|
2001-11-26 05:42:45 +00:00
|
|
|
return (PCIB_READ_CONFIG(device_get_parent(device_get_parent(brdev)),
|
|
|
|
b, s, f, reg, width));
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_write_config(device_t brdev, int b, int s, int f, int reg, uint32_t val,
|
2001-08-26 23:55:34 +00:00
|
|
|
int width)
|
2000-10-18 03:25:13 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Pass through to the next ppb up the chain (i.e. our grandparent).
|
|
|
|
*/
|
2001-08-26 23:55:34 +00:00
|
|
|
PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(brdev)),
|
|
|
|
b, s, f, reg, val, width);
|
2000-10-18 03:25:13 +00:00
|
|
|
}
|
|
|
|
|
2001-12-15 05:58:28 +00:00
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_suspend(device_t self)
|
2001-12-15 05:58:28 +00:00
|
|
|
{
|
|
|
|
int error = 0;
|
2002-10-07 23:11:29 +00:00
|
|
|
struct cbb_softc *sc = device_get_softc(self);
|
2001-12-15 05:58:28 +00:00
|
|
|
|
2003-06-12 03:37:28 +00:00
|
|
|
cbb_set(sc, CBB_SOCKET_MASK, 0); /* Quiet hardware */
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
bus_teardown_intr(self, sc->irq_res, sc->intrhand);
|
2002-11-02 23:00:28 +00:00
|
|
|
sc->flags &= ~CBB_CARD_OK; /* Card is bogus now */
|
2001-12-15 05:58:28 +00:00
|
|
|
error = bus_generic_suspend(self);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_resume(device_t self)
|
2001-12-15 05:58:28 +00:00
|
|
|
{
|
|
|
|
int error = 0;
|
2002-08-15 08:01:24 +00:00
|
|
|
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(self);
|
2002-01-14 02:59:06 +00:00
|
|
|
uint32_t tmp;
|
2001-12-15 05:58:28 +00:00
|
|
|
|
2002-10-07 23:11:29 +00:00
|
|
|
/*
|
|
|
|
* Some BIOSes will not save the BARs for the pci chips, so we
|
|
|
|
* must do it ourselves. If the BAR is reset to 0 for an I/O
|
|
|
|
* device, it will read back as 0x1, so no explicit test for
|
|
|
|
* memory devices are needed.
|
|
|
|
*
|
|
|
|
* Note: The PCI bus code should do this automatically for us on
|
|
|
|
* suspend/resume, but until it does, we have to cope.
|
|
|
|
*/
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
pci_write_config(self, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4);
|
2001-12-15 05:58:28 +00:00
|
|
|
DEVPRINTF((self, "PCI Memory allocated: %08lx\n",
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
rman_get_start(sc->base_res)));
|
2001-12-15 05:58:28 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_chipinit(sc);
|
2001-12-15 05:58:28 +00:00
|
|
|
|
2002-10-07 23:11:29 +00:00
|
|
|
/* reset interrupt -- Do we really need to do this? */
|
|
|
|
tmp = cbb_get(sc, CBB_SOCKET_EVENT);
|
|
|
|
cbb_set(sc, CBB_SOCKET_EVENT, tmp);
|
|
|
|
|
2001-12-15 05:58:28 +00:00
|
|
|
/* re-establish the interrupt. */
|
2004-05-04 02:25:00 +00:00
|
|
|
if (bus_setup_intr(self, sc->irq_res, INTR_TYPE_AV | INTR_MPSAFE,
|
|
|
|
cbb_intr, sc, &sc->intrhand)) {
|
2001-12-15 05:58:28 +00:00
|
|
|
device_printf(self, "couldn't re-establish interrupt");
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res);
|
|
|
|
bus_release_resource(self, SYS_RES_MEMORY, CBBR_SOCKBASE,
|
|
|
|
sc->base_res);
|
|
|
|
sc->irq_res = NULL;
|
|
|
|
sc->base_res = NULL;
|
|
|
|
return (ENOMEM);
|
2001-12-15 05:58:28 +00:00
|
|
|
}
|
2002-02-10 03:28:37 +00:00
|
|
|
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
/* CSC Interrupt: Card detect interrupt on */
|
2002-08-15 08:01:24 +00:00
|
|
|
cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
|
Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.
o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread. Instead, just
create the kthread in the attach routine.
o Remove sc_ from some structure names. It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges. We specifically don't generically
match PCI PCMCIA bridges because they are not, with one exception, yenta
devices.
o Add some comments about the why we need to have a function table ala
OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards. X and Y are numbers to be determined
later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
volage. Windows does this, and MS's design guides imply this is the
right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
warn about it better. Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
|
|
|
|
2002-11-02 23:00:28 +00:00
|
|
|
/* Signal the thread to wakeup. */
|
|
|
|
mtx_lock(&sc->mtx);
|
|
|
|
cv_signal(&sc->cv);
|
|
|
|
mtx_unlock(&sc->mtx);
|
2002-02-10 03:28:37 +00:00
|
|
|
|
|
|
|
error = bus_generic_resume(self);
|
2001-12-15 05:58:28 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2002-11-14 05:20:39 +00:00
|
|
|
static int
|
|
|
|
cbb_child_present(device_t self)
|
|
|
|
{
|
|
|
|
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(self);
|
|
|
|
uint32_t sockstate;
|
|
|
|
|
|
|
|
sockstate = cbb_get(sc, CBB_SOCKET_STATE);
|
2003-08-20 06:13:01 +00:00
|
|
|
return (CBB_CARD_PRESENT(sockstate) &&
|
2003-08-18 21:59:24 +00:00
|
|
|
(sc->flags & CBB_CARD_OK) == CBB_CARD_OK);
|
2002-11-14 05:20:39 +00:00
|
|
|
}
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
static device_method_t cbb_methods[] = {
|
2000-10-18 03:25:13 +00:00
|
|
|
/* Device interface */
|
2002-08-15 08:01:24 +00:00
|
|
|
DEVMETHOD(device_probe, cbb_probe),
|
|
|
|
DEVMETHOD(device_attach, cbb_attach),
|
|
|
|
DEVMETHOD(device_detach, cbb_detach),
|
|
|
|
DEVMETHOD(device_shutdown, cbb_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, cbb_suspend),
|
|
|
|
DEVMETHOD(device_resume, cbb_resume),
|
2000-10-18 03:25:13 +00:00
|
|
|
|
|
|
|
/* bus methods */
|
|
|
|
DEVMETHOD(bus_print_child, bus_generic_print_child),
|
2002-08-15 08:01:24 +00:00
|
|
|
DEVMETHOD(bus_read_ivar, cbb_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, cbb_write_ivar),
|
|
|
|
DEVMETHOD(bus_alloc_resource, cbb_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, cbb_release_resource),
|
|
|
|
DEVMETHOD(bus_activate_resource, cbb_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, cbb_deactivate_resource),
|
|
|
|
DEVMETHOD(bus_driver_added, cbb_driver_added),
|
|
|
|
DEVMETHOD(bus_child_detached, cbb_child_detached),
|
|
|
|
DEVMETHOD(bus_setup_intr, cbb_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, cbb_teardown_intr),
|
2002-11-14 05:20:39 +00:00
|
|
|
DEVMETHOD(bus_child_present, cbb_child_present),
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
/* 16-bit card interface */
|
2002-08-15 08:01:24 +00:00
|
|
|
DEVMETHOD(card_set_res_flags, cbb_pcic_set_res_flags),
|
|
|
|
DEVMETHOD(card_set_memory_offset, cbb_pcic_set_memory_offset),
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
/* power interface */
|
2002-08-15 08:01:24 +00:00
|
|
|
DEVMETHOD(power_enable_socket, cbb_power_enable_socket),
|
|
|
|
DEVMETHOD(power_disable_socket, cbb_power_disable_socket),
|
2000-10-18 03:25:13 +00:00
|
|
|
|
2001-08-27 00:09:42 +00:00
|
|
|
/* pcib compatibility interface */
|
2002-08-15 08:01:24 +00:00
|
|
|
DEVMETHOD(pcib_maxslots, cbb_maxslots),
|
|
|
|
DEVMETHOD(pcib_read_config, cbb_read_config),
|
|
|
|
DEVMETHOD(pcib_write_config, cbb_write_config),
|
2000-10-18 03:25:13 +00:00
|
|
|
{0,0}
|
|
|
|
};
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
static driver_t cbb_driver = {
|
|
|
|
"cbb",
|
|
|
|
cbb_methods,
|
|
|
|
sizeof(struct cbb_softc)
|
2000-10-18 03:25:13 +00:00
|
|
|
};
|
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
static devclass_t cbb_devclass;
|
2000-11-28 00:05:20 +00:00
|
|
|
|
2002-08-15 08:01:24 +00:00
|
|
|
DRIVER_MODULE(cbb, pci, cbb_driver, cbb_devclass, 0, 0);
|
|
|
|
MODULE_VERSION(cbb, 1);
|
|
|
|
MODULE_DEPEND(cbb, exca, 1, 1, 1);
|