diff options
Diffstat (limited to 'drivers/pci/host/pcie-iproc.c')
-rw-r--r-- | drivers/pci/host/pcie-iproc.c | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index d77481ea553e..fe2efb141a9b 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c | |||
@@ -58,9 +58,17 @@ | |||
58 | #define SYS_RC_INTX_EN 0x330 | 58 | #define SYS_RC_INTX_EN 0x330 |
59 | #define SYS_RC_INTX_MASK 0xf | 59 | #define SYS_RC_INTX_MASK 0xf |
60 | 60 | ||
61 | static inline struct iproc_pcie *sys_to_pcie(struct pci_sys_data *sys) | 61 | static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) |
62 | { | 62 | { |
63 | return sys->private_data; | 63 | struct iproc_pcie *pcie; |
64 | #ifdef CONFIG_ARM | ||
65 | struct pci_sys_data *sys = bus->sysdata; | ||
66 | |||
67 | pcie = sys->private_data; | ||
68 | #else | ||
69 | pcie = bus->sysdata; | ||
70 | #endif | ||
71 | return pcie; | ||
64 | } | 72 | } |
65 | 73 | ||
66 | /** | 74 | /** |
@@ -71,8 +79,7 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus, | |||
71 | unsigned int devfn, | 79 | unsigned int devfn, |
72 | int where) | 80 | int where) |
73 | { | 81 | { |
74 | struct pci_sys_data *sys = bus->sysdata; | 82 | struct iproc_pcie *pcie = iproc_data(bus); |
75 | struct iproc_pcie *pcie = sys_to_pcie(sys); | ||
76 | unsigned slot = PCI_SLOT(devfn); | 83 | unsigned slot = PCI_SLOT(devfn); |
77 | unsigned fn = PCI_FUNC(devfn); | 84 | unsigned fn = PCI_FUNC(devfn); |
78 | unsigned busno = bus->number; | 85 | unsigned busno = bus->number; |
@@ -186,32 +193,34 @@ static void iproc_pcie_enable(struct iproc_pcie *pcie) | |||
186 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | 193 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) |
187 | { | 194 | { |
188 | int ret; | 195 | int ret; |
196 | void *sysdata; | ||
189 | struct pci_bus *bus; | 197 | struct pci_bus *bus; |
190 | 198 | ||
191 | if (!pcie || !pcie->dev || !pcie->base) | 199 | if (!pcie || !pcie->dev || !pcie->base) |
192 | return -EINVAL; | 200 | return -EINVAL; |
193 | 201 | ||
194 | if (pcie->phy) { | 202 | ret = phy_init(pcie->phy); |
195 | ret = phy_init(pcie->phy); | 203 | if (ret) { |
196 | if (ret) { | 204 | dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); |
197 | dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); | 205 | return ret; |
198 | return ret; | 206 | } |
199 | } | ||
200 | |||
201 | ret = phy_power_on(pcie->phy); | ||
202 | if (ret) { | ||
203 | dev_err(pcie->dev, "unable to power on PCIe PHY\n"); | ||
204 | goto err_exit_phy; | ||
205 | } | ||
206 | 207 | ||
208 | ret = phy_power_on(pcie->phy); | ||
209 | if (ret) { | ||
210 | dev_err(pcie->dev, "unable to power on PCIe PHY\n"); | ||
211 | goto err_exit_phy; | ||
207 | } | 212 | } |
208 | 213 | ||
209 | iproc_pcie_reset(pcie); | 214 | iproc_pcie_reset(pcie); |
210 | 215 | ||
216 | #ifdef CONFIG_ARM | ||
211 | pcie->sysdata.private_data = pcie; | 217 | pcie->sysdata.private_data = pcie; |
218 | sysdata = &pcie->sysdata; | ||
219 | #else | ||
220 | sysdata = pcie; | ||
221 | #endif | ||
212 | 222 | ||
213 | bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, | 223 | bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, sysdata, res); |
214 | &pcie->sysdata, res); | ||
215 | if (!bus) { | 224 | if (!bus) { |
216 | dev_err(pcie->dev, "unable to create PCI root bus\n"); | 225 | dev_err(pcie->dev, "unable to create PCI root bus\n"); |
217 | ret = -ENOMEM; | 226 | ret = -ENOMEM; |
@@ -229,7 +238,9 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | |||
229 | 238 | ||
230 | pci_scan_child_bus(bus); | 239 | pci_scan_child_bus(bus); |
231 | pci_assign_unassigned_bus_resources(bus); | 240 | pci_assign_unassigned_bus_resources(bus); |
241 | #ifdef CONFIG_ARM | ||
232 | pci_fixup_irqs(pci_common_swizzle, pcie->map_irq); | 242 | pci_fixup_irqs(pci_common_swizzle, pcie->map_irq); |
243 | #endif | ||
233 | pci_bus_add_devices(bus); | 244 | pci_bus_add_devices(bus); |
234 | 245 | ||
235 | return 0; | 246 | return 0; |
@@ -239,12 +250,9 @@ err_rm_root_bus: | |||
239 | pci_remove_root_bus(bus); | 250 | pci_remove_root_bus(bus); |
240 | 251 | ||
241 | err_power_off_phy: | 252 | err_power_off_phy: |
242 | if (pcie->phy) | 253 | phy_power_off(pcie->phy); |
243 | phy_power_off(pcie->phy); | ||
244 | err_exit_phy: | 254 | err_exit_phy: |
245 | if (pcie->phy) | 255 | phy_exit(pcie->phy); |
246 | phy_exit(pcie->phy); | ||
247 | |||
248 | return ret; | 256 | return ret; |
249 | } | 257 | } |
250 | EXPORT_SYMBOL(iproc_pcie_setup); | 258 | EXPORT_SYMBOL(iproc_pcie_setup); |
@@ -254,10 +262,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) | |||
254 | pci_stop_root_bus(pcie->root_bus); | 262 | pci_stop_root_bus(pcie->root_bus); |
255 | pci_remove_root_bus(pcie->root_bus); | 263 | pci_remove_root_bus(pcie->root_bus); |
256 | 264 | ||
257 | if (pcie->phy) { | 265 | phy_power_off(pcie->phy); |
258 | phy_power_off(pcie->phy); | 266 | phy_exit(pcie->phy); |
259 | phy_exit(pcie->phy); | ||
260 | } | ||
261 | 267 | ||
262 | return 0; | 268 | return 0; |
263 | } | 269 | } |