UPSTREAM: drivers: npcx: convert NPCX drivers clock client to DEVICE_DT_GET
Convert the various device_get_binding() calls used to get the device
clock node to use DEVICE_DT_GET. The latter is processed at link time,
so it should be a bit more efficient.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
(cherry picked from commit 3af832868c7c7b9a81c66ea62bcaef011e574d61)
BUG=none
TEST=build only
Change-Id: I096d731ab1623147ff7e29990048ef0bedbcd7dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/3070703
Tested-by: Fabio Baltieri <fabiobaltieri@google.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
diff --git a/drivers/adc/adc_npcx.c b/drivers/adc/adc_npcx.c
index 66043a4..5119700 100644
--- a/drivers/adc/adc_npcx.c
+++ b/drivers/adc/adc_npcx.c
@@ -333,8 +333,7 @@
const struct adc_npcx_config *const config = DRV_CONFIG(dev);
struct adc_npcx_data *const data = DRV_DATA(dev);
struct adc_reg *const inst = HAL_INSTANCE(dev);
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int prescaler = 0, ret;
/* Save ADC device in data */
diff --git a/drivers/clock_control/clock_control_npcx.c b/drivers/clock_control/clock_control_npcx.c
index 4f8a9fe..b956c5c 100644
--- a/drivers/clock_control/clock_control_npcx.c
+++ b/drivers/clock_control/clock_control_npcx.c
@@ -109,8 +109,7 @@
#if defined(CONFIG_PM)
void npcx_clock_control_turn_on_system_sleep(bool is_deep, bool is_instant)
{
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
struct pmc_reg *const inst_pmc = HAL_PMC_INST(clk_dev);
/* Configure that ec enters system sleep mode if receiving 'wfi' */
uint8_t pm_flags = BIT(NPCX_PMCSR_IDLE);
@@ -128,8 +127,7 @@
void npcx_clock_control_turn_off_system_sleep(void)
{
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
struct pmc_reg *const inst_pmc = HAL_PMC_INST(clk_dev);
inst_pmc->PMCSR = 0;
diff --git a/drivers/espi/espi_npcx.c b/drivers/espi/espi_npcx.c
index 882512e..c713645 100644
--- a/drivers/espi/espi_npcx.c
+++ b/drivers/espi/espi_npcx.c
@@ -853,7 +853,7 @@
const struct espi_npcx_config *const config = DRV_CONFIG(dev);
struct espi_npcx_data *const data = DRV_DATA(dev);
struct espi_reg *const inst = HAL_INSTANCE(dev);
- const struct device *clk_dev = device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int i, ret;
/* Turn on eSPI device clock first */
diff --git a/drivers/espi/host_subs_npcx.c b/drivers/espi/host_subs_npcx.c
index 2c6cc4a..23d709c 100644
--- a/drivers/espi/host_subs_npcx.c
+++ b/drivers/espi/host_subs_npcx.c
@@ -979,8 +979,7 @@
{
struct mswc_reg *const inst_mswc = host_sub_cfg.inst_mswc;
struct shm_reg *const inst_shm = host_sub_cfg.inst_shm;
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int i;
uint8_t shm_sts;
diff --git a/drivers/i2c/i2c_npcx_controller.c b/drivers/i2c/i2c_npcx_controller.c
index db43311..b38e02a 100644
--- a/drivers/i2c/i2c_npcx_controller.c
+++ b/drivers/i2c/i2c_npcx_controller.c
@@ -859,8 +859,7 @@
{
const struct i2c_ctrl_config *const config = DRV_CONFIG(dev);
struct i2c_ctrl_data *const data = DRV_DATA(dev);
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
uint32_t i2c_rate;
/* Turn on device clock first and get source clock freq. */
diff --git a/drivers/pwm/pwm_npcx.c b/drivers/pwm/pwm_npcx.c
index 5df9fe4..7dd6e33 100644
--- a/drivers/pwm/pwm_npcx.c
+++ b/drivers/pwm/pwm_npcx.c
@@ -168,8 +168,7 @@
const struct pwm_npcx_config *const config = DRV_CONFIG(dev);
struct pwm_npcx_data *const data = DRV_DATA(dev);
struct pwm_reg *const inst = HAL_INSTANCE(dev);
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int ret;
/*
diff --git a/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c b/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c
index d6cac70..14b3332 100644
--- a/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c
+++ b/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c
@@ -316,8 +316,7 @@
{
const struct tach_npcx_config *const config = DRV_CONFIG(dev);
struct tach_npcx_data *const data = DRV_DATA(dev);
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int ret;
/* Turn on device clock first and get source clock freq. */
diff --git a/drivers/serial/uart_npcx.c b/drivers/serial/uart_npcx.c
index 13b6ded..54ad9cd 100644
--- a/drivers/serial/uart_npcx.c
+++ b/drivers/serial/uart_npcx.c
@@ -350,8 +350,7 @@
const struct uart_npcx_config *const config = DRV_CONFIG(dev);
struct uart_npcx_data *const data = DRV_DATA(dev);
struct uart_reg *const inst = HAL_INSTANCE(dev);
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
uint32_t uart_rate;
int ret;
diff --git a/drivers/timer/npcx_itim_timer.c b/drivers/timer/npcx_itim_timer.c
index a082d90..83f2ec5 100644
--- a/drivers/timer/npcx_itim_timer.c
+++ b/drivers/timer/npcx_itim_timer.c
@@ -272,8 +272,7 @@
ARG_UNUSED(device);
int ret;
uint32_t sys_tmr_rate;
- const struct device *const clk_dev =
- device_get_binding(NPCX_CLK_CTRL_NAME);
+ const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
/* Turn on all itim module clocks used for counting */
for (int i = 0; i < ARRAY_SIZE(itim_clk_cfg); i++) {
diff --git a/soc/arm/nuvoton_npcx/common/soc_clock.h b/soc/arm/nuvoton_npcx/common/soc_clock.h
index 3fab949..19892ac 100644
--- a/soc/arm/nuvoton_npcx/common/soc_clock.h
+++ b/soc/arm/nuvoton_npcx/common/soc_clock.h
@@ -11,8 +11,8 @@
extern "C" {
#endif
-/* Common clock control device name for all NPCX series */
-#define NPCX_CLK_CTRL_NAME DT_LABEL(DT_NODELABEL(pcc))
+/* Common clock control device node for all NPCX series */
+#define NPCX_CLK_CTRL_NODE DT_NODELABEL(pcc)
/**
* @brief NPCX clock configuration structure