Files
OpenCellular/chip/host/gpio.c
Randall Spangler f2b56fcb9f 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
2013-08-07 12:43:35 -07:00

41 lines
772 B
C

/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* GPIO module for emulator */
#include "common.h"
#include "gpio.h"
test_mockable void gpio_pre_init(void)
{
/* Nothing */
}
test_mockable int gpio_get_level(enum gpio_signal signal)
{
return 0;
}
test_mockable void gpio_set_level(enum gpio_signal signal, int value)
{
/* Nothing */
}
test_mockable int gpio_enable_interrupt(enum gpio_signal signal)
{
return EC_SUCCESS;
}
test_mockable void gpio_set_flags_by_mask(uint32_t port, uint32_t mask,
uint32_t flags)
{
/* Nothing */
}
test_mockable void gpio_set_alternate_function(int port, int mask, int func)
{
/* Nothing */
}