drivers: pinctrl: Microchip XEC PINCTRL glitch fix
Glitches were observed if a GPIO pin was configured by ROM to a non-default state and then Zephyr PINCTRL reconfigured the pin. The fix involves using the correct PINCTRL YAML output enable and state flags. Reading the current spin state and reflecting into new pin configuration if the pin is output and the drive low/high properties are not present. We also take advantage of GPIO hardware reflecing the alternate output value in the parallel output bit before enabling parallel output mode. Interpret boolean flags with both enable and disable as do not touch if neither flag is present. We give precedence to enable over disable if both flags mistakenly appear. Note, PINCTRL always clears the GPIO control input pad disable bit. Signed-off-by: Manimaran A <manimaran.a@microchip.com>
This commit is contained in:
parent
79ee5a876f
commit
f8c8ee65be
|
@ -148,11 +148,13 @@
|
|||
|
||||
&i2c00_scl_gpio004 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c00_sda_gpio003 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
@ -181,11 +183,13 @@
|
|||
|
||||
&i2c01_scl_gpio131 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c01_sda_gpio130 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
@ -198,11 +202,13 @@
|
|||
|
||||
&i2c07_scl_gpio013 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c07_sda_gpio012 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
|
|
@ -158,11 +158,13 @@
|
|||
|
||||
&i2c00_scl_gpio004 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c00_sda_gpio003 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
@ -175,11 +177,13 @@
|
|||
|
||||
&i2c01_scl_gpio131 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c01_sda_gpio130 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
@ -192,11 +196,13 @@
|
|||
|
||||
&i2c07_scl_gpio013 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
&i2c07_sda_gpio012 {
|
||||
drive-open-drain;
|
||||
output-enable;
|
||||
output-high;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,56 +12,88 @@
|
|||
#include <zephyr/drivers/pinctrl.h>
|
||||
#include <soc.h>
|
||||
|
||||
/* Microchip XEC: each GPIO pin has two 32-bit control register.
|
||||
/*
|
||||
* Microchip XEC: each GPIO pin has two 32-bit control register.
|
||||
* The first 32-bit register contains all pin features except
|
||||
* slew rate and driver strength in the second control register.
|
||||
* We compute the register index from the beginning of the GPIO
|
||||
* control address space which is the same range of the PINCTRL
|
||||
* parent node.
|
||||
* parent node. A zero value in the PINCTRL pinmux field means
|
||||
* do not touch.
|
||||
*/
|
||||
|
||||
static void config_drive_slew(struct gpio_regs * const regs, uint32_t idx, uint32_t conf)
|
||||
{
|
||||
uint32_t slew = conf & (MCHP_XEC_OSPEEDR_MASK << MCHP_XEC_OSPEEDR_POS);
|
||||
uint32_t drvstr = conf & (MCHP_XEC_ODRVSTR_MASK << MCHP_XEC_ODRVSTR_POS);
|
||||
uint32_t val = 0;
|
||||
uint32_t mask = 0;
|
||||
uint32_t slew = (conf >> MCHP_XEC_SLEW_RATE_POS) & MCHP_XEC_SLEW_RATE_MSK0;
|
||||
uint32_t drvstr = (conf >> MCHP_XEC_DRV_STR_POS) & MCHP_XEC_DRV_STR_MSK0;
|
||||
uint32_t msk = 0, val = 0;
|
||||
|
||||
if (slew != MCHP_XEC_OSPEEDR_NO_CHG) {
|
||||
mask |= MCHP_GPIO_CTRL2_SLEW_MASK;
|
||||
if (slew == MCHP_XEC_OSPEEDR_FAST) {
|
||||
if (slew) {
|
||||
msk |= MCHP_GPIO_CTRL2_SLEW_MASK;
|
||||
/* slow slew value is 0 */
|
||||
if (slew == MCHP_XEC_SLEW_RATE_FAST0) {
|
||||
val |= MCHP_GPIO_CTRL2_SLEW_FAST;
|
||||
}
|
||||
}
|
||||
if (drvstr != MCHP_XEC_ODRVSTR_NO_CHG) {
|
||||
mask |= MCHP_GPIO_CTRL2_DRV_STR_MASK;
|
||||
val |= (drvstr << MCHP_GPIO_CTRL2_DRV_STR_POS);
|
||||
|
||||
if (drvstr) {
|
||||
msk |= MCHP_GPIO_CTRL2_DRV_STR_MASK;
|
||||
/* drive strength values are 0 based */
|
||||
val |= ((drvstr - 1u) << MCHP_GPIO_CTRL2_DRV_STR_POS);
|
||||
}
|
||||
|
||||
if (!mask) {
|
||||
if (!msk) {
|
||||
return;
|
||||
}
|
||||
|
||||
regs->CTRL2[idx] = (regs->CTRL2[idx] & ~mask) | (val & mask);
|
||||
regs->CTRL2[idx] = (regs->CTRL2[idx] & ~msk) | (val & msk);
|
||||
}
|
||||
|
||||
/* Configure pin by writing GPIO Control and Control2 registers.
|
||||
* NOTE: Disable alternate output feature since the GPIO driver does.
|
||||
* While alternate output is enabled (default state of pin) HW does not
|
||||
* ignores writes to the parallel output bit for the pin. To set parallel
|
||||
* output value we must keep pin direction as input, set alternate output
|
||||
* disable, program pin value to parallel output bit, and then disable
|
||||
* alternate output mode.
|
||||
/*
|
||||
* Internal pulls feature:
|
||||
* None, weak pull-up, weak pull-down, or repeater mode (both pulls enabled).
|
||||
* We do not touch this field unless one or more of the DT booleans are set.
|
||||
* If the no-bias boolean is set then disable internal pulls.
|
||||
* If pull up and/or down is set enable the respective pull or both for what
|
||||
* MCHP calls repeater(keeper) mode.
|
||||
*/
|
||||
static uint32_t prog_pud(uint32_t pcr1, uint32_t conf)
|
||||
{
|
||||
if (conf & BIT(MCHP_XEC_NO_PUD_POS)) {
|
||||
pcr1 &= ~(MCHP_GPIO_CTRL_PUD_MASK);
|
||||
pcr1 |= MCHP_GPIO_CTRL_PUD_NONE;
|
||||
return pcr1;
|
||||
}
|
||||
|
||||
if (conf & (BIT(MCHP_XEC_PU_POS) | BIT(MCHP_XEC_PD_POS))) {
|
||||
pcr1 &= ~(MCHP_GPIO_CTRL_PUD_MASK);
|
||||
if (conf & BIT(MCHP_XEC_PU_POS)) {
|
||||
pcr1 |= MCHP_GPIO_CTRL_PUD_PU;
|
||||
}
|
||||
if (conf & BIT(MCHP_XEC_PD_POS)) {
|
||||
pcr1 |= MCHP_GPIO_CTRL_PUD_PD;
|
||||
}
|
||||
}
|
||||
|
||||
return pcr1;
|
||||
}
|
||||
|
||||
/*
|
||||
* DT enable booleans take precedence over disable booleans.
|
||||
* We initially clear alternate output disable allowing us to set output state
|
||||
* in the control register. Hardware sets output state bit in both control and
|
||||
* parallel output register bits. Alternate output disable only controls which
|
||||
* register bit is writable by the EC. We also clear the input pad disable
|
||||
* bit because we need the input pin state and we don't know if the requested
|
||||
* alternate function is input or bi-directional.
|
||||
* Note 1: hardware allows input and output to be simultaneously enabled.
|
||||
* Note 2: hardware interrupt detection is only on the input path.
|
||||
*/
|
||||
static int xec_config_pin(uint32_t portpin, uint32_t conf, uint32_t altf)
|
||||
{
|
||||
struct gpio_regs * const regs = (struct gpio_regs * const)DT_INST_REG_ADDR(0);
|
||||
uint32_t port = MCHP_XEC_PINMUX_PORT(portpin);
|
||||
uint32_t pin = (uint32_t)MCHP_XEC_PINMUX_PIN(portpin);
|
||||
uint32_t msk = MCHP_GPIO_CTRL_AOD_MASK;
|
||||
uint32_t val = MCHP_GPIO_CTRL_AOD_DIS;
|
||||
uint32_t idx = 0u;
|
||||
uint32_t temp = 0u;
|
||||
uint32_t idx = 0u, pcr1 = 0u;
|
||||
|
||||
if (port >= NUM_MCHP_GPIO_PORTS) {
|
||||
return -EINVAL;
|
||||
|
@ -72,57 +104,61 @@ static int xec_config_pin(uint32_t portpin, uint32_t conf, uint32_t altf)
|
|||
|
||||
config_drive_slew(regs, idx, conf);
|
||||
|
||||
/* default input pad enabled, buffer type push-pull, no internal pulls,
|
||||
* and invert polarity normal.
|
||||
*/
|
||||
msk |= (BIT(MCHP_GPIO_CTRL_INPAD_DIS_POS) | MCHP_GPIO_CTRL_BUFT_MASK |
|
||||
MCHP_GPIO_CTRL_PUD_MASK | MCHP_GPIO_CTRL_MUX_MASK
|
||||
| BIT(MCHP_GPIO_CTRL_POL_POS));
|
||||
/* Clear alternate output disable and input pad disable */
|
||||
regs->CTRL[idx] &= ~(BIT(MCHP_GPIO_CTRL_AOD_POS) | BIT(MCHP_GPIO_CTRL_INPAD_DIS_POS));
|
||||
pcr1 = regs->CTRL[idx]; /* current configuration including pin input state */
|
||||
pcr1 = regs->CTRL[idx]; /* read multiple times to allow propagation from pad */
|
||||
pcr1 = regs->CTRL[idx]; /* Is this necessary? */
|
||||
|
||||
pcr1 = prog_pud(pcr1, conf);
|
||||
|
||||
/* Touch output enable. We always enable input */
|
||||
if (conf & BIT(MCHP_XEC_OUT_DIS_POS)) {
|
||||
pcr1 &= ~(MCHP_GPIO_CTRL_DIR_OUTPUT);
|
||||
}
|
||||
if (conf & BIT(MCHP_XEC_OUT_EN_POS)) {
|
||||
pcr1 |= MCHP_GPIO_CTRL_DIR_OUTPUT;
|
||||
}
|
||||
|
||||
/* Touch output state? Bit can be set even if the direction is input only */
|
||||
if (conf & BIT(MCHP_XEC_OUT_LO_POS)) {
|
||||
pcr1 &= ~BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
||||
}
|
||||
if (conf & BIT(MCHP_XEC_OUT_HI_POS)) {
|
||||
pcr1 |= BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
||||
}
|
||||
|
||||
/* Touch output buffer type? */
|
||||
if (conf & BIT(MCHP_XEC_PUSH_PULL_POS)) {
|
||||
pcr1 &= ~(MCHP_GPIO_CTRL_BUFT_OPENDRAIN);
|
||||
}
|
||||
if (conf & BIT(MCHP_XEC_OPEN_DRAIN_POS)) {
|
||||
pcr1 |= MCHP_GPIO_CTRL_BUFT_OPENDRAIN;
|
||||
}
|
||||
|
||||
/* Always touch power gate */
|
||||
pcr1 &= ~MCHP_GPIO_CTRL_PWRG_MASK;
|
||||
if (conf & BIT(MCHP_XEC_PIN_LOW_POWER_POS)) {
|
||||
msk |= MCHP_GPIO_CTRL_PWRG_MASK;
|
||||
val |= MCHP_GPIO_CTRL_PWRG_OFF;
|
||||
pcr1 |= MCHP_GPIO_CTRL_PWRG_OFF;
|
||||
} else {
|
||||
pcr1 |= MCHP_GPIO_CTRL_PWRG_VTR_IO;
|
||||
}
|
||||
|
||||
temp = (conf & MCHP_XEC_PUPDR_MASK) >> MCHP_XEC_PUPDR_POS;
|
||||
switch (temp) {
|
||||
case MCHP_XEC_PULL_UP:
|
||||
val |= MCHP_GPIO_CTRL_PUD_PU;
|
||||
break;
|
||||
case MCHP_XEC_PULL_DOWN:
|
||||
val |= MCHP_GPIO_CTRL_PUD_PD;
|
||||
break;
|
||||
case MCHP_XEC_REPEATER:
|
||||
val |= MCHP_GPIO_CTRL_PUD_RPT;
|
||||
break;
|
||||
default:
|
||||
val |= MCHP_GPIO_CTRL_PUD_NONE;
|
||||
break;
|
||||
/* Always touch MUX (alternate function) */
|
||||
pcr1 &= ~MCHP_GPIO_CTRL_MUX_MASK;
|
||||
pcr1 |= (uint32_t)((altf & MCHP_GPIO_CTRL_MUX_MASK0) << MCHP_GPIO_CTRL_MUX_POS);
|
||||
|
||||
/* Always touch invert of alternate function. Need another bit to avoid touching */
|
||||
if (conf & BIT(MCHP_XEC_FUNC_INV_POS)) {
|
||||
pcr1 |= BIT(MCHP_GPIO_CTRL_POL_POS);
|
||||
} else {
|
||||
pcr1 &= ~BIT(MCHP_GPIO_CTRL_POL_POS);
|
||||
}
|
||||
|
||||
if ((conf >> MCHP_XEC_OTYPER_POS) & MCHP_XEC_OTYPER_MASK) {
|
||||
val |= MCHP_GPIO_CTRL_BUFT_OPENDRAIN;
|
||||
}
|
||||
|
||||
if (conf & MCHP_XEC_FUNC_INV_MSK) {
|
||||
val |= BIT(MCHP_GPIO_CTRL_POL_POS);
|
||||
}
|
||||
|
||||
regs->CTRL[idx] = (regs->CTRL[idx] & ~msk) | val;
|
||||
|
||||
temp = (conf >> MCHP_XEC_OVAL_POS) & MCHP_XEC_OVAL_MASK;
|
||||
if (temp) {
|
||||
if (temp == MCHP_XEC_OVAL_DRV_HIGH) {
|
||||
regs->PAROUT[port] |= BIT(pin);
|
||||
} else {
|
||||
regs->PAROUT[port] &= ~BIT(pin);
|
||||
}
|
||||
|
||||
regs->CTRL[idx] |= MCHP_GPIO_CTRL_DIR_OUTPUT;
|
||||
}
|
||||
|
||||
val = (uint32_t)((altf & MCHP_GPIO_CTRL_MUX_MASK0) << MCHP_GPIO_CTRL_MUX_POS);
|
||||
regs->CTRL[idx] |= val;
|
||||
/* output state set in control & parallel regs */
|
||||
regs->CTRL[idx] = pcr1;
|
||||
/* make output state in control read-only in control and read-write in parallel reg */
|
||||
regs->CTRL[idx] = pcr1 | BIT(MCHP_GPIO_CTRL_AOD_POS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -130,23 +166,22 @@ static int xec_config_pin(uint32_t portpin, uint32_t conf, uint32_t altf)
|
|||
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
|
||||
uintptr_t reg)
|
||||
{
|
||||
uint32_t portpin, mux, cfg, func;
|
||||
uint32_t portpin, pinmux, func;
|
||||
int ret;
|
||||
|
||||
ARG_UNUSED(reg);
|
||||
|
||||
for (uint8_t i = 0U; i < pin_cnt; i++) {
|
||||
mux = pins[i].pinmux;
|
||||
pinmux = pins[i];
|
||||
|
||||
func = MCHP_XEC_PINMUX_FUNC(mux);
|
||||
func = MCHP_XEC_PINMUX_FUNC(pinmux);
|
||||
if (func >= MCHP_AFMAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cfg = pins[i].pincfg;
|
||||
portpin = MEC_XEC_PINMUX_PORT_PIN(mux);
|
||||
portpin = MEC_XEC_PINMUX_PORT_PIN(pinmux);
|
||||
|
||||
ret = xec_config_pin(portpin, cfg, func);
|
||||
ret = xec_config_pin(portpin, pinmux, func);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ child-binding:
|
|||
- drive-push-pull
|
||||
- drive-open-drain
|
||||
- low-power-enable
|
||||
- output-disable
|
||||
- output-enable
|
||||
- output-high
|
||||
- output-low
|
||||
|
||||
|
@ -94,8 +96,9 @@ child-binding:
|
|||
|
||||
slew-rate:
|
||||
type: string
|
||||
default: "low-speed"
|
||||
default: "no-change"
|
||||
enum:
|
||||
- "no-change"
|
||||
- "low-speed"
|
||||
- "high-speed"
|
||||
description: |
|
||||
|
@ -106,8 +109,9 @@ child-binding:
|
|||
|
||||
drive-strength:
|
||||
type: string
|
||||
default: "1x"
|
||||
default: "no-change"
|
||||
enum:
|
||||
- "no-change"
|
||||
- "1x"
|
||||
- "2x"
|
||||
- "4x"
|
||||
|
|
|
@ -20,32 +20,28 @@
|
|||
#define MCHP_AF7 0x7
|
||||
#define MCHP_AFMAX 0x8
|
||||
|
||||
#define MCHP_XEC_PUPDR_POS 0
|
||||
#define MCHP_XEC_PUPDR_MASK 0x3
|
||||
#define MCHP_XEC_FUNC_INV_POS 2
|
||||
#define MCHP_XEC_FUNC_INV_MSK 0x4
|
||||
#define MCHP_XEC_OTYPER_POS 4
|
||||
#define MCHP_XEC_OTYPER_MASK 0x1
|
||||
#define MCHP_XEC_OTYPER_PUSHPULL 0
|
||||
#define MCHP_XEC_OTYPER_OPENDRAIN 0x1
|
||||
#define MCHP_XEC_OVAL_POS 6
|
||||
#define MCHP_XEC_OVAL_MASK 0x3
|
||||
#define MCHP_XEC_OVAL_DRV_LOW 0x1
|
||||
#define MCHP_XEC_OVAL_DRV_HIGH 0x2
|
||||
#define MCHP_XEC_OSPEEDR_POS 8
|
||||
#define MCHP_XEC_OSPEEDR_MASK 0x3
|
||||
#define MCHP_XEC_OSPEEDR_SLOW 0x0
|
||||
#define MCHP_XEC_OSPEEDR_FAST 0x1
|
||||
#define MCHP_XEC_OSPEEDR_NO_CHG 0x3 /* Do not modify slew rate */
|
||||
#define MCHP_XEC_ODRVSTR_POS 12
|
||||
#define MCHP_XEC_ODRVSTR_MASK 0x7
|
||||
#define MCHP_XEC_ODRVSTR_1X 0x0 /* 2 or 4(PIO-24) mA */
|
||||
#define MCHP_XEC_ODRVSTR_2X 0x1 /* 4 or 8(PIO-24) mA */
|
||||
#define MCHP_XEC_ODRVSTR_4X 0x2 /* 8 or 16(PIO-24) mA */
|
||||
#define MCHP_XEC_ODRVSTR_6X 0x3 /* 12 or 24(PIO-24) mA */
|
||||
#define MCHP_XEC_ODRVSTR_NO_CHG 0x7 /* Do not modify drive strength */
|
||||
#define MCHP_XEC_PIN_LOW_POWER_POS 15
|
||||
#define MCHP_XEC_PIN_LOW_POWER 1
|
||||
#define MCHP_XEC_NO_PUD_POS 12
|
||||
#define MCHP_XEC_PD_POS 13
|
||||
#define MCHP_XEC_PU_POS 14
|
||||
#define MCHP_XEC_PUSH_PULL_POS 15
|
||||
#define MCHP_XEC_OPEN_DRAIN_POS 16
|
||||
#define MCHP_XEC_OUT_DIS_POS 17
|
||||
#define MCHP_XEC_OUT_EN_POS 18
|
||||
#define MCHP_XEC_OUT_HI_POS 19
|
||||
#define MCHP_XEC_OUT_LO_POS 20
|
||||
/* bit[21] unused */
|
||||
#define MCHP_XEC_SLEW_RATE_POS 22
|
||||
#define MCHP_XEC_SLEW_RATE_MSK0 0x3
|
||||
#define MCHP_XEC_SLEW_RATE_SLOW0 0x1
|
||||
#define MCHP_XEC_SLEW_RATE_FAST0 0x2
|
||||
#define MCHP_XEC_DRV_STR_POS 24
|
||||
#define MCHP_XEC_DRV_STR_MSK0 0x7
|
||||
#define MCHP_XEC_DRV_STR0_1X 0x1 /* 2 or 4(PIO-24) mA */
|
||||
#define MCHP_XEC_DRV_STR0_2X 0x2 /* 4 or 8(PIO-24) mA */
|
||||
#define MCHP_XEC_DRV_STR0_4X 0x3 /* 8 or 16(PIO-24) mA */
|
||||
#define MCHP_XEC_DRV_STR0_6X 0x4 /* 12 or 24(PIO-24) mA */
|
||||
#define MCHP_XEC_PIN_LOW_POWER_POS 27
|
||||
#define MCHP_XEC_FUNC_INV_POS 29
|
||||
|
||||
#define MCHP_XEC_PINMUX_PORT_POS 0
|
||||
#define MCHP_XEC_PINMUX_PORT_MSK 0xf
|
||||
|
|
|
@ -26,71 +26,30 @@ extern "C" {
|
|||
/** @cond INTERNAL_HIDDEN */
|
||||
|
||||
/* Type for MCHP XEC pin. */
|
||||
typedef struct {
|
||||
/** Pinmux settings (port, pin and function). */
|
||||
uint16_t pinmux;
|
||||
/** Pin configuration (bias, drive and slew rate). */
|
||||
uint16_t pincfg;
|
||||
} pinctrl_soc_pin_t;
|
||||
typedef uint32_t pinctrl_soc_pin_t;
|
||||
|
||||
/* initialize pinmux member fields of pinctrl_pin_t */
|
||||
#define Z_PINCTRL_MCHP_XEC_PINMUX_INIT(node_id) DT_PROP(node_id, pinmux)
|
||||
#define Z_PINCTRL_MCHP_XEC_PINMUX_INIT(node_id) (uint32_t)(DT_PROP(node_id, pinmux))
|
||||
|
||||
#define MCHP_XEC_BIAS_DIS_VAL(nid) \
|
||||
(MCHP_XEC_NO_PULL * DT_PROP(nid, bias_disable))
|
||||
|
||||
#define MCHP_XEC_BIAS_PU_VAL(nid) \
|
||||
(MCHP_XEC_PULL_UP * DT_PROP(nid, bias_pull_up))
|
||||
|
||||
#define MCHP_XEC_BIAS_PD_VAL(nid) \
|
||||
(MCHP_XEC_PULL_DOWN * DT_PROP(nid, bias_pull_down))
|
||||
|
||||
#define MCHP_XEC_DRV_PP_VAL(nid) \
|
||||
(MCHP_XEC_PUSH_PULL * DT_PROP(nid, drive_push_pull))
|
||||
|
||||
#define MCHP_XEC_DRV_OD_VAL(nid) \
|
||||
(MCHP_XEC_OPEN_DRAIN * DT_PROP(nid, drive_open_drain))
|
||||
|
||||
#define MCHP_XEC_OVAL_DRV_LO(nid) \
|
||||
(MCHP_XEC_OVAL_LOW * DT_PROP(nid, output_low))
|
||||
|
||||
#define MCHP_XEC_OVAL_DRV_HI(nid) \
|
||||
(MCHP_XEC_OVAL_HIGH * DT_PROP(nid, output_high))
|
||||
|
||||
#define MCHP_XEC_LOW_POWER_EN(nid) \
|
||||
(MCHP_XEC_PIN_LOW_POWER * DT_PROP(nid, low_power_enable))
|
||||
|
||||
#define MCHP_XEC_SLEW_VAL(nid) \
|
||||
(DT_ENUM_IDX_OR(nid, slew_rate, MCHP_XEC_OSPEEDR_NO_CHG) << \
|
||||
MCHP_XEC_OSPEEDR_POS)
|
||||
|
||||
#define MCHP_XEC_DRVSTR_VAL(nid) \
|
||||
(DT_ENUM_IDX_OR(nid, drive_strength, MCHP_XEC_ODRVSTR_NO_CHG) << \
|
||||
MCHP_XEC_ODRVSTR_POS)
|
||||
|
||||
#define MCHP_XEC_FUNC_INVERT_VAL(nid) \
|
||||
(MCHP_XEC_FUNC_INVERT * DT_PROP(nid, microchip_output_func_invert))
|
||||
|
||||
/* initialize pincfg field in structure pinctrl_pin_t */
|
||||
#define Z_PINCTRL_MCHP_XEC_PINCFG_INIT(node_id) \
|
||||
((MCHP_XEC_BIAS_DIS_VAL(node_id) << MCHP_XEC_PUPDR_POS) | \
|
||||
(MCHP_XEC_BIAS_PU_VAL(node_id) << MCHP_XEC_PUPDR_POS) | \
|
||||
(MCHP_XEC_BIAS_PD_VAL(node_id) << MCHP_XEC_PUPDR_POS) | \
|
||||
(MCHP_XEC_DRV_PP_VAL(node_id) << MCHP_XEC_OTYPER_POS) | \
|
||||
(MCHP_XEC_DRV_OD_VAL(node_id) << MCHP_XEC_OTYPER_POS) | \
|
||||
(MCHP_XEC_OVAL_DRV_LO(node_id) << MCHP_XEC_OVAL_POS) | \
|
||||
(MCHP_XEC_OVAL_DRV_HI(node_id) << MCHP_XEC_OVAL_POS) | \
|
||||
(MCHP_XEC_LOW_POWER_EN(node_id) << MCHP_XEC_PIN_LOW_POWER_POS) | \
|
||||
(MCHP_XEC_FUNC_INVERT_VAL(node_id) << MCHP_XEC_FUNC_INV_POS) | \
|
||||
MCHP_XEC_SLEW_VAL(node_id) | \
|
||||
MCHP_XEC_DRVSTR_VAL(node_id))
|
||||
#define Z_PINCTRL_STATE_PINCFG_INIT(node_id) \
|
||||
((DT_PROP(node_id, bias_disable) << MCHP_XEC_NO_PUD_POS) \
|
||||
| (DT_PROP(node_id, bias_pull_down) << MCHP_XEC_PD_POS) \
|
||||
| (DT_PROP(node_id, bias_pull_up) << MCHP_XEC_PU_POS) \
|
||||
| (DT_PROP(node_id, drive_push_pull) << MCHP_XEC_PUSH_PULL_POS) \
|
||||
| (DT_PROP(node_id, drive_open_drain) << MCHP_XEC_OPEN_DRAIN_POS) \
|
||||
| (DT_PROP(node_id, output_disable) << MCHP_XEC_OUT_DIS_POS) \
|
||||
| (DT_PROP(node_id, output_enable) << MCHP_XEC_OUT_EN_POS) \
|
||||
| (DT_PROP(node_id, output_high) << MCHP_XEC_OUT_HI_POS) \
|
||||
| (DT_PROP(node_id, output_low) << MCHP_XEC_OUT_LO_POS) \
|
||||
| (DT_PROP(node_id, low_power_enable) << MCHP_XEC_PIN_LOW_POWER_POS) \
|
||||
| (DT_PROP(node_id, microchip_output_func_invert) << MCHP_XEC_FUNC_INV_POS) \
|
||||
| (DT_ENUM_IDX(node_id, slew_rate) << MCHP_XEC_SLEW_RATE_POS) \
|
||||
| (DT_ENUM_IDX(node_id, drive_strength) << MCHP_XEC_DRV_STR_POS))
|
||||
|
||||
/* initialize pin structure members */
|
||||
#define Z_PINCTRL_STATE_PIN_INIT(node_id, state_prop, idx) \
|
||||
{ .pinmux = Z_PINCTRL_MCHP_XEC_PINMUX_INIT( \
|
||||
DT_PROP_BY_IDX(node_id, state_prop, idx)), \
|
||||
.pincfg = Z_PINCTRL_MCHP_XEC_PINCFG_INIT( \
|
||||
DT_PROP_BY_IDX(node_id, state_prop, idx)), },
|
||||
(Z_PINCTRL_MCHP_XEC_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) \
|
||||
|
|
|
@ -9,21 +9,23 @@
|
|||
|
||||
#include <zephyr/devicetree.h>
|
||||
|
||||
#define MCHP_XEC_NO_PULL 0x0
|
||||
#define MCHP_XEC_PIN_FEAT_EN 0x1
|
||||
#define MCHP_XEC_NO_PULL 0x1
|
||||
#define MCHP_XEC_PULL_UP 0x1
|
||||
#define MCHP_XEC_PULL_DOWN 0x2
|
||||
#define MCHP_XEC_REPEATER 0x3
|
||||
#define MCHP_XEC_PUSH_PULL 0x0
|
||||
#define MCHP_XEC_PULL_DOWN 0x1
|
||||
#define MCHP_XEC_PUSH_PULL 0x1
|
||||
#define MCHP_XEC_OPEN_DRAIN 0x1
|
||||
#define MCHP_XEC_NO_OVAL 0x0
|
||||
#define MCHP_XEC_OVAL_LOW 0x1
|
||||
#define MCHP_XEC_OVAL_HIGH 0x2
|
||||
#define MCHP_XEC_OUT_DIS 0x1
|
||||
#define MCHP_XEC_OUT_EN 0x1
|
||||
#define MCHP_XEC_OUT_DRV_LOW 0x1
|
||||
#define MCHP_XEC_OUT_DRV_HIGH 0x1
|
||||
#define MCHP_XEC_DRVSTR_NONE 0x0
|
||||
#define MCHP_XEC_DRVSTR_2MA 0x1
|
||||
#define MCHP_XEC_DRVSTR_4MA 0x2
|
||||
#define MCHP_XEC_DRVSTR_8MA 0x3
|
||||
#define MCHP_XEC_DRVSTR_12MA 0x4
|
||||
#define MCHP_XEC_FUNC_INVERT 0x1
|
||||
#define MCHP_XEC_PIN_INPUT_DIS 0x1
|
||||
|
||||
#define MCHP_DT_ESPI_VW_FLAG_STATUS_POS 0
|
||||
#define MCHP_DT_ESPI_VW_FLAG_DIR_POS 1
|
||||
|
|
Loading…
Reference in a new issue