diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2018-10-17 03:41:03 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2018-10-17 04:45:46 -0400 |
commit | b51a625b784aa9cdac4a177560e19f0a0041ce19 (patch) | |
tree | b61270de472c0d42c225b61bb433fdefbbcc2c31 /drivers/pci/controller/dwc | |
parent | 03d178386477cb58031b31efe2403071a01868fd (diff) |
PCI: keystone: Use SYSCON APIs to get device ID from control module
Control module registers should be read using syscon APIs.
pci-keystone.c uses platform_get_resource() to get control module registers.
Fix it here by using syscon APIs to get device id from control module.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Diffstat (limited to 'drivers/pci/controller/dwc')
-rw-r--r-- | drivers/pci/controller/dwc/pci-keystone.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index e2045b5d2af2..e22328f89c84 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c | |||
@@ -15,12 +15,14 @@ | |||
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/irqdomain.h> | 16 | #include <linux/irqdomain.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/mfd/syscon.h> | ||
18 | #include <linux/msi.h> | 19 | #include <linux/msi.h> |
19 | #include <linux/of_irq.h> | 20 | #include <linux/of_irq.h> |
20 | #include <linux/of.h> | 21 | #include <linux/of.h> |
21 | #include <linux/of_pci.h> | 22 | #include <linux/of_pci.h> |
22 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
23 | #include <linux/phy/phy.h> | 24 | #include <linux/phy/phy.h> |
25 | #include <linux/regmap.h> | ||
24 | #include <linux/resource.h> | 26 | #include <linux/resource.h> |
25 | #include <linux/signal.h> | 27 | #include <linux/signal.h> |
26 | 28 | ||
@@ -28,6 +30,9 @@ | |||
28 | 30 | ||
29 | #define DRIVER_NAME "keystone-pcie" | 31 | #define DRIVER_NAME "keystone-pcie" |
30 | 32 | ||
33 | #define PCIE_VENDORID_MASK 0xffff | ||
34 | #define PCIE_DEVICEID_SHIFT 16 | ||
35 | |||
31 | /* DEV_STAT_CTRL */ | 36 | /* DEV_STAT_CTRL */ |
32 | #define PCIE_CAP_BASE 0x70 | 37 | #define PCIE_CAP_BASE 0x70 |
33 | 38 | ||
@@ -744,10 +749,34 @@ static int ks_pcie_fault(unsigned long addr, unsigned int fsr, | |||
744 | return 0; | 749 | return 0; |
745 | } | 750 | } |
746 | 751 | ||
752 | static int __init ks_pcie_init_id(struct keystone_pcie *ks_pcie) | ||
753 | { | ||
754 | int ret; | ||
755 | unsigned int id; | ||
756 | struct regmap *devctrl_regs; | ||
757 | struct dw_pcie *pci = ks_pcie->pci; | ||
758 | struct device *dev = pci->dev; | ||
759 | struct device_node *np = dev->of_node; | ||
760 | |||
761 | devctrl_regs = syscon_regmap_lookup_by_phandle(np, "ti,syscon-pcie-id"); | ||
762 | if (IS_ERR(devctrl_regs)) | ||
763 | return PTR_ERR(devctrl_regs); | ||
764 | |||
765 | ret = regmap_read(devctrl_regs, 0, &id); | ||
766 | if (ret) | ||
767 | return ret; | ||
768 | |||
769 | dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, id & PCIE_VENDORID_MASK); | ||
770 | dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, id >> PCIE_DEVICEID_SHIFT); | ||
771 | |||
772 | return 0; | ||
773 | } | ||
774 | |||
747 | static int __init ks_pcie_host_init(struct pcie_port *pp) | 775 | static int __init ks_pcie_host_init(struct pcie_port *pp) |
748 | { | 776 | { |
749 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | 777 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); |
750 | struct keystone_pcie *ks_pcie = to_keystone_pcie(pci); | 778 | struct keystone_pcie *ks_pcie = to_keystone_pcie(pci); |
779 | int ret; | ||
751 | 780 | ||
752 | dw_pcie_setup_rc(pp); | 781 | dw_pcie_setup_rc(pp); |
753 | 782 | ||
@@ -757,8 +786,9 @@ static int __init ks_pcie_host_init(struct pcie_port *pp) | |||
757 | writew(PCI_IO_RANGE_TYPE_32 | (PCI_IO_RANGE_TYPE_32 << 8), | 786 | writew(PCI_IO_RANGE_TYPE_32 | (PCI_IO_RANGE_TYPE_32 << 8), |
758 | pci->dbi_base + PCI_IO_BASE); | 787 | pci->dbi_base + PCI_IO_BASE); |
759 | 788 | ||
760 | /* update the Vendor ID */ | 789 | ret = ks_pcie_init_id(ks_pcie); |
761 | writew(ks_pcie->device_id, pci->dbi_base + PCI_DEVICE_ID); | 790 | if (ret < 0) |
791 | return ret; | ||
762 | 792 | ||
763 | /* | 793 | /* |
764 | * PCIe access errors that result into OCP errors are caught by ARM as | 794 | * PCIe access errors that result into OCP errors are caught by ARM as |
@@ -864,8 +894,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev) | |||
864 | struct device *dev = &pdev->dev; | 894 | struct device *dev = &pdev->dev; |
865 | struct dw_pcie *pci; | 895 | struct dw_pcie *pci; |
866 | struct keystone_pcie *ks_pcie; | 896 | struct keystone_pcie *ks_pcie; |
867 | struct resource *res; | ||
868 | void __iomem *reg_p; | ||
869 | struct phy *phy; | 897 | struct phy *phy; |
870 | int ret; | 898 | int ret; |
871 | 899 | ||
@@ -893,15 +921,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev) | |||
893 | return ret; | 921 | return ret; |
894 | } | 922 | } |
895 | 923 | ||
896 | /* index 2 is to read PCI DEVICE_ID */ | ||
897 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
898 | reg_p = devm_ioremap_resource(dev, res); | ||
899 | if (IS_ERR(reg_p)) | ||
900 | return PTR_ERR(reg_p); | ||
901 | ks_pcie->device_id = readl(reg_p) >> 16; | ||
902 | devm_iounmap(dev, reg_p); | ||
903 | devm_release_mem_region(dev, res->start, resource_size(res)); | ||
904 | |||
905 | ks_pcie->np = dev->of_node; | 924 | ks_pcie->np = dev->of_node; |
906 | platform_set_drvdata(pdev, ks_pcie); | 925 | platform_set_drvdata(pdev, ks_pcie); |
907 | ks_pcie->clk = devm_clk_get(dev, "pcie"); | 926 | ks_pcie->clk = devm_clk_get(dev, "pcie"); |