device: esp32: 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 19:21:32 -06:00 committed by Kumar Gala
commit 9dfd87b931
2 changed files with 9 additions and 21 deletions

View file

@ -64,7 +64,7 @@ struct uart_esp32_regs_t {
struct uart_esp32_config {
struct uart_device_config dev_conf;
const char *clock_name;
const struct device *clock_dev;
const struct {
int tx_out;
@ -91,7 +91,6 @@ struct uart_esp32_config {
/* driver data */
struct uart_esp32_data {
struct uart_config uart_config;
const struct device *clock_dev;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
uart_irq_callback_user_data_t irq_cb;
void *irq_cb_data;
@ -192,7 +191,7 @@ static int uart_esp32_set_baudrate(const struct device *dev, int baudrate)
{
uint32_t sys_clk_freq = 0;
if (clock_control_get_rate(DEV_DATA(dev)->clock_dev,
if (clock_control_get_rate(DEV_CFG(dev)->clock_dev,
DEV_CFG(dev)->peripheral_id,
&sys_clk_freq)) {
return -EINVAL;
@ -249,7 +248,7 @@ static int uart_esp32_configure(const struct device *dev,
| (UART_TX_FIFO_THRESH << UART_TXFIFO_EMPTY_THRHD_S);
uart_esp32_configure_pins(dev);
clock_control_on(DEV_DATA(dev)->clock_dev, DEV_CFG(dev)->peripheral_id);
clock_control_on(DEV_CFG(dev)->clock_dev, DEV_CFG(dev)->peripheral_id);
/*
* Reset RX Buffer by reading all received bytes
@ -317,12 +316,6 @@ static int uart_esp32_configure(const struct device *dev,
static int uart_esp32_init(const struct device *dev)
{
struct uart_esp32_data *data = DEV_DATA(dev);
data->clock_dev = device_get_binding(DEV_CFG(dev)->clock_name);
__ASSERT_NO_MSG(data->clock_dev);
uart_esp32_configure(dev, &DEV_DATA(dev)->uart_config);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@ -503,7 +496,7 @@ static const DRAM_ATTR struct uart_esp32_config uart_esp32_cfg_port_##idx = {
ESP32_UART_IRQ_HANDLER_FUNC(idx) \
}, \
\
.clock_name = DT_INST_CLOCKS_LABEL(idx), \
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(idx)), \
\
.signals = { \
.tx_out = U##idx##TXD_OUT_IDX, \