summaryrefslogtreecommitdiff
path: root/chip/nrf51
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/nrf51
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/nrf51')
-rw-r--r--chip/nrf51/gpio.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/chip/nrf51/gpio.c b/chip/nrf51/gpio.c
index 48c9f39895..53694b5a74 100644
--- a/chip/nrf51/gpio.c
+++ b/chip/nrf51/gpio.c
@@ -53,7 +53,8 @@ volatile uint32_t * const nrf51_alt_funcs[] = {
const unsigned int nrf51_alt_func_count = ARRAY_SIZE(nrf51_alt_funcs);
/* Make sure the function table and defines stay in sync */
-BUILD_ASSERT(NRF51_MAX_ALT_FUNCS == ARRAY_SIZE(nrf51_alt_funcs));
+BUILD_ASSERT(ARRAY_SIZE(nrf51_alt_funcs) == NRF51_MAX_ALT_FUNCS &&
+ NRF51_MAX_ALT_FUNCS <= GPIO_ALT_FUNC_MAX);
void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
{
@@ -160,16 +161,18 @@ void gpio_pre_init(void)
* NRF51 doesn't have an alternate function table.
* Use the pin select registers in place of the function number.
*/
-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)
{
uint32_t bit = GPIO_MASK_TO_NUM(mask);
ASSERT((~mask & BIT(bit)) == 0); /* Only one bit set. */
ASSERT(port == GPIO_0);
- ASSERT((func >= 0 && func < nrf51_alt_func_count) || func == -1);
+ ASSERT((func >= GPIO_ALT_FUNC_DEFAULT && func < nrf51_alt_func_count) ||
+ func == GPIO_ALT_FUNC_NONE);
/* Remove the previous setting(s) */
- if (func == -1) {
+ if (func == GPIO_ALT_FUNC_NONE) {
int i;
for (i = 0; i < nrf51_alt_func_count; i++) {
if (*(nrf51_alt_funcs[i]) == bit)