diff options
Diffstat (limited to 'board')
-rw-r--r-- | board/bds/board.c | 13 | ||||
-rw-r--r-- | board/bds/board.h | 13 | ||||
-rw-r--r-- | board/bolt/board.c | 37 | ||||
-rw-r--r-- | board/bolt/board.h | 16 | ||||
-rw-r--r-- | board/daisy/board.c | 20 | ||||
-rw-r--r-- | board/daisy/board.h | 9 | ||||
-rw-r--r-- | board/falco/board.c | 27 | ||||
-rw-r--r-- | board/falco/board.h | 15 | ||||
-rw-r--r-- | board/host/board.c | 5 | ||||
-rw-r--r-- | board/host/board.h | 6 | ||||
-rw-r--r-- | board/kirby/board.c | 21 | ||||
-rw-r--r-- | board/kirby/board.h | 10 | ||||
-rw-r--r-- | board/link/board.c | 37 | ||||
-rw-r--r-- | board/link/board.h | 19 | ||||
-rw-r--r-- | board/mccroskey/board.c | 9 | ||||
-rw-r--r-- | board/mccroskey/board.h | 7 | ||||
-rw-r--r-- | board/peppy/board.c | 25 | ||||
-rw-r--r-- | board/peppy/board.h | 15 | ||||
-rw-r--r-- | board/pit/board.c | 21 | ||||
-rw-r--r-- | board/pit/board.h | 10 | ||||
-rw-r--r-- | board/puppy/board.c | 21 | ||||
-rw-r--r-- | board/puppy/board.h | 10 | ||||
-rw-r--r-- | board/slippy/board.c | 25 | ||||
-rw-r--r-- | board/slippy/board.h | 15 | ||||
-rw-r--r-- | board/snow/board.c | 9 | ||||
-rw-r--r-- | board/snow/board.h | 8 | ||||
-rw-r--r-- | board/spring/board.c | 9 | ||||
-rw-r--r-- | board/spring/board.h | 7 | ||||
-rw-r--r-- | board/wolf/board.c | 25 | ||||
-rw-r--r-- | board/wolf/board.h | 15 |
30 files changed, 323 insertions, 156 deletions
diff --git a/board/bds/board.c b/board/bds/board.c index 830b8fcf41..915679d4c3 100644 --- a/board/bds/board.c +++ b/board/bds/board.c @@ -41,10 +41,19 @@ BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); /* GPIO signal list. Must match order from enum gpio_signal. */ const struct gpio_info gpio_list[] = { - {"RECOVERYn", LM4_GPIO_D, (1<<1), GPIO_PULL_UP, NULL}, - {"DEBUG_LED", LM4_GPIO_A, (1<<7), GPIO_OUT_LOW, NULL}, + {"RECOVERYn", GPIO_D, (1<<1), GPIO_PULL_UP, NULL}, + {"DEBUG_LED", GPIO_A, (1<<7), GPIO_OUT_LOW, NULL}, /* Unimplemented signals which we need to emulate for now */ GPIO_SIGNAL_NOT_IMPLEMENTED("WP"), GPIO_SIGNAL_NOT_IMPLEMENTED("ENTERING_RW"), }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); + +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_G, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_G, 0x80, 3, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_B, 0x03, 1, MODULE_UART}, /* UART1 */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); diff --git a/board/bds/board.h b/board/bds/board.h index 61c7c5a7f9..9d4672a34d 100644 --- a/board/bds/board.h +++ b/board/bds/board.h @@ -27,8 +27,14 @@ #ifndef __ASSEMBLER__ -enum adc_channel -{ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_UART, +}; + +enum adc_channel { ADC_CH_EC_TEMP = 0, /* EC internal die temperature in degrees K. */ ADC_CH_BDS_POT, /* BDS pot input. */ ADC_CH_COUNT @@ -39,9 +45,8 @@ enum adc_channel /* Number of I2C ports used */ #define I2C_PORTS_USED 1 -/* GPIOs for second UART port */ +/* Second UART port */ #define CONFIG_UART_HOST 1 -#define CONFIG_UART_HOST_GPIOS_PB0_1 /* GPIO signal list */ enum gpio_signal { diff --git a/board/bolt/board.c b/board/bolt/board.c index ccdc8bce87..de4a3d18e9 100644 --- a/board/bolt/board.c +++ b/board/bolt/board.c @@ -127,6 +127,25 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_A, 0x40, 3, MODULE_I2C}, /* I2C1 SCL */ + {GPIO_A, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C1 SDA */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_G, 0x30, 1, MODULE_UART}, /* UART2 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_N, 0x0c, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ + {GPIO_N, 0x40, 1, MODULE_PWM_KBLIGHT}, /* Fan1 PWM */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -193,15 +212,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PN2:3 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1); -} - -/** * Perform necessary actions on host wake events. */ void board_process_wake_events(uint32_t active_wake_events) @@ -217,12 +227,3 @@ void board_process_wake_events(uint32_t active_wake_events) else gpio_set_level(GPIO_PCH_WAKE_L, 1); } - -/** - * Configure the GPIOs for the pwm module. - */ -void configure_kblight_gpios(void) -{ - /* PN6 alternate function 1 = channel 4 PWM */ - gpio_set_alternate_function(LM4_GPIO_N, 0x40, 1); -} diff --git a/board/bolt/board.h b/board/bolt/board.h index 3fed8c42f4..c646456a95 100644 --- a/board/bolt/board.h +++ b/board/bolt/board.h @@ -42,6 +42,7 @@ #define CONFIG_PWM_FAN #define CONFIG_PWM_KBLIGHT #define CONFIG_TEMP_SENSOR +#define CONFIG_UART_HOST 2 #define CONFIG_WIRELESS #if 0 #define CONFIG_USB_PORT_POWER_DUMB @@ -50,6 +51,17 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_PWM_KBLIGHT, + MODULE_UART, +}; + /* PWM channels */ #define FAN_CH_CPU 2 /* CPU fan */ #define FAN_CH_KBLIGHT 4 /* Keyboard backlight */ @@ -73,10 +85,6 @@ /* USB ports */ #define USB_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 2 -#define CONFIG_UART_HOST_GPIOS_PG4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/daisy/board.c b/board/daisy/board.c index 39eda5e549..2a6eb6e3a5 100644 --- a/board/daisy/board.c +++ b/board/daisy/board.c @@ -101,6 +101,14 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x0004, GPIO_ALT_TIM2, MODULE_POWER_LED}, + {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART}, + {GPIO_B, 0x0cc0, GPIO_ALT_I2C, MODULE_I2C}, +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 5, @@ -158,18 +166,6 @@ int board_i2c_host_port(void) } #endif /* CONFIG_I2C_HOST_AUTO */ -void board_config_post_gpio_init(void) -{ - /* I2C SCL/SDA on PB10-11 and PB6-7 */ - gpio_set_alternate_function(GPIO_B, (1<<11) | - (1<<10) | - (1<<7) | - (1<<6), GPIO_ALT_I2C); - - /* Select Alternate function for USART1 on pins PA9/PA10 */ - gpio_set_alternate_function(GPIO_A, (1<<9) | (1<<10), GPIO_ALT_USART); -} - void keyboard_suppress_noise(void) { /* notify audio codec of keypress for noise suppression */ diff --git a/board/daisy/board.h b/board/daisy/board.h index a76735a4f2..c2af3ef525 100644 --- a/board/daisy/board.h +++ b/board/daisy/board.h @@ -13,7 +13,6 @@ /* Optional features */ #define CONFIG_BATTERY_SMART -#define CONFIG_BOARD_POST_GPIO_INIT #define CONFIG_CHARGER_TPS65090 #ifdef HAS_TASK_CHIPSET #define CONFIG_CHIPSET_GAIA @@ -37,6 +36,14 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_POWER_LED, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/falco/board.c b/board/falco/board.c index 3b9a197584..acb601b917 100644 --- a/board/falco/board.c +++ b/board/falco/board.c @@ -125,6 +125,24 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_A, 0x40, 3, MODULE_I2C}, /* I2C1 SCL */ + {GPIO_A, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C1 SDA */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_G, 0x30, 1, MODULE_UART}, /* UART2 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_N, 0x0c, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -195,15 +213,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PN2:3 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1); -} - -/** * Perform necessary actions on host wake events. */ void board_process_wake_events(uint32_t active_wake_events) diff --git a/board/falco/board.h b/board/falco/board.h index 8abf578cb7..c0b9f656cc 100644 --- a/board/falco/board.h +++ b/board/falco/board.h @@ -30,11 +30,22 @@ #define CONFIG_PWM_FAN #define CONFIG_TEMP_SENSOR #define CONFIG_TEMP_SENSOR_G781 +#define CONFIG_UART_HOST 2 #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_WIRELESS #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_UART, +}; + /* PWM channels */ #define FAN_CH_CPU 2 /* CPU fan */ #define FAN_CH_BL_DISPLAY 4 /* LVDS backlight (from PCH, cleaned by EC) */ @@ -57,10 +68,6 @@ /* USB ports */ #define USB_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 2 -#define CONFIG_UART_HOST_GPIOS_PG4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/host/board.c b/board/host/board.c index 13389ce001..0490d2287e 100644 --- a/board/host/board.c +++ b/board/host/board.c @@ -20,6 +20,11 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions; not on simulated host platform */ +const struct gpio_alt_func gpio_alt_funcs[] = { +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + static int dummy_temp_get_val(int idx, int *temp_ptr) { *temp_ptr = 0; diff --git a/board/host/board.h b/board/host/board.h index f84696d58b..3707e2a1f4 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -36,6 +36,12 @@ #define CONFIG_WP_ACTIVE_HIGH +/* Module IDs */ +enum module_id { + MODULE_I2C, + MODULE_UART, +}; + enum gpio_signal { GPIO_EC_INT, GPIO_LID_OPEN, diff --git a/board/kirby/board.c b/board/kirby/board.c index f22bebd44f..169dc420ab 100644 --- a/board/kirby/board.c +++ b/board/kirby/board.c @@ -93,6 +93,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_C, 0x00e0, GPIO_ALT_TIM3_4, MODULE_LED_KIRBY}, + {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI}, + {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART}, + {GPIO_B, 0x00c0, GPIO_ALT_I2C, MODULE_I2C}, +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 0, @@ -108,15 +117,3 @@ const struct i2c_port_t i2c_ports[] = { {"host", I2C_PORT_HOST, 100}, }; BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); - -void board_config_post_gpio_init(void) -{ - /* I2C SCL/SDA on PB6-7 */ - gpio_set_alternate_function(GPIO_B, (1 << 7) | (1 << 6), GPIO_ALT_I2C); - - /* USART1 on pins PA9/PA10 */ - gpio_set_alternate_function(GPIO_A, (1 << 9) | (1 << 10), - GPIO_ALT_USART); - - /* TODO: Set TIM3 for PC6-8 here? */ -} diff --git a/board/kirby/board.h b/board/kirby/board.h index 5b63b9ce82..2ac8ba6d8b 100644 --- a/board/kirby/board.h +++ b/board/kirby/board.h @@ -9,7 +9,6 @@ #define __BOARD_H /* Optional features */ -#define CONFIG_BOARD_POST_GPIO_INIT #ifdef HAS_TASK_CHIPSET #define CONFIG_CHIPSET_GAIA #endif @@ -21,6 +20,15 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LED_KIRBY, + MODULE_SPI, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/link/board.c b/board/link/board.c index cfcc695ecd..1eac758978 100644 --- a/board/link/board.c +++ b/board/link/board.c @@ -125,6 +125,25 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_A, 0x40, 3, MODULE_I2C}, /* I2C1 SCL */ + {GPIO_A, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C1 SDA */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_C, 0x30, 2, MODULE_UART}, /* UART1 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_K, 0x40, 1, MODULE_PWM_KBLIGHT}, /* Fan1 PWM */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0xc0, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PGOOD_5VALW, 1, "PGOOD_5VALW"}, @@ -217,15 +236,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PM6:7 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_M, 0xc0, 1); -} - -/** * Perform necessary actions on host events. */ void board_process_wake_events(uint32_t active_wake_events) @@ -236,12 +246,3 @@ void board_process_wake_events(uint32_t active_wake_events) else gpio_set_level(GPIO_PCH_WAKE_L, 1); } - -/** - * Configure the GPIOs for the pwm module. - */ -void configure_kblight_gpios(void) -{ - /* PK6 alternate function 1 = channel 1 PWM */ - gpio_set_alternate_function(LM4_GPIO_K, 0x40, 1); -} diff --git a/board/link/board.h b/board/link/board.h index ea6d2f1f62..c81db98525 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -32,19 +32,30 @@ #define CONFIG_PWM_KBLIGHT #define CONFIG_TEMP_SENSOR #define CONFIG_TEMP_SENSOR_TMP006 +#define CONFIG_UART_HOST 1 #define CONFIG_USB_PORT_POWER_SMART #define CONFIG_WIRELESS #define CONFIG_WP_ACTIVE_HIGH #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_PWM_KBLIGHT, + MODULE_UART, +}; + /* Fan PWM channels */ #define FAN_CH_CPU 0 /* CPU fan */ #define FAN_CH_KBLIGHT 1 /* Keyboard backlight */ #define FAN_CH_POWER_LED 5 /* Power adapter LED */ -enum adc_channel -{ +enum adc_channel { /* EC internal die temperature in degrees K. */ ADC_CH_EC_TEMP = 0, /* Charger current in mA. */ @@ -78,10 +89,6 @@ enum adc_channel /* USB charge port */ #define USB_CHARGE_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 1 -#define CONFIG_UART_HOST_GPIOS_PC4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/mccroskey/board.c b/board/mccroskey/board.c index 6f76563847..ca38624331 100644 --- a/board/mccroskey/board.c +++ b/board/mccroskey/board.c @@ -98,6 +98,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + /* + * TODO(rspangler): use this instead of hard-coded register writes in + * board_config_pre_init(). + */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + void board_config_pre_init(void) { uint32_t val; diff --git a/board/mccroskey/board.h b/board/mccroskey/board.h index 0501c06ad6..8d2ac274ab 100644 --- a/board/mccroskey/board.h +++ b/board/mccroskey/board.h @@ -30,6 +30,13 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL) diff --git a/board/peppy/board.c b/board/peppy/board.c index 5a0cc05d5d..623eed7b50 100644 --- a/board/peppy/board.c +++ b/board/peppy/board.c @@ -124,6 +124,22 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_G, 0x30, 1, MODULE_UART}, /* UART2 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_N, 0x0c, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -188,15 +204,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PN2:3 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1); -} - -/** * Perform necessary actions on host wake events. */ void board_process_wake_events(uint32_t active_wake_events) diff --git a/board/peppy/board.h b/board/peppy/board.h index f8988e507a..db323df3e5 100644 --- a/board/peppy/board.h +++ b/board/peppy/board.h @@ -30,11 +30,22 @@ #define CONFIG_PWM_FAN #define CONFIG_TEMP_SENSOR #define CONFIG_TEMP_SENSOR_G781 +#define CONFIG_UART_HOST 2 #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_WIRELESS #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_UART, +}; + /* PWM channels */ #define FAN_CH_CPU 2 /* CPU fan */ #define FAN_CH_BL_DISPLAY 4 /* LVDS backlight (from PCH, cleaned by EC) */ @@ -56,10 +67,6 @@ /* USB ports */ #define USB_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 2 -#define CONFIG_UART_HOST_GPIOS_PG4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/pit/board.c b/board/pit/board.c index 684e61b1dc..6a5dc07c15 100644 --- a/board/pit/board.c +++ b/board/pit/board.c @@ -82,6 +82,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x0004, GPIO_ALT_TIM2, MODULE_POWER_LED}, + {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI}, + {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART}, + {GPIO_B, 0x0cc0, GPIO_ALT_I2C, MODULE_I2C}, +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 0, @@ -98,18 +107,6 @@ const struct i2c_port_t i2c_ports[] = { }; BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); -void board_config_post_gpio_init(void) -{ - /* I2C SCL/SDA on PB10-11 and PB6-7 */ - gpio_set_alternate_function(GPIO_B, - (1 << 11) | (1 << 10) | (1 << 7) | (1 << 6), - GPIO_ALT_I2C); - - /* USART1 on pins PA9/PA10 */ - gpio_set_alternate_function(GPIO_A, (1 << 9) | (1 << 10), - GPIO_ALT_USART); -} - int pmu_board_init(void) { int ver, failure = 0; diff --git a/board/pit/board.h b/board/pit/board.h index 0601d91ad2..046849cdc6 100644 --- a/board/pit/board.h +++ b/board/pit/board.h @@ -11,7 +11,6 @@ /* Optional features */ #define CONFIG_BATTERY_BQ20Z453 #define CONFIG_BATTERY_SMART -#define CONFIG_BOARD_POST_GPIO_INIT #ifdef HAS_TASK_CHARGER #define CONFIG_CHARGER_TPS65090 #endif @@ -30,6 +29,15 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_POWER_LED, + MODULE_SPI, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/puppy/board.c b/board/puppy/board.c index 0bb2eb3a6c..be011561ac 100644 --- a/board/puppy/board.c +++ b/board/puppy/board.c @@ -82,6 +82,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x0004, GPIO_ALT_TIM2, MODULE_POWER_LED}, + {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI}, + {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART}, + {GPIO_B, 0x0cc0, GPIO_ALT_I2C, MODULE_I2C}, +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 5, @@ -98,18 +107,6 @@ const struct i2c_port_t i2c_ports[] = { }; BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); -void board_config_post_gpio_init(void) -{ - /* I2C SCL/SDA on PB10-11 and PB6-7 */ - gpio_set_alternate_function(GPIO_B, - (1 << 11) | (1 << 10) | (1 << 7) | (1 << 6), - GPIO_ALT_I2C); - - /* USART1 on pins PA9/PA10 */ - gpio_set_alternate_function(GPIO_A, (1 << 9) | (1 << 10), - GPIO_ALT_USART); -} - int pmu_board_init(void) { int ver, failure = 0; diff --git a/board/puppy/board.h b/board/puppy/board.h index 024d3ec6d4..8a17472d8c 100644 --- a/board/puppy/board.h +++ b/board/puppy/board.h @@ -11,7 +11,6 @@ /* Optional features */ #define CONFIG_BATTERY_BQ20Z453 #define CONFIG_BATTERY_SMART -#define CONFIG_BOARD_POST_GPIO_INIT #ifdef HAS_TASK_CHARGER #define CONFIG_CHARGER_TPS65090 #endif @@ -29,6 +28,15 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_POWER_LED, + MODULE_SPI, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/slippy/board.c b/board/slippy/board.c index fbeb7e7224..8273ca4e3f 100644 --- a/board/slippy/board.c +++ b/board/slippy/board.c @@ -122,6 +122,22 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_G, 0x30, 1, MODULE_UART}, /* UART2 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_N, 0x0c, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -188,15 +204,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PN2:3 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1); -} - -/** * Perform necessary actions on host wake events. */ void board_process_wake_events(uint32_t active_wake_events) diff --git a/board/slippy/board.h b/board/slippy/board.h index c8f3d8a38f..aa0cf467e7 100644 --- a/board/slippy/board.h +++ b/board/slippy/board.h @@ -31,11 +31,22 @@ #define CONFIG_PWM_FAN #define CONFIG_TEMP_SENSOR #define CONFIG_TEMP_SENSOR_G781 +#define CONFIG_UART_HOST 2 #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_WIRELESS #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_UART, +}; + /* PWM channels */ #define FAN_CH_CPU 2 /* CPU fan */ #define FAN_CH_BL_DISPLAY 4 /* LVDS backlight (from PCH, cleaned by EC) */ @@ -57,10 +68,6 @@ /* USB ports */ #define USB_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 2 -#define CONFIG_UART_HOST_GPIOS_PG4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/snow/board.c b/board/snow/board.c index 79cacf4e90..55e8012972 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -95,6 +95,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + /* + * TODO(rspangler): use this instead of hard-coded register writes in + * board_config_pre_init(). + */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 5, diff --git a/board/snow/board.h b/board/snow/board.h index def9540363..1b97b05ebb 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -36,6 +36,14 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_POWER_LED, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/spring/board.c b/board/spring/board.c index fa156d0ae4..44c231ad79 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -95,6 +95,15 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + /* + * TODO(rspangler): use this instead of hard-coded register writes in + * board_config_pre_init(). + */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { .start_charging_min_c = 5, diff --git a/board/spring/board.h b/board/spring/board.h index be9971f85e..6fe6858908 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -38,6 +38,13 @@ #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_UART, +}; + /* By default, enable all console messages except keyboard */ #define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN)) diff --git a/board/wolf/board.c b/board/wolf/board.c index fe0db01e86..887ce30cc6 100644 --- a/board/wolf/board.c +++ b/board/wolf/board.c @@ -120,6 +120,22 @@ const struct gpio_info gpio_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +/* Pins with alternate functions */ +const struct gpio_alt_func gpio_alt_funcs[] = { + {GPIO_A, 0x03, 1, MODULE_UART}, /* UART0 */ + {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */ + {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */ + {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */ + {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */ + {GPIO_G, 0x30, 1, MODULE_UART}, /* UART2 */ + {GPIO_J, 0x40, 1, MODULE_PECI}, /* PECI Tx */ + {GPIO_J, 0x80, 0, MODULE_PECI, GPIO_ANALOG}, /* PECI Rx */ + {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */ + {GPIO_M, 0x33, 15, MODULE_LPC}, /* LPC */ + {GPIO_N, 0x0c, 1, MODULE_PWM_FAN}, /* Fan0 PWM/tach */ +}; +const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); + /* x86 signal list. Must match order of enum x86_signal. */ const struct x86_signal_info x86_signal_list[] = { {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"}, @@ -185,15 +201,6 @@ struct keyboard_scan_config keyscan_config = { }; /** - * Configure the GPIOs for the pwm module. - */ -void configure_fan_gpios(void) -{ - /* PN2:3 alternate function 1 = channel 0 PWM/tach */ - gpio_set_alternate_function(LM4_GPIO_N, 0x0c, 1); -} - -/** * Perform necessary actions on host wake events. */ void board_process_wake_events(uint32_t active_wake_events) diff --git a/board/wolf/board.h b/board/wolf/board.h index 22da17b654..7ade111cf0 100644 --- a/board/wolf/board.h +++ b/board/wolf/board.h @@ -23,11 +23,22 @@ #define CONFIG_POWER_BUTTON_X86 #define CONFIG_PWM_FAN #define CONFIG_TEMP_SENSOR +#define CONFIG_UART_HOST 2 #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_WIRELESS #ifndef __ASSEMBLER__ +/* Module IDs */ +/* TODO(rspangler): use this in place of enum console_channel as well */ +enum module_id { + MODULE_I2C, + MODULE_LPC, + MODULE_PECI, + MODULE_PWM_FAN, + MODULE_UART, +}; + /* PWM channels */ #define FAN_CH_CPU 2 /* CPU fan */ #define FAN_CH_BL_DISPLAY 4 /* LVDS backlight (from PCH, cleaned by EC) */ @@ -49,10 +60,6 @@ /* USB ports */ #define USB_PORT_COUNT 2 -/* GPIOs for second UART port */ -#define CONFIG_UART_HOST 2 -#define CONFIG_UART_HOST_GPIOS_PG4_5 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ |