diff options
author | Yi Chou <yich@google.com> | 2023-03-28 12:30:59 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-25 13:23:42 +0000 |
commit | 438865216dc3e4b7c86da0af5817040b10e78778 (patch) | |
tree | 6df50f4449deb6618d1d2b95145108f0bd1d11d2 | |
parent | 5400a250e5a8df743cd19f0d6e2ed29d71cdd0b0 (diff) | |
download | chrome-ec-438865216dc3e4b7c86da0af5817040b10e78778.tar.gz |
clock: Add mock for clock_enable_module
BUG=b:248508087
TEST=make buildall -j
BRANCH=none
Force-Relevant-Builds: all
Change-Id: If691bd1400b65c5595b833293578e16208c49849
Signed-off-by: Yi Chou <yich@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4376399
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
-rw-r--r-- | chip/host/clock.c | 3 | ||||
-rw-r--r-- | chip/ish/clock.c | 2 | ||||
-rw-r--r-- | chip/it83xx/clock.c | 2 | ||||
-rw-r--r-- | chip/max32660/clock_chip.c | 2 | ||||
-rw-r--r-- | chip/mchp/clock.c | 2 | ||||
-rw-r--r-- | chip/mt_scp/mt818x/clock_mt8183.c | 2 | ||||
-rw-r--r-- | chip/mt_scp/mt818x/clock_mt8186.c | 2 | ||||
-rw-r--r-- | chip/mt_scp/mt8192/clock.c | 2 | ||||
-rw-r--r-- | chip/mt_scp/mt8195/clock.c | 2 | ||||
-rw-r--r-- | chip/npcx/clock.c | 6 | ||||
-rw-r--r-- | chip/stm32/clock-stm32f0.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32f3.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32f4.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32g4.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32h7.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32l.c | 2 | ||||
-rw-r--r-- | chip/stm32/clock-stm32l4.c | 2 | ||||
-rw-r--r-- | common/mock/build.mk | 1 | ||||
-rw-r--r-- | common/mock/clock_mock.c | 24 | ||||
-rw-r--r-- | include/mock/clock_mock.h | 23 | ||||
-rw-r--r-- | zephyr/shim/chip/it8xxx2/clock.c | 3 | ||||
-rw-r--r-- | zephyr/shim/chip/mchp/clock.c | 3 | ||||
-rw-r--r-- | zephyr/shim/chip/npcx/clock.c | 3 | ||||
-rw-r--r-- | zephyr/shim/chip/stm32/clock.c | 3 | ||||
-rw-r--r-- | zephyr/shim/chip/stub/clock.c | 3 |
25 files changed, 78 insertions, 24 deletions
diff --git a/chip/host/clock.c b/chip/host/clock.c index defb12f4f0..29fb0dfa5a 100644 --- a/chip/host/clock.c +++ b/chip/host/clock.c @@ -6,12 +6,13 @@ */ #include "clock.h" +#include "common.h" int clock_get_freq(void) { return 16000000; } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/ish/clock.c b/chip/ish/clock.c index 2fefa11c2f..133711edf7 100644 --- a/chip/ish/clock.c +++ b/chip/ish/clock.c @@ -30,6 +30,6 @@ void clock_refresh_console_in_use(void) ish_pm_refresh_console_in_use(); } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/it83xx/clock.c b/chip/it83xx/clock.c index abbbcf3b58..bd6ae01281 100644 --- a/chip/it83xx/clock.c +++ b/chip/it83xx/clock.c @@ -702,6 +702,6 @@ DECLARE_CONSOLE_COMMAND(idlestats, command_idle_stats, "", #endif /* CONFIG_CMD_IDLE_STATS */ #endif /* CONFIG_LOW_POWER_IDLE */ -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/max32660/clock_chip.c b/chip/max32660/clock_chip.c index 8e497c846b..83fb2fa1d1 100644 --- a/chip/max32660/clock_chip.c +++ b/chip/max32660/clock_chip.c @@ -140,6 +140,6 @@ void clock_init(void) } } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/mchp/clock.c b/chip/mchp/clock.c index 8732e21117..812825db5a 100644 --- a/chip/mchp/clock.c +++ b/chip/mchp/clock.c @@ -751,6 +751,6 @@ DECLARE_CONSOLE_COMMAND( "See also 'sleep mask'."); #endif /* CONFIG_LOW_POWER_IDLE */ -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/mt_scp/mt818x/clock_mt8183.c b/chip/mt_scp/mt818x/clock_mt8183.c index a48eee952a..5c99d7b393 100644 --- a/chip/mt_scp/mt818x/clock_mt8183.c +++ b/chip/mt_scp/mt818x/clock_mt8183.c @@ -371,6 +371,6 @@ static int command_ulposc(int argc, const char *argv[]) DECLARE_CONSOLE_COMMAND(ulposc, command_ulposc, "[calibrate]", "Calibrate ULPOSC frequency"); -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/mt_scp/mt818x/clock_mt8186.c b/chip/mt_scp/mt818x/clock_mt8186.c index eafc5992fd..a31ab6059c 100644 --- a/chip/mt_scp/mt818x/clock_mt8186.c +++ b/chip/mt_scp/mt818x/clock_mt8186.c @@ -377,6 +377,6 @@ static int command_ulposc(int argc, const char *argv[]) DECLARE_CONSOLE_COMMAND(ulposc, command_ulposc, "[calibrate]", "Calibrate ULPOSC frequency"); -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/mt_scp/mt8192/clock.c b/chip/mt_scp/mt8192/clock.c index ec6e3f2537..62339dae5f 100644 --- a/chip/mt_scp/mt8192/clock.c +++ b/chip/mt_scp/mt8192/clock.c @@ -382,6 +382,6 @@ DECLARE_CONSOLE_COMMAND(ulposc, command_ulposc, "[ulposc]", "Measure ULPOSC frequency"); #endif -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/mt_scp/mt8195/clock.c b/chip/mt_scp/mt8195/clock.c index e41a360ae8..9a0b978929 100644 --- a/chip/mt_scp/mt8195/clock.c +++ b/chip/mt_scp/mt8195/clock.c @@ -502,6 +502,6 @@ DECLARE_CONSOLE_COMMAND(ulposc, command_ulposc, "[ulposc]", "Measure ULPOSC frequency"); #endif -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/npcx/clock.c b/chip/npcx/clock.c index 992fc1b628..8b47d847e8 100644 --- a/chip/npcx/clock.c +++ b/chip/npcx/clock.c @@ -163,7 +163,7 @@ void clock_turbo(void) NPCX_HFCBCD = NPCX_HFCBCD & 0xF3; } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } @@ -194,7 +194,7 @@ void clock_normal(void) NPCX_HFCBCD = (FIUDIV << 4); } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { /* Assume we have a single task using MODULE_FAST_CPU */ if (module == MODULE_FAST_CPU) { @@ -207,7 +207,7 @@ void clock_enable_module(enum module_id module, int enable) #else -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/chip/stm32/clock-stm32f0.c b/chip/stm32/clock-stm32f0.c index 18c089b036..64b0b45e50 100644 --- a/chip/stm32/clock-stm32f0.c +++ b/chip/stm32/clock-stm32f0.c @@ -398,7 +398,7 @@ void clock_wait_bus_cycles(enum bus_type bus, uint32_t cycles) } } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { if (module == MODULE_ADC) { if (enable) diff --git a/chip/stm32/clock-stm32f3.c b/chip/stm32/clock-stm32f3.c index 5b17fe56eb..0a63b27a06 100644 --- a/chip/stm32/clock-stm32f3.c +++ b/chip/stm32/clock-stm32f3.c @@ -398,7 +398,7 @@ void clock_wait_bus_cycles(enum bus_type bus, uint32_t cycles) } } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { if (module == MODULE_ADC) { if (enable) diff --git a/chip/stm32/clock-stm32f4.c b/chip/stm32/clock-stm32f4.c index 15cf8a45e2..c64afdd278 100644 --- a/chip/stm32/clock-stm32f4.c +++ b/chip/stm32/clock-stm32f4.c @@ -295,7 +295,7 @@ void clock_wait_bus_cycles(enum bus_type bus, uint32_t cycles) } } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { if (module == MODULE_USB) { if (enable) { diff --git a/chip/stm32/clock-stm32g4.c b/chip/stm32/clock-stm32g4.c index 962fdc37f2..6b186e9c09 100644 --- a/chip/stm32/clock-stm32g4.c +++ b/chip/stm32/clock-stm32g4.c @@ -239,7 +239,7 @@ void clock_wait_bus_cycles(enum bus_type bus, uint32_t cycles) } } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { if (module == MODULE_USB) { if (enable) { diff --git a/chip/stm32/clock-stm32h7.c b/chip/stm32/clock-stm32h7.c index 3e6ba679cb..1128626e06 100644 --- a/chip/stm32/clock-stm32h7.c +++ b/chip/stm32/clock-stm32h7.c @@ -383,7 +383,7 @@ static void clock_set_osc(enum clock_osc osc) hook_notify(HOOK_FREQ_CHANGE); } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { /* Assume we have a single task using MODULE_FAST_CPU */ if (module == MODULE_FAST_CPU) { diff --git a/chip/stm32/clock-stm32l.c b/chip/stm32/clock-stm32l.c index 1d0252302a..f4e69e4dad 100644 --- a/chip/stm32/clock-stm32l.c +++ b/chip/stm32/clock-stm32l.c @@ -197,7 +197,7 @@ static void clock_set_osc(enum clock_osc osc) static uint64_t clock_mask; -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { uint64_t new_mask; diff --git a/chip/stm32/clock-stm32l4.c b/chip/stm32/clock-stm32l4.c index 9ade941812..fd59d2aa3a 100644 --- a/chip/stm32/clock-stm32l4.c +++ b/chip/stm32/clock-stm32l4.c @@ -453,7 +453,7 @@ static void clock_set_osc(enum clock_osc osc, enum clock_osc pll_osc) static uint64_t clock_mask; -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { uint64_t new_mask; diff --git a/common/mock/build.mk b/common/mock/build.mk index 00c4693d7f..1293f23f4d 100644 --- a/common/mock/build.mk +++ b/common/mock/build.mk @@ -7,6 +7,7 @@ mock-$(HAS_MOCK_ADC) += adc_mock.o mock-$(HAS_MOCK_BATTERY) += battery_mock.o mock-$(HAS_MOCK_CHARGE_MANAGER) += charge_manager_mock.o +mock-$(HAS_MOCK_CLOCK) += clock_mock.o mock-$(HAS_MOCK_FPSENSOR) += fpsensor_mock.o mock-$(HAS_MOCK_FPSENSOR_CRYPTO) += fpsensor_crypto_mock.o mock-$(HAS_MOCK_FPSENSOR_DETECT) += fpsensor_detect_mock.o diff --git a/common/mock/clock_mock.c b/common/mock/clock_mock.c new file mode 100644 index 0000000000..876e691b57 --- /dev/null +++ b/common/mock/clock_mock.c @@ -0,0 +1,24 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "mock/clock_mock.h" + +#ifndef TEST_BUILD +#error "Mocks should only be in the test build." +#endif + +static int fast_cpu_state; + +void clock_enable_module(enum module_id module, int enable) +{ + if (module == MODULE_FAST_CPU) { + fast_cpu_state = enable; + } +} + +int get_mock_fast_cpu_status(void) +{ + return fast_cpu_state; +} diff --git a/include/mock/clock_mock.h b/include/mock/clock_mock.h new file mode 100644 index 0000000000..803be32fc2 --- /dev/null +++ b/include/mock/clock_mock.h @@ -0,0 +1,23 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __MOCK_CLOCK_MOCK_H +#define __MOCK_CLOCK_MOCK_H + +#include "clock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void clock_enable_module(enum module_id module, int enable); + +int get_mock_fast_cpu_status(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __MOCK_CLOCK_MOCK_H */ diff --git a/zephyr/shim/chip/it8xxx2/clock.c b/zephyr/shim/chip/it8xxx2/clock.c index ede854ac14..f76e67b223 100644 --- a/zephyr/shim/chip/it8xxx2/clock.c +++ b/zephyr/shim/chip/it8xxx2/clock.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "common.h" #include "module_id.h" #include <zephyr/device.h> @@ -32,6 +33,6 @@ int clock_get_freq(void) return pll_reg_to_freq[reg_val]; } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/zephyr/shim/chip/mchp/clock.c b/zephyr/shim/chip/mchp/clock.c index 5fb39bfd43..2dff137c33 100644 --- a/zephyr/shim/chip/mchp/clock.c +++ b/zephyr/shim/chip/mchp/clock.c @@ -4,6 +4,7 @@ */ #include "clock_chip.h" +#include "common.h" #include "module_id.h" #include <zephyr/device.h> @@ -65,7 +66,7 @@ void clock_normal(void) __NOP(); } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { /* Assume we have a single task using MODULE_FAST_CPU */ if (module == MODULE_FAST_CPU) { diff --git a/zephyr/shim/chip/npcx/clock.c b/zephyr/shim/chip/npcx/clock.c index 2a6fe27ef4..f6d1a5db98 100644 --- a/zephyr/shim/chip/npcx/clock.c +++ b/zephyr/shim/chip/npcx/clock.c @@ -4,6 +4,7 @@ */ #include "clock_chip.h" +#include "common.h" #include "module_id.h" #include <zephyr/device.h> @@ -66,7 +67,7 @@ void clock_normal(void) cdcg_base->HFCBCD = (FIUDIV_VAL << 4); } -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { /* Assume we have a single task using MODULE_FAST_CPU */ if (module == MODULE_FAST_CPU) { diff --git a/zephyr/shim/chip/stm32/clock.c b/zephyr/shim/chip/stm32/clock.c index 5adf7b2412..0218d656bb 100644 --- a/zephyr/shim/chip/stm32/clock.c +++ b/zephyr/shim/chip/stm32/clock.c @@ -4,7 +4,8 @@ */ #include "clock.h" +#include "common.h" -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } diff --git a/zephyr/shim/chip/stub/clock.c b/zephyr/shim/chip/stub/clock.c index 5adf7b2412..0218d656bb 100644 --- a/zephyr/shim/chip/stub/clock.c +++ b/zephyr/shim/chip/stub/clock.c @@ -4,7 +4,8 @@ */ #include "clock.h" +#include "common.h" -void clock_enable_module(enum module_id module, int enable) +test_mockable void clock_enable_module(enum module_id module, int enable) { } |