diff --git a/distrib/sets/lists/man/mi b/distrib/sets/lists/man/mi index f13fefaf07fb..b386cdef0e7d 100644 --- a/distrib/sets/lists/man/mi +++ b/distrib/sets/lists/man/mi @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1469 2014/04/15 22:09:27 ginsbach Exp $ +# $NetBSD: mi,v 1.1470 2014/04/22 18:51:35 kardel Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -901,6 +901,7 @@ ./usr/share/man/cat4/battery_pmu.0 man-sys-catman .cat ./usr/share/man/cat4/bba.0 man-sys-catman .cat ./usr/share/man/cat4/bce.0 man-sys-catman .cat +./usr/share/man/cat4/bcmgpio.0 man-sys-catman .cat ./usr/share/man/cat4/bcsp.0 man-sys-catman .cat ./usr/share/man/cat4/be.0 man-sys-catman .cat ./usr/share/man/cat4/bge.0 man-sys-catman .cat @@ -3941,6 +3942,7 @@ ./usr/share/man/html4/battery_pmu.html man-sys-htmlman html ./usr/share/man/html4/bba.html man-sys-htmlman html ./usr/share/man/html4/bce.html man-sys-htmlman html +./usr/share/man/html4/bcmgpio.html man-sys-htmlman html ./usr/share/man/html4/bcsp.html man-sys-htmlman html ./usr/share/man/html4/be.html man-sys-htmlman html ./usr/share/man/html4/bge.html man-sys-htmlman html @@ -6745,6 +6747,7 @@ ./usr/share/man/man4/battery_pmu.4 man-sys-man .man ./usr/share/man/man4/bba.4 man-sys-man .man ./usr/share/man/man4/bce.4 man-sys-man .man +./usr/share/man/man4/bcmgpio.4 man-sys-man .man ./usr/share/man/man4/bcsp.4 man-sys-man .man ./usr/share/man/man4/be.4 man-sys-man .man ./usr/share/man/man4/bge.4 man-sys-man .man diff --git a/doc/CHANGES b/doc/CHANGES index 126b383b8394..31b928effd5f 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1918 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1919 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -401,7 +401,7 @@ Changes from NetBSD 6.0 to NetBSD 7.0: ptyfs: Allow multiple mounts and support proper device visibility in chroots (Ilya Zykov) [christos 20140404] i386: Switched to GCC 4.8. [christos 20140404] - mcp23s17gpio: Add Microchip MCP23S17 16-bit GPIO chip driver. + mcp23s17gpio(4): Add Microchip MCP23S17 16-bit GPIO chip driver. e.g. Raspberry Pi interface boards [kardel 20140406] OpenSSL: Imported 1.0.1g [christos 20140407] sparc64: Switched to TOPDOWN_VM [martin 20140414] @@ -411,3 +411,5 @@ Changes from NetBSD 6.0 to NetBSD 7.0: hp300: Add HP9000/425e RTC support. [tsutsui 20140419] ubsec(4): Add support for AES-CBC modes and BCM586x chips. [bad 20140419] + bcmgpio(4): Add BCM2835 GPIO obio driver. + [kardel 20140422] diff --git a/share/man/man4/bcmgpio.4 b/share/man/man4/bcmgpio.4 new file mode 100644 index 000000000000..06e20cdab1a0 --- /dev/null +++ b/share/man/man4/bcmgpio.4 @@ -0,0 +1,63 @@ +.\" $NetBSD: bcmgpio.4,v 1.1 2014/04/22 18:51:35 kardel Exp $ +.\" +.\"Copyright (c) 2014 Frank Kardel +.\"All rights reserved. +.\" +.\"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. +.\" +.\"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS +.\"``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 THE FOUNDATION OR CONTRIBUTORS +.\"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. +.\" +.Dd April 21, 2014 +.Dt BCMGPIO 4 +.Os +.Sh NAME +.Nm bcmgpio +.Nd Driver for BCM2835 onboard gpio +.Sh SYNOPSIS +.Cd "bcmgpio0 at obio?" +.Cd "bcmgpio1 at obio?" +.Cd "gpio* at gpiobus?" +.Sh DESCRIPTION +The +.Nm +driver supports up to two instances. +Access to the pins is provided by the +.Xr gpio 4 +interface. +The +.Nm +.Ar unitnumber +argument selects the pin range. Unit 0 covers GPIO pins 0 through 31 and +unit 1 covers pins 32 through 53. GPIO pins being used in alternate configurations +are not available for GPIO operations. +.Sh SEE ALSO +.Xr gpio 4 , +.Xr intro 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Nx 7.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Frank Kardel Aq Mt kardel@NetBSD.org . diff --git a/sys/arch/arm/broadcom/bcm2835_gpio.c b/sys/arch/arm/broadcom/bcm2835_gpio.c new file mode 100644 index 000000000000..f472efdfecf3 --- /dev/null +++ b/sys/arch/arm/broadcom/bcm2835_gpio.c @@ -0,0 +1,265 @@ +/* $NetBSD: bcm2835_gpio.c,v 1.1 2014/04/22 18:51:35 kardel Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Frank Kardel. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.1 2014/04/22 18:51:35 kardel Exp $"); + +/* + * Driver for BCM2835 GPIO + * + * see: http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf + */ + +#include "gpio.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +/* #define BCM2835_GPIO_DEBUG */ +#ifdef BCM2835_GPIO_DEBUG +int bcm2835gpiodebug = 3; +#define DPRINTF(l, x) do { if (l <= bcm2835gpiodebug) { printf x; } } while (0) +#else +#define DPRINTF(l, x) +#endif + +struct bcmgpio_softc { + device_t sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + struct gpio_chipset_tag sc_gpio_gc; + gpio_pin_t sc_gpio_pins[32]; +}; + +static int bcmgpio_match(device_t, cfdata_t, void *); +static void bcmgpio_attach(device_t, device_t, void *); + +#if NGPIO > 0 +static int bcm2835gpio_gpio_pin_read(void *, int); +static void bcm2835gpio_gpio_pin_write(void *, int, int); +static void bcm2835gpio_gpio_pin_ctl(void *, int, int); +#endif + +CFATTACH_DECL_NEW(bcmgpio, sizeof(struct bcmgpio_softc), + bcmgpio_match, bcmgpio_attach, NULL, NULL); + +static int +bcmgpio_match(device_t parent, cfdata_t cf, void *aux) +{ + struct amba_attach_args * const aaa = aux; + + if (strcmp(aaa->aaa_name, "bcmgpio") != 0) + return 0; + + return 1; +} + +static void +bcmgpio_attach(device_t parent, device_t self, void *aux) +{ + struct bcmgpio_softc * const sc = device_private(self); +#if NGPIO > 0 + int pin, minpin, maxpin; + u_int func; + struct gpiobus_attach_args gba; +#endif + + sc->sc_dev = self; + + if (device_unit(sc->sc_dev) > 1) { + aprint_naive(" NO GPIO\n"); + aprint_normal(": NO GPIO\n"); + return; + } else if (device_unit(sc->sc_dev) == 1) { + maxpin = 53; + minpin = 32; + } else { + maxpin = 31; + minpin = 0; + } + + aprint_naive("\n"); + aprint_normal(": GPIO [%d...%d]\n", minpin, maxpin); + + /* already mapped - nothing to gain from struct amba_attach_args */ + sc->sc_iot = &bcm2835_bs_tag; + sc->sc_ioh = BCM2835_IOPHYSTOVIRT(BCM2835_GPIO_BASE); + +#if NGPIO > 0 + for (pin = minpin; pin <= maxpin; pin++) { + int epin = pin - minpin; + + sc->sc_gpio_pins[epin].pin_num = epin; + /* + * find out pins still available for GPIO + */ + func = bcm2835gpio_function_read(pin); + + if (func == BCM2835_GPIO_IN || + func == BCM2835_GPIO_OUT) { + sc->sc_gpio_pins[epin].pin_caps = GPIO_PIN_INPUT | + GPIO_PIN_OUTPUT | + GPIO_PIN_PUSHPULL | GPIO_PIN_TRISTATE | + GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN; + /* read initial state */ + sc->sc_gpio_pins[epin].pin_state = + bcm2835gpio_gpio_pin_read(sc, epin); + DPRINTF(1, ("%s: attach pin %d\n", device_xname(sc->sc_dev), pin)); + } else { + sc->sc_gpio_pins[epin].pin_caps = 0; + sc->sc_gpio_pins[epin].pin_state = 0; + DPRINTF(1, ("%s: skip pin %d - func = 0x%x\n", device_xname(sc->sc_dev), pin, func)); + } + } + + /* create controller tag */ + sc->sc_gpio_gc.gp_cookie = sc; + sc->sc_gpio_gc.gp_pin_read = bcm2835gpio_gpio_pin_read; + sc->sc_gpio_gc.gp_pin_write = bcm2835gpio_gpio_pin_write; + sc->sc_gpio_gc.gp_pin_ctl = bcm2835gpio_gpio_pin_ctl; + + gba.gba_gc = &sc->sc_gpio_gc; + gba.gba_pins = sc->sc_gpio_pins; + gba.gba_npins = maxpin - minpin + 1; + + config_found_ia(self, "gpiobus", &gba, gpiobus_print); +#else + aprint_normal_dev(sc->sc_dev, "no GPIO configured in kernel"); +#endif +} + +#if NGPIO > 0 +/* GPIO support functions */ +static int +bcm2835gpio_gpio_pin_read(void *arg, int pin) +{ + struct bcmgpio_softc *sc = arg; + int epin = pin + device_unit(sc->sc_dev) * 32; + uint32_t val; + int res; + + if (device_unit(sc->sc_dev) > 1) { + return 0; + } + + val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, + BCM2835_GPIO_GPLEV(epin / BCM2835_GPIO_GPLEV_PINS_PER_REGISTER)); + + res = val & (1 << (epin % BCM2835_GPIO_GPLEV_PINS_PER_REGISTER)) ? + GPIO_PIN_HIGH : GPIO_PIN_LOW; + + DPRINTF(2, ("%s: gpio_read pin %d->%d\n", device_xname(sc->sc_dev), epin, (res == GPIO_PIN_HIGH))); + + return res; +} + +static void +bcm2835gpio_gpio_pin_write(void *arg, int pin, int value) +{ + struct bcmgpio_softc *sc = arg; + int epin = pin + device_unit(sc->sc_dev) * 32; + bus_size_t reg; + + if (device_unit(sc->sc_dev) > 1) { + return; + } + + if (value == GPIO_PIN_HIGH) { + reg = BCM2835_GPIO_GPSET(epin / BCM2835_GPIO_GPSET_PINS_PER_REGISTER); + } else { + reg = BCM2835_GPIO_GPCLR(epin / BCM2835_GPIO_GPCLR_PINS_PER_REGISTER); + } + + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + reg, 1 << (epin % BCM2835_GPIO_GPSET_PINS_PER_REGISTER)); + DPRINTF(2, ("%s: gpio_write pin %d<-%d\n", device_xname(sc->sc_dev), epin, (value == GPIO_PIN_HIGH))); +} + +static void +bcm2835gpio_gpio_pin_ctl(void *arg, int pin, int flags) +{ + struct bcmgpio_softc *sc = arg; + uint32_t cmd; + int epin = pin + device_unit(sc->sc_dev) * 32; + + if (device_unit(sc->sc_dev) > 1) { + return; + } + + DPRINTF(2, ("%s: gpio_ctl pin %d flags 0x%x\n", device_xname(sc->sc_dev), epin, flags)); + + if (flags & (GPIO_PIN_OUTPUT|GPIO_PIN_INPUT)) { + if ((flags & GPIO_PIN_INPUT) || !(flags & GPIO_PIN_OUTPUT)) { + /* for safety INPUT will overide output */ + bcm2835gpio_function_select(epin, BCM2835_GPIO_IN); + } else { + bcm2835gpio_function_select(epin, BCM2835_GPIO_OUT); + } + } + + if (flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) { + cmd = (flags & GPIO_PIN_PULLUP) ? + BCM2835_GPIO_GPPUD_PULLUP : BCM2835_GPIO_GPPUD_PULLDOWN; + } else { + cmd = BCM2835_GPIO_GPPUD_PULLOFF; + } + + /* set up control signal */ + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + BCM2835_GPIO_GPPUD, cmd); + delay(1); /* wait 150 cycles */ + /* set clock signal */ + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + BCM2835_GPIO_GPPUDCLK(device_unit(sc->sc_dev)), + 1 << (epin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER)); + delay(1); /* wait 150 cycles */ + /* reset control signal and clock */ + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + BCM2835_GPIO_GPPUD, BCM2835_GPIO_GPPUD_PULLOFF); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + BCM2835_GPIO_GPPUDCLK(device_unit(sc->sc_dev)), + 0); +} +#endif /* NGPIO > 0 */ diff --git a/sys/arch/arm/broadcom/bcm2835_gpio_subr.c b/sys/arch/arm/broadcom/bcm2835_gpio_subr.c index 591e346688c7..5493dcd9c7c3 100644 --- a/sys/arch/arm/broadcom/bcm2835_gpio_subr.c +++ b/sys/arch/arm/broadcom/bcm2835_gpio_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_gpio_subr.c,v 1.2 2013/01/09 01:58:41 jmcneill Exp $ */ +/* $NetBSD: bcm2835_gpio_subr.c,v 1.3 2014/04/22 18:51:35 kardel Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio_subr.c,v 1.2 2013/01/09 01:58:41 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio_subr.c,v 1.3 2014/04/22 18:51:35 kardel Exp $"); #include #include @@ -51,7 +51,6 @@ bcm2835gpio_function_select(u_int pin, u_int func) BCM2835_GPIO_GPFSEL_BITS_PER_PIN; uint32_t v; - KASSERT(func <= mask); v = bus_space_read_4(iot, ioh, BCM2835_GPIO_GPFSEL(regid)); @@ -67,3 +66,19 @@ bcm2835gpio_function_select(u_int pin, u_int func) bus_space_write_4(iot, ioh, BCM2835_GPIO_GPFSEL(regid), v); } + +u_int +bcm2835gpio_function_read(u_int pin) +{ + const bus_space_tag_t iot = &bcm2835_bs_tag; + const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(BCM2835_GPIO_BASE); + const u_int mask = (1 << BCM2835_GPIO_GPFSEL_BITS_PER_PIN) - 1; + const u_int regid = (pin / BCM2835_GPIO_GPFSEL_PINS_PER_REGISTER); + const u_int shift = (pin % BCM2835_GPIO_GPFSEL_PINS_PER_REGISTER) * + BCM2835_GPIO_GPFSEL_BITS_PER_PIN; + uint32_t v; + + v = bus_space_read_4(iot, ioh, BCM2835_GPIO_GPFSEL(regid)); + + return ((v >> shift) & mask); +} diff --git a/sys/arch/arm/broadcom/bcm2835_gpio_subr.h b/sys/arch/arm/broadcom/bcm2835_gpio_subr.h index 6fe54e086f9d..f0d9c2d245ec 100644 --- a/sys/arch/arm/broadcom/bcm2835_gpio_subr.h +++ b/sys/arch/arm/broadcom/bcm2835_gpio_subr.h @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_gpio_subr.h,v 1.1 2013/01/05 19:55:18 jakllsch Exp $ */ +/* $NetBSD: bcm2835_gpio_subr.h,v 1.2 2014/04/22 18:51:35 kardel Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -31,6 +31,7 @@ #include -void bcm2835gpio_function_select(u_int, u_int); +void bcm2835gpio_function_select(u_int, u_int); +u_int bcm2835gpio_function_read(u_int); #endif /* _BROADCOM_BCM2835_GPIOVAR_H_ */ diff --git a/sys/arch/arm/broadcom/bcm2835_gpioreg.h b/sys/arch/arm/broadcom/bcm2835_gpioreg.h index 81d073d0ea36..fc51143ebced 100644 --- a/sys/arch/arm/broadcom/bcm2835_gpioreg.h +++ b/sys/arch/arm/broadcom/bcm2835_gpioreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_gpioreg.h,v 1.2 2013/04/14 15:11:52 skrll Exp $ */ +/* $NetBSD: bcm2835_gpioreg.h,v 1.3 2014/04/22 18:51:35 kardel Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -33,6 +33,26 @@ #define BCM2835_GPIO_GPFSEL_PINS_PER_REGISTER 10 #define BCM2835_GPIO_GPFSEL_BITS_PER_PIN 3 +#define BCM2835_GPIO_GPSET(x) (0x01C + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPSET_PINS_PER_REGISTER 32 +#define BCM2835_GPIO_GPCLR(x) (0x028 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPCLR_PINS_PER_REGISTER BCM2835_GPIO_GPSET_PINS_PER_REGISTER +#define BCM2835_GPIO_GPLEV(x) (0x034 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPLEV_PINS_PER_REGISTER 32 +#define BCM2835_GPIO_GPEDS(x) (0x040 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPREN(x) (0x04C + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPFEN(x) (0x058 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPHEN(x) (0x064 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPLEN(x) (0x070 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPAREN(x) (0x07C + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPAFEN(x) (0x088 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPPUD (0x094) +#define BCM2835_GPIO_GPPUD_PULLOFF 0x0 +#define BCM2835_GPIO_GPPUD_PULLDOWN 0x1 +#define BCM2835_GPIO_GPPUD_PULLUP 0x2 +#define BCM2835_GPIO_GPPUDCLK(x) (0x098 + (x) * sizeof(uint32_t)) +#define BCM2835_GPIO_GPPUD_PINS_PER_REGISTER 32 + #define BCM2835_GPIO_IN 00 #define BCM2835_GPIO_OUT 01 #define BCM2835_GPIO_ALT5 02 diff --git a/sys/arch/arm/broadcom/bcm2835_obio.c b/sys/arch/arm/broadcom/bcm2835_obio.c index 0179b9e2e994..7d37ff15d36d 100644 --- a/sys/arch/arm/broadcom/bcm2835_obio.c +++ b/sys/arch/arm/broadcom/bcm2835_obio.c @@ -1,7 +1,7 @@ -/* $NetBSD: bcm2835_obio.c,v 1.19 2013/10/15 09:07:48 skrll Exp $ */ +/* $NetBSD: bcm2835_obio.c,v 1.20 2014/04/22 18:51:35 kardel Exp $ */ /*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. + * Copyright (c) 2012, 2014 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcm2835_obio.c,v 1.19 2013/10/15 09:07:48 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_obio.c,v 1.20 2014/04/22 18:51:35 kardel Exp $"); #include "locators.h" #include "obio.h" @@ -157,6 +157,20 @@ static const struct ambadev_locators bcm2835_ambadev_locs[] = { .ad_size = BCM2835_BSC_SIZE, .ad_intr = BCM2835_INT_BSC, }, + { + /* gpio */ + .ad_name = "bcmgpio", + .ad_addr = BCM2835_GPIO_BASE, + .ad_size = BCM2835_GPIO_SIZE, + .ad_intr = -1, + }, + { + /* gpio */ + .ad_name = "bcmgpio", + .ad_addr = BCM2835_GPIO_BASE, + .ad_size = BCM2835_GPIO_SIZE, + .ad_intr = -1, + }, { /* Terminator */ .ad_name = NULL, diff --git a/sys/arch/arm/broadcom/files.bcm2835 b/sys/arch/arm/broadcom/files.bcm2835 index 7d330ad49b99..a8dc09fd9436 100644 --- a/sys/arch/arm/broadcom/files.bcm2835 +++ b/sys/arch/arm/broadcom/files.bcm2835 @@ -1,4 +1,4 @@ -# $NetBSD: files.bcm2835,v 1.20 2013/11/01 12:23:12 skrll Exp $ +# $NetBSD: files.bcm2835,v 1.21 2014/04/22 18:51:35 kardel Exp $ # # Configuration info for Broadcom BCM2835 ARM Peripherals # @@ -83,3 +83,8 @@ include "external/bsd/vchiq/conf/files.vchiq" device vcaudio: audiobus, auconv, mulaw, aurateconv attach vcaudio at vchiqbus file arch/arm/broadcom/bcm2835_vcaudio.c vcaudio + +# GPIO +device bcmgpio: gpiobus +attach bcmgpio at obio +file arch/arm/broadcom/bcm2835_gpio.c diff --git a/sys/arch/evbarm/conf/RPI b/sys/arch/evbarm/conf/RPI index 25c1f788097d..9015fc6e4314 100644 --- a/sys/arch/evbarm/conf/RPI +++ b/sys/arch/evbarm/conf/RPI @@ -1,5 +1,5 @@ # -# $NetBSD: RPI,v 1.43 2014/04/06 17:59:39 kardel Exp $ +# $NetBSD: RPI,v 1.44 2014/04/22 18:51:35 kardel Exp $ # # RPi -- Raspberry Pi # @@ -202,6 +202,10 @@ bcmpm0 at obio? # Random number generator bcmrng0 at obio? +# GPIO +bcmgpio0 at obio? # pins 0 ... 31 +bcmgpio1 at obio? # pins 32 ... 53 + # Arasan SD/MMC Interface sdhc* at obio? sdmmc* at sdhc? @@ -231,8 +235,8 @@ spi* at spibus? #mcp23s17gpio2 at spi? slave 0 flags 2 #mcp23s17gpio3 at spi? slave 0 flags 3 -# gpio support (e. g. mcp23s17gpio) -#gpio* at gpiobus? +# gpio support (e. g. mcp23s17gpio, bcmgpio) +gpio* at gpiobus? # various options for wscons - we try to look as much like a standard # sun console as possible