PERFORCE change 105637 for review

Warner Losh imp at FreeBSD.org
Mon Sep 4 06:08:48 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=105637

Change 105637 by imp at imp_lighthouse on 2006/09/04 06:07:47

	implement GPIO_CFG, and expand it to allow for selective setting
	of configuration things as well as which bits to set.
	
	# This gives TSC all the control it needs from userland.

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/at91_pio.c#17 edit
.. //depot/projects/arm/src/sys/sys/gpio.h#3 edit

Differences ...

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

@@ -287,8 +287,21 @@
 	case GPIO_READ:	/* Get the status of input bits */
 		*(uint32_t *)data = RD4(sc, PIO_PDSR);
 		return (0);
+	case GPIO_CFG:	/* Configure GPIO pins */
+		if (sc->cfgmask & GPIO_CFG_INPUT) {
+			WR4(sc, PIO_OER, sc->iomask & ~sc->input);
+			WR4(sc, PIO_ODR, sc->iomask & sc->input);
+		}
+		if (sc->cfgmask & GPIO_CFG_HI_Z) {
+			WR4(sc, PIO_MDER, sc->iomask & ~sc->hi_z);
+			WR4(sc, PIO_MDDR, sc->iomask & sc->hi_z);
+		}
+		if (ac->cfgmask & GPIO_CFG_PULLUP) {
+			WR4(sc, PIO_PUER, sc->iomask & ~sc->pullup);
+			WR4(sc, PIO_PUDR, sc->iomask & sc->pullup);
+		}
+		return (0);
 	case GPIO_INFO:	/* Learn about this device's GPIO bits */
-	case GPIO_CFG:	/* Configure GPIO pins */
 		break;
 	}
 	return (ENOTTY);

==== //depot/projects/arm/src/sys/sys/gpio.h#3 (text+ko) ====

@@ -40,7 +40,11 @@
 
 struct gpio_cfg
 {
-	uint32_t	mask;		/* Mask of bits to change */
+	uint32_t	cfgmask; 	/* which things change */
+#define	GPIO_CFG_INPUT	1
+#define	GPIO_CFG_HI_Z	2
+#define	GPIO_CFG_PULLUP	4
+	uint32_t	iomask;		/* Mask of bits to change */
 	uint32_t	input;		/* or output */
 	uint32_t	hi_z;		/* Disable output */
 	uint32_t	pullup;		/* Enable pullup resistor */


More information about the p4-projects mailing list