Commit f966c028 authored by Minda Chen's avatar Minda Chen Committed by Bjorn Helgaas

PCI: microchip: Rename interrupt related functions

Rename mc_* to plda_* for IRQ functions and related IRQ domain ops data
instances.

MSI, INTx interrupt code and IRQ init code can all be re-used.

Link: https://lore.kernel.org/linux-pci/20240328091835.14797-11-minda.chen@starfivetech.comSigned-off-by: default avatarMinda Chen <minda.chen@starfivetech.com>
Signed-off-by: default avatarKrzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarConor Dooley <conor.dooley@microchip.com>
parent 39bd5f82
...@@ -318,7 +318,7 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ...@@ -318,7 +318,7 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam)
ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI);
} }
static void mc_handle_msi(struct irq_desc *desc) static void plda_handle_msi(struct irq_desc *desc)
{ {
struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct plda_pcie_rp *port = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip *chip = irq_desc_get_chip(desc);
...@@ -346,7 +346,7 @@ static void mc_handle_msi(struct irq_desc *desc) ...@@ -346,7 +346,7 @@ static void mc_handle_msi(struct irq_desc *desc)
chained_irq_exit(chip, desc); chained_irq_exit(chip, desc);
} }
static void mc_msi_bottom_irq_ack(struct irq_data *data) static void plda_msi_bottom_irq_ack(struct irq_data *data)
{ {
struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data);
void __iomem *bridge_base_addr = port->bridge_addr; void __iomem *bridge_base_addr = port->bridge_addr;
...@@ -355,7 +355,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) ...@@ -355,7 +355,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data)
writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI);
} }
static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
{ {
struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data);
phys_addr_t addr = port->msi.vector_phy; phys_addr_t addr = port->msi.vector_phy;
...@@ -368,21 +368,23 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) ...@@ -368,21 +368,23 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
(int)data->hwirq, msg->address_hi, msg->address_lo); (int)data->hwirq, msg->address_hi, msg->address_lo);
} }
static int mc_msi_set_affinity(struct irq_data *irq_data, static int plda_msi_set_affinity(struct irq_data *irq_data,
const struct cpumask *mask, bool force) const struct cpumask *mask, bool force)
{ {
return -EINVAL; return -EINVAL;
} }
static struct irq_chip mc_msi_bottom_irq_chip = { static struct irq_chip plda_msi_bottom_irq_chip = {
.name = "Microchip MSI", .name = "PLDA MSI",
.irq_ack = mc_msi_bottom_irq_ack, .irq_ack = plda_msi_bottom_irq_ack,
.irq_compose_msi_msg = mc_compose_msi_msg, .irq_compose_msi_msg = plda_compose_msi_msg,
.irq_set_affinity = mc_msi_set_affinity, .irq_set_affinity = plda_msi_set_affinity,
}; };
static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, static int plda_irq_msi_domain_alloc(struct irq_domain *domain,
unsigned int nr_irqs, void *args) unsigned int virq,
unsigned int nr_irqs,
void *args)
{ {
struct plda_pcie_rp *port = domain->host_data; struct plda_pcie_rp *port = domain->host_data;
struct plda_msi *msi = &port->msi; struct plda_msi *msi = &port->msi;
...@@ -397,7 +399,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -397,7 +399,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
set_bit(bit, msi->used); set_bit(bit, msi->used);
irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip, irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip,
domain->host_data, handle_edge_irq, NULL, NULL); domain->host_data, handle_edge_irq, NULL, NULL);
mutex_unlock(&msi->lock); mutex_unlock(&msi->lock);
...@@ -405,7 +407,8 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -405,7 +407,8 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
return 0; return 0;
} }
static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, static void plda_irq_msi_domain_free(struct irq_domain *domain,
unsigned int virq,
unsigned int nr_irqs) 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);
...@@ -423,24 +426,24 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, ...@@ -423,24 +426,24 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq,
} }
static const struct irq_domain_ops msi_domain_ops = { static const struct irq_domain_ops msi_domain_ops = {
.alloc = mc_irq_msi_domain_alloc, .alloc = plda_irq_msi_domain_alloc,
.free = mc_irq_msi_domain_free, .free = plda_irq_msi_domain_free,
}; };
static struct irq_chip mc_msi_irq_chip = { static struct irq_chip plda_msi_irq_chip = {
.name = "Microchip PCIe MSI", .name = "PLDA PCIe MSI",
.irq_ack = irq_chip_ack_parent, .irq_ack = irq_chip_ack_parent,
.irq_mask = pci_msi_mask_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = pci_msi_unmask_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
static struct msi_domain_info mc_msi_domain_info = { static struct msi_domain_info plda_msi_domain_info = {
.flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
MSI_FLAG_PCI_MSIX), MSI_FLAG_PCI_MSIX),
.chip = &mc_msi_irq_chip, .chip = &plda_msi_irq_chip,
}; };
static int mc_allocate_msi_domains(struct plda_pcie_rp *port) static int plda_allocate_msi_domains(struct plda_pcie_rp *port)
{ {
struct device *dev = port->dev; struct device *dev = port->dev;
struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node);
...@@ -455,7 +458,8 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) ...@@ -455,7 +458,8 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port)
return -ENOMEM; return -ENOMEM;
} }
msi->msi_domain = pci_msi_create_irq_domain(fwnode, &mc_msi_domain_info, msi->msi_domain = pci_msi_create_irq_domain(fwnode,
&plda_msi_domain_info,
msi->dev_domain); 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");
...@@ -466,7 +470,7 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) ...@@ -466,7 +470,7 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port)
return 0; return 0;
} }
static void mc_handle_intx(struct irq_desc *desc) static void plda_handle_intx(struct irq_desc *desc)
{ {
struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct plda_pcie_rp *port = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip *chip = irq_desc_get_chip(desc);
...@@ -493,7 +497,7 @@ static void mc_handle_intx(struct irq_desc *desc) ...@@ -493,7 +497,7 @@ static void mc_handle_intx(struct irq_desc *desc)
chained_irq_exit(chip, desc); chained_irq_exit(chip, desc);
} }
static void mc_ack_intx_irq(struct irq_data *data) static void plda_ack_intx_irq(struct irq_data *data)
{ {
struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data);
void __iomem *bridge_base_addr = port->bridge_addr; void __iomem *bridge_base_addr = port->bridge_addr;
...@@ -502,7 +506,7 @@ static void mc_ack_intx_irq(struct irq_data *data) ...@@ -502,7 +506,7 @@ static void mc_ack_intx_irq(struct irq_data *data)
writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL);
} }
static void mc_mask_intx_irq(struct irq_data *data) static void plda_mask_intx_irq(struct irq_data *data)
{ {
struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data);
void __iomem *bridge_base_addr = port->bridge_addr; void __iomem *bridge_base_addr = port->bridge_addr;
...@@ -517,7 +521,7 @@ static void mc_mask_intx_irq(struct irq_data *data) ...@@ -517,7 +521,7 @@ static void mc_mask_intx_irq(struct irq_data *data)
raw_spin_unlock_irqrestore(&port->lock, flags); raw_spin_unlock_irqrestore(&port->lock, flags);
} }
static void mc_unmask_intx_irq(struct irq_data *data) static void plda_unmask_intx_irq(struct irq_data *data)
{ {
struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data);
void __iomem *bridge_base_addr = port->bridge_addr; void __iomem *bridge_base_addr = port->bridge_addr;
...@@ -532,24 +536,24 @@ static void mc_unmask_intx_irq(struct irq_data *data) ...@@ -532,24 +536,24 @@ static void mc_unmask_intx_irq(struct irq_data *data)
raw_spin_unlock_irqrestore(&port->lock, flags); raw_spin_unlock_irqrestore(&port->lock, flags);
} }
static struct irq_chip mc_intx_irq_chip = { static struct irq_chip plda_intx_irq_chip = {
.name = "Microchip PCIe INTx", .name = "PLDA PCIe INTx",
.irq_ack = mc_ack_intx_irq, .irq_ack = plda_ack_intx_irq,
.irq_mask = mc_mask_intx_irq, .irq_mask = plda_mask_intx_irq,
.irq_unmask = mc_unmask_intx_irq, .irq_unmask = plda_unmask_intx_irq,
}; };
static int mc_pcie_intx_map(struct irq_domain *domain, unsigned int irq, static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq) irq_hw_number_t hwirq)
{ {
irq_set_chip_and_handler(irq, &mc_intx_irq_chip, handle_level_irq); irq_set_chip_and_handler(irq, &plda_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;
} }
static const struct irq_domain_ops intx_domain_ops = { static const struct irq_domain_ops intx_domain_ops = {
.map = mc_pcie_intx_map, .map = plda_pcie_intx_map,
}; };
static inline u32 reg_to_event(u32 reg, struct event_map field) static inline u32 reg_to_event(u32 reg, struct event_map field)
...@@ -609,7 +613,7 @@ static u32 local_events(struct mc_pcie *port) ...@@ -609,7 +613,7 @@ static u32 local_events(struct mc_pcie *port)
return val; return val;
} }
static u32 get_events(struct plda_pcie_rp *port) static u32 mc_get_events(struct plda_pcie_rp *port)
{ {
struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda);
u32 events = 0; u32 events = 0;
...@@ -638,7 +642,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) ...@@ -638,7 +642,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void mc_handle_event(struct irq_desc *desc) static void plda_handle_event(struct irq_desc *desc)
{ {
struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct plda_pcie_rp *port = irq_desc_get_handler_data(desc);
unsigned long events; unsigned long events;
...@@ -647,7 +651,7 @@ static void mc_handle_event(struct irq_desc *desc) ...@@ -647,7 +651,7 @@ static void mc_handle_event(struct irq_desc *desc)
chained_irq_enter(chip, desc); chained_irq_enter(chip, desc);
events = get_events(port); events = mc_get_events(port);
for_each_set_bit(bit, &events, NUM_EVENTS) for_each_set_bit(bit, &events, NUM_EVENTS)
generic_handle_domain_irq(port->event_domain, bit); generic_handle_domain_irq(port->event_domain, bit);
...@@ -741,7 +745,7 @@ static struct irq_chip mc_event_irq_chip = { ...@@ -741,7 +745,7 @@ static struct irq_chip mc_event_irq_chip = {
.irq_unmask = mc_unmask_event_irq, .irq_unmask = mc_unmask_event_irq,
}; };
static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq) irq_hw_number_t hwirq)
{ {
irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq);
...@@ -750,8 +754,8 @@ static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, ...@@ -750,8 +754,8 @@ static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq,
return 0; return 0;
} }
static const struct irq_domain_ops event_domain_ops = { static const struct irq_domain_ops plda_event_domain_ops = {
.map = mc_pcie_event_map, .map = plda_pcie_event_map,
}; };
static inline void mc_pcie_deinit_clk(void *data) static inline void mc_pcie_deinit_clk(void *data)
...@@ -799,7 +803,7 @@ static int mc_pcie_init_clks(struct device *dev) ...@@ -799,7 +803,7 @@ static int mc_pcie_init_clks(struct device *dev)
return 0; return 0;
} }
static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port)
{ {
struct device *dev = port->dev; struct device *dev = port->dev;
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
...@@ -813,7 +817,8 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) ...@@ -813,7 +817,8 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port)
} }
port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS, port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS,
&event_domain_ops, port); &plda_event_domain_ops,
port);
if (!port->event_domain) { if (!port->event_domain) {
dev_err(dev, "failed to get event domain\n"); dev_err(dev, "failed to get event domain\n");
of_node_put(pcie_intc_node); of_node_put(pcie_intc_node);
...@@ -835,7 +840,7 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) ...@@ -835,7 +840,7 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port)
of_node_put(pcie_intc_node); of_node_put(pcie_intc_node);
raw_spin_lock_init(&port->lock); raw_spin_lock_init(&port->lock);
return mc_allocate_msi_domains(port); return plda_allocate_msi_domains(port);
} }
static inline void mc_clear_secs(struct mc_pcie *port) static inline void mc_clear_secs(struct mc_pcie *port)
...@@ -898,14 +903,14 @@ static void mc_disable_interrupts(struct mc_pcie *port) ...@@ -898,14 +903,14 @@ static void mc_disable_interrupts(struct mc_pcie *port)
writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST);
} }
static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int irq; int irq;
int i, intx_irq, msi_irq, event_irq; int i, intx_irq, msi_irq, event_irq;
int ret; int ret;
ret = mc_pcie_init_irq_domains(port); ret = plda_pcie_init_irq_domains(port);
if (ret) { if (ret) {
dev_err(dev, "failed creating IRQ domains\n"); dev_err(dev, "failed creating IRQ domains\n");
return ret; return ret;
...@@ -938,7 +943,7 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp ...@@ -938,7 +943,7 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp
} }
/* Plug the INTx chained handler */ /* Plug the INTx chained handler */
irq_set_chained_handler_and_data(intx_irq, mc_handle_intx, port); irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port);
msi_irq = irq_create_mapping(port->event_domain, msi_irq = irq_create_mapping(port->event_domain,
EVENT_LOCAL_PM_MSI_INT_MSI); EVENT_LOCAL_PM_MSI_INT_MSI);
...@@ -946,10 +951,10 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp ...@@ -946,10 +951,10 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp
return -ENXIO; return -ENXIO;
/* Plug the MSI chained handler */ /* Plug the MSI chained handler */
irq_set_chained_handler_and_data(msi_irq, mc_handle_msi, port); irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port);
/* Plug the main event chained handler */ /* Plug the main event chained handler */
irq_set_chained_handler_and_data(irq, mc_handle_event, port); irq_set_chained_handler_and_data(irq, plda_handle_event, port);
return 0; return 0;
} }
...@@ -976,7 +981,7 @@ static int mc_platform_init(struct pci_config_window *cfg) ...@@ -976,7 +981,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
return ret; return ret;
/* Address translation is up; safe to enable interrupts */ /* Address translation is up; safe to enable interrupts */
ret = mc_init_interrupts(pdev, &port->plda); ret = plda_init_interrupts(pdev, &port->plda);
if (ret) if (ret)
return ret; return ret;
......
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