Set up I2C for link board

Also fixes a typo in power_button.c when compiled for link

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7528
TEST=none

Change-Id: Ib43ef9edefe0b0caba246faa4a0d12d66ff9e205
This commit is contained in:
Randall Spangler
2012-01-11 16:53:04 -08:00
parent c386a8ff37
commit d244f97bb9
2 changed files with 30 additions and 8 deletions

View File

@@ -209,18 +209,45 @@ static void configure_gpio(void)
{
volatile uint32_t scratch __attribute__((unused));
#ifdef BOARD_link
/* PA6:7 = I2C1 SCL/SDA; PB2:3 = I2C0 SCL/SDA; PB6:7 = I2C5 SCL/SDA */
/* Enable GPIOA,B modules and delay a few clocks */
LM4_SYSTEM_RCGCGPIO |= 0x0003;
scratch = LM4_SYSTEM_RCGCGPIO;
/* Use alternate function 3 for PA6:7, PB2:3, PB6:7 */
LM4_GPIO_AFSEL(LM4_GPIO_A) |= 0xc0;
LM4_GPIO_AFSEL(LM4_GPIO_B) |= 0xcc;
LM4_GPIO_PCTL(LM4_GPIO_A) =
(LM4_GPIO_PCTL(LM4_GPIO_A) & 0x00ffffff) | 0x33000000;
LM4_GPIO_PCTL(LM4_GPIO_B) =
(LM4_GPIO_PCTL(LM4_GPIO_B) & 0x00ff00ff) | 0x33003300;
LM4_GPIO_DEN(LM4_GPIO_A) |= 0xc0;
LM4_GPIO_DEN(LM4_GPIO_B) |= 0xcc;
/* Configure SDA as open-drain. SCL should not be open-drain,
* since it has an internal pull-up. */
LM4_GPIO_ODR(LM4_GPIO_A) |= 0x80;
LM4_GPIO_ODR(LM4_GPIO_B) |= 0x88;
#else
/* PG6:7 = I2C5 SCL/SDA */
/* Enable GPIOG module and delay a few clocks */
LM4_SYSTEM_RCGCGPIO |= 0x0040;
scratch = LM4_SYSTEM_RCGCGPIO;
/* Use alternate function 3 for PG6:7 */
LM4_GPIO_AFSEL(LM4_GPIO_G) |= 0xc0;
LM4_GPIO_PCTL(LM4_GPIO_G) = (LM4_GPIO_PCTL(LM4_GPIO_G) & 0x00ffffff) |
0x33000000;
LM4_GPIO_PCTL(LM4_GPIO_G) =
(LM4_GPIO_PCTL(LM4_GPIO_G) & 0x00ffffff) | 0x33000000;
LM4_GPIO_DEN(LM4_GPIO_G) |= 0xc0;
/* Configure SDA as open-drain. SCL should not be open-drain,
* since it has an internal pull-up. */
LM4_GPIO_ODR(LM4_GPIO_G) |= 0x80;
#endif
}

View File

@@ -49,10 +49,8 @@ static void lid_switch_isr(void)
{
/* TODO: Currently we pass through the LID_SW# pin to R_EC_LID_OUT#
* directly. Modify this if we need to consider more conditions. */
#ifdef BOARD_bds
gpio_set_level(GPIO_PCH_LID_SWITCHn,
gpio_get_level(GPIO_LID_SWITCHn));
#endif
}
@@ -68,12 +66,9 @@ static void lid_switch_isr(void)
*/
static void set_pwrbtn_to_pch(int high)
{
#ifdef BOARD_link
gpio_set_level(GPIO_PCH_PWRBTN, high);
#else
uart_printf("[%d] set_pwrbtn_to_pch(%s)\n",
get_time().le.lo, high ? "HIGH" : "LOW");
#endif
gpio_set_level(GPIO_PCH_PWRBTNn, high);
}