diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-04-19 12:42:35 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-04-19 13:08:58 -0700 |
commit | f4e772708bde3e4e1d184190a7f0be2417d2029a (patch) | |
tree | 4b668c02a9a6dca2704e6d0a8b3cb8e5c9e95b76 /chip | |
parent | d5d2159c6d215b3a0feca42d961985cd37603ca8 (diff) | |
download | chrome-ec-f4e772708bde3e4e1d184190a7f0be2417d2029a.tar.gz |
Added HOOK_INIT for driver module inits
This covers modules which need to initialize before task_start(), but
don't particularly care in what order they're initialized.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=none
TEST=if it boots, it works
Change-Id: I69829aac8d1c3c14ee04916a794b84bbf03a09eb
Diffstat (limited to 'chip')
-rw-r--r-- | chip/lm4/adc.c | 9 | ||||
-rw-r--r-- | chip/lm4/gpio.c | 4 | ||||
-rw-r--r-- | chip/lm4/i2c.c | 3 | ||||
-rw-r--r-- | chip/lm4/lpc.c | 4 | ||||
-rw-r--r-- | chip/lm4/onewire.c | 6 | ||||
-rw-r--r-- | chip/lm4/peci.c | 3 | ||||
-rw-r--r-- | chip/lm4/power_button.c | 4 | ||||
-rw-r--r-- | chip/lm4/pwm.c | 4 | ||||
-rw-r--r-- | chip/stm32l/gpio.c | 4 | ||||
-rw-r--r-- | chip/stm32l/i2c.c | 7 | ||||
-rw-r--r-- | chip/stm32l/spi.c | 13 |
11 files changed, 43 insertions, 18 deletions
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c index eb09235351..18f8dbe3a7 100644 --- a/chip/lm4/adc.c +++ b/chip/lm4/adc.c @@ -8,6 +8,7 @@ #include "adc.h" #include "console.h" #include "gpio.h" +#include "hooks.h" #include "lm4_adc.h" #include "registers.h" #include "task.h" @@ -47,6 +48,7 @@ const uint32_t ain_port[24][2] = { {LM4_GPIO_N, (1<<0)}, }; + static void configure_gpio(void) { int i; @@ -66,6 +68,7 @@ static void configure_gpio(void) } } + int lm4_adc_flush_and_read(enum lm4_adc_sequencer seq) { /* TODO: right now we have only a single channel so this is @@ -107,6 +110,7 @@ int lm4_adc_flush_and_read(enum lm4_adc_sequencer seq) return LM4_ADC_SSFIFO(seq); } + int lm4_adc_configure(enum lm4_adc_sequencer seq, int ain_id, int ssctl) @@ -133,6 +137,7 @@ int lm4_adc_configure(enum lm4_adc_sequencer seq, return EC_SUCCESS; } + int adc_read_channel(enum adc_channel ch) { const struct adc_t *adc = adc_channels + ch; @@ -181,6 +186,7 @@ static int command_ectemp(int argc, char **argv) } DECLARE_CONSOLE_COMMAND(ectemp, command_ectemp); + static int command_adc(int argc, char **argv) { int i; @@ -197,7 +203,7 @@ DECLARE_CONSOLE_COMMAND(adc, command_adc); /*****************************************************************************/ /* Initialization */ -int adc_init(void) +static int adc_init(void) { int i; const struct adc_t *adc; @@ -231,3 +237,4 @@ int adc_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c index a7c4f96163..114e1a37a1 100644 --- a/chip/lm4/gpio.c +++ b/chip/lm4/gpio.c @@ -7,6 +7,7 @@ #include "board.h" #include "gpio.h" +#include "hooks.h" #include "power_button.h" #include "registers.h" #include "task.h" @@ -116,7 +117,7 @@ int gpio_pre_init(void) } -int gpio_init(void) +static int gpio_init(void) { /* Enable IRQs now that pins are set up */ task_enable_irq(LM4_IRQ_GPIOA); @@ -141,6 +142,7 @@ int gpio_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT); void gpio_set_alternate_function(int port, int mask, int func) diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index c712adf641..8a5a93b3c8 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -437,7 +437,7 @@ static void configure_gpio(void) } -int i2c_init(void) +static int i2c_init(void) { volatile uint32_t scratch __attribute__((unused)); int i; @@ -474,3 +474,4 @@ int i2c_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index 647ed67e7d..c8b45df798 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -7,6 +7,7 @@ #include "board.h" #include "gpio.h" +#include "hooks.h" #include "host_command.h" #include "i8042.h" #include "lpc.h" @@ -105,7 +106,7 @@ static void lpc_generate_sci(void) } -int lpc_init(void) +static int lpc_init(void) { volatile uint32_t scratch __attribute__((unused)); @@ -200,6 +201,7 @@ int lpc_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, lpc_init, HOOK_PRIO_DEFAULT); uint8_t *lpc_get_host_range(int slot) diff --git a/chip/lm4/onewire.c b/chip/lm4/onewire.c index 3cfb7c7401..d505ff5c08 100644 --- a/chip/lm4/onewire.c +++ b/chip/lm4/onewire.c @@ -7,8 +7,9 @@ #include "board.h" #include "gpio.h" -#include "timer.h" +#include "hooks.h" #include "registers.h" +#include "timer.h" #define ONEWIRE_PIN (1<<2) /* One-wire pin mask (on GPIO H) */ @@ -131,10 +132,11 @@ static void configure_gpio(void) } -int onewire_init(void) +static int onewire_init(void) { /* Configure GPIOs */ configure_gpio(); return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, onewire_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c index 0e7540fa10..8accb1d1d5 100644 --- a/chip/lm4/peci.c +++ b/chip/lm4/peci.c @@ -114,7 +114,7 @@ DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp); /*****************************************************************************/ /* Initialization */ -int peci_init(void) +static int peci_init(void) { volatile uint32_t scratch __attribute__((unused)); @@ -130,3 +130,4 @@ int peci_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, peci_init, HOOK_PRIO_DEFAULT); diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index d4752f8311..837c67c214 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -9,6 +9,7 @@ #include "console.h" #include "eoption.h" #include "gpio.h" +#include "hooks.h" #include "keyboard.h" #include "keyboard_scan.h" #include "lpc.h" @@ -287,7 +288,7 @@ void power_button_interrupt(enum gpio_signal signal) } -int power_button_init(void) +static int power_button_init(void) { /* Set up memory-mapped switch positions */ memmap_switches = lpc_get_memmap_range() + EC_LPC_MEMMAP_SWITCHES; @@ -331,6 +332,7 @@ int power_button_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, power_button_init, HOOK_PRIO_DEFAULT); void power_button_task(void) diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c index 7fc95f0124..0a37ffc5b8 100644 --- a/chip/lm4/pwm.c +++ b/chip/lm4/pwm.c @@ -8,6 +8,7 @@ #include "board.h" #include "console.h" #include "gpio.h" +#include "hooks.h" #include "pwm.h" #include "registers.h" #include "uart.h" @@ -272,7 +273,7 @@ DECLARE_CONSOLE_COMMAND(kblight, command_kblight); /*****************************************************************************/ /* Initialization */ -int pwm_init(void) +static int pwm_init(void) { volatile uint32_t scratch __attribute__((unused)); @@ -324,3 +325,4 @@ int pwm_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT); diff --git a/chip/stm32l/gpio.c b/chip/stm32l/gpio.c index bbde5ab741..0f3e7f44a5 100644 --- a/chip/stm32l/gpio.c +++ b/chip/stm32l/gpio.c @@ -7,6 +7,7 @@ #include "board.h" #include "gpio.h" +#include "hooks.h" #include "registers.h" #include "task.h" #include "uart.h" @@ -66,7 +67,7 @@ int gpio_pre_init(void) } -int gpio_init(void) +static int gpio_init(void) { /* Enable IRQs now that pins are set up */ task_enable_irq(STM32L_IRQ_EXTI0); @@ -79,6 +80,7 @@ int gpio_init(void) return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, gpio_init, HOOK_PRIO_DEFAULT); void gpio_set_alternate_function(int port, int mask, int func) diff --git a/chip/stm32l/i2c.c b/chip/stm32l/i2c.c index 98d15525fa..ccf7dba63e 100644 --- a/chip/stm32l/i2c.c +++ b/chip/stm32l/i2c.c @@ -7,8 +7,9 @@ #include "common.h" #include "console.h" #include "gpio.h" +#include "hooks.h" #include "i2c.h" -#include <message.h> +#include "message.h" #include "registers.h" #include "task.h" #include "uart.h" @@ -222,7 +223,8 @@ static int i2c_init2(void) return EC_SUCCESS; } -int i2c_init(void) + +static int i2c_init(void) { int rc = 0; @@ -230,3 +232,4 @@ int i2c_init(void) rc |= i2c_init2(); return rc; } +DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT); diff --git a/chip/stm32l/spi.c b/chip/stm32l/spi.c index c3878b50d2..76d64eee94 100644 --- a/chip/stm32l/spi.c +++ b/chip/stm32l/spi.c @@ -1,16 +1,16 @@ -/* +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * * SPI driver for Chrome EC. * * This uses DMA although not in an optimal way yet. - * - * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ #include "console.h" #include "dma.h" #include "gpio.h" +#include "hooks.h" #include "message.h" #include "registers.h" #include "spi.h" @@ -154,7 +154,7 @@ static void spi1_interrupt(void) { spi_interrupt(STM32L_SPI1_PORT); }; DECLARE_IRQ(STM32L_IRQ_SPI1, spi1_interrupt, 2); -int spi_init(void) +static int spi_init(void) { int port; @@ -186,3 +186,4 @@ int spi_init(void) #endif return EC_SUCCESS; } +DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_DEFAULT); |