diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index 096ef19255..5c03b77e36 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -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 } diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index 1d73827c2b..985c6b913e 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -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); }