summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-05-03 14:47:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-05 01:12:25 -0700
commitb803590c27796573f8e889796d15c16427225028 (patch)
treeece28d9c4da17acf73879dff94ffd4303be183c7
parentd6546857dab57079c50ae9f1140941fd8fb37229 (diff)
downloadchrome-ec-b803590c27796573f8e889796d15c16427225028.tar.gz
hooks: Add relative HOOK_INIT priority for peripherals
Using HOOK_PRIO_DEFAULT for peripheral initialization necessitates using HOOK_PRIO_DEFAULT+1 for board-level code. Instead, use a higher-than-default relative priority for peripheral initialization outside of board. BUG=None TEST=Verify PWM and ADC are functional on kevin. BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ia8e90a7a866bdb0a661099dd458e3dfcaaa3f6bb Reviewed-on: https://chromium-review.googlesource.com/342171 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/kevin/led_kevin.c2
-rw-r--r--chip/it83xx/fan.c2
-rw-r--r--chip/it83xx/pwm.c2
-rw-r--r--chip/it83xx/spi.c2
-rw-r--r--chip/lm4/fan.c3
-rw-r--r--chip/lm4/pwm.c2
-rw-r--r--chip/lm4/spi.c2
-rw-r--r--chip/mec1322/pwm.c2
-rw-r--r--chip/npcx/fan.c2
-rw-r--r--chip/npcx/pwm.c2
-rw-r--r--chip/npcx/spi.c2
-rw-r--r--chip/stm32/spi.c2
-rw-r--r--include/hooks.h12
13 files changed, 21 insertions, 16 deletions
diff --git a/board/kevin/led_kevin.c b/board/kevin/led_kevin.c
index 213e731782..711ab5d4ed 100644
--- a/board/kevin/led_kevin.c
+++ b/board/kevin/led_kevin.c
@@ -121,7 +121,7 @@ static void led_init(void)
set_color(LED_OFF);
}
/* After pwm_pin_init() */
-DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_INIT_PWM + 2);
+DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_DEFAULT);
/**
* Called by hook task every 250 ms
diff --git a/chip/it83xx/fan.c b/chip/it83xx/fan.c
index f61fbaa6f7..d412e14123 100644
--- a/chip/it83xx/fan.c
+++ b/chip/it83xx/fan.c
@@ -475,4 +475,4 @@ static void fan_init(void)
ext_timer_ms(FAN_CTRL_EXT_TIMER, EXT_PSR_32P768K_HZ, 0, 0,
FAN_CTRL_BASED_MS, 1, 0);
}
-DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_PWM);
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_FAN);
diff --git a/chip/it83xx/pwm.c b/chip/it83xx/pwm.c
index 89f71f9a1d..db9f180455 100644
--- a/chip/it83xx/pwm.c
+++ b/chip/it83xx/pwm.c
@@ -257,4 +257,4 @@ static void pwm_init(void)
}
/* The chip PWM module initialization. */
-DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_INIT_PWM);
diff --git a/chip/it83xx/spi.c b/chip/it83xx/spi.c
index e02c3d590d..6e876b3aee 100644
--- a/chip/it83xx/spi.c
+++ b/chip/it83xx/spi.c
@@ -168,4 +168,4 @@ static void sspi_init(void)
/* Disabling spi module */
spi_enable(spi_devices[i].port, 0);
}
-DECLARE_HOOK(HOOK_INIT, sspi_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, sspi_init, HOOK_PRIO_INIT_SPI);
diff --git a/chip/lm4/fan.c b/chip/lm4/fan.c
index 0153b275fc..39baa0a03e 100644
--- a/chip/lm4/fan.c
+++ b/chip/lm4/fan.c
@@ -188,4 +188,5 @@ static void fan_init(void)
/* Disable all fans */
LM4_FAN_FANCTL = 0;
}
-DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_PWM);
+/* Init before PWM */
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_FAN);
diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c
index c60a6be296..b7284c2bee 100644
--- a/chip/lm4/pwm.c
+++ b/chip/lm4/pwm.c
@@ -67,4 +67,4 @@ static void pwm_init(void)
}
/* The chip-specific fan module initializes before this. */
-DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_INIT_PWM);
diff --git a/chip/lm4/spi.c b/chip/lm4/spi.c
index b0b92d86e6..60394bb936 100644
--- a/chip/lm4/spi.c
+++ b/chip/lm4/spi.c
@@ -138,7 +138,7 @@ static int spi_init(void)
return EC_SUCCESS;
}
-DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_INIT_SPI);
/*****************************************************************************/
/* Console commands */
diff --git a/chip/mec1322/pwm.c b/chip/mec1322/pwm.c
index 0c3f97baa3..3708300f71 100644
--- a/chip/mec1322/pwm.c
+++ b/chip/mec1322/pwm.c
@@ -82,4 +82,4 @@ static void pwm_init(void)
pwm_set_duty(i, 0);
}
}
-DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_INIT_PWM);
diff --git a/chip/npcx/fan.c b/chip/npcx/fan.c
index 9836ff60bd..84cbd0e6f3 100644
--- a/chip/npcx/fan.c
+++ b/chip/npcx/fan.c
@@ -504,4 +504,4 @@ static void fan_init(void)
/* Enable the fan module and delay a few clocks */
clock_enable_peripheral(CGC_OFFSET_FAN, CGC_FAN_MASK, CGC_MODE_ALL);
}
-DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_PWM);
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_INIT_FAN);
diff --git a/chip/npcx/pwm.c b/chip/npcx/pwm.c
index e99ed039c2..32f676aa27 100644
--- a/chip/npcx/pwm.c
+++ b/chip/npcx/pwm.c
@@ -237,4 +237,4 @@ static void pwm_init(void)
}
/* The chip-specific fan module initializes before this. */
-DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_INIT_PWM);
diff --git a/chip/npcx/spi.c b/chip/npcx/spi.c
index b3d6ec07d7..a41dcf89eb 100644
--- a/chip/npcx/spi.c
+++ b/chip/npcx/spi.c
@@ -213,7 +213,7 @@ static void spi_init(void)
/* Cleaning junk data in the buffer */
clear_databuf();
}
-DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_INIT_SPI);
/*****************************************************************************/
/* Console commands */
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c
index 8f905d3855..032dd590a9 100644
--- a/chip/stm32/spi.c
+++ b/chip/stm32/spi.c
@@ -663,7 +663,7 @@ static void spi_init(void)
if (was_enabled || chipset_in_state(CHIPSET_STATE_ON))
spi_chipset_startup();
}
-DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, spi_init, HOOK_PRIO_INIT_SPI);
/**
* Get protocol information
diff --git a/include/hooks.h b/include/hooks.h
index 5c28401c8a..1eec3b7ff3 100644
--- a/include/hooks.h
+++ b/include/hooks.h
@@ -29,12 +29,16 @@ enum hook_priority {
HOOK_PRIO_INIT_LID = HOOK_PRIO_FIRST + 4,
/* Power button inits before chipset and switch */
HOOK_PRIO_INIT_POWER_BUTTON = HOOK_PRIO_FIRST + 5,
- /* PWM inits before modules which might use it (fans, LEDs) */
- HOOK_PRIO_INIT_PWM = HOOK_PRIO_FIRST + 6,
+ /* Init fan before PWM */
+ HOOK_PRIO_INIT_FAN = HOOK_PRIO_FIRST + 6,
+ /* PWM inits before modules which might use it (LEDs) */
+ HOOK_PRIO_INIT_PWM = HOOK_PRIO_FIRST + 7,
+ /* SPI inits before modules which might use it (sensors) */
+ HOOK_PRIO_INIT_SPI = HOOK_PRIO_FIRST + 8,
/* Extpower inits before modules which might use it (battery, LEDs) */
- HOOK_PRIO_INIT_EXTPOWER = HOOK_PRIO_FIRST + 7,
+ HOOK_PRIO_INIT_EXTPOWER = HOOK_PRIO_FIRST + 9,
/* Init VBOOT hash later, since it depends on deferred functions */
- HOOK_PRIO_INIT_VBOOT_HASH = HOOK_PRIO_FIRST + 8,
+ HOOK_PRIO_INIT_VBOOT_HASH = HOOK_PRIO_FIRST + 10,
/* Specific values to lump temperature-related hooks together */
HOOK_PRIO_TEMP_SENSOR = 6000,