Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/xscale Add routines for accessing the general p...
details: https://anonhg.NetBSD.org/src/rev/04661686130d
branches: trunk
changeset: 518374:04661686130d
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Nov 29 08:27:11 2001 +0000
description:
Add routines for accessing the general purpose I/O facility of
the i80312 Companion I/O chip.
diffstat:
sys/arch/arm/xscale/files.i80312 | 3 +-
sys/arch/arm/xscale/i80312.c | 14 +++++-
sys/arch/arm/xscale/i80312_gpio.c | 91 +++++++++++++++++++++++++++++++++++++++
sys/arch/arm/xscale/i80312var.h | 12 ++++-
4 files changed, 117 insertions(+), 3 deletions(-)
diffs (190 lines):
diff -r 45c55bff65b5 -r 04661686130d sys/arch/arm/xscale/files.i80312
--- a/sys/arch/arm/xscale/files.i80312 Thu Nov 29 08:26:18 2001 +0000
+++ b/sys/arch/arm/xscale/files.i80312 Thu Nov 29 08:27:11 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i80312,v 1.3 2001/11/09 23:15:53 thorpej Exp $
+# $NetBSD: files.i80312,v 1.4 2001/11/29 08:27:11 thorpej Exp $
#
# Configuration info for Intel i80312 Companion I/O support
#
@@ -8,6 +8,7 @@
device iopxs: pcibus
# Board-specific front-end provides attachment.
file arch/arm/xscale/i80312.c iopxs
+file arch/arm/xscale/i80312_gpio.c iopxs
file arch/arm/xscale/i80312_pci.c iopxs
file arch/arm/xscale/i80312_pci_dma.c iopxs
file arch/arm/xscale/i80312_space.c iopxs
diff -r 45c55bff65b5 -r 04661686130d sys/arch/arm/xscale/i80312.c
--- a/sys/arch/arm/xscale/i80312.c Thu Nov 29 08:26:18 2001 +0000
+++ b/sys/arch/arm/xscale/i80312.c Thu Nov 29 08:27:11 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i80312.c,v 1.4 2001/11/28 22:39:09 thorpej Exp $ */
+/* $NetBSD: i80312.c,v 1.5 2001/11/29 08:27:11 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -56,6 +56,13 @@
*/
struct bus_space i80312_bs_tag;
+/*
+ * There can be only one i80312, so we keep a global pointer to
+ * the softc, so board-specific code can use features of the
+ * i80312 without having to have a handle on the softc itself.
+ */
+struct i80312_softc *i80312_softc;
+
int i80312_pcibus_print(void *, const char *);
/*
@@ -84,6 +91,11 @@
panic("%s: unable to subregion ATU registers\n",
sc->sc_dev.dv_xname);
+ if (bus_space_subregion(sc->sc_st, sc->sc_sh, I80312_INTC_BASE,
+ I80312_INTC_SIZE, &sc->sc_intc_sh))
+ panic("%s: unable to subregion INTC registers\n",
+ sc->sc_dev.dv_xname);
+
/* We expect the Memory Controller to be already sliced off. */
/*
diff -r 45c55bff65b5 -r 04661686130d sys/arch/arm/xscale/i80312_gpio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/xscale/i80312_gpio.c Thu Nov 29 08:27:11 2001 +0000
@@ -0,0 +1,91 @@
+/* $NetBSD: i80312_gpio.c,v 1.1 2001/11/29 08:27:11 thorpej Exp $ */
+
+/*
+ * Copyright (c) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * 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 for the NetBSD Project by
+ * Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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.
+ */
+
+/*
+ * Intel i80312 Companion I/O general purpose I/O support.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/bus.h>
+
+#include <arm/xscale/i80312reg.h>
+#include <arm/xscale/i80312var.h>
+
+/*
+ * i80312_gpio_set_direction:
+ *
+ * Set the direction of the indicated GPIO pins (1 == output).
+ */
+void
+i80312_gpio_set_direction(uint8_t which, uint8_t val)
+{
+ struct i80312_softc *sc = i80312_softc;
+
+ sc->sc_gpio_dir = (sc->sc_gpio_dir & ~which) | val;
+ bus_space_write_1(sc->sc_st, sc->sc_intc_sh, I80312_INTC_GOE,
+ ~sc->sc_gpio_dir);
+}
+
+/*
+ * i80312_gpio_set_val:
+ *
+ * Set the value of the indicated GPIO pins.
+ */
+void
+i80312_gpio_set_val(uint8_t which, uint8_t val)
+{
+ struct i80312_softc *sc = i80312_softc;
+
+ sc->sc_gpio_val = (sc->sc_gpio_val & ~which) | val;
+ bus_space_write_1(sc->sc_st, sc->sc_intc_sh, I80312_INTC_GOD,
+ ~sc->sc_gpio_val);
+}
+
+/*
+ * i80312_gpio_get_val:
+ *
+ * Get the current state of the GPIO pins.
+ */
+uint8_t
+i80312_gpio_get_val(void)
+{
+ struct i80312_softc *sc = i80312_softc;
+
+ return (bus_space_read_1(sc->sc_st, sc->sc_intc_sh, I80312_INTC_GID));
+}
diff -r 45c55bff65b5 -r 04661686130d sys/arch/arm/xscale/i80312var.h
--- a/sys/arch/arm/xscale/i80312var.h Thu Nov 29 08:26:18 2001 +0000
+++ b/sys/arch/arm/xscale/i80312var.h Thu Nov 29 08:27:11 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i80312var.h,v 1.4 2001/11/09 23:15:53 thorpej Exp $ */
+/* $NetBSD: i80312var.h,v 1.5 2001/11/29 08:27:11 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -60,6 +60,7 @@
bus_space_handle_t sc_ppb_sh;
bus_space_handle_t sc_atu_sh;
bus_space_handle_t sc_mem_sh;
+ bus_space_handle_t sc_intc_sh;
/*
* Secondary IDSEL Select bits for providing a private
@@ -150,9 +151,14 @@
struct bus_space sc_pci_memt;
struct arm32_bus_dma_tag sc_pci_dmat;
struct arm32_pci_chipset sc_pci_chipset;
+
+ /* GPIO state */
+ uint8_t sc_gpio_dir; /* GPIO pin direction (1 == output) */
+ uint8_t sc_gpio_val; /* GPIO output pin value */
};
extern struct bus_space i80312_bs_tag;
+extern struct i80312_softc *i80312_softc;
void i80312_sdram_bounds(bus_space_tag_t, bus_space_handle_t,
paddr_t *, psize_t *);
@@ -163,6 +169,10 @@
void i80312_io_bs_init(bus_space_tag_t, void *);
void i80312_mem_bs_init(bus_space_tag_t, void *);
+void i80312_gpio_set_direction(uint8_t, uint8_t);
+void i80312_gpio_set_val(uint8_t, uint8_t);
+uint8_t i80312_gpio_get_val(void);
+
void i80312_pci_dma_init(bus_dma_tag_t, void *);
void i80312_pci_init(pci_chipset_tag_t, void *);
Home |
Main Index |
Thread Index |
Old Index