diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-08-02 14:28:43 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-08-07 12:43:35 -0700 |
commit | f2b56fcb9fe078d5a29f1c3744e47e77240cd4e7 (patch) | |
tree | 4ff810332c543871da7febb2cc21597eee800b6d /chip/stm32/power_led.c | |
parent | ce704b40005c1acdffabe58f47df42c1d7da33c2 (diff) | |
download | chrome-ec-f2b56fcb9fe078d5a29f1c3744e47e77240cd4e7.tar.gz |
Clean up configuring GPIO alternate functions
GPIO alternate functions used to be configured throughout the code,
which made it hard to tell which ones you needed to configure yourself
in board.c. It also sometimes (chip/lm4/i2c.c) led to GPIOs being
configured as alternate functions even if they weren't used on a given
board.
With this change, every board has a table in board.c which lists ALL
GPIOs which have alternate functions. This is now the only place
where alternate functions are configured. Each module then calls
gpio_init_module() to set up its GPIOs.
This also fixes a bug where gpio_set_flags() ignored most of the flags
passed to it (only direction and level were actually used).
On stm32f, gpio_set_alternate() does not exist, and pins are
configured via direct register writes from board.c. Rather than
attempt to change that in the same CL, I've stubbed out
gpio_set_alternate() for stm32f, and will fix the register writes in a
follow-up CL.
BUG=chrome-os-partner:21618
BRANCH=peppy (fixes I2C1 being initialized even though those pins are used
for other things)
TEST=boot link, falco, pit, spring
Change-Id: I40f47025d8f767e0723c6b40c80413af9ba8deba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64400
Diffstat (limited to 'chip/stm32/power_led.c')
-rw-r--r-- | chip/stm32/power_led.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/chip/stm32/power_led.c b/chip/stm32/power_led.c index 8794c82d7c..237fd14670 100644 --- a/chip/stm32/power_led.c +++ b/chip/stm32/power_led.c @@ -65,8 +65,7 @@ static void power_led_use_pwm(void) val |= 0x00009000; /* alt. function (TIM2/PWM) */ STM32_GPIO_CRL(GPIO_B) = val; #else - /* PA2 = TIM2_CH3 */ - gpio_set_alternate_function(GPIO_A, (1 << 2), GPIO_ALT_TIM2); + gpio_config_module(MODULE_POWER_LED, 1); #endif /* Enable timer */ @@ -123,8 +122,12 @@ static void power_led_manual_off(void) * configure it as an open-drain output and set it to high impedence, * but reconfiguring as an input had better results in testing. */ +#ifdef BOARD_snow gpio_set_flags(GPIO_LED_POWER_L, GPIO_INPUT); gpio_set_level(GPIO_LED_POWER_L, 1); +#else + gpio_config_module(MODULE_POWER_LED, 0); +#endif using_pwm = 0; } |