Browse Source

drivers: pinctrl: pinctrl driver

Add pinctrl driver for ENE KB106X

Signed-off-by: Steven Chang <steven@ene.com.tw>
pull/74835/merge
Steven Chang 2 weeks ago committed by Benjamin Cabé
parent
commit
d9310b6648
  1. 1
      drivers/pinctrl/CMakeLists.txt
  2. 13
      drivers/pinctrl/Kconfig.ene
  3. 223
      drivers/pinctrl/pinctrl_ene_kb106x.c
  4. 7
      dts/arm/ene/kb106x/kb1062-pinctrl.dtsi
  5. 49
      dts/arm/ene/kb106x/kb1064-pinctrl.dtsi
  6. 641
      dts/arm/ene/kb106x/kb106x-pinctrl.dtsi
  7. 8
      dts/arm/ene/kb106x/kb106x.dtsi
  8. 102
      dts/bindings/pinctrl/ene,kb106x-pinctrl.yaml
  9. 53
      include/zephyr/dt-bindings/pinctrl/ene-kb106x-pinctrl.h
  10. 55
      soc/ene/kb106x/common/pinctrl_soc.h

1
drivers/pinctrl/CMakeLists.txt

@ -46,6 +46,7 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_TI_CC32XX pinctrl_ti_cc32xx.c) @@ -46,6 +46,7 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_TI_CC32XX pinctrl_ti_cc32xx.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_NUMAKER pinctrl_numaker.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_QUICKLOGIC_EOS_S3 pinctrl_eos_s3.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_MCI_IO_MUX pinctrl_mci_io_mux.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_ENE_KB106X pinctrl_ene_kb106x.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_ENE_KB1200 pinctrl_ene_kb1200.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_IMX_SCU pinctrl_imx_scu.c)
zephyr_library_sources_ifdef(CONFIG_PINCTRL_MAX32 pinctrl_max32.c)

13
drivers/pinctrl/Kconfig.ene

@ -7,3 +7,16 @@ config PINCTRL_ENE_KB1200 @@ -7,3 +7,16 @@ config PINCTRL_ENE_KB1200
depends on DT_HAS_ENE_KB1200_PINCTRL_ENABLED
help
Enable pin controller driver for ENE KB1200 MCUs
config PINCTRL_ENE_KB106X
bool "ENE KB106X Pin controller driver"
default y
depends on DT_HAS_ENE_KB106X_PINCTRL_ENABLED
help
Enable pin controller driver for ENE KB106X MCUs
config PINCTRL_ENE_KB106X_ALT_OUTPUT_LOOKBACK
bool "ENE KB106X Pin controller alt-output lookback"
depends on PINCTRL_ENE_KB106X
help
Enable alt-output lookback for ENE KB106X MCUs

223
drivers/pinctrl/pinctrl_ene_kb106x.c

@ -0,0 +1,223 @@ @@ -0,0 +1,223 @@
/*
* Copyright (c) ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT ene_kb106x_pinctrl
#include <zephyr/devicetree.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/sys/util_macro.h>
#include <zephyr/dt-bindings/pinctrl/ene-kb106x-pinctrl.h>
#include <zephyr/sys/util.h>
#include <reg/gcfg.h>
#include <reg/gpio.h>
/*
* PINMUX_FUNC_A : GPIO Function
* PINMUX_FUNC_B : AltOutput 1 Function
* PINMUX_FUNC_C : AltOutput 2 Function
* PINMUX_FUNC_D : AltOutput 3 Function
* PINMUX_FUNC_E : AltOutput 4 Function
*
* GPIO Alternate Output Function Selection
* (PINMUX_FUNC_A) (PINMUX_FUNC_B) (PINMUX_FUNC_C) (PINMUX_FUNC_D) (PINMUX_FUNC_E)
* GPIO0B ESBCLK SCL5
* GPIO0C ESBDAT SDA5
* GPIO0D RLC_TX2 SDA4
* GPIO16 SER_TXD UART_SOUT SBUD_CLK
* GPIO17 SER_RXD UART_SIN SBUD_DAT
* GPIO19 PWM3 PWMLED0
* GPIO30 SER_TXD NKROKSI0
* GPIO48 KSO16 UART_SOUT2
* GPIO4C PSCLK2 SCL3
* GPIO4D SDAT2 SDA3
* GPIO4E PSCLK3 KSO18
* GPIO4F PSDAT3 KSO19
* GPIO4A PSCLK1 SCL2 USBDM
* GPIO4B PSDAT1 SDA2 USBDP
* GPIO01 ESPI_ALERT
* GPIO03 ESPI_CS
* GPIO07 ESPI_RST
*/
/*
* f is function number
* b[7:5] = pin bank
* b[4:0] = pin position in bank
* b[11:8] = function
*/
#define ENE_KB106X_PINMUX_PIN(p) FIELD_GET(GENMASK(4, 0), p)
#define ENE_KB106X_PINMUX_PORT(p) FIELD_GET(GENMASK(7, 5), p)
#define ENE_KB106X_PINMUX_FUNC(p) FIELD_GET(GENMASK(11, 8), p)
#define ENE_KB106X_PINMUX_PORT_PIN(p) FIELD_GET(GENMASK(7, 0), p)
static const uint32_t gcfg_reg_addr = DT_REG_ADDR_BY_NAME(DT_NODELABEL(gcfg), gcfg);
static const uint32_t gpio_reg_bases[] = {
DT_REG_ADDR(DT_NODELABEL(gpio0x1x)),
DT_REG_ADDR(DT_NODELABEL(gpio2x3x)),
DT_REG_ADDR(DT_NODELABEL(gpio4x5x)),
DT_REG_ADDR(DT_NODELABEL(gpio6x7x)),
DT_REG_ADDR(DT_NODELABEL(egpio0x1x)),
};
static int kb106x_config_pin(uint32_t gpio, uint32_t conf, uint32_t func)
{
uint32_t port = ENE_KB106X_PINMUX_PORT(gpio);
uint32_t pin = (uint32_t)ENE_KB106X_PINMUX_PIN(gpio);
struct gpio_regs *gpio_regs = (struct gpio_regs *)gpio_reg_bases[port];
struct gcfg_regs *gcfg_regs = (struct gcfg_regs *)gcfg_reg_addr;
if (port >= ARRAY_SIZE(gpio_reg_bases)) {
return -EINVAL;
}
if (func == PINMUX_FUNC_GPIO) {
/* only GPIO function */
WRITE_BIT(gpio_regs->GPIOFS, pin, 0);
} else {
func -= 1;
/*for change to GPIOALT setting value*/
switch (gpio) {
case GPIO0B_ESBCLK_SCL5:
WRITE_BIT(gcfg_regs->GPIOALT, 0, func);
break;
case GPIO0C_ESBDAT_SDA5:
WRITE_BIT(gcfg_regs->GPIOALT, 1, func);
break;
case GPIO0D_RLCTX2_SDA4:
WRITE_BIT(gcfg_regs->GPIOALT, 2, func);
break;
case GPIO16_SERTXD_UARTSOUT_SBUDCLK:
case GPIO17_SERRXD_UARTSIN_SBUDDAT:
gcfg_regs->GPIOMUX = (gcfg_regs->GPIOMUX & ~(3 << 9)) | (func << 9);
break;
case GPIO19_PWM3_PWMLED0:
WRITE_BIT(gcfg_regs->GPIOALT, 3, func);
break;
case GPIO30_SERTXD_NKROKSI0:
WRITE_BIT(gcfg_regs->GPIOALT, 5, func);
break;
case GPIO48_KSO16_UART_SOUT2:
WRITE_BIT(gcfg_regs->GPIOALT, 6, func);
break;
case GPIO4C_PSCLK2_SCL3:
WRITE_BIT(gcfg_regs->GPIOALT, 7, func);
break;
case GPIO4D_SDAT2_SDA3:
WRITE_BIT(gcfg_regs->GPIOALT, 8, func);
break;
case GPIO4E_PSCLK3_KSO18:
WRITE_BIT(gcfg_regs->GPIOALT, 9, func);
break;
case GPIO4F_PSDAT3_KSO19:
WRITE_BIT(gcfg_regs->GPIOALT, 10, func);
break;
case GPIO4A_PSCLK1_SCL2_USBDM:
gcfg_regs->GPIOALT = (gcfg_regs->GPIOALT & ~(3 << 24)) | (func << 24);
break;
case GPIO4B_PSDAT1_SDA2_USBDP:
gcfg_regs->GPIOALT = (gcfg_regs->GPIOALT & ~(3 << 26)) | (func << 26);
break;
case GPIO60_SHICS:
case GPIO61_SHICLK:
case GPIO62_SHIDO:
case GPIO78_SHIDI:
gcfg_regs->GPIOMUX = (gcfg_regs->GPIOMUX & ~(3 << 0)) | (3 << 0);
break;
case GPIO5A_SHR_SPICS:
case GPIO58_SHR_SPICLK:
case GPIO5C_SHR_MOSI:
case GPIO5B_SHR_MISO:
gcfg_regs->GPIOMUX = (gcfg_regs->GPIOMUX & ~(3 << 0)) | (2 << 0);
break;
case GPIO01_ESPI_ALERT:
case GPIO03_ESPI_CS:
case GPIO07_ESPI_RST:
WRITE_BIT(gcfg_regs->GPIOALT, 3, func);
break;
default:
break;
}
WRITE_BIT(gpio_regs->GPIOFS, pin, 1);
#ifdef CONFIG_PINCTRL_ENE_KB106X_ALT_OUTPUT_LOOKBACK
/* default Input always enable for loopback */
WRITE_BIT(gpio_regs->GPIOIE, pin, 1);
#endif /* CONFIG_PINCTRL_ENE_KB106X_ALT_OUTPUT_LOOKBACK */
}
/* pull-up/pull-down function */
if (conf & BIT(ENE_KB106X_NO_PUD_POS)) {
WRITE_BIT(gpio_regs->GPIOPU, pin, 0);
}
if (conf & BIT(ENE_KB106X_PU_POS)) {
WRITE_BIT(gpio_regs->GPIOPU, pin, 1);
}
if (conf & BIT(ENE_KB106X_PD_POS)) {
/* KB106x not support */
}
/* output high/low, output type function */
if (conf & BIT(ENE_KB106X_OUT_LO_POS)) {
WRITE_BIT(gpio_regs->GPIOD, pin, 0);
}
if (conf & BIT(ENE_KB106X_OUT_HI_POS)) {
WRITE_BIT(gpio_regs->GPIOD, pin, 1);
}
if (conf & BIT(ENE_KB106X_PUSH_PULL_POS)) {
WRITE_BIT(gpio_regs->GPIOOD, pin, 0);
}
if (conf & BIT(ENE_KB106X_OUT_DIS_POS)) {
WRITE_BIT(gpio_regs->GPIOOE, pin, 0);
WRITE_BIT(gpio_regs->GPIOOD, pin, 0);
}
if (conf & BIT(ENE_KB106X_OUT_EN_POS)) {
if (conf & BIT(ENE_KB106X_OPEN_DRAIN_POS)) {
WRITE_BIT(gpio_regs->GPIOOD, pin, 1);
}
WRITE_BIT(gpio_regs->GPIOOE, pin, 1);
}
/* low voltage mode(support 1.8v Vih/Vil) */
if (conf & BIT(ENE_KB106X_PIN_LOW_POWER_POS)) {
WRITE_BIT(gpio_regs->GPIOLV, pin, 1);
}
/* input function */
if (conf & BIT(ENE_KB106X_IN_DIS_POS)) {
WRITE_BIT(gpio_regs->GPIOIE, pin, 0);
}
if (conf & BIT(ENE_KB106X_IN_EN_POS)) {
WRITE_BIT(gpio_regs->GPIOIE, pin, 1);
}
/* drive strength function(4mA/16mA) */
if (conf & BIT(ENE_KB106X_DRIVING_POS)) {
WRITE_BIT(gpio_regs->GPIODC, pin, 1);
} else {
WRITE_BIT(gpio_regs->GPIODC, pin, 0);
}
return 0;
}
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
{
uint32_t portpin, pinmux, func;
int ret;
ARG_UNUSED(reg);
for (uint8_t i = 0U; i < pin_cnt; i++) {
pinmux = pins[i];
func = ENE_KB106X_PINMUX_FUNC(pinmux);
if (func >= PINMUX_FUNC_MAX) {
return -EINVAL;
}
portpin = ENE_KB106X_PINMUX_PORT_PIN(pinmux);
ret = kb106x_config_pin(portpin, pinmux, func);
if (ret < 0) {
return ret;
}
}
return 0;
}

7
dts/arm/ene/kb106x/kb1062-pinctrl.dtsi

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
/*
* Copyright (c) 2025 ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <arm/ene/kb106x/kb106x-pinctrl.dtsi>

49
dts/arm/ene/kb106x/kb1064-pinctrl.dtsi

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
/*
* Copyright (c) 2025 ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <arm/ene/kb106x/kb106x-pinctrl.dtsi>
&pinctrl {
/omit-if-no-ref/ pwm4_egpio00: pwm4_egpio00 {
pinmux = <ENE_KB106X_PINMUX(0x80, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm5_egpio01: pwm5_egpio01 {
pinmux = <ENE_KB106X_PINMUX(0x81, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm8_egpio04: pwm8_egpio04 {
pinmux = <ENE_KB106X_PINMUX(0x84, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm9_egpio05: pwm9_egpio05 {
pinmux = <ENE_KB106X_PINMUX(0x85, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm10_egpio06: pwm10_egpio06 {
pinmux = <ENE_KB106X_PINMUX(0x86, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm11_egpio07: pwm11_egpio07 {
pinmux = <ENE_KB106X_PINMUX(0x87, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm12_egpio08: pwm12_egpio08 {
pinmux = <ENE_KB106X_PINMUX(0x88, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm13_egpio09: pwm13_egpio09 {
pinmux = <ENE_KB106X_PINMUX(0x89, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm14_egpio0a: pwm14_egpio0a {
pinmux = <ENE_KB106X_PINMUX(0x8a, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm15_egpio0b: pwm15_egpio0b {
pinmux = <ENE_KB106X_PINMUX(0x8b, PINMUX_FUNC_B)>;
};
};

641
dts/arm/ene/kb106x/kb106x-pinctrl.dtsi

@ -0,0 +1,641 @@ @@ -0,0 +1,641 @@
/*
* Copyright (c) 2025 ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pinctrl/ene-kb106x-pinctrl.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
&pinctrl {
/* serial port */
/omit-if-no-ref/ ser0_tx_gpio16: ser0_tx_gpio16 {
pinmux = <ENE_KB106X_PINMUX(0x16, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ ser0_tx_gpio30: ser0_tx_gpio30 {
pinmux = <ENE_KB106X_PINMUX(0x30, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ ser0_rx_gpio17: ser0_rx_gpio17 {
pinmux = <ENE_KB106X_PINMUX(0x17, PINMUX_FUNC_A)>;
input-enable;
};
/* adc */
/omit-if-no-ref/ adc0_gpio38: adc0_gpio38 {
pinmux = <ENE_KB106X_PINMUX(0x38, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc1_gpio39: adc1_gpio39 {
pinmux = <ENE_KB106X_PINMUX(0x39, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc2_gpio3a: adc2_gpio3a {
pinmux = <ENE_KB106X_PINMUX(0x3A, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc3_gpio3b: adc3_gpio3b {
pinmux = <ENE_KB106X_PINMUX(0x3B, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc4_gpio42: adc4_gpio42 {
pinmux = <ENE_KB106X_PINMUX(0x42, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc5_gpio43: adc5_gpio43 {
pinmux = <ENE_KB106X_PINMUX(0x43, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc6_gpio40: adc6_gpio40 {
pinmux = <ENE_KB106X_PINMUX(0x40, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc7_gpio41: adc7_gpio41 {
pinmux = <ENE_KB106X_PINMUX(0x41, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc8_gpio78: adc8_gpio78 {
pinmux = <ENE_KB106X_PINMUX(0x78, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ adc9_gpio65: adc9_gpio65 {
pinmux = <ENE_KB106X_PINMUX(0x65, PINMUX_FUNC_A)>;
};
/* fsmbus */
/omit-if-no-ref/ i2c0_clk_gpio44: i2c0_clk_gpio44 {
pinmux = <ENE_KB106X_PINMUX(0x44, PINMUX_FUNC_B)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c0_dat_gpio45: i2c0_dat_gpio45 {
pinmux = <ENE_KB106X_PINMUX(0x45, PINMUX_FUNC_B)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c1_clk_gpio46: i2c1_clk_gpio46 {
pinmux = <ENE_KB106X_PINMUX(0x46, PINMUX_FUNC_B)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c1_dat_gpio47: i2c1_dat_gpio47 {
pinmux = <ENE_KB106X_PINMUX(0x47, PINMUX_FUNC_B)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c2_clk_gpio4a: i2c2_clk_gpio4a {
pinmux = <ENE_KB106X_PINMUX(0x4A, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c2_dat_gpio4b: i2c2_dat_gpio4b {
pinmux = <ENE_KB106X_PINMUX(0x4B, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c3_clk_gpio4c: i2c3_clk_gpio4c {
pinmux = <ENE_KB106X_PINMUX(0x4C, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c3_dat_gpio4d: i2c3_dat_gpio4d {
pinmux = <ENE_KB106X_PINMUX(0x4D, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c4_clk_gpio08: i2c4_clk_gpio08 {
pinmux = <ENE_KB106X_PINMUX(0x08, PINMUX_FUNC_B)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c4_dat_gpio0d: i2c4_dat_gpio0d {
pinmux = <ENE_KB106X_PINMUX(0x0D, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c5_clk_gpio0b: i2c5_clk_gpio0b {
pinmux = <ENE_KB106X_PINMUX(0x0B, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ i2c5_dat_gpio0c: i2c5_dat_gpio0c {
pinmux = <ENE_KB106X_PINMUX(0x0C, PINMUX_FUNC_C)>;
bias-pull-up;
input-enable;
};
/* spi host - shi pinout */
/omit-if-no-ref/ shi_cs_gpio60: shi_cs_gpio60 {
pinmux = < ENE_KB106X_PINMUX(0x60, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shi_clk_gpio61: shi_clk_gpio61 {
pinmux = < ENE_KB106X_PINMUX(0x61, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shi_mosi_gpio62: shi_mosi_gpio62 {
pinmux = < ENE_KB106X_PINMUX(0x62, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shi_miso_gpio78: shi_miso_gpio78 {
pinmux = < ENE_KB106X_PINMUX(0x78, PINMUX_FUNC_A) >;
input-enable;
};
/omit-if-no-ref/ shi_cs_off_gpio60: shi_cs_off_gpio60 {
pinmux = < ENE_KB106X_PINMUX(0x60, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shi_clk_off_gpio61: shi_clk_off_gpio61 {
pinmux = < ENE_KB106X_PINMUX(0x61, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shi_mosi_off_gpio62: shi_mosi_off_gpio62 {
pinmux = < ENE_KB106X_PINMUX(0x62, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shi_miso_off_gpio78: shi_miso_off_gpio78 {
pinmux = < ENE_KB106X_PINMUX(0x78, PINMUX_FUNC_A) >;
};
/* spi host - share rom pinout */
/omit-if-no-ref/ shr_cs_gpio5a: shr_cs_gpio5a {
pinmux = < ENE_KB106X_PINMUX(0x5A, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shr_clk_gpio58: shr_clk_gpio58 {
pinmux = < ENE_KB106X_PINMUX(0x58, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shr_mosi_gpio5c: shr_mosi_gpio5c {
pinmux = < ENE_KB106X_PINMUX(0x5C, PINMUX_FUNC_B) >;
drive-strength = <16> ;
};
/omit-if-no-ref/ shr_miso_gpio5b: shr_miso_gpio5b {
pinmux = < ENE_KB106X_PINMUX(0x5B, PINMUX_FUNC_A) >;
input-enable;
};
/omit-if-no-ref/ shr_cs_off_gpio5a: shr_cs_off_gpio5a {
pinmux = < ENE_KB106X_PINMUX(0x5A, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shr_clk_off_gpio58: shr_clk_off_gpio58 {
pinmux = < ENE_KB106X_PINMUX(0x58, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shr_mosi_off_gpio5c: shr_mosi_off_gpio5c {
pinmux = < ENE_KB106X_PINMUX(0x5C, PINMUX_FUNC_A) >;
};
/omit-if-no-ref/ shr_miso_off_gpio5b: shr_miso_off_gpio5b {
pinmux = < ENE_KB106X_PINMUX(0x5B, PINMUX_FUNC_A) >;
};
/* pwm */
/omit-if-no-ref/ pwm0_gpio0f: pwm0_gpio0f {
pinmux = <ENE_KB106X_PINMUX(0x0F, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm1_gpio10: pwm1_gpio10 {
pinmux = <ENE_KB106X_PINMUX(0x10, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm2_gpio11: pwm2_gpio11 {
pinmux = <ENE_KB106X_PINMUX(0x11, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ pwm3_gpio19: pwm3_gpio19 {
pinmux = <ENE_KB106X_PINMUX(0x19, PINMUX_FUNC_B)>;
};
/* fan pwm */
/omit-if-no-ref/ fanpwm0_gpio12: fanpwm0_gpio12 {
pinmux = <ENE_KB106X_PINMUX(0x12, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ fanpwm1_gpio13: fanpwm1_gpio13 {
pinmux = <ENE_KB106X_PINMUX(0x13, PINMUX_FUNC_B)>;
};
/* fan tachometer */
/omit-if-no-ref/ tach0_gpio14: tach0_gpio14 {
pinmux = <ENE_KB106X_PINMUX(0x14, PINMUX_FUNC_A)>;
input-enable;
};
/omit-if-no-ref/ tach1_gpio15: tach1_gpio15 {
pinmux = <ENE_KB106X_PINMUX(0x15, PINMUX_FUNC_A)>;
input-enable;
};
/omit-if-no-ref/ tach2_gpio43: tach2_gpio43 {
pinmux = <ENE_KB106X_PINMUX(0x43, PINMUX_FUNC_A)>;
input-enable;
};
/omit-if-no-ref/ tach3_gpio64: tach3_gpio64 {
pinmux = <ENE_KB106X_PINMUX(0x64, PINMUX_FUNC_A)>;
input-enable;
};
/* external clock xclki */
/omit-if-no-ref/ xclki_gpio5d: xclki_gpio5d {
pinmux = <ENE_KB106X_PINMUX(0x5D, PINMUX_FUNC_A)>;
input-enable;
};
/* keyboard ksi */
/omit-if-no-ref/ ksi00_gpio30: ksi00_gpio30 {
pinmux = <ENE_KB106X_PINMUX(0x30, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi01_gpio31: ksi01_gpio31 {
pinmux = <ENE_KB106X_PINMUX(0x31, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi02_gpio32: ksi02_gpio32 {
pinmux = <ENE_KB106X_PINMUX(0x32, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi03_gpio33: ksi03_gpio33 {
pinmux = <ENE_KB106X_PINMUX(0x33, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi04_gpio34: ksi04_gpio34 {
pinmux = <ENE_KB106X_PINMUX(0x34, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi05_gpio35: ksi05_gpio35 {
pinmux = <ENE_KB106X_PINMUX(0x35, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi06_gpio36: ksi06_gpio36 {
pinmux = <ENE_KB106X_PINMUX(0x36, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/omit-if-no-ref/ ksi07_gpio37: ksi07_gpio37 {
pinmux = <ENE_KB106X_PINMUX(0x37, PINMUX_FUNC_A)>;
bias-pull-up;
input-enable;
};
/* keyboard kso */
/omit-if-no-ref/ kso00_gpio20: kso00_gpio20 {
pinmux = <ENE_KB106X_PINMUX(0x20, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso01_gpio21: kso01_gpio21 {
pinmux = <ENE_KB106X_PINMUX(0x21, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso02_gpio22: kso02_gpio22 {
pinmux = <ENE_KB106X_PINMUX(0x22, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso03_gpio23: kso03_gpio23 {
pinmux = <ENE_KB106X_PINMUX(0x23, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso04_gpio24: kso04_gpio24 {
pinmux = <ENE_KB106X_PINMUX(0x24, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso05_gpio25: kso05_gpio25 {
pinmux = <ENE_KB106X_PINMUX(0x25, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso06_gpio26: kso06_gpio26 {
pinmux = <ENE_KB106X_PINMUX(0x26, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso07_gpio27: kso07_gpio27 {
pinmux = <ENE_KB106X_PINMUX(0x27, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso08_gpio28: kso08_gpio28 {
pinmux = <ENE_KB106X_PINMUX(0x28, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso09_gpio29: kso09_gpio29 {
pinmux = <ENE_KB106X_PINMUX(0x29, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso10_gpio2a: kso10_gpio2a {
pinmux = <ENE_KB106X_PINMUX(0x2A, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso11_gpio2b: kso11_gpio2b {
pinmux = <ENE_KB106X_PINMUX(0x2B, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso12_gpio2c: kso12_gpio2c {
pinmux = <ENE_KB106X_PINMUX(0x2C, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso13_gpio2d: kso13_gpio2d {
pinmux = <ENE_KB106X_PINMUX(0x2D, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso14_gpio2e: kso14_gpio2e {
pinmux = <ENE_KB106X_PINMUX(0x2E, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso15_gpio2f: kso15_gpio2f {
pinmux = <ENE_KB106X_PINMUX(0x2F, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso16_gpio48: kso16_gpio48 {
pinmux = <ENE_KB106X_PINMUX(0x48, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso17_gpio49: kso17_gpio49 {
pinmux = <ENE_KB106X_PINMUX(0x49, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ kso18_gpio4e: kso18_gpio4e {
pinmux = <ENE_KB106X_PINMUX(0x4E, PINMUX_FUNC_C)>;
};
/omit-if-no-ref/ kso19_gpio4f: kso19_gpio4f {
pinmux = <ENE_KB106X_PINMUX(0x4F, PINMUX_FUNC_C)>;
};
/omit-if-no-ref/ kso20_gpio52: kso20_gpio52 {
pinmux = <ENE_KB106X_PINMUX(0x52, PINMUX_FUNC_B)>;
};
/* keyboard nkro ksi */
/omit-if-no-ref/ nkro_ksi00_gpio30: nkro_ksi00_gpio30 {
pinmux = <ENE_KB106X_PINMUX(0x30, PINMUX_FUNC_C)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi01_gpio31: nkro_ksi01_gpio31 {
pinmux = <ENE_KB106X_PINMUX(0x31, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi02_gpio32: nkro_ksi02_gpio32 {
pinmux = <ENE_KB106X_PINMUX(0x32, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi03_gpio33: nkro_ksi03_gpio33 {
pinmux = <ENE_KB106X_PINMUX(0x33, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi04_gpio34: nkro_ksi04_gpio34 {
pinmux = <ENE_KB106X_PINMUX(0x34, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi05_gpio35: nkro_ksi05_gpio35 {
pinmux = <ENE_KB106X_PINMUX(0x35, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi06_gpio36: nkro_ksi06_gpio36 {
pinmux = <ENE_KB106X_PINMUX(0x36, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi07_gpio37: nkro_ksi07_gpio37 {
pinmux = <ENE_KB106X_PINMUX(0x37, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi08_gpio28: nkro_ksi08_gpio28 {
pinmux = <ENE_KB106X_PINMUX(0x28, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi09_gpio29: nkro_ksi09_gpio29 {
pinmux = <ENE_KB106X_PINMUX(0x29, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi10_gpio2a: nkro_ksi10_gpio2a {
pinmux = <ENE_KB106X_PINMUX(0x2A, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi11_gpio2b: nkro_ksi11_gpio2b {
pinmux = <ENE_KB106X_PINMUX(0x2B, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi12_gpio2c: nkro_ksi12_gpio2c {
pinmux = <ENE_KB106X_PINMUX(0x2C, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi13_gpio2d: nkro_ksi13_gpio2d {
pinmux = <ENE_KB106X_PINMUX(0x2D, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi14_gpio2e: nkro_ksi14_gpio2e {
pinmux = <ENE_KB106X_PINMUX(0x2E, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi15_gpio2f: nkro_ksi15_gpio2f {
pinmux = <ENE_KB106X_PINMUX(0x2F, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi16_gpio48: nkro_ksi16_gpio48 {
pinmux = <ENE_KB106X_PINMUX(0x48, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi17_gpio49: nkro_ksi17_gpio49 {
pinmux = <ENE_KB106X_PINMUX(0x49, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi18_gpio4e: nkro_ksi18_gpio4e {
pinmux = <ENE_KB106X_PINMUX(0x4E, PINMUX_FUNC_C)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi19_gpio4f: nkro_ksi19_gpio4f {
pinmux = <ENE_KB106X_PINMUX(0x4F, PINMUX_FUNC_C)>;
bias-disable;
input-enable;
};
/omit-if-no-ref/ nkro_ksi20_gpio52: nkro_ksi20_gpio52 {
pinmux = <ENE_KB106X_PINMUX(0x52, PINMUX_FUNC_B)>;
bias-disable;
input-enable;
};
/* keyboard nkro kso */
/omit-if-no-ref/ nkro_kso00_gpio20: nkro_kso00_gpio20 {
pinmux = <ENE_KB106X_PINMUX(0x20, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso01_gpio21: nkro_kso01_gpio21 {
pinmux = <ENE_KB106X_PINMUX(0x21, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso02_gpio22: nkro_kso02_gpio22 {
pinmux = <ENE_KB106X_PINMUX(0x22, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso03_gpio23: nkro_kso03_gpio23 {
pinmux = <ENE_KB106X_PINMUX(0x23, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso04_gpio24: nkro_kso04_gpio24 {
pinmux = <ENE_KB106X_PINMUX(0x24, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso05_gpio25: nkro_kso05_gpio25 {
pinmux = <ENE_KB106X_PINMUX(0x25, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso06_gpio26: nkro_kso06_gpio26 {
pinmux = <ENE_KB106X_PINMUX(0x26, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/omit-if-no-ref/ nkro_kso07_gpio27: nkro_kso07_gpio27 {
pinmux = <ENE_KB106X_PINMUX(0x27, PINMUX_FUNC_B)>;
bias-pull-up;
drive-strength = <16>;
};
/* ps2 channel 1 */
/omit-if-no-ref/ psclk1_gpio4a: psclk1_gpio4a {
pinmux = <ENE_KB106X_PINMUX(0x4A, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ psdat1_gpio4b: psdat1_gpio4b {
pinmux = <ENE_KB106X_PINMUX(0x4B, PINMUX_FUNC_B)>;
};
/* ps2 channel 2 */
/omit-if-no-ref/ psclk2_gpio4c: psclk2_gpio4c {
pinmux = <ENE_KB106X_PINMUX(0x4C, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ psdat2_gpio4d: psdat2_gpio4d {
pinmux = <ENE_KB106X_PINMUX(0x4D, PINMUX_FUNC_B)>;
};
/* ps2 channel 3 */
/omit-if-no-ref/ psclk3_gpio4e: psclk3_gpio4e {
pinmux = <ENE_KB106X_PINMUX(0x4E, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ psdat3_gpio4f: psdat3_gpio4f {
pinmux = <ENE_KB106X_PINMUX(0x4F, PINMUX_FUNC_B)>;
};
/* peci */
/omit-if-no-ref/ peci_gpio7f: peci_gpio7f {
pinmux = <ENE_KB106X_PINMUX(0x7f, PINMUX_FUNC_B)>;
input-enable;
};
/* espi */
/omit-if-no-ref/ espi_alert_gpio01: espi_alert_gpio01 {
pinmux = <ENE_KB106X_PINMUX(0x01, PINMUX_FUNC_B)>;
};
/omit-if-no-ref/ espi_cs_gpio03: espi_cs_gpio03 {
pinmux = <ENE_KB106X_PINMUX(0x03, PINMUX_FUNC_A)>;
};
/omit-if-no-ref/ espi_rst_gpio07: espi_rst_gpio07 {
pinmux = <ENE_KB106X_PINMUX(0x07, PINMUX_FUNC_A)>;
input-enable;
};
/* uart */
/omit-if-no-ref/ uart_sin_gpio17: uart_sin_gpio17 {
pinmux = <ENE_KB106X_PINMUX(0x17, PINMUX_FUNC_C)>;
input-enable;
};
/omit-if-no-ref/ uart_sout_gpio16: uart_sout_gpio16 {
pinmux = <ENE_KB106X_PINMUX(0x16, PINMUX_FUNC_C)>;
};
/omit-if-no-ref/ uart_sin2_gpio49: uart_sin2_gpio49 {
pinmux = <ENE_KB106X_PINMUX(0x49, PINMUX_FUNC_A)>;
input-enable;
};
/omit-if-no-ref/ uart_sout2_gpio48: uart_sout2_gpio48 {
pinmux = <ENE_KB106X_PINMUX(0x48, PINMUX_FUNC_C)>;
};
};

8
dts/arm/ene/kb106x/kb106x.dtsi

@ -53,6 +53,14 @@ @@ -53,6 +53,14 @@
0x40040000 0x100>;
reg-names = "gcfg", "pmu", "vcc0";
};
pinctrl: pin-controller@50000000 {
compatible = "ene,kb106x-pinctrl";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x50000000 0x100>;
status = "okay";
};
};
};

102
dts/bindings/pinctrl/ene,kb106x-pinctrl.yaml

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
# SPDX-License-Identifier: Apache-2.0
description: |
The ENE KB106X pin controller is a singleton node responsible for controlling
pin function selection and pin properties. For example, you can use these
nodes to select peripheral pin functions.
Here is a list of supported standard pin properties:
- bias-disable: Disable pull-up/down resistor.
- bias-pull-up: Enable pull-up resistor.
- bias-pull-down: Enable pull-down resistor.
- drive-push-pull: Output driver is push-pull.
- drive-open-drain: Output driver is open-drain.
- output-disable: Disable GPIO output driver data
- output-enable: Ensable GPIO output driver data
- output-high: GPIO output data high
- output-low: GPIO output data low
- low-power-enable: Support input data ViH/ViL with low vlotage range(ex. 1.8V domain)
- input-enable: enable input on pin
- input-disable: disable input on pin
- drive-strength: current driving strength
Here is a list of support pinmux type:
- PINMUX_FUNC_A : GPIO Function
- PINMUX_FUNC_B : AltOutput 1 Function
- PINMUX_FUNC_C : AltOutput 2 Function
- PINMUX_FUNC_D : AltOutput 3 Function
- PINMUX_FUNC_E : AltOutput 4 Function
(Note. Alt-input function does not need to set pinmux type other than PINMUX_FUNC_A)
An example for KB106X, include the chip level pinctrl DTSI file in the
board level DTS:
#include <ene_kb106x/ene_kb106x-pinctrl.dtsi>
We want to use the I2C0_0 port of the KB106X controller and enable the
internal 3.3V pull-up if its i2c frequency won't exceed 400kHz. And we
need to set I2C0_0 pinmux type as PINMUX_FUNC_B (the alt-output 1
function) not a GPIO.
To change a pin's pinctrl default properties, add a reference to the
pin in the board's DTS file and set the properties as below:
&i2c0_0 {
pinctrl-0 = <&i2c0_clk_gpio2c &i2c0_dat_gpio2d>;
pinctrl-names = "default";
}
/omit-if-no-ref/ i2c0_clk_gpio2c: i2c0_clk_gpio2c {
pinmux = <ENE_KB106X_PINMUX(0x2C, PINMUX_FUNC_B)>;
bias-pull-up;
};
/omit-if-no-ref/ i2c0_dat_gpio2d: i2c0_dat_gpio2d {
pinmux = <ENE_KB106X_PINMUX(0x2D, PINMUX_FUNC_B)>;
bias-pull-up;
};
compatible: "ene,kb106x-pinctrl"
include: base.yaml
properties:
reg:
required: true
child-binding:
description: |
This binding gives a base representation of the ENE KB106x pins configuration.
Only when the pinmux type is selected as PINMUX_FUNC_A and output enable is set,
the below setting will effect.
"output-high/output-low/drive-push-pull/drive-open-drain."
include:
- name: pincfg-node.yaml
property-allowlist:
- bias-disable
- bias-pull-down
- bias-pull-up
- drive-push-pull
- drive-open-drain
- output-disable
- output-enable
- output-high
- output-low
- input-enable
- input-disable
- low-power-enable
- drive-strength
properties:
pinmux:
type: int
required: true
description: Pinmux selection
drive-strength:
enum:
- 4
- 16
default: 4
description: |
The drive strength controls the maximum driving capabilities.
4 : 4 mA (SoC default)
16: 16 mA

53
include/zephyr/dt-bindings/pinctrl/ene-kb106x-pinctrl.h

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
/*
* Copyright (c) ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_ENE_KB106X_PINCTRL_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_ENE_KB106X_PINCTRL_H_
#include <zephyr/dt-bindings/dt-util.h>
#define PINMUX_FUNC_GPIO 0x00
#define PINMUX_FUNC_A 0x00
#define PINMUX_FUNC_B 0x01
#define PINMUX_FUNC_C 0x02
#define PINMUX_FUNC_D 0x03
#define PINMUX_FUNC_MAX 0x04
#define ENE_KB106X_NO_PUD_POS 12
#define ENE_KB106X_PD_POS 13
#define ENE_KB106X_PU_POS 14
#define ENE_KB106X_PUSH_PULL_POS 15
#define ENE_KB106X_OPEN_DRAIN_POS 16
#define ENE_KB106X_OUT_DIS_POS 17
#define ENE_KB106X_OUT_EN_POS 18
#define ENE_KB106X_OUT_HI_POS 19
#define ENE_KB106X_OUT_LO_POS 20
#define ENE_KB106X_PIN_LOW_POWER_POS 21
#define ENE_KB106X_IN_DIS_POS 22
#define ENE_KB106X_IN_EN_POS 23
#define ENE_KB106X_DRIVING_POS 31
#define ENE_KB106X_PINMUX_PORT_POS 5
#define ENE_KB106X_PINMUX_PORT_MSK 0x7
#define ENE_KB106X_PINMUX_PIN_POS 0
#define ENE_KB106X_PINMUX_PIN_MSK 0x1f
#define ENE_KB106X_PINMUX_FUNC_POS 8
#define ENE_KB106X_PINMUX_FUNC_MSK 0xf
#define ENE_KB106X_EXTENDED_BANK 0x80
/*
* f is function number
* b[7:5] = pin bank
* b[4:0] = pin position in bank
* b[11:8] = function
*/
#define ENE_KB106X_PINMUX(n, f) \
(((((n) >> 5) & ENE_KB106X_PINMUX_PORT_MSK) << ENE_KB106X_PINMUX_PORT_POS) | \
(((n) & ENE_KB106X_PINMUX_PIN_MSK) << ENE_KB106X_PINMUX_PIN_POS) | \
(((f) & ENE_KB106X_PINMUX_FUNC_MSK) << ENE_KB106X_PINMUX_FUNC_POS))
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_ENE_KB106X_PINCTRL_H_ */

55
soc/ene/kb106x/common/pinctrl_soc.h

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
/*
* Copyright (c) 2025 ENE Technology Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_SOC_ARM_KB106X_PINCTRL_SOC_H_
#define ZEPHYR_SOC_ARM_KB106X_PINCTRL_SOC_H_
#include <zephyr/dt-bindings/pinctrl/ene-kb106x-pinctrl.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @cond INTERNAL_HIDDEN */
typedef uint32_t pinctrl_soc_pin_t;
/* initialize pinmux member fields of pinctrl_pin_t */
#define Z_PINCTRL_ENE_KB106X_PINMUX_INIT(node_id) (uint32_t)(DT_PROP(node_id, pinmux))
#define Z_PINCTRL_STATE_PINCFG_INIT(node_id) \
((DT_PROP(node_id, bias_disable) << ENE_KB106X_NO_PUD_POS) | \
(DT_PROP(node_id, bias_pull_down) << ENE_KB106X_PD_POS) | \
(DT_PROP(node_id, bias_pull_up) << ENE_KB106X_PU_POS) | \
(DT_PROP(node_id, drive_push_pull) << ENE_KB106X_PUSH_PULL_POS) | \
(DT_PROP(node_id, drive_open_drain) << ENE_KB106X_OPEN_DRAIN_POS) | \
(DT_PROP(node_id, output_disable) << ENE_KB106X_OUT_DIS_POS) | \
(DT_PROP(node_id, output_enable) << ENE_KB106X_OUT_EN_POS) | \
(DT_PROP(node_id, output_high) << ENE_KB106X_OUT_HI_POS) | \
(DT_PROP(node_id, output_low) << ENE_KB106X_OUT_LO_POS) | \
(DT_PROP(node_id, input_disable) << ENE_KB106X_IN_DIS_POS) | \
(DT_PROP(node_id, input_enable) << ENE_KB106X_IN_EN_POS) | \
(DT_PROP(node_id, low_power_enable) << ENE_KB106X_PIN_LOW_POWER_POS) | \
(DT_ENUM_IDX(node_id, drive_strength) << ENE_KB106X_DRIVING_POS))
/* initialize pin structure members */
#define Z_PINCTRL_STATE_PIN_INIT(node_id, state_prop, idx) \
(Z_PINCTRL_ENE_KB106X_PINMUX_INIT(DT_PROP_BY_IDX(node_id, state_prop, idx)) | \
Z_PINCTRL_STATE_PINCFG_INIT(DT_PROP_BY_IDX(node_id, state_prop, idx))),
/* Use DT FOREACH macro to initialize each used pin */
#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
{ \
DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) \
}
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_SOC_ARM_KB106X_PINCTRL_SOC_H_ */
Loading…
Cancel
Save