mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 18:27:56 +08:00
arch/arm64: porting config iomux use scmi form arm imx95
pinctrl use same format scmi and config regs Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
This commit is contained in:
@@ -531,6 +531,10 @@ config IMX9_CLK_OVER_SCMI
|
||||
bool "Configure CLK over SCMI"
|
||||
default y
|
||||
|
||||
config IMX9_IOMUX_OVER_SCMI
|
||||
bool "Configure IOMUX over SCMI"
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
menu "LPI2C Peripherals"
|
||||
|
||||
@@ -31,10 +31,11 @@ endif
|
||||
CHIP_CSRCS = imx9_boot.c imx9_timer.c
|
||||
|
||||
ifeq ($(CONFIG_ARCH_CHIP_IMX93),y)
|
||||
CHIP_CSRCS += imx9_ccm.c imx9_gpio.c imx9_iomuxc.c
|
||||
CHIP_CSRCS += imx9_ccm.c imx9_gpio.c
|
||||
endif
|
||||
|
||||
CHIP_CSRCS += imx9_lpuart.c imx9_lowputc.c imx9_clockconfig.c
|
||||
CHIP_CSRCS += imx9_iomuxc.c
|
||||
|
||||
ifeq ($(CONFIG_IMX9_GPIO_IRQ),y)
|
||||
CHIP_CSRCS += imx9_gpioirq.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,7 @@
|
||||
#if defined(CONFIG_ARCH_CHIP_IMX93)
|
||||
# include "hardware/imx93/imx93_iomux.h"
|
||||
#elif defined(CONFIG_ARCH_CHIP_IMX95)
|
||||
#else
|
||||
# error Unrecognized i.MX9 architecture
|
||||
# include "hardware/imx95/imx95_iomuxc.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
#include "arm64_internal.h"
|
||||
#include "imx9_iomuxc.h"
|
||||
|
||||
#ifdef CONFIG_IMX9_IOMUX_OVER_SCMI
|
||||
|
||||
#include "imx9_scmi.h"
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -51,8 +57,91 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_IMX9_IOMUX_OVER_SCMI
|
||||
|
||||
/* Sets the IOMUXC pin mux mode.
|
||||
*/
|
||||
|
||||
void imx9_sm_iomucx_configure(scmi_pinctrl_t *pinctrl)
|
||||
{
|
||||
scmi_pin_config_t configs[4];
|
||||
uint32_t num_configs = 0;
|
||||
uint32_t channel = pinctrl->channel;
|
||||
uint32_t mux_register = pinctrl->mux_register;
|
||||
uint32_t mux_mode = pinctrl->mux_mode;
|
||||
uint32_t input_register = pinctrl->input_register;
|
||||
uint32_t input_daisy = pinctrl->input_daisy;
|
||||
uint32_t input_on_field = pinctrl->input_on_field;
|
||||
uint32_t config_register = pinctrl->config_register;
|
||||
uint32_t config_value = pinctrl->config_value;
|
||||
|
||||
if (mux_register)
|
||||
{
|
||||
configs[num_configs].type = SCMI_PINCTRL_TYPE_MUX;
|
||||
configs[num_configs].value = SCMI_PLATFORM_PINCTRL_MUX_MODE(mux_mode)
|
||||
| SCMI_PLATFORM_PINCTRL_SION(
|
||||
input_on_field);
|
||||
num_configs++;
|
||||
}
|
||||
|
||||
if (input_register & 0xffff)
|
||||
{
|
||||
configs[num_configs].type = SCMI_PINCTRL_TYPE_DAISY_ID;
|
||||
configs[num_configs].value =
|
||||
(input_register - SCMI_PLATFORM_PINCTRL_DAISYREG_OFF) / 4;
|
||||
num_configs++;
|
||||
configs[num_configs].type = SCMI_PINCTRL_TYPE_DAISY_CFG;
|
||||
configs[num_configs].value = input_daisy;
|
||||
num_configs++;
|
||||
}
|
||||
|
||||
if (config_register)
|
||||
{
|
||||
configs[num_configs].type = SCMI_PINCTRL_TYPE_CONFIG;
|
||||
configs[num_configs].value = config_value;
|
||||
num_configs++;
|
||||
}
|
||||
|
||||
if (mux_register || input_register)
|
||||
{
|
||||
uint32_t attributes = SCMI_PINCTRL_SET_ATTR_SELECTOR(
|
||||
SCMI_PINCTRL_SEL_PIN)
|
||||
| SCMI_PINCTRL_SET_ATTR_NUM_CONFIGS(
|
||||
num_configs);
|
||||
|
||||
int32_t ret = imx9_scmi_set_pinctrl_config(
|
||||
channel, (mux_register - SCMI_PLATFORM_PINCTRL_MUXREG_OFF) / 4,
|
||||
attributes, configs);
|
||||
if (ret != 0)
|
||||
{
|
||||
assert("Unable to set iomux over SCMI");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int imx9_iomux_configure(iomux_cfg_t cfg)
|
||||
{
|
||||
#ifdef CONFIG_IMX9_IOMUX_OVER_SCMI
|
||||
|
||||
scmi_pinctrl_t pinctrl =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
pinctrl.channel = SCMI_PLATFORM_A2P;
|
||||
pinctrl.mux_register = cfg.padcfg.ctlreg;
|
||||
pinctrl.mux_mode = cfg.padcfg.mode;
|
||||
pinctrl.input_register = cfg.padcfg.dsy;
|
||||
pinctrl.input_daisy = cfg.padcfg.dsy;
|
||||
pinctrl.config_register = cfg.padcfg.padreg;
|
||||
pinctrl.config_value = cfg.pad;
|
||||
pinctrl.input_on_field = cfg.mux;
|
||||
imx9_sm_iomucx_configure(&pinctrl);
|
||||
|
||||
#else
|
||||
|
||||
if (!cfg.padcfg.ctlreg)
|
||||
{
|
||||
return -EINVAL;
|
||||
@@ -70,9 +159,13 @@ int imx9_iomux_configure(iomux_cfg_t cfg)
|
||||
putreg32(cfg.pad, cfg.padcfg.padreg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_IMX9_IOMUX_OVER_SCMI
|
||||
|
||||
/****************************************************************************
|
||||
* Name: imx9_iomux_configure
|
||||
*
|
||||
@@ -116,3 +209,5 @@ int imx9_iomux_gpio(iomux_cfg_t cfg, bool sion)
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,6 +84,7 @@ struct iomux_cfg_s
|
||||
uint32_t pad;
|
||||
uint32_t mux;
|
||||
};
|
||||
|
||||
typedef struct iomux_cfg_s iomux_cfg_t;
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include "hardware/imx95/imx95_memorymap.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
Reference in New Issue
Block a user