From owner-p4-projects@FreeBSD.ORG Fri Jun 23 03:02:01 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 3289216A4C2; Fri, 23 Jun 2006 03:02:01 +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 0DF6916A4A5 for ; Fri, 23 Jun 2006 03:02:01 +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 1DE05458A4 for ; Thu, 22 Jun 2006 22:06:26 +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 k5MM6PV7017122 for ; Thu, 22 Jun 2006 22:06:25 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5MM6PeF017119 for perforce@freebsd.org; Thu, 22 Jun 2006 22:06:25 GMT (envelope-from imp@freebsd.org) Date: Thu, 22 Jun 2006 22:06:25 GMT Message-Id: <200606222206.k5MM6PeF017119@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 99835 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: Fri, 23 Jun 2006 03:02:01 -0000 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 #include +#include #include +#include 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),