MFp4:
o Protect .h against multiple includes. o eliminate the pointers to the read/write routines. The bus_space_read routines can cope since we have the offset field. o Print a warning if the requested map address is > 16M and your chipset doesn't support the extended ExCA registers.
This commit is contained in:
parent
a850203de0
commit
6dfd31d460
@ -82,7 +82,6 @@
|
||||
#define DPRINTF(fmt, args...)
|
||||
#endif
|
||||
|
||||
|
||||
/* memory */
|
||||
|
||||
#define EXCA_MEMINFO(NUM) { \
|
||||
@ -198,6 +197,11 @@ exca_mem_map(struct exca_softc *sc, int kind, struct resource *res)
|
||||
}
|
||||
if (win >= EXCA_MEM_WINS)
|
||||
return (1);
|
||||
if (((rman_get_start(res) >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff) != 0 &&
|
||||
(sc->flags & EXCA_HAS_MEMREG_WIN) == 0) {
|
||||
device_printf(sc->dev, "Does not support mapping above 24M.");
|
||||
return (1);
|
||||
}
|
||||
|
||||
sc->mem[win].cardaddr = 0;
|
||||
sc->mem[win].memt = rman_get_bustag(res);
|
||||
@ -555,13 +559,10 @@ exca_reset(struct exca_softc *sc, device_t child)
|
||||
* Initialize the exca_softc data structure for the first time.
|
||||
*/
|
||||
void
|
||||
exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn,
|
||||
exca_read_t *rdfn, bus_space_tag_t bst, bus_space_handle_t bsh,
|
||||
uint32_t offset)
|
||||
exca_init(struct exca_softc *sc, device_t dev,
|
||||
bus_space_tag_t bst, bus_space_handle_t bsh, uint32_t offset)
|
||||
{
|
||||
sc->dev = dev;
|
||||
sc->write_exca = wrfn;
|
||||
sc->read_exca = rdfn;
|
||||
sc->memalloc = 0;
|
||||
sc->ioalloc = 0;
|
||||
sc->bst = bst;
|
||||
@ -580,8 +581,7 @@ exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn,
|
||||
* "exca" parameter.
|
||||
*/
|
||||
int
|
||||
exca_probe_slots(device_t dev, struct exca_softc *exca, exca_write_t writefnp,
|
||||
exca_read_t readfnp)
|
||||
exca_probe_slots(device_t dev, struct exca_softc *exca)
|
||||
{
|
||||
int rid;
|
||||
struct resource *res;
|
||||
@ -599,8 +599,7 @@ exca_probe_slots(device_t dev, struct exca_softc *exca, exca_write_t writefnp,
|
||||
iot = rman_get_bustag(res);
|
||||
ioh = rman_get_bushandle(res);
|
||||
for (i = 0; i < EXCA_NSLOTS; i++) {
|
||||
exca_init(&exca[i], dev, writefnp, readfnp, iot, ioh,
|
||||
i * EXCA_SOCKET_SIZE);
|
||||
exca_init(&exca[i], dev, iot, ioh, i * EXCA_SOCKET_SIZE);
|
||||
if (exca_is_pcic(&exca[i])) {
|
||||
err = 0;
|
||||
exca[i].flags |= EXCA_SOCKET_PRESENT;
|
||||
|
@ -55,6 +55,9 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DEV_EXCA_EXCAREG_H
|
||||
#define _SYS_DEV_EXCA_EXCAREG_H
|
||||
|
||||
/*
|
||||
* All information is from the intel 82365sl PC Card Interface Controller
|
||||
* (PCIC) data sheet, marked "preliminary". Order number 290423-002, January
|
||||
@ -419,3 +422,5 @@
|
||||
#else
|
||||
#define EXCA_INT_MASK_ALLOWED 0xDEB8 /* AT */
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_DEV_EXCA_EXCAREG_H */
|
||||
|
@ -54,18 +54,17 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DEV_EXCA_EXCAVAR_H
|
||||
#define _SYS_DEV_EXCA_EXCAVAR_H
|
||||
|
||||
/*
|
||||
* Structure to manage the ExCA part of the chip.
|
||||
*/
|
||||
struct exca_softc;
|
||||
typedef uint8_t (exca_read_t)(struct exca_softc *, int);
|
||||
typedef void (exca_write_t)(struct exca_softc *, int, uint8_t);
|
||||
|
||||
struct exca_softc
|
||||
{
|
||||
device_t dev;
|
||||
exca_read_t *read_exca;
|
||||
exca_write_t *write_exca;
|
||||
int memalloc;
|
||||
struct pccard_mem_handle mem[EXCA_MEM_WINS];
|
||||
int ioalloc;
|
||||
@ -74,11 +73,12 @@ struct exca_softc
|
||||
bus_space_handle_t bsh;
|
||||
uint32_t flags;
|
||||
#define EXCA_SOCKET_PRESENT 0x00000001
|
||||
#define EXCA_HAS_MEMREG_WIN 0x00000002
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
void exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn,
|
||||
exca_read_t *rdfn, bus_space_tag_t, bus_space_handle_t, uint32_t);
|
||||
void exca_init(struct exca_softc *sc, device_t dev,
|
||||
bus_space_tag_t, bus_space_handle_t, uint32_t);
|
||||
int exca_io_map(struct exca_softc *sc, int width, struct resource *r);
|
||||
int exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
|
||||
int exca_is_pcic(struct exca_softc *sc);
|
||||
@ -88,20 +88,19 @@ int exca_mem_set_flags(struct exca_softc *sc, struct resource *res,
|
||||
int exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
|
||||
uint32_t cardaddr, uint32_t *deltap);
|
||||
int exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
|
||||
int exca_probe_slots(device_t dev, struct exca_softc *, exca_write_t *,
|
||||
exca_read_t *);
|
||||
int exca_probe_slots(device_t dev, struct exca_softc *);
|
||||
void exca_reset(struct exca_softc *, device_t child);
|
||||
|
||||
static __inline uint8_t
|
||||
exca_read(struct exca_softc *sc, int reg)
|
||||
{
|
||||
return (sc->read_exca(sc, reg));
|
||||
return (bus_space_read_1(sc->bst, sc->bsh, sc->offset + reg));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
exca_write(struct exca_softc *sc, int reg, uint8_t val)
|
||||
{
|
||||
sc->write_exca(sc, reg, val);
|
||||
return (bus_space_write_1(sc->bst, sc->bsh, sc->offset + reg, val));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@ -115,3 +114,5 @@ exca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
|
||||
{
|
||||
exca_write(sc, reg, exca_read(sc, reg) & ~mask);
|
||||
}
|
||||
|
||||
#endif /* !_SYS_DEV_EXCA_EXCAVAR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user