From owner-p4-projects@FreeBSD.ORG Mon Sep 4 06:08:48 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5A89816A4E0; Mon, 4 Sep 2006 06:08:48 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3042216A4DD for ; Mon, 4 Sep 2006 06:08:48 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C452B43D62 for ; Mon, 4 Sep 2006 06:08:46 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k8468kRi023348 for ; Mon, 4 Sep 2006 06:08:46 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k8468kaj023345 for perforce@freebsd.org; Mon, 4 Sep 2006 06:08:46 GMT (envelope-from imp@freebsd.org) Date: Mon, 4 Sep 2006 06:08:46 GMT Message-Id: <200609040608.k8468kaj023345@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 105637 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2006 06:08:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=105637 Change 105637 by imp@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 */