device: rv32m1: Convert clock control to use DEVICE_DT_GET

Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2021-02-11 18:05:31 -06:00 committed by Kumar Gala
commit 3a8fffb9c3
6 changed files with 24 additions and 71 deletions

View file

@ -16,7 +16,7 @@
struct rv32m1_lpuart_config {
LPUART_Type *base;
char *clock_name;
const struct device *clock_dev;
clock_control_subsys_t clock_subsys;
clock_ip_name_t clock_ip_name;
uint32_t clock_ip_src;
@ -239,19 +239,13 @@ static int rv32m1_lpuart_init(const struct device *dev)
{
const struct rv32m1_lpuart_config *config = dev->config;
lpuart_config_t uart_config;
const struct device *clock_dev;
uint32_t clock_freq;
/* set clock source */
/* TODO: Don't change if another core has configured */
CLOCK_SetIpSrc(config->clock_ip_name, config->clock_ip_src);
clock_dev = device_get_binding(config->clock_name);
if (clock_dev == NULL) {
return -EINVAL;
}
if (clock_control_get_rate(clock_dev, config->clock_subsys,
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
&clock_freq)) {
return -EINVAL;
}
@ -299,7 +293,7 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = {
#define RV32M1_LPUART_DECLARE_CFG(n, IRQ_FUNC_INIT) \
static const struct rv32m1_lpuart_config rv32m1_lpuart_##n##_cfg = {\
.base = (LPUART_Type *)DT_INST_REG_ADDR(n), \
.clock_name = DT_INST_CLOCKS_LABEL(n), \
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
.clock_subsys = \
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
.clock_ip_name = INST_DT_CLOCK_IP_NAME(n), \