Index: sys/arm/broadcom/bcm2835/bcm2835_bsc.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_bsc.c +++ sys/arm/broadcom/bcm2835/bcm2835_bsc.c @@ -100,7 +100,6 @@ #include #include -#include #include #include @@ -298,9 +297,7 @@ bcm_bsc_attach(device_t dev) { struct bcm_bsc_softc *sc; - unsigned long start; - device_t gpio; - int i, rid; + int rid; sc = device_get_softc(dev); sc->sc_dev = dev; @@ -315,31 +312,6 @@ sc->sc_bst = rman_get_bustag(sc->sc_mem_res); sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res); - - /* Check the unit we are attaching by its base address. */ - start = rman_get_start(sc->sc_mem_res); - for (i = 0; i < nitems(bcm_bsc_pins); i++) { - if (bcm_bsc_pins[i].start == (start & BCM_BSC_BASE_MASK)) - break; - } - if (i == nitems(bcm_bsc_pins)) { - device_printf(dev, "only bsc0 and bsc1 are supported\n"); - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); - return (ENXIO); - } - - /* - * Configure the GPIO pins to ALT0 function to enable BSC control - * over the pins. - */ - gpio = devclass_get_device(devclass_find("gpio"), 0); - if (!gpio) { - device_printf(dev, "cannot find gpio0\n"); - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); - return (ENXIO); - } - bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].sda, BCM_GPIO_ALT0); - bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].scl, BCM_GPIO_ALT0); rid = 0; sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, Index: sys/arm/broadcom/bcm2835/bcm2835_bscvar.h =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_bscvar.h +++ sys/arm/broadcom/bcm2835/bcm2835_bscvar.h @@ -32,16 +32,6 @@ #ifndef _BCM2835_BSCVAR_H #define _BCM2835_BSCVAR_H -struct { - uint32_t sda; - uint32_t scl; - unsigned long start; -} bcm_bsc_pins[] = { - { 0, 1, 0x205000 }, /* BSC0 GPIO pins and base address. */ - { 2, 3, 0x804000 } /* BSC1 GPIO pins and base address. */ -}; -#define BCM_BSC_BASE_MASK 0x00ffffff - struct iic_msg; struct bcm_bsc_softc { Index: sys/arm/broadcom/bcm2835/bcm2835_gpio.h =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_gpio.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2013 Oleksandr Tymoshenko - * - * 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _BCM2835_GPIO_H_ -#define _BCM2835_GPIO_H_ - -enum bcm_gpio_fsel { - BCM_GPIO_INPUT, - BCM_GPIO_OUTPUT, - BCM_GPIO_ALT5, - BCM_GPIO_ALT4, - BCM_GPIO_ALT0, - BCM_GPIO_ALT1, - BCM_GPIO_ALT2, - BCM_GPIO_ALT3, -}; - -void bcm_gpio_set_alternate(device_t, uint32_t, uint32_t); - -#endif /* _BCM2835_GPIO_H_ */ Index: sys/arm/broadcom/bcm2835/bcm2835_gpio.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_gpio.c +++ sys/arm/broadcom/bcm2835/bcm2835_gpio.c @@ -48,11 +48,10 @@ #include #include +#include #include #include -#include - #include "gpio_if.h" #include "pic_if.h" @@ -73,6 +72,19 @@ GPIO_INTR_LEVEL_HIGH | GPIO_INTR_EDGE_RISING | \ GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH) +#define BCM2835_FSEL_GPIO_IN 0 +#define BCM2835_FSEL_GPIO_OUT 1 +#define BCM2835_FSEL_ALT5 2 +#define BCM2835_FSEL_ALT4 3 +#define BCM2835_FSEL_ALT0 4 +#define BCM2835_FSEL_ALT1 5 +#define BCM2835_FSEL_ALT2 6 +#define BCM2835_FSEL_ALT3 7 + +#define BCM2835_PUD_OFF 0 +#define BCM2835_PUD_DOWN 1 +#define BCM2835_PUD_UP 2 + static struct resource_spec bcm_gpio_res_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, { SYS_RES_IRQ, 0, RF_ACTIVE }, /* bank 0 interrupt */ @@ -187,28 +199,28 @@ { switch (nfunc) { - case BCM_GPIO_INPUT: + case BCM2835_FSEL_GPIO_IN: strncpy(buf, "input", bufsize); break; - case BCM_GPIO_OUTPUT: + case BCM2835_FSEL_GPIO_OUT: strncpy(buf, "output", bufsize); break; - case BCM_GPIO_ALT0: + case BCM2835_FSEL_ALT0: strncpy(buf, "alt0", bufsize); break; - case BCM_GPIO_ALT1: + case BCM2835_FSEL_ALT1: strncpy(buf, "alt1", bufsize); break; - case BCM_GPIO_ALT2: + case BCM2835_FSEL_ALT2: strncpy(buf, "alt2", bufsize); break; - case BCM_GPIO_ALT3: + case BCM2835_FSEL_ALT3: strncpy(buf, "alt3", bufsize); break; - case BCM_GPIO_ALT4: + case BCM2835_FSEL_ALT4: strncpy(buf, "alt4", bufsize); break; - case BCM_GPIO_ALT5: + case BCM2835_FSEL_ALT5: strncpy(buf, "alt5", bufsize); break; default: @@ -221,21 +233,21 @@ { if (strcasecmp(func, "input") == 0) - *nfunc = BCM_GPIO_INPUT; + *nfunc = BCM2835_FSEL_GPIO_IN; else if (strcasecmp(func, "output") == 0) - *nfunc = BCM_GPIO_OUTPUT; + *nfunc = BCM2835_FSEL_GPIO_OUT; else if (strcasecmp(func, "alt0") == 0) - *nfunc = BCM_GPIO_ALT0; + *nfunc = BCM2835_FSEL_ALT0; else if (strcasecmp(func, "alt1") == 0) - *nfunc = BCM_GPIO_ALT1; + *nfunc = BCM2835_FSEL_ALT1; else if (strcasecmp(func, "alt2") == 0) - *nfunc = BCM_GPIO_ALT2; + *nfunc = BCM2835_FSEL_ALT2; else if (strcasecmp(func, "alt3") == 0) - *nfunc = BCM_GPIO_ALT3; + *nfunc = BCM2835_FSEL_ALT3; else if (strcasecmp(func, "alt4") == 0) - *nfunc = BCM_GPIO_ALT4; + *nfunc = BCM2835_FSEL_ALT4; else if (strcasecmp(func, "alt5") == 0) - *nfunc = BCM_GPIO_ALT5; + *nfunc = BCM2835_FSEL_ALT5; else return (-1); @@ -247,9 +259,9 @@ { switch (nfunc) { - case BCM_GPIO_INPUT: + case BCM2835_FSEL_GPIO_IN: return (GPIO_PIN_INPUT); - case BCM_GPIO_OUTPUT: + case BCM2835_FSEL_GPIO_OUT: return (GPIO_PIN_OUTPUT); } return (0); @@ -288,7 +300,7 @@ BCM_GPIO_WRITE(sc, BCM_GPIO_GPPUDCLK(bank), 0); } -void +static void bcm_gpio_set_alternate(device_t dev, uint32_t pin, uint32_t nfunc) { struct bcm_gpio_softc *sc; @@ -329,11 +341,11 @@ if (flags & GPIO_PIN_OUTPUT) { pin->gp_flags |= GPIO_PIN_OUTPUT; bcm_gpio_set_function(sc, pin->gp_pin, - BCM_GPIO_OUTPUT); + BCM2835_FSEL_GPIO_OUT); } else { pin->gp_flags |= GPIO_PIN_INPUT; bcm_gpio_set_function(sc, pin->gp_pin, - BCM_GPIO_INPUT); + BCM2835_FSEL_GPIO_IN); } } @@ -793,6 +805,9 @@ if (sc->sc_busdev == NULL) goto fail; + fdt_pinctrl_register(dev, "brcm,pins"); + fdt_pinctrl_configure_tree(dev); + return (0); fail: @@ -1187,6 +1202,83 @@ return (ofw_bus_get_node(bus)); } +static int +bcm_gpio_configure_pins(device_t dev, phandle_t cfgxref) +{ + phandle_t cfgnode; + int i, pintuples, pulltuples; + uint32_t pin; + uint32_t *pins; + uint32_t *pulls; + uint32_t function; + static struct bcm_gpio_softc *sc; + + sc = device_get_softc(dev); + cfgnode = OF_node_from_xref(cfgxref); + + pins = NULL; + pintuples = OF_getencprop_alloc(cfgnode, "brcm,pins", sizeof(*pins), + (void **)&pins); + + char name[32]; + OF_getprop(cfgnode, "name", &name, sizeof(name)); + + if (pintuples < 0) + return (ENOENT); + + if (pintuples == 0) + return (0); /* Empty property is not an error. */ + + if (OF_getencprop(cfgnode, "brcm,function", &function, + sizeof(function)) <= 0) + return (EINVAL); + + + pulls = NULL; + pulltuples = OF_getencprop_alloc(cfgnode, "brcm,pull", sizeof(*pulls), + (void **)&pulls); + + if ((pulls != NULL) && (pulltuples != pintuples)) { + OF_prop_free(pins); + OF_prop_free(pulls); + return (EINVAL); + } + + for (i = 0; i < pintuples; i++) { + pin = pins[i]; + bcm_gpio_set_alternate(dev, pin, function); + if (bootverbose) + device_printf(dev, "set pin %d to func %d", pin, function); + if (pulls) { + if (bootverbose) + printf(", pull %d", pulls[i]); + switch (pulls[i]) { + /* Convert to gpio(4) flags */ + case BCM2835_PUD_OFF: + bcm_gpio_pin_setflags(dev, pin, 0); + break; + case BCM2835_PUD_UP: + bcm_gpio_pin_setflags(dev, pin, GPIO_PIN_PULLUP); + break; + case BCM2835_PUD_DOWN: + bcm_gpio_pin_setflags(dev, pin, GPIO_PIN_PULLDOWN); + break; + default: + printf("%s: invalid pull value for pin %d: %d\n", + name, pin, pulls[i]); + } + } + if (bootverbose) + printf("\n"); + } + + OF_prop_free(pins); + if (pulls) + OF_prop_free(pulls); + + return (0); +} + static device_method_t bcm_gpio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bcm_gpio_probe), @@ -1217,6 +1309,9 @@ /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_node, bcm_gpio_get_node), + /* fdt_pinctrl interface */ + DEVMETHOD(fdt_pinctrl_configure, bcm_gpio_configure_pins), + DEVMETHOD_END }; @@ -1228,4 +1323,4 @@ sizeof(struct bcm_gpio_softc), }; -DRIVER_MODULE(bcm_gpio, simplebus, bcm_gpio_driver, bcm_gpio_devclass, 0, 0); +EARLY_DRIVER_MODULE(bcm_gpio, simplebus, bcm_gpio_driver, bcm_gpio_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); Index: sys/arm/broadcom/bcm2835/bcm2835_intr.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_intr.c +++ sys/arm/broadcom/bcm2835/bcm2835_intr.c @@ -445,4 +445,4 @@ static devclass_t bcm_intc_devclass; EARLY_DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, - 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); + 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); Index: sys/arm/broadcom/bcm2835/bcm2835_pwm.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_pwm.c +++ sys/arm/broadcom/bcm2835/bcm2835_pwm.c @@ -46,7 +46,6 @@ #include #include -#include #include static struct ofw_compat_data compat_data[] = { @@ -93,7 +92,6 @@ bcm_pwm_reconf(struct bcm_pwm_softc *sc) { uint32_t u; - device_t gpio; /* Disable PWM */ W_CTL(sc, 0); @@ -103,14 +101,6 @@ if (sc->mode == 0) return (0); - - /* Ask GPIO0 to set ALT0 for pin 12 */ - gpio = devclass_get_device(devclass_find("gpio"), 0); - if (!gpio) { - device_printf(sc->sc_dev, "cannot find gpio0\n"); - return (ENXIO); - } - bcm_gpio_set_alternate(gpio, 12, BCM_GPIO_ALT0); u = bcm2835_clkman_set_frequency(sc->clkman, BCM_PWM_CLKSRC, sc->freq); if (u == 0) Index: sys/arm/broadcom/bcm2835/bcm2835_spi.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_spi.c +++ sys/arm/broadcom/bcm2835/bcm2835_spi.c @@ -51,7 +51,6 @@ #include #include -#include #include #include @@ -250,8 +249,7 @@ bcm_spi_attach(device_t dev) { struct bcm_spi_softc *sc; - device_t gpio; - int i, rid; + int rid; if (device_get_unit(dev) != 0) { device_printf(dev, "only one SPI controller supported\n"); @@ -260,15 +258,6 @@ sc = device_get_softc(dev); sc->sc_dev = dev; - - /* Configure the GPIO pins to ALT0 function to enable SPI the pins. */ - gpio = devclass_get_device(devclass_find("gpio"), 0); - if (!gpio) { - device_printf(dev, "cannot find gpio0\n"); - return (ENXIO); - } - for (i = 0; i < nitems(bcm_spi_pins); i++) - bcm_gpio_set_alternate(gpio, bcm_spi_pins[i], BCM_GPIO_ALT0); rid = 0; sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, Index: sys/arm/broadcom/bcm2835/bcm2835_spivar.h =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_spivar.h +++ sys/arm/broadcom/bcm2835/bcm2835_spivar.h @@ -32,18 +32,6 @@ #ifndef _BCM2835_SPIVAR_H_ #define _BCM2835_SPIVAR_H_ -/* - * Only the available pins are listed here. - * i.e. CS2 isn't available. - */ -uint32_t bcm_spi_pins[] = { - 7, /* CS1 */ - 8, /* CS0 */ - 9, /* MISO */ - 10, /* MOSI */ - 11 /* SCLK */ -}; - struct bcm_spi_softc { device_t sc_dev; struct mtx sc_mtx; Index: sys/arm/broadcom/bcm2835/bcm2836.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2836.c +++ sys/arm/broadcom/bcm2835/bcm2836.c @@ -736,4 +736,4 @@ static devclass_t bcm_lintc_devclass; EARLY_DRIVER_MODULE(local_intc, simplebus, bcm_lintc_driver, bcm_lintc_devclass, - 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); + 0, 0, BUS_PASS_INTERRUPT); Index: sys/arm/broadcom/bcm2835/std.rpi =================================================================== --- sys/arm/broadcom/bcm2835/std.rpi +++ sys/arm/broadcom/bcm2835/std.rpi @@ -1,3 +1,4 @@ # $FreeBSD$ options LINUX_BOOT_ABI +device fdt_pinctrl Index: sys/dts/arm/bcm2835.dtsi =================================================================== --- sys/dts/arm/bcm2835.dtsi +++ sys/dts/arm/bcm2835.dtsi @@ -155,240 +155,26 @@ broadcom,read-only = <46>, <47>, <48>, <49>, <50>, <51>, <52>, <53>; - /* BSC0 */ - pins_bsc0_a: bsc0_a { - broadcom,pins = <0>, <1>; + spi0_pins: spi0_pins { + brcm,pins = <9 10 11>; + brcm,function = <4>; /* alt0 */ }; - - pins_bsc0_b: bsc0_b { - broadcom,pins = <28>, <29>; + + spi0_cs_pins: spi0_cs_pins { + brcm,pins = <8 7>; + brcm,function = <1>; /* output */ }; - - pins_bsc0_c: bsc0_c { - broadcom,pins = <44>, <45>; + + bsc0_pins: bsc0 { + brcm,pins = <0 1>; + brcm,function = <4>; }; - - /* BSC1 */ - pins_bsc1_a: bsc1_a { - broadcom,pins = <2>, <3>; + + bsc1_pins: bsc1 { + brcm,pins = <2 3>; + brcm,function = <4>; }; - pins_bsc1_b: bsc1_b { - broadcom,pins = <44>, <45>; - }; - - /* GPCLK0 */ - pins_gpclk0_a: gpclk0_a { - broadcom,pins = <4>; - }; - - pins_gpclk0_b: gpclk0_b { - broadcom,pins = <20>; - }; - - pins_gpclk0_c: gpclk0_c { - broadcom,pins = <32>; - }; - - pins_gpclk0_d: gpclk0_d { - broadcom,pins = <34>; - }; - - /* GPCLK1 */ - pins_gpclk1_a: gpclk1_a { - broadcom,pins = <5>; - }; - - pins_gpclk1_b: gpclk1_b { - broadcom,pins = <21>; - }; - - pins_gpclk1_c: gpclk1_c { - broadcom,pins = <42>; - }; - - pins_gpclk1_d: gpclk1_d { - broadcom,pins = <44>; - }; - - /* GPCLK2 */ - pins_gpclk2_a: gpclk2_a { - broadcom,pins = <6>; - }; - - pins_gpclk2_b: gpclk2_b { - broadcom,pins = <43>; - }; - - /* SPI0 */ - pins_spi0_a: spi0_a { - broadcom,pins = <7>, <8>, <9>, <10>, <11>; - }; - - pins_spi0_b: spi0_b { - broadcom,pins = <35>, <36>, <37>, <38>, <39>; - }; - - /* PWM */ - pins_pwm0_a: pwm0_a { - broadcom,pins = <12>; - }; - - pins_pwm0_b: pwm0_b { - broadcom,pins = <18>; - }; - - pins_pwm0_c: pwm0_c { - broadcom,pins = <40>; - }; - - pins_pwm1_a: pwm1_a { - broadcom,pins = <13>; - }; - - pins_pwm1_b: pwm1_b { - broadcom,pins = <19>; - }; - - pins_pwm1_c: pwm1_c { - broadcom,pins = <41>; - }; - - pins_pwm1_d: pwm1_d { - broadcom,pins = <45>; - }; - - /* UART0 */ - pins_uart0_a: uart0_a { - broadcom,pins = <14>, <15>; - }; - - pins_uart0_b: uart0_b { - broadcom,pins = <32>, <33>; - }; - - pins_uart0_c: uart0_c { - broadcom,pins = <36>, <37>; - }; - - pins_uart0_fc_a: uart0_fc_a { - broadcom,pins = <16>, <17>; - }; - - pins_uart0_fc_b: uart0_fc_b { - broadcom,pins = <30>, <31>; - }; - - pins_uart0_fc_c: uart0_fc_c { - broadcom,pins = <39>, <38>; - }; - - /* PCM */ - pins_pcm_a: pcm_a { - broadcom,pins = <18>, <19>, <20>, <21>; - }; - - pins_pcm_b: pcm_b { - broadcom,pins = <28>, <29>, <30>, <31>; - }; - - /* Secondary Address Bus */ - pins_sm_addr_a: sm_addr_a { - broadcom,pins = <5>, <4>, <3>, <2>, <1>, <0>; - }; - - pins_sm_addr_b: sm_addr_b { - broadcom,pins = <33>, <32>, <31>, <30>, <29>, - <28>; - }; - - pins_sm_ctl_a: sm_ctl_a { - broadcom,pins = <6>, <7>; - }; - - pins_sm_ctl_b: sm_ctl_b { - broadcom,pins = <34>, <35>; - }; - - pins_sm_data_8bit_a: sm_data_8bit_a { - broadcom,pins = <8>, <9>, <10>, <11>, <12>, - <13>, <14>, <15>; - }; - - pins_sm_data_8bit_b: sm_data_8bit_b { - broadcom,pins = <36>, <37>, <38>, <39>, <40>, - <41>, <42>, <43>; - }; - - pins_sm_data_16bit: sm_data_16bit { - broadcom,pins = <16>, <17>, <18>, <19>, <20>, - <21>, <22>, <23>; - }; - - pins_sm_data_18bit: sm_data_18bit { - broadcom,pins = <24>, <25>; - }; - - /* BSCSL */ - pins_bscsl: bscsl { - broadcom,pins = <18>, <19>; - }; - - /* SPISL */ - pins_spisl: spisl { - broadcom,pins = <18>, <19>, <20>, <21>; - }; - - /* SPI1 */ - pins_spi1: spi1 { - broadcom,pins = <16>, <17>, <18>, <19>, <20>, - <21>; - }; - - /* UART1 */ - pins_uart1_a: uart1_a { - broadcom,pins = <14>, <15>; - }; - - pins_uart1_b: uart1_b { - broadcom,pins = <32>, <33>; - }; - - pins_uart1_c: uart1_c { - broadcom,pins = <40>, <41>; - }; - - pins_uart1_fc_a: uart1_fc_a { - broadcom,pins = <16>, <17>; - }; - - pins_uart1_fc_b: uart1_fc_b { - broadcom,pins = <30>, <31>; - }; - - pins_uart1_fc_c: uart1_fc_c { - broadcom,pins = <43>, <42>; - }; - - /* SPI2 */ - pins_spi2: spi2 { - broadcom,pins = <40>, <41>, <42>, <43>, <44>, - <45>; - }; - - /* ARM JTAG */ - pins_arm_jtag_trst: arm_jtag_trst { - broadcom,pins = <22>; - }; - - pins_arm_jtag_a: arm_jtag_a { - broadcom,pins = <4>, <5>, <6>, <12>, <13>; - }; - - pins_arm_jtag_b: arm_jtag_b { - broadcom,pins = <23>, <24>, <25>, <26>, <27>; - }; - /* Reserved */ pins_reserved: reserved { broadcom,pins = <48>, <49>, <50>, <51>, <52>, @@ -404,7 +190,7 @@ interrupt-parent = <&intc>; }; - bsc0 { + bsc0: bsc0 { #address-cells = <1>; #size-cells = <0>; compatible = "broadcom,bcm2835-bsc", @@ -414,7 +200,7 @@ interrupt-parent = <&intc>; }; - bsc1 { + bsc1: bsc1 { #address-cells = <1>; #size-cells = <0>; compatible = "broadcom,bcm2835-bsc", @@ -424,7 +210,7 @@ interrupt-parent = <&intc>; }; - spi0 { + spi0: spi0 { compatible = "broadcom,bcm2835-spi", "broadcom,bcm2708-spi"; reg = <0x204000 0x20>; Index: sys/dts/arm/bcm2836.dtsi =================================================================== --- sys/dts/arm/bcm2836.dtsi +++ sys/dts/arm/bcm2836.dtsi @@ -148,241 +148,27 @@ broadcom,read-only = <46>, <48>, <49>, <50>, <51>, <52>, <53>; - /* BSC0 */ - pins_bsc0_a: bsc0_a { - broadcom,pins = <0>, <1>; + spi0_pins: spi0_pins { + brcm,pins = <9 10 11>; + brcm,function = <4>; /* alt0 */ }; - pins_bsc0_b: bsc0_b { - broadcom,pins = <28>, <29>; + spi0_cs_pins: spi0_cs_pins { + brcm,pins = <8 7>; + brcm,function = <1>; /* output */ }; - pins_bsc0_c: bsc0_c { - broadcom,pins = <44>, <45>; + bsc0_pins: bsc0 { + brcm,pins = <0 1>; + brcm,function = <4>; /* alt0 */ }; - /* BSC1 */ - pins_bsc1_a: bsc1_a { - broadcom,pins = <2>, <3>; + bsc1_pins: bsc1 { + brcm,pins = <2 3>; + brcm,function = <4>; /* alt0 */ }; - pins_bsc1_b: bsc1_b { - broadcom,pins = <44>, <45>; - }; - - /* GPCLK0 */ - pins_gpclk0_a: gpclk0_a { - broadcom,pins = <4>; - }; - - pins_gpclk0_b: gpclk0_b { - broadcom,pins = <20>; - }; - - pins_gpclk0_c: gpclk0_c { - broadcom,pins = <32>; - }; - - pins_gpclk0_d: gpclk0_d { - broadcom,pins = <34>; - }; - - /* GPCLK1 */ - pins_gpclk1_a: gpclk1_a { - broadcom,pins = <5>; - }; - - pins_gpclk1_b: gpclk1_b { - broadcom,pins = <21>; - }; - - pins_gpclk1_c: gpclk1_c { - broadcom,pins = <42>; - }; - - pins_gpclk1_d: gpclk1_d { - broadcom,pins = <44>; - }; - - /* GPCLK2 */ - pins_gpclk2_a: gpclk2_a { - broadcom,pins = <6>; - }; - - pins_gpclk2_b: gpclk2_b { - broadcom,pins = <43>; - }; - - /* SPI0 */ - pins_spi0_a: spi0_a { - broadcom,pins = <7>, <8>, <9>, <10>, <11>; - }; - - pins_spi0_b: spi0_b { - broadcom,pins = <35>, <36>, <37>, <38>, <39>; - }; - - /* PWM */ - pins_pwm0_a: pwm0_a { - broadcom,pins = <12>; - }; - - pins_pwm0_b: pwm0_b { - broadcom,pins = <18>; - }; - - pins_pwm0_c: pwm0_c { - broadcom,pins = <40>; - }; - - pins_pwm1_a: pwm1_a { - broadcom,pins = <13>; - }; - - pins_pwm1_b: pwm1_b { - broadcom,pins = <19>; - }; - - pins_pwm1_c: pwm1_c { - broadcom,pins = <41>; - }; - - pins_pwm1_d: pwm1_d { - broadcom,pins = <45>; - }; - - /* UART0 */ - pins_uart0_a: uart0_a { - broadcom,pins = <14>, <15>; - }; - - pins_uart0_b: uart0_b { - broadcom,pins = <32>, <33>; - }; - - pins_uart0_c: uart0_c { - broadcom,pins = <36>, <37>; - }; - - pins_uart0_fc_a: uart0_fc_a { - broadcom,pins = <16>, <17>; - }; - - pins_uart0_fc_b: uart0_fc_b { - broadcom,pins = <30>, <31>; - }; - - pins_uart0_fc_c: uart0_fc_c { - broadcom,pins = <39>, <38>; - }; - - /* PCM */ - pins_pcm_a: pcm_a { - broadcom,pins = <18>, <19>, <20>, <21>; - }; - - pins_pcm_b: pcm_b { - broadcom,pins = <28>, <29>, <30>, <31>; - }; - - /* Secondary Address Bus */ - pins_sm_addr_a: sm_addr_a { - broadcom,pins = <5>, <4>, <3>, <2>, <1>, <0>; - }; - - pins_sm_addr_b: sm_addr_b { - broadcom,pins = <33>, <32>, <31>, <30>, <29>, - <28>; - }; - - pins_sm_ctl_a: sm_ctl_a { - broadcom,pins = <6>, <7>; - }; - - pins_sm_ctl_b: sm_ctl_b { - broadcom,pins = <34>, <35>; - }; - - pins_sm_data_8bit_a: sm_data_8bit_a { - broadcom,pins = <8>, <9>, <10>, <11>, <12>, - <13>, <14>, <15>; - }; - - pins_sm_data_8bit_b: sm_data_8bit_b { - broadcom,pins = <36>, <37>, <38>, <39>, <40>, - <41>, <42>, <43>; - }; - - pins_sm_data_16bit: sm_data_16bit { - broadcom,pins = <16>, <17>, <18>, <19>, <20>, - <21>, <22>, <23>; - }; - - pins_sm_data_18bit: sm_data_18bit { - broadcom,pins = <24>, <25>; - }; - - /* BSCSL */ - pins_bscsl: bscsl { - broadcom,pins = <18>, <19>; - }; - - /* SPISL */ - pins_spisl: spisl { - broadcom,pins = <18>, <19>, <20>, <21>; - }; - - /* SPI1 */ - pins_spi1: spi1 { - broadcom,pins = <16>, <17>, <18>, <19>, <20>, - <21>; - }; - - /* UART1 */ - pins_uart1_a: uart1_a { - broadcom,pins = <14>, <15>; - }; - - pins_uart1_b: uart1_b { - broadcom,pins = <32>, <33>; - }; - - pins_uart1_c: uart1_c { - broadcom,pins = <40>, <41>; - }; - - pins_uart1_fc_a: uart1_fc_a { - broadcom,pins = <16>, <17>; - }; - - pins_uart1_fc_b: uart1_fc_b { - broadcom,pins = <30>, <31>; - }; - - pins_uart1_fc_c: uart1_fc_c { - broadcom,pins = <43>, <42>; - }; - - /* SPI2 */ - pins_spi2: spi2 { - broadcom,pins = <40>, <41>, <42>, <43>, <44>, - <45>; - }; - - /* ARM JTAG */ - pins_arm_jtag_trst: arm_jtag_trst { - broadcom,pins = <22>; - }; - - pins_arm_jtag_a: arm_jtag_a { - broadcom,pins = <4>, <5>, <6>, <12>, <13>; - }; - - pins_arm_jtag_b: arm_jtag_b { - broadcom,pins = <23>, <24>, <25>, <26>, <27>; - }; - - /* Reserved */ + /* This is for compatibility with older code */ pins_reserved: reserved { broadcom,pins = <48>, <49>, <50>, <51>, <52>, <53>; @@ -402,7 +188,7 @@ interrupt-parent = <&intc>; }; - bsc0 { + bsc0: bsc0 { #address-cells = <1>; #size-cells = <0>; compatible = "broadcom,bcm2835-bsc", @@ -412,7 +198,7 @@ interrupt-parent = <&intc>; }; - bsc1 { + bsc1: bsc1 { #address-cells = <1>; #size-cells = <0>; compatible = "broadcom,bcm2835-bsc", @@ -422,7 +208,7 @@ interrupt-parent = <&intc>; }; - spi0 { + spi0: spi0 { compatible = "broadcom,bcm2835-spi", "broadcom,bcm2708-spi"; reg = <0x204000 0x20>; Index: sys/dts/arm/rpi.dts =================================================================== --- sys/dts/arm/rpi.dts +++ sys/dts/arm/rpi.dts @@ -399,3 +399,18 @@ cache_line_size = <&vchiq>, "cache-line-size:0"; }; }; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins &spi0_cs_pins>; +} + +&bsc0 { + pinctrl-names = "default"; + pinctrl-0 = <&bsc0_pins>; +}; + +&bsc1 { + pinctrl-names = "default"; + pinctrl-0 = <&bsc1_pins>; +}; Index: sys/dts/arm/rpi2.dts =================================================================== --- sys/dts/arm/rpi2.dts +++ sys/dts/arm/rpi2.dts @@ -76,238 +76,6 @@ axi { gpio: gpio { - /* BSC0 */ - pins_bsc0_a: bsc0_a { - broadcom,function = "ALT0"; - }; - - pins_bsc0_b: bsc0_b { - broadcom,function = "ALT0"; - }; - - pins_bsc0_c: bsc0_c { - broadcom,function = "ALT1"; - }; - - /* BSC1 */ - pins_bsc1_a: bsc1_a { - broadcom,function = "ALT0"; - }; - - pins_bsc1_b: bsc1_b { - broadcom,function = "ALT2"; - }; - - /* GPCLK0 */ - pins_gpclk0_a: gpclk0_a { - broadcom,function = "ALT0"; - }; - - pins_gpclk0_b: gpclk0_b { - broadcom,function = "ALT5"; - }; - - pins_gpclk0_c: gpclk0_c { - broadcom,function = "ALT0"; - }; - - pins_gpclk0_d: gpclk0_d { - broadcom,function = "ALT0"; - }; - - /* GPCLK1 */ - pins_gpclk1_a: gpclk1_a { - broadcom,function = "ALT0"; - }; - - pins_gpclk1_b: gpclk1_b { - broadcom,function = "ALT5"; - }; - - pins_gpclk1_c: gpclk1_c { - broadcom,function = "ALT0"; - }; - - pins_gpclk1_d: gpclk1_d { - broadcom,function = "ALT0"; - }; - - /* GPCLK2 */ - pins_gpclk2_a: gpclk2_a { - broadcom,function = "ALT0"; - }; - - pins_gpclk2_b: gpclk2_b { - broadcom,function = "ALT0"; - }; - - /* SPI0 */ - pins_spi0_a: spi0_a { - broadcom,function = "ALT0"; - }; - - pins_spi0_b: spi0_b { - broadcom,function = "ALT0"; - }; - - /* PWM */ - pins_pwm0_a: pwm0_a { - broadcom,function = "ALT0"; - }; - - pins_pwm0_b: pwm0_b { - broadcom,function = "ALT5"; - }; - - pins_pwm0_c: pwm0_c { - broadcom,function = "ALT0"; - }; - - pins_pwm1_a: pwm1_a { - broadcom,function = "ALT0"; - }; - - pins_pwm1_b: pwm1_b { - broadcom,function = "ALT5"; - }; - - pins_pwm1_c: pwm1_c { - broadcom,function = "ALT0"; - }; - - pins_pwm1_d: pwm1_d { - broadcom,function = "ALT0"; - }; - - /* UART0 */ - pins_uart0_a: uart0_a { - broadcom,function = "ALT0"; - }; - - pins_uart0_b: uart0_b { - broadcom,function = "ALT3"; - }; - - pins_uart0_c: uart0_c { - broadcom,function = "ALT2"; - }; - - pins_uart0_fc_a: uart0_fc_a { - broadcom,function = "ALT3"; - }; - - pins_uart0_fc_b: uart0_fc_b { - broadcom,function = "ALT3"; - }; - - pins_uart0_fc_c: uart0_fc_c { - broadcom,function = "ALT2"; - }; - - /* PCM */ - pins_pcm_a: pcm_a { - broadcom,function = "ALT0"; - }; - - pins_pcm_b: pcm_b { - broadcom,function = "ALT2"; - }; - - /* Secondary Address Bus */ - pins_sm_addr_a: sm_addr_a { - broadcom,function = "ALT1"; - }; - - pins_sm_addr_b: sm_addr_b { - broadcom,function = "ALT1"; - }; - - pins_sm_ctl_a: sm_ctl_a { - broadcom,function = "ALT1"; - }; - - pins_sm_ctl_b: sm_ctl_b { - broadcom,function = "ALT1"; - }; - - pins_sm_data_8bit_a: sm_data_8bit_a { - broadcom,function = "ALT1"; - }; - - pins_sm_data_8bit_b: sm_data_8bit_b { - broadcom,function = "ALT1"; - }; - - pins_sm_data_16bit: sm_data_16bit { - broadcom,function = "ALT1"; - }; - - pins_sm_data_18bit: sm_data_18bit { - broadcom,function = "ALT1"; - }; - - /* BSCSL */ - pins_bscsl: bscsl { - broadcom,function = "ALT3"; - }; - - /* SPISL */ - pins_spisl: spisl { - broadcom,function = "ALT3"; - }; - - /* SPI1 */ - pins_spi1: spi1 { - broadcom,function = "ALT4"; - }; - - /* UART1 */ - pins_uart1_a: uart1_a { - broadcom,function = "ALT5"; - }; - - pins_uart1_b: uart1_b { - broadcom,function = "ALT5"; - }; - - pins_uart1_c: uart1_c { - broadcom,function = "ALT5"; - }; - - pins_uart1_fc_a: uart1_fc_a { - broadcom,function = "ALT5"; - }; - - pins_uart1_fc_b: uart1_fc_b { - broadcom,function = "ALT5"; - }; - - pins_uart1_fc_c: uart1_fc_c { - broadcom,function = "ALT5"; - }; - - /* SPI2 */ - pins_spi2: spi2 { - broadcom,function = "ALT4"; - }; - - /* ARM JTAG */ - pins_arm_jtag_trst: arm_jtag_trst { - broadcom,function = "ALT4"; - }; - - pins_arm_jtag_a: arm_jtag_a { - broadcom,function = "ALT5"; - }; - - pins_arm_jtag_b: arm_jtag_b { - broadcom,function = "ALT4"; - }; - - /* Reserved */ - pins_reserved: reserved { - broadcom,function = "ALT3"; - }; }; usb { hub { @@ -409,4 +177,19 @@ __overrides__ { cache_line_size = <&vchiq>, "cache-line-size:0"; }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins &spi0_cs_pins>; +} + +&bsc0 { + pinctrl-names = "default"; + pinctrl-0 = <&bsc0_pins>; +}; + +&bsc1 { + pinctrl-names = "default"; + pinctrl-0 = <&bsc1_pins>; };