drivers: pinctrl: sifive: use DT ngpios property
Instead of hardcoded definitions from soc.h. Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
parent
3381fb4b3d
commit
7e3b3dd258
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
|
#define MAX_PIN_NUM DT_PROP(DT_INST_PARENT(0), ngpios)
|
||||||
#define PINCTRL_BASE_ADDR DT_INST_REG_ADDR(0)
|
#define PINCTRL_BASE_ADDR DT_INST_REG_ADDR(0)
|
||||||
#define PINCTRL_IOF_EN (PINCTRL_BASE_ADDR + 0x0)
|
#define PINCTRL_IOF_EN (PINCTRL_BASE_ADDR + 0x0)
|
||||||
#define PINCTRL_IOF_SEL (PINCTRL_BASE_ADDR + 0x4)
|
#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;
|
uint32_t val;
|
||||||
|
|
||||||
if (func > SIFIVE_PINMUX_IOF1 || pin >= SIFIVE_PINMUX_PINS) {
|
if (func > SIFIVE_PINMUX_IOF1 || pin >= MAX_PIN_NUM) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
#ifndef __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_
|
#ifndef __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_
|
||||||
#define __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_
|
#define __RISCV_SIFIVE_FREEDOM_FE300_SOC_H_
|
||||||
|
|
||||||
/* PINMUX MAX PINS */
|
|
||||||
#define SIFIVE_PINMUX_PINS 32
|
|
||||||
|
|
||||||
/* Clock controller. */
|
/* Clock controller. */
|
||||||
#define PRCI_BASE_ADDR 0x10008000
|
#define PRCI_BASE_ADDR 0x10008000
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
/* Clock controller. */
|
/* Clock controller. */
|
||||||
#define PRCI_BASE_ADDR 0x10000000
|
#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
|
* On FE310 and FU540, peripherals such as SPI, UART, I2C and PWM are clocked
|
||||||
* by TLCLK, which is derived from CORECLK.
|
* by TLCLK, which is derived from CORECLK.
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
/* Clock controller. */
|
/* Clock controller. */
|
||||||
#define PRCI_BASE_ADDR 0x10000000
|
#define PRCI_BASE_ADDR 0x10000000
|
||||||
|
|
||||||
/* PINMUX MAX PINS */
|
|
||||||
#define SIFIVE_PINMUX_PINS 16
|
|
||||||
|
|
||||||
/* On FU740, peripherals are clocked by PCLK. */
|
/* On FU740, peripherals are clocked by PCLK. */
|
||||||
#define SIFIVE_PERIPHERAL_CLOCK_FREQUENCY \
|
#define SIFIVE_PERIPHERAL_CLOCK_FREQUENCY \
|
||||||
DT_PROP(DT_NODELABEL(pclk), clock_frequency)
|
DT_PROP(DT_NODELABEL(pclk), clock_frequency)
|
||||||
|
|
Loading…
Reference in a new issue