Commit e369faf6 authored by Hou Zhiqiang's avatar Hou Zhiqiang Committed by Lorenzo Pieralisi

PCI: mobiveil: Reformat the code for readability

Reformat the code to make it more readable. No functional
change intended.
Signed-off-by: default avatarHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarMinghuan Lian <Minghuan.Lian@nxp.com>
parent 93bad0f5
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
#define PAB_REG_BLOCK_SIZE 16 #define PAB_REG_BLOCK_SIZE 16
#define PAB_EXT_REG_BLOCK_SIZE 4 #define PAB_EXT_REG_BLOCK_SIZE 4
#define PAB_REG_ADDR(offset, win) (offset + (win * PAB_REG_BLOCK_SIZE)) #define PAB_REG_ADDR(offset, win) \
#define PAB_EXT_REG_ADDR(offset, win) (offset + (win * PAB_EXT_REG_BLOCK_SIZE)) (offset + (win * PAB_REG_BLOCK_SIZE))
#define PAB_EXT_REG_ADDR(offset, win) \
(offset + (win * PAB_EXT_REG_BLOCK_SIZE))
#define LTSSM_STATUS 0x0404 #define LTSSM_STATUS 0x0404
#define LTSSM_STATUS_L0_MASK 0x3f #define LTSSM_STATUS_L0_MASK 0x3f
...@@ -301,10 +303,9 @@ static void __iomem *mobiveil_pcie_map_bus(struct pci_bus *bus, ...@@ -301,10 +303,9 @@ static void __iomem *mobiveil_pcie_map_bus(struct pci_bus *bus,
if (!mobiveil_pcie_valid_device(bus, devfn)) if (!mobiveil_pcie_valid_device(bus, devfn))
return NULL; return NULL;
if (bus->number == pcie->root_bus_nr) {
/* RC config access */ /* RC config access */
if (bus->number == pcie->root_bus_nr)
return pcie->csr_axi_slave_base + where; return pcie->csr_axi_slave_base + where;
}
/* /*
* EP config access (in Config/APIO space) * EP config access (in Config/APIO space)
...@@ -359,8 +360,8 @@ static void mobiveil_pcie_isr(struct irq_desc *desc) ...@@ -359,8 +360,8 @@ static void mobiveil_pcie_isr(struct irq_desc *desc)
if (virq) if (virq)
generic_handle_irq(virq); generic_handle_irq(virq);
else else
dev_err_ratelimited(dev, dev_err_ratelimited(dev, "unexpected IRQ, INT%d\n",
"unexpected IRQ, INT%d\n", bit); bit);
/* clear interrupt */ /* clear interrupt */
csr_writel(pcie, csr_writel(pcie,
...@@ -375,8 +376,7 @@ static void mobiveil_pcie_isr(struct irq_desc *desc) ...@@ -375,8 +376,7 @@ static void mobiveil_pcie_isr(struct irq_desc *desc)
/* handle MSI interrupts */ /* handle MSI interrupts */
while (msi_status & 1) { while (msi_status & 1) {
msi_data = readl_relaxed(pcie->apb_csr_base msi_data = readl_relaxed(pcie->apb_csr_base + MSI_DATA_OFFSET);
+ MSI_DATA_OFFSET);
/* /*
* MSI_STATUS_OFFSET register gets updated to zero * MSI_STATUS_OFFSET register gets updated to zero
...@@ -463,8 +463,8 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, ...@@ -463,8 +463,8 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num,
} }
pio_ctrl_val = csr_readl(pcie, PAB_PEX_PIO_CTRL); pio_ctrl_val = csr_readl(pcie, PAB_PEX_PIO_CTRL);
csr_writel(pcie, csr_writel(pcie, pio_ctrl_val | (1 << PIO_ENABLE_SHIFT),
pio_ctrl_val | (1 << PIO_ENABLE_SHIFT), PAB_PEX_PIO_CTRL); PAB_PEX_PIO_CTRL);
amap_ctrl_dw = csr_readl(pcie, PAB_PEX_AMAP_CTRL(win_num)); amap_ctrl_dw = csr_readl(pcie, PAB_PEX_AMAP_CTRL(win_num));
amap_ctrl_dw = (amap_ctrl_dw | (type << AMAP_CTRL_TYPE_SHIFT)); amap_ctrl_dw = (amap_ctrl_dw | (type << AMAP_CTRL_TYPE_SHIFT));
amap_ctrl_dw = (amap_ctrl_dw | (1 << AMAP_CTRL_EN_SHIFT)); amap_ctrl_dw = (amap_ctrl_dw | (1 << AMAP_CTRL_EN_SHIFT));
...@@ -484,7 +484,8 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, ...@@ -484,7 +484,8 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num,
* routine to program the outbound windows * routine to program the outbound windows
*/ */
static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num,
u64 cpu_addr, u64 pci_addr, u32 config_io_bit, u64 size) u64 cpu_addr, u64 pci_addr,
u32 config_io_bit, u64 size)
{ {
u32 value, type; u32 value, type;
...@@ -536,7 +537,9 @@ static int mobiveil_bringup_link(struct mobiveil_pcie *pcie) ...@@ -536,7 +537,9 @@ static int mobiveil_bringup_link(struct mobiveil_pcie *pcie)
usleep_range(LINK_WAIT_MIN, LINK_WAIT_MAX); usleep_range(LINK_WAIT_MIN, LINK_WAIT_MAX);
} }
dev_err(&pcie->pdev->dev, "link never came up\n"); dev_err(&pcie->pdev->dev, "link never came up\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -679,6 +682,7 @@ static int mobiveil_pcie_intx_map(struct irq_domain *domain, unsigned int irq, ...@@ -679,6 +682,7 @@ static int mobiveil_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
{ {
irq_set_chip_and_handler(irq, &intx_irq_chip, handle_level_irq); irq_set_chip_and_handler(irq, &intx_irq_chip, handle_level_irq);
irq_set_chip_data(irq, domain->host_data); irq_set_chip_data(irq, domain->host_data);
return 0; return 0;
} }
...@@ -725,7 +729,8 @@ static struct irq_chip mobiveil_msi_bottom_irq_chip = { ...@@ -725,7 +729,8 @@ static struct irq_chip mobiveil_msi_bottom_irq_chip = {
}; };
static int mobiveil_irq_msi_domain_alloc(struct irq_domain *domain, static int mobiveil_irq_msi_domain_alloc(struct irq_domain *domain,
unsigned int virq, unsigned int nr_irqs, void *args) unsigned int virq,
unsigned int nr_irqs, void *args)
{ {
struct mobiveil_pcie *pcie = domain->host_data; struct mobiveil_pcie *pcie = domain->host_data;
struct mobiveil_msi *msi = &pcie->msi; struct mobiveil_msi *msi = &pcie->msi;
...@@ -745,13 +750,13 @@ static int mobiveil_irq_msi_domain_alloc(struct irq_domain *domain, ...@@ -745,13 +750,13 @@ static int mobiveil_irq_msi_domain_alloc(struct irq_domain *domain,
mutex_unlock(&msi->lock); mutex_unlock(&msi->lock);
irq_domain_set_info(domain, virq, bit, &mobiveil_msi_bottom_irq_chip, irq_domain_set_info(domain, virq, bit, &mobiveil_msi_bottom_irq_chip,
domain->host_data, handle_level_irq, domain->host_data, handle_level_irq, NULL, NULL);
NULL, NULL);
return 0; return 0;
} }
static void mobiveil_irq_msi_domain_free(struct irq_domain *domain, static void mobiveil_irq_msi_domain_free(struct irq_domain *domain,
unsigned int virq, unsigned int nr_irqs) unsigned int virq,
unsigned int nr_irqs)
{ {
struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct irq_data *d = irq_domain_get_irq_data(domain, virq);
struct mobiveil_pcie *pcie = irq_data_get_irq_chip_data(d); struct mobiveil_pcie *pcie = irq_data_get_irq_chip_data(d);
...@@ -759,12 +764,11 @@ static void mobiveil_irq_msi_domain_free(struct irq_domain *domain, ...@@ -759,12 +764,11 @@ static void mobiveil_irq_msi_domain_free(struct irq_domain *domain,
mutex_lock(&msi->lock); mutex_lock(&msi->lock);
if (!test_bit(d->hwirq, msi->msi_irq_in_use)) { if (!test_bit(d->hwirq, msi->msi_irq_in_use))
dev_err(&pcie->pdev->dev, "trying to free unused MSI#%lu\n", dev_err(&pcie->pdev->dev, "trying to free unused MSI#%lu\n",
d->hwirq); d->hwirq);
} else { else
__clear_bit(d->hwirq, msi->msi_irq_in_use); __clear_bit(d->hwirq, msi->msi_irq_in_use);
}
mutex_unlock(&msi->lock); mutex_unlock(&msi->lock);
} }
...@@ -788,12 +792,14 @@ static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie) ...@@ -788,12 +792,14 @@ static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie)
} }
msi->msi_domain = pci_msi_create_irq_domain(fwnode, msi->msi_domain = pci_msi_create_irq_domain(fwnode,
&mobiveil_msi_domain_info, msi->dev_domain); &mobiveil_msi_domain_info,
msi->dev_domain);
if (!msi->msi_domain) { if (!msi->msi_domain) {
dev_err(dev, "failed to create MSI domain\n"); dev_err(dev, "failed to create MSI domain\n");
irq_domain_remove(msi->dev_domain); irq_domain_remove(msi->dev_domain);
return -ENOMEM; return -ENOMEM;
} }
return 0; return 0;
} }
...@@ -804,8 +810,8 @@ static int mobiveil_pcie_init_irq_domain(struct mobiveil_pcie *pcie) ...@@ -804,8 +810,8 @@ static int mobiveil_pcie_init_irq_domain(struct mobiveil_pcie *pcie)
int ret; int ret;
/* setup INTx */ /* setup INTx */
pcie->intx_domain = irq_domain_add_linear(node, pcie->intx_domain = irq_domain_add_linear(node, PCI_NUM_INTX,
PCI_NUM_INTX, &intx_domain_ops, pcie); &intx_domain_ops, pcie);
if (!pcie->intx_domain) { if (!pcie->intx_domain) {
dev_err(dev, "Failed to get a INTx IRQ domain\n"); dev_err(dev, "Failed to get a INTx IRQ domain\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment