linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] pci: designware: add separate driver for the MSI part of the RC
Date: Thu, 24 Aug 2017 17:48:34 +0100	[thread overview]
Message-ID: <e1f5e20d-929f-db8d-1c60-181698e678f0@arm.com> (raw)
In-Reply-To: <20170821192907.8695-3-ard.biesheuvel@linaro.org>

Hi Ard,

On 21/08/17 20:29, Ard Biesheuvel wrote:
[...]
> +static int dw_pcie_msi_probe(struct platform_device *pdev)
> +{
> +	struct fwnode_handle *fwnode = of_node_to_fwnode(pdev->dev.of_node);

Mini-nit: since fairly recently (f94277af03ea) dev->fwnode should
already be set appropriately by of_platform_device_create(), so you
should be able to make this entirely firmware-agnostic if you like.

Robin.

> +	struct device *dev = &pdev->dev;
> +	struct dw_pcie_msi *dw_msi;
> +	struct resource *res;
> +
> +	dw_msi = devm_kzalloc(dev, sizeof(*dw_msi), GFP_KERNEL);
> +	if (!dw_msi)
> +		return -ENOMEM;
> +
> +	/* get the control register and map it */
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	dw_msi->regbase = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(dw_msi->regbase))
> +		return PTR_ERR(dw_msi->regbase);
> +
> +	/* get the wired interrupt that gets raised when we receive an MSI */
> +	dw_msi->irq = platform_get_irq(pdev, 0);
> +	if (dw_msi->irq <= 0) {
> +		pr_err("Failed to map IRQ\n");
> +		return -ENXIO;
> +	}
> +
> +	dw_msi->irqd = irq_domain_create_linear(fwnode, MAX_MSI_IRQS,
> +						&irq_dom_ops, dw_msi);
> +	if (!dw_msi->irqd) {
> +		dev_err(dev, "Failed to create IRQ domain\n");
> +		return -ENOMEM;
> +	}
> +
> +	dw_msi->msid = pci_msi_create_irq_domain(fwnode, &dw_pcie_msi_dom_info,
> +						 dw_msi->irqd);
> +	if (!dw_msi->msid) {
> +		dev_err(dev, "Failed to create MSI domain\n");
> +		irq_domain_remove(dw_msi->irqd);
> +		return -ENOMEM;
> +	}
> +
> +	irq_set_chained_handler_and_data(dw_msi->irq, dw_pcie_msi_isr, dw_msi);
> +	platform_set_drvdata(pdev, dw_msi);
> +
> +	/* program the msi_data */
> +	writel_relaxed(lower_32_bits(virt_to_phys(&dw_msi->doorbell)),
> +		       dw_msi->regbase + PCIE_MSI_ADDR_LO);
> +	writel_relaxed(upper_32_bits(virt_to_phys(&dw_msi->doorbell)),
> +		       dw_msi->regbase + PCIE_MSI_ADDR_HI);
> +
> +	return 0;
> +}
> +
> +static int dw_pcie_msi_remove(struct platform_device *pdev)
> +{
> +	struct dw_pcie_msi *dw_msi = platform_get_drvdata(pdev);
> +
> +	irq_set_chained_handler_and_data(dw_msi->irq, NULL, NULL);
> +	irq_domain_remove(dw_msi->msid);
> +	irq_domain_remove(dw_msi->irqd);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id dw_pcie_dw_msi_of_match[] = {
> +	{ .compatible = "snps,dw-pcie-msi" },
> +	{ },
> +};
> +
> +static struct platform_driver pci_dw_msi_driver = {
> +	.driver.name			= "pcie-designware-msi",
> +	.driver.of_match_table		= dw_pcie_dw_msi_of_match,
> +	.probe				= dw_pcie_msi_probe,
> +	.remove				= dw_pcie_msi_remove,
> +};
> +builtin_platform_driver(pci_dw_msi_driver);
> 

  parent reply	other threads:[~2017-08-24 16:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 19:29 [PATCH 0/3] pci: add support for firmware initialized designware RCs Ard Biesheuvel
2017-08-21 19:29 ` [PATCH 1/3] pci: designware: add driver for DWC controller in ECAM shift mode Ard Biesheuvel
2017-08-24 16:24   ` kbuild test robot
2017-08-24 16:25   ` kbuild test robot
2017-08-21 19:29 ` [PATCH 2/3] pci: designware: add separate driver for the MSI part of the RC Ard Biesheuvel
2017-08-24 16:42   ` Bjorn Helgaas
2017-08-24 16:43     ` Ard Biesheuvel
2017-08-24 16:48   ` Robin Murphy [this message]
2017-08-24 16:50     ` Ard Biesheuvel
2020-02-15  0:54   ` Alan Mikhak
2020-02-15  9:35     ` Ard Biesheuvel
2020-02-15 10:36       ` Marc Zyngier
2020-02-18 19:09         ` Alan Mikhak
2020-02-19  8:11           ` Marc Zyngier
2020-02-19  8:17             ` Ard Biesheuvel
2020-02-19 20:24               ` Alan Mikhak
2020-02-19 21:06                 ` Ard Biesheuvel
2020-02-19 21:35                   ` Alan Mikhak
2017-08-21 19:29 ` [PATCH 3/3] dt-bindings: designware: add binding for Designware PCIe in ECAM mode Ard Biesheuvel
2017-08-24 16:46 ` [PATCH 0/3] pci: add support for firmware initialized designware RCs Bjorn Helgaas
2017-08-31 19:21   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1f5e20d-929f-db8d-1c60-181698e678f0@arm.com \
    --to=robin.murphy@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).