freebsd-dev/sys/pccard/pcicvar.h
Warner Losh 57462c010c Next step on the road to pci: power taming.
Work through the various power commands and convert them from a "is
this a foo controller or a foo' controller or a foo''' controller" to
a cabability based scheme.  We have bits in the softc that tell us
what kind of power control scheme the controller uses, rather than
relying on being able to enumerate them all.  Cardbus bridges are
numerous, but nearly all implement the i82365sl-DF scheme (well, a few
implement cirrus CL-PD67xx, but those were made by Cirrus Logic!).

Add a pointer back to the softc in each pcic_slot so we can access
these flags.

Add comments that talk about the issues here.  Also note in passing
that there are two differ Vpp schemes in use and that we may need to
adjust the code to deal with both of them.  Note why it usually works
now.

We have 5 power management modes right now: KING, AB, DF, PD and VG.
AB is for the i82365 stpes A, B and C.  DF is for step DF.  PD is the
cirrus logic extensions for 3.3V while VG is the VADEM extensions for
3.3V.  KING is for the IBM KING controller found on some old cards.
# I'm looking for one of those old cards or a laptop that has the KING
# bridge in it.

We have to still cheat and treat the AB parts like the DF parts
because pci isn't here yet.  As far as I can tell, this is harmless
for actual old parts and necessary to work with 3.3V cards in some
laptops.

This almost eliminates all tests for controller in the code.  There
are still a few unrelated to power that need taming as well.
2001-05-21 04:44:14 +00:00

87 lines
3.6 KiB
C

/*
* Copyright (c) 2001 M. Warner Losh. 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.
*
* 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.
*
* $FreeBSD$
*/
/*
* Per-slot data table.
*/
struct pcic_slot {
int index; /* Index register */
int data; /* Data register */
int offset; /* Offset value for index */
char controller; /* Device type */
char revision; /* Device Revision */
struct slot *slt; /* Back ptr to slot */
struct pcic_softc *sc; /* Back pointer to softc */
u_char (*getb)(struct pcic_slot *, int);
void (*putb)(struct pcic_slot *, int, u_char);
u_char *regs; /* Pointer to regs in mem */
};
struct pcic_softc
{
u_int32_t slotmask; /* Mask of valid slots */
u_int32_t flags; /* Interesting flags */
#define PCIC_IO_MAPPED 0x00000001 /* ExCA registers are io mapped */
#define PCIC_MEM_MAPPED 0x00000002 /* ExCA registers mem mapped */
#define PCIC_VG_POWER 0x00000004 /* Uses VG power regs */
#define PCIC_DF_POWER 0x00000008 /* Uses DF step regs */
#define PCIC_PD_POWER 0x00000010 /* Uses CL-PD regs */
#define PCIC_KING_POWER 0x00000020 /* Uses IBM KING regs */
#define PCIC_AB_POWER 0x00000040 /* Use old A/B step power */
int iorid; /* Rid of I/O region */
struct resource *iores; /* resource for I/O region */
int memrid;
struct resource *memres;
int irqrid;
struct resource *irqres;
void *ih;
int unit;
struct callout_handle timeout_ch;
struct pcic_slot slots[PCIC_MAX_SLOTS];
};
extern devclass_t pcic_devclass;
int pcic_attach(device_t dev);
int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
struct resource *r);
int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
int flags, driver_intr_t *intr, void *arg, void **cookiep);
int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
void *cookie);
int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
u_long value);
int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
u_long *value);
int pcic_get_memory_offset(device_t bus, device_t child, int rid,
u_int32_t *offset);
int pcic_set_memory_offset(device_t bus, device_t child, int rid,
u_int32_t offset, u_int32_t *deltap);
void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask);