diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/hooks.c | 6 | ||||
-rw-r--r-- | common/main.c | 54 | ||||
-rw-r--r-- | common/usb_charge.c | 13 |
3 files changed, 20 insertions, 53 deletions
diff --git a/common/hooks.c b/common/hooks.c index 94bf2627fb..58ff10546a 100644 --- a/common/hooks.c +++ b/common/hooks.c @@ -10,6 +10,8 @@ #include "util.h" /* Hooks are described in special sections */ +extern const struct hook_data __hooks_init[]; +extern const struct hook_data __hooks_init_end[]; extern const struct hook_data __hooks_freq_change[]; extern const struct hook_data __hooks_freq_change_end[]; @@ -23,6 +25,10 @@ int hook_notify(enum hook_type type, int stop_on_error) /* Get the start and end pointers for the hook type */ switch (type) { + case HOOK_INIT: + start = __hooks_init; + end = __hooks_init_end; + break; case HOOK_FREQ_CHANGE: start = __hooks_freq_change; end = __hooks_freq_change_end; diff --git a/common/main.c b/common/main.c index 606a04d830..ce3d6fad68 100644 --- a/common/main.c +++ b/common/main.c @@ -5,36 +5,20 @@ * Main routine for Chrome EC */ -#include "adc.h" -#include "charger.h" -#include "chip_temp_sensor.h" #include "clock.h" #include "config.h" -#include "console.h" #include "eeprom.h" #include "eoption.h" #include "flash.h" #include "gpio.h" -#include "i2c.h" +#include "hooks.h" #include "jtag.h" #include "keyboard.h" #include "keyboard_scan.h" -#include "lpc.h" -#include "memory_commands.h" -#include "onewire.h" -#include "peci.h" -#include "port80.h" -#include "power_button.h" -#include "powerdemo.h" -#include "pwm.h" -#include "spi.h" #include "system.h" #include "task.h" -#include "temp_sensor.h" -#include "tmp006.h" #include "timer.h" #include "uart.h" -#include "usb_charge.h" #include "vboot.h" #include "watchdog.h" @@ -114,38 +98,12 @@ int main(void) * RO image and once in the RW image. */ vboot_init(); - /* Initialize driver modules. These can occur in any order. State - * machines are initialized in their task functions, not here. */ + /* TODO: reduce core clock now that vboot is done */ - gpio_init(); - -#ifdef CONFIG_LPC - lpc_init(); -#endif -#ifdef CONFIG_SPI - spi_init(); -#endif -#ifdef CONFIG_PWM - pwm_init(); -#endif -#ifdef CONFIG_I2C - i2c_init(); -#endif -#ifdef CONFIG_TASK_POWERBTN - power_button_init(); -#endif -#ifdef CONFIG_ADC - adc_init(); -#endif -#ifdef CONFIG_ONEWIRE - onewire_init(); -#endif -#ifdef CONFIG_PECI - peci_init(); -#endif -#ifdef CONFIG_USB_CHARGE - usb_charge_init(); -#endif + /* Initialize other driver modules. These can occur in any order. + * Non-driver modules with tasks do their inits from their task + * functions, not here. */ + hook_notify(HOOK_INIT, 0); /* Print the init time and reset cause. Init time isn't completely * accurate because it can't take into account the time for the first diff --git a/common/usb_charge.c b/common/usb_charge.c index 883bae5039..f14cfe393d 100644 --- a/common/usb_charge.c +++ b/common/usb_charge.c @@ -5,11 +5,12 @@ /* USB charging control module for Chrome EC */ -#include "usb_charge.h" #include "board.h" +#include "console.h" #include "gpio.h" +#include "hooks.h" #include "uart.h" -#include "console.h" +#include "usb_charge.h" #include "util.h" static void usb_charge_set_control_mode(int port_id, int mode) @@ -26,6 +27,7 @@ static void usb_charge_set_control_mode(int port_id, int mode) } } + static void usb_charge_set_enabled(int port_id, int en) { if (port_id == 0) @@ -34,6 +36,7 @@ static void usb_charge_set_enabled(int port_id, int en) gpio_set_level(GPIO_USB2_ENABLE, en); } + static void usb_charge_set_ilim(int port_id, int sel) { if (port_id == 0) @@ -42,6 +45,7 @@ static void usb_charge_set_ilim(int port_id, int sel) gpio_set_level(GPIO_USB2_ILIM_SEL, sel); } + int usb_charge_set_mode(int port_id, enum usb_charge_mode mode) { if (port_id >= USB_CHARGE_PORT_COUNT) @@ -77,7 +81,6 @@ int usb_charge_set_mode(int port_id, enum usb_charge_mode mode) return EC_SUCCESS; } - /*****************************************************************************/ /* Console commands */ @@ -114,11 +117,10 @@ static int command_set_mode(int argc, char **argv) } DECLARE_CONSOLE_COMMAND(usbchargemode, command_set_mode); - /*****************************************************************************/ /* Initialization */ -int usb_charge_init(void) +static int usb_charge_init(void) { int i; @@ -127,3 +129,4 @@ int usb_charge_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, usb_charge_init, HOOK_PRIO_DEFAULT); |