summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Anderson <dianders@chromium.org>2012-08-23 15:58:50 -0700
committerGerrit <chrome-bot@google.com>2012-08-24 15:07:07 -0700
commit343df7227722874d74928404604d21c560d2f426 (patch)
treea385eb85ebfa1d1e89669a2b74cf0f84be520a42
parentfc783fb585cec5aa8ee8bc6d0e15c78160e29b90 (diff)
downloadchrome-ec-343df7227722874d74928404604d21c560d2f426.tar.gz
gpio: Fix initting pulldowns
At the moment we don't seem to have any pull downs configured, but they wouldn't work. That's because: * GPIO_PULL_UP => 0x0006 * GPIO_PULL_DOWN => 0x0002 ...so if we've got GPIO_PULL_DOWN in flags and then we run the test "if (flags & GPIO_PULL_UP)", we'll actually test TRUE. Oops. BUG=None TEST=Code inspection. BRANCH=snow Change-Id: Ie46ae291fe7edfc9f5237cf8bba3791de9755c5b Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31278 Reviewed-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r--chip/stm32/gpio-stm32f100.c4
-rw-r--r--chip/stm32/gpio-stm32l15x.c6
2 files changed, 6 insertions, 4 deletions
diff --git a/chip/stm32/gpio-stm32f100.c b/chip/stm32/gpio-stm32f100.c
index dd729eab82..8c071394e4 100644
--- a/chip/stm32/gpio-stm32f100.c
+++ b/chip/stm32/gpio-stm32f100.c
@@ -73,11 +73,11 @@ int gpio_set_flags(enum gpio_signal signal, int flags)
} else {
/* GPIOx_ODR determines which resistor to activate in
* input mode, see Table 16 (datasheet rm0041) */
- if (flags & GPIO_PULL_UP) {
+ if ((flags & GPIO_PULL_UP) == GPIO_PULL_UP) {
mask |= 0x88888888 & cnf;
STM32_GPIO_BSRR_OFF(g->port) |= g->mask;
gpio_set_level(signal, 1);
- } else if (flags & GPIO_PULL_DOWN) {
+ } else if ((flags & GPIO_PULL_DOWN) == GPIO_PULL_DOWN) {
mask |= 0x88888888 & cnf;
gpio_set_level(signal, 0);
} else {
diff --git a/chip/stm32/gpio-stm32l15x.c b/chip/stm32/gpio-stm32l15x.c
index c80e57604b..f5513dafb8 100644
--- a/chip/stm32/gpio-stm32l15x.c
+++ b/chip/stm32/gpio-stm32l15x.c
@@ -42,9 +42,11 @@ int gpio_pre_init(void)
uint32_t val;
val = STM32_GPIO_PUPDR_OFF(g->port) & ~mask2;
- if (g->flags & GPIO_PULL_UP) /* Pull Up = 01 */
+ if ((g->flags & GPIO_PULL_UP) == GPIO_PULL_UP)
+ /* Pull Up = 01 */
val |= 0x55555555 & mask2;
- else if (g->flags & GPIO_PULL_DOWN) /* Pull Down = 10 */
+ else if ((g->flags & GPIO_PULL_DOWN) == GPIO_PULL_DOWN)
+ /* Pull Down = 10 */
val |= 0xaaaaaaaa & mask2;
STM32_GPIO_PUPDR_OFF(g->port) = val;