Lines Matching +full:write +full:- +full:bit +full:- +full:idx
2 * Copyright (c) 2016 Open-RnD Sp. z o.o.
7 * SPDX-License-Identifier: Apache-2.0
16 * Microchip XEC: each GPIO pin has two 32-bit control register.
17 * The first 32-bit register contains all pin features except
24 static void config_drive_slew(struct gpio_regs * const regs, uint32_t idx, uint32_t conf) in config_drive_slew() argument
41 val |= ((drvstr - 1u) << MCHP_GPIO_CTRL2_DRV_STR_POS); in config_drive_slew()
48 regs->CTRL2[idx] = (regs->CTRL2[idx] & ~msk) | (val & msk); in config_drive_slew()
53 * None, weak pull-up, weak pull-down, or repeater mode (both pulls enabled).
55 * If the no-bias boolean is set then disable internal pulls.
61 if (conf & BIT(MCHP_XEC_NO_PUD_POS)) { in prog_pud()
67 if (conf & (BIT(MCHP_XEC_PU_POS) | BIT(MCHP_XEC_PD_POS))) { in prog_pud()
69 if (conf & BIT(MCHP_XEC_PU_POS)) { in prog_pud()
72 if (conf & BIT(MCHP_XEC_PD_POS)) { in prog_pud()
83 * in the control register. Hardware sets output state bit in both control and
85 * register bit is writable by the EC. We also clear the input pad disable
86 * bit because we need the input pin state and we don't know if the requested
87 * alternate function is input or bi-directional.
96 uint32_t idx = 0u, pcr1 = 0u; in xec_config_pin() local
99 return -EINVAL; in xec_config_pin()
103 idx = (port * 32U) + pin; in xec_config_pin()
105 config_drive_slew(regs, idx, conf); in xec_config_pin()
108 regs->CTRL[idx] &= ~(BIT(MCHP_GPIO_CTRL_AOD_POS) | BIT(MCHP_GPIO_CTRL_INPAD_DIS_POS)); in xec_config_pin()
109 pcr1 = regs->CTRL[idx]; /* current configuration including pin input state */ in xec_config_pin()
110 pcr1 = regs->CTRL[idx]; /* read multiple times to allow propagation from pad */ in xec_config_pin()
111 pcr1 = regs->CTRL[idx]; /* Is this necessary? */ in xec_config_pin()
116 if (conf & BIT(MCHP_XEC_OUT_DIS_POS)) { in xec_config_pin()
119 if (conf & BIT(MCHP_XEC_OUT_EN_POS)) { in xec_config_pin()
123 /* Touch output state? Bit can be set even if the direction is input only */ in xec_config_pin()
124 if (conf & BIT(MCHP_XEC_OUT_LO_POS)) { in xec_config_pin()
125 pcr1 &= ~BIT(MCHP_GPIO_CTRL_OUTVAL_POS); in xec_config_pin()
127 if (conf & BIT(MCHP_XEC_OUT_HI_POS)) { in xec_config_pin()
128 pcr1 |= BIT(MCHP_GPIO_CTRL_OUTVAL_POS); in xec_config_pin()
132 if (conf & BIT(MCHP_XEC_PUSH_PULL_POS)) { in xec_config_pin()
135 if (conf & BIT(MCHP_XEC_OPEN_DRAIN_POS)) { in xec_config_pin()
141 if (conf & BIT(MCHP_XEC_PIN_LOW_POWER_POS)) { in xec_config_pin()
151 /* Always touch invert of alternate function. Need another bit to avoid touching */ in xec_config_pin()
152 if (conf & BIT(MCHP_XEC_FUNC_INV_POS)) { in xec_config_pin()
153 pcr1 |= BIT(MCHP_GPIO_CTRL_POL_POS); in xec_config_pin()
155 pcr1 &= ~BIT(MCHP_GPIO_CTRL_POL_POS); in xec_config_pin()
159 regs->CTRL[idx] = pcr1; in xec_config_pin()
160 /* make output state in control read-only in control and read-write in parallel reg */ in xec_config_pin()
161 regs->CTRL[idx] = pcr1 | BIT(MCHP_GPIO_CTRL_AOD_POS); in xec_config_pin()
179 return -EINVAL; in pinctrl_configure_pins()