Skip to content

Commit dde796a

Browse files
scottwcpgnashif
authored andcommitted
drivers: gpio: mchp: Fix pin configure after disconnect
GPIO driver properly disconnects a pin. On subsequent pin configure calls the driver does not clear the GPIO pin's power gate field resulting in the pin remaining disconnected. Signed-off-by: Scott Worley <[email protected]>
1 parent 477f4d4 commit dde796a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/gpio/gpio_mchp_xec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ static int gpio_xec_configure(const struct device *dev,
7979
* PCRs for a given GPIO. There are no GPIO modules in Microchip SOCs!
8080
* Keep direction as input until last.
8181
* Clear input pad disable allowing input pad to operate.
82+
* Clear Power gate to allow pads to operate.
8283
*/
8384
mask |= MCHP_GPIO_CTRL_DIR_MASK;
8485
mask |= MCHP_GPIO_CTRL_INPAD_DIS_MASK;
86+
mask |= MCHP_GPIO_CTRL_PWRG_MASK;
8587
pcr1 |= MCHP_GPIO_CTRL_DIR_INPUT;
8688

8789
/* Figure out the pullup/pulldown configuration and keep it in the
@@ -114,6 +116,11 @@ static int gpio_xec_configure(const struct device *dev,
114116
mask |= MCHP_GPIO_CTRL_AOD_MASK;
115117
pcr1 |= MCHP_GPIO_CTRL_AOD_DIS;
116118

119+
/* Make sure disconnected on first control register write */
120+
if (flags == GPIO_DISCONNECTED) {
121+
pcr1 |= MCHP_GPIO_CTRL_PWRG_OFF;
122+
}
123+
117124
/* Now write contents of pcr1 variable to the PCR1 register that
118125
* corresponds to the GPIO being configured.
119126
* AOD is 1 and direction is input. HW will allow use to set the
@@ -133,13 +140,6 @@ static int gpio_xec_configure(const struct device *dev,
133140
mask = MCHP_GPIO_CTRL_DIR_MASK;
134141
pcr1 = MCHP_GPIO_CTRL_DIR_OUTPUT;
135142
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
136-
} else if ((flags & GPIO_INPUT) != 0U) {
137-
/* Already configured */
138-
} else {
139-
/* GPIO disconnected */
140-
mask |= MCHP_GPIO_CTRL_PWRG_MASK;
141-
pcr1 |= MCHP_GPIO_CTRL_PWRG_OFF;
142-
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
143143
}
144144

145145
return 0;

0 commit comments

Comments
 (0)