summaryrefslogtreecommitdiff
path: root/chip/npcx/gpio.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2019-10-25 03:38:30 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-01 02:46:00 +0000
commit3b390264a415ce121a8c6f8db9fa9c42c647aaec (patch)
treeef137798bf0672d035e644784c27f2f7162d3db2 /chip/npcx/gpio.c
parent946402100fd0589b5480eebd8444a7c3eb9b6aa5 (diff)
downloadchrome-ec-3b390264a415ce121a8c6f8db9fa9c42c647aaec.tar.gz
Cleanup: Correct GPIO alternate function parameter
Added code to correct the GPIO alternate function parameter at Chipset level. Optionally board level functions can cleanup the code in additional change lists. BUG=b:139427854 BRANCH=none TEST=make buildall -j Change-Id: I1171ca36a703291070fc89f972f84414adcf04fc Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1880974 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'chip/npcx/gpio.c')
-rw-r--r--chip/npcx/gpio.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c
index 4f7a50b672..e20319ab0f 100644
--- a/chip/npcx/gpio.c
+++ b/chip/npcx/gpio.c
@@ -113,7 +113,8 @@ static uint8_t gpio_is_alt_sel(uint8_t port, uint8_t bit)
}
#endif
-static int gpio_alt_sel(uint8_t port, uint8_t bit, int8_t func)
+static int gpio_alt_sel(uint8_t port, uint8_t bit,
+ enum gpio_alternate_func func)
{
struct gpio_alt_map const *map;
@@ -124,10 +125,10 @@ static int gpio_alt_sel(uint8_t port, uint8_t bit, int8_t func)
uint8_t alt_mask = 1 << map->alt.bit;
/*
- * func < 0 -> GPIO functionality
+ * func < GPIO_ALT_FUNC_DEFAULT -> GPIO functionality
* map->alt.inverted -> Set DEVALT bit for GPIO
*/
- if ((func < 0) ^ map->alt.inverted)
+ if ((func < GPIO_ALT_FUNC_DEFAULT) ^ map->alt.inverted)
NPCX_DEVALT(map->alt.group) &= ~alt_mask;
else
NPCX_DEVALT(map->alt.group) |= alt_mask;
@@ -136,7 +137,7 @@ static int gpio_alt_sel(uint8_t port, uint8_t bit, int8_t func)
}
}
- if (func > 0)
+ if (func > GPIO_ALT_FUNC_DEFAULT)
CPRINTS("Warn! No alter func in port%d, pin%d", port, bit);
return -1;
@@ -306,7 +307,8 @@ BUILD_ASSERT(ARRAY_SIZE(gpio_lvol_table[0].lvol_gpio) == 8);
/*****************************************************************************/
/* IC specific low-level driver */
-void gpio_set_alternate_function(uint32_t port, uint32_t mask, int func)
+void gpio_set_alternate_function(uint32_t port, uint32_t mask,
+ enum gpio_alternate_func func)
{
/* Enable alternative pins by func*/
int pin;
@@ -583,7 +585,8 @@ void gpio_pre_init(void)
* configured as a GPIO, and not left in its default state,
* which may or may not be as a GPIO.
*/
- gpio_set_alternate_function(g->port, g->mask, -1);
+ gpio_set_alternate_function(g->port, g->mask,
+ GPIO_ALT_FUNC_NONE);
}
/* The bypass of low voltage IOs for better power consumption */