Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jun 2006 22:06:25 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 99835 for review
Message-ID:  <200606222206.k5MM6PeF017119@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99835

Change 99835 by imp@imp_lighthouse on 2006/06/22 22:05:33

	Allow for GPIO configuration

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/at91_pio.c#11 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/at91/at91_pio.c#11 (text+ko) ====

@@ -38,7 +38,9 @@
 #include <sys/rman.h>
 #include <machine/bus.h>
 
+#include <arm/at91/at91rm92reg.h>
 #include <arm/at91/at91_pioreg.h>
+#include <arm/at91/at91_piovar.h>
 
 struct at91_pio_softc
 {
@@ -118,6 +120,9 @@
 	if (err)
 		goto out;
 
+	device_printf(dev, "ABSR: %#x OSR: %#x PSR:%#x ODSR: %#x\n",
+	    RD4(sc, PIO_ABSR), RD4(sc, PIO_OSR), RD4(sc, PIO_PSR),
+	    RD4(sc, PIO_ODSR));
 	AT91_PIO_LOCK_INIT(sc);
 
 	/*
@@ -250,6 +255,69 @@
 	return (ENXIO);
 }
 
+/*
+ * The following functions are called early in the boot process, so
+ * don't use bus_space, as that isn't yet available when we need to use
+ * them.
+ */
+void
+at91_pio_use_periph_a(uint32_t pio, uint32_t periph_a_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_ASR / 4] = periph_a_mask;
+	PIO[PIO_PDR / 4] = periph_a_mask;
+}
+
+void
+at91_pio_use_periph_b(uint32_t pio, uint32_t periph_b_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_BSR / 4] = periph_b_mask;
+	PIO[PIO_PDR / 4] = periph_b_mask;
+}
+
+void
+at91_pio_use_gpio(uint32_t pio, uint32_t gpio_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_PER / 4] = gpio_mask;
+}
+
+void
+at91_pio_gpio_input(uint32_t pio, uint32_t input_enable_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_ODR / 4] = input_enable_mask;
+}
+
+void
+at91_pio_gpio_output(uint32_t pio, uint32_t output_enable_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_OER / 4] = output_enable_mask;
+}
+
+void
+at91_pio_gpio_set(uint32_t pio, uint32_t data_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_SODR / 4] = data_mask;
+}
+
+void
+at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask)
+{
+	uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
+
+	PIO[PIO_CODR / 4] = data_mask;
+}
+
 static device_method_t at91_pio_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		at91_pio_probe),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606222206.k5MM6PeF017119>