drivers: serial: ns16550: Moved PCIe probe to init function
Moved PCIe probe from configure function to init function because whenever uart_configure api is called MMIO address is getting updated. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
This commit is contained in:
parent
712dab4f04
commit
00991e4720
1 changed files with 25 additions and 29 deletions
|
@ -332,38 +332,12 @@ static int uart_ns16550_configure(const struct device *dev,
|
||||||
|
|
||||||
k_spinlock_key_t key = k_spin_lock(&dev_data->lock);
|
k_spinlock_key_t key = k_spin_lock(&dev_data->lock);
|
||||||
|
|
||||||
ARG_UNUSED(dev_data);
|
|
||||||
ARG_UNUSED(dev_cfg);
|
|
||||||
|
|
||||||
#if defined(CONFIG_PINCTRL)
|
#if defined(CONFIG_PINCTRL)
|
||||||
if (dev_cfg->pincfg != NULL) {
|
if (dev_cfg->pincfg != NULL) {
|
||||||
pinctrl_apply_state(dev_cfg->pincfg, PINCTRL_STATE_DEFAULT);
|
pinctrl_apply_state(dev_cfg->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_UART_NS16550_ACCESS_IOPORT
|
|
||||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(pcie)
|
|
||||||
if (dev_cfg->pcie) {
|
|
||||||
struct pcie_bar mbar;
|
|
||||||
|
|
||||||
if (dev_cfg->pcie->bdf == PCIE_BDF_NONE) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcie_probe_mbar(dev_cfg->pcie->bdf, 0, &mbar);
|
|
||||||
pcie_set_cmd(dev_cfg->pcie->bdf, PCIE_CONF_CMDSTAT_MEM, true);
|
|
||||||
|
|
||||||
device_map(DEVICE_MMIO_RAM_PTR(dev), mbar.phys_addr, mbar.size,
|
|
||||||
K_MEM_CACHE_NONE);
|
|
||||||
} else
|
|
||||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(pcie) */
|
|
||||||
{
|
|
||||||
/* Map directly from DTS */
|
|
||||||
DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
|
|
||||||
}
|
|
||||||
#endif /* UART_NS15660_ACCESS_IOPORT */
|
|
||||||
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
dev_data->iir_cache = 0U;
|
dev_data->iir_cache = 0U;
|
||||||
#endif
|
#endif
|
||||||
|
@ -524,17 +498,39 @@ static int uart_ns16550_config_get(const struct device *dev,
|
||||||
static int uart_ns16550_init(const struct device *dev)
|
static int uart_ns16550_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct uart_ns16550_dev_data *data = dev->data;
|
struct uart_ns16550_dev_data *data = dev->data;
|
||||||
|
const struct uart_ns16550_device_config *dev_cfg = dev->config;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev_cfg);
|
||||||
|
|
||||||
|
#ifndef CONFIG_UART_NS16550_ACCESS_IOPORT
|
||||||
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(pcie)
|
||||||
|
if (dev_cfg->pcie) {
|
||||||
|
struct pcie_bar mbar;
|
||||||
|
|
||||||
|
if (dev_cfg->pcie->bdf == PCIE_BDF_NONE) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcie_probe_mbar(dev_cfg->pcie->bdf, 0, &mbar);
|
||||||
|
pcie_set_cmd(dev_cfg->pcie->bdf, PCIE_CONF_CMDSTAT_MEM, true);
|
||||||
|
|
||||||
|
device_map(DEVICE_MMIO_RAM_PTR(dev), mbar.phys_addr, mbar.size,
|
||||||
|
K_MEM_CACHE_NONE);
|
||||||
|
} else
|
||||||
|
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(pcie) */
|
||||||
|
{
|
||||||
|
/* Map directly from DTS */
|
||||||
|
DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
|
||||||
|
}
|
||||||
|
#endif /* !UART_NS15660_ACCESS_IOPORT */
|
||||||
ret = uart_ns16550_configure(dev, &data->uart_config);
|
ret = uart_ns16550_configure(dev, &data->uart_config);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
const struct uart_ns16550_device_config *config = dev->config;
|
dev_cfg->irq_config_func(dev);
|
||||||
|
|
||||||
config->irq_config_func(dev);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue