2008-04-29 00:22:51 +04:00
|
|
|
/* $NetBSD: am79c930.c,v 1.16 2008/04/28 20:23:49 martin Exp $ */
|
1999-11-05 08:13:36 +03:00
|
|
|
|
1999-11-04 20:10:53 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Bill Sommerfeld
|
|
|
|
*
|
|
|
|
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Am79c930 chip driver.
|
|
|
|
*
|
|
|
|
* This is used by the awi driver to use the shared
|
|
|
|
* memory attached to the 79c930 to communicate with the firmware running
|
|
|
|
* in the 930's on-board 80188 core.
|
|
|
|
*
|
|
|
|
* The 79c930 can be mapped into just I/O space, or also have a
|
|
|
|
* memory mapping; the mapping must be set up by the bus front-end
|
|
|
|
* before am79c930_init is called.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* operations:
|
|
|
|
*
|
|
|
|
* read_8, read_16, read_32, read_64, read_bytes
|
|
|
|
* write_8, write_16, write_32, write_64, write_bytes
|
|
|
|
* (two versions, depending on whether memory-space or i/o space is in use).
|
|
|
|
*
|
|
|
|
* interrupt E.C.
|
|
|
|
* start isr
|
|
|
|
* end isr
|
|
|
|
*/
|
|
|
|
|
2001-11-13 16:14:31 +03:00
|
|
|
#include <sys/cdefs.h>
|
2004-01-15 12:33:48 +03:00
|
|
|
#ifdef __NetBSD__
|
2008-04-29 00:22:51 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: am79c930.c,v 1.16 2008/04/28 20:23:49 martin Exp $");
|
2004-01-15 12:33:48 +03:00
|
|
|
#endif
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
#endif
|
2001-11-13 16:14:31 +03:00
|
|
|
|
1999-11-04 20:10:53 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2004-01-15 12:33:48 +03:00
|
|
|
#include <sys/endian.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#ifndef __FreeBSD__
|
1999-11-04 20:10:53 +03:00
|
|
|
#include <sys/device.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#endif
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/cpu.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <machine/bus_pio.h>
|
|
|
|
#include <machine/bus_memio.h>
|
|
|
|
#endif
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#ifdef __NetBSD__
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/intr.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#endif
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
#ifdef __NetBSD__
|
1999-11-04 20:10:53 +03:00
|
|
|
#include <dev/ic/am79c930reg.h>
|
|
|
|
#include <dev/ic/am79c930var.h>
|
2000-03-22 14:22:20 +03:00
|
|
|
#endif
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <dev/awi/am79c930reg.h>
|
|
|
|
#include <dev/awi/am79c930var.h>
|
|
|
|
#endif
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
#define AM930_DELAY(x) /*nothing*/
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2004-03-11 08:59:33 +03:00
|
|
|
#ifndef __BUS_SPACE_HAS_STREAM_METHODS
|
|
|
|
#define bus_space_read_stream_2 bus_space_read_2
|
|
|
|
#define bus_space_read_stream_4 bus_space_read_4
|
|
|
|
#define bus_space_write_stream_2 bus_space_write_2
|
|
|
|
#define bus_space_write_stream_4 bus_space_write_4
|
|
|
|
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
void am79c930_regdump(struct am79c930_softc *sc);
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void io_write_1(struct am79c930_softc *, u_int32_t, u_int8_t);
|
|
|
|
static void io_write_2(struct am79c930_softc *, u_int32_t, u_int16_t);
|
|
|
|
static void io_write_4(struct am79c930_softc *, u_int32_t, u_int32_t);
|
|
|
|
static void io_write_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t);
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int8_t io_read_1(struct am79c930_softc *, u_int32_t);
|
|
|
|
static u_int16_t io_read_2(struct am79c930_softc *, u_int32_t);
|
|
|
|
static u_int32_t io_read_4(struct am79c930_softc *, u_int32_t);
|
|
|
|
static void io_read_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t);
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void mem_write_1(struct am79c930_softc *, u_int32_t, u_int8_t);
|
|
|
|
static void mem_write_2(struct am79c930_softc *, u_int32_t, u_int16_t);
|
|
|
|
static void mem_write_4(struct am79c930_softc *, u_int32_t, u_int32_t);
|
|
|
|
static void mem_write_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t);
|
1999-11-04 20:10:53 +03:00
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int8_t mem_read_1(struct am79c930_softc *, u_int32_t);
|
|
|
|
static u_int16_t mem_read_2(struct am79c930_softc *, u_int32_t);
|
|
|
|
static u_int32_t mem_read_4(struct am79c930_softc *, u_int32_t);
|
|
|
|
static void mem_read_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t);
|
1999-11-04 20:10:53 +03:00
|
|
|
|
|
|
|
static struct am79c930_ops iospace_ops = {
|
|
|
|
io_write_1,
|
|
|
|
io_write_2,
|
|
|
|
io_write_4,
|
|
|
|
io_write_bytes,
|
|
|
|
io_read_1,
|
|
|
|
io_read_2,
|
|
|
|
io_read_4,
|
|
|
|
io_read_bytes
|
|
|
|
};
|
|
|
|
|
|
|
|
struct am79c930_ops memspace_ops = {
|
|
|
|
mem_write_1,
|
|
|
|
mem_write_2,
|
|
|
|
mem_write_4,
|
|
|
|
mem_write_bytes,
|
|
|
|
mem_read_1,
|
|
|
|
mem_read_2,
|
|
|
|
mem_read_4,
|
|
|
|
mem_read_bytes
|
|
|
|
};
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
io_write_1( struct am79c930_softc *sc, u_int32_t off, u_int8_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA, val);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
io_write_2(struct am79c930_softc *sc, u_int32_t off, u_int16_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, val & 0xff);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, (val>>8)&0xff);
|
|
|
|
AM930_DELAY(1);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
io_write_4(struct am79c930_softc *sc, u_int32_t off, u_int32_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,val & 0xff);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>8)&0xff);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>16)&0xff);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>24)&0xff);
|
|
|
|
AM930_DELAY(1);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
io_write_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr,
|
|
|
|
size_t len)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
int i;
|
2000-02-17 20:37:23 +03:00
|
|
|
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
1999-11-04 20:10:53 +03:00
|
|
|
for (i=0; i<len; i++)
|
2000-02-17 20:37:23 +03:00
|
|
|
bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,ptr[i]);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int8_t
|
|
|
|
io_read_1(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
u_int8_t val;
|
2004-01-15 12:33:48 +03:00
|
|
|
|
1999-11-04 20:10:53 +03:00
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int16_t
|
|
|
|
io_read_2(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
u_int16_t val;
|
|
|
|
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8;
|
2005-02-27 03:26:58 +03:00
|
|
|
AM930_DELAY(1);
|
2000-02-17 20:37:23 +03:00
|
|
|
return val;
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int32_t
|
|
|
|
io_read_4(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
u_int32_t val;
|
|
|
|
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA);
|
|
|
|
AM930_DELAY(1);
|
|
|
|
val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8;
|
2005-02-27 03:26:58 +03:00
|
|
|
AM930_DELAY(1);
|
2000-02-17 20:37:23 +03:00
|
|
|
val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 16;
|
2005-02-27 03:26:58 +03:00
|
|
|
AM930_DELAY(1);
|
2000-02-17 20:37:23 +03:00
|
|
|
val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 24;
|
2005-02-27 03:26:58 +03:00
|
|
|
AM930_DELAY(1);
|
2000-02-17 20:37:23 +03:00
|
|
|
return val;
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
io_read_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr,
|
|
|
|
size_t len)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
int i;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2000-02-17 20:37:23 +03:00
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI,
|
|
|
|
((off>>8)& 0x7f));
|
|
|
|
AM930_DELAY(1);
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff));
|
|
|
|
AM930_DELAY(1);
|
2005-02-27 03:26:58 +03:00
|
|
|
for (i=0; i<len; i++)
|
2000-02-17 20:37:23 +03:00
|
|
|
ptr[i] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
|
|
|
|
AM79C930_IODPA);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
mem_write_1(struct am79c930_softc *sc, u_int32_t off, u_int8_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
bus_space_write_1(sc->sc_memt, sc->sc_memh, off, val);
|
|
|
|
}
|
|
|
|
|
2004-02-13 04:22:20 +03:00
|
|
|
static void
|
|
|
|
mem_write_2(struct am79c930_softc *sc, u_int32_t off, u_int16_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-03-23 16:57:58 +03:00
|
|
|
bus_space_tag_t t = sc->sc_memt;
|
|
|
|
bus_space_handle_t h = sc->sc_memh;
|
|
|
|
|
|
|
|
/* could be unaligned */
|
|
|
|
if ((off & 0x1) == 0)
|
2004-03-08 09:52:44 +03:00
|
|
|
bus_space_write_stream_2(t, h, off, htole16(val));
|
2000-03-23 16:57:58 +03:00
|
|
|
else {
|
|
|
|
bus_space_write_1(t, h, off, val & 0xff);
|
|
|
|
bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
|
|
|
|
}
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
mem_write_4(struct am79c930_softc *sc, u_int32_t off, u_int32_t val)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-03-23 16:57:58 +03:00
|
|
|
bus_space_tag_t t = sc->sc_memt;
|
|
|
|
bus_space_handle_t h = sc->sc_memh;
|
|
|
|
|
|
|
|
/* could be unaligned */
|
|
|
|
if ((off & 0x3) == 0)
|
2004-03-08 09:52:44 +03:00
|
|
|
bus_space_write_stream_4(t, h, off, htole32(val));
|
2000-03-23 16:57:58 +03:00
|
|
|
else {
|
|
|
|
bus_space_write_1(t, h, off, val & 0xff);
|
|
|
|
bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
|
|
|
|
bus_space_write_1(t, h, off+2, (val >> 16) & 0xff);
|
|
|
|
bus_space_write_1(t, h, off+3, (val >> 24) & 0xff);
|
|
|
|
}
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
mem_write_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr,
|
|
|
|
size_t len)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
bus_space_write_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int8_t
|
|
|
|
mem_read_1(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
return bus_space_read_1(sc->sc_memt, sc->sc_memh, off);
|
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int16_t
|
|
|
|
mem_read_2(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-03-23 16:57:58 +03:00
|
|
|
/* could be unaligned */
|
|
|
|
if ((off & 0x1) == 0)
|
2004-03-08 09:52:44 +03:00
|
|
|
return le16toh(bus_space_read_stream_2(sc->sc_memt,
|
|
|
|
sc->sc_memh, off));
|
2000-03-23 16:57:58 +03:00
|
|
|
else
|
|
|
|
return
|
|
|
|
bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
|
|
|
|
(bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static u_int32_t
|
|
|
|
mem_read_4(struct am79c930_softc *sc, u_int32_t off)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-03-23 16:57:58 +03:00
|
|
|
/* could be unaligned */
|
|
|
|
if ((off & 0x3) == 0)
|
2004-03-08 09:52:44 +03:00
|
|
|
return le32toh(bus_space_read_stream_4(sc->sc_memt, sc->sc_memh,
|
|
|
|
off));
|
2000-03-23 16:57:58 +03:00
|
|
|
else
|
|
|
|
return
|
|
|
|
bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
|
|
|
|
(bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8) |
|
|
|
|
(bus_space_read_1(sc->sc_memt, sc->sc_memh, off+2) <<16) |
|
|
|
|
(bus_space_read_1(sc->sc_memt, sc->sc_memh, off+3) <<24);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
static void
|
|
|
|
mem_read_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr,
|
|
|
|
size_t len)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
2000-02-17 20:37:23 +03:00
|
|
|
bus_space_read_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len);
|
1999-11-04 20:10:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set bits in GCR.
|
|
|
|
*/
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
void
|
|
|
|
am79c930_gcr_setbits(struct am79c930_softc *sc, u_int8_t bits)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
|
|
|
|
|
|
|
|
gcr |= bits;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1999-11-04 20:10:53 +03:00
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear bits in GCR.
|
|
|
|
*/
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
void
|
|
|
|
am79c930_gcr_clearbits(struct am79c930_softc *sc, u_int8_t bits)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
|
|
|
|
|
|
|
|
gcr &= ~bits;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1999-11-04 20:10:53 +03:00
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr);
|
|
|
|
}
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
u_int8_t
|
|
|
|
am79c930_gcr_read(struct am79c930_softc *sc)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
return bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR);
|
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
#if 0
|
2004-01-15 12:33:48 +03:00
|
|
|
void
|
|
|
|
am79c930_regdump(struct am79c930_softc *sc)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
u_int8_t buf[8];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
AM930_DELAY(5);
|
|
|
|
for (i=0; i<8; i++) {
|
|
|
|
buf[i] = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, i);
|
|
|
|
AM930_DELAY(5);
|
|
|
|
}
|
|
|
|
printf("am79c930: regdump:");
|
|
|
|
for (i=0; i<8; i++) {
|
|
|
|
printf(" %02x", buf[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-01-15 12:33:48 +03:00
|
|
|
void
|
|
|
|
am79c930_chip_init(struct am79c930_softc *sc, int how)
|
1999-11-04 20:10:53 +03:00
|
|
|
{
|
|
|
|
/* zero the bank select register, and leave it that way.. */
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_BSS, 0);
|
|
|
|
if (how)
|
|
|
|
sc->sc_ops = &memspace_ops;
|
|
|
|
else
|
|
|
|
sc->sc_ops = &iospace_ops;
|
|
|
|
}
|