From 7e3b3dd258c0a0db2575a2be874189cee4ff2cb9 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 16 Jan 2024 15:08:26 +0100 Subject: [PATCH] drivers: pinctrl: sifive: use DT ngpios property Instead of hardcoded definitions from soc.h. Signed-off-by: Gerard Marull-Paretas --- drivers/pinctrl/pinctrl_sifive.c | 3 ++- soc/riscv/sifive_freedom/e300/soc.h | 3 --- soc/riscv/sifive_freedom/u500/soc.h | 3 --- soc/riscv/sifive_freedom/u700/soc.h | 3 --- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl_sifive.c b/drivers/pinctrl/pinctrl_sifive.c index ff770b53a6..7dd8c6f944 100644 --- a/drivers/pinctrl/pinctrl_sifive.c +++ b/drivers/pinctrl/pinctrl_sifive.c @@ -13,6 +13,7 @@ #include +#define MAX_PIN_NUM DT_PROP(DT_INST_PARENT(0), ngpios) #define PINCTRL_BASE_ADDR DT_INST_REG_ADDR(0) #define PINCTRL_IOF_EN (PINCTRL_BASE_ADDR + 0x0) #define PINCTRL_IOF_SEL (PINCTRL_BASE_ADDR + 0x4) @@ -21,7 +22,7 @@ static int pinctrl_sifive_set(uint32_t pin, uint32_t func) { uint32_t val; - if (func > SIFIVE_PINMUX_IOF1 || pin >= SIFIVE_PINMUX_PINS) { + if (func > SIFIVE_PINMUX_IOF1 || pin >= MAX_PIN_NUM) { return -EINVAL; } diff --git a/soc/riscv/sifive_freedom/e300/soc.h b/soc/riscv/sifive_freedom/e300/soc.h index 3c29efb2a7..1194790baf 100644 --- a/soc/riscv/sifive_freedom/e300/soc.h +++ b/soc/riscv/sifive_freedom/e300/soc.h @@ -11,9 +11,6 @@ #ifndef __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_ #define __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_ -/* PINMUX MAX PINS */ -#define SIFIVE_PINMUX_PINS 32 - /* Clock controller. */ #define PRCI_BASE_ADDR 0x10008000 diff --git a/soc/riscv/sifive_freedom/u500/soc.h b/soc/riscv/sifive_freedom/u500/soc.h index 1e18850787..35526ed43b 100644 --- a/soc/riscv/sifive_freedom/u500/soc.h +++ b/soc/riscv/sifive_freedom/u500/soc.h @@ -14,9 +14,6 @@ /* Clock controller. */ #define PRCI_BASE_ADDR 0x10000000 -/* PINMUX MAX PINS */ -#define SIFIVE_PINMUX_PINS 16 - /* * On FE310 and FU540, peripherals such as SPI, UART, I2C and PWM are clocked * by TLCLK, which is derived from CORECLK. diff --git a/soc/riscv/sifive_freedom/u700/soc.h b/soc/riscv/sifive_freedom/u700/soc.h index 2f15ba3b1c..aaaa13edb9 100644 --- a/soc/riscv/sifive_freedom/u700/soc.h +++ b/soc/riscv/sifive_freedom/u700/soc.h @@ -14,9 +14,6 @@ /* Clock controller. */ #define PRCI_BASE_ADDR 0x10000000 -/* PINMUX MAX PINS */ -#define SIFIVE_PINMUX_PINS 16 - /* On FU740, peripherals are clocked by PCLK. */ #define SIFIVE_PERIPHERAL_CLOCK_FREQUENCY \ DT_PROP(DT_NODELABEL(pclk), clock_frequency)