uart: ns16550: Enable clock if defined

Currently, ns16550 allows the user to specify a clock attribute in the
Device Tree. This node is use to retrieve the internal frequency of the
hardware block.

However, ns16550 expects the clock is already initialised and it doesn't
try to enable it. Let's fix that issue.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
This commit is contained in:
Jérôme Pouiller 2025-01-29 22:01:18 +01:00 committed by Benjamin Cabé
parent 52b2a8019d
commit 88830a3b25

View File

@ -573,9 +573,7 @@ static int uart_ns16550_configure(const struct device *dev,
const struct uart_ns16550_dev_config * const dev_cfg = dev->config;
uint8_t mdc = 0U, c;
uint32_t pclk = 0U;
/* temp for return value if error occurs in this locked region */
int ret = 0;
int ret;
k_spinlock_key_t key = k_spin_lock(&dev_data->lock);
@ -622,6 +620,11 @@ static int uart_ns16550_configure(const struct device *dev,
goto out;
}
ret = clock_control_on(dev_cfg->clock_dev, dev_cfg->clock_subsys);
if (ret != 0 && ret != -EALREADY) {
goto out;
}
if (clock_control_get_rate(dev_cfg->clock_dev,
dev_cfg->clock_subsys,
&pclk) != 0) {
@ -722,6 +725,7 @@ static int uart_ns16550_configure(const struct device *dev,
/* disable interrupts */
ns16550_outbyte(dev_cfg, IER(dev), 0x00);
ret = 0;
out:
k_spin_unlock(&dev_data->lock, key);