diff options
Diffstat (limited to 'drivers/pci/pcie/pme.c')
-rw-r--r-- | drivers/pci/pcie/pme.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 001f1b78f39c..9ca0dc9ffd84 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
@@ -57,17 +57,12 @@ struct pcie_pme_service_data { | |||
57 | */ | 57 | */ |
58 | void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) | 58 | void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) |
59 | { | 59 | { |
60 | int rtctl_pos; | ||
61 | u16 rtctl; | ||
62 | |||
63 | rtctl_pos = pci_pcie_cap(dev) + PCI_EXP_RTCTL; | ||
64 | |||
65 | pci_read_config_word(dev, rtctl_pos, &rtctl); | ||
66 | if (enable) | 60 | if (enable) |
67 | rtctl |= PCI_EXP_RTCTL_PMEIE; | 61 | pcie_capability_set_word(dev, PCI_EXP_RTCTL, |
62 | PCI_EXP_RTCTL_PMEIE); | ||
68 | else | 63 | else |
69 | rtctl &= ~PCI_EXP_RTCTL_PMEIE; | 64 | pcie_capability_clear_word(dev, PCI_EXP_RTCTL, |
70 | pci_write_config_word(dev, rtctl_pos, rtctl); | 65 | PCI_EXP_RTCTL_PMEIE); |
71 | } | 66 | } |
72 | 67 | ||
73 | /** | 68 | /** |
@@ -120,7 +115,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn) | |||
120 | if (!dev) | 115 | if (!dev) |
121 | return false; | 116 | return false; |
122 | 117 | ||
123 | if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { | 118 | if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) { |
124 | down_read(&pci_bus_sem); | 119 | down_read(&pci_bus_sem); |
125 | if (pcie_pme_walk_bus(bus)) | 120 | if (pcie_pme_walk_bus(bus)) |
126 | found = true; | 121 | found = true; |
@@ -226,18 +221,15 @@ static void pcie_pme_work_fn(struct work_struct *work) | |||
226 | struct pcie_pme_service_data *data = | 221 | struct pcie_pme_service_data *data = |
227 | container_of(work, struct pcie_pme_service_data, work); | 222 | container_of(work, struct pcie_pme_service_data, work); |
228 | struct pci_dev *port = data->srv->port; | 223 | struct pci_dev *port = data->srv->port; |
229 | int rtsta_pos; | ||
230 | u32 rtsta; | 224 | u32 rtsta; |
231 | 225 | ||
232 | rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; | ||
233 | |||
234 | spin_lock_irq(&data->lock); | 226 | spin_lock_irq(&data->lock); |
235 | 227 | ||
236 | for (;;) { | 228 | for (;;) { |
237 | if (data->noirq) | 229 | if (data->noirq) |
238 | break; | 230 | break; |
239 | 231 | ||
240 | pci_read_config_dword(port, rtsta_pos, &rtsta); | 232 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); |
241 | if (rtsta & PCI_EXP_RTSTA_PME) { | 233 | if (rtsta & PCI_EXP_RTSTA_PME) { |
242 | /* | 234 | /* |
243 | * Clear PME status of the port. If there are other | 235 | * Clear PME status of the port. If there are other |
@@ -276,17 +268,14 @@ static irqreturn_t pcie_pme_irq(int irq, void *context) | |||
276 | { | 268 | { |
277 | struct pci_dev *port; | 269 | struct pci_dev *port; |
278 | struct pcie_pme_service_data *data; | 270 | struct pcie_pme_service_data *data; |
279 | int rtsta_pos; | ||
280 | u32 rtsta; | 271 | u32 rtsta; |
281 | unsigned long flags; | 272 | unsigned long flags; |
282 | 273 | ||
283 | port = ((struct pcie_device *)context)->port; | 274 | port = ((struct pcie_device *)context)->port; |
284 | data = get_service_data((struct pcie_device *)context); | 275 | data = get_service_data((struct pcie_device *)context); |
285 | 276 | ||
286 | rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; | ||
287 | |||
288 | spin_lock_irqsave(&data->lock, flags); | 277 | spin_lock_irqsave(&data->lock, flags); |
289 | pci_read_config_dword(port, rtsta_pos, &rtsta); | 278 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); |
290 | 279 | ||
291 | if (!(rtsta & PCI_EXP_RTSTA_PME)) { | 280 | if (!(rtsta & PCI_EXP_RTSTA_PME)) { |
292 | spin_unlock_irqrestore(&data->lock, flags); | 281 | spin_unlock_irqrestore(&data->lock, flags); |
@@ -335,13 +324,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port) | |||
335 | struct pci_dev *dev; | 324 | struct pci_dev *dev; |
336 | 325 | ||
337 | /* Check if this is a root port event collector. */ | 326 | /* Check if this is a root port event collector. */ |
338 | if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus) | 327 | if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus) |
339 | return; | 328 | return; |
340 | 329 | ||
341 | down_read(&pci_bus_sem); | 330 | down_read(&pci_bus_sem); |
342 | list_for_each_entry(dev, &bus->devices, bus_list) | 331 | list_for_each_entry(dev, &bus->devices, bus_list) |
343 | if (pci_is_pcie(dev) | 332 | if (pci_is_pcie(dev) |
344 | && dev->pcie_type == PCI_EXP_TYPE_RC_END) | 333 | && pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) |
345 | pcie_pme_set_native(dev, NULL); | 334 | pcie_pme_set_native(dev, NULL); |
346 | up_read(&pci_bus_sem); | 335 | up_read(&pci_bus_sem); |
347 | } | 336 | } |