diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2013-10-31 15:58:29 -0400 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-10-31 15:58:29 -0400 |
| commit | 356bd765e2242bd351964bc2cca602dcee05c19d (patch) | |
| tree | b2591dd95ca7633b6e04d52cd75f0f1bbf08ae08 | |
| parent | f36c493491df1c83d6fee03433dd9ceaf2563e8b (diff) | |
| parent | eb36309a9db9e9e8e8e0813ebbe3a14a58969351 (diff) | |
Merge branch 'pci/host-exynos' into next
* pci/host-exynos:
PCI: exynos: Remove redundant of_match_ptr
PCI: designware: Add irq_create_mapping()
PCI: designware: Make dw_pcie_rd_own_conf(), etc., static
PCI: designware: Add header guards
PCI: exynos: Add missing clk_disable_unprepare() on error path
| -rw-r--r-- | drivers/pci/host/pci-exynos.c | 20 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-designware.c | 41 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-designware.h | 14 |
3 files changed, 40 insertions, 35 deletions
diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c index ee692c2c3d73..24beed38ddc7 100644 --- a/drivers/pci/host/pci-exynos.c +++ b/drivers/pci/host/pci-exynos.c | |||
| @@ -599,18 +599,24 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) | |||
| 599 | 599 | ||
| 600 | elbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 600 | elbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 601 | exynos_pcie->elbi_base = devm_ioremap_resource(&pdev->dev, elbi_base); | 601 | exynos_pcie->elbi_base = devm_ioremap_resource(&pdev->dev, elbi_base); |
| 602 | if (IS_ERR(exynos_pcie->elbi_base)) | 602 | if (IS_ERR(exynos_pcie->elbi_base)) { |
| 603 | return PTR_ERR(exynos_pcie->elbi_base); | 603 | ret = PTR_ERR(exynos_pcie->elbi_base); |
| 604 | goto fail_bus_clk; | ||
| 605 | } | ||
| 604 | 606 | ||
| 605 | phy_base = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 607 | phy_base = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 606 | exynos_pcie->phy_base = devm_ioremap_resource(&pdev->dev, phy_base); | 608 | exynos_pcie->phy_base = devm_ioremap_resource(&pdev->dev, phy_base); |
| 607 | if (IS_ERR(exynos_pcie->phy_base)) | 609 | if (IS_ERR(exynos_pcie->phy_base)) { |
| 608 | return PTR_ERR(exynos_pcie->phy_base); | 610 | ret = PTR_ERR(exynos_pcie->phy_base); |
| 611 | goto fail_bus_clk; | ||
| 612 | } | ||
| 609 | 613 | ||
| 610 | block_base = platform_get_resource(pdev, IORESOURCE_MEM, 2); | 614 | block_base = platform_get_resource(pdev, IORESOURCE_MEM, 2); |
| 611 | exynos_pcie->block_base = devm_ioremap_resource(&pdev->dev, block_base); | 615 | exynos_pcie->block_base = devm_ioremap_resource(&pdev->dev, block_base); |
| 612 | if (IS_ERR(exynos_pcie->block_base)) | 616 | if (IS_ERR(exynos_pcie->block_base)) { |
| 613 | return PTR_ERR(exynos_pcie->block_base); | 617 | ret = PTR_ERR(exynos_pcie->block_base); |
| 618 | goto fail_bus_clk; | ||
| 619 | } | ||
| 614 | 620 | ||
| 615 | ret = add_pcie_port(pp, pdev); | 621 | ret = add_pcie_port(pp, pdev); |
| 616 | if (ret < 0) | 622 | if (ret < 0) |
| @@ -647,7 +653,7 @@ static struct platform_driver exynos_pcie_driver = { | |||
| 647 | .driver = { | 653 | .driver = { |
| 648 | .name = "exynos-pcie", | 654 | .name = "exynos-pcie", |
| 649 | .owner = THIS_MODULE, | 655 | .owner = THIS_MODULE, |
| 650 | .of_match_table = of_match_ptr(exynos_pcie_of_match), | 656 | .of_match_table = exynos_pcie_of_match, |
| 651 | }, | 657 | }, |
| 652 | }; | 658 | }; |
| 653 | 659 | ||
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index 896301788e9d..1e1fea4d959b 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c | |||
| @@ -67,7 +67,7 @@ | |||
| 67 | 67 | ||
| 68 | static struct hw_pci dw_pci; | 68 | static struct hw_pci dw_pci; |
| 69 | 69 | ||
| 70 | unsigned long global_io_offset; | 70 | static unsigned long global_io_offset; |
| 71 | 71 | ||
| 72 | static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys) | 72 | static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys) |
| 73 | { | 73 | { |
| @@ -118,8 +118,8 @@ static inline void dw_pcie_writel_rc(struct pcie_port *pp, u32 val, u32 reg) | |||
| 118 | writel(val, pp->dbi_base + reg); | 118 | writel(val, pp->dbi_base + reg); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, | 121 | static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, |
| 122 | u32 *val) | 122 | u32 *val) |
| 123 | { | 123 | { |
| 124 | int ret; | 124 | int ret; |
| 125 | 125 | ||
| @@ -131,8 +131,8 @@ int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, | |||
| 131 | return ret; | 131 | return ret; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, | 134 | static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, |
| 135 | u32 val) | 135 | u32 val) |
| 136 | { | 136 | { |
| 137 | int ret; | 137 | int ret; |
| 138 | 138 | ||
| @@ -157,7 +157,7 @@ static struct irq_chip dw_msi_irq_chip = { | |||
| 157 | void dw_handle_msi_irq(struct pcie_port *pp) | 157 | void dw_handle_msi_irq(struct pcie_port *pp) |
| 158 | { | 158 | { |
| 159 | unsigned long val; | 159 | unsigned long val; |
| 160 | int i, pos; | 160 | int i, pos, irq; |
| 161 | 161 | ||
| 162 | for (i = 0; i < MAX_MSI_CTRLS; i++) { | 162 | for (i = 0; i < MAX_MSI_CTRLS; i++) { |
| 163 | dw_pcie_rd_own_conf(pp, PCIE_MSI_INTR0_STATUS + i * 12, 4, | 163 | dw_pcie_rd_own_conf(pp, PCIE_MSI_INTR0_STATUS + i * 12, 4, |
| @@ -165,8 +165,9 @@ void dw_handle_msi_irq(struct pcie_port *pp) | |||
| 165 | if (val) { | 165 | if (val) { |
| 166 | pos = 0; | 166 | pos = 0; |
| 167 | while ((pos = find_next_bit(&val, 32, pos)) != 32) { | 167 | while ((pos = find_next_bit(&val, 32, pos)) != 32) { |
| 168 | generic_handle_irq(pp->msi_irq_start | 168 | irq = irq_find_mapping(pp->irq_domain, |
| 169 | + (i * 32) + pos); | 169 | i * 32 + pos); |
| 170 | generic_handle_irq(irq); | ||
| 170 | pos++; | 171 | pos++; |
| 171 | } | 172 | } |
| 172 | } | 173 | } |
| @@ -237,9 +238,8 @@ static int assign_irq(int no_irqs, struct msi_desc *desc, int *pos) | |||
| 237 | } | 238 | } |
| 238 | } | 239 | } |
| 239 | 240 | ||
| 240 | irq = (pp->msi_irq_start + pos0); | 241 | irq = irq_find_mapping(pp->irq_domain, pos0); |
| 241 | 242 | if (!irq) | |
| 242 | if ((irq + no_irqs) > (pp->msi_irq_start + MAX_MSI_IRQS-1)) | ||
| 243 | goto no_valid_irq; | 243 | goto no_valid_irq; |
| 244 | 244 | ||
| 245 | i = 0; | 245 | i = 0; |
| @@ -270,6 +270,7 @@ static void clear_irq(unsigned int irq) | |||
| 270 | struct irq_desc *desc; | 270 | struct irq_desc *desc; |
| 271 | struct msi_desc *msi; | 271 | struct msi_desc *msi; |
| 272 | struct pcie_port *pp; | 272 | struct pcie_port *pp; |
| 273 | struct irq_data *data = irq_get_irq_data(irq); | ||
| 273 | 274 | ||
| 274 | /* get the port structure */ | 275 | /* get the port structure */ |
| 275 | desc = irq_to_desc(irq); | 276 | desc = irq_to_desc(irq); |
| @@ -280,7 +281,7 @@ static void clear_irq(unsigned int irq) | |||
| 280 | return; | 281 | return; |
| 281 | } | 282 | } |
| 282 | 283 | ||
| 283 | pos = irq - pp->msi_irq_start; | 284 | pos = data->hwirq; |
| 284 | 285 | ||
| 285 | irq_free_desc(irq); | 286 | irq_free_desc(irq); |
| 286 | 287 | ||
| @@ -371,8 +372,7 @@ int __init dw_pcie_host_init(struct pcie_port *pp) | |||
| 371 | struct of_pci_range range; | 372 | struct of_pci_range range; |
| 372 | struct of_pci_range_parser parser; | 373 | struct of_pci_range_parser parser; |
| 373 | u32 val; | 374 | u32 val; |
| 374 | 375 | int i; | |
| 375 | struct irq_domain *irq_domain; | ||
| 376 | 376 | ||
| 377 | if (of_pci_range_parser_init(&parser, np)) { | 377 | if (of_pci_range_parser_init(&parser, np)) { |
| 378 | dev_err(pp->dev, "missing ranges property\n"); | 378 | dev_err(pp->dev, "missing ranges property\n"); |
| @@ -441,15 +441,16 @@ int __init dw_pcie_host_init(struct pcie_port *pp) | |||
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | 443 | if (IS_ENABLED(CONFIG_PCI_MSI)) { |
| 444 | irq_domain = irq_domain_add_linear(pp->dev->of_node, | 444 | pp->irq_domain = irq_domain_add_linear(pp->dev->of_node, |
| 445 | MAX_MSI_IRQS, &msi_domain_ops, | 445 | MAX_MSI_IRQS, &msi_domain_ops, |
| 446 | &dw_pcie_msi_chip); | 446 | &dw_pcie_msi_chip); |
| 447 | if (!irq_domain) { | 447 | if (!pp->irq_domain) { |
| 448 | dev_err(pp->dev, "irq domain init failed\n"); | 448 | dev_err(pp->dev, "irq domain init failed\n"); |
| 449 | return -ENXIO; | 449 | return -ENXIO; |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | pp->msi_irq_start = irq_find_mapping(irq_domain, 0); | 452 | for (i = 0; i < MAX_MSI_IRQS; i++) |
| 453 | irq_create_mapping(pp->irq_domain, i); | ||
| 453 | } | 454 | } |
| 454 | 455 | ||
| 455 | if (pp->ops->host_init) | 456 | if (pp->ops->host_init) |
| @@ -667,7 +668,7 @@ static struct pci_ops dw_pcie_ops = { | |||
| 667 | .write = dw_pcie_wr_conf, | 668 | .write = dw_pcie_wr_conf, |
| 668 | }; | 669 | }; |
| 669 | 670 | ||
| 670 | int dw_pcie_setup(int nr, struct pci_sys_data *sys) | 671 | static int dw_pcie_setup(int nr, struct pci_sys_data *sys) |
| 671 | { | 672 | { |
| 672 | struct pcie_port *pp; | 673 | struct pcie_port *pp; |
| 673 | 674 | ||
| @@ -690,7 +691,7 @@ int dw_pcie_setup(int nr, struct pci_sys_data *sys) | |||
| 690 | return 1; | 691 | return 1; |
| 691 | } | 692 | } |
| 692 | 693 | ||
| 693 | struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 694 | static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
| 694 | { | 695 | { |
| 695 | struct pci_bus *bus; | 696 | struct pci_bus *bus; |
| 696 | struct pcie_port *pp = sys_to_pcie(sys); | 697 | struct pcie_port *pp = sys_to_pcie(sys); |
| @@ -707,7 +708,7 @@ struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) | |||
| 707 | return bus; | 708 | return bus; |
| 708 | } | 709 | } |
| 709 | 710 | ||
| 710 | int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 711 | static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
| 711 | { | 712 | { |
| 712 | struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata); | 713 | struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata); |
| 713 | 714 | ||
diff --git a/drivers/pci/host/pcie-designware.h b/drivers/pci/host/pcie-designware.h index faccbbf31907..c15379be2372 100644 --- a/drivers/pci/host/pcie-designware.h +++ b/drivers/pci/host/pcie-designware.h | |||
| @@ -11,6 +11,9 @@ | |||
| 11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #ifndef _PCIE_DESIGNWARE_H | ||
| 15 | #define _PCIE_DESIGNWARE_H | ||
| 16 | |||
| 14 | struct pcie_port_info { | 17 | struct pcie_port_info { |
| 15 | u32 cfg0_size; | 18 | u32 cfg0_size; |
| 16 | u32 cfg1_size; | 19 | u32 cfg1_size; |
| @@ -47,7 +50,7 @@ struct pcie_port { | |||
| 47 | u32 lanes; | 50 | u32 lanes; |
| 48 | struct pcie_host_ops *ops; | 51 | struct pcie_host_ops *ops; |
| 49 | int msi_irq; | 52 | int msi_irq; |
| 50 | int msi_irq_start; | 53 | struct irq_domain *irq_domain; |
| 51 | unsigned long msi_data; | 54 | unsigned long msi_data; |
| 52 | DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); | 55 | DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); |
| 53 | }; | 56 | }; |
| @@ -63,17 +66,12 @@ struct pcie_host_ops { | |||
| 63 | void (*host_init)(struct pcie_port *pp); | 66 | void (*host_init)(struct pcie_port *pp); |
| 64 | }; | 67 | }; |
| 65 | 68 | ||
| 66 | extern unsigned long global_io_offset; | ||
| 67 | |||
| 68 | int cfg_read(void __iomem *addr, int where, int size, u32 *val); | 69 | int cfg_read(void __iomem *addr, int where, int size, u32 *val); |
| 69 | int cfg_write(void __iomem *addr, int where, int size, u32 val); | 70 | int cfg_write(void __iomem *addr, int where, int size, u32 val); |
| 70 | int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, u32 val); | ||
| 71 | int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, u32 *val); | ||
| 72 | void dw_handle_msi_irq(struct pcie_port *pp); | 71 | void dw_handle_msi_irq(struct pcie_port *pp); |
| 73 | void dw_pcie_msi_init(struct pcie_port *pp); | 72 | void dw_pcie_msi_init(struct pcie_port *pp); |
| 74 | int dw_pcie_link_up(struct pcie_port *pp); | 73 | int dw_pcie_link_up(struct pcie_port *pp); |
| 75 | void dw_pcie_setup_rc(struct pcie_port *pp); | 74 | void dw_pcie_setup_rc(struct pcie_port *pp); |
| 76 | int dw_pcie_host_init(struct pcie_port *pp); | 75 | int dw_pcie_host_init(struct pcie_port *pp); |
| 77 | int dw_pcie_setup(int nr, struct pci_sys_data *sys); | 76 | |
| 78 | struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys); | 77 | #endif /* _PCIE_DESIGNWARE_H */ |
| 79 | int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin); | ||
