summaryrefslogtreecommitdiff
path: root/chip/lm4/peci.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-08-02 14:28:43 -0700
committerChromeBot <chrome-bot@google.com>2013-08-07 12:43:35 -0700
commitf2b56fcb9fe078d5a29f1c3744e47e77240cd4e7 (patch)
tree4ff810332c543871da7febb2cc21597eee800b6d /chip/lm4/peci.c
parentce704b40005c1acdffabe58f47df42c1d7da33c2 (diff)
downloadchrome-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/lm4/peci.c')
-rw-r--r--chip/lm4/peci.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c
index b547165b49..b791c97a89 100644
--- a/chip/lm4/peci.c
+++ b/chip/lm4/peci.c
@@ -40,18 +40,6 @@
static int temp_vals[TEMP_AVG_LENGTH];
static int temp_idx = 0;
-/**
- * Configure the GPIOs for the PECI module.
- */
-static void configure_gpios(void)
-{
- /* PJ6 alternate function 1 = PECI Tx */
- gpio_set_alternate_function(LM4_GPIO_J, 0x40, 1);
-
- /* PJ7 analog input = PECI Rx (comparator) */
- LM4_GPIO_DEN(LM4_GPIO_J) &= ~0x80;
-}
-
int peci_get_cpu_temp(void)
{
int v = LM4_PECI_M0D0 & 0xffff;
@@ -120,15 +108,14 @@ DECLARE_HOOK(HOOK_FREQ_CHANGE, peci_freq_changed, HOOK_PRIO_DEFAULT - 1);
static void peci_init(void)
{
- volatile uint32_t scratch __attribute__((unused));
int i;
/* Enable the PECI module and delay a few clocks */
LM4_SYSTEM_RCGCPECI = 1;
- scratch = LM4_SYSTEM_RCGCPECI;
+ clock_wait_cycles(3);
/* Configure GPIOs */
- configure_gpios();
+ gpio_config_module(MODULE_PECI, 1);
/* Set initial clock frequency */
peci_freq_changed();