boards: riscv: rv32m1_vega: convert from pinmux to pinctrl

Convert the OpenISA RV32M1 VEGAboard from pinmux to pinctrl.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
Henrik Brix Andersen 2022-05-01 22:32:33 +02:00 committed by David Leach
commit 191bf2ab0a
8 changed files with 145 additions and 147 deletions

View file

@ -1,4 +1,6 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
zephyr_library() if(CONFIG_BT_CTLR_DEBUG_PINS)
zephyr_library_sources(pinmux.c) zephyr_library()
zephyr_library_sources(board.c)
endif()

View file

@ -0,0 +1,12 @@
# OpenISA VEGAboard board configuration
# Copyright (c) 2022 Henrik Brix Andersen <henrik@brixandersen.dk>
# SPDX-License-Identifier: Apache-2.0
config BOARD_INIT_PRIORITY
int "Board initialization priority"
default 45
depends on BOARD_RV32M1_VEGA && BT_CTLR_DEBUG_PINS
help
Board initialization priority. The board initialization must take
place after the GPIO driver is initialized.

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Henrik Brix Andersen <henrik@brixandersen.dk>
* Copyright 2018 Foundries.io Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <drivers/gpio.h>
static int rv32m1_vega_board_init(const struct device *dev)
{
const struct device *gpiob = DEVICE_DT_GET(DT_NODELABEL(gpiob));
const struct device *gpioc = DEVICE_DT_GET(DT_NODELABEL(gpioc));
const struct device *gpiod = DEVICE_DT_GET(DT_NODELABEL(gpiod));
ARG_UNUSED(dev);
__ASSERT_NO_MSG(device_is_ready(gpiob));
__ASSERT_NO_MSG(device_is_ready(gpioc));
__ASSERT_NO_MSG(device_is_ready(gpiod));
gpio_pin_configure(gpiob, 29, GPIO_OUTPUT);
gpio_pin_configure(gpioc, 28, GPIO_OUTPUT);
gpio_pin_configure(gpioc, 29, GPIO_OUTPUT);
gpio_pin_configure(gpioc, 30, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 0, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 1, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 2, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 3, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 4, GPIO_OUTPUT);
gpio_pin_configure(gpiod, 5, GPIO_OUTPUT);
return 0;
}
SYS_INIT(rv32m1_vega_board_init, PRE_KERNEL_1, CONFIG_BOARD_INIT_PRIORITY);

View file

@ -1,142 +0,0 @@
/*
* Copyright 2018 Foundries.io Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <init.h>
#include <drivers/pinmux.h>
#include <drivers/gpio.h>
#include <fsl_port.h>
#ifdef CONFIG_BT_CTLR_DEBUG_PINS
const struct device *vega_debug_portb;
const struct device *vega_debug_portc;
const struct device *vega_debug_portd;
#endif
static int rv32m1_vega_pinmux_init(const struct device *dev)
{
ARG_UNUSED(dev);
#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay)
__unused const struct device *porta =
DEVICE_DT_GET(DT_NODELABEL(porta));
__ASSERT_NO_MSG(device_is_ready(porta));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay)
__unused const struct device *portb =
DEVICE_DT_GET(DT_NODELABEL(portb));
__ASSERT_NO_MSG(device_is_ready(portb));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay)
__unused const struct device *portc =
DEVICE_DT_GET(DT_NODELABEL(portc));
__ASSERT_NO_MSG(device_is_ready(portc));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay)
__unused const struct device *portd =
DEVICE_DT_GET(DT_NODELABEL(portd));
__ASSERT_NO_MSG(device_is_ready(portd));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay)
__unused const struct device *porte =
DEVICE_DT_GET(DT_NODELABEL(porte));
__ASSERT_NO_MSG(device_is_ready(porte));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart0), okay) && CONFIG_SERIAL
/* LPUART0 RX, TX */
pinmux_pin_set(portc, 7, PORT_PCR_MUX(kPORT_MuxAlt3));
pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart1), okay) && CONFIG_SERIAL
/* LPUART1 RX, TX */
pinmux_pin_set(portc, 29, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portc, 30, PORT_PCR_MUX(kPORT_MuxAlt2));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpi2c0), okay) && CONFIG_I2C
/* LPI2C0 SCL, SDA - Arduino header */
pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt4));
pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt4));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpi2c3), okay) && CONFIG_I2C
/* LPI2C3 SCL, SDA - FXOS8700 */
pinmux_pin_set(porte, 30, PORT_PCR_MUX(kPORT_MuxAlt3));
pinmux_pin_set(porte, 29, PORT_PCR_MUX(kPORT_MuxAlt3));
#endif
/* FXOS8700 INT1, INT2, RST */
pinmux_pin_set(porte, 1, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(porte, 22, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(porte, 27, PORT_PCR_MUX(kPORT_MuxAsGpio));
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpspi0), okay) && CONFIG_SPI
/* LPSPI0 SCK, SOUT, PCS2, SIN */
pinmux_pin_set(portb, 4, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 6, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 7, PORT_PCR_MUX(kPORT_MuxAlt2));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpspi1), okay) && CONFIG_SPI
/* LPSPI1 SCK, SIN, SOUT, CS */
pinmux_pin_set(portb, 20, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 21, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 24, PORT_PCR_MUX(kPORT_MuxAlt2));
pinmux_pin_set(portb, 22, PORT_PCR_MUX(kPORT_MuxAlt2));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(tpm2), okay) && CONFIG_PWM
/* RGB LEDs as PWM */
pinmux_pin_set(porta, 22, PORT_PCR_MUX(kPORT_MuxAlt6));
pinmux_pin_set(porta, 23, PORT_PCR_MUX(kPORT_MuxAlt6));
pinmux_pin_set(porta, 24, PORT_PCR_MUX(kPORT_MuxAlt6));
#else
/* RGB LEDs as GPIO */
pinmux_pin_set(porta, 22, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(porta, 23, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(porta, 24, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif
#ifdef CONFIG_BT_CTLR_DEBUG_PINS
pinmux_pin_set(portb, 29, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 28, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 29, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portc, 30, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 4, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 5, PORT_PCR_MUX(kPORT_MuxAsGpio));
const struct device *gpio_dev =
device_get_binding(DT_LABEL(DT_NODELABEL(gpiob)));
gpio_pin_configure(gpio_dev, 29, GPIO_OUTPUT);
gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpioc)));
gpio_pin_configure(gpio_dev, 28, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 29, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 30, GPIO_OUTPUT);
gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpiod)));
gpio_pin_configure(gpio_dev, 0, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 1, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 2, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 3, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 4, GPIO_OUTPUT);
gpio_pin_configure(gpio_dev, 5, GPIO_OUTPUT);
#endif
return 0;
}
SYS_INIT(rv32m1_vega_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

View file

@ -0,0 +1,69 @@
/*
* Copyright (c) 2022 Henrik Brix Andersen <henrik@brixandersen.dk>
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pinctrl/rv32m1-pinctrl.h>
&pinctrl {
lpuart0_default: lpuart0_default {
group0 {
pinmux = <RV32M1_MUX('C', 7, 3)>,
<RV32M1_MUX('C', 8, 3)>;
slew-rate = "slow";
};
};
lpuart1_default: lpuart1_default {
group0 {
pinmux = <RV32M1_MUX('C', 29, 2)>,
<RV32M1_MUX('C', 30, 2)>;
slew-rate = "slow";
};
};
lpi2c0_default: lpi2c0_default {
group0 {
pinmux = <RV32M1_MUX('C', 9, 4)>,
<RV32M1_MUX('C', 10, 4)>;
slew-rate = "slow";
};
};
lpi2c3_default: lpi2c3_default {
group0 {
pinmux = <RV32M1_MUX('E', 29, 3)>,
<RV32M1_MUX('E', 30, 3)>;
slew-rate = "slow";
};
};
lpspi0_default: lpspi0_default {
group0 {
pinmux = <RV32M1_MUX('B', 4, 2)>,
<RV32M1_MUX('B', 5, 2)>,
<RV32M1_MUX('B', 6, 2)>,
<RV32M1_MUX('B', 7, 2)>;
slew-rate = "slow";
};
};
lpspi1_default: lpspi1_default {
group0 {
pinmux = <RV32M1_MUX('B', 20, 2)>,
<RV32M1_MUX('B', 21, 2)>,
<RV32M1_MUX('B', 22, 2)>,
<RV32M1_MUX('B', 24, 2)>;
slew-rate = "slow";
};
};
tpm2_default: tpm2_default {
group0 {
pinmux = <RV32M1_MUX('A', 22, 6)>,
<RV32M1_MUX('A', 23, 6)>,
<RV32M1_MUX('A', 24, 6)>;
slew-rate = "slow";
};
};
};

View file

@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "rv32m1_vega-pinctrl.dtsi"
/ { / {
aliases { aliases {
led0 = &green_led; led0 = &green_led;
@ -107,19 +109,28 @@
}; };
}; };
arduino_serial: &lpuart1 {}; arduino_serial: &lpuart1 {
pinctrl-0 = <&lpuart1_default>;
pinctrl-names = "default";
};
&lpuart0 { &lpuart0 {
current-speed = <115200>; current-speed = <115200>;
status = "okay"; status = "okay";
pinctrl-0 = <&lpuart0_default>;
pinctrl-names = "default";
}; };
arduino_i2c: &lpi2c0 { arduino_i2c: &lpi2c0 {
status = "okay"; status = "okay";
pinctrl-0 = <&lpi2c0_default>;
pinctrl-names = "default";
}; };
&lpi2c3 { &lpi2c3 {
status = "okay"; status = "okay";
pinctrl-0 = <&lpi2c3_default>;
pinctrl-names = "default";
fxos8700@1e { fxos8700@1e {
compatible = "nxp,fxos8700"; compatible = "nxp,fxos8700";
@ -133,11 +144,16 @@ arduino_i2c: &lpi2c0 {
arduino_spi: &lpspi0 { arduino_spi: &lpspi0 {
status = "okay"; status = "okay";
pinctrl-0 = <&lpspi0_default>;
pinctrl-names = "default";
}; };
&lpspi1 { &lpspi1 {
status = "okay"; status = "okay";
cs-gpios = <&gpiob 22 GPIO_ACTIVE_LOW>; cs-gpios = <&gpiob 22 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&lpspi1_default>;
pinctrl-names = "default";
mx25r32: mx25r3235f@0 { mx25r32: mx25r3235f@0 {
compatible = "jedec,spi-nor"; compatible = "jedec,spi-nor";
reg = <0>; reg = <0>;
@ -150,4 +166,6 @@ arduino_spi: &lpspi0 {
&tpm2 { &tpm2 {
status = "okay"; status = "okay";
pinctrl-0 = <&tpm2_default>;
pinctrl-names = "default";
}; };

View file

@ -5,7 +5,7 @@ CONFIG_SOC_OPENISA_RV32M1_RI5CY=y
CONFIG_BOARD_RV32M1_VEGA=y CONFIG_BOARD_RV32M1_VEGA=y
CONFIG_CLOCK_CONTROL_RV32M1_PCC=y CONFIG_CLOCK_CONTROL_RV32M1_PCC=y
CONFIG_GPIO=y CONFIG_GPIO=y
CONFIG_PINMUX=y CONFIG_PINCTRL=y
CONFIG_SERIAL=y CONFIG_SERIAL=y
CONFIG_CONSOLE=y CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y CONFIG_UART_CONSOLE=y

View file

@ -3,7 +3,7 @@ CONFIG_SOC_OPENISA_RV32M1_ZERO_RISCY=y
CONFIG_BOARD_RV32M1_VEGA=y CONFIG_BOARD_RV32M1_VEGA=y
CONFIG_CLOCK_CONTROL_RV32M1_PCC=y CONFIG_CLOCK_CONTROL_RV32M1_PCC=y
CONFIG_GPIO=y CONFIG_GPIO=y
CONFIG_PINMUX=y CONFIG_PINCTRL=y
CONFIG_SERIAL=y CONFIG_SERIAL=y
CONFIG_CONSOLE=y CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y CONFIG_UART_CONSOLE=y