drivers: pinmux: rv32m1: Convert driver to new DT_INST macros
Convert driver to use DT_INST macros and remove related board per instance Kconfig symbol usage. Updated the openisa,rv32m1_vega-pinmux binding to require the label property and updated the rv32m1.dtsi to add label properties for the pinmux nodes. Also update gpio_basic_api test to use DT_NODELABEL. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
ec048128ae
commit
8f0018663f
7 changed files with 30 additions and 144 deletions
|
@ -7,25 +7,6 @@ config BOARD
|
|||
default "rv32m1_vega_ri5cy" if SOC_OPENISA_RV32M1_RI5CY
|
||||
default "rv32m1_vega_zero_riscy" if SOC_OPENISA_RV32M1_ZERO_RISCY
|
||||
|
||||
if PINMUX_RV32M1
|
||||
|
||||
config PINMUX_RV32M1_PORTA
|
||||
default y
|
||||
|
||||
config PINMUX_RV32M1_PORTB
|
||||
default y
|
||||
|
||||
config PINMUX_RV32M1_PORTC
|
||||
default y
|
||||
|
||||
config PINMUX_RV32M1_PORTD
|
||||
default y
|
||||
|
||||
config PINMUX_RV32M1_PORTE
|
||||
default y if RV32M1_INTMUX
|
||||
|
||||
endif # PINMUX_RV32M1
|
||||
|
||||
if GPIO_RV32M1
|
||||
|
||||
config GPIO_RV32M1_PORTA
|
||||
|
|
|
@ -21,23 +21,23 @@ static int rv32m1_vega_pinmux_init(struct device *dev)
|
|||
|
||||
#if DT_HAS_NODE(DT_NODELABEL(porta))
|
||||
__unused struct device *porta =
|
||||
device_get_binding(CONFIG_PINMUX_RV32M1_PORTA_NAME);
|
||||
device_get_binding(DT_LABEL(DT_NODELABEL(porta)));
|
||||
#endif
|
||||
#if DT_HAS_NODE(DT_NODELABEL(portb))
|
||||
__unused struct device *portb =
|
||||
device_get_binding(CONFIG_PINMUX_RV32M1_PORTB_NAME);
|
||||
device_get_binding(DT_LABEL(DT_NODELABEL(portb)));
|
||||
#endif
|
||||
#if DT_HAS_NODE(DT_NODELABEL(portc))
|
||||
__unused struct device *portc =
|
||||
device_get_binding(CONFIG_PINMUX_RV32M1_PORTC_NAME);
|
||||
device_get_binding(DT_LABEL(DT_NODELABEL(portc)));
|
||||
#endif
|
||||
#if DT_HAS_NODE(DT_NODELABEL(portd))
|
||||
__unused struct device *portd =
|
||||
device_get_binding(CONFIG_PINMUX_RV32M1_PORTD_NAME);
|
||||
device_get_binding(DT_LABEL(DT_NODELABEL(portd)));
|
||||
#endif
|
||||
#if DT_HAS_NODE(DT_NODELABEL(porte))
|
||||
__unused struct device *porte =
|
||||
device_get_binding(CONFIG_PINMUX_RV32M1_PORTE_NAME);
|
||||
device_get_binding(DT_LABEL(DT_NODELABEL(porte)));
|
||||
#endif
|
||||
|
||||
#if DT_HAS_NODE(DT_NODELABEL(lpuart0))
|
||||
|
|
|
@ -3,63 +3,8 @@
|
|||
# Copyright (c) 2018 Foundries.io
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig PINMUX_RV32M1
|
||||
config PINMUX_RV32M1
|
||||
bool "RV32M1 pinmux driver"
|
||||
depends on SOC_OPENISA_RV32M1_RISCV32
|
||||
help
|
||||
Enable the RV32M1 pinmux driver.
|
||||
|
||||
if PINMUX_RV32M1
|
||||
|
||||
config PINMUX_RV32M1_PORTA
|
||||
bool "Port A"
|
||||
help
|
||||
Enable Port A.
|
||||
|
||||
config PINMUX_RV32M1_PORTA_NAME
|
||||
string "Pinmux Port A driver name"
|
||||
depends on PINMUX_RV32M1_PORTA
|
||||
default "porta"
|
||||
|
||||
config PINMUX_RV32M1_PORTB
|
||||
bool "Port B"
|
||||
help
|
||||
Enable Port B.
|
||||
|
||||
config PINMUX_RV32M1_PORTB_NAME
|
||||
string "Pinmux Port B driver name"
|
||||
depends on PINMUX_RV32M1_PORTB
|
||||
default "portb"
|
||||
|
||||
config PINMUX_RV32M1_PORTC
|
||||
bool "Port C"
|
||||
help
|
||||
Enable Port C.
|
||||
|
||||
config PINMUX_RV32M1_PORTC_NAME
|
||||
string "Pinmux Port C driver name"
|
||||
depends on PINMUX_RV32M1_PORTC
|
||||
default "portc"
|
||||
|
||||
config PINMUX_RV32M1_PORTD
|
||||
bool "Port D"
|
||||
help
|
||||
Enable Port D.
|
||||
|
||||
config PINMUX_RV32M1_PORTD_NAME
|
||||
string "Pinmux Port D driver name"
|
||||
depends on PINMUX_RV32M1_PORTD
|
||||
default "portd"
|
||||
|
||||
config PINMUX_RV32M1_PORTE
|
||||
bool "Port E"
|
||||
depends on RV32M1_INTMUX
|
||||
help
|
||||
Enable Port E.
|
||||
|
||||
config PINMUX_RV32M1_PORTE_NAME
|
||||
string "Pinmux Port E driver name"
|
||||
depends on PINMUX_RV32M1_PORTE
|
||||
default "porte"
|
||||
|
||||
endif # PINMUX_RV32M1
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT openisa_rv32m1_pinmux
|
||||
|
||||
#include <errno.h>
|
||||
#include <device.h>
|
||||
#include <drivers/pinmux.h>
|
||||
|
@ -63,67 +65,17 @@ static const struct pinmux_driver_api pinmux_rv32m1_driver_api = {
|
|||
.input = pinmux_rv32m1_input,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PINMUX_RV32M1_PORTA
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_porta_config = {
|
||||
.base = (PORT_Type *)DT_OPENISA_RV32M1_PINMUX_PINMUX_A_BASE_ADDRESS,
|
||||
.clock_ip_name = kCLOCK_PortA,
|
||||
};
|
||||
#define PINMUX_RV32M1_INIT(n) \
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_##n##_config = {\
|
||||
.base = (PORT_Type *)DT_INST_REG_ADDR(n), \
|
||||
.clock_ip_name = INST_DT_CLOCK_IP_NAME(n), \
|
||||
}; \
|
||||
\
|
||||
DEVICE_AND_API_INIT(pinmux_rv32m1_##n, DT_INST_LABEL(n), \
|
||||
&pinmux_rv32m1_init, \
|
||||
NULL, &pinmux_rv32m1_##n##_config, \
|
||||
PRE_KERNEL_1, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
&pinmux_rv32m1_driver_api)
|
||||
|
||||
DEVICE_AND_API_INIT(pinmux_porta, CONFIG_PINMUX_RV32M1_PORTA_NAME,
|
||||
&pinmux_rv32m1_init,
|
||||
NULL, &pinmux_rv32m1_porta_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_rv32m1_driver_api);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_RV32M1_PORTB
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_portb_config = {
|
||||
.base = (PORT_Type *)DT_OPENISA_RV32M1_PINMUX_PINMUX_B_BASE_ADDRESS,
|
||||
.clock_ip_name = kCLOCK_PortB,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(pinmux_portb, CONFIG_PINMUX_RV32M1_PORTB_NAME,
|
||||
&pinmux_rv32m1_init,
|
||||
NULL, &pinmux_rv32m1_portb_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_rv32m1_driver_api);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_RV32M1_PORTC
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_portc_config = {
|
||||
.base = (PORT_Type *)DT_OPENISA_RV32M1_PINMUX_PINMUX_C_BASE_ADDRESS,
|
||||
.clock_ip_name = kCLOCK_PortC,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(pinmux_portc, CONFIG_PINMUX_RV32M1_PORTC_NAME,
|
||||
&pinmux_rv32m1_init,
|
||||
NULL, &pinmux_rv32m1_portc_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_rv32m1_driver_api);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_RV32M1_PORTD
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_portd_config = {
|
||||
.base = (PORT_Type *)DT_OPENISA_RV32M1_PINMUX_PINMUX_D_BASE_ADDRESS,
|
||||
.clock_ip_name = kCLOCK_PortD,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(pinmux_portd, CONFIG_PINMUX_RV32M1_PORTD_NAME,
|
||||
&pinmux_rv32m1_init,
|
||||
NULL, &pinmux_rv32m1_portd_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_rv32m1_driver_api);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_RV32M1_PORTE
|
||||
static const struct pinmux_rv32m1_config pinmux_rv32m1_porte_config = {
|
||||
.base = (PORT_Type *)DT_OPENISA_RV32M1_PINMUX_PINMUX_E_BASE_ADDRESS,
|
||||
.clock_ip_name = kCLOCK_PortE,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(pinmux_porte, CONFIG_PINMUX_RV32M1_PORTE_NAME,
|
||||
&pinmux_rv32m1_init,
|
||||
NULL, &pinmux_rv32m1_porte_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_rv32m1_driver_api);
|
||||
#endif
|
||||
DT_INST_FOREACH(PINMUX_RV32M1_INIT)
|
||||
|
|
|
@ -5,6 +5,9 @@ compatible: "openisa,rv32m1-pinmux"
|
|||
include: base.yaml
|
||||
|
||||
properties:
|
||||
label:
|
||||
required: true
|
||||
|
||||
reg:
|
||||
required: true
|
||||
|
||||
|
|
|
@ -308,30 +308,35 @@
|
|||
compatible = "openisa,rv32m1-pinmux";
|
||||
reg = <0x40046000 0xd0>;
|
||||
clocks = <&pcc0 0x118>;
|
||||
label = "porta";
|
||||
};
|
||||
|
||||
portb: pinmux@40047000 {
|
||||
compatible = "openisa,rv32m1-pinmux";
|
||||
reg = <0x40047000 0xd0>;
|
||||
clocks = <&pcc0 0x11c>;
|
||||
label = "portb";
|
||||
};
|
||||
|
||||
portc: pinmux@40048000 {
|
||||
compatible = "openisa,rv32m1-pinmux";
|
||||
reg = <0x40048000 0xd0>;
|
||||
clocks = <&pcc0 0x120>;
|
||||
label = "portc";
|
||||
};
|
||||
|
||||
portd: pinmux@40049000 {
|
||||
compatible = "openisa,rv32m1-pinmux";
|
||||
reg = <0x40049000 0xd0>;
|
||||
clocks = <&pcc0 0x124>;
|
||||
label = "portd";
|
||||
};
|
||||
|
||||
porte: pinmux@41037000 {
|
||||
compatible = "openisa,rv32m1-pinmux";
|
||||
reg = <0x41037000 0xd0>;
|
||||
clocks = <&pcc1 0xdc>;
|
||||
label = "porte";
|
||||
};
|
||||
|
||||
gpioa: gpio@48020000 {
|
||||
|
|
|
@ -110,7 +110,7 @@ static void board_setup(void)
|
|||
pinmux_pin_set(port0, PIN_IN, pin_config);
|
||||
pinmux_pin_set(port0, PIN_OUT, pin_config);
|
||||
#elif defined(CONFIG_BOARD_RV32M1_VEGA)
|
||||
const char *pmx_name = CONFIG_PINMUX_RV32M1_PORTA_NAME;
|
||||
const char *pmx_name = DT_LABEL(DT_NODELABEL(porta));
|
||||
struct device *pmx = device_get_binding(pmx_name);
|
||||
|
||||
pinmux_pin_set(pmx, PIN_OUT, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue