boards: imx93_evk: add board.c to control board muxes
i.MX 93 EVK has a series of digital MUXes controlled by ADP5585 GPIO expander. This commit adds board level initialization to such MUXes to control these MUXes. Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
This commit is contained in:
parent
6925692902
commit
10e4d091a2
6 changed files with 127 additions and 10 deletions
|
@ -1 +1,4 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
zephyr_library()
|
||||||
|
zephyr_library_sources(board.c)
|
||||||
|
|
16
boards/nxp/imx93_evk/Kconfig
Normal file
16
boards/nxp/imx93_evk/Kconfig
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# i.MX 93 EVK board configuration
|
||||||
|
|
||||||
|
# Copyright 2024 NXP
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config BOARD_MIMX93_EVK_EXP_SEL_INIT
|
||||||
|
bool "Configure i.MX 93 EVK board mux control during init"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config BOARD_MIMX93_EVK_EXP_SEL_INIT_PRIO
|
||||||
|
int "i.MX 93 EVK board mux control init priority"
|
||||||
|
default 60
|
||||||
|
|
||||||
|
module = BOARD_MIMX93_EVK
|
||||||
|
module-str = Board Control
|
||||||
|
source "subsys/logging/Kconfig.template.log_config"
|
|
@ -5,6 +5,20 @@ if BOARD_IMX93_EVK
|
||||||
|
|
||||||
if BOARD_IMX93_EVK_MIMX9352_A55
|
if BOARD_IMX93_EVK_MIMX9352_A55
|
||||||
|
|
||||||
|
if BOARD_MIMX93_EVK_EXP_SEL_INIT
|
||||||
|
|
||||||
|
# Enable I2C, MFD, MFD_APD5585 and GPIO_ADP5585
|
||||||
|
config GPIO
|
||||||
|
default y
|
||||||
|
|
||||||
|
config MFD_ADP5585_INIT_PRIORITY
|
||||||
|
default 55
|
||||||
|
|
||||||
|
config GPIO_ADP5585_INIT_PRIORITY
|
||||||
|
default 56
|
||||||
|
|
||||||
|
endif # BOARD_MIMX93_EVK_EXP_SEL_INIT
|
||||||
|
|
||||||
if NETWORKING
|
if NETWORKING
|
||||||
|
|
||||||
config NET_L2_ETHERNET
|
config NET_L2_ETHERNET
|
||||||
|
|
60
boards/nxp/imx93_evk/board.c
Normal file
60
boards/nxp/imx93_evk/board.c
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2024 NXP
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
#include <zephyr/init.h>
|
||||||
|
#include <zephyr/devicetree.h>
|
||||||
|
#include <zephyr/logging/log.h>
|
||||||
|
#include <zephyr/drivers/gpio.h>
|
||||||
|
|
||||||
|
LOG_MODULE_REGISTER(board_control, CONFIG_BOARD_MIMX93_EVK_LOG_LEVEL);
|
||||||
|
|
||||||
|
#if DT_HAS_COMPAT_STATUS_OKAY(imx93evk_exp_sel) && \
|
||||||
|
IS_ENABLED(CONFIG_BOARD_MIMX93_EVK_EXP_SEL_INIT)
|
||||||
|
|
||||||
|
#define BOARD_EXP_SEL_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(imx93evk_exp_sel)
|
||||||
|
|
||||||
|
#define BOARD_EXP_SEL_MUX_A (0U)
|
||||||
|
#define BOARD_EXP_SEL_MUX_B (1U)
|
||||||
|
|
||||||
|
static int board_init_exp_sel(void)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
const struct gpio_dt_spec mux =
|
||||||
|
GPIO_DT_SPEC_GET(BOARD_EXP_SEL_NODE, mux_gpios);
|
||||||
|
uint32_t pin_state = DT_ENUM_IDX(BOARD_EXP_SEL_NODE, mux);
|
||||||
|
|
||||||
|
if (!gpio_is_ready_dt(&mux)) {
|
||||||
|
LOG_ERR("EXP_SEL Pin port is not ready");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_CAN)
|
||||||
|
if (pin_state != BOARD_EXP_SEL_MUX_A) {
|
||||||
|
LOG_WRN("CAN is enabled, EXP_SEL overrides to A");
|
||||||
|
pin_state = BOARD_EXP_SEL_MUX_A;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN */
|
||||||
|
|
||||||
|
rc = gpio_pin_configure_dt(&mux, pin_state);
|
||||||
|
if (rc) {
|
||||||
|
LOG_ERR("Write EXP_SEL Pin error %d", rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
LOG_INF("EXP_SEL mux %c with priority %d",
|
||||||
|
pin_state ? 'B' : 'A',
|
||||||
|
CONFIG_BOARD_MIMX93_EVK_EXP_SEL_INIT_PRIO
|
||||||
|
);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SYS_INIT(board_init_exp_sel, POST_KERNEL, CONFIG_BOARD_MIMX93_EVK_EXP_SEL_INIT_PRIO);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* DT_HAS_COMPAT_STATUS_OKAY(imx93evk_exp_sel) && \
|
||||||
|
* IS_ENABLED(CONFIG_BOARD_MIMX93_EVK_EXP_SEL_INIT)
|
||||||
|
*/
|
25
boards/nxp/imx93_evk/dts/bindings/imx93evk-exp-sel.yaml
Normal file
25
boards/nxp/imx93_evk/dts/bindings/imx93evk-exp-sel.yaml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Copyright 2024 NXP
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
description: |
|
||||||
|
The i.MX 93 EVK boards has a series of MUXes that selects between 2 pin
|
||||||
|
functions. They are controlled by EXP_SEL signal from gpio_exp0, an
|
||||||
|
ADP5585 GPIO expander.
|
||||||
|
|
||||||
|
compatible: "imx93evk-exp-sel"
|
||||||
|
|
||||||
|
include: base.yaml
|
||||||
|
|
||||||
|
properties:
|
||||||
|
mux-gpios:
|
||||||
|
type: phandle-array
|
||||||
|
required: true
|
||||||
|
description: Pin used to select the MUX
|
||||||
|
|
||||||
|
mux:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
enum:
|
||||||
|
- "A"
|
||||||
|
- "B"
|
||||||
|
description: MUX choice
|
|
@ -64,6 +64,12 @@
|
||||||
gpios = <&gpio2 24 GPIO_ACTIVE_LOW>;
|
gpios = <&gpio2 24 GPIO_ACTIVE_LOW>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
board_exp_sel: board-exp-sel {
|
||||||
|
compatible = "imx93evk-exp-sel";
|
||||||
|
mux-gpios = <&gpio_exp0 4 GPIO_ACTIVE_HIGH>;
|
||||||
|
mux = "A";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
&enet {
|
&enet {
|
||||||
|
@ -115,7 +121,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
&lpi2c2 {
|
&lpi2c2 {
|
||||||
status = "disabled";
|
status = "okay";
|
||||||
clock-frequency = <I2C_BITRATE_FAST>;
|
clock-frequency = <I2C_BITRATE_FAST>;
|
||||||
pinctrl-0 = <&i2c2_default>;
|
pinctrl-0 = <&i2c2_default>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
|
@ -123,7 +129,7 @@
|
||||||
mfd0:adp5585@34 {
|
mfd0:adp5585@34 {
|
||||||
compatible = "adi,adp5585";
|
compatible = "adi,adp5585";
|
||||||
reg = <0x34>;
|
reg = <0x34>;
|
||||||
status = "disabled";
|
status = "okay";
|
||||||
|
|
||||||
gpio_exp0: adp5585_gpio {
|
gpio_exp0: adp5585_gpio {
|
||||||
compatible = "adi,adp5585-gpio";
|
compatible = "adi,adp5585-gpio";
|
||||||
|
@ -131,19 +137,12 @@
|
||||||
#gpio-cells = <2>;
|
#gpio-cells = <2>;
|
||||||
ngpios = <13>;
|
ngpios = <13>;
|
||||||
gpio-reserved-ranges = <5 3>;
|
gpio-reserved-ranges = <5 3>;
|
||||||
|
status = "okay";
|
||||||
/*
|
/*
|
||||||
* This device has non-contiguous gpio range:
|
* This device has non-contiguous gpio range:
|
||||||
* GPIO Pin R0~R4 are gpio0~4
|
* GPIO Pin R0~R4 are gpio0~4
|
||||||
* GPIO Pin C0~C4 are gpio8~12
|
* GPIO Pin C0~C4 are gpio8~12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gpiohog_exp_sel: exp-sel-hog {
|
|
||||||
gpio-hog;
|
|
||||||
gpios = <4 GPIO_ACTIVE_HIGH>;
|
|
||||||
line-name = "exp_sel";
|
|
||||||
output-low;
|
|
||||||
};
|
|
||||||
status = "disabled";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue