diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-21 14:52:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-21 14:52:16 -0500 |
commit | d43421565bf0510d35e6a39ebf96586ad486f3aa (patch) | |
tree | f3a6cf9f5284d0146c9c858dc96c5b6bcdf28dc9 | |
parent | 859e762544902c3e09b3f8d994aab80ea5ff5042 (diff) | |
parent | 9662e32c810ad3e6ce49832d5f585a54f8fbdbdb (diff) |
Merge tag 'pci-v4.5-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI updates from Bjorn Helgaas:
"PCI changes for the v4.5 merge window:
Enumeration:
- Simplify config space size computation (Bjorn Helgaas)
- Avoid iterating through ROM outside the resource window (Edward O'Callaghan)
- Support PCIe devices with short cfg_size (Jason S. McMullan)
- Add Netronome vendor and device IDs (Jason S. McMullan)
- Limit config space size for Netronome NFP6000 family (Jason S. McMullan)
- Add Netronome NFP4000 PF device ID (Simon Horman)
- Limit config space size for Netronome NFP4000 (Simon Horman)
- Print warnings for all invalid expansion ROM headers (Vladis Dronov)
Resource management:
- Fix minimum allocation address overwrite (Christoph Biedl)
PCI device hotplug:
- acpiphp_ibm: Fix null dereferences on null ibm_slot (Colin Ian King)
- pciehp: Always protect pciehp_disable_slot() with hotplug mutex (Guenter Roeck)
- shpchp: Constify hpc_ops structure (Julia Lawall)
- ibmphp: Remove unneeded NULL test (Julia Lawall)
Power management:
- Make ASPM sysfs link_state_store() consistent with link_state_show() (Andy Lutomirski)
Virtualization
- Add function 1 DMA alias quirk for Lite-On/Plextor M6e/Marvell 88SS9183 (Tim Sander)
MSI:
- Remove empty pci_msi_init_pci_dev() (Bjorn Helgaas)
- Mark PCIe/PCI (MSI) IRQ cascade handlers as IRQF_NO_THREAD (Grygorii Strashko)
- Initialize MSI capability for all architectures (Guilherme G. Piccoli)
- Relax msi_domain_alloc() to support parentless MSI irqdomains (Liu Jiang)
ARM Versatile host bridge driver:
- Remove unused pci_sys_data structures (Lorenzo Pieralisi)
Broadcom iProc host bridge driver:
- Hide CONFIG_PCIE_IPROC (Arnd Bergmann)
- Do not use 0x in front of %pap (Dmitry V. Krivenok)
- Update iProc PCIe device tree binding (Ray Jui)
- Add PAXC interface support (Ray Jui)
- Add iProc PCIe MSI device tree binding (Ray Jui)
- Add iProc PCIe MSI support (Ray Jui)
Freescale i.MX6 host bridge driver:
- Use gpio_set_value_cansleep() (Fabio Estevam)
- Add support for active-low reset GPIO (Petr Štetiar)
HiSilicon host bridge driver:
- Add support for HiSilicon Hip06 PCIe host controllers (Gabriele Paoloni)
Intel VMD host bridge driver:
- Export irq_domain_set_info() for module use (Keith Busch)
- x86/PCI: Allow DMA ops specific to a PCI domain (Keith Busch)
- Use 32 bit PCI domain numbers (Keith Busch)
- Add driver for Intel Volume Management Device (VMD) (Keith Busch)
Qualcomm host bridge driver:
- Document PCIe devicetree bindings (Stanimir Varbanov)
- Add Qualcomm PCIe controller driver (Stanimir Varbanov)
- dts: apq8064: add PCIe devicetree node (Stanimir Varbanov)
- dts: ifc6410: enable PCIe DT node for this board (Stanimir Varbanov)
Renesas R-Car host bridge driver:
- Add support for R-Car H3 to pcie-rcar (Harunobu Kurokawa)
- Allow DT to override default window settings (Phil Edworthy)
- Convert to DT resource parsing API (Phil Edworthy)
- Revert "PCI: rcar: Build pcie-rcar.c only on ARM" (Phil Edworthy)
- Remove unused pci_sys_data struct from pcie-rcar (Phil Edworthy)
- Add runtime PM support to pcie-rcar (Phil Edworthy)
- Add Gen2 PHY setup to pcie-rcar (Phil Edworthy)
- Add gen2 fallback compatibility string for pci-rcar-gen2 (Simon Horman)
- Add gen2 fallback compatibility string for pcie-rcar (Simon Horman)
Synopsys DesignWare host bridge driver:
- Simplify control flow (Bjorn Helgaas)
- Make config accessor override checking symmetric (Bjorn Helgaas)
- Ensure ATU is enabled before IO/conf space accesses (Stanimir Varbanov)
Miscellaneous:
- Add of_pci_get_host_bridge_resources() stub (Arnd Bergmann)
- Check for PCI_HEADER_TYPE_BRIDGE equality, not bitmask (Bjorn Helgaas)
- Fix all whitespace issues (Bogicevic Sasa)
- x86/PCI: Simplify pci_bios_{read,write} (Geliang Tang)
- Use to_pci_dev() instead of open-coding it (Geliang Tang)
- Use kobj_to_dev() instead of open-coding it (Geliang Tang)
- Use list_for_each_entry() to simplify code (Geliang Tang)
- Fix typos in <linux/msi.h> (Thomas Petazzoni)
- x86/PCI: Clarify AMD Fam10h config access restrictions comment (Tomasz Nowicki)"
* tag 'pci-v4.5-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (58 commits)
PCI: Add function 1 DMA alias quirk for Lite-On/Plextor M6e/Marvell 88SS9183
PCI: Limit config space size for Netronome NFP4000
PCI: Add Netronome NFP4000 PF device ID
x86/PCI: Add driver for Intel Volume Management Device (VMD)
PCI/AER: Use 32 bit PCI domain numbers
x86/PCI: Allow DMA ops specific to a PCI domain
irqdomain: Export irq_domain_set_info() for module use
PCI: host: Add of_pci_get_host_bridge_resources() stub
genirq/MSI: Relax msi_domain_alloc() to support parentless MSI irqdomains
PCI: rcar: Add Gen2 PHY setup to pcie-rcar
PCI: rcar: Add runtime PM support to pcie-rcar
PCI: designware: Make config accessor override checking symmetric
PCI: ibmphp: Remove unneeded NULL test
ARM: dts: ifc6410: enable PCIe DT node for this board
ARM: dts: apq8064: add PCIe devicetree node
PCI: hotplug: Use list_for_each_entry() to simplify code
PCI: rcar: Remove unused pci_sys_data struct from pcie-rcar
PCI: hisi: Add support for HiSilicon Hip06 PCIe host controllers
PCI: Avoid iterating through memory outside the resource window
PCI: acpiphp_ibm: Fix null dereferences on null ibm_slot
...
96 files changed, 4682 insertions, 1896 deletions
diff --git a/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt b/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt index 45c2a8094a9f..01b88f4e0d5b 100644 --- a/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt +++ b/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt | |||
@@ -1,7 +1,10 @@ | |||
1 | * Broadcom iProc PCIe controller with the platform bus interface | 1 | * Broadcom iProc PCIe controller with the platform bus interface |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: Must be "brcm,iproc-pcie" | 4 | - compatible: Must be "brcm,iproc-pcie" for PAXB, or "brcm,iproc-pcie-paxc" |
5 | for PAXC. PAXB-based root complex is used for external endpoint devices. | ||
6 | PAXC-based root complex is connected to emulated endpoint devices | ||
7 | internal to the ASIC | ||
5 | - reg: base address and length of the PCIe controller I/O register space | 8 | - reg: base address and length of the PCIe controller I/O register space |
6 | - #interrupt-cells: set to <1> | 9 | - #interrupt-cells: set to <1> |
7 | - interrupt-map-mask and interrupt-map, standard PCI properties to define the | 10 | - interrupt-map-mask and interrupt-map, standard PCI properties to define the |
@@ -32,6 +35,28 @@ Optional: | |||
32 | - brcm,pcie-ob-oarr-size: Some iProc SoCs need the OARR size bit to be set to | 35 | - brcm,pcie-ob-oarr-size: Some iProc SoCs need the OARR size bit to be set to |
33 | increase the outbound window size | 36 | increase the outbound window size |
34 | 37 | ||
38 | MSI support (optional): | ||
39 | |||
40 | For older platforms without MSI integrated in the GIC, iProc PCIe core provides | ||
41 | an event queue based MSI support. The iProc MSI uses host memories to store | ||
42 | MSI posted writes in the event queues | ||
43 | |||
44 | - msi-parent: Link to the device node of the MSI controller. On newer iProc | ||
45 | platforms, the MSI controller may be gicv2m or gicv3-its. On older iProc | ||
46 | platforms without MSI support in its interrupt controller, one may use the | ||
47 | event queue based MSI support integrated within the iProc PCIe core. | ||
48 | |||
49 | When the iProc event queue based MSI is used, one needs to define the | ||
50 | following properties in the MSI device node: | ||
51 | - compatible: Must be "brcm,iproc-msi" | ||
52 | - msi-controller: claims itself as an MSI controller | ||
53 | - interrupt-parent: Link to its parent interrupt device | ||
54 | - interrupts: List of interrupt IDs from its parent interrupt device | ||
55 | |||
56 | Optional properties: | ||
57 | - brcm,pcie-msi-inten: Needs to be present for some older iProc platforms that | ||
58 | require the interrupt enable registers to be set explicitly to enable MSI | ||
59 | |||
35 | Example: | 60 | Example: |
36 | pcie0: pcie@18012000 { | 61 | pcie0: pcie@18012000 { |
37 | compatible = "brcm,iproc-pcie"; | 62 | compatible = "brcm,iproc-pcie"; |
@@ -58,6 +83,19 @@ Example: | |||
58 | brcm,pcie-ob-oarr-size; | 83 | brcm,pcie-ob-oarr-size; |
59 | brcm,pcie-ob-axi-offset = <0x00000000>; | 84 | brcm,pcie-ob-axi-offset = <0x00000000>; |
60 | brcm,pcie-ob-window-size = <256>; | 85 | brcm,pcie-ob-window-size = <256>; |
86 | |||
87 | msi-parent = <&msi0>; | ||
88 | |||
89 | /* iProc event queue based MSI */ | ||
90 | msi0: msi@18012000 { | ||
91 | compatible = "brcm,iproc-msi"; | ||
92 | msi-controller; | ||
93 | interrupt-parent = <&gic>; | ||
94 | interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>, | ||
95 | <GIC_SPI 97 IRQ_TYPE_NONE>, | ||
96 | <GIC_SPI 98 IRQ_TYPE_NONE>, | ||
97 | <GIC_SPI 99 IRQ_TYPE_NONE>, | ||
98 | }; | ||
61 | }; | 99 | }; |
62 | 100 | ||
63 | pcie1: pcie@18013000 { | 101 | pcie1: pcie@18013000 { |
diff --git a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt index 17c6ed9c6059..b721beacfe4d 100644 --- a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt +++ b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | HiSilicon PCIe host bridge DT description | 1 | HiSilicon Hip05 and Hip06 PCIe host bridge DT description |
2 | 2 | ||
3 | HiSilicon PCIe host controller is based on Designware PCI core. | 3 | HiSilicon PCIe host controller is based on Designware PCI core. |
4 | It shares common functions with PCIe Designware core driver and inherits | 4 | It shares common functions with PCIe Designware core driver and inherits |
@@ -7,8 +7,8 @@ Documentation/devicetree/bindings/pci/designware-pci.txt. | |||
7 | 7 | ||
8 | Additional properties are described here: | 8 | Additional properties are described here: |
9 | 9 | ||
10 | Required properties: | 10 | Required properties |
11 | - compatible: Should contain "hisilicon,hip05-pcie". | 11 | - compatible: Should contain "hisilicon,hip05-pcie" or "hisilicon,hip06-pcie". |
12 | - reg: Should contain rc_dbi, config registers location and length. | 12 | - reg: Should contain rc_dbi, config registers location and length. |
13 | - reg-names: Must include the following entries: | 13 | - reg-names: Must include the following entries: |
14 | "rc_dbi": controller configuration registers; | 14 | "rc_dbi": controller configuration registers; |
@@ -20,7 +20,7 @@ Optional properties: | |||
20 | - status: Either "ok" or "disabled". | 20 | - status: Either "ok" or "disabled". |
21 | - dma-coherent: Present if DMA operations are coherent. | 21 | - dma-coherent: Present if DMA operations are coherent. |
22 | 22 | ||
23 | Example: | 23 | Hip05 Example (note that Hip06 is the same except compatible): |
24 | pcie@0xb0080000 { | 24 | pcie@0xb0080000 { |
25 | compatible = "hisilicon,hip05-pcie", "snps,dw-pcie"; | 25 | compatible = "hisilicon,hip05-pcie", "snps,dw-pcie"; |
26 | reg = <0 0xb0080000 0 0x10000>, <0x220 0x00000000 0 0x2000>; | 26 | reg = <0 0xb0080000 0 0x10000>, <0x220 0x00000000 0 0x2000>; |
diff --git a/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt b/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt index 7fab84b33531..4e8b90e43dd8 100644 --- a/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt +++ b/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt | |||
@@ -8,7 +8,14 @@ OHCI and EHCI controllers. | |||
8 | Required properties: | 8 | Required properties: |
9 | - compatible: "renesas,pci-r8a7790" for the R8A7790 SoC; | 9 | - compatible: "renesas,pci-r8a7790" for the R8A7790 SoC; |
10 | "renesas,pci-r8a7791" for the R8A7791 SoC; | 10 | "renesas,pci-r8a7791" for the R8A7791 SoC; |
11 | "renesas,pci-r8a7794" for the R8A7794 SoC. | 11 | "renesas,pci-r8a7794" for the R8A7794 SoC; |
12 | "renesas,pci-rcar-gen2" for a generic R-Car Gen2 compatible device | ||
13 | |||
14 | |||
15 | When compatible with the generic version, nodes must list the | ||
16 | SoC-specific version corresponding to the platform first | ||
17 | followed by the generic version. | ||
18 | |||
12 | - reg: A list of physical regions to access the device: the first is | 19 | - reg: A list of physical regions to access the device: the first is |
13 | the operational registers for the OHCI/EHCI controllers and the | 20 | the operational registers for the OHCI/EHCI controllers and the |
14 | second is for the bridge configuration and control registers. | 21 | second is for the bridge configuration and control registers. |
@@ -24,10 +31,15 @@ Required properties: | |||
24 | - interrupt-map-mask: standard property that helps to define the interrupt | 31 | - interrupt-map-mask: standard property that helps to define the interrupt |
25 | mapping. | 32 | mapping. |
26 | 33 | ||
34 | Optional properties: | ||
35 | - dma-ranges: a single range for the inbound memory region. If not supplied, | ||
36 | defaults to 1GiB at 0x40000000. Note there are hardware restrictions on the | ||
37 | allowed combinations of address and size. | ||
38 | |||
27 | Example SoC configuration: | 39 | Example SoC configuration: |
28 | 40 | ||
29 | pci0: pci@ee090000 { | 41 | pci0: pci@ee090000 { |
30 | compatible = "renesas,pci-r8a7790"; | 42 | compatible = "renesas,pci-r8a7790", "renesas,pci-rcar-gen2"; |
31 | clocks = <&mstp7_clks R8A7790_CLK_EHCI>; | 43 | clocks = <&mstp7_clks R8A7790_CLK_EHCI>; |
32 | reg = <0x0 0xee090000 0x0 0xc00>, | 44 | reg = <0x0 0xee090000 0x0 0xc00>, |
33 | <0x0 0xee080000 0x0 0x1100>; | 45 | <0x0 0xee080000 0x0 0x1100>; |
@@ -38,6 +50,7 @@ Example SoC configuration: | |||
38 | #address-cells = <3>; | 50 | #address-cells = <3>; |
39 | #size-cells = <2>; | 51 | #size-cells = <2>; |
40 | #interrupt-cells = <1>; | 52 | #interrupt-cells = <1>; |
53 | dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 0 0x40000000>; | ||
41 | interrupt-map-mask = <0xff00 0 0 0x7>; | 54 | interrupt-map-mask = <0xff00 0 0 0x7>; |
42 | interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH | 55 | interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH |
43 | 0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH | 56 | 0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH |
diff --git a/Documentation/devicetree/bindings/pci/qcom,pcie.txt b/Documentation/devicetree/bindings/pci/qcom,pcie.txt new file mode 100644 index 000000000000..4059a6f89bc1 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/qcom,pcie.txt | |||
@@ -0,0 +1,233 @@ | |||
1 | * Qualcomm PCI express root complex | ||
2 | |||
3 | - compatible: | ||
4 | Usage: required | ||
5 | Value type: <stringlist> | ||
6 | Definition: Value should contain | ||
7 | - "qcom,pcie-ipq8064" for ipq8064 | ||
8 | - "qcom,pcie-apq8064" for apq8064 | ||
9 | - "qcom,pcie-apq8084" for apq8084 | ||
10 | |||
11 | - reg: | ||
12 | Usage: required | ||
13 | Value type: <prop-encoded-array> | ||
14 | Definition: Register ranges as listed in the reg-names property | ||
15 | |||
16 | - reg-names: | ||
17 | Usage: required | ||
18 | Value type: <stringlist> | ||
19 | Definition: Must include the following entries | ||
20 | - "parf" Qualcomm specific registers | ||
21 | - "dbi" Designware PCIe registers | ||
22 | - "elbi" External local bus interface registers | ||
23 | - "config" PCIe configuration space | ||
24 | |||
25 | - device_type: | ||
26 | Usage: required | ||
27 | Value type: <string> | ||
28 | Definition: Should be "pci". As specified in designware-pcie.txt | ||
29 | |||
30 | - #address-cells: | ||
31 | Usage: required | ||
32 | Value type: <u32> | ||
33 | Definition: Should be 3. As specified in designware-pcie.txt | ||
34 | |||
35 | - #size-cells: | ||
36 | Usage: required | ||
37 | Value type: <u32> | ||
38 | Definition: Should be 2. As specified in designware-pcie.txt | ||
39 | |||
40 | - ranges: | ||
41 | Usage: required | ||
42 | Value type: <prop-encoded-array> | ||
43 | Definition: As specified in designware-pcie.txt | ||
44 | |||
45 | - interrupts: | ||
46 | Usage: required | ||
47 | Value type: <prop-encoded-array> | ||
48 | Definition: MSI interrupt | ||
49 | |||
50 | - interrupt-names: | ||
51 | Usage: required | ||
52 | Value type: <stringlist> | ||
53 | Definition: Should contain "msi" | ||
54 | |||
55 | - #interrupt-cells: | ||
56 | Usage: required | ||
57 | Value type: <u32> | ||
58 | Definition: Should be 1. As specified in designware-pcie.txt | ||
59 | |||
60 | - interrupt-map-mask: | ||
61 | Usage: required | ||
62 | Value type: <prop-encoded-array> | ||
63 | Definition: As specified in designware-pcie.txt | ||
64 | |||
65 | - interrupt-map: | ||
66 | Usage: required | ||
67 | Value type: <prop-encoded-array> | ||
68 | Definition: As specified in designware-pcie.txt | ||
69 | |||
70 | - clocks: | ||
71 | Usage: required | ||
72 | Value type: <prop-encoded-array> | ||
73 | Definition: List of phandle and clock specifier pairs as listed | ||
74 | in clock-names property | ||
75 | |||
76 | - clock-names: | ||
77 | Usage: required | ||
78 | Value type: <stringlist> | ||
79 | Definition: Should contain the following entries | ||
80 | - "iface" Configuration AHB clock | ||
81 | |||
82 | - clock-names: | ||
83 | Usage: required for ipq/apq8064 | ||
84 | Value type: <stringlist> | ||
85 | Definition: Should contain the following entries | ||
86 | - "core" Clocks the pcie hw block | ||
87 | - "phy" Clocks the pcie PHY block | ||
88 | - clock-names: | ||
89 | Usage: required for apq8084 | ||
90 | Value type: <stringlist> | ||
91 | Definition: Should contain the following entries | ||
92 | - "aux" Auxiliary (AUX) clock | ||
93 | - "bus_master" Master AXI clock | ||
94 | - "bus_slave" Slave AXI clock | ||
95 | - resets: | ||
96 | Usage: required | ||
97 | Value type: <prop-encoded-array> | ||
98 | Definition: List of phandle and reset specifier pairs as listed | ||
99 | in reset-names property | ||
100 | |||
101 | - reset-names: | ||
102 | Usage: required for ipq/apq8064 | ||
103 | Value type: <stringlist> | ||
104 | Definition: Should contain the following entries | ||
105 | - "axi" AXI reset | ||
106 | - "ahb" AHB reset | ||
107 | - "por" POR reset | ||
108 | - "pci" PCI reset | ||
109 | - "phy" PHY reset | ||
110 | |||
111 | - reset-names: | ||
112 | Usage: required for apq8084 | ||
113 | Value type: <stringlist> | ||
114 | Definition: Should contain the following entries | ||
115 | - "core" Core reset | ||
116 | |||
117 | - power-domains: | ||
118 | Usage: required for apq8084 | ||
119 | Value type: <prop-encoded-array> | ||
120 | Definition: A phandle and power domain specifier pair to the | ||
121 | power domain which is responsible for collapsing | ||
122 | and restoring power to the peripheral | ||
123 | |||
124 | - vdda-supply: | ||
125 | Usage: required | ||
126 | Value type: <phandle> | ||
127 | Definition: A phandle to the core analog power supply | ||
128 | |||
129 | - vdda_phy-supply: | ||
130 | Usage: required for ipq/apq8064 | ||
131 | Value type: <phandle> | ||
132 | Definition: A phandle to the analog power supply for PHY | ||
133 | |||
134 | - vdda_refclk-supply: | ||
135 | Usage: required for ipq/apq8064 | ||
136 | Value type: <phandle> | ||
137 | Definition: A phandle to the analog power supply for IC which generates | ||
138 | reference clock | ||
139 | |||
140 | - phys: | ||
141 | Usage: required for apq8084 | ||
142 | Value type: <phandle> | ||
143 | Definition: List of phandle(s) as listed in phy-names property | ||
144 | |||
145 | - phy-names: | ||
146 | Usage: required for apq8084 | ||
147 | Value type: <stringlist> | ||
148 | Definition: Should contain "pciephy" | ||
149 | |||
150 | - <name>-gpios: | ||
151 | Usage: optional | ||
152 | Value type: <prop-encoded-array> | ||
153 | Definition: List of phandle and gpio specifier pairs. Should contain | ||
154 | - "perst-gpios" PCIe endpoint reset signal line | ||
155 | - "wake-gpios" PCIe endpoint wake signal line | ||
156 | |||
157 | * Example for ipq/apq8064 | ||
158 | pcie@1b500000 { | ||
159 | compatible = "qcom,pcie-apq8064", "qcom,pcie-ipq8064", "snps,dw-pcie"; | ||
160 | reg = <0x1b500000 0x1000 | ||
161 | 0x1b502000 0x80 | ||
162 | 0x1b600000 0x100 | ||
163 | 0x0ff00000 0x100000>; | ||
164 | reg-names = "dbi", "elbi", "parf", "config"; | ||
165 | device_type = "pci"; | ||
166 | linux,pci-domain = <0>; | ||
167 | bus-range = <0x00 0xff>; | ||
168 | num-lanes = <1>; | ||
169 | #address-cells = <3>; | ||
170 | #size-cells = <2>; | ||
171 | ranges = <0x81000000 0 0 0x0fe00000 0 0x00100000 /* I/O */ | ||
172 | 0x82000000 0 0 0x08000000 0 0x07e00000>; /* memory */ | ||
173 | interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>; | ||
174 | interrupt-names = "msi"; | ||
175 | #interrupt-cells = <1>; | ||
176 | interrupt-map-mask = <0 0 0 0x7>; | ||
177 | interrupt-map = <0 0 0 1 &intc 0 36 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ | ||
178 | <0 0 0 2 &intc 0 37 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ | ||
179 | <0 0 0 3 &intc 0 38 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ | ||
180 | <0 0 0 4 &intc 0 39 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ | ||
181 | clocks = <&gcc PCIE_A_CLK>, | ||
182 | <&gcc PCIE_H_CLK>, | ||
183 | <&gcc PCIE_PHY_CLK>; | ||
184 | clock-names = "core", "iface", "phy"; | ||
185 | resets = <&gcc PCIE_ACLK_RESET>, | ||
186 | <&gcc PCIE_HCLK_RESET>, | ||
187 | <&gcc PCIE_POR_RESET>, | ||
188 | <&gcc PCIE_PCI_RESET>, | ||
189 | <&gcc PCIE_PHY_RESET>; | ||
190 | reset-names = "axi", "ahb", "por", "pci", "phy"; | ||
191 | pinctrl-0 = <&pcie_pins_default>; | ||
192 | pinctrl-names = "default"; | ||
193 | }; | ||
194 | |||
195 | * Example for apq8084 | ||
196 | pcie0@fc520000 { | ||
197 | compatible = "qcom,pcie-apq8084", "snps,dw-pcie"; | ||
198 | reg = <0xfc520000 0x2000>, | ||
199 | <0xff000000 0x1000>, | ||
200 | <0xff001000 0x1000>, | ||
201 | <0xff002000 0x2000>; | ||
202 | reg-names = "parf", "dbi", "elbi", "config"; | ||
203 | device_type = "pci"; | ||
204 | linux,pci-domain = <0>; | ||
205 | bus-range = <0x00 0xff>; | ||
206 | num-lanes = <1>; | ||
207 | #address-cells = <3>; | ||
208 | #size-cells = <2>; | ||
209 | ranges = <0x81000000 0 0 0xff200000 0 0x00100000 /* I/O */ | ||
210 | 0x82000000 0 0x00300000 0xff300000 0 0x00d00000>; /* memory */ | ||
211 | interrupts = <GIC_SPI 243 IRQ_TYPE_NONE>; | ||
212 | interrupt-names = "msi"; | ||
213 | #interrupt-cells = <1>; | ||
214 | interrupt-map-mask = <0 0 0 0x7>; | ||
215 | interrupt-map = <0 0 0 1 &intc 0 244 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ | ||
216 | <0 0 0 2 &intc 0 245 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ | ||
217 | <0 0 0 3 &intc 0 247 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ | ||
218 | <0 0 0 4 &intc 0 248 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ | ||
219 | clocks = <&gcc GCC_PCIE_0_CFG_AHB_CLK>, | ||
220 | <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, | ||
221 | <&gcc GCC_PCIE_0_SLV_AXI_CLK>, | ||
222 | <&gcc GCC_PCIE_0_AUX_CLK>; | ||
223 | clock-names = "iface", "master_bus", "slave_bus", "aux"; | ||
224 | resets = <&gcc GCC_PCIE_0_BCR>; | ||
225 | reset-names = "core"; | ||
226 | power-domains = <&gcc PCIE0_GDSC>; | ||
227 | vdda-supply = <&pma8084_l3>; | ||
228 | phys = <&pciephy0>; | ||
229 | phy-names = "pciephy"; | ||
230 | perst-gpio = <&tlmm 70 GPIO_ACTIVE_LOW>; | ||
231 | pinctrl-0 = <&pcie0_pins_default>; | ||
232 | pinctrl-names = "default"; | ||
233 | }; | ||
diff --git a/Documentation/devicetree/bindings/pci/rcar-pci.txt b/Documentation/devicetree/bindings/pci/rcar-pci.txt index 29d3b989d3b0..558fe528ae19 100644 --- a/Documentation/devicetree/bindings/pci/rcar-pci.txt +++ b/Documentation/devicetree/bindings/pci/rcar-pci.txt | |||
@@ -1,8 +1,16 @@ | |||
1 | * Renesas RCar PCIe interface | 1 | * Renesas RCar PCIe interface |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: should contain one of the following | 4 | compatible: "renesas,pcie-r8a7779" for the R8A7779 SoC; |
5 | "renesas,pcie-r8a7779", "renesas,pcie-r8a7790", "renesas,pcie-r8a7791" | 5 | "renesas,pcie-r8a7790" for the R8A7790 SoC; |
6 | "renesas,pcie-r8a7791" for the R8A7791 SoC; | ||
7 | "renesas,pcie-r8a7795" for the R8A7795 SoC; | ||
8 | "renesas,pcie-rcar-gen2" for a generic R-Car Gen2 compatible device. | ||
9 | |||
10 | When compatible with the generic version, nodes must list the | ||
11 | SoC-specific version corresponding to the platform first | ||
12 | followed by the generic version. | ||
13 | |||
6 | - reg: base address and length of the pcie controller registers. | 14 | - reg: base address and length of the pcie controller registers. |
7 | - #address-cells: set to <3> | 15 | - #address-cells: set to <3> |
8 | - #size-cells: set to <2> | 16 | - #size-cells: set to <2> |
@@ -25,7 +33,7 @@ Example: | |||
25 | SoC specific DT Entry: | 33 | SoC specific DT Entry: |
26 | 34 | ||
27 | pcie: pcie@fe000000 { | 35 | pcie: pcie@fe000000 { |
28 | compatible = "renesas,pcie-r8a7791"; | 36 | compatible = "renesas,pcie-r8a7791", "renesas,pcie-rcar-gen2"; |
29 | reg = <0 0xfe000000 0 0x80000>; | 37 | reg = <0 0xfe000000 0 0x80000>; |
30 | #address-cells = <3>; | 38 | #address-cells = <3>; |
31 | #size-cells = <2>; | 39 | #size-cells = <2>; |
diff --git a/MAINTAINERS b/MAINTAINERS index 293874ca4d4e..84e08e626e10 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -8317,6 +8317,12 @@ S: Maintained | |||
8317 | F: Documentation/devicetree/bindings/pci/host-generic-pci.txt | 8317 | F: Documentation/devicetree/bindings/pci/host-generic-pci.txt |
8318 | F: drivers/pci/host/pci-host-generic.c | 8318 | F: drivers/pci/host/pci-host-generic.c |
8319 | 8319 | ||
8320 | PCI DRIVER FOR INTEL VOLUME MANAGEMENT DEVICE (VMD) | ||
8321 | M: Keith Busch <keith.busch@intel.com> | ||
8322 | L: linux-pci@vger.kernel.org | ||
8323 | S: Supported | ||
8324 | F: arch/x86/pci/vmd.c | ||
8325 | |||
8320 | PCIE DRIVER FOR ST SPEAR13XX | 8326 | PCIE DRIVER FOR ST SPEAR13XX |
8321 | M: Pratyush Anand <pratyush.anand@gmail.com> | 8327 | M: Pratyush Anand <pratyush.anand@gmail.com> |
8322 | L: linux-pci@vger.kernel.org | 8328 | L: linux-pci@vger.kernel.org |
@@ -8341,11 +8347,19 @@ F: drivers/pci/host/pci-xgene-msi.c | |||
8341 | 8347 | ||
8342 | PCIE DRIVER FOR HISILICON | 8348 | PCIE DRIVER FOR HISILICON |
8343 | M: Zhou Wang <wangzhou1@hisilicon.com> | 8349 | M: Zhou Wang <wangzhou1@hisilicon.com> |
8350 | M: Gabriele Paoloni <gabriele.paoloni@huawei.com> | ||
8344 | L: linux-pci@vger.kernel.org | 8351 | L: linux-pci@vger.kernel.org |
8345 | S: Maintained | 8352 | S: Maintained |
8346 | F: Documentation/devicetree/bindings/pci/hisilicon-pcie.txt | 8353 | F: Documentation/devicetree/bindings/pci/hisilicon-pcie.txt |
8347 | F: drivers/pci/host/pcie-hisi.c | 8354 | F: drivers/pci/host/pcie-hisi.c |
8348 | 8355 | ||
8356 | PCIE DRIVER FOR QUALCOMM MSM | ||
8357 | M: Stanimir Varbanov <svarbanov@mm-sol.com> | ||
8358 | L: linux-pci@vger.kernel.org | ||
8359 | L: linux-arm-msm@vger.kernel.org | ||
8360 | S: Maintained | ||
8361 | F: drivers/pci/host/*qcom* | ||
8362 | |||
8349 | PCMCIA SUBSYSTEM | 8363 | PCMCIA SUBSYSTEM |
8350 | P: Linux PCMCIA Team | 8364 | P: Linux PCMCIA Team |
8351 | L: linux-pcmcia@lists.infradead.org | 8365 | L: linux-pcmcia@lists.infradead.org |
diff --git a/arch/arm/boot/dts/qcom-apq8064-ifc6410.dts b/arch/arm/boot/dts/qcom-apq8064-ifc6410.dts index aa9303b84d67..fd4d49ef9ef2 100644 --- a/arch/arm/boot/dts/qcom-apq8064-ifc6410.dts +++ b/arch/arm/boot/dts/qcom-apq8064-ifc6410.dts | |||
@@ -47,6 +47,18 @@ | |||
47 | bias-disable; | 47 | bias-disable; |
48 | }; | 48 | }; |
49 | }; | 49 | }; |
50 | |||
51 | pcie_pins: pcie_pinmux { | ||
52 | mux { | ||
53 | pins = "gpio27"; | ||
54 | function = "gpio"; | ||
55 | }; | ||
56 | conf { | ||
57 | pins = "gpio27"; | ||
58 | drive-strength = <12>; | ||
59 | bias-disable; | ||
60 | }; | ||
61 | }; | ||
50 | }; | 62 | }; |
51 | 63 | ||
52 | rpm@108000 { | 64 | rpm@108000 { |
@@ -123,6 +135,10 @@ | |||
123 | lvs1 { | 135 | lvs1 { |
124 | bias-pull-down; | 136 | bias-pull-down; |
125 | }; | 137 | }; |
138 | |||
139 | lvs6 { | ||
140 | bias-pull-down; | ||
141 | }; | ||
126 | }; | 142 | }; |
127 | }; | 143 | }; |
128 | 144 | ||
@@ -231,6 +247,16 @@ | |||
231 | status = "okay"; | 247 | status = "okay"; |
232 | }; | 248 | }; |
233 | 249 | ||
250 | pci@1b500000 { | ||
251 | status = "ok"; | ||
252 | vdda-supply = <&pm8921_s3>; | ||
253 | vdda_phy-supply = <&pm8921_lvs6>; | ||
254 | vdda_refclk-supply = <&ext_3p3v>; | ||
255 | pinctrl-0 = <&pcie_pins>; | ||
256 | pinctrl-names = "default"; | ||
257 | perst-gpio = <&tlmm_pinmux 27 GPIO_ACTIVE_LOW>; | ||
258 | }; | ||
259 | |||
234 | qcom,ssbi@500000 { | 260 | qcom,ssbi@500000 { |
235 | pmic@0 { | 261 | pmic@0 { |
236 | gpio@150 { | 262 | gpio@150 { |
diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi index edfc6ee56ea1..ed521e85e208 100644 --- a/arch/arm/boot/dts/qcom-apq8064.dtsi +++ b/arch/arm/boot/dts/qcom-apq8064.dtsi | |||
@@ -785,5 +785,41 @@ | |||
785 | compatible = "qcom,tcsr-apq8064", "syscon"; | 785 | compatible = "qcom,tcsr-apq8064", "syscon"; |
786 | reg = <0x1a400000 0x100>; | 786 | reg = <0x1a400000 0x100>; |
787 | }; | 787 | }; |
788 | |||
789 | pcie: pci@1b500000 { | ||
790 | compatible = "qcom,pcie-apq8064", "snps,dw-pcie"; | ||
791 | reg = <0x1b500000 0x1000 | ||
792 | 0x1b502000 0x80 | ||
793 | 0x1b600000 0x100 | ||
794 | 0x0ff00000 0x100000>; | ||
795 | reg-names = "dbi", "elbi", "parf", "config"; | ||
796 | device_type = "pci"; | ||
797 | linux,pci-domain = <0>; | ||
798 | bus-range = <0x00 0xff>; | ||
799 | num-lanes = <1>; | ||
800 | #address-cells = <3>; | ||
801 | #size-cells = <2>; | ||
802 | ranges = <0x81000000 0 0 0x0fe00000 0 0x00100000 /* I/O */ | ||
803 | 0x82000000 0 0 0x08000000 0 0x07e00000>; /* memory */ | ||
804 | interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>; | ||
805 | interrupt-names = "msi"; | ||
806 | #interrupt-cells = <1>; | ||
807 | interrupt-map-mask = <0 0 0 0x7>; | ||
808 | interrupt-map = <0 0 0 1 &intc 0 36 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ | ||
809 | <0 0 0 2 &intc 0 37 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ | ||
810 | <0 0 0 3 &intc 0 38 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ | ||
811 | <0 0 0 4 &intc 0 39 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ | ||
812 | clocks = <&gcc PCIE_A_CLK>, | ||
813 | <&gcc PCIE_H_CLK>, | ||
814 | <&gcc PCIE_PHY_REF_CLK>; | ||
815 | clock-names = "core", "iface", "phy"; | ||
816 | resets = <&gcc PCIE_ACLK_RESET>, | ||
817 | <&gcc PCIE_HCLK_RESET>, | ||
818 | <&gcc PCIE_POR_RESET>, | ||
819 | <&gcc PCIE_PCI_RESET>, | ||
820 | <&gcc PCIE_PHY_RESET>; | ||
821 | reset-names = "axi", "ahb", "por", "pci", "phy"; | ||
822 | status = "disabled"; | ||
823 | }; | ||
788 | }; | 824 | }; |
789 | }; | 825 | }; |
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c index 8d14feb40f12..938742135ee0 100644 --- a/arch/powerpc/kernel/eeh_driver.c +++ b/arch/powerpc/kernel/eeh_driver.c | |||
@@ -400,7 +400,7 @@ static void *eeh_rmv_device(void *data, void *userdata) | |||
400 | * support EEH. So we just care about PCI devices for | 400 | * support EEH. So we just care about PCI devices for |
401 | * simplicity here. | 401 | * simplicity here. |
402 | */ | 402 | */ |
403 | if (!dev || (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) | 403 | if (!dev || (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) |
404 | return NULL; | 404 | return NULL; |
405 | 405 | ||
406 | /* | 406 | /* |
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 2e710c15893f..526ac6750e4d 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c | |||
@@ -187,9 +187,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, | |||
187 | 187 | ||
188 | pci_device_add(dev, bus); | 188 | pci_device_add(dev, bus); |
189 | 189 | ||
190 | /* Setup MSI caps & disable MSI/MSI-X interrupts */ | ||
191 | pci_msi_setup_pci_dev(dev); | ||
192 | |||
193 | return dev; | 190 | return dev; |
194 | } | 191 | } |
195 | EXPORT_SYMBOL(of_create_pci_dev); | 192 | EXPORT_SYMBOL(of_create_pci_dev); |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4a10ba9e95da..9bd3cc03d51d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -2699,6 +2699,19 @@ config PMC_ATOM | |||
2699 | def_bool y | 2699 | def_bool y |
2700 | depends on PCI | 2700 | depends on PCI |
2701 | 2701 | ||
2702 | config VMD | ||
2703 | depends on PCI_MSI | ||
2704 | tristate "Volume Management Device Driver" | ||
2705 | default N | ||
2706 | ---help--- | ||
2707 | Adds support for the Intel Volume Management Device (VMD). VMD is a | ||
2708 | secondary PCI host bridge that allows PCI Express root ports, | ||
2709 | and devices attached to them, to be removed from the default | ||
2710 | PCI domain and placed within the VMD domain. This provides | ||
2711 | more bus resources than are otherwise possible with a | ||
2712 | single domain. If you know your system provides one of these and | ||
2713 | has devices attached to it, say Y; if you are not sure, say N. | ||
2714 | |||
2702 | source "net/Kconfig" | 2715 | source "net/Kconfig" |
2703 | 2716 | ||
2704 | source "drivers/Kconfig" | 2717 | source "drivers/Kconfig" |
diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h index 03dd72957d2f..684ed6c3aa67 100644 --- a/arch/x86/include/asm/device.h +++ b/arch/x86/include/asm/device.h | |||
@@ -10,6 +10,16 @@ struct dev_archdata { | |||
10 | #endif | 10 | #endif |
11 | }; | 11 | }; |
12 | 12 | ||
13 | #if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS) | ||
14 | struct dma_domain { | ||
15 | struct list_head node; | ||
16 | struct dma_map_ops *dma_ops; | ||
17 | int domain_nr; | ||
18 | }; | ||
19 | void add_dma_domain(struct dma_domain *domain); | ||
20 | void del_dma_domain(struct dma_domain *domain); | ||
21 | #endif | ||
22 | |||
13 | struct pdev_archdata { | 23 | struct pdev_archdata { |
14 | }; | 24 | }; |
15 | 25 | ||
diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index 1e3408e88604..1815b736269d 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h | |||
@@ -130,6 +130,11 @@ struct irq_alloc_info { | |||
130 | char *uv_name; | 130 | char *uv_name; |
131 | }; | 131 | }; |
132 | #endif | 132 | #endif |
133 | #if IS_ENABLED(CONFIG_VMD) | ||
134 | struct { | ||
135 | struct msi_desc *desc; | ||
136 | }; | ||
137 | #endif | ||
133 | }; | 138 | }; |
134 | }; | 139 | }; |
135 | 140 | ||
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index fa1195dae425..46873fbd44e1 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h | |||
@@ -151,11 +151,11 @@ extern struct list_head pci_mmcfg_list; | |||
151 | #define PCI_MMCFG_BUS_OFFSET(bus) ((bus) << 20) | 151 | #define PCI_MMCFG_BUS_OFFSET(bus) ((bus) << 20) |
152 | 152 | ||
153 | /* | 153 | /* |
154 | * AMD Fam10h CPUs are buggy, and cannot access MMIO config space | 154 | * On AMD Fam10h CPUs, all PCI MMIO configuration space accesses must use |
155 | * on their northbrige except through the * %eax register. As such, you MUST | 155 | * %eax. No other source or target registers may be used. The following |
156 | * NOT use normal IOMEM accesses, you need to only use the magic mmio-config | 156 | * mmio_config_* accessors enforce this. See "BIOS and Kernel Developer's |
157 | * accessor functions. | 157 | * Guide (BKDG) For AMD Family 10h Processors", rev. 3.48, sec 2.11.1, |
158 | * In fact just use pci_config_*, nothing else please. | 158 | * "MMIO Configuration Coding Requirements". |
159 | */ | 159 | */ |
160 | static inline unsigned char mmio_config_readb(void __iomem *pos) | 160 | static inline unsigned char mmio_config_readb(void __iomem *pos) |
161 | { | 161 | { |
diff --git a/arch/x86/pci/Makefile b/arch/x86/pci/Makefile index 5c6fc3577a49..97062a635b77 100644 --- a/arch/x86/pci/Makefile +++ b/arch/x86/pci/Makefile | |||
@@ -23,6 +23,8 @@ obj-y += bus_numa.o | |||
23 | obj-$(CONFIG_AMD_NB) += amd_bus.o | 23 | obj-$(CONFIG_AMD_NB) += amd_bus.o |
24 | obj-$(CONFIG_PCI_CNB20LE_QUIRK) += broadcom_bus.o | 24 | obj-$(CONFIG_PCI_CNB20LE_QUIRK) += broadcom_bus.o |
25 | 25 | ||
26 | obj-$(CONFIG_VMD) += vmd.o | ||
27 | |||
26 | ifeq ($(CONFIG_PCI_DEBUG),y) | 28 | ifeq ($(CONFIG_PCI_DEBUG),y) |
27 | EXTRA_CFLAGS += -DDEBUG | 29 | EXTRA_CFLAGS += -DDEBUG |
28 | endif | 30 | endif |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index eccd4d99e6a4..2879efc73a96 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -641,6 +641,43 @@ unsigned int pcibios_assign_all_busses(void) | |||
641 | return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; | 641 | return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; |
642 | } | 642 | } |
643 | 643 | ||
644 | #if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS) | ||
645 | static LIST_HEAD(dma_domain_list); | ||
646 | static DEFINE_SPINLOCK(dma_domain_list_lock); | ||
647 | |||
648 | void add_dma_domain(struct dma_domain *domain) | ||
649 | { | ||
650 | spin_lock(&dma_domain_list_lock); | ||
651 | list_add(&domain->node, &dma_domain_list); | ||
652 | spin_unlock(&dma_domain_list_lock); | ||
653 | } | ||
654 | EXPORT_SYMBOL_GPL(add_dma_domain); | ||
655 | |||
656 | void del_dma_domain(struct dma_domain *domain) | ||
657 | { | ||
658 | spin_lock(&dma_domain_list_lock); | ||
659 | list_del(&domain->node); | ||
660 | spin_unlock(&dma_domain_list_lock); | ||
661 | } | ||
662 | EXPORT_SYMBOL_GPL(del_dma_domain); | ||
663 | |||
664 | static void set_dma_domain_ops(struct pci_dev *pdev) | ||
665 | { | ||
666 | struct dma_domain *domain; | ||
667 | |||
668 | spin_lock(&dma_domain_list_lock); | ||
669 | list_for_each_entry(domain, &dma_domain_list, node) { | ||
670 | if (pci_domain_nr(pdev->bus) == domain->domain_nr) { | ||
671 | pdev->dev.archdata.dma_ops = domain->dma_ops; | ||
672 | break; | ||
673 | } | ||
674 | } | ||
675 | spin_unlock(&dma_domain_list_lock); | ||
676 | } | ||
677 | #else | ||
678 | static void set_dma_domain_ops(struct pci_dev *pdev) {} | ||
679 | #endif | ||
680 | |||
644 | int pcibios_add_device(struct pci_dev *dev) | 681 | int pcibios_add_device(struct pci_dev *dev) |
645 | { | 682 | { |
646 | struct setup_data *data; | 683 | struct setup_data *data; |
@@ -670,6 +707,7 @@ int pcibios_add_device(struct pci_dev *dev) | |||
670 | pa_data = data->next; | 707 | pa_data = data->next; |
671 | iounmap(data); | 708 | iounmap(data); |
672 | } | 709 | } |
710 | set_dma_domain_ops(dev); | ||
673 | return 0; | 711 | return 0; |
674 | } | 712 | } |
675 | 713 | ||
diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c index 9b83b9051ae7..9770e55e768f 100644 --- a/arch/x86/pci/pcbios.c +++ b/arch/x86/pci/pcbios.c | |||
@@ -180,6 +180,7 @@ static int pci_bios_read(unsigned int seg, unsigned int bus, | |||
180 | unsigned long result = 0; | 180 | unsigned long result = 0; |
181 | unsigned long flags; | 181 | unsigned long flags; |
182 | unsigned long bx = (bus << 8) | devfn; | 182 | unsigned long bx = (bus << 8) | devfn; |
183 | u16 number = 0, mask = 0; | ||
183 | 184 | ||
184 | WARN_ON(seg); | 185 | WARN_ON(seg); |
185 | if (!value || (bus > 255) || (devfn > 255) || (reg > 255)) | 186 | if (!value || (bus > 255) || (devfn > 255) || (reg > 255)) |
@@ -189,53 +190,35 @@ static int pci_bios_read(unsigned int seg, unsigned int bus, | |||
189 | 190 | ||
190 | switch (len) { | 191 | switch (len) { |
191 | case 1: | 192 | case 1: |
192 | __asm__("lcall *(%%esi); cld\n\t" | 193 | number = PCIBIOS_READ_CONFIG_BYTE; |
193 | "jc 1f\n\t" | 194 | mask = 0xff; |
194 | "xor %%ah, %%ah\n" | ||
195 | "1:" | ||
196 | : "=c" (*value), | ||
197 | "=a" (result) | ||
198 | : "1" (PCIBIOS_READ_CONFIG_BYTE), | ||
199 | "b" (bx), | ||
200 | "D" ((long)reg), | ||
201 | "S" (&pci_indirect)); | ||
202 | /* | ||
203 | * Zero-extend the result beyond 8 bits, do not trust the | ||
204 | * BIOS having done it: | ||
205 | */ | ||
206 | *value &= 0xff; | ||
207 | break; | 195 | break; |
208 | case 2: | 196 | case 2: |
209 | __asm__("lcall *(%%esi); cld\n\t" | 197 | number = PCIBIOS_READ_CONFIG_WORD; |
210 | "jc 1f\n\t" | 198 | mask = 0xffff; |
211 | "xor %%ah, %%ah\n" | ||
212 | "1:" | ||
213 | : "=c" (*value), | ||
214 | "=a" (result) | ||
215 | : "1" (PCIBIOS_READ_CONFIG_WORD), | ||
216 | "b" (bx), | ||
217 | "D" ((long)reg), | ||
218 | "S" (&pci_indirect)); | ||
219 | /* | ||
220 | * Zero-extend the result beyond 16 bits, do not trust the | ||
221 | * BIOS having done it: | ||
222 | */ | ||
223 | *value &= 0xffff; | ||
224 | break; | 199 | break; |
225 | case 4: | 200 | case 4: |
226 | __asm__("lcall *(%%esi); cld\n\t" | 201 | number = PCIBIOS_READ_CONFIG_DWORD; |
227 | "jc 1f\n\t" | ||
228 | "xor %%ah, %%ah\n" | ||
229 | "1:" | ||
230 | : "=c" (*value), | ||
231 | "=a" (result) | ||
232 | : "1" (PCIBIOS_READ_CONFIG_DWORD), | ||
233 | "b" (bx), | ||
234 | "D" ((long)reg), | ||
235 | "S" (&pci_indirect)); | ||
236 | break; | 202 | break; |
237 | } | 203 | } |
238 | 204 | ||
205 | __asm__("lcall *(%%esi); cld\n\t" | ||
206 | "jc 1f\n\t" | ||
207 | "xor %%ah, %%ah\n" | ||
208 | "1:" | ||
209 | : "=c" (*value), | ||
210 | "=a" (result) | ||
211 | : "1" (number), | ||
212 | "b" (bx), | ||
213 | "D" ((long)reg), | ||
214 | "S" (&pci_indirect)); | ||
215 | /* | ||
216 | * Zero-extend the result beyond 8 or 16 bits, do not trust the | ||
217 | * BIOS having done it: | ||
218 | */ | ||
219 | if (mask) | ||
220 | *value &= mask; | ||
221 | |||
239 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); | 222 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); |
240 | 223 | ||
241 | return (int)((result & 0xff00) >> 8); | 224 | return (int)((result & 0xff00) >> 8); |
@@ -247,6 +230,7 @@ static int pci_bios_write(unsigned int seg, unsigned int bus, | |||
247 | unsigned long result = 0; | 230 | unsigned long result = 0; |
248 | unsigned long flags; | 231 | unsigned long flags; |
249 | unsigned long bx = (bus << 8) | devfn; | 232 | unsigned long bx = (bus << 8) | devfn; |
233 | u16 number = 0; | ||
250 | 234 | ||
251 | WARN_ON(seg); | 235 | WARN_ON(seg); |
252 | if ((bus > 255) || (devfn > 255) || (reg > 255)) | 236 | if ((bus > 255) || (devfn > 255) || (reg > 255)) |
@@ -256,43 +240,27 @@ static int pci_bios_write(unsigned int seg, unsigned int bus, | |||
256 | 240 | ||
257 | switch (len) { | 241 | switch (len) { |
258 | case 1: | 242 | case 1: |
259 | __asm__("lcall *(%%esi); cld\n\t" | 243 | number = PCIBIOS_WRITE_CONFIG_BYTE; |
260 | "jc 1f\n\t" | ||
261 | "xor %%ah, %%ah\n" | ||
262 | "1:" | ||
263 | : "=a" (result) | ||
264 | : "0" (PCIBIOS_WRITE_CONFIG_BYTE), | ||
265 | "c" (value), | ||
266 | "b" (bx), | ||
267 | "D" ((long)reg), | ||
268 | "S" (&pci_indirect)); | ||
269 | break; | 244 | break; |
270 | case 2: | 245 | case 2: |
271 | __asm__("lcall *(%%esi); cld\n\t" | 246 | number = PCIBIOS_WRITE_CONFIG_WORD; |
272 | "jc 1f\n\t" | ||
273 | "xor %%ah, %%ah\n" | ||
274 | "1:" | ||
275 | : "=a" (result) | ||
276 | : "0" (PCIBIOS_WRITE_CONFIG_WORD), | ||
277 | "c" (value), | ||
278 | "b" (bx), | ||
279 | "D" ((long)reg), | ||
280 | "S" (&pci_indirect)); | ||
281 | break; | 247 | break; |
282 | case 4: | 248 | case 4: |
283 | __asm__("lcall *(%%esi); cld\n\t" | 249 | number = PCIBIOS_WRITE_CONFIG_DWORD; |
284 | "jc 1f\n\t" | ||
285 | "xor %%ah, %%ah\n" | ||
286 | "1:" | ||
287 | : "=a" (result) | ||
288 | : "0" (PCIBIOS_WRITE_CONFIG_DWORD), | ||
289 | "c" (value), | ||
290 | "b" (bx), | ||
291 | "D" ((long)reg), | ||
292 | "S" (&pci_indirect)); | ||
293 | break; | 250 | break; |
294 | } | 251 | } |
295 | 252 | ||
253 | __asm__("lcall *(%%esi); cld\n\t" | ||
254 | "jc 1f\n\t" | ||
255 | "xor %%ah, %%ah\n" | ||
256 | "1:" | ||
257 | : "=a" (result) | ||
258 | : "0" (number), | ||
259 | "c" (value), | ||
260 | "b" (bx), | ||
261 | "D" ((long)reg), | ||
262 | "S" (&pci_indirect)); | ||
263 | |||
296 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); | 264 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); |
297 | 265 | ||
298 | return (int)((result & 0xff00) >> 8); | 266 | return (int)((result & 0xff00) >> 8); |
diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c new file mode 100644 index 000000000000..d57e48016f15 --- /dev/null +++ b/arch/x86/pci/vmd.c | |||
@@ -0,0 +1,723 @@ | |||
1 | /* | ||
2 | * Volume Management Device driver | ||
3 | * Copyright (c) 2015, Intel Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/device.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/irq.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/msi.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/rculist.h> | ||
23 | #include <linux/rcupdate.h> | ||
24 | |||
25 | #include <asm/irqdomain.h> | ||
26 | #include <asm/device.h> | ||
27 | #include <asm/msi.h> | ||
28 | #include <asm/msidef.h> | ||
29 | |||
30 | #define VMD_CFGBAR 0 | ||
31 | #define VMD_MEMBAR1 2 | ||
32 | #define VMD_MEMBAR2 4 | ||
33 | |||
34 | /* | ||
35 | * Lock for manipulating VMD IRQ lists. | ||
36 | */ | ||
37 | static DEFINE_RAW_SPINLOCK(list_lock); | ||
38 | |||
39 | /** | ||
40 | * struct vmd_irq - private data to map driver IRQ to the VMD shared vector | ||
41 | * @node: list item for parent traversal. | ||
42 | * @rcu: RCU callback item for freeing. | ||
43 | * @irq: back pointer to parent. | ||
44 | * @virq: the virtual IRQ value provided to the requesting driver. | ||
45 | * | ||
46 | * Every MSI/MSI-X IRQ requested for a device in a VMD domain will be mapped to | ||
47 | * a VMD IRQ using this structure. | ||
48 | */ | ||
49 | struct vmd_irq { | ||
50 | struct list_head node; | ||
51 | struct rcu_head rcu; | ||
52 | struct vmd_irq_list *irq; | ||
53 | unsigned int virq; | ||
54 | }; | ||
55 | |||
56 | /** | ||
57 | * struct vmd_irq_list - list of driver requested IRQs mapping to a VMD vector | ||
58 | * @irq_list: the list of irq's the VMD one demuxes to. | ||
59 | * @vmd_vector: the h/w IRQ assigned to the VMD. | ||
60 | * @index: index into the VMD MSI-X table; used for message routing. | ||
61 | * @count: number of child IRQs assigned to this vector; used to track | ||
62 | * sharing. | ||
63 | */ | ||
64 | struct vmd_irq_list { | ||
65 | struct list_head irq_list; | ||
66 | struct vmd_dev *vmd; | ||
67 | unsigned int vmd_vector; | ||
68 | unsigned int index; | ||
69 | unsigned int count; | ||
70 | }; | ||
71 | |||
72 | struct vmd_dev { | ||
73 | struct pci_dev *dev; | ||
74 | |||
75 | spinlock_t cfg_lock; | ||
76 | char __iomem *cfgbar; | ||
77 | |||
78 | int msix_count; | ||
79 | struct msix_entry *msix_entries; | ||
80 | struct vmd_irq_list *irqs; | ||
81 | |||
82 | struct pci_sysdata sysdata; | ||
83 | struct resource resources[3]; | ||
84 | struct irq_domain *irq_domain; | ||
85 | struct pci_bus *bus; | ||
86 | |||
87 | #ifdef CONFIG_X86_DEV_DMA_OPS | ||
88 | struct dma_map_ops dma_ops; | ||
89 | struct dma_domain dma_domain; | ||
90 | #endif | ||
91 | }; | ||
92 | |||
93 | static inline struct vmd_dev *vmd_from_bus(struct pci_bus *bus) | ||
94 | { | ||
95 | return container_of(bus->sysdata, struct vmd_dev, sysdata); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * Drivers managing a device in a VMD domain allocate their own IRQs as before, | ||
100 | * but the MSI entry for the hardware it's driving will be programmed with a | ||
101 | * destination ID for the VMD MSI-X table. The VMD muxes interrupts in its | ||
102 | * domain into one of its own, and the VMD driver de-muxes these for the | ||
103 | * handlers sharing that VMD IRQ. The vmd irq_domain provides the operations | ||
104 | * and irq_chip to set this up. | ||
105 | */ | ||
106 | static void vmd_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) | ||
107 | { | ||
108 | struct vmd_irq *vmdirq = data->chip_data; | ||
109 | struct vmd_irq_list *irq = vmdirq->irq; | ||
110 | |||
111 | msg->address_hi = MSI_ADDR_BASE_HI; | ||
112 | msg->address_lo = MSI_ADDR_BASE_LO | MSI_ADDR_DEST_ID(irq->index); | ||
113 | msg->data = 0; | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * We rely on MSI_FLAG_USE_DEF_CHIP_OPS to set the IRQ mask/unmask ops. | ||
118 | */ | ||
119 | static void vmd_irq_enable(struct irq_data *data) | ||
120 | { | ||
121 | struct vmd_irq *vmdirq = data->chip_data; | ||
122 | |||
123 | raw_spin_lock(&list_lock); | ||
124 | list_add_tail_rcu(&vmdirq->node, &vmdirq->irq->irq_list); | ||
125 | raw_spin_unlock(&list_lock); | ||
126 | |||
127 | data->chip->irq_unmask(data); | ||
128 | } | ||
129 | |||
130 | static void vmd_irq_disable(struct irq_data *data) | ||
131 | { | ||
132 | struct vmd_irq *vmdirq = data->chip_data; | ||
133 | |||
134 | data->chip->irq_mask(data); | ||
135 | |||
136 | raw_spin_lock(&list_lock); | ||
137 | list_del_rcu(&vmdirq->node); | ||
138 | raw_spin_unlock(&list_lock); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * XXX: Stubbed until we develop acceptable way to not create conflicts with | ||
143 | * other devices sharing the same vector. | ||
144 | */ | ||
145 | static int vmd_irq_set_affinity(struct irq_data *data, | ||
146 | const struct cpumask *dest, bool force) | ||
147 | { | ||
148 | return -EINVAL; | ||
149 | } | ||
150 | |||
151 | static struct irq_chip vmd_msi_controller = { | ||
152 | .name = "VMD-MSI", | ||
153 | .irq_enable = vmd_irq_enable, | ||
154 | .irq_disable = vmd_irq_disable, | ||
155 | .irq_compose_msi_msg = vmd_compose_msi_msg, | ||
156 | .irq_set_affinity = vmd_irq_set_affinity, | ||
157 | }; | ||
158 | |||
159 | static irq_hw_number_t vmd_get_hwirq(struct msi_domain_info *info, | ||
160 | msi_alloc_info_t *arg) | ||
161 | { | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * XXX: We can be even smarter selecting the best IRQ once we solve the | ||
167 | * affinity problem. | ||
168 | */ | ||
169 | static struct vmd_irq_list *vmd_next_irq(struct vmd_dev *vmd) | ||
170 | { | ||
171 | int i, best = 0; | ||
172 | |||
173 | raw_spin_lock(&list_lock); | ||
174 | for (i = 1; i < vmd->msix_count; i++) | ||
175 | if (vmd->irqs[i].count < vmd->irqs[best].count) | ||
176 | best = i; | ||
177 | vmd->irqs[best].count++; | ||
178 | raw_spin_unlock(&list_lock); | ||
179 | |||
180 | return &vmd->irqs[best]; | ||
181 | } | ||
182 | |||
183 | static int vmd_msi_init(struct irq_domain *domain, struct msi_domain_info *info, | ||
184 | unsigned int virq, irq_hw_number_t hwirq, | ||
185 | msi_alloc_info_t *arg) | ||
186 | { | ||
187 | struct vmd_dev *vmd = vmd_from_bus(msi_desc_to_pci_dev(arg->desc)->bus); | ||
188 | struct vmd_irq *vmdirq = kzalloc(sizeof(*vmdirq), GFP_KERNEL); | ||
189 | |||
190 | if (!vmdirq) | ||
191 | return -ENOMEM; | ||
192 | |||
193 | INIT_LIST_HEAD(&vmdirq->node); | ||
194 | vmdirq->irq = vmd_next_irq(vmd); | ||
195 | vmdirq->virq = virq; | ||
196 | |||
197 | irq_domain_set_info(domain, virq, vmdirq->irq->vmd_vector, info->chip, | ||
198 | vmdirq, handle_simple_irq, vmd, NULL); | ||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | static void vmd_msi_free(struct irq_domain *domain, | ||
203 | struct msi_domain_info *info, unsigned int virq) | ||
204 | { | ||
205 | struct vmd_irq *vmdirq = irq_get_chip_data(virq); | ||
206 | |||
207 | /* XXX: Potential optimization to rebalance */ | ||
208 | raw_spin_lock(&list_lock); | ||
209 | vmdirq->irq->count--; | ||
210 | raw_spin_unlock(&list_lock); | ||
211 | |||
212 | kfree_rcu(vmdirq, rcu); | ||
213 | } | ||
214 | |||
215 | static int vmd_msi_prepare(struct irq_domain *domain, struct device *dev, | ||
216 | int nvec, msi_alloc_info_t *arg) | ||
217 | { | ||
218 | struct pci_dev *pdev = to_pci_dev(dev); | ||
219 | struct vmd_dev *vmd = vmd_from_bus(pdev->bus); | ||
220 | |||
221 | if (nvec > vmd->msix_count) | ||
222 | return vmd->msix_count; | ||
223 | |||
224 | memset(arg, 0, sizeof(*arg)); | ||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | static void vmd_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) | ||
229 | { | ||
230 | arg->desc = desc; | ||
231 | } | ||
232 | |||
233 | static struct msi_domain_ops vmd_msi_domain_ops = { | ||
234 | .get_hwirq = vmd_get_hwirq, | ||
235 | .msi_init = vmd_msi_init, | ||
236 | .msi_free = vmd_msi_free, | ||
237 | .msi_prepare = vmd_msi_prepare, | ||
238 | .set_desc = vmd_set_desc, | ||
239 | }; | ||
240 | |||
241 | static struct msi_domain_info vmd_msi_domain_info = { | ||
242 | .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | | ||
243 | MSI_FLAG_PCI_MSIX, | ||
244 | .ops = &vmd_msi_domain_ops, | ||
245 | .chip = &vmd_msi_controller, | ||
246 | }; | ||
247 | |||
248 | #ifdef CONFIG_X86_DEV_DMA_OPS | ||
249 | /* | ||
250 | * VMD replaces the requester ID with its own. DMA mappings for devices in a | ||
251 | * VMD domain need to be mapped for the VMD, not the device requiring | ||
252 | * the mapping. | ||
253 | */ | ||
254 | static struct device *to_vmd_dev(struct device *dev) | ||
255 | { | ||
256 | struct pci_dev *pdev = to_pci_dev(dev); | ||
257 | struct vmd_dev *vmd = vmd_from_bus(pdev->bus); | ||
258 | |||
259 | return &vmd->dev->dev; | ||
260 | } | ||
261 | |||
262 | static struct dma_map_ops *vmd_dma_ops(struct device *dev) | ||
263 | { | ||
264 | return to_vmd_dev(dev)->archdata.dma_ops; | ||
265 | } | ||
266 | |||
267 | static void *vmd_alloc(struct device *dev, size_t size, dma_addr_t *addr, | ||
268 | gfp_t flag, struct dma_attrs *attrs) | ||
269 | { | ||
270 | return vmd_dma_ops(dev)->alloc(to_vmd_dev(dev), size, addr, flag, | ||
271 | attrs); | ||
272 | } | ||
273 | |||
274 | static void vmd_free(struct device *dev, size_t size, void *vaddr, | ||
275 | dma_addr_t addr, struct dma_attrs *attrs) | ||
276 | { | ||
277 | return vmd_dma_ops(dev)->free(to_vmd_dev(dev), size, vaddr, addr, | ||
278 | attrs); | ||
279 | } | ||
280 | |||
281 | static int vmd_mmap(struct device *dev, struct vm_area_struct *vma, | ||
282 | void *cpu_addr, dma_addr_t addr, size_t size, | ||
283 | struct dma_attrs *attrs) | ||
284 | { | ||
285 | return vmd_dma_ops(dev)->mmap(to_vmd_dev(dev), vma, cpu_addr, addr, | ||
286 | size, attrs); | ||
287 | } | ||
288 | |||
289 | static int vmd_get_sgtable(struct device *dev, struct sg_table *sgt, | ||
290 | void *cpu_addr, dma_addr_t addr, size_t size, | ||
291 | struct dma_attrs *attrs) | ||
292 | { | ||
293 | return vmd_dma_ops(dev)->get_sgtable(to_vmd_dev(dev), sgt, cpu_addr, | ||
294 | addr, size, attrs); | ||
295 | } | ||
296 | |||
297 | static dma_addr_t vmd_map_page(struct device *dev, struct page *page, | ||
298 | unsigned long offset, size_t size, | ||
299 | enum dma_data_direction dir, | ||
300 | struct dma_attrs *attrs) | ||
301 | { | ||
302 | return vmd_dma_ops(dev)->map_page(to_vmd_dev(dev), page, offset, size, | ||
303 | dir, attrs); | ||
304 | } | ||
305 | |||
306 | static void vmd_unmap_page(struct device *dev, dma_addr_t addr, size_t size, | ||
307 | enum dma_data_direction dir, struct dma_attrs *attrs) | ||
308 | { | ||
309 | vmd_dma_ops(dev)->unmap_page(to_vmd_dev(dev), addr, size, dir, attrs); | ||
310 | } | ||
311 | |||
312 | static int vmd_map_sg(struct device *dev, struct scatterlist *sg, int nents, | ||
313 | enum dma_data_direction dir, struct dma_attrs *attrs) | ||
314 | { | ||
315 | return vmd_dma_ops(dev)->map_sg(to_vmd_dev(dev), sg, nents, dir, attrs); | ||
316 | } | ||
317 | |||
318 | static void vmd_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, | ||
319 | enum dma_data_direction dir, struct dma_attrs *attrs) | ||
320 | { | ||
321 | vmd_dma_ops(dev)->unmap_sg(to_vmd_dev(dev), sg, nents, dir, attrs); | ||
322 | } | ||
323 | |||
324 | static void vmd_sync_single_for_cpu(struct device *dev, dma_addr_t addr, | ||
325 | size_t size, enum dma_data_direction dir) | ||
326 | { | ||
327 | vmd_dma_ops(dev)->sync_single_for_cpu(to_vmd_dev(dev), addr, size, dir); | ||
328 | } | ||
329 | |||
330 | static void vmd_sync_single_for_device(struct device *dev, dma_addr_t addr, | ||
331 | size_t size, enum dma_data_direction dir) | ||
332 | { | ||
333 | vmd_dma_ops(dev)->sync_single_for_device(to_vmd_dev(dev), addr, size, | ||
334 | dir); | ||
335 | } | ||
336 | |||
337 | static void vmd_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, | ||
338 | int nents, enum dma_data_direction dir) | ||
339 | { | ||
340 | vmd_dma_ops(dev)->sync_sg_for_cpu(to_vmd_dev(dev), sg, nents, dir); | ||
341 | } | ||
342 | |||
343 | static void vmd_sync_sg_for_device(struct device *dev, struct scatterlist *sg, | ||
344 | int nents, enum dma_data_direction dir) | ||
345 | { | ||
346 | vmd_dma_ops(dev)->sync_sg_for_device(to_vmd_dev(dev), sg, nents, dir); | ||
347 | } | ||
348 | |||
349 | static int vmd_mapping_error(struct device *dev, dma_addr_t addr) | ||
350 | { | ||
351 | return vmd_dma_ops(dev)->mapping_error(to_vmd_dev(dev), addr); | ||
352 | } | ||
353 | |||
354 | static int vmd_dma_supported(struct device *dev, u64 mask) | ||
355 | { | ||
356 | return vmd_dma_ops(dev)->dma_supported(to_vmd_dev(dev), mask); | ||
357 | } | ||
358 | |||
359 | #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK | ||
360 | static u64 vmd_get_required_mask(struct device *dev) | ||
361 | { | ||
362 | return vmd_dma_ops(dev)->get_required_mask(to_vmd_dev(dev)); | ||
363 | } | ||
364 | #endif | ||
365 | |||
366 | static void vmd_teardown_dma_ops(struct vmd_dev *vmd) | ||
367 | { | ||
368 | struct dma_domain *domain = &vmd->dma_domain; | ||
369 | |||
370 | if (vmd->dev->dev.archdata.dma_ops) | ||
371 | del_dma_domain(domain); | ||
372 | } | ||
373 | |||
374 | #define ASSIGN_VMD_DMA_OPS(source, dest, fn) \ | ||
375 | do { \ | ||
376 | if (source->fn) \ | ||
377 | dest->fn = vmd_##fn; \ | ||
378 | } while (0) | ||
379 | |||
380 | static void vmd_setup_dma_ops(struct vmd_dev *vmd) | ||
381 | { | ||
382 | const struct dma_map_ops *source = vmd->dev->dev.archdata.dma_ops; | ||
383 | struct dma_map_ops *dest = &vmd->dma_ops; | ||
384 | struct dma_domain *domain = &vmd->dma_domain; | ||
385 | |||
386 | domain->domain_nr = vmd->sysdata.domain; | ||
387 | domain->dma_ops = dest; | ||
388 | |||
389 | if (!source) | ||
390 | return; | ||
391 | ASSIGN_VMD_DMA_OPS(source, dest, alloc); | ||
392 | ASSIGN_VMD_DMA_OPS(source, dest, free); | ||
393 | ASSIGN_VMD_DMA_OPS(source, dest, mmap); | ||
394 | ASSIGN_VMD_DMA_OPS(source, dest, get_sgtable); | ||
395 | ASSIGN_VMD_DMA_OPS(source, dest, map_page); | ||
396 | ASSIGN_VMD_DMA_OPS(source, dest, unmap_page); | ||
397 | ASSIGN_VMD_DMA_OPS(source, dest, map_sg); | ||
398 | ASSIGN_VMD_DMA_OPS(source, dest, unmap_sg); | ||
399 | ASSIGN_VMD_DMA_OPS(source, dest, sync_single_for_cpu); | ||
400 | ASSIGN_VMD_DMA_OPS(source, dest, sync_single_for_device); | ||
401 | ASSIGN_VMD_DMA_OPS(source, dest, sync_sg_for_cpu); | ||
402 | ASSIGN_VMD_DMA_OPS(source, dest, sync_sg_for_device); | ||
403 | ASSIGN_VMD_DMA_OPS(source, dest, mapping_error); | ||
404 | ASSIGN_VMD_DMA_OPS(source, dest, dma_supported); | ||
405 | #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK | ||
406 | ASSIGN_VMD_DMA_OPS(source, dest, get_required_mask); | ||
407 | #endif | ||
408 | add_dma_domain(domain); | ||
409 | } | ||
410 | #undef ASSIGN_VMD_DMA_OPS | ||
411 | #else | ||
412 | static void vmd_teardown_dma_ops(struct vmd_dev *vmd) {} | ||
413 | static void vmd_setup_dma_ops(struct vmd_dev *vmd) {} | ||
414 | #endif | ||
415 | |||
416 | static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus, | ||
417 | unsigned int devfn, int reg, int len) | ||
418 | { | ||
419 | char __iomem *addr = vmd->cfgbar + | ||
420 | (bus->number << 20) + (devfn << 12) + reg; | ||
421 | |||
422 | if ((addr - vmd->cfgbar) + len >= | ||
423 | resource_size(&vmd->dev->resource[VMD_CFGBAR])) | ||
424 | return NULL; | ||
425 | |||
426 | return addr; | ||
427 | } | ||
428 | |||
429 | /* | ||
430 | * CPU may deadlock if config space is not serialized on some versions of this | ||
431 | * hardware, so all config space access is done under a spinlock. | ||
432 | */ | ||
433 | static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg, | ||
434 | int len, u32 *value) | ||
435 | { | ||
436 | struct vmd_dev *vmd = vmd_from_bus(bus); | ||
437 | char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len); | ||
438 | unsigned long flags; | ||
439 | int ret = 0; | ||
440 | |||
441 | if (!addr) | ||
442 | return -EFAULT; | ||
443 | |||
444 | spin_lock_irqsave(&vmd->cfg_lock, flags); | ||
445 | switch (len) { | ||
446 | case 1: | ||
447 | *value = readb(addr); | ||
448 | break; | ||
449 | case 2: | ||
450 | *value = readw(addr); | ||
451 | break; | ||
452 | case 4: | ||
453 | *value = readl(addr); | ||
454 | break; | ||
455 | default: | ||
456 | ret = -EINVAL; | ||
457 | break; | ||
458 | } | ||
459 | spin_unlock_irqrestore(&vmd->cfg_lock, flags); | ||
460 | return ret; | ||
461 | } | ||
462 | |||
463 | /* | ||
464 | * VMD h/w converts non-posted config writes to posted memory writes. The | ||
465 | * read-back in this function forces the completion so it returns only after | ||
466 | * the config space was written, as expected. | ||
467 | */ | ||
468 | static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg, | ||
469 | int len, u32 value) | ||
470 | { | ||
471 | struct vmd_dev *vmd = vmd_from_bus(bus); | ||
472 | char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len); | ||
473 | unsigned long flags; | ||
474 | int ret = 0; | ||
475 | |||
476 | if (!addr) | ||
477 | return -EFAULT; | ||
478 | |||
479 | spin_lock_irqsave(&vmd->cfg_lock, flags); | ||
480 | switch (len) { | ||
481 | case 1: | ||
482 | writeb(value, addr); | ||
483 | readb(addr); | ||
484 | break; | ||
485 | case 2: | ||
486 | writew(value, addr); | ||
487 | readw(addr); | ||
488 | break; | ||
489 | case 4: | ||
490 | writel(value, addr); | ||
491 | readl(addr); | ||
492 | break; | ||
493 | default: | ||
494 | ret = -EINVAL; | ||
495 | break; | ||
496 | } | ||
497 | spin_unlock_irqrestore(&vmd->cfg_lock, flags); | ||
498 | return ret; | ||
499 | } | ||
500 | |||
501 | static struct pci_ops vmd_ops = { | ||
502 | .read = vmd_pci_read, | ||
503 | .write = vmd_pci_write, | ||
504 | }; | ||
505 | |||
506 | /* | ||
507 | * VMD domains start at 0x1000 to not clash with ACPI _SEG domains. | ||
508 | */ | ||
509 | static int vmd_find_free_domain(void) | ||
510 | { | ||
511 | int domain = 0xffff; | ||
512 | struct pci_bus *bus = NULL; | ||
513 | |||
514 | while ((bus = pci_find_next_bus(bus)) != NULL) | ||
515 | domain = max_t(int, domain, pci_domain_nr(bus)); | ||
516 | return domain + 1; | ||
517 | } | ||
518 | |||
519 | static int vmd_enable_domain(struct vmd_dev *vmd) | ||
520 | { | ||
521 | struct pci_sysdata *sd = &vmd->sysdata; | ||
522 | struct resource *res; | ||
523 | u32 upper_bits; | ||
524 | unsigned long flags; | ||
525 | LIST_HEAD(resources); | ||
526 | |||
527 | res = &vmd->dev->resource[VMD_CFGBAR]; | ||
528 | vmd->resources[0] = (struct resource) { | ||
529 | .name = "VMD CFGBAR", | ||
530 | .start = res->start, | ||
531 | .end = (resource_size(res) >> 20) - 1, | ||
532 | .flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED, | ||
533 | }; | ||
534 | |||
535 | res = &vmd->dev->resource[VMD_MEMBAR1]; | ||
536 | upper_bits = upper_32_bits(res->end); | ||
537 | flags = res->flags & ~IORESOURCE_SIZEALIGN; | ||
538 | if (!upper_bits) | ||
539 | flags &= ~IORESOURCE_MEM_64; | ||
540 | vmd->resources[1] = (struct resource) { | ||
541 | .name = "VMD MEMBAR1", | ||
542 | .start = res->start, | ||
543 | .end = res->end, | ||
544 | .flags = flags, | ||
545 | }; | ||
546 | |||
547 | res = &vmd->dev->resource[VMD_MEMBAR2]; | ||
548 | upper_bits = upper_32_bits(res->end); | ||
549 | flags = res->flags & ~IORESOURCE_SIZEALIGN; | ||
550 | if (!upper_bits) | ||
551 | flags &= ~IORESOURCE_MEM_64; | ||
552 | vmd->resources[2] = (struct resource) { | ||
553 | .name = "VMD MEMBAR2", | ||
554 | .start = res->start + 0x2000, | ||
555 | .end = res->end, | ||
556 | .flags = flags, | ||
557 | }; | ||
558 | |||
559 | sd->domain = vmd_find_free_domain(); | ||
560 | if (sd->domain < 0) | ||
561 | return sd->domain; | ||
562 | |||
563 | sd->node = pcibus_to_node(vmd->dev->bus); | ||
564 | |||
565 | vmd->irq_domain = pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info, | ||
566 | NULL); | ||
567 | if (!vmd->irq_domain) | ||
568 | return -ENODEV; | ||
569 | |||
570 | pci_add_resource(&resources, &vmd->resources[0]); | ||
571 | pci_add_resource(&resources, &vmd->resources[1]); | ||
572 | pci_add_resource(&resources, &vmd->resources[2]); | ||
573 | vmd->bus = pci_create_root_bus(&vmd->dev->dev, 0, &vmd_ops, sd, | ||
574 | &resources); | ||
575 | if (!vmd->bus) { | ||
576 | pci_free_resource_list(&resources); | ||
577 | irq_domain_remove(vmd->irq_domain); | ||
578 | return -ENODEV; | ||
579 | } | ||
580 | |||
581 | vmd_setup_dma_ops(vmd); | ||
582 | dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain); | ||
583 | pci_rescan_bus(vmd->bus); | ||
584 | |||
585 | WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, | ||
586 | "domain"), "Can't create symlink to domain\n"); | ||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | static irqreturn_t vmd_irq(int irq, void *data) | ||
591 | { | ||
592 | struct vmd_irq_list *irqs = data; | ||
593 | struct vmd_irq *vmdirq; | ||
594 | |||
595 | rcu_read_lock(); | ||
596 | list_for_each_entry_rcu(vmdirq, &irqs->irq_list, node) | ||
597 | generic_handle_irq(vmdirq->virq); | ||
598 | rcu_read_unlock(); | ||
599 | |||
600 | return IRQ_HANDLED; | ||
601 | } | ||
602 | |||
603 | static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
604 | { | ||
605 | struct vmd_dev *vmd; | ||
606 | int i, err; | ||
607 | |||
608 | if (resource_size(&dev->resource[VMD_CFGBAR]) < (1 << 20)) | ||
609 | return -ENOMEM; | ||
610 | |||
611 | vmd = devm_kzalloc(&dev->dev, sizeof(*vmd), GFP_KERNEL); | ||
612 | if (!vmd) | ||
613 | return -ENOMEM; | ||
614 | |||
615 | vmd->dev = dev; | ||
616 | err = pcim_enable_device(dev); | ||
617 | if (err < 0) | ||
618 | return err; | ||
619 | |||
620 | vmd->cfgbar = pcim_iomap(dev, VMD_CFGBAR, 0); | ||
621 | if (!vmd->cfgbar) | ||
622 | return -ENOMEM; | ||
623 | |||
624 | pci_set_master(dev); | ||
625 | if (dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)) && | ||
626 | dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32))) | ||
627 | return -ENODEV; | ||
628 | |||
629 | vmd->msix_count = pci_msix_vec_count(dev); | ||
630 | if (vmd->msix_count < 0) | ||
631 | return -ENODEV; | ||
632 | |||
633 | vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs), | ||
634 | GFP_KERNEL); | ||
635 | if (!vmd->irqs) | ||
636 | return -ENOMEM; | ||
637 | |||
638 | vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count, | ||
639 | sizeof(*vmd->msix_entries), | ||
640 | GFP_KERNEL); | ||
641 | if (!vmd->msix_entries) | ||
642 | return -ENOMEM; | ||
643 | for (i = 0; i < vmd->msix_count; i++) | ||
644 | vmd->msix_entries[i].entry = i; | ||
645 | |||
646 | vmd->msix_count = pci_enable_msix_range(vmd->dev, vmd->msix_entries, 1, | ||
647 | vmd->msix_count); | ||
648 | if (vmd->msix_count < 0) | ||
649 | return vmd->msix_count; | ||
650 | |||
651 | for (i = 0; i < vmd->msix_count; i++) { | ||
652 | INIT_LIST_HEAD(&vmd->irqs[i].irq_list); | ||
653 | vmd->irqs[i].vmd_vector = vmd->msix_entries[i].vector; | ||
654 | vmd->irqs[i].index = i; | ||
655 | |||
656 | err = devm_request_irq(&dev->dev, vmd->irqs[i].vmd_vector, | ||
657 | vmd_irq, 0, "vmd", &vmd->irqs[i]); | ||
658 | if (err) | ||
659 | return err; | ||
660 | } | ||
661 | |||
662 | spin_lock_init(&vmd->cfg_lock); | ||
663 | pci_set_drvdata(dev, vmd); | ||
664 | err = vmd_enable_domain(vmd); | ||
665 | if (err) | ||
666 | return err; | ||
667 | |||
668 | dev_info(&vmd->dev->dev, "Bound to PCI domain %04x\n", | ||
669 | vmd->sysdata.domain); | ||
670 | return 0; | ||
671 | } | ||
672 | |||
673 | static void vmd_remove(struct pci_dev *dev) | ||
674 | { | ||
675 | struct vmd_dev *vmd = pci_get_drvdata(dev); | ||
676 | |||
677 | pci_set_drvdata(dev, NULL); | ||
678 | sysfs_remove_link(&vmd->dev->dev.kobj, "domain"); | ||
679 | pci_stop_root_bus(vmd->bus); | ||
680 | pci_remove_root_bus(vmd->bus); | ||
681 | vmd_teardown_dma_ops(vmd); | ||
682 | irq_domain_remove(vmd->irq_domain); | ||
683 | } | ||
684 | |||
685 | #ifdef CONFIG_PM | ||
686 | static int vmd_suspend(struct device *dev) | ||
687 | { | ||
688 | struct pci_dev *pdev = to_pci_dev(dev); | ||
689 | |||
690 | pci_save_state(pdev); | ||
691 | return 0; | ||
692 | } | ||
693 | |||
694 | static int vmd_resume(struct device *dev) | ||
695 | { | ||
696 | struct pci_dev *pdev = to_pci_dev(dev); | ||
697 | |||
698 | pci_restore_state(pdev); | ||
699 | return 0; | ||
700 | } | ||
701 | #endif | ||
702 | static SIMPLE_DEV_PM_OPS(vmd_dev_pm_ops, vmd_suspend, vmd_resume); | ||
703 | |||
704 | static const struct pci_device_id vmd_ids[] = { | ||
705 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x201d),}, | ||
706 | {0,} | ||
707 | }; | ||
708 | MODULE_DEVICE_TABLE(pci, vmd_ids); | ||
709 | |||
710 | static struct pci_driver vmd_drv = { | ||
711 | .name = "vmd", | ||
712 | .id_table = vmd_ids, | ||
713 | .probe = vmd_probe, | ||
714 | .remove = vmd_remove, | ||
715 | .driver = { | ||
716 | .pm = &vmd_dev_pm_ops, | ||
717 | }, | ||
718 | }; | ||
719 | module_pci_driver(vmd_drv); | ||
720 | |||
721 | MODULE_AUTHOR("Intel Corporation"); | ||
722 | MODULE_LICENSE("GPL v2"); | ||
723 | MODULE_VERSION("0.6"); | ||
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 59ac36fe7c42..8c05b5ceeaec 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -25,7 +25,7 @@ DEFINE_RAW_SPINLOCK(pci_lock); | |||
25 | #define PCI_word_BAD (pos & 1) | 25 | #define PCI_word_BAD (pos & 1) |
26 | #define PCI_dword_BAD (pos & 3) | 26 | #define PCI_dword_BAD (pos & 3) |
27 | 27 | ||
28 | #define PCI_OP_READ(size,type,len) \ | 28 | #define PCI_OP_READ(size, type, len) \ |
29 | int pci_bus_read_config_##size \ | 29 | int pci_bus_read_config_##size \ |
30 | (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ | 30 | (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ |
31 | { \ | 31 | { \ |
@@ -40,7 +40,7 @@ int pci_bus_read_config_##size \ | |||
40 | return res; \ | 40 | return res; \ |
41 | } | 41 | } |
42 | 42 | ||
43 | #define PCI_OP_WRITE(size,type,len) \ | 43 | #define PCI_OP_WRITE(size, type, len) \ |
44 | int pci_bus_write_config_##size \ | 44 | int pci_bus_write_config_##size \ |
45 | (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ | 45 | (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ |
46 | { \ | 46 | { \ |
@@ -231,7 +231,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev) | |||
231 | } | 231 | } |
232 | 232 | ||
233 | /* Returns 0 on success, negative values indicate error. */ | 233 | /* Returns 0 on success, negative values indicate error. */ |
234 | #define PCI_USER_READ_CONFIG(size,type) \ | 234 | #define PCI_USER_READ_CONFIG(size, type) \ |
235 | int pci_user_read_config_##size \ | 235 | int pci_user_read_config_##size \ |
236 | (struct pci_dev *dev, int pos, type *val) \ | 236 | (struct pci_dev *dev, int pos, type *val) \ |
237 | { \ | 237 | { \ |
@@ -251,7 +251,7 @@ int pci_user_read_config_##size \ | |||
251 | EXPORT_SYMBOL_GPL(pci_user_read_config_##size); | 251 | EXPORT_SYMBOL_GPL(pci_user_read_config_##size); |
252 | 252 | ||
253 | /* Returns 0 on success, negative values indicate error. */ | 253 | /* Returns 0 on success, negative values indicate error. */ |
254 | #define PCI_USER_WRITE_CONFIG(size,type) \ | 254 | #define PCI_USER_WRITE_CONFIG(size, type) \ |
255 | int pci_user_write_config_##size \ | 255 | int pci_user_write_config_##size \ |
256 | (struct pci_dev *dev, int pos, type val) \ | 256 | (struct pci_dev *dev, int pos, type val) \ |
257 | { \ | 257 | { \ |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index d3346d23963b..89b3befc7155 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -140,6 +140,8 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, | |||
140 | type_mask |= IORESOURCE_TYPE_BITS; | 140 | type_mask |= IORESOURCE_TYPE_BITS; |
141 | 141 | ||
142 | pci_bus_for_each_resource(bus, r, i) { | 142 | pci_bus_for_each_resource(bus, r, i) { |
143 | resource_size_t min_used = min; | ||
144 | |||
143 | if (!r) | 145 | if (!r) |
144 | continue; | 146 | continue; |
145 | 147 | ||
@@ -163,12 +165,12 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, | |||
163 | * overrides "min". | 165 | * overrides "min". |
164 | */ | 166 | */ |
165 | if (avail.start) | 167 | if (avail.start) |
166 | min = avail.start; | 168 | min_used = avail.start; |
167 | 169 | ||
168 | max = avail.end; | 170 | max = avail.end; |
169 | 171 | ||
170 | /* Ok, try it out.. */ | 172 | /* Ok, try it out.. */ |
171 | ret = allocate_resource(r, res, size, min, max, | 173 | ret = allocate_resource(r, res, size, min_used, max, |
172 | align, alignf, alignf_data); | 174 | align, alignf, alignf_data); |
173 | if (ret == 0) | 175 | if (ret == 0) |
174 | return 0; | 176 | return 0; |
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index c0ad9aaa16a7..75a605426538 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
@@ -49,8 +49,7 @@ config PCI_RCAR_GEN2 | |||
49 | 49 | ||
50 | config PCI_RCAR_GEN2_PCIE | 50 | config PCI_RCAR_GEN2_PCIE |
51 | bool "Renesas R-Car PCIe controller" | 51 | bool "Renesas R-Car PCIe controller" |
52 | depends on ARM | 52 | depends on ARCH_SHMOBILE || (ARM && COMPILE_TEST) |
53 | depends on ARCH_SHMOBILE || COMPILE_TEST | ||
54 | help | 53 | help |
55 | Say Y here if you want PCIe controller support on R-Car Gen2 SoCs. | 54 | Say Y here if you want PCIe controller support on R-Car Gen2 SoCs. |
56 | 55 | ||
@@ -119,13 +118,11 @@ config PCI_VERSATILE | |||
119 | depends on ARCH_VERSATILE | 118 | depends on ARCH_VERSATILE |
120 | 119 | ||
121 | config PCIE_IPROC | 120 | config PCIE_IPROC |
122 | tristate "Broadcom iProc PCIe controller" | 121 | tristate |
123 | depends on OF && (ARM || ARM64) | ||
124 | default n | ||
125 | help | 122 | help |
126 | This enables the iProc PCIe core controller support for Broadcom's | 123 | This enables the iProc PCIe core controller support for Broadcom's |
127 | iProc family of SoCs. An appropriate bus interface driver also needs | 124 | iProc family of SoCs. An appropriate bus interface driver needs |
128 | to be enabled | 125 | to be enabled to select this. |
129 | 126 | ||
130 | config PCIE_IPROC_PLATFORM | 127 | config PCIE_IPROC_PLATFORM |
131 | tristate "Broadcom iProc PCIe platform bus driver" | 128 | tristate "Broadcom iProc PCIe platform bus driver" |
@@ -148,6 +145,16 @@ config PCIE_IPROC_BCMA | |||
148 | Say Y here if you want to use the Broadcom iProc PCIe controller | 145 | Say Y here if you want to use the Broadcom iProc PCIe controller |
149 | through the BCMA bus interface | 146 | through the BCMA bus interface |
150 | 147 | ||
148 | config PCIE_IPROC_MSI | ||
149 | bool "Broadcom iProc PCIe MSI support" | ||
150 | depends on PCIE_IPROC_PLATFORM || PCIE_IPROC_BCMA | ||
151 | depends on PCI_MSI | ||
152 | select PCI_MSI_IRQ_DOMAIN | ||
153 | default ARCH_BCM_IPROC | ||
154 | help | ||
155 | Say Y here if you want to enable MSI support for Broadcom's iProc | ||
156 | PCIe controller | ||
157 | |||
151 | config PCIE_ALTERA | 158 | config PCIE_ALTERA |
152 | bool "Altera PCIe controller" | 159 | bool "Altera PCIe controller" |
153 | depends on ARM || NIOS2 | 160 | depends on ARM || NIOS2 |
@@ -167,10 +174,21 @@ config PCIE_ALTERA_MSI | |||
167 | 174 | ||
168 | config PCI_HISI | 175 | config PCI_HISI |
169 | depends on OF && ARM64 | 176 | depends on OF && ARM64 |
170 | bool "HiSilicon SoC HIP05 PCIe controller" | 177 | bool "HiSilicon Hip05 and Hip06 SoCs PCIe controllers" |
171 | select PCIEPORTBUS | 178 | select PCIEPORTBUS |
172 | select PCIE_DW | 179 | select PCIE_DW |
173 | help | 180 | help |
174 | Say Y here if you want PCIe controller support on HiSilicon HIP05 SoC | 181 | Say Y here if you want PCIe controller support on HiSilicon |
182 | Hip05 and Hip06 SoCs | ||
183 | |||
184 | config PCIE_QCOM | ||
185 | bool "Qualcomm PCIe controller" | ||
186 | depends on ARCH_QCOM && OF | ||
187 | select PCIE_DW | ||
188 | select PCIEPORTBUS | ||
189 | help | ||
190 | Say Y here to enable PCIe controller support on Qualcomm SoCs. The | ||
191 | PCIe controller uses the Designware core plus Qualcomm-specific | ||
192 | hardware wrappers. | ||
175 | 193 | ||
176 | endmenu | 194 | endmenu |
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index 9d4d3c6924a1..7b2f20c6ccc6 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile | |||
@@ -15,8 +15,10 @@ obj-$(CONFIG_PCI_XGENE_MSI) += pci-xgene-msi.o | |||
15 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o | 15 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o |
16 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o | 16 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o |
17 | obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o | 17 | obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o |
18 | obj-$(CONFIG_PCIE_IPROC_MSI) += pcie-iproc-msi.o | ||
18 | obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o | 19 | obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o |
19 | obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o | 20 | obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o |
20 | obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o | 21 | obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o |
21 | obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o | 22 | obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o |
22 | obj-$(CONFIG_PCI_HISI) += pcie-hisi.o | 23 | obj-$(CONFIG_PCI_HISI) += pcie-hisi.o |
24 | obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o | ||
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c index 8c3688046c02..923607bdabc5 100644 --- a/drivers/pci/host/pci-dra7xx.c +++ b/drivers/pci/host/pci-dra7xx.c | |||
@@ -302,7 +302,8 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, | |||
302 | } | 302 | } |
303 | 303 | ||
304 | ret = devm_request_irq(&pdev->dev, pp->irq, | 304 | ret = devm_request_irq(&pdev->dev, pp->irq, |
305 | dra7xx_pcie_msi_irq_handler, IRQF_SHARED, | 305 | dra7xx_pcie_msi_irq_handler, |
306 | IRQF_SHARED | IRQF_NO_THREAD, | ||
306 | "dra7-pcie-msi", pp); | 307 | "dra7-pcie-msi", pp); |
307 | if (ret) { | 308 | if (ret) { |
308 | dev_err(&pdev->dev, "failed to request irq\n"); | 309 | dev_err(&pdev->dev, "failed to request irq\n"); |
diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c index 01095e1160a4..d997d22d4231 100644 --- a/drivers/pci/host/pci-exynos.c +++ b/drivers/pci/host/pci-exynos.c | |||
@@ -522,7 +522,8 @@ static int __init exynos_add_pcie_port(struct pcie_port *pp, | |||
522 | 522 | ||
523 | ret = devm_request_irq(&pdev->dev, pp->msi_irq, | 523 | ret = devm_request_irq(&pdev->dev, pp->msi_irq, |
524 | exynos_pcie_msi_irq_handler, | 524 | exynos_pcie_msi_irq_handler, |
525 | IRQF_SHARED, "exynos-pcie", pp); | 525 | IRQF_SHARED | IRQF_NO_THREAD, |
526 | "exynos-pcie", pp); | ||
526 | if (ret) { | 527 | if (ret) { |
527 | dev_err(&pdev->dev, "failed to request msi irq\n"); | 528 | dev_err(&pdev->dev, "failed to request msi irq\n"); |
528 | return ret; | 529 | return ret; |
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 5434c90db243..1652bc70b145 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c | |||
@@ -38,16 +38,7 @@ struct gen_pci_cfg_windows { | |||
38 | struct gen_pci_cfg_bus_ops *ops; | 38 | struct gen_pci_cfg_bus_ops *ops; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | /* | ||
42 | * ARM pcibios functions expect the ARM struct pci_sys_data as the PCI | ||
43 | * sysdata. Add pci_sys_data as the first element in struct gen_pci so | ||
44 | * that when we use a gen_pci pointer as sysdata, it is also a pointer to | ||
45 | * a struct pci_sys_data. | ||
46 | */ | ||
47 | struct gen_pci { | 41 | struct gen_pci { |
48 | #ifdef CONFIG_ARM | ||
49 | struct pci_sys_data sys; | ||
50 | #endif | ||
51 | struct pci_host_bridge host; | 42 | struct pci_host_bridge host; |
52 | struct gen_pci_cfg_windows cfg; | 43 | struct gen_pci_cfg_windows cfg; |
53 | struct list_head resources; | 44 | struct list_head resources; |
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 22e8224126fd..fe600964fa50 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp) | 32 | #define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp) |
33 | 33 | ||
34 | struct imx6_pcie { | 34 | struct imx6_pcie { |
35 | int reset_gpio; | 35 | struct gpio_desc *reset_gpio; |
36 | struct clk *pcie_bus; | 36 | struct clk *pcie_bus; |
37 | struct clk *pcie_phy; | 37 | struct clk *pcie_phy; |
38 | struct clk *pcie; | 38 | struct clk *pcie; |
@@ -122,7 +122,7 @@ static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */ | 124 | /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */ |
125 | static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data) | 125 | static int pcie_phy_read(void __iomem *dbi_base, int addr, int *data) |
126 | { | 126 | { |
127 | u32 val, phy_ctl; | 127 | u32 val, phy_ctl; |
128 | int ret; | 128 | int ret; |
@@ -287,10 +287,10 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) | |||
287 | usleep_range(200, 500); | 287 | usleep_range(200, 500); |
288 | 288 | ||
289 | /* Some boards don't have PCIe reset GPIO. */ | 289 | /* Some boards don't have PCIe reset GPIO. */ |
290 | if (gpio_is_valid(imx6_pcie->reset_gpio)) { | 290 | if (imx6_pcie->reset_gpio) { |
291 | gpio_set_value(imx6_pcie->reset_gpio, 0); | 291 | gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 0); |
292 | msleep(100); | 292 | msleep(100); |
293 | gpio_set_value(imx6_pcie->reset_gpio, 1); | 293 | gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 1); |
294 | } | 294 | } |
295 | return 0; | 295 | return 0; |
296 | 296 | ||
@@ -537,7 +537,8 @@ static int __init imx6_add_pcie_port(struct pcie_port *pp, | |||
537 | 537 | ||
538 | ret = devm_request_irq(&pdev->dev, pp->msi_irq, | 538 | ret = devm_request_irq(&pdev->dev, pp->msi_irq, |
539 | imx6_pcie_msi_handler, | 539 | imx6_pcie_msi_handler, |
540 | IRQF_SHARED, "mx6-pcie-msi", pp); | 540 | IRQF_SHARED | IRQF_NO_THREAD, |
541 | "mx6-pcie-msi", pp); | ||
541 | if (ret) { | 542 | if (ret) { |
542 | dev_err(&pdev->dev, "failed to request MSI irq\n"); | 543 | dev_err(&pdev->dev, "failed to request MSI irq\n"); |
543 | return ret; | 544 | return ret; |
@@ -560,7 +561,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) | |||
560 | { | 561 | { |
561 | struct imx6_pcie *imx6_pcie; | 562 | struct imx6_pcie *imx6_pcie; |
562 | struct pcie_port *pp; | 563 | struct pcie_port *pp; |
563 | struct device_node *np = pdev->dev.of_node; | ||
564 | struct resource *dbi_base; | 564 | struct resource *dbi_base; |
565 | int ret; | 565 | int ret; |
566 | 566 | ||
@@ -581,15 +581,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) | |||
581 | return PTR_ERR(pp->dbi_base); | 581 | return PTR_ERR(pp->dbi_base); |
582 | 582 | ||
583 | /* Fetch GPIOs */ | 583 | /* Fetch GPIOs */ |
584 | imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); | 584 | imx6_pcie->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", |
585 | if (gpio_is_valid(imx6_pcie->reset_gpio)) { | 585 | GPIOD_OUT_LOW); |
586 | ret = devm_gpio_request_one(&pdev->dev, imx6_pcie->reset_gpio, | ||
587 | GPIOF_OUT_INIT_LOW, "PCIe reset"); | ||
588 | if (ret) { | ||
589 | dev_err(&pdev->dev, "unable to get reset gpio\n"); | ||
590 | return ret; | ||
591 | } | ||
592 | } | ||
593 | 586 | ||
594 | /* Fetch clocks */ | 587 | /* Fetch clocks */ |
595 | imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy"); | 588 | imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy"); |
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index c4f64bfee551..9980a4bdae7e 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/of_address.h> | ||
18 | #include <linux/of_pci.h> | 19 | #include <linux/of_pci.h> |
19 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
20 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
@@ -102,6 +103,8 @@ struct rcar_pci_priv { | |||
102 | unsigned busnr; | 103 | unsigned busnr; |
103 | int irq; | 104 | int irq; |
104 | unsigned long window_size; | 105 | unsigned long window_size; |
106 | unsigned long window_addr; | ||
107 | unsigned long window_pci; | ||
105 | }; | 108 | }; |
106 | 109 | ||
107 | /* PCI configuration space operations */ | 110 | /* PCI configuration space operations */ |
@@ -239,8 +242,8 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
239 | RCAR_PCI_ARBITER_PCIBP_MODE; | 242 | RCAR_PCI_ARBITER_PCIBP_MODE; |
240 | iowrite32(val, reg + RCAR_PCI_ARBITER_CTR_REG); | 243 | iowrite32(val, reg + RCAR_PCI_ARBITER_CTR_REG); |
241 | 244 | ||
242 | /* PCI-AHB mapping: 0x40000000 base */ | 245 | /* PCI-AHB mapping */ |
243 | iowrite32(0x40000000 | RCAR_PCIAHB_PREFETCH16, | 246 | iowrite32(priv->window_addr | RCAR_PCIAHB_PREFETCH16, |
244 | reg + RCAR_PCIAHB_WIN1_CTR_REG); | 247 | reg + RCAR_PCIAHB_WIN1_CTR_REG); |
245 | 248 | ||
246 | /* AHB-PCI mapping: OHCI/EHCI registers */ | 249 | /* AHB-PCI mapping: OHCI/EHCI registers */ |
@@ -251,7 +254,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
251 | iowrite32(RCAR_AHBPCI_WIN1_HOST | RCAR_AHBPCI_WIN_CTR_CFG, | 254 | iowrite32(RCAR_AHBPCI_WIN1_HOST | RCAR_AHBPCI_WIN_CTR_CFG, |
252 | reg + RCAR_AHBPCI_WIN1_CTR_REG); | 255 | reg + RCAR_AHBPCI_WIN1_CTR_REG); |
253 | /* Set PCI-AHB Window1 address */ | 256 | /* Set PCI-AHB Window1 address */ |
254 | iowrite32(0x40000000 | PCI_BASE_ADDRESS_MEM_PREFETCH, | 257 | iowrite32(priv->window_pci | PCI_BASE_ADDRESS_MEM_PREFETCH, |
255 | reg + PCI_BASE_ADDRESS_1); | 258 | reg + PCI_BASE_ADDRESS_1); |
256 | /* Set AHB-PCI bridge PCI communication area address */ | 259 | /* Set AHB-PCI bridge PCI communication area address */ |
257 | val = priv->cfg_res->start + RCAR_AHBPCI_PCICOM_OFFSET; | 260 | val = priv->cfg_res->start + RCAR_AHBPCI_PCICOM_OFFSET; |
@@ -284,6 +287,64 @@ static struct pci_ops rcar_pci_ops = { | |||
284 | .write = pci_generic_config_write, | 287 | .write = pci_generic_config_write, |
285 | }; | 288 | }; |
286 | 289 | ||
290 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
291 | struct device_node *node) | ||
292 | { | ||
293 | const int na = 3, ns = 2; | ||
294 | int rlen; | ||
295 | |||
296 | parser->node = node; | ||
297 | parser->pna = of_n_addr_cells(node); | ||
298 | parser->np = parser->pna + na + ns; | ||
299 | |||
300 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
301 | if (!parser->range) | ||
302 | return -ENOENT; | ||
303 | |||
304 | parser->end = parser->range + rlen / sizeof(__be32); | ||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, | ||
309 | struct device_node *np) | ||
310 | { | ||
311 | struct of_pci_range range; | ||
312 | struct of_pci_range_parser parser; | ||
313 | int index = 0; | ||
314 | |||
315 | /* Failure to parse is ok as we fall back to defaults */ | ||
316 | if (pci_dma_range_parser_init(&parser, np)) | ||
317 | return 0; | ||
318 | |||
319 | /* Get the dma-ranges from DT */ | ||
320 | for_each_of_pci_range(&parser, &range) { | ||
321 | /* Hardware only allows one inbound 32-bit range */ | ||
322 | if (index) | ||
323 | return -EINVAL; | ||
324 | |||
325 | pci->window_addr = (unsigned long)range.cpu_addr; | ||
326 | pci->window_pci = (unsigned long)range.pci_addr; | ||
327 | pci->window_size = (unsigned long)range.size; | ||
328 | |||
329 | /* Catch HW limitations */ | ||
330 | if (!(range.flags & IORESOURCE_PREFETCH)) { | ||
331 | dev_err(pci->dev, "window must be prefetchable\n"); | ||
332 | return -EINVAL; | ||
333 | } | ||
334 | if (pci->window_addr) { | ||
335 | u32 lowaddr = 1 << (ffs(pci->window_addr) - 1); | ||
336 | |||
337 | if (lowaddr < pci->window_size) { | ||
338 | dev_err(pci->dev, "invalid window size/addr\n"); | ||
339 | return -EINVAL; | ||
340 | } | ||
341 | } | ||
342 | index++; | ||
343 | } | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
287 | static int rcar_pci_probe(struct platform_device *pdev) | 348 | static int rcar_pci_probe(struct platform_device *pdev) |
288 | { | 349 | { |
289 | struct resource *cfg_res, *mem_res; | 350 | struct resource *cfg_res, *mem_res; |
@@ -329,6 +390,9 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
329 | return priv->irq; | 390 | return priv->irq; |
330 | } | 391 | } |
331 | 392 | ||
393 | /* default window addr and size if not specified in DT */ | ||
394 | priv->window_addr = 0x40000000; | ||
395 | priv->window_pci = 0x40000000; | ||
332 | priv->window_size = SZ_1G; | 396 | priv->window_size = SZ_1G; |
333 | 397 | ||
334 | if (pdev->dev.of_node) { | 398 | if (pdev->dev.of_node) { |
@@ -344,6 +408,12 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
344 | priv->busnr = busnr.start; | 408 | priv->busnr = busnr.start; |
345 | if (busnr.end != busnr.start) | 409 | if (busnr.end != busnr.start) |
346 | dev_warn(&pdev->dev, "only one bus number supported\n"); | 410 | dev_warn(&pdev->dev, "only one bus number supported\n"); |
411 | |||
412 | ret = rcar_pci_parse_map_dma_ranges(priv, pdev->dev.of_node); | ||
413 | if (ret < 0) { | ||
414 | dev_err(&pdev->dev, "failed to parse dma-range\n"); | ||
415 | return ret; | ||
416 | } | ||
347 | } else { | 417 | } else { |
348 | priv->busnr = pdev->id; | 418 | priv->busnr = pdev->id; |
349 | } | 419 | } |
@@ -360,6 +430,7 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
360 | } | 430 | } |
361 | 431 | ||
362 | static struct of_device_id rcar_pci_of_match[] = { | 432 | static struct of_device_id rcar_pci_of_match[] = { |
433 | { .compatible = "renesas,pci-rcar-gen2", }, | ||
363 | { .compatible = "renesas,pci-r8a7790", }, | 434 | { .compatible = "renesas,pci-r8a7790", }, |
364 | { .compatible = "renesas,pci-r8a7791", }, | 435 | { .compatible = "renesas,pci-r8a7791", }, |
365 | { .compatible = "renesas,pci-r8a7794", }, | 436 | { .compatible = "renesas,pci-r8a7794", }, |
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 3018ae52e092..30323114c53c 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c | |||
@@ -1288,7 +1288,7 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie) | |||
1288 | 1288 | ||
1289 | msi->irq = err; | 1289 | msi->irq = err; |
1290 | 1290 | ||
1291 | err = request_irq(msi->irq, tegra_pcie_msi_irq, 0, | 1291 | err = request_irq(msi->irq, tegra_pcie_msi_irq, IRQF_NO_THREAD, |
1292 | tegra_msi_irq_chip.name, pcie); | 1292 | tegra_msi_irq_chip.name, pcie); |
1293 | if (err < 0) { | 1293 | if (err < 0) { |
1294 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); | 1294 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); |
diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c index 0863d9cc25f8..f843a72dc51c 100644 --- a/drivers/pci/host/pci-versatile.c +++ b/drivers/pci/host/pci-versatile.c | |||
@@ -125,9 +125,6 @@ out_release_res: | |||
125 | return err; | 125 | return err; |
126 | } | 126 | } |
127 | 127 | ||
128 | /* Unused, temporary to satisfy ARM arch code */ | ||
129 | struct pci_sys_data sys; | ||
130 | |||
131 | static int versatile_pci_probe(struct platform_device *pdev) | 128 | static int versatile_pci_probe(struct platform_device *pdev) |
132 | { | 129 | { |
133 | struct resource *res; | 130 | struct resource *res; |
@@ -208,7 +205,7 @@ static int versatile_pci_probe(struct platform_device *pdev) | |||
208 | pci_add_flags(PCI_ENABLE_PROC_DOMAINS); | 205 | pci_add_flags(PCI_ENABLE_PROC_DOMAINS); |
209 | pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC); | 206 | pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC); |
210 | 207 | ||
211 | bus = pci_scan_root_bus(&pdev->dev, 0, &pci_versatile_ops, &sys, &pci_res); | 208 | bus = pci_scan_root_bus(&pdev->dev, 0, &pci_versatile_ops, NULL, &pci_res); |
212 | if (!bus) | 209 | if (!bus) |
213 | return -ENOMEM; | 210 | return -ENOMEM; |
214 | 211 | ||
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index 02a7452bdf23..21716827847a 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c | |||
@@ -128,32 +128,26 @@ static inline void dw_pcie_writel_rc(struct pcie_port *pp, u32 val, u32 reg) | |||
128 | static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, | 128 | static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, |
129 | u32 *val) | 129 | u32 *val) |
130 | { | 130 | { |
131 | int ret; | ||
132 | |||
133 | if (pp->ops->rd_own_conf) | 131 | if (pp->ops->rd_own_conf) |
134 | ret = pp->ops->rd_own_conf(pp, where, size, val); | 132 | return pp->ops->rd_own_conf(pp, where, size, val); |
135 | else | ||
136 | ret = dw_pcie_cfg_read(pp->dbi_base + where, size, val); | ||
137 | 133 | ||
138 | return ret; | 134 | return dw_pcie_cfg_read(pp->dbi_base + where, size, val); |
139 | } | 135 | } |
140 | 136 | ||
141 | static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, | 137 | static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, |
142 | u32 val) | 138 | u32 val) |
143 | { | 139 | { |
144 | int ret; | ||
145 | |||
146 | if (pp->ops->wr_own_conf) | 140 | if (pp->ops->wr_own_conf) |
147 | ret = pp->ops->wr_own_conf(pp, where, size, val); | 141 | return pp->ops->wr_own_conf(pp, where, size, val); |
148 | else | ||
149 | ret = dw_pcie_cfg_write(pp->dbi_base + where, size, val); | ||
150 | 142 | ||
151 | return ret; | 143 | return dw_pcie_cfg_write(pp->dbi_base + where, size, val); |
152 | } | 144 | } |
153 | 145 | ||
154 | static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, | 146 | static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, |
155 | int type, u64 cpu_addr, u64 pci_addr, u32 size) | 147 | int type, u64 cpu_addr, u64 pci_addr, u32 size) |
156 | { | 148 | { |
149 | u32 val; | ||
150 | |||
157 | dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | index, | 151 | dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | index, |
158 | PCIE_ATU_VIEWPORT); | 152 | PCIE_ATU_VIEWPORT); |
159 | dw_pcie_writel_rc(pp, lower_32_bits(cpu_addr), PCIE_ATU_LOWER_BASE); | 153 | dw_pcie_writel_rc(pp, lower_32_bits(cpu_addr), PCIE_ATU_LOWER_BASE); |
@@ -164,6 +158,12 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, | |||
164 | dw_pcie_writel_rc(pp, upper_32_bits(pci_addr), PCIE_ATU_UPPER_TARGET); | 158 | dw_pcie_writel_rc(pp, upper_32_bits(pci_addr), PCIE_ATU_UPPER_TARGET); |
165 | dw_pcie_writel_rc(pp, type, PCIE_ATU_CR1); | 159 | dw_pcie_writel_rc(pp, type, PCIE_ATU_CR1); |
166 | dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2); | 160 | dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2); |
161 | |||
162 | /* | ||
163 | * Make sure ATU enable takes effect before any subsequent config | ||
164 | * and I/O accesses. | ||
165 | */ | ||
166 | dw_pcie_readl_rc(pp, PCIE_ATU_CR2, &val); | ||
167 | } | 167 | } |
168 | 168 | ||
169 | static struct irq_chip dw_msi_irq_chip = { | 169 | static struct irq_chip dw_msi_irq_chip = { |
@@ -384,8 +384,8 @@ int dw_pcie_link_up(struct pcie_port *pp) | |||
384 | { | 384 | { |
385 | if (pp->ops->link_up) | 385 | if (pp->ops->link_up) |
386 | return pp->ops->link_up(pp); | 386 | return pp->ops->link_up(pp); |
387 | else | 387 | |
388 | return 0; | 388 | return 0; |
389 | } | 389 | } |
390 | 390 | ||
391 | static int dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq, | 391 | static int dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq, |
@@ -571,6 +571,9 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, | |||
571 | u64 cpu_addr; | 571 | u64 cpu_addr; |
572 | void __iomem *va_cfg_base; | 572 | void __iomem *va_cfg_base; |
573 | 573 | ||
574 | if (pp->ops->rd_other_conf) | ||
575 | return pp->ops->rd_other_conf(pp, bus, devfn, where, size, val); | ||
576 | |||
574 | busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) | | 577 | busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) | |
575 | PCIE_ATU_FUNC(PCI_FUNC(devfn)); | 578 | PCIE_ATU_FUNC(PCI_FUNC(devfn)); |
576 | 579 | ||
@@ -605,6 +608,9 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus, | |||
605 | u64 cpu_addr; | 608 | u64 cpu_addr; |
606 | void __iomem *va_cfg_base; | 609 | void __iomem *va_cfg_base; |
607 | 610 | ||
611 | if (pp->ops->wr_other_conf) | ||
612 | return pp->ops->wr_other_conf(pp, bus, devfn, where, size, val); | ||
613 | |||
608 | busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) | | 614 | busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) | |
609 | PCIE_ATU_FUNC(PCI_FUNC(devfn)); | 615 | PCIE_ATU_FUNC(PCI_FUNC(devfn)); |
610 | 616 | ||
@@ -658,46 +664,30 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, | |||
658 | int size, u32 *val) | 664 | int size, u32 *val) |
659 | { | 665 | { |
660 | struct pcie_port *pp = bus->sysdata; | 666 | struct pcie_port *pp = bus->sysdata; |
661 | int ret; | ||
662 | 667 | ||
663 | if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) { | 668 | if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) { |
664 | *val = 0xffffffff; | 669 | *val = 0xffffffff; |
665 | return PCIBIOS_DEVICE_NOT_FOUND; | 670 | return PCIBIOS_DEVICE_NOT_FOUND; |
666 | } | 671 | } |
667 | 672 | ||
668 | if (bus->number != pp->root_bus_nr) | 673 | if (bus->number == pp->root_bus_nr) |
669 | if (pp->ops->rd_other_conf) | 674 | return dw_pcie_rd_own_conf(pp, where, size, val); |
670 | ret = pp->ops->rd_other_conf(pp, bus, devfn, | ||
671 | where, size, val); | ||
672 | else | ||
673 | ret = dw_pcie_rd_other_conf(pp, bus, devfn, | ||
674 | where, size, val); | ||
675 | else | ||
676 | ret = dw_pcie_rd_own_conf(pp, where, size, val); | ||
677 | 675 | ||
678 | return ret; | 676 | return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val); |
679 | } | 677 | } |
680 | 678 | ||
681 | static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn, | 679 | static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn, |
682 | int where, int size, u32 val) | 680 | int where, int size, u32 val) |
683 | { | 681 | { |
684 | struct pcie_port *pp = bus->sysdata; | 682 | struct pcie_port *pp = bus->sysdata; |
685 | int ret; | ||
686 | 683 | ||
687 | if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) | 684 | if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) |
688 | return PCIBIOS_DEVICE_NOT_FOUND; | 685 | return PCIBIOS_DEVICE_NOT_FOUND; |
689 | 686 | ||
690 | if (bus->number != pp->root_bus_nr) | 687 | if (bus->number == pp->root_bus_nr) |
691 | if (pp->ops->wr_other_conf) | 688 | return dw_pcie_wr_own_conf(pp, where, size, val); |
692 | ret = pp->ops->wr_other_conf(pp, bus, devfn, | ||
693 | where, size, val); | ||
694 | else | ||
695 | ret = dw_pcie_wr_other_conf(pp, bus, devfn, | ||
696 | where, size, val); | ||
697 | else | ||
698 | ret = dw_pcie_wr_own_conf(pp, where, size, val); | ||
699 | 689 | ||
700 | return ret; | 690 | return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val); |
701 | } | 691 | } |
702 | 692 | ||
703 | static struct pci_ops dw_pcie_ops = { | 693 | static struct pci_ops dw_pcie_ops = { |
diff --git a/drivers/pci/host/pcie-hisi.c b/drivers/pci/host/pcie-hisi.c index 77f7c669a1b9..3e98d4edae2d 100644 --- a/drivers/pci/host/pcie-hisi.c +++ b/drivers/pci/host/pcie-hisi.c | |||
@@ -1,10 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * PCIe host controller driver for HiSilicon Hip05 SoC | 2 | * PCIe host controller driver for HiSilicon SoCs |
3 | * | 3 | * |
4 | * Copyright (C) 2015 HiSilicon Co., Ltd. http://www.hisilicon.com | 4 | * Copyright (C) 2015 HiSilicon Co., Ltd. http://www.hisilicon.com |
5 | * | 5 | * |
6 | * Author: Zhou Wang <wangzhou1@hisilicon.com> | 6 | * Authors: Zhou Wang <wangzhou1@hisilicon.com> |
7 | * Dacai Zhu <zhudacai@hisilicon.com> | 7 | * Dacai Zhu <zhudacai@hisilicon.com> |
8 | * Gabriele Paoloni <gabriele.paoloni@huawei.com> | ||
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
@@ -16,21 +17,31 @@ | |||
16 | #include <linux/of_address.h> | 17 | #include <linux/of_address.h> |
17 | #include <linux/of_pci.h> | 18 | #include <linux/of_pci.h> |
18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/of_device.h> | ||
19 | #include <linux/regmap.h> | 21 | #include <linux/regmap.h> |
20 | 22 | ||
21 | #include "pcie-designware.h" | 23 | #include "pcie-designware.h" |
22 | 24 | ||
23 | #define PCIE_SUBCTRL_SYS_STATE4_REG 0x6818 | 25 | #define PCIE_LTSSM_LINKUP_STATE 0x11 |
24 | #define PCIE_LTSSM_LINKUP_STATE 0x11 | 26 | #define PCIE_LTSSM_STATE_MASK 0x3F |
25 | #define PCIE_LTSSM_STATE_MASK 0x3F | 27 | #define PCIE_SUBCTRL_SYS_STATE4_REG 0x6818 |
28 | #define PCIE_SYS_STATE4 0x31c | ||
29 | #define PCIE_HIP06_CTRL_OFF 0x1000 | ||
26 | 30 | ||
27 | #define to_hisi_pcie(x) container_of(x, struct hisi_pcie, pp) | 31 | #define to_hisi_pcie(x) container_of(x, struct hisi_pcie, pp) |
28 | 32 | ||
33 | struct hisi_pcie; | ||
34 | |||
35 | struct pcie_soc_ops { | ||
36 | int (*hisi_pcie_link_up)(struct hisi_pcie *pcie); | ||
37 | }; | ||
38 | |||
29 | struct hisi_pcie { | 39 | struct hisi_pcie { |
30 | struct regmap *subctrl; | 40 | struct regmap *subctrl; |
31 | void __iomem *reg_base; | 41 | void __iomem *reg_base; |
32 | u32 port_id; | 42 | u32 port_id; |
33 | struct pcie_port pp; | 43 | struct pcie_port pp; |
44 | struct pcie_soc_ops *soc_ops; | ||
34 | }; | 45 | }; |
35 | 46 | ||
36 | static inline void hisi_pcie_apb_writel(struct hisi_pcie *pcie, | 47 | static inline void hisi_pcie_apb_writel(struct hisi_pcie *pcie, |
@@ -44,7 +55,7 @@ static inline u32 hisi_pcie_apb_readl(struct hisi_pcie *pcie, u32 reg) | |||
44 | return readl(pcie->reg_base + reg); | 55 | return readl(pcie->reg_base + reg); |
45 | } | 56 | } |
46 | 57 | ||
47 | /* Hip05 PCIe host only supports 32-bit config access */ | 58 | /* HipXX PCIe host only supports 32-bit config access */ |
48 | static int hisi_pcie_cfg_read(struct pcie_port *pp, int where, int size, | 59 | static int hisi_pcie_cfg_read(struct pcie_port *pp, int where, int size, |
49 | u32 *val) | 60 | u32 *val) |
50 | { | 61 | { |
@@ -69,7 +80,7 @@ static int hisi_pcie_cfg_read(struct pcie_port *pp, int where, int size, | |||
69 | return PCIBIOS_SUCCESSFUL; | 80 | return PCIBIOS_SUCCESSFUL; |
70 | } | 81 | } |
71 | 82 | ||
72 | /* Hip05 PCIe host only supports 32-bit config access */ | 83 | /* HipXX PCIe host only supports 32-bit config access */ |
73 | static int hisi_pcie_cfg_write(struct pcie_port *pp, int where, int size, | 84 | static int hisi_pcie_cfg_write(struct pcie_port *pp, int where, int size, |
74 | u32 val) | 85 | u32 val) |
75 | { | 86 | { |
@@ -96,10 +107,9 @@ static int hisi_pcie_cfg_write(struct pcie_port *pp, int where, int size, | |||
96 | return PCIBIOS_SUCCESSFUL; | 107 | return PCIBIOS_SUCCESSFUL; |
97 | } | 108 | } |
98 | 109 | ||
99 | static int hisi_pcie_link_up(struct pcie_port *pp) | 110 | static int hisi_pcie_link_up_hip05(struct hisi_pcie *hisi_pcie) |
100 | { | 111 | { |
101 | u32 val; | 112 | u32 val; |
102 | struct hisi_pcie *hisi_pcie = to_hisi_pcie(pp); | ||
103 | 113 | ||
104 | regmap_read(hisi_pcie->subctrl, PCIE_SUBCTRL_SYS_STATE4_REG + | 114 | regmap_read(hisi_pcie->subctrl, PCIE_SUBCTRL_SYS_STATE4_REG + |
105 | 0x100 * hisi_pcie->port_id, &val); | 115 | 0x100 * hisi_pcie->port_id, &val); |
@@ -107,6 +117,23 @@ static int hisi_pcie_link_up(struct pcie_port *pp) | |||
107 | return ((val & PCIE_LTSSM_STATE_MASK) == PCIE_LTSSM_LINKUP_STATE); | 117 | return ((val & PCIE_LTSSM_STATE_MASK) == PCIE_LTSSM_LINKUP_STATE); |
108 | } | 118 | } |
109 | 119 | ||
120 | static int hisi_pcie_link_up_hip06(struct hisi_pcie *hisi_pcie) | ||
121 | { | ||
122 | u32 val; | ||
123 | |||
124 | val = hisi_pcie_apb_readl(hisi_pcie, PCIE_HIP06_CTRL_OFF + | ||
125 | PCIE_SYS_STATE4); | ||
126 | |||
127 | return ((val & PCIE_LTSSM_STATE_MASK) == PCIE_LTSSM_LINKUP_STATE); | ||
128 | } | ||
129 | |||
130 | static int hisi_pcie_link_up(struct pcie_port *pp) | ||
131 | { | ||
132 | struct hisi_pcie *hisi_pcie = to_hisi_pcie(pp); | ||
133 | |||
134 | return hisi_pcie->soc_ops->hisi_pcie_link_up(hisi_pcie); | ||
135 | } | ||
136 | |||
110 | static struct pcie_host_ops hisi_pcie_host_ops = { | 137 | static struct pcie_host_ops hisi_pcie_host_ops = { |
111 | .rd_own_conf = hisi_pcie_cfg_read, | 138 | .rd_own_conf = hisi_pcie_cfg_read, |
112 | .wr_own_conf = hisi_pcie_cfg_write, | 139 | .wr_own_conf = hisi_pcie_cfg_write, |
@@ -145,7 +172,9 @@ static int hisi_pcie_probe(struct platform_device *pdev) | |||
145 | { | 172 | { |
146 | struct hisi_pcie *hisi_pcie; | 173 | struct hisi_pcie *hisi_pcie; |
147 | struct pcie_port *pp; | 174 | struct pcie_port *pp; |
175 | const struct of_device_id *match; | ||
148 | struct resource *reg; | 176 | struct resource *reg; |
177 | struct device_driver *driver; | ||
149 | int ret; | 178 | int ret; |
150 | 179 | ||
151 | hisi_pcie = devm_kzalloc(&pdev->dev, sizeof(*hisi_pcie), GFP_KERNEL); | 180 | hisi_pcie = devm_kzalloc(&pdev->dev, sizeof(*hisi_pcie), GFP_KERNEL); |
@@ -154,6 +183,10 @@ static int hisi_pcie_probe(struct platform_device *pdev) | |||
154 | 183 | ||
155 | pp = &hisi_pcie->pp; | 184 | pp = &hisi_pcie->pp; |
156 | pp->dev = &pdev->dev; | 185 | pp->dev = &pdev->dev; |
186 | driver = (pdev->dev).driver; | ||
187 | |||
188 | match = of_match_device(driver->of_match_table, &pdev->dev); | ||
189 | hisi_pcie->soc_ops = (struct pcie_soc_ops *) match->data; | ||
157 | 190 | ||
158 | hisi_pcie->subctrl = | 191 | hisi_pcie->subctrl = |
159 | syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl"); | 192 | syscon_regmap_lookup_by_compatible("hisilicon,pcie-sas-subctrl"); |
@@ -182,11 +215,27 @@ static int hisi_pcie_probe(struct platform_device *pdev) | |||
182 | return 0; | 215 | return 0; |
183 | } | 216 | } |
184 | 217 | ||
218 | static struct pcie_soc_ops hip05_ops = { | ||
219 | &hisi_pcie_link_up_hip05 | ||
220 | }; | ||
221 | |||
222 | static struct pcie_soc_ops hip06_ops = { | ||
223 | &hisi_pcie_link_up_hip06 | ||
224 | }; | ||
225 | |||
185 | static const struct of_device_id hisi_pcie_of_match[] = { | 226 | static const struct of_device_id hisi_pcie_of_match[] = { |
186 | {.compatible = "hisilicon,hip05-pcie",}, | 227 | { |
228 | .compatible = "hisilicon,hip05-pcie", | ||
229 | .data = (void *) &hip05_ops, | ||
230 | }, | ||
231 | { | ||
232 | .compatible = "hisilicon,hip06-pcie", | ||
233 | .data = (void *) &hip06_ops, | ||
234 | }, | ||
187 | {}, | 235 | {}, |
188 | }; | 236 | }; |
189 | 237 | ||
238 | |||
190 | MODULE_DEVICE_TABLE(of, hisi_pcie_of_match); | 239 | MODULE_DEVICE_TABLE(of, hisi_pcie_of_match); |
191 | 240 | ||
192 | static struct platform_driver hisi_pcie_driver = { | 241 | static struct platform_driver hisi_pcie_driver = { |
@@ -198,3 +247,8 @@ static struct platform_driver hisi_pcie_driver = { | |||
198 | }; | 247 | }; |
199 | 248 | ||
200 | module_platform_driver(hisi_pcie_driver); | 249 | module_platform_driver(hisi_pcie_driver); |
250 | |||
251 | MODULE_AUTHOR("Zhou Wang <wangzhou1@hisilicon.com>"); | ||
252 | MODULE_AUTHOR("Dacai Zhu <zhudacai@hisilicon.com>"); | ||
253 | MODULE_AUTHOR("Gabriele Paoloni <gabriele.paoloni@huawei.com>"); | ||
254 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c index 96a7d999fd5e..0d7bee4a0d26 100644 --- a/drivers/pci/host/pcie-iproc-bcma.c +++ b/drivers/pci/host/pcie-iproc-bcma.c | |||
@@ -55,6 +55,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) | |||
55 | bcma_set_drvdata(bdev, pcie); | 55 | bcma_set_drvdata(bdev, pcie); |
56 | 56 | ||
57 | pcie->base = bdev->io_addr; | 57 | pcie->base = bdev->io_addr; |
58 | pcie->base_addr = bdev->addr; | ||
58 | 59 | ||
59 | res_mem.start = bdev->addr_s[0]; | 60 | res_mem.start = bdev->addr_s[0]; |
60 | res_mem.end = bdev->addr_s[0] + SZ_128M - 1; | 61 | res_mem.end = bdev->addr_s[0] + SZ_128M - 1; |
diff --git a/drivers/pci/host/pcie-iproc-msi.c b/drivers/pci/host/pcie-iproc-msi.c new file mode 100644 index 000000000000..9a2973bdc78a --- /dev/null +++ b/drivers/pci/host/pcie-iproc-msi.c | |||
@@ -0,0 +1,675 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Broadcom Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/irqchip/chained_irq.h> | ||
16 | #include <linux/irqdomain.h> | ||
17 | #include <linux/msi.h> | ||
18 | #include <linux/of_irq.h> | ||
19 | #include <linux/of_pci.h> | ||
20 | #include <linux/pci.h> | ||
21 | |||
22 | #include "pcie-iproc.h" | ||
23 | |||
24 | #define IPROC_MSI_INTR_EN_SHIFT 11 | ||
25 | #define IPROC_MSI_INTR_EN BIT(IPROC_MSI_INTR_EN_SHIFT) | ||
26 | #define IPROC_MSI_INT_N_EVENT_SHIFT 1 | ||
27 | #define IPROC_MSI_INT_N_EVENT BIT(IPROC_MSI_INT_N_EVENT_SHIFT) | ||
28 | #define IPROC_MSI_EQ_EN_SHIFT 0 | ||
29 | #define IPROC_MSI_EQ_EN BIT(IPROC_MSI_EQ_EN_SHIFT) | ||
30 | |||
31 | #define IPROC_MSI_EQ_MASK 0x3f | ||
32 | |||
33 | /* Max number of GIC interrupts */ | ||
34 | #define NR_HW_IRQS 6 | ||
35 | |||
36 | /* Number of entries in each event queue */ | ||
37 | #define EQ_LEN 64 | ||
38 | |||
39 | /* Size of each event queue memory region */ | ||
40 | #define EQ_MEM_REGION_SIZE SZ_4K | ||
41 | |||
42 | /* Size of each MSI address region */ | ||
43 | #define MSI_MEM_REGION_SIZE SZ_4K | ||
44 | |||
45 | enum iproc_msi_reg { | ||
46 | IPROC_MSI_EQ_PAGE = 0, | ||
47 | IPROC_MSI_EQ_PAGE_UPPER, | ||
48 | IPROC_MSI_PAGE, | ||
49 | IPROC_MSI_PAGE_UPPER, | ||
50 | IPROC_MSI_CTRL, | ||
51 | IPROC_MSI_EQ_HEAD, | ||
52 | IPROC_MSI_EQ_TAIL, | ||
53 | IPROC_MSI_INTS_EN, | ||
54 | IPROC_MSI_REG_SIZE, | ||
55 | }; | ||
56 | |||
57 | struct iproc_msi; | ||
58 | |||
59 | /** | ||
60 | * iProc MSI group | ||
61 | * | ||
62 | * One MSI group is allocated per GIC interrupt, serviced by one iProc MSI | ||
63 | * event queue. | ||
64 | * | ||
65 | * @msi: pointer to iProc MSI data | ||
66 | * @gic_irq: GIC interrupt | ||
67 | * @eq: Event queue number | ||
68 | */ | ||
69 | struct iproc_msi_grp { | ||
70 | struct iproc_msi *msi; | ||
71 | int gic_irq; | ||
72 | unsigned int eq; | ||
73 | }; | ||
74 | |||
75 | /** | ||
76 | * iProc event queue based MSI | ||
77 | * | ||
78 | * Only meant to be used on platforms without MSI support integrated into the | ||
79 | * GIC. | ||
80 | * | ||
81 | * @pcie: pointer to iProc PCIe data | ||
82 | * @reg_offsets: MSI register offsets | ||
83 | * @grps: MSI groups | ||
84 | * @nr_irqs: number of total interrupts connected to GIC | ||
85 | * @nr_cpus: number of toal CPUs | ||
86 | * @has_inten_reg: indicates the MSI interrupt enable register needs to be | ||
87 | * set explicitly (required for some legacy platforms) | ||
88 | * @bitmap: MSI vector bitmap | ||
89 | * @bitmap_lock: lock to protect access to the MSI bitmap | ||
90 | * @nr_msi_vecs: total number of MSI vectors | ||
91 | * @inner_domain: inner IRQ domain | ||
92 | * @msi_domain: MSI IRQ domain | ||
93 | * @nr_eq_region: required number of 4K aligned memory region for MSI event | ||
94 | * queues | ||
95 | * @nr_msi_region: required number of 4K aligned address region for MSI posted | ||
96 | * writes | ||
97 | * @eq_cpu: pointer to allocated memory region for MSI event queues | ||
98 | * @eq_dma: DMA address of MSI event queues | ||
99 | * @msi_addr: MSI address | ||
100 | */ | ||
101 | struct iproc_msi { | ||
102 | struct iproc_pcie *pcie; | ||
103 | const u16 (*reg_offsets)[IPROC_MSI_REG_SIZE]; | ||
104 | struct iproc_msi_grp *grps; | ||
105 | int nr_irqs; | ||
106 | int nr_cpus; | ||
107 | bool has_inten_reg; | ||
108 | unsigned long *bitmap; | ||
109 | struct mutex bitmap_lock; | ||
110 | unsigned int nr_msi_vecs; | ||
111 | struct irq_domain *inner_domain; | ||
112 | struct irq_domain *msi_domain; | ||
113 | unsigned int nr_eq_region; | ||
114 | unsigned int nr_msi_region; | ||
115 | void *eq_cpu; | ||
116 | dma_addr_t eq_dma; | ||
117 | phys_addr_t msi_addr; | ||
118 | }; | ||
119 | |||
120 | static const u16 iproc_msi_reg_paxb[NR_HW_IRQS][IPROC_MSI_REG_SIZE] = { | ||
121 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x210, 0x250, 0x254, 0x208 }, | ||
122 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x214, 0x258, 0x25c, 0x208 }, | ||
123 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x218, 0x260, 0x264, 0x208 }, | ||
124 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x21c, 0x268, 0x26c, 0x208 }, | ||
125 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x220, 0x270, 0x274, 0x208 }, | ||
126 | { 0x200, 0x2c0, 0x204, 0x2c4, 0x224, 0x278, 0x27c, 0x208 }, | ||
127 | }; | ||
128 | |||
129 | static const u16 iproc_msi_reg_paxc[NR_HW_IRQS][IPROC_MSI_REG_SIZE] = { | ||
130 | { 0xc00, 0xc04, 0xc08, 0xc0c, 0xc40, 0xc50, 0xc60 }, | ||
131 | { 0xc10, 0xc14, 0xc18, 0xc1c, 0xc44, 0xc54, 0xc64 }, | ||
132 | { 0xc20, 0xc24, 0xc28, 0xc2c, 0xc48, 0xc58, 0xc68 }, | ||
133 | { 0xc30, 0xc34, 0xc38, 0xc3c, 0xc4c, 0xc5c, 0xc6c }, | ||
134 | }; | ||
135 | |||
136 | static inline u32 iproc_msi_read_reg(struct iproc_msi *msi, | ||
137 | enum iproc_msi_reg reg, | ||
138 | unsigned int eq) | ||
139 | { | ||
140 | struct iproc_pcie *pcie = msi->pcie; | ||
141 | |||
142 | return readl_relaxed(pcie->base + msi->reg_offsets[eq][reg]); | ||
143 | } | ||
144 | |||
145 | static inline void iproc_msi_write_reg(struct iproc_msi *msi, | ||
146 | enum iproc_msi_reg reg, | ||
147 | int eq, u32 val) | ||
148 | { | ||
149 | struct iproc_pcie *pcie = msi->pcie; | ||
150 | |||
151 | writel_relaxed(val, pcie->base + msi->reg_offsets[eq][reg]); | ||
152 | } | ||
153 | |||
154 | static inline u32 hwirq_to_group(struct iproc_msi *msi, unsigned long hwirq) | ||
155 | { | ||
156 | return (hwirq % msi->nr_irqs); | ||
157 | } | ||
158 | |||
159 | static inline unsigned int iproc_msi_addr_offset(struct iproc_msi *msi, | ||
160 | unsigned long hwirq) | ||
161 | { | ||
162 | if (msi->nr_msi_region > 1) | ||
163 | return hwirq_to_group(msi, hwirq) * MSI_MEM_REGION_SIZE; | ||
164 | else | ||
165 | return hwirq_to_group(msi, hwirq) * sizeof(u32); | ||
166 | } | ||
167 | |||
168 | static inline unsigned int iproc_msi_eq_offset(struct iproc_msi *msi, u32 eq) | ||
169 | { | ||
170 | if (msi->nr_eq_region > 1) | ||
171 | return eq * EQ_MEM_REGION_SIZE; | ||
172 | else | ||
173 | return eq * EQ_LEN * sizeof(u32); | ||
174 | } | ||
175 | |||
176 | static struct irq_chip iproc_msi_irq_chip = { | ||
177 | .name = "iProc-MSI", | ||
178 | }; | ||
179 | |||
180 | static struct msi_domain_info iproc_msi_domain_info = { | ||
181 | .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | | ||
182 | MSI_FLAG_PCI_MSIX, | ||
183 | .chip = &iproc_msi_irq_chip, | ||
184 | }; | ||
185 | |||
186 | /* | ||
187 | * In iProc PCIe core, each MSI group is serviced by a GIC interrupt and a | ||
188 | * dedicated event queue. Each MSI group can support up to 64 MSI vectors. | ||
189 | * | ||
190 | * The number of MSI groups varies between different iProc SoCs. The total | ||
191 | * number of CPU cores also varies. To support MSI IRQ affinity, we | ||
192 | * distribute GIC interrupts across all available CPUs. MSI vector is moved | ||
193 | * from one GIC interrupt to another to steer to the target CPU. | ||
194 | * | ||
195 | * Assuming: | ||
196 | * - the number of MSI groups is M | ||
197 | * - the number of CPU cores is N | ||
198 | * - M is always a multiple of N | ||
199 | * | ||
200 | * Total number of raw MSI vectors = M * 64 | ||
201 | * Total number of supported MSI vectors = (M * 64) / N | ||
202 | */ | ||
203 | static inline int hwirq_to_cpu(struct iproc_msi *msi, unsigned long hwirq) | ||
204 | { | ||
205 | return (hwirq % msi->nr_cpus); | ||
206 | } | ||
207 | |||
208 | static inline unsigned long hwirq_to_canonical_hwirq(struct iproc_msi *msi, | ||
209 | unsigned long hwirq) | ||
210 | { | ||
211 | return (hwirq - hwirq_to_cpu(msi, hwirq)); | ||
212 | } | ||
213 | |||
214 | static int iproc_msi_irq_set_affinity(struct irq_data *data, | ||
215 | const struct cpumask *mask, bool force) | ||
216 | { | ||
217 | struct iproc_msi *msi = irq_data_get_irq_chip_data(data); | ||
218 | int target_cpu = cpumask_first(mask); | ||
219 | int curr_cpu; | ||
220 | |||
221 | curr_cpu = hwirq_to_cpu(msi, data->hwirq); | ||
222 | if (curr_cpu == target_cpu) | ||
223 | return IRQ_SET_MASK_OK_DONE; | ||
224 | |||
225 | /* steer MSI to the target CPU */ | ||
226 | data->hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq) + target_cpu; | ||
227 | |||
228 | return IRQ_SET_MASK_OK; | ||
229 | } | ||
230 | |||
231 | static void iproc_msi_irq_compose_msi_msg(struct irq_data *data, | ||
232 | struct msi_msg *msg) | ||
233 | { | ||
234 | struct iproc_msi *msi = irq_data_get_irq_chip_data(data); | ||
235 | dma_addr_t addr; | ||
236 | |||
237 | addr = msi->msi_addr + iproc_msi_addr_offset(msi, data->hwirq); | ||
238 | msg->address_lo = lower_32_bits(addr); | ||
239 | msg->address_hi = upper_32_bits(addr); | ||
240 | msg->data = data->hwirq; | ||
241 | } | ||
242 | |||
243 | static struct irq_chip iproc_msi_bottom_irq_chip = { | ||
244 | .name = "MSI", | ||
245 | .irq_set_affinity = iproc_msi_irq_set_affinity, | ||
246 | .irq_compose_msi_msg = iproc_msi_irq_compose_msi_msg, | ||
247 | }; | ||
248 | |||
249 | static int iproc_msi_irq_domain_alloc(struct irq_domain *domain, | ||
250 | unsigned int virq, unsigned int nr_irqs, | ||
251 | void *args) | ||
252 | { | ||
253 | struct iproc_msi *msi = domain->host_data; | ||
254 | int hwirq; | ||
255 | |||
256 | mutex_lock(&msi->bitmap_lock); | ||
257 | |||
258 | /* Allocate 'nr_cpus' number of MSI vectors each time */ | ||
259 | hwirq = bitmap_find_next_zero_area(msi->bitmap, msi->nr_msi_vecs, 0, | ||
260 | msi->nr_cpus, 0); | ||
261 | if (hwirq < msi->nr_msi_vecs) { | ||
262 | bitmap_set(msi->bitmap, hwirq, msi->nr_cpus); | ||
263 | } else { | ||
264 | mutex_unlock(&msi->bitmap_lock); | ||
265 | return -ENOSPC; | ||
266 | } | ||
267 | |||
268 | mutex_unlock(&msi->bitmap_lock); | ||
269 | |||
270 | irq_domain_set_info(domain, virq, hwirq, &iproc_msi_bottom_irq_chip, | ||
271 | domain->host_data, handle_simple_irq, NULL, NULL); | ||
272 | |||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static void iproc_msi_irq_domain_free(struct irq_domain *domain, | ||
277 | unsigned int virq, unsigned int nr_irqs) | ||
278 | { | ||
279 | struct irq_data *data = irq_domain_get_irq_data(domain, virq); | ||
280 | struct iproc_msi *msi = irq_data_get_irq_chip_data(data); | ||
281 | unsigned int hwirq; | ||
282 | |||
283 | mutex_lock(&msi->bitmap_lock); | ||
284 | |||
285 | hwirq = hwirq_to_canonical_hwirq(msi, data->hwirq); | ||
286 | bitmap_clear(msi->bitmap, hwirq, msi->nr_cpus); | ||
287 | |||
288 | mutex_unlock(&msi->bitmap_lock); | ||
289 | |||
290 | irq_domain_free_irqs_parent(domain, virq, nr_irqs); | ||
291 | } | ||
292 | |||
293 | static const struct irq_domain_ops msi_domain_ops = { | ||
294 | .alloc = iproc_msi_irq_domain_alloc, | ||
295 | .free = iproc_msi_irq_domain_free, | ||
296 | }; | ||
297 | |||
298 | static inline u32 decode_msi_hwirq(struct iproc_msi *msi, u32 eq, u32 head) | ||
299 | { | ||
300 | u32 *msg, hwirq; | ||
301 | unsigned int offs; | ||
302 | |||
303 | offs = iproc_msi_eq_offset(msi, eq) + head * sizeof(u32); | ||
304 | msg = (u32 *)(msi->eq_cpu + offs); | ||
305 | hwirq = *msg & IPROC_MSI_EQ_MASK; | ||
306 | |||
307 | /* | ||
308 | * Since we have multiple hwirq mapped to a single MSI vector, | ||
309 | * now we need to derive the hwirq at CPU0. It can then be used to | ||
310 | * mapped back to virq. | ||
311 | */ | ||
312 | return hwirq_to_canonical_hwirq(msi, hwirq); | ||
313 | } | ||
314 | |||
315 | static void iproc_msi_handler(struct irq_desc *desc) | ||
316 | { | ||
317 | struct irq_chip *chip = irq_desc_get_chip(desc); | ||
318 | struct iproc_msi_grp *grp; | ||
319 | struct iproc_msi *msi; | ||
320 | struct iproc_pcie *pcie; | ||
321 | u32 eq, head, tail, nr_events; | ||
322 | unsigned long hwirq; | ||
323 | int virq; | ||
324 | |||
325 | chained_irq_enter(chip, desc); | ||
326 | |||
327 | grp = irq_desc_get_handler_data(desc); | ||
328 | msi = grp->msi; | ||
329 | pcie = msi->pcie; | ||
330 | eq = grp->eq; | ||
331 | |||
332 | /* | ||
333 | * iProc MSI event queue is tracked by head and tail pointers. Head | ||
334 | * pointer indicates the next entry (MSI data) to be consumed by SW in | ||
335 | * the queue and needs to be updated by SW. iProc MSI core uses the | ||
336 | * tail pointer as the next data insertion point. | ||
337 | * | ||
338 | * Entries between head and tail pointers contain valid MSI data. MSI | ||
339 | * data is guaranteed to be in the event queue memory before the tail | ||
340 | * pointer is updated by the iProc MSI core. | ||
341 | */ | ||
342 | head = iproc_msi_read_reg(msi, IPROC_MSI_EQ_HEAD, | ||
343 | eq) & IPROC_MSI_EQ_MASK; | ||
344 | do { | ||
345 | tail = iproc_msi_read_reg(msi, IPROC_MSI_EQ_TAIL, | ||
346 | eq) & IPROC_MSI_EQ_MASK; | ||
347 | |||
348 | /* | ||
349 | * Figure out total number of events (MSI data) to be | ||
350 | * processed. | ||
351 | */ | ||
352 | nr_events = (tail < head) ? | ||
353 | (EQ_LEN - (head - tail)) : (tail - head); | ||
354 | if (!nr_events) | ||
355 | break; | ||
356 | |||
357 | /* process all outstanding events */ | ||
358 | while (nr_events--) { | ||
359 | hwirq = decode_msi_hwirq(msi, eq, head); | ||
360 | virq = irq_find_mapping(msi->inner_domain, hwirq); | ||
361 | generic_handle_irq(virq); | ||
362 | |||
363 | head++; | ||
364 | head %= EQ_LEN; | ||
365 | } | ||
366 | |||
367 | /* | ||
368 | * Now all outstanding events have been processed. Update the | ||
369 | * head pointer. | ||
370 | */ | ||
371 | iproc_msi_write_reg(msi, IPROC_MSI_EQ_HEAD, eq, head); | ||
372 | |||
373 | /* | ||
374 | * Now go read the tail pointer again to see if there are new | ||
375 | * oustanding events that came in during the above window. | ||
376 | */ | ||
377 | } while (true); | ||
378 | |||
379 | chained_irq_exit(chip, desc); | ||
380 | } | ||
381 | |||
382 | static void iproc_msi_enable(struct iproc_msi *msi) | ||
383 | { | ||
384 | int i, eq; | ||
385 | u32 val; | ||
386 | |||
387 | /* Program memory region for each event queue */ | ||
388 | for (i = 0; i < msi->nr_eq_region; i++) { | ||
389 | dma_addr_t addr = msi->eq_dma + (i * EQ_MEM_REGION_SIZE); | ||
390 | |||
391 | iproc_msi_write_reg(msi, IPROC_MSI_EQ_PAGE, i, | ||
392 | lower_32_bits(addr)); | ||
393 | iproc_msi_write_reg(msi, IPROC_MSI_EQ_PAGE_UPPER, i, | ||
394 | upper_32_bits(addr)); | ||
395 | } | ||
396 | |||
397 | /* Program address region for MSI posted writes */ | ||
398 | for (i = 0; i < msi->nr_msi_region; i++) { | ||
399 | phys_addr_t addr = msi->msi_addr + (i * MSI_MEM_REGION_SIZE); | ||
400 | |||
401 | iproc_msi_write_reg(msi, IPROC_MSI_PAGE, i, | ||
402 | lower_32_bits(addr)); | ||
403 | iproc_msi_write_reg(msi, IPROC_MSI_PAGE_UPPER, i, | ||
404 | upper_32_bits(addr)); | ||
405 | } | ||
406 | |||
407 | for (eq = 0; eq < msi->nr_irqs; eq++) { | ||
408 | /* Enable MSI event queue */ | ||
409 | val = IPROC_MSI_INTR_EN | IPROC_MSI_INT_N_EVENT | | ||
410 | IPROC_MSI_EQ_EN; | ||
411 | iproc_msi_write_reg(msi, IPROC_MSI_CTRL, eq, val); | ||
412 | |||
413 | /* | ||
414 | * Some legacy platforms require the MSI interrupt enable | ||
415 | * register to be set explicitly. | ||
416 | */ | ||
417 | if (msi->has_inten_reg) { | ||
418 | val = iproc_msi_read_reg(msi, IPROC_MSI_INTS_EN, eq); | ||
419 | val |= BIT(eq); | ||
420 | iproc_msi_write_reg(msi, IPROC_MSI_INTS_EN, eq, val); | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | |||
425 | static void iproc_msi_disable(struct iproc_msi *msi) | ||
426 | { | ||
427 | u32 eq, val; | ||
428 | |||
429 | for (eq = 0; eq < msi->nr_irqs; eq++) { | ||
430 | if (msi->has_inten_reg) { | ||
431 | val = iproc_msi_read_reg(msi, IPROC_MSI_INTS_EN, eq); | ||
432 | val &= ~BIT(eq); | ||
433 | iproc_msi_write_reg(msi, IPROC_MSI_INTS_EN, eq, val); | ||
434 | } | ||
435 | |||
436 | val = iproc_msi_read_reg(msi, IPROC_MSI_CTRL, eq); | ||
437 | val &= ~(IPROC_MSI_INTR_EN | IPROC_MSI_INT_N_EVENT | | ||
438 | IPROC_MSI_EQ_EN); | ||
439 | iproc_msi_write_reg(msi, IPROC_MSI_CTRL, eq, val); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | static int iproc_msi_alloc_domains(struct device_node *node, | ||
444 | struct iproc_msi *msi) | ||
445 | { | ||
446 | msi->inner_domain = irq_domain_add_linear(NULL, msi->nr_msi_vecs, | ||
447 | &msi_domain_ops, msi); | ||
448 | if (!msi->inner_domain) | ||
449 | return -ENOMEM; | ||
450 | |||
451 | msi->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(node), | ||
452 | &iproc_msi_domain_info, | ||
453 | msi->inner_domain); | ||
454 | if (!msi->msi_domain) { | ||
455 | irq_domain_remove(msi->inner_domain); | ||
456 | return -ENOMEM; | ||
457 | } | ||
458 | |||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | static void iproc_msi_free_domains(struct iproc_msi *msi) | ||
463 | { | ||
464 | if (msi->msi_domain) | ||
465 | irq_domain_remove(msi->msi_domain); | ||
466 | |||
467 | if (msi->inner_domain) | ||
468 | irq_domain_remove(msi->inner_domain); | ||
469 | } | ||
470 | |||
471 | static void iproc_msi_irq_free(struct iproc_msi *msi, unsigned int cpu) | ||
472 | { | ||
473 | int i; | ||
474 | |||
475 | for (i = cpu; i < msi->nr_irqs; i += msi->nr_cpus) { | ||
476 | irq_set_chained_handler_and_data(msi->grps[i].gic_irq, | ||
477 | NULL, NULL); | ||
478 | } | ||
479 | } | ||
480 | |||
481 | static int iproc_msi_irq_setup(struct iproc_msi *msi, unsigned int cpu) | ||
482 | { | ||
483 | int i, ret; | ||
484 | cpumask_var_t mask; | ||
485 | struct iproc_pcie *pcie = msi->pcie; | ||
486 | |||
487 | for (i = cpu; i < msi->nr_irqs; i += msi->nr_cpus) { | ||
488 | irq_set_chained_handler_and_data(msi->grps[i].gic_irq, | ||
489 | iproc_msi_handler, | ||
490 | &msi->grps[i]); | ||
491 | /* Dedicate GIC interrupt to each CPU core */ | ||
492 | if (alloc_cpumask_var(&mask, GFP_KERNEL)) { | ||
493 | cpumask_clear(mask); | ||
494 | cpumask_set_cpu(cpu, mask); | ||
495 | ret = irq_set_affinity(msi->grps[i].gic_irq, mask); | ||
496 | if (ret) | ||
497 | dev_err(pcie->dev, | ||
498 | "failed to set affinity for IRQ%d\n", | ||
499 | msi->grps[i].gic_irq); | ||
500 | free_cpumask_var(mask); | ||
501 | } else { | ||
502 | dev_err(pcie->dev, "failed to alloc CPU mask\n"); | ||
503 | ret = -EINVAL; | ||
504 | } | ||
505 | |||
506 | if (ret) { | ||
507 | /* Free all configured/unconfigured IRQs */ | ||
508 | iproc_msi_irq_free(msi, cpu); | ||
509 | return ret; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | return 0; | ||
514 | } | ||
515 | |||
516 | int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node) | ||
517 | { | ||
518 | struct iproc_msi *msi; | ||
519 | int i, ret; | ||
520 | unsigned int cpu; | ||
521 | |||
522 | if (!of_device_is_compatible(node, "brcm,iproc-msi")) | ||
523 | return -ENODEV; | ||
524 | |||
525 | if (!of_find_property(node, "msi-controller", NULL)) | ||
526 | return -ENODEV; | ||
527 | |||
528 | if (pcie->msi) | ||
529 | return -EBUSY; | ||
530 | |||
531 | msi = devm_kzalloc(pcie->dev, sizeof(*msi), GFP_KERNEL); | ||
532 | if (!msi) | ||
533 | return -ENOMEM; | ||
534 | |||
535 | msi->pcie = pcie; | ||
536 | pcie->msi = msi; | ||
537 | msi->msi_addr = pcie->base_addr; | ||
538 | mutex_init(&msi->bitmap_lock); | ||
539 | msi->nr_cpus = num_possible_cpus(); | ||
540 | |||
541 | msi->nr_irqs = of_irq_count(node); | ||
542 | if (!msi->nr_irqs) { | ||
543 | dev_err(pcie->dev, "found no MSI GIC interrupt\n"); | ||
544 | return -ENODEV; | ||
545 | } | ||
546 | |||
547 | if (msi->nr_irqs > NR_HW_IRQS) { | ||
548 | dev_warn(pcie->dev, "too many MSI GIC interrupts defined %d\n", | ||
549 | msi->nr_irqs); | ||
550 | msi->nr_irqs = NR_HW_IRQS; | ||
551 | } | ||
552 | |||
553 | if (msi->nr_irqs < msi->nr_cpus) { | ||
554 | dev_err(pcie->dev, | ||
555 | "not enough GIC interrupts for MSI affinity\n"); | ||
556 | return -EINVAL; | ||
557 | } | ||
558 | |||
559 | if (msi->nr_irqs % msi->nr_cpus != 0) { | ||
560 | msi->nr_irqs -= msi->nr_irqs % msi->nr_cpus; | ||
561 | dev_warn(pcie->dev, "Reducing number of interrupts to %d\n", | ||
562 | msi->nr_irqs); | ||
563 | } | ||
564 | |||
565 | switch (pcie->type) { | ||
566 | case IPROC_PCIE_PAXB: | ||
567 | msi->reg_offsets = iproc_msi_reg_paxb; | ||
568 | msi->nr_eq_region = 1; | ||
569 | msi->nr_msi_region = 1; | ||
570 | break; | ||
571 | case IPROC_PCIE_PAXC: | ||
572 | msi->reg_offsets = iproc_msi_reg_paxc; | ||
573 | msi->nr_eq_region = msi->nr_irqs; | ||
574 | msi->nr_msi_region = msi->nr_irqs; | ||
575 | break; | ||
576 | default: | ||
577 | dev_err(pcie->dev, "incompatible iProc PCIe interface\n"); | ||
578 | return -EINVAL; | ||
579 | } | ||
580 | |||
581 | if (of_find_property(node, "brcm,pcie-msi-inten", NULL)) | ||
582 | msi->has_inten_reg = true; | ||
583 | |||
584 | msi->nr_msi_vecs = msi->nr_irqs * EQ_LEN; | ||
585 | msi->bitmap = devm_kcalloc(pcie->dev, BITS_TO_LONGS(msi->nr_msi_vecs), | ||
586 | sizeof(*msi->bitmap), GFP_KERNEL); | ||
587 | if (!msi->bitmap) | ||
588 | return -ENOMEM; | ||
589 | |||
590 | msi->grps = devm_kcalloc(pcie->dev, msi->nr_irqs, sizeof(*msi->grps), | ||
591 | GFP_KERNEL); | ||
592 | if (!msi->grps) | ||
593 | return -ENOMEM; | ||
594 | |||
595 | for (i = 0; i < msi->nr_irqs; i++) { | ||
596 | unsigned int irq = irq_of_parse_and_map(node, i); | ||
597 | |||
598 | if (!irq) { | ||
599 | dev_err(pcie->dev, "unable to parse/map interrupt\n"); | ||
600 | ret = -ENODEV; | ||
601 | goto free_irqs; | ||
602 | } | ||
603 | msi->grps[i].gic_irq = irq; | ||
604 | msi->grps[i].msi = msi; | ||
605 | msi->grps[i].eq = i; | ||
606 | } | ||
607 | |||
608 | /* Reserve memory for event queue and make sure memories are zeroed */ | ||
609 | msi->eq_cpu = dma_zalloc_coherent(pcie->dev, | ||
610 | msi->nr_eq_region * EQ_MEM_REGION_SIZE, | ||
611 | &msi->eq_dma, GFP_KERNEL); | ||
612 | if (!msi->eq_cpu) { | ||
613 | ret = -ENOMEM; | ||
614 | goto free_irqs; | ||
615 | } | ||
616 | |||
617 | ret = iproc_msi_alloc_domains(node, msi); | ||
618 | if (ret) { | ||
619 | dev_err(pcie->dev, "failed to create MSI domains\n"); | ||
620 | goto free_eq_dma; | ||
621 | } | ||
622 | |||
623 | for_each_online_cpu(cpu) { | ||
624 | ret = iproc_msi_irq_setup(msi, cpu); | ||
625 | if (ret) | ||
626 | goto free_msi_irq; | ||
627 | } | ||
628 | |||
629 | iproc_msi_enable(msi); | ||
630 | |||
631 | return 0; | ||
632 | |||
633 | free_msi_irq: | ||
634 | for_each_online_cpu(cpu) | ||
635 | iproc_msi_irq_free(msi, cpu); | ||
636 | iproc_msi_free_domains(msi); | ||
637 | |||
638 | free_eq_dma: | ||
639 | dma_free_coherent(pcie->dev, msi->nr_eq_region * EQ_MEM_REGION_SIZE, | ||
640 | msi->eq_cpu, msi->eq_dma); | ||
641 | |||
642 | free_irqs: | ||
643 | for (i = 0; i < msi->nr_irqs; i++) { | ||
644 | if (msi->grps[i].gic_irq) | ||
645 | irq_dispose_mapping(msi->grps[i].gic_irq); | ||
646 | } | ||
647 | pcie->msi = NULL; | ||
648 | return ret; | ||
649 | } | ||
650 | EXPORT_SYMBOL(iproc_msi_init); | ||
651 | |||
652 | void iproc_msi_exit(struct iproc_pcie *pcie) | ||
653 | { | ||
654 | struct iproc_msi *msi = pcie->msi; | ||
655 | unsigned int i, cpu; | ||
656 | |||
657 | if (!msi) | ||
658 | return; | ||
659 | |||
660 | iproc_msi_disable(msi); | ||
661 | |||
662 | for_each_online_cpu(cpu) | ||
663 | iproc_msi_irq_free(msi, cpu); | ||
664 | |||
665 | iproc_msi_free_domains(msi); | ||
666 | |||
667 | dma_free_coherent(pcie->dev, msi->nr_eq_region * EQ_MEM_REGION_SIZE, | ||
668 | msi->eq_cpu, msi->eq_dma); | ||
669 | |||
670 | for (i = 0; i < msi->nr_irqs; i++) { | ||
671 | if (msi->grps[i].gic_irq) | ||
672 | irq_dispose_mapping(msi->grps[i].gic_irq); | ||
673 | } | ||
674 | } | ||
675 | EXPORT_SYMBOL(iproc_msi_exit); | ||
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index c9550dc8b8ed..1738c5288eb6 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c | |||
@@ -26,8 +26,21 @@ | |||
26 | 26 | ||
27 | #include "pcie-iproc.h" | 27 | #include "pcie-iproc.h" |
28 | 28 | ||
29 | static const struct of_device_id iproc_pcie_of_match_table[] = { | ||
30 | { | ||
31 | .compatible = "brcm,iproc-pcie", | ||
32 | .data = (int *)IPROC_PCIE_PAXB, | ||
33 | }, { | ||
34 | .compatible = "brcm,iproc-pcie-paxc", | ||
35 | .data = (int *)IPROC_PCIE_PAXC, | ||
36 | }, | ||
37 | { /* sentinel */ } | ||
38 | }; | ||
39 | MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); | ||
40 | |||
29 | static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | 41 | static int iproc_pcie_pltfm_probe(struct platform_device *pdev) |
30 | { | 42 | { |
43 | const struct of_device_id *of_id; | ||
31 | struct iproc_pcie *pcie; | 44 | struct iproc_pcie *pcie; |
32 | struct device_node *np = pdev->dev.of_node; | 45 | struct device_node *np = pdev->dev.of_node; |
33 | struct resource reg; | 46 | struct resource reg; |
@@ -35,11 +48,16 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
35 | LIST_HEAD(res); | 48 | LIST_HEAD(res); |
36 | int ret; | 49 | int ret; |
37 | 50 | ||
51 | of_id = of_match_device(iproc_pcie_of_match_table, &pdev->dev); | ||
52 | if (!of_id) | ||
53 | return -EINVAL; | ||
54 | |||
38 | pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); | 55 | pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); |
39 | if (!pcie) | 56 | if (!pcie) |
40 | return -ENOMEM; | 57 | return -ENOMEM; |
41 | 58 | ||
42 | pcie->dev = &pdev->dev; | 59 | pcie->dev = &pdev->dev; |
60 | pcie->type = (enum iproc_pcie_type)of_id->data; | ||
43 | platform_set_drvdata(pdev, pcie); | 61 | platform_set_drvdata(pdev, pcie); |
44 | 62 | ||
45 | ret = of_address_to_resource(np, 0, ®); | 63 | ret = of_address_to_resource(np, 0, ®); |
@@ -53,6 +71,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
53 | dev_err(pcie->dev, "unable to map controller registers\n"); | 71 | dev_err(pcie->dev, "unable to map controller registers\n"); |
54 | return -ENOMEM; | 72 | return -ENOMEM; |
55 | } | 73 | } |
74 | pcie->base_addr = reg.start; | ||
56 | 75 | ||
57 | if (of_property_read_bool(np, "brcm,pcie-ob")) { | 76 | if (of_property_read_bool(np, "brcm,pcie-ob")) { |
58 | u32 val; | 77 | u32 val; |
@@ -114,12 +133,6 @@ static int iproc_pcie_pltfm_remove(struct platform_device *pdev) | |||
114 | return iproc_pcie_remove(pcie); | 133 | return iproc_pcie_remove(pcie); |
115 | } | 134 | } |
116 | 135 | ||
117 | static const struct of_device_id iproc_pcie_of_match_table[] = { | ||
118 | { .compatible = "brcm,iproc-pcie", }, | ||
119 | { /* sentinel */ } | ||
120 | }; | ||
121 | MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); | ||
122 | |||
123 | static struct platform_driver iproc_pcie_pltfm_driver = { | 136 | static struct platform_driver iproc_pcie_pltfm_driver = { |
124 | .driver = { | 137 | .driver = { |
125 | .name = "iproc-pcie", | 138 | .name = "iproc-pcie", |
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index eac719af16aa..5816bceddb65 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c | |||
@@ -30,20 +30,16 @@ | |||
30 | 30 | ||
31 | #include "pcie-iproc.h" | 31 | #include "pcie-iproc.h" |
32 | 32 | ||
33 | #define CLK_CONTROL_OFFSET 0x000 | ||
34 | #define EP_PERST_SOURCE_SELECT_SHIFT 2 | 33 | #define EP_PERST_SOURCE_SELECT_SHIFT 2 |
35 | #define EP_PERST_SOURCE_SELECT BIT(EP_PERST_SOURCE_SELECT_SHIFT) | 34 | #define EP_PERST_SOURCE_SELECT BIT(EP_PERST_SOURCE_SELECT_SHIFT) |
36 | #define EP_MODE_SURVIVE_PERST_SHIFT 1 | 35 | #define EP_MODE_SURVIVE_PERST_SHIFT 1 |
37 | #define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT) | 36 | #define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT) |
38 | #define RC_PCIE_RST_OUTPUT_SHIFT 0 | 37 | #define RC_PCIE_RST_OUTPUT_SHIFT 0 |
39 | #define RC_PCIE_RST_OUTPUT BIT(RC_PCIE_RST_OUTPUT_SHIFT) | 38 | #define RC_PCIE_RST_OUTPUT BIT(RC_PCIE_RST_OUTPUT_SHIFT) |
39 | #define PAXC_RESET_MASK 0x7f | ||
40 | 40 | ||
41 | #define CFG_IND_ADDR_OFFSET 0x120 | ||
42 | #define CFG_IND_ADDR_MASK 0x00001ffc | 41 | #define CFG_IND_ADDR_MASK 0x00001ffc |
43 | 42 | ||
44 | #define CFG_IND_DATA_OFFSET 0x124 | ||
45 | |||
46 | #define CFG_ADDR_OFFSET 0x1f8 | ||
47 | #define CFG_ADDR_BUS_NUM_SHIFT 20 | 43 | #define CFG_ADDR_BUS_NUM_SHIFT 20 |
48 | #define CFG_ADDR_BUS_NUM_MASK 0x0ff00000 | 44 | #define CFG_ADDR_BUS_NUM_MASK 0x0ff00000 |
49 | #define CFG_ADDR_DEV_NUM_SHIFT 15 | 45 | #define CFG_ADDR_DEV_NUM_SHIFT 15 |
@@ -55,12 +51,8 @@ | |||
55 | #define CFG_ADDR_CFG_TYPE_SHIFT 0 | 51 | #define CFG_ADDR_CFG_TYPE_SHIFT 0 |
56 | #define CFG_ADDR_CFG_TYPE_MASK 0x00000003 | 52 | #define CFG_ADDR_CFG_TYPE_MASK 0x00000003 |
57 | 53 | ||
58 | #define CFG_DATA_OFFSET 0x1fc | ||
59 | |||
60 | #define SYS_RC_INTX_EN 0x330 | ||
61 | #define SYS_RC_INTX_MASK 0xf | 54 | #define SYS_RC_INTX_MASK 0xf |
62 | 55 | ||
63 | #define PCIE_LINK_STATUS_OFFSET 0xf0c | ||
64 | #define PCIE_PHYLINKUP_SHIFT 3 | 56 | #define PCIE_PHYLINKUP_SHIFT 3 |
65 | #define PCIE_PHYLINKUP BIT(PCIE_PHYLINKUP_SHIFT) | 57 | #define PCIE_PHYLINKUP BIT(PCIE_PHYLINKUP_SHIFT) |
66 | #define PCIE_DL_ACTIVE_SHIFT 2 | 58 | #define PCIE_DL_ACTIVE_SHIFT 2 |
@@ -71,12 +63,54 @@ | |||
71 | #define OARR_SIZE_CFG_SHIFT 1 | 63 | #define OARR_SIZE_CFG_SHIFT 1 |
72 | #define OARR_SIZE_CFG BIT(OARR_SIZE_CFG_SHIFT) | 64 | #define OARR_SIZE_CFG BIT(OARR_SIZE_CFG_SHIFT) |
73 | 65 | ||
74 | #define OARR_LO(window) (0xd20 + (window) * 8) | ||
75 | #define OARR_HI(window) (0xd24 + (window) * 8) | ||
76 | #define OMAP_LO(window) (0xd40 + (window) * 8) | ||
77 | #define OMAP_HI(window) (0xd44 + (window) * 8) | ||
78 | |||
79 | #define MAX_NUM_OB_WINDOWS 2 | 66 | #define MAX_NUM_OB_WINDOWS 2 |
67 | #define MAX_NUM_PAXC_PF 4 | ||
68 | |||
69 | #define IPROC_PCIE_REG_INVALID 0xffff | ||
70 | |||
71 | enum iproc_pcie_reg { | ||
72 | IPROC_PCIE_CLK_CTRL = 0, | ||
73 | IPROC_PCIE_CFG_IND_ADDR, | ||
74 | IPROC_PCIE_CFG_IND_DATA, | ||
75 | IPROC_PCIE_CFG_ADDR, | ||
76 | IPROC_PCIE_CFG_DATA, | ||
77 | IPROC_PCIE_INTX_EN, | ||
78 | IPROC_PCIE_OARR_LO, | ||
79 | IPROC_PCIE_OARR_HI, | ||
80 | IPROC_PCIE_OMAP_LO, | ||
81 | IPROC_PCIE_OMAP_HI, | ||
82 | IPROC_PCIE_LINK_STATUS, | ||
83 | }; | ||
84 | |||
85 | /* iProc PCIe PAXB registers */ | ||
86 | static const u16 iproc_pcie_reg_paxb[] = { | ||
87 | [IPROC_PCIE_CLK_CTRL] = 0x000, | ||
88 | [IPROC_PCIE_CFG_IND_ADDR] = 0x120, | ||
89 | [IPROC_PCIE_CFG_IND_DATA] = 0x124, | ||
90 | [IPROC_PCIE_CFG_ADDR] = 0x1f8, | ||
91 | [IPROC_PCIE_CFG_DATA] = 0x1fc, | ||
92 | [IPROC_PCIE_INTX_EN] = 0x330, | ||
93 | [IPROC_PCIE_OARR_LO] = 0xd20, | ||
94 | [IPROC_PCIE_OARR_HI] = 0xd24, | ||
95 | [IPROC_PCIE_OMAP_LO] = 0xd40, | ||
96 | [IPROC_PCIE_OMAP_HI] = 0xd44, | ||
97 | [IPROC_PCIE_LINK_STATUS] = 0xf0c, | ||
98 | }; | ||
99 | |||
100 | /* iProc PCIe PAXC v1 registers */ | ||
101 | static const u16 iproc_pcie_reg_paxc[] = { | ||
102 | [IPROC_PCIE_CLK_CTRL] = 0x000, | ||
103 | [IPROC_PCIE_CFG_IND_ADDR] = 0x1f0, | ||
104 | [IPROC_PCIE_CFG_IND_DATA] = 0x1f4, | ||
105 | [IPROC_PCIE_CFG_ADDR] = 0x1f8, | ||
106 | [IPROC_PCIE_CFG_DATA] = 0x1fc, | ||
107 | [IPROC_PCIE_INTX_EN] = IPROC_PCIE_REG_INVALID, | ||
108 | [IPROC_PCIE_OARR_LO] = IPROC_PCIE_REG_INVALID, | ||
109 | [IPROC_PCIE_OARR_HI] = IPROC_PCIE_REG_INVALID, | ||
110 | [IPROC_PCIE_OMAP_LO] = IPROC_PCIE_REG_INVALID, | ||
111 | [IPROC_PCIE_OMAP_HI] = IPROC_PCIE_REG_INVALID, | ||
112 | [IPROC_PCIE_LINK_STATUS] = IPROC_PCIE_REG_INVALID, | ||
113 | }; | ||
80 | 114 | ||
81 | static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) | 115 | static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) |
82 | { | 116 | { |
@@ -91,6 +125,65 @@ static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) | |||
91 | return pcie; | 125 | return pcie; |
92 | } | 126 | } |
93 | 127 | ||
128 | static inline bool iproc_pcie_reg_is_invalid(u16 reg_offset) | ||
129 | { | ||
130 | return !!(reg_offset == IPROC_PCIE_REG_INVALID); | ||
131 | } | ||
132 | |||
133 | static inline u16 iproc_pcie_reg_offset(struct iproc_pcie *pcie, | ||
134 | enum iproc_pcie_reg reg) | ||
135 | { | ||
136 | return pcie->reg_offsets[reg]; | ||
137 | } | ||
138 | |||
139 | static inline u32 iproc_pcie_read_reg(struct iproc_pcie *pcie, | ||
140 | enum iproc_pcie_reg reg) | ||
141 | { | ||
142 | u16 offset = iproc_pcie_reg_offset(pcie, reg); | ||
143 | |||
144 | if (iproc_pcie_reg_is_invalid(offset)) | ||
145 | return 0; | ||
146 | |||
147 | return readl(pcie->base + offset); | ||
148 | } | ||
149 | |||
150 | static inline void iproc_pcie_write_reg(struct iproc_pcie *pcie, | ||
151 | enum iproc_pcie_reg reg, u32 val) | ||
152 | { | ||
153 | u16 offset = iproc_pcie_reg_offset(pcie, reg); | ||
154 | |||
155 | if (iproc_pcie_reg_is_invalid(offset)) | ||
156 | return; | ||
157 | |||
158 | writel(val, pcie->base + offset); | ||
159 | } | ||
160 | |||
161 | static inline void iproc_pcie_ob_write(struct iproc_pcie *pcie, | ||
162 | enum iproc_pcie_reg reg, | ||
163 | unsigned window, u32 val) | ||
164 | { | ||
165 | u16 offset = iproc_pcie_reg_offset(pcie, reg); | ||
166 | |||
167 | if (iproc_pcie_reg_is_invalid(offset)) | ||
168 | return; | ||
169 | |||
170 | writel(val, pcie->base + offset + (window * 8)); | ||
171 | } | ||
172 | |||
173 | static inline bool iproc_pcie_device_is_valid(struct iproc_pcie *pcie, | ||
174 | unsigned int slot, | ||
175 | unsigned int fn) | ||
176 | { | ||
177 | if (slot > 0) | ||
178 | return false; | ||
179 | |||
180 | /* PAXC can only support limited number of functions */ | ||
181 | if (pcie->type == IPROC_PCIE_PAXC && fn >= MAX_NUM_PAXC_PF) | ||
182 | return false; | ||
183 | |||
184 | return true; | ||
185 | } | ||
186 | |||
94 | /** | 187 | /** |
95 | * Note access to the configuration registers are protected at the higher layer | 188 | * Note access to the configuration registers are protected at the higher layer |
96 | * by 'pci_lock' in drivers/pci/access.c | 189 | * by 'pci_lock' in drivers/pci/access.c |
@@ -104,28 +197,34 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus, | |||
104 | unsigned fn = PCI_FUNC(devfn); | 197 | unsigned fn = PCI_FUNC(devfn); |
105 | unsigned busno = bus->number; | 198 | unsigned busno = bus->number; |
106 | u32 val; | 199 | u32 val; |
200 | u16 offset; | ||
201 | |||
202 | if (!iproc_pcie_device_is_valid(pcie, slot, fn)) | ||
203 | return NULL; | ||
107 | 204 | ||
108 | /* root complex access */ | 205 | /* root complex access */ |
109 | if (busno == 0) { | 206 | if (busno == 0) { |
110 | if (slot >= 1) | 207 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CFG_IND_ADDR, |
208 | where & CFG_IND_ADDR_MASK); | ||
209 | offset = iproc_pcie_reg_offset(pcie, IPROC_PCIE_CFG_IND_DATA); | ||
210 | if (iproc_pcie_reg_is_invalid(offset)) | ||
111 | return NULL; | 211 | return NULL; |
112 | writel(where & CFG_IND_ADDR_MASK, | 212 | else |
113 | pcie->base + CFG_IND_ADDR_OFFSET); | 213 | return (pcie->base + offset); |
114 | return (pcie->base + CFG_IND_DATA_OFFSET); | ||
115 | } | 214 | } |
116 | 215 | ||
117 | if (fn > 1) | ||
118 | return NULL; | ||
119 | |||
120 | /* EP device access */ | 216 | /* EP device access */ |
121 | val = (busno << CFG_ADDR_BUS_NUM_SHIFT) | | 217 | val = (busno << CFG_ADDR_BUS_NUM_SHIFT) | |
122 | (slot << CFG_ADDR_DEV_NUM_SHIFT) | | 218 | (slot << CFG_ADDR_DEV_NUM_SHIFT) | |
123 | (fn << CFG_ADDR_FUNC_NUM_SHIFT) | | 219 | (fn << CFG_ADDR_FUNC_NUM_SHIFT) | |
124 | (where & CFG_ADDR_REG_NUM_MASK) | | 220 | (where & CFG_ADDR_REG_NUM_MASK) | |
125 | (1 & CFG_ADDR_CFG_TYPE_MASK); | 221 | (1 & CFG_ADDR_CFG_TYPE_MASK); |
126 | writel(val, pcie->base + CFG_ADDR_OFFSET); | 222 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CFG_ADDR, val); |
127 | 223 | offset = iproc_pcie_reg_offset(pcie, IPROC_PCIE_CFG_DATA); | |
128 | return (pcie->base + CFG_DATA_OFFSET); | 224 | if (iproc_pcie_reg_is_invalid(offset)) |
225 | return NULL; | ||
226 | else | ||
227 | return (pcie->base + offset); | ||
129 | } | 228 | } |
130 | 229 | ||
131 | static struct pci_ops iproc_pcie_ops = { | 230 | static struct pci_ops iproc_pcie_ops = { |
@@ -138,18 +237,29 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie) | |||
138 | { | 237 | { |
139 | u32 val; | 238 | u32 val; |
140 | 239 | ||
240 | if (pcie->type == IPROC_PCIE_PAXC) { | ||
241 | val = iproc_pcie_read_reg(pcie, IPROC_PCIE_CLK_CTRL); | ||
242 | val &= ~PAXC_RESET_MASK; | ||
243 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); | ||
244 | udelay(100); | ||
245 | val |= PAXC_RESET_MASK; | ||
246 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); | ||
247 | udelay(100); | ||
248 | return; | ||
249 | } | ||
250 | |||
141 | /* | 251 | /* |
142 | * Select perst_b signal as reset source. Put the device into reset, | 252 | * Select perst_b signal as reset source. Put the device into reset, |
143 | * and then bring it out of reset | 253 | * and then bring it out of reset |
144 | */ | 254 | */ |
145 | val = readl(pcie->base + CLK_CONTROL_OFFSET); | 255 | val = iproc_pcie_read_reg(pcie, IPROC_PCIE_CLK_CTRL); |
146 | val &= ~EP_PERST_SOURCE_SELECT & ~EP_MODE_SURVIVE_PERST & | 256 | val &= ~EP_PERST_SOURCE_SELECT & ~EP_MODE_SURVIVE_PERST & |
147 | ~RC_PCIE_RST_OUTPUT; | 257 | ~RC_PCIE_RST_OUTPUT; |
148 | writel(val, pcie->base + CLK_CONTROL_OFFSET); | 258 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); |
149 | udelay(250); | 259 | udelay(250); |
150 | 260 | ||
151 | val |= RC_PCIE_RST_OUTPUT; | 261 | val |= RC_PCIE_RST_OUTPUT; |
152 | writel(val, pcie->base + CLK_CONTROL_OFFSET); | 262 | iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); |
153 | msleep(100); | 263 | msleep(100); |
154 | } | 264 | } |
155 | 265 | ||
@@ -160,7 +270,14 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) | |||
160 | u16 pos, link_status; | 270 | u16 pos, link_status; |
161 | bool link_is_active = false; | 271 | bool link_is_active = false; |
162 | 272 | ||
163 | val = readl(pcie->base + PCIE_LINK_STATUS_OFFSET); | 273 | /* |
274 | * PAXC connects to emulated endpoint devices directly and does not | ||
275 | * have a Serdes. Therefore skip the link detection logic here. | ||
276 | */ | ||
277 | if (pcie->type == IPROC_PCIE_PAXC) | ||
278 | return 0; | ||
279 | |||
280 | val = iproc_pcie_read_reg(pcie, IPROC_PCIE_LINK_STATUS); | ||
164 | if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) { | 281 | if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) { |
165 | dev_err(pcie->dev, "PHY or data link is INACTIVE!\n"); | 282 | dev_err(pcie->dev, "PHY or data link is INACTIVE!\n"); |
166 | return -ENODEV; | 283 | return -ENODEV; |
@@ -221,7 +338,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) | |||
221 | 338 | ||
222 | static void iproc_pcie_enable(struct iproc_pcie *pcie) | 339 | static void iproc_pcie_enable(struct iproc_pcie *pcie) |
223 | { | 340 | { |
224 | writel(SYS_RC_INTX_MASK, pcie->base + SYS_RC_INTX_EN); | 341 | iproc_pcie_write_reg(pcie, IPROC_PCIE_INTX_EN, SYS_RC_INTX_MASK); |
225 | } | 342 | } |
226 | 343 | ||
227 | /** | 344 | /** |
@@ -245,7 +362,7 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, | |||
245 | 362 | ||
246 | if (size > max_size) { | 363 | if (size > max_size) { |
247 | dev_err(pcie->dev, | 364 | dev_err(pcie->dev, |
248 | "res size 0x%pap exceeds max supported size 0x%llx\n", | 365 | "res size %pap exceeds max supported size 0x%llx\n", |
249 | &size, max_size); | 366 | &size, max_size); |
250 | return -EINVAL; | 367 | return -EINVAL; |
251 | } | 368 | } |
@@ -272,11 +389,15 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, | |||
272 | axi_addr -= ob->axi_offset; | 389 | axi_addr -= ob->axi_offset; |
273 | 390 | ||
274 | for (i = 0; i < MAX_NUM_OB_WINDOWS; i++) { | 391 | for (i = 0; i < MAX_NUM_OB_WINDOWS; i++) { |
275 | writel(lower_32_bits(axi_addr) | OARR_VALID | | 392 | iproc_pcie_ob_write(pcie, IPROC_PCIE_OARR_LO, i, |
276 | (ob->set_oarr_size ? 1 : 0), pcie->base + OARR_LO(i)); | 393 | lower_32_bits(axi_addr) | OARR_VALID | |
277 | writel(upper_32_bits(axi_addr), pcie->base + OARR_HI(i)); | 394 | (ob->set_oarr_size ? 1 : 0)); |
278 | writel(lower_32_bits(pci_addr), pcie->base + OMAP_LO(i)); | 395 | iproc_pcie_ob_write(pcie, IPROC_PCIE_OARR_HI, i, |
279 | writel(upper_32_bits(pci_addr), pcie->base + OMAP_HI(i)); | 396 | upper_32_bits(axi_addr)); |
397 | iproc_pcie_ob_write(pcie, IPROC_PCIE_OMAP_LO, i, | ||
398 | lower_32_bits(pci_addr)); | ||
399 | iproc_pcie_ob_write(pcie, IPROC_PCIE_OMAP_HI, i, | ||
400 | upper_32_bits(pci_addr)); | ||
280 | 401 | ||
281 | size -= ob->window_size; | 402 | size -= ob->window_size; |
282 | if (size == 0) | 403 | if (size == 0) |
@@ -319,6 +440,26 @@ static int iproc_pcie_map_ranges(struct iproc_pcie *pcie, | |||
319 | return 0; | 440 | return 0; |
320 | } | 441 | } |
321 | 442 | ||
443 | static int iproc_pcie_msi_enable(struct iproc_pcie *pcie) | ||
444 | { | ||
445 | struct device_node *msi_node; | ||
446 | |||
447 | msi_node = of_parse_phandle(pcie->dev->of_node, "msi-parent", 0); | ||
448 | if (!msi_node) | ||
449 | return -ENODEV; | ||
450 | |||
451 | /* | ||
452 | * If another MSI controller is being used, the call below should fail | ||
453 | * but that is okay | ||
454 | */ | ||
455 | return iproc_msi_init(pcie, msi_node); | ||
456 | } | ||
457 | |||
458 | static void iproc_pcie_msi_disable(struct iproc_pcie *pcie) | ||
459 | { | ||
460 | iproc_msi_exit(pcie); | ||
461 | } | ||
462 | |||
322 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | 463 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) |
323 | { | 464 | { |
324 | int ret; | 465 | int ret; |
@@ -340,6 +481,19 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | |||
340 | goto err_exit_phy; | 481 | goto err_exit_phy; |
341 | } | 482 | } |
342 | 483 | ||
484 | switch (pcie->type) { | ||
485 | case IPROC_PCIE_PAXB: | ||
486 | pcie->reg_offsets = iproc_pcie_reg_paxb; | ||
487 | break; | ||
488 | case IPROC_PCIE_PAXC: | ||
489 | pcie->reg_offsets = iproc_pcie_reg_paxc; | ||
490 | break; | ||
491 | default: | ||
492 | dev_err(pcie->dev, "incompatible iProc PCIe interface\n"); | ||
493 | ret = -EINVAL; | ||
494 | goto err_power_off_phy; | ||
495 | } | ||
496 | |||
343 | iproc_pcie_reset(pcie); | 497 | iproc_pcie_reset(pcie); |
344 | 498 | ||
345 | if (pcie->need_ob_cfg) { | 499 | if (pcie->need_ob_cfg) { |
@@ -373,6 +527,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | |||
373 | 527 | ||
374 | iproc_pcie_enable(pcie); | 528 | iproc_pcie_enable(pcie); |
375 | 529 | ||
530 | if (IS_ENABLED(CONFIG_PCI_MSI)) | ||
531 | if (iproc_pcie_msi_enable(pcie)) | ||
532 | dev_info(pcie->dev, "not using iProc MSI\n"); | ||
533 | |||
376 | pci_scan_child_bus(bus); | 534 | pci_scan_child_bus(bus); |
377 | pci_assign_unassigned_bus_resources(bus); | 535 | pci_assign_unassigned_bus_resources(bus); |
378 | pci_fixup_irqs(pci_common_swizzle, pcie->map_irq); | 536 | pci_fixup_irqs(pci_common_swizzle, pcie->map_irq); |
@@ -397,6 +555,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) | |||
397 | pci_stop_root_bus(pcie->root_bus); | 555 | pci_stop_root_bus(pcie->root_bus); |
398 | pci_remove_root_bus(pcie->root_bus); | 556 | pci_remove_root_bus(pcie->root_bus); |
399 | 557 | ||
558 | iproc_pcie_msi_disable(pcie); | ||
559 | |||
400 | phy_power_off(pcie->phy); | 560 | phy_power_off(pcie->phy); |
401 | phy_exit(pcie->phy); | 561 | phy_exit(pcie->phy); |
402 | 562 | ||
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index d3dc940f773a..e84d93c53c7b 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h | |||
@@ -15,6 +15,20 @@ | |||
15 | #define _PCIE_IPROC_H | 15 | #define _PCIE_IPROC_H |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * iProc PCIe interface type | ||
19 | * | ||
20 | * PAXB is the wrapper used in root complex that can be connected to an | ||
21 | * external endpoint device. | ||
22 | * | ||
23 | * PAXC is the wrapper used in root complex dedicated for internal emulated | ||
24 | * endpoint devices. | ||
25 | */ | ||
26 | enum iproc_pcie_type { | ||
27 | IPROC_PCIE_PAXB = 0, | ||
28 | IPROC_PCIE_PAXC, | ||
29 | }; | ||
30 | |||
31 | /** | ||
18 | * iProc PCIe outbound mapping | 32 | * iProc PCIe outbound mapping |
19 | * @set_oarr_size: indicates the OARR size bit needs to be set | 33 | * @set_oarr_size: indicates the OARR size bit needs to be set |
20 | * @axi_offset: offset from the AXI address to the internal address used by | 34 | * @axi_offset: offset from the AXI address to the internal address used by |
@@ -27,21 +41,30 @@ struct iproc_pcie_ob { | |||
27 | resource_size_t window_size; | 41 | resource_size_t window_size; |
28 | }; | 42 | }; |
29 | 43 | ||
44 | struct iproc_msi; | ||
45 | |||
30 | /** | 46 | /** |
31 | * iProc PCIe device | 47 | * iProc PCIe device |
48 | * | ||
32 | * @dev: pointer to device data structure | 49 | * @dev: pointer to device data structure |
50 | * @type: iProc PCIe interface type | ||
51 | * @reg_offsets: register offsets | ||
33 | * @base: PCIe host controller I/O register base | 52 | * @base: PCIe host controller I/O register base |
53 | * @base_addr: PCIe host controller register base physical address | ||
34 | * @sysdata: Per PCI controller data (ARM-specific) | 54 | * @sysdata: Per PCI controller data (ARM-specific) |
35 | * @root_bus: pointer to root bus | 55 | * @root_bus: pointer to root bus |
36 | * @phy: optional PHY device that controls the Serdes | 56 | * @phy: optional PHY device that controls the Serdes |
37 | * @irqs: interrupt IDs | ||
38 | * @map_irq: function callback to map interrupts | 57 | * @map_irq: function callback to map interrupts |
39 | * @need_ob_cfg: indidates SW needs to configure the outbound mapping window | 58 | * @need_ob_cfg: indicates SW needs to configure the outbound mapping window |
40 | * @ob: outbound mapping parameters | 59 | * @ob: outbound mapping parameters |
60 | * @msi: MSI data | ||
41 | */ | 61 | */ |
42 | struct iproc_pcie { | 62 | struct iproc_pcie { |
43 | struct device *dev; | 63 | struct device *dev; |
64 | enum iproc_pcie_type type; | ||
65 | const u16 *reg_offsets; | ||
44 | void __iomem *base; | 66 | void __iomem *base; |
67 | phys_addr_t base_addr; | ||
45 | #ifdef CONFIG_ARM | 68 | #ifdef CONFIG_ARM |
46 | struct pci_sys_data sysdata; | 69 | struct pci_sys_data sysdata; |
47 | #endif | 70 | #endif |
@@ -50,9 +73,24 @@ struct iproc_pcie { | |||
50 | int (*map_irq)(const struct pci_dev *, u8, u8); | 73 | int (*map_irq)(const struct pci_dev *, u8, u8); |
51 | bool need_ob_cfg; | 74 | bool need_ob_cfg; |
52 | struct iproc_pcie_ob ob; | 75 | struct iproc_pcie_ob ob; |
76 | struct iproc_msi *msi; | ||
53 | }; | 77 | }; |
54 | 78 | ||
55 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); | 79 | int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); |
56 | int iproc_pcie_remove(struct iproc_pcie *pcie); | 80 | int iproc_pcie_remove(struct iproc_pcie *pcie); |
57 | 81 | ||
82 | #ifdef CONFIG_PCIE_IPROC_MSI | ||
83 | int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node); | ||
84 | void iproc_msi_exit(struct iproc_pcie *pcie); | ||
85 | #else | ||
86 | static inline int iproc_msi_init(struct iproc_pcie *pcie, | ||
87 | struct device_node *node) | ||
88 | { | ||
89 | return -ENODEV; | ||
90 | } | ||
91 | static inline void iproc_msi_exit(struct iproc_pcie *pcie) | ||
92 | { | ||
93 | } | ||
94 | #endif | ||
95 | |||
58 | #endif /* _PCIE_IPROC_H */ | 96 | #endif /* _PCIE_IPROC_H */ |
diff --git a/drivers/pci/host/pcie-qcom.c b/drivers/pci/host/pcie-qcom.c new file mode 100644 index 000000000000..e845fba19632 --- /dev/null +++ b/drivers/pci/host/pcie-qcom.c | |||
@@ -0,0 +1,616 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. | ||
3 | * Copyright 2015 Linaro Limited. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 and | ||
7 | * only version 2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/clk.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/iopoll.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/of_device.h> | ||
24 | #include <linux/of_gpio.h> | ||
25 | #include <linux/pci.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/phy/phy.h> | ||
28 | #include <linux/regulator/consumer.h> | ||
29 | #include <linux/reset.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/types.h> | ||
32 | |||
33 | #include "pcie-designware.h" | ||
34 | |||
35 | #define PCIE20_PARF_PHY_CTRL 0x40 | ||
36 | #define PCIE20_PARF_PHY_REFCLK 0x4C | ||
37 | #define PCIE20_PARF_DBI_BASE_ADDR 0x168 | ||
38 | #define PCIE20_PARF_SLV_ADDR_SPACE_SIZE 0x16c | ||
39 | #define PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT 0x178 | ||
40 | |||
41 | #define PCIE20_ELBI_SYS_CTRL 0x04 | ||
42 | #define PCIE20_ELBI_SYS_CTRL_LT_ENABLE BIT(0) | ||
43 | |||
44 | #define PCIE20_CAP 0x70 | ||
45 | |||
46 | #define PERST_DELAY_US 1000 | ||
47 | |||
48 | struct qcom_pcie_resources_v0 { | ||
49 | struct clk *iface_clk; | ||
50 | struct clk *core_clk; | ||
51 | struct clk *phy_clk; | ||
52 | struct reset_control *pci_reset; | ||
53 | struct reset_control *axi_reset; | ||
54 | struct reset_control *ahb_reset; | ||
55 | struct reset_control *por_reset; | ||
56 | struct reset_control *phy_reset; | ||
57 | struct regulator *vdda; | ||
58 | struct regulator *vdda_phy; | ||
59 | struct regulator *vdda_refclk; | ||
60 | }; | ||
61 | |||
62 | struct qcom_pcie_resources_v1 { | ||
63 | struct clk *iface; | ||
64 | struct clk *aux; | ||
65 | struct clk *master_bus; | ||
66 | struct clk *slave_bus; | ||
67 | struct reset_control *core; | ||
68 | struct regulator *vdda; | ||
69 | }; | ||
70 | |||
71 | union qcom_pcie_resources { | ||
72 | struct qcom_pcie_resources_v0 v0; | ||
73 | struct qcom_pcie_resources_v1 v1; | ||
74 | }; | ||
75 | |||
76 | struct qcom_pcie; | ||
77 | |||
78 | struct qcom_pcie_ops { | ||
79 | int (*get_resources)(struct qcom_pcie *pcie); | ||
80 | int (*init)(struct qcom_pcie *pcie); | ||
81 | void (*deinit)(struct qcom_pcie *pcie); | ||
82 | }; | ||
83 | |||
84 | struct qcom_pcie { | ||
85 | struct pcie_port pp; | ||
86 | struct device *dev; | ||
87 | union qcom_pcie_resources res; | ||
88 | void __iomem *parf; | ||
89 | void __iomem *dbi; | ||
90 | void __iomem *elbi; | ||
91 | struct phy *phy; | ||
92 | struct gpio_desc *reset; | ||
93 | struct qcom_pcie_ops *ops; | ||
94 | }; | ||
95 | |||
96 | #define to_qcom_pcie(x) container_of(x, struct qcom_pcie, pp) | ||
97 | |||
98 | static void qcom_ep_reset_assert(struct qcom_pcie *pcie) | ||
99 | { | ||
100 | gpiod_set_value(pcie->reset, 1); | ||
101 | usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); | ||
102 | } | ||
103 | |||
104 | static void qcom_ep_reset_deassert(struct qcom_pcie *pcie) | ||
105 | { | ||
106 | gpiod_set_value(pcie->reset, 0); | ||
107 | usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); | ||
108 | } | ||
109 | |||
110 | static irqreturn_t qcom_pcie_msi_irq_handler(int irq, void *arg) | ||
111 | { | ||
112 | struct pcie_port *pp = arg; | ||
113 | |||
114 | return dw_handle_msi_irq(pp); | ||
115 | } | ||
116 | |||
117 | static int qcom_pcie_establish_link(struct qcom_pcie *pcie) | ||
118 | { | ||
119 | struct device *dev = pcie->dev; | ||
120 | unsigned int retries = 0; | ||
121 | u32 val; | ||
122 | |||
123 | if (dw_pcie_link_up(&pcie->pp)) | ||
124 | return 0; | ||
125 | |||
126 | /* enable link training */ | ||
127 | val = readl(pcie->elbi + PCIE20_ELBI_SYS_CTRL); | ||
128 | val |= PCIE20_ELBI_SYS_CTRL_LT_ENABLE; | ||
129 | writel(val, pcie->elbi + PCIE20_ELBI_SYS_CTRL); | ||
130 | |||
131 | do { | ||
132 | if (dw_pcie_link_up(&pcie->pp)) | ||
133 | return 0; | ||
134 | usleep_range(250, 1000); | ||
135 | } while (retries < 200); | ||
136 | |||
137 | dev_warn(dev, "phy link never came up\n"); | ||
138 | |||
139 | return -ETIMEDOUT; | ||
140 | } | ||
141 | |||
142 | static int qcom_pcie_get_resources_v0(struct qcom_pcie *pcie) | ||
143 | { | ||
144 | struct qcom_pcie_resources_v0 *res = &pcie->res.v0; | ||
145 | struct device *dev = pcie->dev; | ||
146 | |||
147 | res->vdda = devm_regulator_get(dev, "vdda"); | ||
148 | if (IS_ERR(res->vdda)) | ||
149 | return PTR_ERR(res->vdda); | ||
150 | |||
151 | res->vdda_phy = devm_regulator_get(dev, "vdda_phy"); | ||
152 | if (IS_ERR(res->vdda_phy)) | ||
153 | return PTR_ERR(res->vdda_phy); | ||
154 | |||
155 | res->vdda_refclk = devm_regulator_get(dev, "vdda_refclk"); | ||
156 | if (IS_ERR(res->vdda_refclk)) | ||
157 | return PTR_ERR(res->vdda_refclk); | ||
158 | |||
159 | res->iface_clk = devm_clk_get(dev, "iface"); | ||
160 | if (IS_ERR(res->iface_clk)) | ||
161 | return PTR_ERR(res->iface_clk); | ||
162 | |||
163 | res->core_clk = devm_clk_get(dev, "core"); | ||
164 | if (IS_ERR(res->core_clk)) | ||
165 | return PTR_ERR(res->core_clk); | ||
166 | |||
167 | res->phy_clk = devm_clk_get(dev, "phy"); | ||
168 | if (IS_ERR(res->phy_clk)) | ||
169 | return PTR_ERR(res->phy_clk); | ||
170 | |||
171 | res->pci_reset = devm_reset_control_get(dev, "pci"); | ||
172 | if (IS_ERR(res->pci_reset)) | ||
173 | return PTR_ERR(res->pci_reset); | ||
174 | |||
175 | res->axi_reset = devm_reset_control_get(dev, "axi"); | ||
176 | if (IS_ERR(res->axi_reset)) | ||
177 | return PTR_ERR(res->axi_reset); | ||
178 | |||
179 | res->ahb_reset = devm_reset_control_get(dev, "ahb"); | ||
180 | if (IS_ERR(res->ahb_reset)) | ||
181 | return PTR_ERR(res->ahb_reset); | ||
182 | |||
183 | res->por_reset = devm_reset_control_get(dev, "por"); | ||
184 | if (IS_ERR(res->por_reset)) | ||
185 | return PTR_ERR(res->por_reset); | ||
186 | |||
187 | res->phy_reset = devm_reset_control_get(dev, "phy"); | ||
188 | if (IS_ERR(res->phy_reset)) | ||
189 | return PTR_ERR(res->phy_reset); | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int qcom_pcie_get_resources_v1(struct qcom_pcie *pcie) | ||
195 | { | ||
196 | struct qcom_pcie_resources_v1 *res = &pcie->res.v1; | ||
197 | struct device *dev = pcie->dev; | ||
198 | |||
199 | res->vdda = devm_regulator_get(dev, "vdda"); | ||
200 | if (IS_ERR(res->vdda)) | ||
201 | return PTR_ERR(res->vdda); | ||
202 | |||
203 | res->iface = devm_clk_get(dev, "iface"); | ||
204 | if (IS_ERR(res->iface)) | ||
205 | return PTR_ERR(res->iface); | ||
206 | |||
207 | res->aux = devm_clk_get(dev, "aux"); | ||
208 | if (IS_ERR(res->aux)) | ||
209 | return PTR_ERR(res->aux); | ||
210 | |||
211 | res->master_bus = devm_clk_get(dev, "master_bus"); | ||
212 | if (IS_ERR(res->master_bus)) | ||
213 | return PTR_ERR(res->master_bus); | ||
214 | |||
215 | res->slave_bus = devm_clk_get(dev, "slave_bus"); | ||
216 | if (IS_ERR(res->slave_bus)) | ||
217 | return PTR_ERR(res->slave_bus); | ||
218 | |||
219 | res->core = devm_reset_control_get(dev, "core"); | ||
220 | if (IS_ERR(res->core)) | ||
221 | return PTR_ERR(res->core); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static void qcom_pcie_deinit_v0(struct qcom_pcie *pcie) | ||
227 | { | ||
228 | struct qcom_pcie_resources_v0 *res = &pcie->res.v0; | ||
229 | |||
230 | reset_control_assert(res->pci_reset); | ||
231 | reset_control_assert(res->axi_reset); | ||
232 | reset_control_assert(res->ahb_reset); | ||
233 | reset_control_assert(res->por_reset); | ||
234 | reset_control_assert(res->pci_reset); | ||
235 | clk_disable_unprepare(res->iface_clk); | ||
236 | clk_disable_unprepare(res->core_clk); | ||
237 | clk_disable_unprepare(res->phy_clk); | ||
238 | regulator_disable(res->vdda); | ||
239 | regulator_disable(res->vdda_phy); | ||
240 | regulator_disable(res->vdda_refclk); | ||
241 | } | ||
242 | |||
243 | static int qcom_pcie_init_v0(struct qcom_pcie *pcie) | ||
244 | { | ||
245 | struct qcom_pcie_resources_v0 *res = &pcie->res.v0; | ||
246 | struct device *dev = pcie->dev; | ||
247 | u32 val; | ||
248 | int ret; | ||
249 | |||
250 | ret = regulator_enable(res->vdda); | ||
251 | if (ret) { | ||
252 | dev_err(dev, "cannot enable vdda regulator\n"); | ||
253 | return ret; | ||
254 | } | ||
255 | |||
256 | ret = regulator_enable(res->vdda_refclk); | ||
257 | if (ret) { | ||
258 | dev_err(dev, "cannot enable vdda_refclk regulator\n"); | ||
259 | goto err_refclk; | ||
260 | } | ||
261 | |||
262 | ret = regulator_enable(res->vdda_phy); | ||
263 | if (ret) { | ||
264 | dev_err(dev, "cannot enable vdda_phy regulator\n"); | ||
265 | goto err_vdda_phy; | ||
266 | } | ||
267 | |||
268 | ret = reset_control_assert(res->ahb_reset); | ||
269 | if (ret) { | ||
270 | dev_err(dev, "cannot assert ahb reset\n"); | ||
271 | goto err_assert_ahb; | ||
272 | } | ||
273 | |||
274 | ret = clk_prepare_enable(res->iface_clk); | ||
275 | if (ret) { | ||
276 | dev_err(dev, "cannot prepare/enable iface clock\n"); | ||
277 | goto err_assert_ahb; | ||
278 | } | ||
279 | |||
280 | ret = clk_prepare_enable(res->phy_clk); | ||
281 | if (ret) { | ||
282 | dev_err(dev, "cannot prepare/enable phy clock\n"); | ||
283 | goto err_clk_phy; | ||
284 | } | ||
285 | |||
286 | ret = clk_prepare_enable(res->core_clk); | ||
287 | if (ret) { | ||
288 | dev_err(dev, "cannot prepare/enable core clock\n"); | ||
289 | goto err_clk_core; | ||
290 | } | ||
291 | |||
292 | ret = reset_control_deassert(res->ahb_reset); | ||
293 | if (ret) { | ||
294 | dev_err(dev, "cannot deassert ahb reset\n"); | ||
295 | goto err_deassert_ahb; | ||
296 | } | ||
297 | |||
298 | /* enable PCIe clocks and resets */ | ||
299 | val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL); | ||
300 | val &= ~BIT(0); | ||
301 | writel(val, pcie->parf + PCIE20_PARF_PHY_CTRL); | ||
302 | |||
303 | /* enable external reference clock */ | ||
304 | val = readl(pcie->parf + PCIE20_PARF_PHY_REFCLK); | ||
305 | val |= BIT(16); | ||
306 | writel(val, pcie->parf + PCIE20_PARF_PHY_REFCLK); | ||
307 | |||
308 | ret = reset_control_deassert(res->phy_reset); | ||
309 | if (ret) { | ||
310 | dev_err(dev, "cannot deassert phy reset\n"); | ||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | ret = reset_control_deassert(res->pci_reset); | ||
315 | if (ret) { | ||
316 | dev_err(dev, "cannot deassert pci reset\n"); | ||
317 | return ret; | ||
318 | } | ||
319 | |||
320 | ret = reset_control_deassert(res->por_reset); | ||
321 | if (ret) { | ||
322 | dev_err(dev, "cannot deassert por reset\n"); | ||
323 | return ret; | ||
324 | } | ||
325 | |||
326 | ret = reset_control_deassert(res->axi_reset); | ||
327 | if (ret) { | ||
328 | dev_err(dev, "cannot deassert axi reset\n"); | ||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | /* wait for clock acquisition */ | ||
333 | usleep_range(1000, 1500); | ||
334 | |||
335 | return 0; | ||
336 | |||
337 | err_deassert_ahb: | ||
338 | clk_disable_unprepare(res->core_clk); | ||
339 | err_clk_core: | ||
340 | clk_disable_unprepare(res->phy_clk); | ||
341 | err_clk_phy: | ||
342 | clk_disable_unprepare(res->iface_clk); | ||
343 | err_assert_ahb: | ||
344 | regulator_disable(res->vdda_phy); | ||
345 | err_vdda_phy: | ||
346 | regulator_disable(res->vdda_refclk); | ||
347 | err_refclk: | ||
348 | regulator_disable(res->vdda); | ||
349 | |||
350 | return ret; | ||
351 | } | ||
352 | |||
353 | static void qcom_pcie_deinit_v1(struct qcom_pcie *pcie) | ||
354 | { | ||
355 | struct qcom_pcie_resources_v1 *res = &pcie->res.v1; | ||
356 | |||
357 | reset_control_assert(res->core); | ||
358 | clk_disable_unprepare(res->slave_bus); | ||
359 | clk_disable_unprepare(res->master_bus); | ||
360 | clk_disable_unprepare(res->iface); | ||
361 | clk_disable_unprepare(res->aux); | ||
362 | regulator_disable(res->vdda); | ||
363 | } | ||
364 | |||
365 | static int qcom_pcie_init_v1(struct qcom_pcie *pcie) | ||
366 | { | ||
367 | struct qcom_pcie_resources_v1 *res = &pcie->res.v1; | ||
368 | struct device *dev = pcie->dev; | ||
369 | int ret; | ||
370 | |||
371 | ret = reset_control_deassert(res->core); | ||
372 | if (ret) { | ||
373 | dev_err(dev, "cannot deassert core reset\n"); | ||
374 | return ret; | ||
375 | } | ||
376 | |||
377 | ret = clk_prepare_enable(res->aux); | ||
378 | if (ret) { | ||
379 | dev_err(dev, "cannot prepare/enable aux clock\n"); | ||
380 | goto err_res; | ||
381 | } | ||
382 | |||
383 | ret = clk_prepare_enable(res->iface); | ||
384 | if (ret) { | ||
385 | dev_err(dev, "cannot prepare/enable iface clock\n"); | ||
386 | goto err_aux; | ||
387 | } | ||
388 | |||
389 | ret = clk_prepare_enable(res->master_bus); | ||
390 | if (ret) { | ||
391 | dev_err(dev, "cannot prepare/enable master_bus clock\n"); | ||
392 | goto err_iface; | ||
393 | } | ||
394 | |||
395 | ret = clk_prepare_enable(res->slave_bus); | ||
396 | if (ret) { | ||
397 | dev_err(dev, "cannot prepare/enable slave_bus clock\n"); | ||
398 | goto err_master; | ||
399 | } | ||
400 | |||
401 | ret = regulator_enable(res->vdda); | ||
402 | if (ret) { | ||
403 | dev_err(dev, "cannot enable vdda regulator\n"); | ||
404 | goto err_slave; | ||
405 | } | ||
406 | |||
407 | /* change DBI base address */ | ||
408 | writel(0, pcie->parf + PCIE20_PARF_DBI_BASE_ADDR); | ||
409 | |||
410 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | ||
411 | u32 val = readl(pcie->parf + PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT); | ||
412 | |||
413 | val |= BIT(31); | ||
414 | writel(val, pcie->parf + PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT); | ||
415 | } | ||
416 | |||
417 | return 0; | ||
418 | err_slave: | ||
419 | clk_disable_unprepare(res->slave_bus); | ||
420 | err_master: | ||
421 | clk_disable_unprepare(res->master_bus); | ||
422 | err_iface: | ||
423 | clk_disable_unprepare(res->iface); | ||
424 | err_aux: | ||
425 | clk_disable_unprepare(res->aux); | ||
426 | err_res: | ||
427 | reset_control_assert(res->core); | ||
428 | |||
429 | return ret; | ||
430 | } | ||
431 | |||
432 | static int qcom_pcie_link_up(struct pcie_port *pp) | ||
433 | { | ||
434 | struct qcom_pcie *pcie = to_qcom_pcie(pp); | ||
435 | u16 val = readw(pcie->dbi + PCIE20_CAP + PCI_EXP_LNKSTA); | ||
436 | |||
437 | return !!(val & PCI_EXP_LNKSTA_DLLLA); | ||
438 | } | ||
439 | |||
440 | static void qcom_pcie_host_init(struct pcie_port *pp) | ||
441 | { | ||
442 | struct qcom_pcie *pcie = to_qcom_pcie(pp); | ||
443 | int ret; | ||
444 | |||
445 | qcom_ep_reset_assert(pcie); | ||
446 | |||
447 | ret = pcie->ops->init(pcie); | ||
448 | if (ret) | ||
449 | goto err_deinit; | ||
450 | |||
451 | ret = phy_power_on(pcie->phy); | ||
452 | if (ret) | ||
453 | goto err_deinit; | ||
454 | |||
455 | dw_pcie_setup_rc(pp); | ||
456 | |||
457 | if (IS_ENABLED(CONFIG_PCI_MSI)) | ||
458 | dw_pcie_msi_init(pp); | ||
459 | |||
460 | qcom_ep_reset_deassert(pcie); | ||
461 | |||
462 | ret = qcom_pcie_establish_link(pcie); | ||
463 | if (ret) | ||
464 | goto err; | ||
465 | |||
466 | return; | ||
467 | err: | ||
468 | qcom_ep_reset_assert(pcie); | ||
469 | phy_power_off(pcie->phy); | ||
470 | err_deinit: | ||
471 | pcie->ops->deinit(pcie); | ||
472 | } | ||
473 | |||
474 | static int qcom_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, | ||
475 | u32 *val) | ||
476 | { | ||
477 | /* the device class is not reported correctly from the register */ | ||
478 | if (where == PCI_CLASS_REVISION && size == 4) { | ||
479 | *val = readl(pp->dbi_base + PCI_CLASS_REVISION); | ||
480 | *val &= 0xff; /* keep revision id */ | ||
481 | *val |= PCI_CLASS_BRIDGE_PCI << 16; | ||
482 | return PCIBIOS_SUCCESSFUL; | ||
483 | } | ||
484 | |||
485 | return dw_pcie_cfg_read(pp->dbi_base + where, size, val); | ||
486 | } | ||
487 | |||
488 | static struct pcie_host_ops qcom_pcie_dw_ops = { | ||
489 | .link_up = qcom_pcie_link_up, | ||
490 | .host_init = qcom_pcie_host_init, | ||
491 | .rd_own_conf = qcom_pcie_rd_own_conf, | ||
492 | }; | ||
493 | |||
494 | static const struct qcom_pcie_ops ops_v0 = { | ||
495 | .get_resources = qcom_pcie_get_resources_v0, | ||
496 | .init = qcom_pcie_init_v0, | ||
497 | .deinit = qcom_pcie_deinit_v0, | ||
498 | }; | ||
499 | |||
500 | static const struct qcom_pcie_ops ops_v1 = { | ||
501 | .get_resources = qcom_pcie_get_resources_v1, | ||
502 | .init = qcom_pcie_init_v1, | ||
503 | .deinit = qcom_pcie_deinit_v1, | ||
504 | }; | ||
505 | |||
506 | static int qcom_pcie_probe(struct platform_device *pdev) | ||
507 | { | ||
508 | struct device *dev = &pdev->dev; | ||
509 | struct resource *res; | ||
510 | struct qcom_pcie *pcie; | ||
511 | struct pcie_port *pp; | ||
512 | int ret; | ||
513 | |||
514 | pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); | ||
515 | if (!pcie) | ||
516 | return -ENOMEM; | ||
517 | |||
518 | pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev); | ||
519 | pcie->dev = dev; | ||
520 | |||
521 | pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); | ||
522 | if (IS_ERR(pcie->reset)) | ||
523 | return PTR_ERR(pcie->reset); | ||
524 | |||
525 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); | ||
526 | pcie->parf = devm_ioremap_resource(dev, res); | ||
527 | if (IS_ERR(pcie->parf)) | ||
528 | return PTR_ERR(pcie->parf); | ||
529 | |||
530 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); | ||
531 | pcie->dbi = devm_ioremap_resource(dev, res); | ||
532 | if (IS_ERR(pcie->dbi)) | ||
533 | return PTR_ERR(pcie->dbi); | ||
534 | |||
535 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi"); | ||
536 | pcie->elbi = devm_ioremap_resource(dev, res); | ||
537 | if (IS_ERR(pcie->elbi)) | ||
538 | return PTR_ERR(pcie->elbi); | ||
539 | |||
540 | pcie->phy = devm_phy_optional_get(dev, "pciephy"); | ||
541 | if (IS_ERR(pcie->phy)) | ||
542 | return PTR_ERR(pcie->phy); | ||
543 | |||
544 | ret = pcie->ops->get_resources(pcie); | ||
545 | if (ret) | ||
546 | return ret; | ||
547 | |||
548 | pp = &pcie->pp; | ||
549 | pp->dev = dev; | ||
550 | pp->dbi_base = pcie->dbi; | ||
551 | pp->root_bus_nr = -1; | ||
552 | pp->ops = &qcom_pcie_dw_ops; | ||
553 | |||
554 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | ||
555 | pp->msi_irq = platform_get_irq_byname(pdev, "msi"); | ||
556 | if (pp->msi_irq < 0) | ||
557 | return pp->msi_irq; | ||
558 | |||
559 | ret = devm_request_irq(dev, pp->msi_irq, | ||
560 | qcom_pcie_msi_irq_handler, | ||
561 | IRQF_SHARED, "qcom-pcie-msi", pp); | ||
562 | if (ret) { | ||
563 | dev_err(dev, "cannot request msi irq\n"); | ||
564 | return ret; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | ret = phy_init(pcie->phy); | ||
569 | if (ret) | ||
570 | return ret; | ||
571 | |||
572 | ret = dw_pcie_host_init(pp); | ||
573 | if (ret) { | ||
574 | dev_err(dev, "cannot initialize host\n"); | ||
575 | return ret; | ||
576 | } | ||
577 | |||
578 | platform_set_drvdata(pdev, pcie); | ||
579 | |||
580 | return 0; | ||
581 | } | ||
582 | |||
583 | static int qcom_pcie_remove(struct platform_device *pdev) | ||
584 | { | ||
585 | struct qcom_pcie *pcie = platform_get_drvdata(pdev); | ||
586 | |||
587 | qcom_ep_reset_assert(pcie); | ||
588 | phy_power_off(pcie->phy); | ||
589 | phy_exit(pcie->phy); | ||
590 | pcie->ops->deinit(pcie); | ||
591 | |||
592 | return 0; | ||
593 | } | ||
594 | |||
595 | static const struct of_device_id qcom_pcie_match[] = { | ||
596 | { .compatible = "qcom,pcie-ipq8064", .data = &ops_v0 }, | ||
597 | { .compatible = "qcom,pcie-apq8064", .data = &ops_v0 }, | ||
598 | { .compatible = "qcom,pcie-apq8084", .data = &ops_v1 }, | ||
599 | { } | ||
600 | }; | ||
601 | MODULE_DEVICE_TABLE(of, qcom_pcie_match); | ||
602 | |||
603 | static struct platform_driver qcom_pcie_driver = { | ||
604 | .probe = qcom_pcie_probe, | ||
605 | .remove = qcom_pcie_remove, | ||
606 | .driver = { | ||
607 | .name = "qcom-pcie", | ||
608 | .of_match_table = qcom_pcie_match, | ||
609 | }, | ||
610 | }; | ||
611 | |||
612 | module_platform_driver(qcom_pcie_driver); | ||
613 | |||
614 | MODULE_AUTHOR("Stanimir Varbanov <svarbanov@mm-sol.com>"); | ||
615 | MODULE_DESCRIPTION("Qualcomm PCIe root complex driver"); | ||
616 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index f4fa6c537448..4edb5181f4e2 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
27 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/pm_runtime.h> | ||
29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
30 | 31 | ||
31 | #define DRV_NAME "rcar-pcie" | 32 | #define DRV_NAME "rcar-pcie" |
@@ -94,6 +95,11 @@ | |||
94 | #define H1_PCIEPHYDOUTR 0x040014 | 95 | #define H1_PCIEPHYDOUTR 0x040014 |
95 | #define H1_PCIEPHYSR 0x040018 | 96 | #define H1_PCIEPHYSR 0x040018 |
96 | 97 | ||
98 | /* R-Car Gen2 PHY */ | ||
99 | #define GEN2_PCIEPHYADDR 0x780 | ||
100 | #define GEN2_PCIEPHYDATA 0x784 | ||
101 | #define GEN2_PCIEPHYCTRL 0x78c | ||
102 | |||
97 | #define INT_PCI_MSI_NR 32 | 103 | #define INT_PCI_MSI_NR 32 |
98 | 104 | ||
99 | #define RCONF(x) (PCICONF(0)+(x)) | 105 | #define RCONF(x) (PCICONF(0)+(x)) |
@@ -108,8 +114,6 @@ | |||
108 | #define RCAR_PCI_MAX_RESOURCES 4 | 114 | #define RCAR_PCI_MAX_RESOURCES 4 |
109 | #define MAX_NR_INBOUND_MAPS 6 | 115 | #define MAX_NR_INBOUND_MAPS 6 |
110 | 116 | ||
111 | static unsigned long global_io_offset; | ||
112 | |||
113 | struct rcar_msi { | 117 | struct rcar_msi { |
114 | DECLARE_BITMAP(used, INT_PCI_MSI_NR); | 118 | DECLARE_BITMAP(used, INT_PCI_MSI_NR); |
115 | struct irq_domain *domain; | 119 | struct irq_domain *domain; |
@@ -126,20 +130,10 @@ static inline struct rcar_msi *to_rcar_msi(struct msi_controller *chip) | |||
126 | } | 130 | } |
127 | 131 | ||
128 | /* Structure representing the PCIe interface */ | 132 | /* Structure representing the PCIe interface */ |
129 | /* | ||
130 | * ARM pcibios functions expect the ARM struct pci_sys_data as the PCI | ||
131 | * sysdata. Add pci_sys_data as the first element in struct gen_pci so | ||
132 | * that when we use a gen_pci pointer as sysdata, it is also a pointer to | ||
133 | * a struct pci_sys_data. | ||
134 | */ | ||
135 | struct rcar_pcie { | 133 | struct rcar_pcie { |
136 | #ifdef CONFIG_ARM | ||
137 | struct pci_sys_data sys; | ||
138 | #endif | ||
139 | struct device *dev; | 134 | struct device *dev; |
140 | void __iomem *base; | 135 | void __iomem *base; |
141 | struct resource res[RCAR_PCI_MAX_RESOURCES]; | 136 | struct list_head resources; |
142 | struct resource busn; | ||
143 | int root_bus_nr; | 137 | int root_bus_nr; |
144 | struct clk *clk; | 138 | struct clk *clk; |
145 | struct clk *bus_clk; | 139 | struct clk *bus_clk; |
@@ -323,10 +317,9 @@ static struct pci_ops rcar_pcie_ops = { | |||
323 | .write = rcar_pcie_write_conf, | 317 | .write = rcar_pcie_write_conf, |
324 | }; | 318 | }; |
325 | 319 | ||
326 | static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie) | 320 | static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie, |
321 | struct resource *res) | ||
327 | { | 322 | { |
328 | struct resource *res = &pcie->res[win]; | ||
329 | |||
330 | /* Setup PCIe address space mappings for each resource */ | 323 | /* Setup PCIe address space mappings for each resource */ |
331 | resource_size_t size; | 324 | resource_size_t size; |
332 | resource_size_t res_start; | 325 | resource_size_t res_start; |
@@ -359,31 +352,33 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie) | |||
359 | rcar_pci_write_reg(pcie, mask, PCIEPTCTLR(win)); | 352 | rcar_pci_write_reg(pcie, mask, PCIEPTCTLR(win)); |
360 | } | 353 | } |
361 | 354 | ||
362 | static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pcie) | 355 | static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci) |
363 | { | 356 | { |
364 | struct resource *res; | 357 | struct resource_entry *win; |
365 | int i; | 358 | int i = 0; |
366 | |||
367 | pcie->root_bus_nr = pcie->busn.start; | ||
368 | 359 | ||
369 | /* Setup PCI resources */ | 360 | /* Setup PCI resources */ |
370 | for (i = 0; i < RCAR_PCI_MAX_RESOURCES; i++) { | 361 | resource_list_for_each_entry(win, &pci->resources) { |
362 | struct resource *res = win->res; | ||
371 | 363 | ||
372 | res = &pcie->res[i]; | ||
373 | if (!res->flags) | 364 | if (!res->flags) |
374 | continue; | 365 | continue; |
375 | 366 | ||
376 | rcar_pcie_setup_window(i, pcie); | 367 | switch (resource_type(res)) { |
377 | 368 | case IORESOURCE_IO: | |
378 | if (res->flags & IORESOURCE_IO) { | 369 | case IORESOURCE_MEM: |
379 | phys_addr_t io_start = pci_pio_to_address(res->start); | 370 | rcar_pcie_setup_window(i, pci, res); |
380 | pci_ioremap_io(global_io_offset, io_start); | 371 | i++; |
381 | global_io_offset += SZ_64K; | 372 | break; |
373 | case IORESOURCE_BUS: | ||
374 | pci->root_bus_nr = res->start; | ||
375 | break; | ||
376 | default: | ||
377 | continue; | ||
382 | } | 378 | } |
383 | 379 | ||
384 | pci_add_resource(resource, res); | 380 | pci_add_resource(resource, res); |
385 | } | 381 | } |
386 | pci_add_resource(resource, &pcie->busn); | ||
387 | 382 | ||
388 | return 1; | 383 | return 1; |
389 | } | 384 | } |
@@ -578,6 +573,26 @@ static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie) | |||
578 | return -ETIMEDOUT; | 573 | return -ETIMEDOUT; |
579 | } | 574 | } |
580 | 575 | ||
576 | static int rcar_pcie_hw_init_gen2(struct rcar_pcie *pcie) | ||
577 | { | ||
578 | /* | ||
579 | * These settings come from the R-Car Series, 2nd Generation User's | ||
580 | * Manual, section 50.3.1 (2) Initialization of the physical layer. | ||
581 | */ | ||
582 | rcar_pci_write_reg(pcie, 0x000f0030, GEN2_PCIEPHYADDR); | ||
583 | rcar_pci_write_reg(pcie, 0x00381203, GEN2_PCIEPHYDATA); | ||
584 | rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); | ||
585 | rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); | ||
586 | |||
587 | rcar_pci_write_reg(pcie, 0x000f0054, GEN2_PCIEPHYADDR); | ||
588 | /* The following value is for DC connection, no termination resistor */ | ||
589 | rcar_pci_write_reg(pcie, 0x13802007, GEN2_PCIEPHYDATA); | ||
590 | rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); | ||
591 | rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); | ||
592 | |||
593 | return rcar_pcie_hw_init(pcie); | ||
594 | } | ||
595 | |||
581 | static int rcar_msi_alloc(struct rcar_msi *chip) | 596 | static int rcar_msi_alloc(struct rcar_msi *chip) |
582 | { | 597 | { |
583 | int msi; | 598 | int msi; |
@@ -720,14 +735,16 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) | |||
720 | 735 | ||
721 | /* Two irqs are for MSI, but they are also used for non-MSI irqs */ | 736 | /* Two irqs are for MSI, but they are also used for non-MSI irqs */ |
722 | err = devm_request_irq(&pdev->dev, msi->irq1, rcar_pcie_msi_irq, | 737 | err = devm_request_irq(&pdev->dev, msi->irq1, rcar_pcie_msi_irq, |
723 | IRQF_SHARED, rcar_msi_irq_chip.name, pcie); | 738 | IRQF_SHARED | IRQF_NO_THREAD, |
739 | rcar_msi_irq_chip.name, pcie); | ||
724 | if (err < 0) { | 740 | if (err < 0) { |
725 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); | 741 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); |
726 | goto err; | 742 | goto err; |
727 | } | 743 | } |
728 | 744 | ||
729 | err = devm_request_irq(&pdev->dev, msi->irq2, rcar_pcie_msi_irq, | 745 | err = devm_request_irq(&pdev->dev, msi->irq2, rcar_pcie_msi_irq, |
730 | IRQF_SHARED, rcar_msi_irq_chip.name, pcie); | 746 | IRQF_SHARED | IRQF_NO_THREAD, |
747 | rcar_msi_irq_chip.name, pcie); | ||
731 | if (err < 0) { | 748 | if (err < 0) { |
732 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); | 749 | dev_err(&pdev->dev, "failed to request IRQ: %d\n", err); |
733 | goto err; | 750 | goto err; |
@@ -917,20 +934,71 @@ static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, | |||
917 | 934 | ||
918 | static const struct of_device_id rcar_pcie_of_match[] = { | 935 | static const struct of_device_id rcar_pcie_of_match[] = { |
919 | { .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 }, | 936 | { .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 }, |
920 | { .compatible = "renesas,pcie-r8a7790", .data = rcar_pcie_hw_init }, | 937 | { .compatible = "renesas,pcie-rcar-gen2", .data = rcar_pcie_hw_init_gen2 }, |
921 | { .compatible = "renesas,pcie-r8a7791", .data = rcar_pcie_hw_init }, | 938 | { .compatible = "renesas,pcie-r8a7790", .data = rcar_pcie_hw_init_gen2 }, |
939 | { .compatible = "renesas,pcie-r8a7791", .data = rcar_pcie_hw_init_gen2 }, | ||
940 | { .compatible = "renesas,pcie-r8a7795", .data = rcar_pcie_hw_init }, | ||
922 | {}, | 941 | {}, |
923 | }; | 942 | }; |
924 | MODULE_DEVICE_TABLE(of, rcar_pcie_of_match); | 943 | MODULE_DEVICE_TABLE(of, rcar_pcie_of_match); |
925 | 944 | ||
945 | static void rcar_pcie_release_of_pci_ranges(struct rcar_pcie *pci) | ||
946 | { | ||
947 | pci_free_resource_list(&pci->resources); | ||
948 | } | ||
949 | |||
950 | static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci) | ||
951 | { | ||
952 | int err; | ||
953 | struct device *dev = pci->dev; | ||
954 | struct device_node *np = dev->of_node; | ||
955 | resource_size_t iobase; | ||
956 | struct resource_entry *win; | ||
957 | |||
958 | err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pci->resources, &iobase); | ||
959 | if (err) | ||
960 | return err; | ||
961 | |||
962 | resource_list_for_each_entry(win, &pci->resources) { | ||
963 | struct resource *parent, *res = win->res; | ||
964 | |||
965 | switch (resource_type(res)) { | ||
966 | case IORESOURCE_IO: | ||
967 | parent = &ioport_resource; | ||
968 | err = pci_remap_iospace(res, iobase); | ||
969 | if (err) { | ||
970 | dev_warn(dev, "error %d: failed to map resource %pR\n", | ||
971 | err, res); | ||
972 | continue; | ||
973 | } | ||
974 | break; | ||
975 | case IORESOURCE_MEM: | ||
976 | parent = &iomem_resource; | ||
977 | break; | ||
978 | |||
979 | case IORESOURCE_BUS: | ||
980 | default: | ||
981 | continue; | ||
982 | } | ||
983 | |||
984 | err = devm_request_resource(dev, parent, res); | ||
985 | if (err) | ||
986 | goto out_release_res; | ||
987 | } | ||
988 | |||
989 | return 0; | ||
990 | |||
991 | out_release_res: | ||
992 | rcar_pcie_release_of_pci_ranges(pci); | ||
993 | return err; | ||
994 | } | ||
995 | |||
926 | static int rcar_pcie_probe(struct platform_device *pdev) | 996 | static int rcar_pcie_probe(struct platform_device *pdev) |
927 | { | 997 | { |
928 | struct rcar_pcie *pcie; | 998 | struct rcar_pcie *pcie; |
929 | unsigned int data; | 999 | unsigned int data; |
930 | struct of_pci_range range; | ||
931 | struct of_pci_range_parser parser; | ||
932 | const struct of_device_id *of_id; | 1000 | const struct of_device_id *of_id; |
933 | int err, win = 0; | 1001 | int err; |
934 | int (*hw_init_fn)(struct rcar_pcie *); | 1002 | int (*hw_init_fn)(struct rcar_pcie *); |
935 | 1003 | ||
936 | pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL); | 1004 | pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL); |
@@ -940,16 +1008,9 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
940 | pcie->dev = &pdev->dev; | 1008 | pcie->dev = &pdev->dev; |
941 | platform_set_drvdata(pdev, pcie); | 1009 | platform_set_drvdata(pdev, pcie); |
942 | 1010 | ||
943 | /* Get the bus range */ | 1011 | INIT_LIST_HEAD(&pcie->resources); |
944 | if (of_pci_parse_bus_range(pdev->dev.of_node, &pcie->busn)) { | ||
945 | dev_err(&pdev->dev, "failed to parse bus-range property\n"); | ||
946 | return -EINVAL; | ||
947 | } | ||
948 | 1012 | ||
949 | if (of_pci_range_parser_init(&parser, pdev->dev.of_node)) { | 1013 | rcar_pcie_parse_request_of_pci_ranges(pcie); |
950 | dev_err(&pdev->dev, "missing ranges property\n"); | ||
951 | return -EINVAL; | ||
952 | } | ||
953 | 1014 | ||
954 | err = rcar_pcie_get_resources(pdev, pcie); | 1015 | err = rcar_pcie_get_resources(pdev, pcie); |
955 | if (err < 0) { | 1016 | if (err < 0) { |
@@ -957,46 +1018,55 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
957 | return err; | 1018 | return err; |
958 | } | 1019 | } |
959 | 1020 | ||
960 | for_each_of_pci_range(&parser, &range) { | ||
961 | err = of_pci_range_to_resource(&range, pdev->dev.of_node, | ||
962 | &pcie->res[win++]); | ||
963 | if (err < 0) | ||
964 | return err; | ||
965 | |||
966 | if (win > RCAR_PCI_MAX_RESOURCES) | ||
967 | break; | ||
968 | } | ||
969 | |||
970 | err = rcar_pcie_parse_map_dma_ranges(pcie, pdev->dev.of_node); | 1021 | err = rcar_pcie_parse_map_dma_ranges(pcie, pdev->dev.of_node); |
971 | if (err) | 1022 | if (err) |
972 | return err; | 1023 | return err; |
973 | 1024 | ||
974 | if (IS_ENABLED(CONFIG_PCI_MSI)) { | ||
975 | err = rcar_pcie_enable_msi(pcie); | ||
976 | if (err < 0) { | ||
977 | dev_err(&pdev->dev, | ||
978 | "failed to enable MSI support: %d\n", | ||
979 | err); | ||
980 | return err; | ||
981 | } | ||
982 | } | ||
983 | |||
984 | of_id = of_match_device(rcar_pcie_of_match, pcie->dev); | 1025 | of_id = of_match_device(rcar_pcie_of_match, pcie->dev); |
985 | if (!of_id || !of_id->data) | 1026 | if (!of_id || !of_id->data) |
986 | return -EINVAL; | 1027 | return -EINVAL; |
987 | hw_init_fn = of_id->data; | 1028 | hw_init_fn = of_id->data; |
988 | 1029 | ||
1030 | pm_runtime_enable(pcie->dev); | ||
1031 | err = pm_runtime_get_sync(pcie->dev); | ||
1032 | if (err < 0) { | ||
1033 | dev_err(pcie->dev, "pm_runtime_get_sync failed\n"); | ||
1034 | goto err_pm_disable; | ||
1035 | } | ||
1036 | |||
989 | /* Failure to get a link might just be that no cards are inserted */ | 1037 | /* Failure to get a link might just be that no cards are inserted */ |
990 | err = hw_init_fn(pcie); | 1038 | err = hw_init_fn(pcie); |
991 | if (err) { | 1039 | if (err) { |
992 | dev_info(&pdev->dev, "PCIe link down\n"); | 1040 | dev_info(&pdev->dev, "PCIe link down\n"); |
993 | return 0; | 1041 | err = 0; |
1042 | goto err_pm_put; | ||
994 | } | 1043 | } |
995 | 1044 | ||
996 | data = rcar_pci_read_reg(pcie, MACSR); | 1045 | data = rcar_pci_read_reg(pcie, MACSR); |
997 | dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); | 1046 | dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); |
998 | 1047 | ||
999 | return rcar_pcie_enable(pcie); | 1048 | if (IS_ENABLED(CONFIG_PCI_MSI)) { |
1049 | err = rcar_pcie_enable_msi(pcie); | ||
1050 | if (err < 0) { | ||
1051 | dev_err(&pdev->dev, | ||
1052 | "failed to enable MSI support: %d\n", | ||
1053 | err); | ||
1054 | goto err_pm_put; | ||
1055 | } | ||
1056 | } | ||
1057 | |||
1058 | err = rcar_pcie_enable(pcie); | ||
1059 | if (err) | ||
1060 | goto err_pm_put; | ||
1061 | |||
1062 | return 0; | ||
1063 | |||
1064 | err_pm_put: | ||
1065 | pm_runtime_put(pcie->dev); | ||
1066 | |||
1067 | err_pm_disable: | ||
1068 | pm_runtime_disable(pcie->dev); | ||
1069 | return err; | ||
1000 | } | 1070 | } |
1001 | 1071 | ||
1002 | static struct platform_driver rcar_pcie_driver = { | 1072 | static struct platform_driver rcar_pcie_driver = { |
diff --git a/drivers/pci/host/pcie-spear13xx.c b/drivers/pci/host/pcie-spear13xx.c index b95b7563c052..a6cd8233e8c0 100644 --- a/drivers/pci/host/pcie-spear13xx.c +++ b/drivers/pci/host/pcie-spear13xx.c | |||
@@ -279,7 +279,8 @@ static int spear13xx_add_pcie_port(struct pcie_port *pp, | |||
279 | return -ENODEV; | 279 | return -ENODEV; |
280 | } | 280 | } |
281 | ret = devm_request_irq(dev, pp->irq, spear13xx_pcie_irq_handler, | 281 | ret = devm_request_irq(dev, pp->irq, spear13xx_pcie_irq_handler, |
282 | IRQF_SHARED, "spear1340-pcie", pp); | 282 | IRQF_SHARED | IRQF_NO_THREAD, |
283 | "spear1340-pcie", pp); | ||
283 | if (ret) { | 284 | if (ret) { |
284 | dev_err(dev, "failed to request irq %d\n", pp->irq); | 285 | dev_err(dev, "failed to request irq %d\n", pp->irq); |
285 | return ret; | 286 | return ret; |
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c index 3c7a0d580b1e..4cfa46360d12 100644 --- a/drivers/pci/host/pcie-xilinx.c +++ b/drivers/pci/host/pcie-xilinx.c | |||
@@ -781,7 +781,8 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie_port *port) | |||
781 | 781 | ||
782 | port->irq = irq_of_parse_and_map(node, 0); | 782 | port->irq = irq_of_parse_and_map(node, 0); |
783 | err = devm_request_irq(dev, port->irq, xilinx_pcie_intr_handler, | 783 | err = devm_request_irq(dev, port->irq, xilinx_pcie_intr_handler, |
784 | IRQF_SHARED, "xilinx-pcie", port); | 784 | IRQF_SHARED | IRQF_NO_THREAD, |
785 | "xilinx-pcie", port); | ||
785 | if (err) { | 786 | if (err) { |
786 | dev_err(dev, "unable to request irq %d\n", port->irq); | 787 | dev_err(dev, "unable to request irq %d\n", port->irq); |
787 | return err; | 788 | return err; |
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index 876ccc620440..a5e66df4ad14 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -36,10 +36,10 @@ | |||
36 | 36 | ||
37 | #define MY_NAME "acpi_pcihp" | 37 | #define MY_NAME "acpi_pcihp" |
38 | 38 | ||
39 | #define dbg(fmt, arg...) do { if (debug_acpi) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0) | 39 | #define dbg(fmt, arg...) do { if (debug_acpi) printk(KERN_DEBUG "%s: %s: " fmt, MY_NAME, __func__, ## arg); } while (0) |
40 | #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) | 40 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
41 | #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) | 41 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
42 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) | 42 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
43 | 43 | ||
44 | #define METHOD_NAME__SUN "_SUN" | 44 | #define METHOD_NAME__SUN "_SUN" |
45 | #define METHOD_NAME_OSHP "OSHP" | 45 | #define METHOD_NAME_OSHP "OSHP" |
@@ -132,7 +132,7 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev, u32 flags) | |||
132 | 132 | ||
133 | while (handle) { | 133 | while (handle) { |
134 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); | 134 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); |
135 | dbg("Trying to get hotplug control for %s \n", | 135 | dbg("Trying to get hotplug control for %s\n", |
136 | (char *)string.pointer); | 136 | (char *)string.pointer); |
137 | status = acpi_run_oshp(handle); | 137 | status = acpi_run_oshp(handle); |
138 | if (ACPI_SUCCESS(status)) | 138 | if (ACPI_SUCCESS(status)) |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index b0e61bf261a7..f0ebc8b9a15a 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -181,7 +181,7 @@ struct acpiphp_attention_info | |||
181 | /* function prototypes */ | 181 | /* function prototypes */ |
182 | 182 | ||
183 | /* acpiphp_core.c */ | 183 | /* acpiphp_core.c */ |
184 | int acpiphp_register_attention(struct acpiphp_attention_info*info); | 184 | int acpiphp_register_attention(struct acpiphp_attention_info *info); |
185 | int acpiphp_unregister_attention(struct acpiphp_attention_info *info); | 185 | int acpiphp_unregister_attention(struct acpiphp_attention_info *info); |
186 | int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun); | 186 | int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun); |
187 | void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); | 187 | void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index e291efcd02a2..3c81fc8b0103 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -63,13 +63,13 @@ MODULE_LICENSE("GPL"); | |||
63 | MODULE_PARM_DESC(disable, "disable acpiphp driver"); | 63 | MODULE_PARM_DESC(disable, "disable acpiphp driver"); |
64 | module_param_named(disable, acpiphp_disabled, bool, 0444); | 64 | module_param_named(disable, acpiphp_disabled, bool, 0444); |
65 | 65 | ||
66 | static int enable_slot (struct hotplug_slot *slot); | 66 | static int enable_slot(struct hotplug_slot *slot); |
67 | static int disable_slot (struct hotplug_slot *slot); | 67 | static int disable_slot(struct hotplug_slot *slot); |
68 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 68 | static int set_attention_status(struct hotplug_slot *slot, u8 value); |
69 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | 69 | static int get_power_status(struct hotplug_slot *slot, u8 *value); |
70 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 70 | static int get_attention_status(struct hotplug_slot *slot, u8 *value); |
71 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 71 | static int get_latch_status(struct hotplug_slot *slot, u8 *value); |
72 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 72 | static int get_adapter_status(struct hotplug_slot *slot, u8 *value); |
73 | 73 | ||
74 | static struct hotplug_slot_ops acpi_hotplug_slot_ops = { | 74 | static struct hotplug_slot_ops acpi_hotplug_slot_ops = { |
75 | .enable_slot = enable_slot, | 75 | .enable_slot = enable_slot, |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index ff538568a617..5f2fda12e006 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -707,7 +707,7 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus) | |||
707 | unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; | 707 | unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; |
708 | 708 | ||
709 | list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) { | 709 | list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) { |
710 | for (i=0; i<PCI_BRIDGE_RESOURCES; i++) { | 710 | for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { |
711 | struct resource *res = &dev->resource[i]; | 711 | struct resource *res = &dev->resource[i]; |
712 | if ((res->flags & type_mask) && !res->start && | 712 | if ((res->flags & type_mask) && !res->start && |
713 | res->end) { | 713 | res->end) { |
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 6ca23998ee8f..2f6d3a1c1726 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -154,7 +154,8 @@ static union apci_descriptor *ibm_slot_from_id(int id) | |||
154 | ibm_slot_done: | 154 | ibm_slot_done: |
155 | if (ret) { | 155 | if (ret) { |
156 | ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL); | 156 | ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL); |
157 | memcpy(ret, des, sizeof(union apci_descriptor)); | 157 | if (ret) |
158 | memcpy(ret, des, sizeof(union apci_descriptor)); | ||
158 | } | 159 | } |
159 | kfree(table); | 160 | kfree(table); |
160 | return ret; | 161 | return ret; |
@@ -175,8 +176,13 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) | |||
175 | acpi_status stat; | 176 | acpi_status stat; |
176 | unsigned long long rc; | 177 | unsigned long long rc; |
177 | union apci_descriptor *ibm_slot; | 178 | union apci_descriptor *ibm_slot; |
179 | int id = hpslot_to_sun(slot); | ||
178 | 180 | ||
179 | ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot)); | 181 | ibm_slot = ibm_slot_from_id(id); |
182 | if (!ibm_slot) { | ||
183 | pr_err("APLS null ACPI descriptor for slot %d\n", id); | ||
184 | return -ENODEV; | ||
185 | } | ||
180 | 186 | ||
181 | pr_debug("%s: set slot %d (%d) attention status to %d\n", __func__, | 187 | pr_debug("%s: set slot %d (%d) attention status to %d\n", __func__, |
182 | ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, | 188 | ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, |
@@ -215,8 +221,13 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) | |||
215 | static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) | 221 | static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status) |
216 | { | 222 | { |
217 | union apci_descriptor *ibm_slot; | 223 | union apci_descriptor *ibm_slot; |
224 | int id = hpslot_to_sun(slot); | ||
218 | 225 | ||
219 | ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot)); | 226 | ibm_slot = ibm_slot_from_id(id); |
227 | if (!ibm_slot) { | ||
228 | pr_err("APLS null ACPI descriptor for slot %d\n", id); | ||
229 | return -ENODEV; | ||
230 | } | ||
220 | 231 | ||
221 | if (ibm_slot->slot.attn & 0xa0 || ibm_slot->slot.status[1] & 0x08) | 232 | if (ibm_slot->slot.attn & 0xa0 || ibm_slot->slot.status[1] & 0x08) |
222 | *status = 1; | 233 | *status = 1; |
@@ -325,7 +336,7 @@ static int ibm_get_table_from_acpi(char **bufp) | |||
325 | } | 336 | } |
326 | 337 | ||
327 | size = 0; | 338 | size = 0; |
328 | for (i=0; i<package->package.count; i++) { | 339 | for (i = 0; i < package->package.count; i++) { |
329 | memcpy(&lbuf[size], | 340 | memcpy(&lbuf[size], |
330 | package->package.elements[i].buffer.pointer, | 341 | package->package.elements[i].buffer.pointer, |
331 | package->package.elements[i].buffer.length); | 342 | package->package.elements[i].buffer.length); |
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h index 6a0ddf757349..555bcde3b196 100644 --- a/drivers/pci/hotplug/cpci_hotplug.h +++ b/drivers/pci/hotplug/cpci_hotplug.h | |||
@@ -52,13 +52,13 @@ struct slot { | |||
52 | }; | 52 | }; |
53 | 53 | ||
54 | struct cpci_hp_controller_ops { | 54 | struct cpci_hp_controller_ops { |
55 | int (*query_enum) (void); | 55 | int (*query_enum)(void); |
56 | int (*enable_irq) (void); | 56 | int (*enable_irq)(void); |
57 | int (*disable_irq) (void); | 57 | int (*disable_irq)(void); |
58 | int (*check_irq) (void *dev_id); | 58 | int (*check_irq)(void *dev_id); |
59 | int (*hardware_test) (struct slot *slot, u32 value); | 59 | int (*hardware_test)(struct slot *slot, u32 value); |
60 | u8 (*get_power) (struct slot *slot); | 60 | u8 (*get_power)(struct slot *slot); |
61 | int (*set_power) (struct slot *slot, int value); | 61 | int (*set_power)(struct slot *slot, int value); |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct cpci_hp_controller { | 64 | struct cpci_hp_controller { |
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 46db29395a62..7d3866c47312 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -45,12 +45,12 @@ | |||
45 | #define dbg(format, arg...) \ | 45 | #define dbg(format, arg...) \ |
46 | do { \ | 46 | do { \ |
47 | if (cpci_debug) \ | 47 | if (cpci_debug) \ |
48 | printk (KERN_DEBUG "%s: " format "\n", \ | 48 | printk(KERN_DEBUG "%s: " format "\n", \ |
49 | MY_NAME , ## arg); \ | 49 | MY_NAME, ## arg); \ |
50 | } while (0) | 50 | } while (0) |
51 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 51 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg) |
52 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 52 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg) |
53 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 53 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg) |
54 | 54 | ||
55 | /* local variables */ | 55 | /* local variables */ |
56 | static DECLARE_RWSEM(list_rwsem); | 56 | static DECLARE_RWSEM(list_rwsem); |
@@ -238,21 +238,21 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
238 | * with the pci_hotplug subsystem. | 238 | * with the pci_hotplug subsystem. |
239 | */ | 239 | */ |
240 | for (i = first; i <= last; ++i) { | 240 | for (i = first; i <= last; ++i) { |
241 | slot = kzalloc(sizeof (struct slot), GFP_KERNEL); | 241 | slot = kzalloc(sizeof(struct slot), GFP_KERNEL); |
242 | if (!slot) { | 242 | if (!slot) { |
243 | status = -ENOMEM; | 243 | status = -ENOMEM; |
244 | goto error; | 244 | goto error; |
245 | } | 245 | } |
246 | 246 | ||
247 | hotplug_slot = | 247 | hotplug_slot = |
248 | kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL); | 248 | kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
249 | if (!hotplug_slot) { | 249 | if (!hotplug_slot) { |
250 | status = -ENOMEM; | 250 | status = -ENOMEM; |
251 | goto error_slot; | 251 | goto error_slot; |
252 | } | 252 | } |
253 | slot->hotplug_slot = hotplug_slot; | 253 | slot->hotplug_slot = hotplug_slot; |
254 | 254 | ||
255 | info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); | 255 | info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
256 | if (!info) { | 256 | if (!info) { |
257 | status = -ENOMEM; | 257 | status = -ENOMEM; |
258 | goto error_hpslot; | 258 | goto error_hpslot; |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index 788db48dbbad..80c80017197d 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -38,12 +38,12 @@ extern int cpci_debug; | |||
38 | #define dbg(format, arg...) \ | 38 | #define dbg(format, arg...) \ |
39 | do { \ | 39 | do { \ |
40 | if (cpci_debug) \ | 40 | if (cpci_debug) \ |
41 | printk (KERN_DEBUG "%s: " format "\n", \ | 41 | printk(KERN_DEBUG "%s: " format "\n", \ |
42 | MY_NAME , ## arg); \ | 42 | MY_NAME, ## arg); \ |
43 | } while (0) | 43 | } while (0) |
44 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 44 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg) |
45 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 45 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg) |
46 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 46 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg) |
47 | 47 | ||
48 | 48 | ||
49 | u8 cpci_get_attention_status(struct slot *slot) | 49 | u8 cpci_get_attention_status(struct slot *slot) |
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c index 66b7bbebe493..88a44a707b96 100644 --- a/drivers/pci/hotplug/cpcihp_generic.c +++ b/drivers/pci/hotplug/cpcihp_generic.c | |||
@@ -54,12 +54,12 @@ | |||
54 | #define dbg(format, arg...) \ | 54 | #define dbg(format, arg...) \ |
55 | do { \ | 55 | do { \ |
56 | if (debug) \ | 56 | if (debug) \ |
57 | printk (KERN_DEBUG "%s: " format "\n", \ | 57 | printk(KERN_DEBUG "%s: " format "\n", \ |
58 | MY_NAME , ## arg); \ | 58 | MY_NAME, ## arg); \ |
59 | } while (0) | 59 | } while (0) |
60 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 60 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg) |
61 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 61 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg) |
62 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 62 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg) |
63 | 63 | ||
64 | /* local variables */ | 64 | /* local variables */ |
65 | static bool debug; | 65 | static bool debug; |
@@ -164,7 +164,7 @@ static int __init cpcihp_generic_init(void) | |||
164 | bus = dev->subordinate; | 164 | bus = dev->subordinate; |
165 | pci_dev_put(dev); | 165 | pci_dev_put(dev); |
166 | 166 | ||
167 | memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller)); | 167 | memset(&generic_hpc, 0, sizeof(struct cpci_hp_controller)); |
168 | generic_hpc_ops.query_enum = query_enum; | 168 | generic_hpc_ops.query_enum = query_enum; |
169 | generic_hpc.ops = &generic_hpc_ops; | 169 | generic_hpc.ops = &generic_hpc_ops; |
170 | 170 | ||
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c index 7ecf34e76a61..5f49c3fd736a 100644 --- a/drivers/pci/hotplug/cpcihp_zt5550.c +++ b/drivers/pci/hotplug/cpcihp_zt5550.c | |||
@@ -49,12 +49,12 @@ | |||
49 | #define dbg(format, arg...) \ | 49 | #define dbg(format, arg...) \ |
50 | do { \ | 50 | do { \ |
51 | if (debug) \ | 51 | if (debug) \ |
52 | printk (KERN_DEBUG "%s: " format "\n", \ | 52 | printk(KERN_DEBUG "%s: " format "\n", \ |
53 | MY_NAME , ## arg); \ | 53 | MY_NAME, ## arg); \ |
54 | } while (0) | 54 | } while (0) |
55 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 55 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg) |
56 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 56 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg) |
57 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 57 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg) |
58 | 58 | ||
59 | /* local variables */ | 59 | /* local variables */ |
60 | static bool debug; | 60 | static bool debug; |
@@ -204,7 +204,7 @@ static int zt5550_hc_disable_irq(void) | |||
204 | return 0; | 204 | return 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 207 | static int zt5550_hc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
208 | { | 208 | { |
209 | int status; | 209 | int status; |
210 | 210 | ||
@@ -214,7 +214,7 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id | |||
214 | 214 | ||
215 | dbg("returned from zt5550_hc_config"); | 215 | dbg("returned from zt5550_hc_config"); |
216 | 216 | ||
217 | memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller)); | 217 | memset(&zt5550_hpc, 0, sizeof(struct cpci_hp_controller)); |
218 | zt5550_hpc_ops.query_enum = zt5550_hc_query_enum; | 218 | zt5550_hpc_ops.query_enum = zt5550_hc_query_enum; |
219 | zt5550_hpc.ops = &zt5550_hpc_ops; | 219 | zt5550_hpc.ops = &zt5550_hpc_ops; |
220 | if (!poll) { | 220 | if (!poll) { |
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index b28b2d2184cd..9103a7b9f3b9 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h | |||
@@ -36,10 +36,10 @@ | |||
36 | 36 | ||
37 | #define MY_NAME "cpqphp" | 37 | #define MY_NAME "cpqphp" |
38 | 38 | ||
39 | #define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) | 39 | #define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0) |
40 | #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) | 40 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
41 | #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) | 41 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
42 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) | 42 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
@@ -424,7 +424,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func); | |||
424 | int cpqhp_hardware_test(struct controller *ctrl, int test_num); | 424 | int cpqhp_hardware_test(struct controller *ctrl, int test_num); |
425 | 425 | ||
426 | /* resource functions */ | 426 | /* resource functions */ |
427 | int cpqhp_resource_sort_and_combine (struct pci_resource **head); | 427 | int cpqhp_resource_sort_and_combine(struct pci_resource **head); |
428 | 428 | ||
429 | /* pci functions */ | 429 | /* pci functions */ |
430 | int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num); | 430 | int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num); |
@@ -685,7 +685,7 @@ static inline int cpq_get_latch_status(struct controller *ctrl, | |||
685 | u8 hp_slot; | 685 | u8 hp_slot; |
686 | 686 | ||
687 | hp_slot = slot->device - ctrl->slot_device_offset; | 687 | hp_slot = slot->device - ctrl->slot_device_offset; |
688 | dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d \n", | 688 | dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d\n", |
689 | __func__, slot->device, ctrl->slot_device_offset); | 689 | __func__, slot->device, ctrl->slot_device_offset); |
690 | 690 | ||
691 | status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)); | 691 | status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)); |
@@ -712,7 +712,7 @@ static inline int get_presence_status(struct controller *ctrl, | |||
712 | 712 | ||
713 | static inline int wait_for_ctrl_irq(struct controller *ctrl) | 713 | static inline int wait_for_ctrl_irq(struct controller *ctrl) |
714 | { | 714 | { |
715 | DECLARE_WAITQUEUE(wait, current); | 715 | DECLARE_WAITQUEUE(wait, current); |
716 | int retval = 0; | 716 | int retval = 0; |
717 | 717 | ||
718 | dbg("%s - start\n", __func__); | 718 | dbg("%s - start\n", __func__); |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index a53084ddc118..74f3a0695b43 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -291,7 +291,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
291 | kfree(slot); | 291 | kfree(slot); |
292 | } | 292 | } |
293 | 293 | ||
294 | static int ctrl_slot_cleanup (struct controller *ctrl) | 294 | static int ctrl_slot_cleanup(struct controller *ctrl) |
295 | { | 295 | { |
296 | struct slot *old_slot, *next_slot; | 296 | struct slot *old_slot, *next_slot; |
297 | 297 | ||
@@ -301,7 +301,7 @@ static int ctrl_slot_cleanup (struct controller *ctrl) | |||
301 | while (old_slot) { | 301 | while (old_slot) { |
302 | /* memory will be freed by the release_slot callback */ | 302 | /* memory will be freed by the release_slot callback */ |
303 | next_slot = old_slot->next; | 303 | next_slot = old_slot->next; |
304 | pci_hp_deregister (old_slot->hotplug_slot); | 304 | pci_hp_deregister(old_slot->hotplug_slot); |
305 | old_slot = next_slot; | 305 | old_slot = next_slot; |
306 | } | 306 | } |
307 | 307 | ||
@@ -413,9 +413,9 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
413 | mutex_lock(&ctrl->crit_sect); | 413 | mutex_lock(&ctrl->crit_sect); |
414 | 414 | ||
415 | if (status == 1) | 415 | if (status == 1) |
416 | amber_LED_on (ctrl, hp_slot); | 416 | amber_LED_on(ctrl, hp_slot); |
417 | else if (status == 0) | 417 | else if (status == 0) |
418 | amber_LED_off (ctrl, hp_slot); | 418 | amber_LED_off(ctrl, hp_slot); |
419 | else { | 419 | else { |
420 | /* Done with exclusive hardware access */ | 420 | /* Done with exclusive hardware access */ |
421 | mutex_unlock(&ctrl->crit_sect); | 421 | mutex_unlock(&ctrl->crit_sect); |
@@ -425,7 +425,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
425 | set_SOGO(ctrl); | 425 | set_SOGO(ctrl); |
426 | 426 | ||
427 | /* Wait for SOBS to be unset */ | 427 | /* Wait for SOBS to be unset */ |
428 | wait_for_ctrl_irq (ctrl); | 428 | wait_for_ctrl_irq(ctrl); |
429 | 429 | ||
430 | /* Done with exclusive hardware access */ | 430 | /* Done with exclusive hardware access */ |
431 | mutex_unlock(&ctrl->crit_sect); | 431 | mutex_unlock(&ctrl->crit_sect); |
@@ -439,7 +439,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
439 | * @hotplug_slot: slot to change LED on | 439 | * @hotplug_slot: slot to change LED on |
440 | * @status: LED control flag | 440 | * @status: LED control flag |
441 | */ | 441 | */ |
442 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | 442 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) |
443 | { | 443 | { |
444 | struct pci_func *slot_func; | 444 | struct pci_func *slot_func; |
445 | struct slot *slot = hotplug_slot->private; | 445 | struct slot *slot = hotplug_slot->private; |
@@ -610,7 +610,7 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
610 | u8 ctrl_slot; | 610 | u8 ctrl_slot; |
611 | u32 tempdword; | 611 | u32 tempdword; |
612 | char name[SLOT_NAME_SIZE]; | 612 | char name[SLOT_NAME_SIZE]; |
613 | void __iomem *slot_entry= NULL; | 613 | void __iomem *slot_entry = NULL; |
614 | int result; | 614 | int result; |
615 | 615 | ||
616 | dbg("%s\n", __func__); | 616 | dbg("%s\n", __func__); |
@@ -755,7 +755,7 @@ static int one_time_init(void) | |||
755 | if (cpqhp_debug) | 755 | if (cpqhp_debug) |
756 | pci_print_IRQ_route(); | 756 | pci_print_IRQ_route(); |
757 | 757 | ||
758 | dbg("Initialize + Start the notification mechanism \n"); | 758 | dbg("Initialize + Start the notification mechanism\n"); |
759 | 759 | ||
760 | retval = cpqhp_event_start_thread(); | 760 | retval = cpqhp_event_start_thread(); |
761 | if (retval) | 761 | if (retval) |
@@ -772,7 +772,7 @@ static int one_time_init(void) | |||
772 | /* Map rom address */ | 772 | /* Map rom address */ |
773 | cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); | 773 | cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); |
774 | if (!cpqhp_rom_start) { | 774 | if (!cpqhp_rom_start) { |
775 | err ("Could not ioremap memory region for ROM\n"); | 775 | err("Could not ioremap memory region for ROM\n"); |
776 | retval = -EIO; | 776 | retval = -EIO; |
777 | goto error; | 777 | goto error; |
778 | } | 778 | } |
@@ -786,7 +786,7 @@ static int one_time_init(void) | |||
786 | smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, | 786 | smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, |
787 | cpqhp_rom_start + ROM_PHY_LEN); | 787 | cpqhp_rom_start + ROM_PHY_LEN); |
788 | if (!smbios_table) { | 788 | if (!smbios_table) { |
789 | err ("Could not find the SMBIOS pointer in memory\n"); | 789 | err("Could not find the SMBIOS pointer in memory\n"); |
790 | retval = -EIO; | 790 | retval = -EIO; |
791 | goto error_rom_start; | 791 | goto error_rom_start; |
792 | } | 792 | } |
@@ -794,7 +794,7 @@ static int one_time_init(void) | |||
794 | smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), | 794 | smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), |
795 | readw(smbios_table + ST_LENGTH)); | 795 | readw(smbios_table + ST_LENGTH)); |
796 | if (!smbios_start) { | 796 | if (!smbios_start) { |
797 | err ("Could not ioremap memory region taken from SMBIOS values\n"); | 797 | err("Could not ioremap memory region taken from SMBIOS values\n"); |
798 | retval = -EIO; | 798 | retval = -EIO; |
799 | goto error_smbios_start; | 799 | goto error_smbios_start; |
800 | } | 800 | } |
@@ -1181,7 +1181,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1181 | * Finish setting up the hot plug ctrl device | 1181 | * Finish setting up the hot plug ctrl device |
1182 | */ | 1182 | */ |
1183 | ctrl->slot_device_offset = readb(ctrl->hpc_reg + SLOT_MASK) >> 4; | 1183 | ctrl->slot_device_offset = readb(ctrl->hpc_reg + SLOT_MASK) >> 4; |
1184 | dbg("NumSlots %d \n", ctrl->slot_device_offset); | 1184 | dbg("NumSlots %d\n", ctrl->slot_device_offset); |
1185 | 1185 | ||
1186 | ctrl->next_event = 0; | 1186 | ctrl->next_event = 0; |
1187 | 1187 | ||
@@ -1198,7 +1198,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1198 | writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK); | 1198 | writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK); |
1199 | 1199 | ||
1200 | /* set up the interrupt */ | 1200 | /* set up the interrupt */ |
1201 | dbg("HPC interrupt = %d \n", ctrl->interrupt); | 1201 | dbg("HPC interrupt = %d\n", ctrl->interrupt); |
1202 | if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr, | 1202 | if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr, |
1203 | IRQF_SHARED, MY_NAME, ctrl)) { | 1203 | IRQF_SHARED, MY_NAME, ctrl)) { |
1204 | err("Can't get irq %d for the hotplug pci controller\n", | 1204 | err("Can't get irq %d for the hotplug pci controller\n", |
@@ -1321,7 +1321,7 @@ static void __exit unload_cpqphpd(void) | |||
1321 | while (ctrl) { | 1321 | while (ctrl) { |
1322 | if (ctrl->hpc_reg) { | 1322 | if (ctrl->hpc_reg) { |
1323 | u16 misc; | 1323 | u16 misc; |
1324 | rc = read_slot_enable (ctrl); | 1324 | rc = read_slot_enable(ctrl); |
1325 | 1325 | ||
1326 | writeb(0, ctrl->hpc_reg + SLOT_SERR); | 1326 | writeb(0, ctrl->hpc_reg + SLOT_SERR); |
1327 | writel(0xFFFFFFC0L | ~rc, ctrl->hpc_reg + INT_MASK); | 1327 | writel(0xFFFFFFC0L | ~rc, ctrl->hpc_reg + INT_MASK); |
@@ -1361,7 +1361,7 @@ static void __exit unload_cpqphpd(void) | |||
1361 | kfree(tres); | 1361 | kfree(tres); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | kfree (ctrl->pci_bus); | 1364 | kfree(ctrl->pci_bus); |
1365 | 1365 | ||
1366 | tctrl = ctrl; | 1366 | tctrl = ctrl; |
1367 | ctrl = ctrl->next; | 1367 | ctrl = ctrl->next; |
@@ -1446,7 +1446,7 @@ static int __init cpqhpc_init(void) | |||
1446 | 1446 | ||
1447 | cpqhp_debug = debug; | 1447 | cpqhp_debug = debug; |
1448 | 1448 | ||
1449 | info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 1449 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
1450 | cpqhp_initialize_debugfs(); | 1450 | cpqhp_initialize_debugfs(); |
1451 | result = pci_register_driver(&cpqhpc_driver); | 1451 | result = pci_register_driver(&cpqhpc_driver); |
1452 | dbg("pci_register_driver = %d\n", result); | 1452 | dbg("pci_register_driver = %d\n", result); |
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index c5cbefee5236..a55653b54eed 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -155,7 +155,7 @@ static u8 handle_presence_change(u16 change, struct controller *ctrl) | |||
155 | * Presence Change | 155 | * Presence Change |
156 | */ | 156 | */ |
157 | dbg("cpqsbd: Presence/Notify input change.\n"); | 157 | dbg("cpqsbd: Presence/Notify input change.\n"); |
158 | dbg(" Changed bits are 0x%4.4x\n", change ); | 158 | dbg(" Changed bits are 0x%4.4x\n", change); |
159 | 159 | ||
160 | for (hp_slot = 0; hp_slot < 6; hp_slot++) { | 160 | for (hp_slot = 0; hp_slot < 6; hp_slot++) { |
161 | if (change & (0x0101 << hp_slot)) { | 161 | if (change & (0x0101 << hp_slot)) { |
@@ -276,9 +276,9 @@ static u8 handle_power_fault(u8 change, struct controller *ctrl) | |||
276 | taskInfo->event_type = INT_POWER_FAULT; | 276 | taskInfo->event_type = INT_POWER_FAULT; |
277 | 277 | ||
278 | if (ctrl->rev < 4) { | 278 | if (ctrl->rev < 4) { |
279 | amber_LED_on (ctrl, hp_slot); | 279 | amber_LED_on(ctrl, hp_slot); |
280 | green_LED_off (ctrl, hp_slot); | 280 | green_LED_off(ctrl, hp_slot); |
281 | set_SOGO (ctrl); | 281 | set_SOGO(ctrl); |
282 | 282 | ||
283 | /* this is a fatal condition, we want | 283 | /* this is a fatal condition, we want |
284 | * to crash the machine to protect from | 284 | * to crash the machine to protect from |
@@ -438,7 +438,7 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h | |||
438 | 438 | ||
439 | node = *head; | 439 | node = *head; |
440 | 440 | ||
441 | if (node->length & (alignment -1)) { | 441 | if (node->length & (alignment - 1)) { |
442 | /* this one isn't an aligned length, so we'll make a new entry | 442 | /* this one isn't an aligned length, so we'll make a new entry |
443 | * and split it up. | 443 | * and split it up. |
444 | */ | 444 | */ |
@@ -835,13 +835,13 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head) | |||
835 | if (!(*head)) | 835 | if (!(*head)) |
836 | return 1; | 836 | return 1; |
837 | 837 | ||
838 | dbg("*head->next = %p\n",(*head)->next); | 838 | dbg("*head->next = %p\n", (*head)->next); |
839 | 839 | ||
840 | if (!(*head)->next) | 840 | if (!(*head)->next) |
841 | return 0; /* only one item on the list, already sorted! */ | 841 | return 0; /* only one item on the list, already sorted! */ |
842 | 842 | ||
843 | dbg("*head->base = 0x%x\n",(*head)->base); | 843 | dbg("*head->base = 0x%x\n", (*head)->base); |
844 | dbg("*head->next->base = 0x%x\n",(*head)->next->base); | 844 | dbg("*head->next->base = 0x%x\n", (*head)->next->base); |
845 | while (out_of_order) { | 845 | while (out_of_order) { |
846 | out_of_order = 0; | 846 | out_of_order = 0; |
847 | 847 | ||
@@ -917,7 +917,7 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data) | |||
917 | /* Read to clear posted writes */ | 917 | /* Read to clear posted writes */ |
918 | misc = readw(ctrl->hpc_reg + MISC); | 918 | misc = readw(ctrl->hpc_reg + MISC); |
919 | 919 | ||
920 | dbg ("%s - waking up\n", __func__); | 920 | dbg("%s - waking up\n", __func__); |
921 | wake_up_interruptible(&ctrl->queue); | 921 | wake_up_interruptible(&ctrl->queue); |
922 | } | 922 | } |
923 | 923 | ||
@@ -1285,18 +1285,18 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1285 | /* | 1285 | /* |
1286 | * The board is already on | 1286 | * The board is already on |
1287 | */ | 1287 | */ |
1288 | else if (is_slot_enabled (ctrl, hp_slot)) | 1288 | else if (is_slot_enabled(ctrl, hp_slot)) |
1289 | rc = CARD_FUNCTIONING; | 1289 | rc = CARD_FUNCTIONING; |
1290 | else { | 1290 | else { |
1291 | mutex_lock(&ctrl->crit_sect); | 1291 | mutex_lock(&ctrl->crit_sect); |
1292 | 1292 | ||
1293 | /* turn on board without attaching to the bus */ | 1293 | /* turn on board without attaching to the bus */ |
1294 | enable_slot_power (ctrl, hp_slot); | 1294 | enable_slot_power(ctrl, hp_slot); |
1295 | 1295 | ||
1296 | set_SOGO(ctrl); | 1296 | set_SOGO(ctrl); |
1297 | 1297 | ||
1298 | /* Wait for SOBS to be unset */ | 1298 | /* Wait for SOBS to be unset */ |
1299 | wait_for_ctrl_irq (ctrl); | 1299 | wait_for_ctrl_irq(ctrl); |
1300 | 1300 | ||
1301 | /* Change bits in slot power register to force another shift out | 1301 | /* Change bits in slot power register to force another shift out |
1302 | * NOTE: this is to work around the timer bug */ | 1302 | * NOTE: this is to work around the timer bug */ |
@@ -1307,7 +1307,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1307 | set_SOGO(ctrl); | 1307 | set_SOGO(ctrl); |
1308 | 1308 | ||
1309 | /* Wait for SOBS to be unset */ | 1309 | /* Wait for SOBS to be unset */ |
1310 | wait_for_ctrl_irq (ctrl); | 1310 | wait_for_ctrl_irq(ctrl); |
1311 | 1311 | ||
1312 | adapter_speed = get_adapter_speed(ctrl, hp_slot); | 1312 | adapter_speed = get_adapter_speed(ctrl, hp_slot); |
1313 | if (bus->cur_bus_speed != adapter_speed) | 1313 | if (bus->cur_bus_speed != adapter_speed) |
@@ -1315,12 +1315,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1315 | rc = WRONG_BUS_FREQUENCY; | 1315 | rc = WRONG_BUS_FREQUENCY; |
1316 | 1316 | ||
1317 | /* turn off board without attaching to the bus */ | 1317 | /* turn off board without attaching to the bus */ |
1318 | disable_slot_power (ctrl, hp_slot); | 1318 | disable_slot_power(ctrl, hp_slot); |
1319 | 1319 | ||
1320 | set_SOGO(ctrl); | 1320 | set_SOGO(ctrl); |
1321 | 1321 | ||
1322 | /* Wait for SOBS to be unset */ | 1322 | /* Wait for SOBS to be unset */ |
1323 | wait_for_ctrl_irq (ctrl); | 1323 | wait_for_ctrl_irq(ctrl); |
1324 | 1324 | ||
1325 | mutex_unlock(&ctrl->crit_sect); | 1325 | mutex_unlock(&ctrl->crit_sect); |
1326 | 1326 | ||
@@ -1329,15 +1329,15 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1329 | 1329 | ||
1330 | mutex_lock(&ctrl->crit_sect); | 1330 | mutex_lock(&ctrl->crit_sect); |
1331 | 1331 | ||
1332 | slot_enable (ctrl, hp_slot); | 1332 | slot_enable(ctrl, hp_slot); |
1333 | green_LED_blink (ctrl, hp_slot); | 1333 | green_LED_blink(ctrl, hp_slot); |
1334 | 1334 | ||
1335 | amber_LED_off (ctrl, hp_slot); | 1335 | amber_LED_off(ctrl, hp_slot); |
1336 | 1336 | ||
1337 | set_SOGO(ctrl); | 1337 | set_SOGO(ctrl); |
1338 | 1338 | ||
1339 | /* Wait for SOBS to be unset */ | 1339 | /* Wait for SOBS to be unset */ |
1340 | wait_for_ctrl_irq (ctrl); | 1340 | wait_for_ctrl_irq(ctrl); |
1341 | 1341 | ||
1342 | mutex_unlock(&ctrl->crit_sect); | 1342 | mutex_unlock(&ctrl->crit_sect); |
1343 | 1343 | ||
@@ -1366,14 +1366,14 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1366 | 1366 | ||
1367 | mutex_lock(&ctrl->crit_sect); | 1367 | mutex_lock(&ctrl->crit_sect); |
1368 | 1368 | ||
1369 | amber_LED_on (ctrl, hp_slot); | 1369 | amber_LED_on(ctrl, hp_slot); |
1370 | green_LED_off (ctrl, hp_slot); | 1370 | green_LED_off(ctrl, hp_slot); |
1371 | slot_disable (ctrl, hp_slot); | 1371 | slot_disable(ctrl, hp_slot); |
1372 | 1372 | ||
1373 | set_SOGO(ctrl); | 1373 | set_SOGO(ctrl); |
1374 | 1374 | ||
1375 | /* Wait for SOBS to be unset */ | 1375 | /* Wait for SOBS to be unset */ |
1376 | wait_for_ctrl_irq (ctrl); | 1376 | wait_for_ctrl_irq(ctrl); |
1377 | 1377 | ||
1378 | mutex_unlock(&ctrl->crit_sect); | 1378 | mutex_unlock(&ctrl->crit_sect); |
1379 | 1379 | ||
@@ -1392,14 +1392,14 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1392 | 1392 | ||
1393 | mutex_lock(&ctrl->crit_sect); | 1393 | mutex_lock(&ctrl->crit_sect); |
1394 | 1394 | ||
1395 | amber_LED_on (ctrl, hp_slot); | 1395 | amber_LED_on(ctrl, hp_slot); |
1396 | green_LED_off (ctrl, hp_slot); | 1396 | green_LED_off(ctrl, hp_slot); |
1397 | slot_disable (ctrl, hp_slot); | 1397 | slot_disable(ctrl, hp_slot); |
1398 | 1398 | ||
1399 | set_SOGO(ctrl); | 1399 | set_SOGO(ctrl); |
1400 | 1400 | ||
1401 | /* Wait for SOBS to be unset */ | 1401 | /* Wait for SOBS to be unset */ |
1402 | wait_for_ctrl_irq (ctrl); | 1402 | wait_for_ctrl_irq(ctrl); |
1403 | 1403 | ||
1404 | mutex_unlock(&ctrl->crit_sect); | 1404 | mutex_unlock(&ctrl->crit_sect); |
1405 | } | 1405 | } |
@@ -1443,7 +1443,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1443 | set_SOGO(ctrl); | 1443 | set_SOGO(ctrl); |
1444 | 1444 | ||
1445 | /* Wait for SOBS to be unset */ | 1445 | /* Wait for SOBS to be unset */ |
1446 | wait_for_ctrl_irq (ctrl); | 1446 | wait_for_ctrl_irq(ctrl); |
1447 | 1447 | ||
1448 | /* Change bits in slot power register to force another shift out | 1448 | /* Change bits in slot power register to force another shift out |
1449 | * NOTE: this is to work around the timer bug | 1449 | * NOTE: this is to work around the timer bug |
@@ -1455,7 +1455,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1455 | set_SOGO(ctrl); | 1455 | set_SOGO(ctrl); |
1456 | 1456 | ||
1457 | /* Wait for SOBS to be unset */ | 1457 | /* Wait for SOBS to be unset */ |
1458 | wait_for_ctrl_irq (ctrl); | 1458 | wait_for_ctrl_irq(ctrl); |
1459 | 1459 | ||
1460 | adapter_speed = get_adapter_speed(ctrl, hp_slot); | 1460 | adapter_speed = get_adapter_speed(ctrl, hp_slot); |
1461 | if (bus->cur_bus_speed != adapter_speed) | 1461 | if (bus->cur_bus_speed != adapter_speed) |
@@ -1463,7 +1463,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1463 | rc = WRONG_BUS_FREQUENCY; | 1463 | rc = WRONG_BUS_FREQUENCY; |
1464 | 1464 | ||
1465 | /* turn off board without attaching to the bus */ | 1465 | /* turn off board without attaching to the bus */ |
1466 | disable_slot_power (ctrl, hp_slot); | 1466 | disable_slot_power(ctrl, hp_slot); |
1467 | 1467 | ||
1468 | set_SOGO(ctrl); | 1468 | set_SOGO(ctrl); |
1469 | 1469 | ||
@@ -1484,20 +1484,20 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1484 | dbg("%s: after down\n", __func__); | 1484 | dbg("%s: after down\n", __func__); |
1485 | 1485 | ||
1486 | dbg("%s: before slot_enable\n", __func__); | 1486 | dbg("%s: before slot_enable\n", __func__); |
1487 | slot_enable (ctrl, hp_slot); | 1487 | slot_enable(ctrl, hp_slot); |
1488 | 1488 | ||
1489 | dbg("%s: before green_LED_blink\n", __func__); | 1489 | dbg("%s: before green_LED_blink\n", __func__); |
1490 | green_LED_blink (ctrl, hp_slot); | 1490 | green_LED_blink(ctrl, hp_slot); |
1491 | 1491 | ||
1492 | dbg("%s: before amber_LED_blink\n", __func__); | 1492 | dbg("%s: before amber_LED_blink\n", __func__); |
1493 | amber_LED_off (ctrl, hp_slot); | 1493 | amber_LED_off(ctrl, hp_slot); |
1494 | 1494 | ||
1495 | dbg("%s: before set_SOGO\n", __func__); | 1495 | dbg("%s: before set_SOGO\n", __func__); |
1496 | set_SOGO(ctrl); | 1496 | set_SOGO(ctrl); |
1497 | 1497 | ||
1498 | /* Wait for SOBS to be unset */ | 1498 | /* Wait for SOBS to be unset */ |
1499 | dbg("%s: before wait_for_ctrl_irq\n", __func__); | 1499 | dbg("%s: before wait_for_ctrl_irq\n", __func__); |
1500 | wait_for_ctrl_irq (ctrl); | 1500 | wait_for_ctrl_irq(ctrl); |
1501 | dbg("%s: after wait_for_ctrl_irq\n", __func__); | 1501 | dbg("%s: after wait_for_ctrl_irq\n", __func__); |
1502 | 1502 | ||
1503 | dbg("%s: before up\n", __func__); | 1503 | dbg("%s: before up\n", __func__); |
@@ -1520,7 +1520,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1520 | } else { | 1520 | } else { |
1521 | /* Get vendor/device ID u32 */ | 1521 | /* Get vendor/device ID u32 */ |
1522 | ctrl->pci_bus->number = func->bus; | 1522 | ctrl->pci_bus->number = func->bus; |
1523 | rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register); | 1523 | rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register); |
1524 | dbg("%s: pci_read_config_dword returns %d\n", __func__, rc); | 1524 | dbg("%s: pci_read_config_dword returns %d\n", __func__, rc); |
1525 | dbg("%s: temp_register is %x\n", __func__, temp_register); | 1525 | dbg("%s: temp_register is %x\n", __func__, temp_register); |
1526 | 1526 | ||
@@ -1557,14 +1557,14 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1557 | if (rc) { | 1557 | if (rc) { |
1558 | mutex_lock(&ctrl->crit_sect); | 1558 | mutex_lock(&ctrl->crit_sect); |
1559 | 1559 | ||
1560 | amber_LED_on (ctrl, hp_slot); | 1560 | amber_LED_on(ctrl, hp_slot); |
1561 | green_LED_off (ctrl, hp_slot); | 1561 | green_LED_off(ctrl, hp_slot); |
1562 | slot_disable (ctrl, hp_slot); | 1562 | slot_disable(ctrl, hp_slot); |
1563 | 1563 | ||
1564 | set_SOGO(ctrl); | 1564 | set_SOGO(ctrl); |
1565 | 1565 | ||
1566 | /* Wait for SOBS to be unset */ | 1566 | /* Wait for SOBS to be unset */ |
1567 | wait_for_ctrl_irq (ctrl); | 1567 | wait_for_ctrl_irq(ctrl); |
1568 | 1568 | ||
1569 | mutex_unlock(&ctrl->crit_sect); | 1569 | mutex_unlock(&ctrl->crit_sect); |
1570 | return rc; | 1570 | return rc; |
@@ -1589,25 +1589,25 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1589 | 1589 | ||
1590 | mutex_lock(&ctrl->crit_sect); | 1590 | mutex_lock(&ctrl->crit_sect); |
1591 | 1591 | ||
1592 | green_LED_on (ctrl, hp_slot); | 1592 | green_LED_on(ctrl, hp_slot); |
1593 | 1593 | ||
1594 | set_SOGO(ctrl); | 1594 | set_SOGO(ctrl); |
1595 | 1595 | ||
1596 | /* Wait for SOBS to be unset */ | 1596 | /* Wait for SOBS to be unset */ |
1597 | wait_for_ctrl_irq (ctrl); | 1597 | wait_for_ctrl_irq(ctrl); |
1598 | 1598 | ||
1599 | mutex_unlock(&ctrl->crit_sect); | 1599 | mutex_unlock(&ctrl->crit_sect); |
1600 | } else { | 1600 | } else { |
1601 | mutex_lock(&ctrl->crit_sect); | 1601 | mutex_lock(&ctrl->crit_sect); |
1602 | 1602 | ||
1603 | amber_LED_on (ctrl, hp_slot); | 1603 | amber_LED_on(ctrl, hp_slot); |
1604 | green_LED_off (ctrl, hp_slot); | 1604 | green_LED_off(ctrl, hp_slot); |
1605 | slot_disable (ctrl, hp_slot); | 1605 | slot_disable(ctrl, hp_slot); |
1606 | 1606 | ||
1607 | set_SOGO(ctrl); | 1607 | set_SOGO(ctrl); |
1608 | 1608 | ||
1609 | /* Wait for SOBS to be unset */ | 1609 | /* Wait for SOBS to be unset */ |
1610 | wait_for_ctrl_irq (ctrl); | 1610 | wait_for_ctrl_irq(ctrl); |
1611 | 1611 | ||
1612 | mutex_unlock(&ctrl->crit_sect); | 1612 | mutex_unlock(&ctrl->crit_sect); |
1613 | 1613 | ||
@@ -1672,8 +1672,8 @@ static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controll | |||
1672 | 1672 | ||
1673 | mutex_lock(&ctrl->crit_sect); | 1673 | mutex_lock(&ctrl->crit_sect); |
1674 | 1674 | ||
1675 | green_LED_off (ctrl, hp_slot); | 1675 | green_LED_off(ctrl, hp_slot); |
1676 | slot_disable (ctrl, hp_slot); | 1676 | slot_disable(ctrl, hp_slot); |
1677 | 1677 | ||
1678 | set_SOGO(ctrl); | 1678 | set_SOGO(ctrl); |
1679 | 1679 | ||
@@ -1683,7 +1683,7 @@ static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controll | |||
1683 | writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR); | 1683 | writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR); |
1684 | 1684 | ||
1685 | /* Wait for SOBS to be unset */ | 1685 | /* Wait for SOBS to be unset */ |
1686 | wait_for_ctrl_irq (ctrl); | 1686 | wait_for_ctrl_irq(ctrl); |
1687 | 1687 | ||
1688 | mutex_unlock(&ctrl->crit_sect); | 1688 | mutex_unlock(&ctrl->crit_sect); |
1689 | 1689 | ||
@@ -1755,7 +1755,7 @@ static int event_thread(void *data) | |||
1755 | if (pushbutton_pending) | 1755 | if (pushbutton_pending) |
1756 | cpqhp_pushbutton_thread(pushbutton_pending); | 1756 | cpqhp_pushbutton_thread(pushbutton_pending); |
1757 | else | 1757 | else |
1758 | for (ctrl = cpqhp_ctrl_list; ctrl; ctrl=ctrl->next) | 1758 | for (ctrl = cpqhp_ctrl_list; ctrl; ctrl = ctrl->next) |
1759 | interrupt_event_handler(ctrl); | 1759 | interrupt_event_handler(ctrl); |
1760 | } | 1760 | } |
1761 | dbg("event_thread signals exit\n"); | 1761 | dbg("event_thread signals exit\n"); |
@@ -1766,7 +1766,7 @@ int cpqhp_event_start_thread(void) | |||
1766 | { | 1766 | { |
1767 | cpqhp_event_thread = kthread_run(event_thread, NULL, "phpd_event"); | 1767 | cpqhp_event_thread = kthread_run(event_thread, NULL, "phpd_event"); |
1768 | if (IS_ERR(cpqhp_event_thread)) { | 1768 | if (IS_ERR(cpqhp_event_thread)) { |
1769 | err ("Can't start up our event thread\n"); | 1769 | err("Can't start up our event thread\n"); |
1770 | return PTR_ERR(cpqhp_event_thread); | 1770 | return PTR_ERR(cpqhp_event_thread); |
1771 | } | 1771 | } |
1772 | 1772 | ||
@@ -1794,7 +1794,7 @@ static int update_slot_info(struct controller *ctrl, struct slot *slot) | |||
1794 | info->latch_status = cpq_get_latch_status(ctrl, slot); | 1794 | info->latch_status = cpq_get_latch_status(ctrl, slot); |
1795 | info->adapter_status = get_presence_status(ctrl, slot); | 1795 | info->adapter_status = get_presence_status(ctrl, slot); |
1796 | result = pci_hp_change_slot_info(slot->hotplug_slot, info); | 1796 | result = pci_hp_change_slot_info(slot->hotplug_slot, info); |
1797 | kfree (info); | 1797 | kfree(info); |
1798 | return result; | 1798 | return result; |
1799 | } | 1799 | } |
1800 | 1800 | ||
@@ -1837,23 +1837,23 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1837 | if (p_slot->state == BLINKINGOFF_STATE) { | 1837 | if (p_slot->state == BLINKINGOFF_STATE) { |
1838 | /* slot is on */ | 1838 | /* slot is on */ |
1839 | dbg("turn on green LED\n"); | 1839 | dbg("turn on green LED\n"); |
1840 | green_LED_on (ctrl, hp_slot); | 1840 | green_LED_on(ctrl, hp_slot); |
1841 | } else if (p_slot->state == BLINKINGON_STATE) { | 1841 | } else if (p_slot->state == BLINKINGON_STATE) { |
1842 | /* slot is off */ | 1842 | /* slot is off */ |
1843 | dbg("turn off green LED\n"); | 1843 | dbg("turn off green LED\n"); |
1844 | green_LED_off (ctrl, hp_slot); | 1844 | green_LED_off(ctrl, hp_slot); |
1845 | } | 1845 | } |
1846 | 1846 | ||
1847 | info(msg_button_cancel, p_slot->number); | 1847 | info(msg_button_cancel, p_slot->number); |
1848 | 1848 | ||
1849 | p_slot->state = STATIC_STATE; | 1849 | p_slot->state = STATIC_STATE; |
1850 | 1850 | ||
1851 | amber_LED_off (ctrl, hp_slot); | 1851 | amber_LED_off(ctrl, hp_slot); |
1852 | 1852 | ||
1853 | set_SOGO(ctrl); | 1853 | set_SOGO(ctrl); |
1854 | 1854 | ||
1855 | /* Wait for SOBS to be unset */ | 1855 | /* Wait for SOBS to be unset */ |
1856 | wait_for_ctrl_irq (ctrl); | 1856 | wait_for_ctrl_irq(ctrl); |
1857 | 1857 | ||
1858 | mutex_unlock(&ctrl->crit_sect); | 1858 | mutex_unlock(&ctrl->crit_sect); |
1859 | } | 1859 | } |
@@ -1861,7 +1861,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1861 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { | 1861 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { |
1862 | dbg("button release\n"); | 1862 | dbg("button release\n"); |
1863 | 1863 | ||
1864 | if (is_slot_enabled (ctrl, hp_slot)) { | 1864 | if (is_slot_enabled(ctrl, hp_slot)) { |
1865 | dbg("slot is on\n"); | 1865 | dbg("slot is on\n"); |
1866 | p_slot->state = BLINKINGOFF_STATE; | 1866 | p_slot->state = BLINKINGOFF_STATE; |
1867 | info(msg_button_off, p_slot->number); | 1867 | info(msg_button_off, p_slot->number); |
@@ -1874,13 +1874,13 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1874 | 1874 | ||
1875 | dbg("blink green LED and turn off amber\n"); | 1875 | dbg("blink green LED and turn off amber\n"); |
1876 | 1876 | ||
1877 | amber_LED_off (ctrl, hp_slot); | 1877 | amber_LED_off(ctrl, hp_slot); |
1878 | green_LED_blink (ctrl, hp_slot); | 1878 | green_LED_blink(ctrl, hp_slot); |
1879 | 1879 | ||
1880 | set_SOGO(ctrl); | 1880 | set_SOGO(ctrl); |
1881 | 1881 | ||
1882 | /* Wait for SOBS to be unset */ | 1882 | /* Wait for SOBS to be unset */ |
1883 | wait_for_ctrl_irq (ctrl); | 1883 | wait_for_ctrl_irq(ctrl); |
1884 | 1884 | ||
1885 | mutex_unlock(&ctrl->crit_sect); | 1885 | mutex_unlock(&ctrl->crit_sect); |
1886 | init_timer(&p_slot->task_event); | 1886 | init_timer(&p_slot->task_event); |
@@ -1940,7 +1940,7 @@ void cpqhp_pushbutton_thread(unsigned long slot) | |||
1940 | dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl); | 1940 | dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl); |
1941 | if (!func) { | 1941 | if (!func) { |
1942 | dbg("Error! func NULL in %s\n", __func__); | 1942 | dbg("Error! func NULL in %s\n", __func__); |
1943 | return ; | 1943 | return; |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | if (cpqhp_process_SS(ctrl, func) != 0) { | 1946 | if (cpqhp_process_SS(ctrl, func) != 0) { |
@@ -1962,7 +1962,7 @@ void cpqhp_pushbutton_thread(unsigned long slot) | |||
1962 | dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl); | 1962 | dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl); |
1963 | if (!func) { | 1963 | if (!func) { |
1964 | dbg("Error! func NULL in %s\n", __func__); | 1964 | dbg("Error! func NULL in %s\n", __func__); |
1965 | return ; | 1965 | return; |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | if (ctrl != NULL) { | 1968 | if (ctrl != NULL) { |
@@ -1973,7 +1973,7 @@ void cpqhp_pushbutton_thread(unsigned long slot) | |||
1973 | set_SOGO(ctrl); | 1973 | set_SOGO(ctrl); |
1974 | 1974 | ||
1975 | /* Wait for SOBS to be unset */ | 1975 | /* Wait for SOBS to be unset */ |
1976 | wait_for_ctrl_irq (ctrl); | 1976 | wait_for_ctrl_irq(ctrl); |
1977 | } | 1977 | } |
1978 | } | 1978 | } |
1979 | 1979 | ||
@@ -2086,7 +2086,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func) | |||
2086 | unsigned int devfn; | 2086 | unsigned int devfn; |
2087 | struct slot *p_slot; | 2087 | struct slot *p_slot; |
2088 | struct pci_bus *pci_bus = ctrl->pci_bus; | 2088 | struct pci_bus *pci_bus = ctrl->pci_bus; |
2089 | int physical_slot=0; | 2089 | int physical_slot = 0; |
2090 | 2090 | ||
2091 | device = func->device; | 2091 | device = func->device; |
2092 | func = cpqhp_slot_find(ctrl->bus, device, index++); | 2092 | func = cpqhp_slot_find(ctrl->bus, device, index++); |
@@ -2100,7 +2100,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func) | |||
2100 | devfn = PCI_DEVFN(func->device, func->function); | 2100 | devfn = PCI_DEVFN(func->device, func->function); |
2101 | 2101 | ||
2102 | /* Check the Class Code */ | 2102 | /* Check the Class Code */ |
2103 | rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); | 2103 | rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code); |
2104 | if (rc) | 2104 | if (rc) |
2105 | return rc; | 2105 | return rc; |
2106 | 2106 | ||
@@ -2109,13 +2109,13 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func) | |||
2109 | rc = REMOVE_NOT_SUPPORTED; | 2109 | rc = REMOVE_NOT_SUPPORTED; |
2110 | } else { | 2110 | } else { |
2111 | /* See if it's a bridge */ | 2111 | /* See if it's a bridge */ |
2112 | rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); | 2112 | rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); |
2113 | if (rc) | 2113 | if (rc) |
2114 | return rc; | 2114 | return rc; |
2115 | 2115 | ||
2116 | /* If it's a bridge, check the VGA Enable bit */ | 2116 | /* If it's a bridge, check the VGA Enable bit */ |
2117 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { | 2117 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { |
2118 | rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); | 2118 | rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); |
2119 | if (rc) | 2119 | if (rc) |
2120 | return rc; | 2120 | return rc; |
2121 | 2121 | ||
@@ -2217,7 +2217,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) | |||
2217 | set_SOGO(ctrl); | 2217 | set_SOGO(ctrl); |
2218 | 2218 | ||
2219 | /* Wait for SOGO interrupt */ | 2219 | /* Wait for SOGO interrupt */ |
2220 | wait_for_ctrl_irq (ctrl); | 2220 | wait_for_ctrl_irq(ctrl); |
2221 | 2221 | ||
2222 | /* Get ready for next iteration */ | 2222 | /* Get ready for next iteration */ |
2223 | long_delay((3*HZ)/10); | 2223 | long_delay((3*HZ)/10); |
@@ -2227,7 +2227,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) | |||
2227 | set_SOGO(ctrl); | 2227 | set_SOGO(ctrl); |
2228 | 2228 | ||
2229 | /* Wait for SOGO interrupt */ | 2229 | /* Wait for SOGO interrupt */ |
2230 | wait_for_ctrl_irq (ctrl); | 2230 | wait_for_ctrl_irq(ctrl); |
2231 | 2231 | ||
2232 | /* Get ready for next iteration */ | 2232 | /* Get ready for next iteration */ |
2233 | long_delay((3*HZ)/10); | 2233 | long_delay((3*HZ)/10); |
@@ -2243,7 +2243,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) | |||
2243 | set_SOGO(ctrl); | 2243 | set_SOGO(ctrl); |
2244 | 2244 | ||
2245 | /* Wait for SOBS to be unset */ | 2245 | /* Wait for SOBS to be unset */ |
2246 | wait_for_ctrl_irq (ctrl); | 2246 | wait_for_ctrl_irq(ctrl); |
2247 | break; | 2247 | break; |
2248 | case 2: | 2248 | case 2: |
2249 | /* Do other stuff here! */ | 2249 | /* Do other stuff here! */ |
@@ -2279,7 +2279,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func | |||
2279 | dbg("%s\n", __func__); | 2279 | dbg("%s\n", __func__); |
2280 | /* Check for Multi-function device */ | 2280 | /* Check for Multi-function device */ |
2281 | ctrl->pci_bus->number = func->bus; | 2281 | ctrl->pci_bus->number = func->bus; |
2282 | rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte); | 2282 | rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte); |
2283 | if (rc) { | 2283 | if (rc) { |
2284 | dbg("%s: rc = %d\n", __func__, rc); | 2284 | dbg("%s: rc = %d\n", __func__, rc); |
2285 | return rc; | 2285 | return rc; |
@@ -2296,7 +2296,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func | |||
2296 | rc = configure_new_function(ctrl, new_slot, behind_bridge, resources); | 2296 | rc = configure_new_function(ctrl, new_slot, behind_bridge, resources); |
2297 | 2297 | ||
2298 | if (rc) { | 2298 | if (rc) { |
2299 | dbg("configure_new_function failed %d\n",rc); | 2299 | dbg("configure_new_function failed %d\n", rc); |
2300 | index = 0; | 2300 | index = 0; |
2301 | 2301 | ||
2302 | while (new_slot) { | 2302 | while (new_slot) { |
@@ -2317,7 +2317,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func | |||
2317 | * and creates a board structure */ | 2317 | * and creates a board structure */ |
2318 | 2318 | ||
2319 | while ((function < max_functions) && (!stop_it)) { | 2319 | while ((function < max_functions) && (!stop_it)) { |
2320 | pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); | 2320 | pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); |
2321 | 2321 | ||
2322 | if (ID == 0xFFFFFFFF) { | 2322 | if (ID == 0xFFFFFFFF) { |
2323 | function++; | 2323 | function++; |
@@ -2543,10 +2543,10 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2543 | 2543 | ||
2544 | /* set Pre Mem base and Limit registers */ | 2544 | /* set Pre Mem base and Limit registers */ |
2545 | temp_word = p_mem_node->base >> 16; | 2545 | temp_word = p_mem_node->base >> 16; |
2546 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); | 2546 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); |
2547 | 2547 | ||
2548 | temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; | 2548 | temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; |
2549 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); | 2549 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); |
2550 | 2550 | ||
2551 | /* Adjust this to compensate for extra adjustment in first loop | 2551 | /* Adjust this to compensate for extra adjustment in first loop |
2552 | */ | 2552 | */ |
@@ -2560,7 +2560,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2560 | 2560 | ||
2561 | ID = 0xFFFFFFFF; | 2561 | ID = 0xFFFFFFFF; |
2562 | pci_bus->number = hold_bus_node->base; | 2562 | pci_bus->number = hold_bus_node->base; |
2563 | pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), 0x00, &ID); | 2563 | pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0), 0x00, &ID); |
2564 | pci_bus->number = func->bus; | 2564 | pci_bus->number = func->bus; |
2565 | 2565 | ||
2566 | if (ID != 0xFFFFFFFF) { /* device present */ | 2566 | if (ID != 0xFFFFFFFF) { /* device present */ |
@@ -2579,7 +2579,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2579 | new_slot->status = 0; | 2579 | new_slot->status = 0; |
2580 | 2580 | ||
2581 | rc = configure_new_device(ctrl, new_slot, 1, &temp_resources); | 2581 | rc = configure_new_device(ctrl, new_slot, 1, &temp_resources); |
2582 | dbg("configure_new_device rc=0x%x\n",rc); | 2582 | dbg("configure_new_device rc=0x%x\n", rc); |
2583 | } /* End of IF (device in slot?) */ | 2583 | } /* End of IF (device in slot?) */ |
2584 | } /* End of FOR loop */ | 2584 | } /* End of FOR loop */ |
2585 | 2585 | ||
@@ -2615,7 +2615,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2615 | temp_byte = temp_resources.bus_head->base - 1; | 2615 | temp_byte = temp_resources.bus_head->base - 1; |
2616 | 2616 | ||
2617 | /* set subordinate bus */ | 2617 | /* set subordinate bus */ |
2618 | rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte); | 2618 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte); |
2619 | 2619 | ||
2620 | if (temp_resources.bus_head->length == 0) { | 2620 | if (temp_resources.bus_head->length == 0) { |
2621 | kfree(temp_resources.bus_head); | 2621 | kfree(temp_resources.bus_head); |
@@ -2636,7 +2636,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2636 | hold_IO_node->base = io_node->base + io_node->length; | 2636 | hold_IO_node->base = io_node->base + io_node->length; |
2637 | 2637 | ||
2638 | temp_byte = (hold_IO_node->base) >> 8; | 2638 | temp_byte = (hold_IO_node->base) >> 8; |
2639 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_BASE, temp_byte); | 2639 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_IO_BASE, temp_byte); |
2640 | 2640 | ||
2641 | return_resource(&(resources->io_head), io_node); | 2641 | return_resource(&(resources->io_head), io_node); |
2642 | } | 2642 | } |
@@ -2655,13 +2655,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2655 | func->io_head = hold_IO_node; | 2655 | func->io_head = hold_IO_node; |
2656 | 2656 | ||
2657 | temp_byte = (io_node->base - 1) >> 8; | 2657 | temp_byte = (io_node->base - 1) >> 8; |
2658 | rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte); | 2658 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte); |
2659 | 2659 | ||
2660 | return_resource(&(resources->io_head), io_node); | 2660 | return_resource(&(resources->io_head), io_node); |
2661 | } else { | 2661 | } else { |
2662 | /* it doesn't need any IO */ | 2662 | /* it doesn't need any IO */ |
2663 | temp_word = 0x0000; | 2663 | temp_word = 0x0000; |
2664 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_LIMIT, temp_word); | 2664 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_IO_LIMIT, temp_word); |
2665 | 2665 | ||
2666 | return_resource(&(resources->io_head), io_node); | 2666 | return_resource(&(resources->io_head), io_node); |
2667 | kfree(hold_IO_node); | 2667 | kfree(hold_IO_node); |
@@ -2687,7 +2687,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2687 | hold_mem_node->base = mem_node->base + mem_node->length; | 2687 | hold_mem_node->base = mem_node->base + mem_node->length; |
2688 | 2688 | ||
2689 | temp_word = (hold_mem_node->base) >> 16; | 2689 | temp_word = (hold_mem_node->base) >> 16; |
2690 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word); | 2690 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word); |
2691 | 2691 | ||
2692 | return_resource(&(resources->mem_head), mem_node); | 2692 | return_resource(&(resources->mem_head), mem_node); |
2693 | } | 2693 | } |
@@ -2706,14 +2706,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2706 | 2706 | ||
2707 | /* configure end address */ | 2707 | /* configure end address */ |
2708 | temp_word = (mem_node->base - 1) >> 16; | 2708 | temp_word = (mem_node->base - 1) >> 16; |
2709 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); | 2709 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); |
2710 | 2710 | ||
2711 | /* Return unused resources to the pool */ | 2711 | /* Return unused resources to the pool */ |
2712 | return_resource(&(resources->mem_head), mem_node); | 2712 | return_resource(&(resources->mem_head), mem_node); |
2713 | } else { | 2713 | } else { |
2714 | /* it doesn't need any Mem */ | 2714 | /* it doesn't need any Mem */ |
2715 | temp_word = 0x0000; | 2715 | temp_word = 0x0000; |
2716 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); | 2716 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); |
2717 | 2717 | ||
2718 | return_resource(&(resources->mem_head), mem_node); | 2718 | return_resource(&(resources->mem_head), mem_node); |
2719 | kfree(hold_mem_node); | 2719 | kfree(hold_mem_node); |
@@ -2739,7 +2739,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2739 | hold_p_mem_node->base = p_mem_node->base + p_mem_node->length; | 2739 | hold_p_mem_node->base = p_mem_node->base + p_mem_node->length; |
2740 | 2740 | ||
2741 | temp_word = (hold_p_mem_node->base) >> 16; | 2741 | temp_word = (hold_p_mem_node->base) >> 16; |
2742 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); | 2742 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); |
2743 | 2743 | ||
2744 | return_resource(&(resources->p_mem_head), p_mem_node); | 2744 | return_resource(&(resources->p_mem_head), p_mem_node); |
2745 | } | 2745 | } |
@@ -2758,13 +2758,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2758 | func->p_mem_head = hold_p_mem_node; | 2758 | func->p_mem_head = hold_p_mem_node; |
2759 | 2759 | ||
2760 | temp_word = (p_mem_node->base - 1) >> 16; | 2760 | temp_word = (p_mem_node->base - 1) >> 16; |
2761 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); | 2761 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); |
2762 | 2762 | ||
2763 | return_resource(&(resources->p_mem_head), p_mem_node); | 2763 | return_resource(&(resources->p_mem_head), p_mem_node); |
2764 | } else { | 2764 | } else { |
2765 | /* it doesn't need any PMem */ | 2765 | /* it doesn't need any PMem */ |
2766 | temp_word = 0x0000; | 2766 | temp_word = 0x0000; |
2767 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); | 2767 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); |
2768 | 2768 | ||
2769 | return_resource(&(resources->p_mem_head), p_mem_node); | 2769 | return_resource(&(resources->p_mem_head), p_mem_node); |
2770 | kfree(hold_p_mem_node); | 2770 | kfree(hold_p_mem_node); |
@@ -2790,16 +2790,16 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2790 | * PCI_COMMAND_INVALIDATE | | 2790 | * PCI_COMMAND_INVALIDATE | |
2791 | * PCI_COMMAND_PARITY | | 2791 | * PCI_COMMAND_PARITY | |
2792 | * PCI_COMMAND_SERR */ | 2792 | * PCI_COMMAND_SERR */ |
2793 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_COMMAND, command); | 2793 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command); |
2794 | 2794 | ||
2795 | /* set Bridge Control Register */ | 2795 | /* set Bridge Control Register */ |
2796 | command = 0x07; /* = PCI_BRIDGE_CTL_PARITY | | 2796 | command = 0x07; /* = PCI_BRIDGE_CTL_PARITY | |
2797 | * PCI_BRIDGE_CTL_SERR | | 2797 | * PCI_BRIDGE_CTL_SERR | |
2798 | * PCI_BRIDGE_CTL_NO_ISA */ | 2798 | * PCI_BRIDGE_CTL_NO_ISA */ |
2799 | rc = pci_bus_write_config_word (pci_bus, devfn, PCI_BRIDGE_CONTROL, command); | 2799 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command); |
2800 | } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) { | 2800 | } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) { |
2801 | /* Standard device */ | 2801 | /* Standard device */ |
2802 | rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); | 2802 | rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code); |
2803 | 2803 | ||
2804 | if (class_code == PCI_BASE_CLASS_DISPLAY) { | 2804 | if (class_code == PCI_BASE_CLASS_DISPLAY) { |
2805 | /* Display (video) adapter (not supported) */ | 2805 | /* Display (video) adapter (not supported) */ |
@@ -2810,9 +2810,9 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2810 | temp_register = 0xFFFFFFFF; | 2810 | temp_register = 0xFFFFFFFF; |
2811 | 2811 | ||
2812 | dbg("CND: bus=%d, devfn=%d, offset=%d\n", pci_bus->number, devfn, cloop); | 2812 | dbg("CND: bus=%d, devfn=%d, offset=%d\n", pci_bus->number, devfn, cloop); |
2813 | rc = pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); | 2813 | rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); |
2814 | 2814 | ||
2815 | rc = pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp_register); | 2815 | rc = pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register); |
2816 | dbg("CND: base = 0x%x\n", temp_register); | 2816 | dbg("CND: base = 0x%x\n", temp_register); |
2817 | 2817 | ||
2818 | if (temp_register) { /* If this register is implemented */ | 2818 | if (temp_register) { /* If this register is implemented */ |
@@ -2891,7 +2891,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2891 | } /* End of base register loop */ | 2891 | } /* End of base register loop */ |
2892 | if (cpqhp_legacy_mode) { | 2892 | if (cpqhp_legacy_mode) { |
2893 | /* Figure out which interrupt pin this function uses */ | 2893 | /* Figure out which interrupt pin this function uses */ |
2894 | rc = pci_bus_read_config_byte (pci_bus, devfn, | 2894 | rc = pci_bus_read_config_byte(pci_bus, devfn, |
2895 | PCI_INTERRUPT_PIN, &temp_byte); | 2895 | PCI_INTERRUPT_PIN, &temp_byte); |
2896 | 2896 | ||
2897 | /* If this function needs an interrupt and we are behind | 2897 | /* If this function needs an interrupt and we are behind |
@@ -2905,7 +2905,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2905 | resources->irqs->barber_pole - 1) & 0x03]; | 2905 | resources->irqs->barber_pole - 1) & 0x03]; |
2906 | } else { | 2906 | } else { |
2907 | /* Program IRQ based on card type */ | 2907 | /* Program IRQ based on card type */ |
2908 | rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); | 2908 | rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code); |
2909 | 2909 | ||
2910 | if (class_code == PCI_BASE_CLASS_STORAGE) | 2910 | if (class_code == PCI_BASE_CLASS_STORAGE) |
2911 | IRQ = cpqhp_disk_irq; | 2911 | IRQ = cpqhp_disk_irq; |
@@ -2914,7 +2914,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2914 | } | 2914 | } |
2915 | 2915 | ||
2916 | /* IRQ Line */ | 2916 | /* IRQ Line */ |
2917 | rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ); | 2917 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ); |
2918 | } | 2918 | } |
2919 | 2919 | ||
2920 | if (!behind_bridge) { | 2920 | if (!behind_bridge) { |
@@ -2950,7 +2950,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2950 | * PCI_COMMAND_INVALIDATE | | 2950 | * PCI_COMMAND_INVALIDATE | |
2951 | * PCI_COMMAND_PARITY | | 2951 | * PCI_COMMAND_PARITY | |
2952 | * PCI_COMMAND_SERR */ | 2952 | * PCI_COMMAND_SERR */ |
2953 | rc = pci_bus_write_config_word (pci_bus, devfn, | 2953 | rc = pci_bus_write_config_word(pci_bus, devfn, |
2954 | PCI_COMMAND, temp_word); | 2954 | PCI_COMMAND, temp_word); |
2955 | } else { /* End of Not-A-Bridge else */ | 2955 | } else { /* End of Not-A-Bridge else */ |
2956 | /* It's some strange type of PCI adapter (Cardbus?) */ | 2956 | /* It's some strange type of PCI adapter (Cardbus?) */ |
@@ -2961,11 +2961,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2961 | 2961 | ||
2962 | return 0; | 2962 | return 0; |
2963 | free_and_out: | 2963 | free_and_out: |
2964 | cpqhp_destroy_resource_list (&temp_resources); | 2964 | cpqhp_destroy_resource_list(&temp_resources); |
2965 | 2965 | ||
2966 | return_resource(&(resources-> bus_head), hold_bus_node); | 2966 | return_resource(&(resources->bus_head), hold_bus_node); |
2967 | return_resource(&(resources-> io_head), hold_IO_node); | 2967 | return_resource(&(resources->io_head), hold_IO_node); |
2968 | return_resource(&(resources-> mem_head), hold_mem_node); | 2968 | return_resource(&(resources->mem_head), hold_mem_node); |
2969 | return_resource(&(resources-> p_mem_head), hold_p_mem_node); | 2969 | return_resource(&(resources->p_mem_head), hold_p_mem_node); |
2970 | return rc; | 2970 | return rc; |
2971 | } | 2971 | } |
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index 1e08ff8c229c..c25fc9061059 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c | |||
@@ -114,10 +114,10 @@ static u32 add_byte(u32 **p_buffer, u8 value, u32 *used, u32 *avail) | |||
114 | if ((*used + 1) > *avail) | 114 | if ((*used + 1) > *avail) |
115 | return(1); | 115 | return(1); |
116 | 116 | ||
117 | *((u8*)*p_buffer) = value; | 117 | *((u8 *)*p_buffer) = value; |
118 | tByte = (u8**)p_buffer; | 118 | tByte = (u8 **)p_buffer; |
119 | (*tByte)++; | 119 | (*tByte)++; |
120 | *used+=1; | 120 | *used += 1; |
121 | return(0); | 121 | return(0); |
122 | } | 122 | } |
123 | 123 | ||
@@ -129,7 +129,7 @@ static u32 add_dword(u32 **p_buffer, u32 value, u32 *used, u32 *avail) | |||
129 | 129 | ||
130 | **p_buffer = value; | 130 | **p_buffer = value; |
131 | (*p_buffer)++; | 131 | (*p_buffer)++; |
132 | *used+=4; | 132 | *used += 4; |
133 | return(0); | 133 | return(0); |
134 | } | 134 | } |
135 | 135 | ||
@@ -141,7 +141,7 @@ static u32 add_dword(u32 **p_buffer, u32 value, u32 *used, u32 *avail) | |||
141 | * | 141 | * |
142 | * returns 0 for non-Compaq ROM, 1 for Compaq ROM | 142 | * returns 0 for non-Compaq ROM, 1 for Compaq ROM |
143 | */ | 143 | */ |
144 | static int check_for_compaq_ROM (void __iomem *rom_start) | 144 | static int check_for_compaq_ROM(void __iomem *rom_start) |
145 | { | 145 | { |
146 | u8 temp1, temp2, temp3, temp4, temp5, temp6; | 146 | u8 temp1, temp2, temp3, temp4, temp5, temp6; |
147 | int result = 0; | 147 | int result = 0; |
@@ -160,12 +160,12 @@ static int check_for_compaq_ROM (void __iomem *rom_start) | |||
160 | (temp6 == 'Q')) { | 160 | (temp6 == 'Q')) { |
161 | result = 1; | 161 | result = 1; |
162 | } | 162 | } |
163 | dbg ("%s - returned %d\n", __func__, result); | 163 | dbg("%s - returned %d\n", __func__, result); |
164 | return result; | 164 | return result; |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size) | 168 | static u32 access_EV(u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size) |
169 | { | 169 | { |
170 | unsigned long flags; | 170 | unsigned long flags; |
171 | int op = operation; | 171 | int op = operation; |
@@ -197,7 +197,7 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size) | |||
197 | * | 197 | * |
198 | * Read the hot plug Resource Table from NVRAM | 198 | * Read the hot plug Resource Table from NVRAM |
199 | */ | 199 | */ |
200 | static int load_HRT (void __iomem *rom_start) | 200 | static int load_HRT(void __iomem *rom_start) |
201 | { | 201 | { |
202 | u32 available; | 202 | u32 available; |
203 | u32 temp_dword; | 203 | u32 temp_dword; |
@@ -232,7 +232,7 @@ static int load_HRT (void __iomem *rom_start) | |||
232 | * | 232 | * |
233 | * Save the hot plug Resource Table in NVRAM | 233 | * Save the hot plug Resource Table in NVRAM |
234 | */ | 234 | */ |
235 | static u32 store_HRT (void __iomem *rom_start) | 235 | static u32 store_HRT(void __iomem *rom_start) |
236 | { | 236 | { |
237 | u32 *buffer; | 237 | u32 *buffer; |
238 | u32 *pFill; | 238 | u32 *pFill; |
@@ -252,7 +252,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
252 | if (!check_for_compaq_ROM(rom_start)) | 252 | if (!check_for_compaq_ROM(rom_start)) |
253 | return(1); | 253 | return(1); |
254 | 254 | ||
255 | buffer = (u32*) evbuffer; | 255 | buffer = (u32 *) evbuffer; |
256 | 256 | ||
257 | if (!buffer) | 257 | if (!buffer) |
258 | return(1); | 258 | return(1); |
@@ -306,7 +306,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
306 | loop = 0; | 306 | loop = 0; |
307 | 307 | ||
308 | while (resNode) { | 308 | while (resNode) { |
309 | loop ++; | 309 | loop++; |
310 | 310 | ||
311 | /* base */ | 311 | /* base */ |
312 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); | 312 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); |
@@ -331,7 +331,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
331 | loop = 0; | 331 | loop = 0; |
332 | 332 | ||
333 | while (resNode) { | 333 | while (resNode) { |
334 | loop ++; | 334 | loop++; |
335 | 335 | ||
336 | /* base */ | 336 | /* base */ |
337 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); | 337 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); |
@@ -356,7 +356,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
356 | loop = 0; | 356 | loop = 0; |
357 | 357 | ||
358 | while (resNode) { | 358 | while (resNode) { |
359 | loop ++; | 359 | loop++; |
360 | 360 | ||
361 | /* base */ | 361 | /* base */ |
362 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); | 362 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); |
@@ -381,7 +381,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
381 | loop = 0; | 381 | loop = 0; |
382 | 382 | ||
383 | while (resNode) { | 383 | while (resNode) { |
384 | loop ++; | 384 | loop++; |
385 | 385 | ||
386 | /* base */ | 386 | /* base */ |
387 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); | 387 | rc = add_dword(&pFill, resNode->base, &usedbytes, &available); |
@@ -408,7 +408,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
408 | 408 | ||
409 | temp_dword = usedbytes; | 409 | temp_dword = usedbytes; |
410 | 410 | ||
411 | rc = access_EV(WRITE_EV, "CQTHPS", (u8*) buffer, &temp_dword); | 411 | rc = access_EV(WRITE_EV, "CQTHPS", (u8 *) buffer, &temp_dword); |
412 | 412 | ||
413 | dbg("usedbytes = 0x%x, length = 0x%x\n", usedbytes, temp_dword); | 413 | dbg("usedbytes = 0x%x, length = 0x%x\n", usedbytes, temp_dword); |
414 | 414 | ||
@@ -423,7 +423,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
423 | } | 423 | } |
424 | 424 | ||
425 | 425 | ||
426 | void compaq_nvram_init (void __iomem *rom_start) | 426 | void compaq_nvram_init(void __iomem *rom_start) |
427 | { | 427 | { |
428 | if (rom_start) | 428 | if (rom_start) |
429 | compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR); | 429 | compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR); |
@@ -435,7 +435,7 @@ void compaq_nvram_init (void __iomem *rom_start) | |||
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | 438 | int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl) |
439 | { | 439 | { |
440 | u8 bus, device, function; | 440 | u8 bus, device, function; |
441 | u8 nummem, numpmem, numio, numbus; | 441 | u8 nummem, numpmem, numio, numbus; |
@@ -451,7 +451,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
451 | if (!evbuffer_init) { | 451 | if (!evbuffer_init) { |
452 | /* Read the resource list information in from NVRAM */ | 452 | /* Read the resource list information in from NVRAM */ |
453 | if (load_HRT(rom_start)) | 453 | if (load_HRT(rom_start)) |
454 | memset (evbuffer, 0, 1024); | 454 | memset(evbuffer, 0, 1024); |
455 | 455 | ||
456 | evbuffer_init = 1; | 456 | evbuffer_init = 1; |
457 | } | 457 | } |
@@ -472,7 +472,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
472 | 472 | ||
473 | p_byte += 3; | 473 | p_byte += 3; |
474 | 474 | ||
475 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 475 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) |
476 | return 2; | 476 | return 2; |
477 | 477 | ||
478 | bus = p_ev_ctrl->bus; | 478 | bus = p_ev_ctrl->bus; |
@@ -489,20 +489,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
489 | 489 | ||
490 | p_byte += 4; | 490 | p_byte += 4; |
491 | 491 | ||
492 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 492 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) |
493 | return 2; | 493 | return 2; |
494 | 494 | ||
495 | /* Skip forward to the next entry */ | 495 | /* Skip forward to the next entry */ |
496 | p_byte += (nummem + numpmem + numio + numbus) * 8; | 496 | p_byte += (nummem + numpmem + numio + numbus) * 8; |
497 | 497 | ||
498 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 498 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) |
499 | return 2; | 499 | return 2; |
500 | 500 | ||
501 | p_ev_ctrl = (struct ev_hrt_ctrl *) p_byte; | 501 | p_ev_ctrl = (struct ev_hrt_ctrl *) p_byte; |
502 | 502 | ||
503 | p_byte += 3; | 503 | p_byte += 3; |
504 | 504 | ||
505 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 505 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) |
506 | return 2; | 506 | return 2; |
507 | 507 | ||
508 | bus = p_ev_ctrl->bus; | 508 | bus = p_ev_ctrl->bus; |
@@ -517,7 +517,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
517 | 517 | ||
518 | p_byte += 4; | 518 | p_byte += 4; |
519 | 519 | ||
520 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 520 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) |
521 | return 2; | 521 | return 2; |
522 | 522 | ||
523 | while (nummem--) { | 523 | while (nummem--) { |
@@ -526,20 +526,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
526 | if (!mem_node) | 526 | if (!mem_node) |
527 | break; | 527 | break; |
528 | 528 | ||
529 | mem_node->base = *(u32*)p_byte; | 529 | mem_node->base = *(u32 *)p_byte; |
530 | dbg("mem base = %8.8x\n",mem_node->base); | 530 | dbg("mem base = %8.8x\n", mem_node->base); |
531 | p_byte += 4; | 531 | p_byte += 4; |
532 | 532 | ||
533 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 533 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
534 | kfree(mem_node); | 534 | kfree(mem_node); |
535 | return 2; | 535 | return 2; |
536 | } | 536 | } |
537 | 537 | ||
538 | mem_node->length = *(u32*)p_byte; | 538 | mem_node->length = *(u32 *)p_byte; |
539 | dbg("mem length = %8.8x\n",mem_node->length); | 539 | dbg("mem length = %8.8x\n", mem_node->length); |
540 | p_byte += 4; | 540 | p_byte += 4; |
541 | 541 | ||
542 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 542 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
543 | kfree(mem_node); | 543 | kfree(mem_node); |
544 | return 2; | 544 | return 2; |
545 | } | 545 | } |
@@ -554,20 +554,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
554 | if (!p_mem_node) | 554 | if (!p_mem_node) |
555 | break; | 555 | break; |
556 | 556 | ||
557 | p_mem_node->base = *(u32*)p_byte; | 557 | p_mem_node->base = *(u32 *)p_byte; |
558 | dbg("pre-mem base = %8.8x\n",p_mem_node->base); | 558 | dbg("pre-mem base = %8.8x\n", p_mem_node->base); |
559 | p_byte += 4; | 559 | p_byte += 4; |
560 | 560 | ||
561 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 561 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
562 | kfree(p_mem_node); | 562 | kfree(p_mem_node); |
563 | return 2; | 563 | return 2; |
564 | } | 564 | } |
565 | 565 | ||
566 | p_mem_node->length = *(u32*)p_byte; | 566 | p_mem_node->length = *(u32 *)p_byte; |
567 | dbg("pre-mem length = %8.8x\n",p_mem_node->length); | 567 | dbg("pre-mem length = %8.8x\n", p_mem_node->length); |
568 | p_byte += 4; | 568 | p_byte += 4; |
569 | 569 | ||
570 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 570 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
571 | kfree(p_mem_node); | 571 | kfree(p_mem_node); |
572 | return 2; | 572 | return 2; |
573 | } | 573 | } |
@@ -582,20 +582,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
582 | if (!io_node) | 582 | if (!io_node) |
583 | break; | 583 | break; |
584 | 584 | ||
585 | io_node->base = *(u32*)p_byte; | 585 | io_node->base = *(u32 *)p_byte; |
586 | dbg("io base = %8.8x\n",io_node->base); | 586 | dbg("io base = %8.8x\n", io_node->base); |
587 | p_byte += 4; | 587 | p_byte += 4; |
588 | 588 | ||
589 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 589 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
590 | kfree(io_node); | 590 | kfree(io_node); |
591 | return 2; | 591 | return 2; |
592 | } | 592 | } |
593 | 593 | ||
594 | io_node->length = *(u32*)p_byte; | 594 | io_node->length = *(u32 *)p_byte; |
595 | dbg("io length = %8.8x\n",io_node->length); | 595 | dbg("io length = %8.8x\n", io_node->length); |
596 | p_byte += 4; | 596 | p_byte += 4; |
597 | 597 | ||
598 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 598 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
599 | kfree(io_node); | 599 | kfree(io_node); |
600 | return 2; | 600 | return 2; |
601 | } | 601 | } |
@@ -610,18 +610,18 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
610 | if (!bus_node) | 610 | if (!bus_node) |
611 | break; | 611 | break; |
612 | 612 | ||
613 | bus_node->base = *(u32*)p_byte; | 613 | bus_node->base = *(u32 *)p_byte; |
614 | p_byte += 4; | 614 | p_byte += 4; |
615 | 615 | ||
616 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 616 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
617 | kfree(bus_node); | 617 | kfree(bus_node); |
618 | return 2; | 618 | return 2; |
619 | } | 619 | } |
620 | 620 | ||
621 | bus_node->length = *(u32*)p_byte; | 621 | bus_node->length = *(u32 *)p_byte; |
622 | p_byte += 4; | 622 | p_byte += 4; |
623 | 623 | ||
624 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { | 624 | if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { |
625 | kfree(bus_node); | 625 | kfree(bus_node); |
626 | return 2; | 626 | return 2; |
627 | } | 627 | } |
@@ -650,7 +650,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | int compaq_nvram_store (void __iomem *rom_start) | 653 | int compaq_nvram_store(void __iomem *rom_start) |
654 | { | 654 | { |
655 | int rc = 1; | 655 | int rc = 1; |
656 | 656 | ||
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 1c8c2f130d31..e220d49307bd 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c | |||
@@ -81,7 +81,7 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom | |||
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | int cpqhp_configure_device (struct controller *ctrl, struct pci_func *func) | 84 | int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func) |
85 | { | 85 | { |
86 | struct pci_bus *child; | 86 | struct pci_bus *child; |
87 | int num; | 87 | int num; |
@@ -89,7 +89,7 @@ int cpqhp_configure_device (struct controller *ctrl, struct pci_func *func) | |||
89 | pci_lock_rescan_remove(); | 89 | pci_lock_rescan_remove(); |
90 | 90 | ||
91 | if (func->pci_dev == NULL) | 91 | if (func->pci_dev == NULL) |
92 | func->pci_dev = pci_get_bus_and_slot(func->bus,PCI_DEVFN(func->device, func->function)); | 92 | func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function)); |
93 | 93 | ||
94 | /* No pci device, we need to create it then */ | 94 | /* No pci device, we need to create it then */ |
95 | if (func->pci_dev == NULL) { | 95 | if (func->pci_dev == NULL) { |
@@ -128,7 +128,7 @@ int cpqhp_unconfigure_device(struct pci_func *func) | |||
128 | dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function); | 128 | dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function); |
129 | 129 | ||
130 | pci_lock_rescan_remove(); | 130 | pci_lock_rescan_remove(); |
131 | for (j=0; j<8 ; j++) { | 131 | for (j = 0; j < 8 ; j++) { |
132 | struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); | 132 | struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); |
133 | if (temp) { | 133 | if (temp) { |
134 | pci_dev_put(temp); | 134 | pci_dev_put(temp); |
@@ -143,11 +143,11 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 o | |||
143 | { | 143 | { |
144 | u32 vendID = 0; | 144 | u32 vendID = 0; |
145 | 145 | ||
146 | if (pci_bus_read_config_dword (bus, devfn, PCI_VENDOR_ID, &vendID) == -1) | 146 | if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) == -1) |
147 | return -1; | 147 | return -1; |
148 | if (vendID == 0xffffffff) | 148 | if (vendID == 0xffffffff) |
149 | return -1; | 149 | return -1; |
150 | return pci_bus_read_config_dword (bus, devfn, offset, value); | 150 | return pci_bus_read_config_dword(bus, devfn, offset, value); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
@@ -158,7 +158,7 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 o | |||
158 | * @dev_num: device number of PCI device | 158 | * @dev_num: device number of PCI device |
159 | * @slot: pointer to u8 where slot number will be returned | 159 | * @slot: pointer to u8 where slot number will be returned |
160 | */ | 160 | */ |
161 | int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) | 161 | int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) |
162 | { | 162 | { |
163 | int rc = 0; | 163 | int rc = 0; |
164 | 164 | ||
@@ -230,7 +230,7 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_ | |||
230 | dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); | 230 | dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); |
231 | /* Yep we got one. bridge ? */ | 231 | /* Yep we got one. bridge ? */ |
232 | if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { | 232 | if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { |
233 | pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus); | 233 | pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus); |
234 | /* XXX: no recursion, wtf? */ | 234 | /* XXX: no recursion, wtf? */ |
235 | dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice); | 235 | dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice); |
236 | return 0; | 236 | return 0; |
@@ -257,16 +257,16 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num | |||
257 | *bus_num = tbus; | 257 | *bus_num = tbus; |
258 | *dev_num = tdevice; | 258 | *dev_num = tdevice; |
259 | ctrl->pci_bus->number = tbus; | 259 | ctrl->pci_bus->number = tbus; |
260 | pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); | 260 | pci_bus_read_config_dword(ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); |
261 | if (!nobridge || (work == 0xffffffff)) | 261 | if (!nobridge || (work == 0xffffffff)) |
262 | return 0; | 262 | return 0; |
263 | 263 | ||
264 | dbg("bus_num %d devfn %d\n", *bus_num, *dev_num); | 264 | dbg("bus_num %d devfn %d\n", *bus_num, *dev_num); |
265 | pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work); | 265 | pci_bus_read_config_dword(ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work); |
266 | dbg("work >> 8 (%x) = BRIDGE (%x)\n", work >> 8, PCI_TO_PCI_BRIDGE_CLASS); | 266 | dbg("work >> 8 (%x) = BRIDGE (%x)\n", work >> 8, PCI_TO_PCI_BRIDGE_CLASS); |
267 | 267 | ||
268 | if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { | 268 | if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { |
269 | pci_bus_read_config_byte (ctrl->pci_bus, *dev_num, PCI_SECONDARY_BUS, &tbus); | 269 | pci_bus_read_config_byte(ctrl->pci_bus, *dev_num, PCI_SECONDARY_BUS, &tbus); |
270 | dbg("Scan bus for Non Bridge: bus %d\n", tbus); | 270 | dbg("Scan bus for Non Bridge: bus %d\n", tbus); |
271 | if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { | 271 | if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { |
272 | *bus_num = tbus; | 272 | *bus_num = tbus; |
@@ -280,7 +280,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num | |||
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | int cpqhp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot) | 283 | int cpqhp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot) |
284 | { | 284 | { |
285 | /* plain (bridges allowed) */ | 285 | /* plain (bridges allowed) */ |
286 | return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0); | 286 | return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0); |
@@ -419,7 +419,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) | |||
419 | new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function); | 419 | new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function); |
420 | 420 | ||
421 | for (cloop = 0; cloop < 0x20; cloop++) { | 421 | for (cloop = 0; cloop < 0x20; cloop++) { |
422 | rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop])); | 422 | rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop])); |
423 | if (rc) | 423 | if (rc) |
424 | return rc; | 424 | return rc; |
425 | } | 425 | } |
@@ -465,7 +465,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) | |||
465 | * | 465 | * |
466 | * returns 0 if success | 466 | * returns 0 if success |
467 | */ | 467 | */ |
468 | int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot) | 468 | int cpqhp_save_slot_config(struct controller *ctrl, struct pci_func *new_slot) |
469 | { | 469 | { |
470 | long rc; | 470 | long rc; |
471 | u8 class_code; | 471 | u8 class_code; |
@@ -481,7 +481,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot) | |||
481 | ID = 0xFFFFFFFF; | 481 | ID = 0xFFFFFFFF; |
482 | 482 | ||
483 | ctrl->pci_bus->number = new_slot->bus; | 483 | ctrl->pci_bus->number = new_slot->bus; |
484 | pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_VENDOR_ID, &ID); | 484 | pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_VENDOR_ID, &ID); |
485 | 485 | ||
486 | if (ID == 0xFFFFFFFF) | 486 | if (ID == 0xFFFFFFFF) |
487 | return 2; | 487 | return 2; |
@@ -497,7 +497,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot) | |||
497 | while (function < max_functions) { | 497 | while (function < max_functions) { |
498 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { | 498 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { |
499 | /* Recurse the subordinate bus */ | 499 | /* Recurse the subordinate bus */ |
500 | pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus); | 500 | pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus); |
501 | 501 | ||
502 | sub_bus = (int) secondary_bus; | 502 | sub_bus = (int) secondary_bus; |
503 | 503 | ||
@@ -514,7 +514,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot) | |||
514 | new_slot->status = 0; | 514 | new_slot->status = 0; |
515 | 515 | ||
516 | for (cloop = 0; cloop < 0x20; cloop++) | 516 | for (cloop = 0; cloop < 0x20; cloop++) |
517 | pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop])); | 517 | pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop])); |
518 | 518 | ||
519 | function++; | 519 | function++; |
520 | 520 | ||
@@ -571,10 +571,10 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func) | |||
571 | devfn = PCI_DEVFN(func->device, func->function); | 571 | devfn = PCI_DEVFN(func->device, func->function); |
572 | 572 | ||
573 | /* Check for Bridge */ | 573 | /* Check for Bridge */ |
574 | pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); | 574 | pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); |
575 | 575 | ||
576 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { | 576 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { |
577 | pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); | 577 | pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); |
578 | 578 | ||
579 | sub_bus = (int) secondary_bus; | 579 | sub_bus = (int) secondary_bus; |
580 | 580 | ||
@@ -595,8 +595,8 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func) | |||
595 | */ | 595 | */ |
596 | for (cloop = 0x10; cloop <= 0x14; cloop += 4) { | 596 | for (cloop = 0x10; cloop <= 0x14; cloop += 4) { |
597 | temp_register = 0xFFFFFFFF; | 597 | temp_register = 0xFFFFFFFF; |
598 | pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); | 598 | pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); |
599 | pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); | 599 | pci_bus_read_config_dword(pci_bus, devfn, cloop, &base); |
600 | /* If this register is implemented */ | 600 | /* If this register is implemented */ |
601 | if (base) { | 601 | if (base) { |
602 | if (base & 0x01L) { | 602 | if (base & 0x01L) { |
@@ -631,8 +631,8 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func) | |||
631 | /* Figure out IO and memory base lengths */ | 631 | /* Figure out IO and memory base lengths */ |
632 | for (cloop = 0x10; cloop <= 0x24; cloop += 4) { | 632 | for (cloop = 0x10; cloop <= 0x24; cloop += 4) { |
633 | temp_register = 0xFFFFFFFF; | 633 | temp_register = 0xFFFFFFFF; |
634 | pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); | 634 | pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); |
635 | pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); | 635 | pci_bus_read_config_dword(pci_bus, devfn, cloop, &base); |
636 | 636 | ||
637 | /* If this register is implemented */ | 637 | /* If this register is implemented */ |
638 | if (base) { | 638 | if (base) { |
@@ -686,7 +686,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func) | |||
686 | * | 686 | * |
687 | * returns 0 if success | 687 | * returns 0 if success |
688 | */ | 688 | */ |
689 | int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func *func) | 689 | int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) |
690 | { | 690 | { |
691 | u8 cloop; | 691 | u8 cloop; |
692 | u8 header_type; | 692 | u8 header_type; |
@@ -791,7 +791,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func *func) | |||
791 | } | 791 | } |
792 | /* Figure out IO and memory base lengths */ | 792 | /* Figure out IO and memory base lengths */ |
793 | for (cloop = 0x10; cloop <= 0x14; cloop += 4) { | 793 | for (cloop = 0x10; cloop <= 0x14; cloop += 4) { |
794 | pci_bus_read_config_dword (pci_bus, devfn, cloop, &save_base); | 794 | pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base); |
795 | 795 | ||
796 | temp_register = 0xFFFFFFFF; | 796 | temp_register = 0xFFFFFFFF; |
797 | pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); | 797 | pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); |
@@ -972,13 +972,13 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func) | |||
972 | * registers are programmed last | 972 | * registers are programmed last |
973 | */ | 973 | */ |
974 | for (cloop = 0x3C; cloop > 0; cloop -= 4) | 974 | for (cloop = 0x3C; cloop > 0; cloop -= 4) |
975 | pci_bus_write_config_dword (pci_bus, devfn, cloop, func->config_space[cloop >> 2]); | 975 | pci_bus_write_config_dword(pci_bus, devfn, cloop, func->config_space[cloop >> 2]); |
976 | 976 | ||
977 | pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); | 977 | pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); |
978 | 978 | ||
979 | /* If this is a bridge device, restore subordinate devices */ | 979 | /* If this is a bridge device, restore subordinate devices */ |
980 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { | 980 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { |
981 | pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); | 981 | pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); |
982 | 982 | ||
983 | sub_bus = (int) secondary_bus; | 983 | sub_bus = (int) secondary_bus; |
984 | 984 | ||
@@ -998,7 +998,7 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func) | |||
998 | */ | 998 | */ |
999 | 999 | ||
1000 | for (cloop = 16; cloop < 40; cloop += 4) { | 1000 | for (cloop = 16; cloop < 40; cloop += 4) { |
1001 | pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp); | 1001 | pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp); |
1002 | 1002 | ||
1003 | if (temp != func->config_space[cloop >> 2]) { | 1003 | if (temp != func->config_space[cloop >> 2]) { |
1004 | dbg("Config space compare failure!!! offset = %x\n", cloop); | 1004 | dbg("Config space compare failure!!! offset = %x\n", cloop); |
@@ -1050,7 +1050,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func) | |||
1050 | pci_bus->number = func->bus; | 1050 | pci_bus->number = func->bus; |
1051 | devfn = PCI_DEVFN(func->device, func->function); | 1051 | devfn = PCI_DEVFN(func->device, func->function); |
1052 | 1052 | ||
1053 | pci_bus_read_config_dword (pci_bus, devfn, PCI_VENDOR_ID, &temp_register); | 1053 | pci_bus_read_config_dword(pci_bus, devfn, PCI_VENDOR_ID, &temp_register); |
1054 | 1054 | ||
1055 | /* No adapter present */ | 1055 | /* No adapter present */ |
1056 | if (temp_register == 0xFFFFFFFF) | 1056 | if (temp_register == 0xFFFFFFFF) |
@@ -1060,14 +1060,14 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func) | |||
1060 | return(ADAPTER_NOT_SAME); | 1060 | return(ADAPTER_NOT_SAME); |
1061 | 1061 | ||
1062 | /* Check for same revision number and class code */ | 1062 | /* Check for same revision number and class code */ |
1063 | pci_bus_read_config_dword (pci_bus, devfn, PCI_CLASS_REVISION, &temp_register); | 1063 | pci_bus_read_config_dword(pci_bus, devfn, PCI_CLASS_REVISION, &temp_register); |
1064 | 1064 | ||
1065 | /* Adapter not the same */ | 1065 | /* Adapter not the same */ |
1066 | if (temp_register != func->config_space[0x08 >> 2]) | 1066 | if (temp_register != func->config_space[0x08 >> 2]) |
1067 | return(ADAPTER_NOT_SAME); | 1067 | return(ADAPTER_NOT_SAME); |
1068 | 1068 | ||
1069 | /* Check for Bridge */ | 1069 | /* Check for Bridge */ |
1070 | pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); | 1070 | pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); |
1071 | 1071 | ||
1072 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { | 1072 | if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { |
1073 | /* In order to continue checking, we must program the | 1073 | /* In order to continue checking, we must program the |
@@ -1076,7 +1076,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func) | |||
1076 | */ | 1076 | */ |
1077 | 1077 | ||
1078 | temp_register = func->config_space[0x18 >> 2]; | 1078 | temp_register = func->config_space[0x18 >> 2]; |
1079 | pci_bus_write_config_dword (pci_bus, devfn, PCI_PRIMARY_BUS, temp_register); | 1079 | pci_bus_write_config_dword(pci_bus, devfn, PCI_PRIMARY_BUS, temp_register); |
1080 | 1080 | ||
1081 | secondary_bus = (temp_register >> 8) & 0xFF; | 1081 | secondary_bus = (temp_register >> 8) & 0xFF; |
1082 | 1082 | ||
@@ -1094,7 +1094,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func) | |||
1094 | /* Check to see if it is a standard config header */ | 1094 | /* Check to see if it is a standard config header */ |
1095 | else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) { | 1095 | else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) { |
1096 | /* Check subsystem vendor and ID */ | 1096 | /* Check subsystem vendor and ID */ |
1097 | pci_bus_read_config_dword (pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register); | 1097 | pci_bus_read_config_dword(pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register); |
1098 | 1098 | ||
1099 | if (temp_register != func->config_space[0x2C >> 2]) { | 1099 | if (temp_register != func->config_space[0x2C >> 2]) { |
1100 | /* If it's a SMART-2 and the register isn't | 1100 | /* If it's a SMART-2 and the register isn't |
@@ -1108,8 +1108,8 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func) | |||
1108 | /* Figure out IO and memory base lengths */ | 1108 | /* Figure out IO and memory base lengths */ |
1109 | for (cloop = 0x10; cloop <= 0x24; cloop += 4) { | 1109 | for (cloop = 0x10; cloop <= 0x24; cloop += 4) { |
1110 | temp_register = 0xFFFFFFFF; | 1110 | temp_register = 0xFFFFFFFF; |
1111 | pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); | 1111 | pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); |
1112 | pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); | 1112 | pci_bus_read_config_dword(pci_bus, devfn, cloop, &base); |
1113 | 1113 | ||
1114 | /* If this register is implemented */ | 1114 | /* If this register is implemented */ |
1115 | if (base) { | 1115 | if (base) { |
@@ -1234,7 +1234,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st | |||
1234 | if (rc) | 1234 | if (rc) |
1235 | return rc; | 1235 | return rc; |
1236 | 1236 | ||
1237 | one_slot = rom_resource_table + sizeof (struct hrt); | 1237 | one_slot = rom_resource_table + sizeof(struct hrt); |
1238 | 1238 | ||
1239 | i = readb(rom_resource_table + NUMBER_OF_ENTRIES); | 1239 | i = readb(rom_resource_table + NUMBER_OF_ENTRIES); |
1240 | dbg("number_of_entries = %d\n", i); | 1240 | dbg("number_of_entries = %d\n", i); |
@@ -1263,12 +1263,12 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st | |||
1263 | /* If this entry isn't for our controller's bus, ignore it */ | 1263 | /* If this entry isn't for our controller's bus, ignore it */ |
1264 | if (primary_bus != ctrl->bus) { | 1264 | if (primary_bus != ctrl->bus) { |
1265 | i--; | 1265 | i--; |
1266 | one_slot += sizeof (struct slot_rt); | 1266 | one_slot += sizeof(struct slot_rt); |
1267 | continue; | 1267 | continue; |
1268 | } | 1268 | } |
1269 | /* find out if this entry is for an occupied slot */ | 1269 | /* find out if this entry is for an occupied slot */ |
1270 | ctrl->pci_bus->number = primary_bus; | 1270 | ctrl->pci_bus->number = primary_bus; |
1271 | pci_bus_read_config_dword (ctrl->pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword); | 1271 | pci_bus_read_config_dword(ctrl->pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword); |
1272 | dbg("temp_D_word = %x\n", temp_dword); | 1272 | dbg("temp_D_word = %x\n", temp_dword); |
1273 | 1273 | ||
1274 | if (temp_dword != 0xFFFFFFFF) { | 1274 | if (temp_dword != 0xFFFFFFFF) { |
@@ -1283,7 +1283,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st | |||
1283 | /* If we can't find a match, skip this table entry */ | 1283 | /* If we can't find a match, skip this table entry */ |
1284 | if (!func) { | 1284 | if (!func) { |
1285 | i--; | 1285 | i--; |
1286 | one_slot += sizeof (struct slot_rt); | 1286 | one_slot += sizeof(struct slot_rt); |
1287 | continue; | 1287 | continue; |
1288 | } | 1288 | } |
1289 | /* this may not work and shouldn't be used */ | 1289 | /* this may not work and shouldn't be used */ |
@@ -1395,7 +1395,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st | |||
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | i--; | 1397 | i--; |
1398 | one_slot += sizeof (struct slot_rt); | 1398 | one_slot += sizeof(struct slot_rt); |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | /* If all of the following fail, we don't have any resources for | 1401 | /* If all of the following fail, we don't have any resources for |
@@ -1475,7 +1475,7 @@ int cpqhp_return_board_resources(struct pci_func *func, struct resource_lists *r | |||
1475 | * | 1475 | * |
1476 | * Puts node back in the resource list pointed to by head | 1476 | * Puts node back in the resource list pointed to by head |
1477 | */ | 1477 | */ |
1478 | void cpqhp_destroy_resource_list (struct resource_lists *resources) | 1478 | void cpqhp_destroy_resource_list(struct resource_lists *resources) |
1479 | { | 1479 | { |
1480 | struct pci_resource *res, *tres; | 1480 | struct pci_resource *res, *tres; |
1481 | 1481 | ||
@@ -1522,7 +1522,7 @@ void cpqhp_destroy_resource_list (struct resource_lists *resources) | |||
1522 | * | 1522 | * |
1523 | * Puts node back in the resource list pointed to by head | 1523 | * Puts node back in the resource list pointed to by head |
1524 | */ | 1524 | */ |
1525 | void cpqhp_destroy_board_resources (struct pci_func *func) | 1525 | void cpqhp_destroy_board_resources(struct pci_func *func) |
1526 | { | 1526 | { |
1527 | struct pci_resource *res, *tres; | 1527 | struct pci_resource *res, *tres; |
1528 | 1528 | ||
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index d81648f71425..775974deda74 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "cpqphp.h" | 39 | #include "cpqphp.h" |
40 | 40 | ||
41 | static DEFINE_MUTEX(cpqphp_mutex); | 41 | static DEFINE_MUTEX(cpqphp_mutex); |
42 | static int show_ctrl (struct controller *ctrl, char *buf) | 42 | static int show_ctrl(struct controller *ctrl, char *buf) |
43 | { | 43 | { |
44 | char *out = buf; | 44 | char *out = buf; |
45 | int index; | 45 | int index; |
@@ -77,7 +77,7 @@ static int show_ctrl (struct controller *ctrl, char *buf) | |||
77 | return out - buf; | 77 | return out - buf; |
78 | } | 78 | } |
79 | 79 | ||
80 | static int show_dev (struct controller *ctrl, char *buf) | 80 | static int show_dev(struct controller *ctrl, char *buf) |
81 | { | 81 | { |
82 | char *out = buf; | 82 | char *out = buf; |
83 | int index; | 83 | int index; |
@@ -119,7 +119,7 @@ static int show_dev (struct controller *ctrl, char *buf) | |||
119 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); | 119 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); |
120 | res = res->next; | 120 | res = res->next; |
121 | } | 121 | } |
122 | slot=slot->next; | 122 | slot = slot->next; |
123 | } | 123 | } |
124 | 124 | ||
125 | return out - buf; | 125 | return out - buf; |
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h index e3e46a7b3ee7..d3256838cb05 100644 --- a/drivers/pci/hotplug/ibmphp.h +++ b/drivers/pci/hotplug/ibmphp.h | |||
@@ -39,11 +39,11 @@ extern int ibmphp_debug; | |||
39 | #else | 39 | #else |
40 | #define MY_NAME THIS_MODULE->name | 40 | #define MY_NAME THIS_MODULE->name |
41 | #endif | 41 | #endif |
42 | #define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) | 42 | #define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0) |
43 | #define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) | 43 | #define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0) |
44 | #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) | 44 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
45 | #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) | 45 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
46 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) | 46 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
47 | 47 | ||
48 | 48 | ||
49 | /* EBDA stuff */ | 49 | /* EBDA stuff */ |
@@ -603,7 +603,7 @@ void ibmphp_hpc_stop_poll_thread(void); | |||
603 | #define SLOT_CONNECT(s) ((u8) ((s & HPC_SLOT_CONNECT) \ | 603 | #define SLOT_CONNECT(s) ((u8) ((s & HPC_SLOT_CONNECT) \ |
604 | ? HPC_SLOT_DISCONNECTED : HPC_SLOT_CONNECTED)) | 604 | ? HPC_SLOT_DISCONNECTED : HPC_SLOT_CONNECTED)) |
605 | 605 | ||
606 | #define SLOT_ATTN(s,es) ((u8) ((es & HPC_SLOT_BLINK_ATTN) \ | 606 | #define SLOT_ATTN(s, es) ((u8) ((es & HPC_SLOT_BLINK_ATTN) \ |
607 | ? HPC_SLOT_ATTN_BLINK \ | 607 | ? HPC_SLOT_ATTN_BLINK \ |
608 | : ((s & HPC_SLOT_ATTN) ? HPC_SLOT_ATTN_ON : HPC_SLOT_ATTN_OFF))) | 608 | : ((s & HPC_SLOT_ATTN) ? HPC_SLOT_ATTN_ON : HPC_SLOT_ATTN_OFF))) |
609 | 609 | ||
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 15302475f5b7..5efd01d84498 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -39,11 +39,11 @@ | |||
39 | #include <asm/io_apic.h> | 39 | #include <asm/io_apic.h> |
40 | #include "ibmphp.h" | 40 | #include "ibmphp.h" |
41 | 41 | ||
42 | #define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON) | 42 | #define attn_on(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_ATTNON) |
43 | #define attn_off(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNOFF) | 43 | #define attn_off(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_ATTNOFF) |
44 | #define attn_LED_blink(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_BLINKLED) | 44 | #define attn_LED_blink(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_BLINKLED) |
45 | #define get_ctrl_revision(sl, rev) ibmphp_hpc_readslot (sl, READ_REVLEVEL, rev) | 45 | #define get_ctrl_revision(sl, rev) ibmphp_hpc_readslot(sl, READ_REVLEVEL, rev) |
46 | #define get_hpc_options(sl, opt) ibmphp_hpc_readslot (sl, READ_HPCOPTIONS, opt) | 46 | #define get_hpc_options(sl, opt) ibmphp_hpc_readslot(sl, READ_HPCOPTIONS, opt) |
47 | 47 | ||
48 | #define DRIVER_VERSION "0.6" | 48 | #define DRIVER_VERSION "0.6" |
49 | #define DRIVER_DESC "IBM Hot Plug PCI Controller Driver" | 49 | #define DRIVER_DESC "IBM Hot Plug PCI Controller Driver" |
@@ -52,9 +52,9 @@ int ibmphp_debug; | |||
52 | 52 | ||
53 | static bool debug; | 53 | static bool debug; |
54 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 54 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
55 | MODULE_PARM_DESC (debug, "Debugging mode enabled or not"); | 55 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); |
56 | MODULE_LICENSE ("GPL"); | 56 | MODULE_LICENSE("GPL"); |
57 | MODULE_DESCRIPTION (DRIVER_DESC); | 57 | MODULE_DESCRIPTION(DRIVER_DESC); |
58 | 58 | ||
59 | struct pci_bus *ibmphp_pci_bus; | 59 | struct pci_bus *ibmphp_pci_bus; |
60 | static int max_slots; | 60 | static int max_slots; |
@@ -113,14 +113,12 @@ static inline int slot_update(struct slot **sl) | |||
113 | return rc; | 113 | return rc; |
114 | } | 114 | } |
115 | 115 | ||
116 | static int __init get_max_slots (void) | 116 | static int __init get_max_slots(void) |
117 | { | 117 | { |
118 | struct slot *slot_cur; | 118 | struct slot *slot_cur; |
119 | struct list_head *tmp; | ||
120 | u8 slot_count = 0; | 119 | u8 slot_count = 0; |
121 | 120 | ||
122 | list_for_each(tmp, &ibmphp_slot_head) { | 121 | list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) { |
123 | slot_cur = list_entry(tmp, struct slot, ibm_slot_list); | ||
124 | /* sometimes the hot-pluggable slots start with 4 (not always from 1) */ | 122 | /* sometimes the hot-pluggable slots start with 4 (not always from 1) */ |
125 | slot_count = max(slot_count, slot_cur->number); | 123 | slot_count = max(slot_count, slot_cur->number); |
126 | } | 124 | } |
@@ -459,7 +457,7 @@ static int get_max_adapter_speed_1(struct hotplug_slot *hotplug_slot, u8 *value, | |||
459 | *value = SLOT_SPEED(myslot.ext_status); | 457 | *value = SLOT_SPEED(myslot.ext_status); |
460 | } else | 458 | } else |
461 | *value = MAX_ADAPTER_NONE; | 459 | *value = MAX_ADAPTER_NONE; |
462 | } | 460 | } |
463 | } | 461 | } |
464 | 462 | ||
465 | if (flag) | 463 | if (flag) |
@@ -501,16 +499,10 @@ static int get_bus_name(struct hotplug_slot *hotplug_slot, char *value) | |||
501 | static int __init init_ops(void) | 499 | static int __init init_ops(void) |
502 | { | 500 | { |
503 | struct slot *slot_cur; | 501 | struct slot *slot_cur; |
504 | struct list_head *tmp; | ||
505 | int retval; | 502 | int retval; |
506 | int rc; | 503 | int rc; |
507 | 504 | ||
508 | list_for_each(tmp, &ibmphp_slot_head) { | 505 | list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) { |
509 | slot_cur = list_entry(tmp, struct slot, ibm_slot_list); | ||
510 | |||
511 | if (!slot_cur) | ||
512 | return -ENODEV; | ||
513 | |||
514 | debug("BEFORE GETTING SLOT STATUS, slot # %x\n", | 506 | debug("BEFORE GETTING SLOT STATUS, slot # %x\n", |
515 | slot_cur->number); | 507 | slot_cur->number); |
516 | if (slot_cur->ctrl->revision == 0xFF) | 508 | if (slot_cur->ctrl->revision == 0xFF) |
@@ -620,11 +612,11 @@ int ibmphp_update_slot_info(struct slot *slot_cur) | |||
620 | info->attention_status = SLOT_ATTN(slot_cur->status, | 612 | info->attention_status = SLOT_ATTN(slot_cur->status, |
621 | slot_cur->ext_status); | 613 | slot_cur->ext_status); |
622 | info->latch_status = SLOT_LATCH(slot_cur->status); | 614 | info->latch_status = SLOT_LATCH(slot_cur->status); |
623 | if (!SLOT_PRESENT(slot_cur->status)) { | 615 | if (!SLOT_PRESENT(slot_cur->status)) { |
624 | info->adapter_status = 0; | 616 | info->adapter_status = 0; |
625 | /* info->max_adapter_speed_status = MAX_ADAPTER_NONE; */ | 617 | /* info->max_adapter_speed_status = MAX_ADAPTER_NONE; */ |
626 | } else { | 618 | } else { |
627 | info->adapter_status = 1; | 619 | info->adapter_status = 1; |
628 | /* get_max_adapter_speed_1(slot_cur->hotplug_slot, | 620 | /* get_max_adapter_speed_1(slot_cur->hotplug_slot, |
629 | &info->max_adapter_speed_status, 0); */ | 621 | &info->max_adapter_speed_status, 0); */ |
630 | } | 622 | } |
@@ -669,9 +661,7 @@ static struct pci_func *ibm_slot_find(u8 busno, u8 device, u8 function) | |||
669 | { | 661 | { |
670 | struct pci_func *func_cur; | 662 | struct pci_func *func_cur; |
671 | struct slot *slot_cur; | 663 | struct slot *slot_cur; |
672 | struct list_head *tmp; | 664 | list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) { |
673 | list_for_each(tmp, &ibmphp_slot_head) { | ||
674 | slot_cur = list_entry(tmp, struct slot, ibm_slot_list); | ||
675 | if (slot_cur->func) { | 665 | if (slot_cur->func) { |
676 | func_cur = slot_cur->func; | 666 | func_cur = slot_cur->func; |
677 | while (func_cur) { | 667 | while (func_cur) { |
@@ -693,14 +683,12 @@ static struct pci_func *ibm_slot_find(u8 busno, u8 device, u8 function) | |||
693 | *************************************************************/ | 683 | *************************************************************/ |
694 | static void free_slots(void) | 684 | static void free_slots(void) |
695 | { | 685 | { |
696 | struct slot *slot_cur; | 686 | struct slot *slot_cur, *next; |
697 | struct list_head *tmp; | ||
698 | struct list_head *next; | ||
699 | 687 | ||
700 | debug("%s -- enter\n", __func__); | 688 | debug("%s -- enter\n", __func__); |
701 | 689 | ||
702 | list_for_each_safe(tmp, next, &ibmphp_slot_head) { | 690 | list_for_each_entry_safe(slot_cur, next, &ibmphp_slot_head, |
703 | slot_cur = list_entry(tmp, struct slot, ibm_slot_list); | 691 | ibm_slot_list) { |
704 | pci_hp_deregister(slot_cur->hotplug_slot); | 692 | pci_hp_deregister(slot_cur->hotplug_slot); |
705 | } | 693 | } |
706 | debug("%s -- exit\n", __func__); | 694 | debug("%s -- exit\n", __func__); |
@@ -866,7 +854,7 @@ static int set_bus(struct slot *slot_cur) | |||
866 | int retval; | 854 | int retval; |
867 | static struct pci_device_id ciobx[] = { | 855 | static struct pci_device_id ciobx[] = { |
868 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) }, | 856 | { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) }, |
869 | { }, | 857 | { }, |
870 | }; | 858 | }; |
871 | 859 | ||
872 | debug("%s - entry slot # %d\n", __func__, slot_cur->number); | 860 | debug("%s - entry slot # %d\n", __func__, slot_cur->number); |
@@ -1182,7 +1170,7 @@ error_power: | |||
1182 | * HOT REMOVING ADAPTER CARD * | 1170 | * HOT REMOVING ADAPTER CARD * |
1183 | * INPUT: POINTER TO THE HOTPLUG SLOT STRUCTURE * | 1171 | * INPUT: POINTER TO THE HOTPLUG SLOT STRUCTURE * |
1184 | * OUTPUT: SUCCESS 0 ; FAILURE: UNCONFIGURE , VALIDATE * | 1172 | * OUTPUT: SUCCESS 0 ; FAILURE: UNCONFIGURE , VALIDATE * |
1185 | DISABLE POWER , * | 1173 | * DISABLE POWER , * |
1186 | **************************************************************/ | 1174 | **************************************************************/ |
1187 | static int ibmphp_disable_slot(struct hotplug_slot *hotplug_slot) | 1175 | static int ibmphp_disable_slot(struct hotplug_slot *hotplug_slot) |
1188 | { | 1176 | { |
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index d9b197d5c6b4..43e345ac296b 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -49,32 +49,32 @@ | |||
49 | */ | 49 | */ |
50 | 50 | ||
51 | /* Global lists */ | 51 | /* Global lists */ |
52 | LIST_HEAD (ibmphp_ebda_pci_rsrc_head); | 52 | LIST_HEAD(ibmphp_ebda_pci_rsrc_head); |
53 | LIST_HEAD (ibmphp_slot_head); | 53 | LIST_HEAD(ibmphp_slot_head); |
54 | 54 | ||
55 | /* Local variables */ | 55 | /* Local variables */ |
56 | static struct ebda_hpc_list *hpc_list_ptr; | 56 | static struct ebda_hpc_list *hpc_list_ptr; |
57 | static struct ebda_rsrc_list *rsrc_list_ptr; | 57 | static struct ebda_rsrc_list *rsrc_list_ptr; |
58 | static struct rio_table_hdr *rio_table_ptr = NULL; | 58 | static struct rio_table_hdr *rio_table_ptr = NULL; |
59 | static LIST_HEAD (ebda_hpc_head); | 59 | static LIST_HEAD(ebda_hpc_head); |
60 | static LIST_HEAD (bus_info_head); | 60 | static LIST_HEAD(bus_info_head); |
61 | static LIST_HEAD (rio_vg_head); | 61 | static LIST_HEAD(rio_vg_head); |
62 | static LIST_HEAD (rio_lo_head); | 62 | static LIST_HEAD(rio_lo_head); |
63 | static LIST_HEAD (opt_vg_head); | 63 | static LIST_HEAD(opt_vg_head); |
64 | static LIST_HEAD (opt_lo_head); | 64 | static LIST_HEAD(opt_lo_head); |
65 | static void __iomem *io_mem; | 65 | static void __iomem *io_mem; |
66 | 66 | ||
67 | /* Local functions */ | 67 | /* Local functions */ |
68 | static int ebda_rsrc_controller (void); | 68 | static int ebda_rsrc_controller(void); |
69 | static int ebda_rsrc_rsrc (void); | 69 | static int ebda_rsrc_rsrc(void); |
70 | static int ebda_rio_table (void); | 70 | static int ebda_rio_table(void); |
71 | 71 | ||
72 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) | 72 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list(void) |
73 | { | 73 | { |
74 | return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); | 74 | return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); |
75 | } | 75 | } |
76 | 76 | ||
77 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | 77 | static struct controller *alloc_ebda_hpc(u32 slot_count, u32 bus_count) |
78 | { | 78 | { |
79 | struct controller *controller; | 79 | struct controller *controller; |
80 | struct ebda_hpc_slot *slots; | 80 | struct ebda_hpc_slot *slots; |
@@ -103,146 +103,146 @@ error: | |||
103 | return NULL; | 103 | return NULL; |
104 | } | 104 | } |
105 | 105 | ||
106 | static void free_ebda_hpc (struct controller *controller) | 106 | static void free_ebda_hpc(struct controller *controller) |
107 | { | 107 | { |
108 | kfree (controller->slots); | 108 | kfree(controller->slots); |
109 | kfree (controller->buses); | 109 | kfree(controller->buses); |
110 | kfree (controller); | 110 | kfree(controller); |
111 | } | 111 | } |
112 | 112 | ||
113 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) | 113 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list(void) |
114 | { | 114 | { |
115 | return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); | 115 | return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); |
116 | } | 116 | } |
117 | 117 | ||
118 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) | 118 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc(void) |
119 | { | 119 | { |
120 | return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); | 120 | return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); |
121 | } | 121 | } |
122 | 122 | ||
123 | static void __init print_bus_info (void) | 123 | static void __init print_bus_info(void) |
124 | { | 124 | { |
125 | struct bus_info *ptr; | 125 | struct bus_info *ptr; |
126 | 126 | ||
127 | list_for_each_entry(ptr, &bus_info_head, bus_info_list) { | 127 | list_for_each_entry(ptr, &bus_info_head, bus_info_list) { |
128 | debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); | 128 | debug("%s - slot_min = %x\n", __func__, ptr->slot_min); |
129 | debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); | 129 | debug("%s - slot_max = %x\n", __func__, ptr->slot_max); |
130 | debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); | 130 | debug("%s - slot_count = %x\n", __func__, ptr->slot_count); |
131 | debug ("%s - bus# = %x\n", __func__, ptr->busno); | 131 | debug("%s - bus# = %x\n", __func__, ptr->busno); |
132 | debug ("%s - current_speed = %x\n", __func__, ptr->current_speed); | 132 | debug("%s - current_speed = %x\n", __func__, ptr->current_speed); |
133 | debug ("%s - controller_id = %x\n", __func__, ptr->controller_id); | 133 | debug("%s - controller_id = %x\n", __func__, ptr->controller_id); |
134 | 134 | ||
135 | debug ("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv); | 135 | debug("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv); |
136 | debug ("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv); | 136 | debug("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv); |
137 | debug ("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix); | 137 | debug("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix); |
138 | debug ("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix); | 138 | debug("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix); |
139 | debug ("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix); | 139 | debug("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix); |
140 | 140 | ||
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | static void print_lo_info (void) | 144 | static void print_lo_info(void) |
145 | { | 145 | { |
146 | struct rio_detail *ptr; | 146 | struct rio_detail *ptr; |
147 | debug ("print_lo_info ----\n"); | 147 | debug("print_lo_info ----\n"); |
148 | list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) { | 148 | list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) { |
149 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); | 149 | debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); |
150 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); | 150 | debug("%s - rio_type = %x\n", __func__, ptr->rio_type); |
151 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); | 151 | debug("%s - owner_id = %x\n", __func__, ptr->owner_id); |
152 | debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); | 152 | debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); |
153 | debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); | 153 | debug("%s - wpindex = %x\n", __func__, ptr->wpindex); |
154 | debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); | 154 | debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num); |
155 | 155 | ||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | static void print_vg_info (void) | 159 | static void print_vg_info(void) |
160 | { | 160 | { |
161 | struct rio_detail *ptr; | 161 | struct rio_detail *ptr; |
162 | debug ("%s ---\n", __func__); | 162 | debug("%s ---\n", __func__); |
163 | list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) { | 163 | list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) { |
164 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); | 164 | debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); |
165 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); | 165 | debug("%s - rio_type = %x\n", __func__, ptr->rio_type); |
166 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); | 166 | debug("%s - owner_id = %x\n", __func__, ptr->owner_id); |
167 | debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); | 167 | debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); |
168 | debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); | 168 | debug("%s - wpindex = %x\n", __func__, ptr->wpindex); |
169 | debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); | 169 | debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num); |
170 | 170 | ||
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | static void __init print_ebda_pci_rsrc (void) | 174 | static void __init print_ebda_pci_rsrc(void) |
175 | { | 175 | { |
176 | struct ebda_pci_rsrc *ptr; | 176 | struct ebda_pci_rsrc *ptr; |
177 | 177 | ||
178 | list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) { | 178 | list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) { |
179 | debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", | 179 | debug("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", |
180 | __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); | 180 | __func__, ptr->rsrc_type, ptr->bus_num, ptr->dev_fun, ptr->start_addr, ptr->end_addr); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | static void __init print_ibm_slot (void) | 184 | static void __init print_ibm_slot(void) |
185 | { | 185 | { |
186 | struct slot *ptr; | 186 | struct slot *ptr; |
187 | 187 | ||
188 | list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) { | 188 | list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) { |
189 | debug ("%s - slot_number: %x\n", __func__, ptr->number); | 189 | debug("%s - slot_number: %x\n", __func__, ptr->number); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | static void __init print_opt_vg (void) | 193 | static void __init print_opt_vg(void) |
194 | { | 194 | { |
195 | struct opt_rio *ptr; | 195 | struct opt_rio *ptr; |
196 | debug ("%s ---\n", __func__); | 196 | debug("%s ---\n", __func__); |
197 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { | 197 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { |
198 | debug ("%s - rio_type %x\n", __func__, ptr->rio_type); | 198 | debug("%s - rio_type %x\n", __func__, ptr->rio_type); |
199 | debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); | 199 | debug("%s - chassis_num: %x\n", __func__, ptr->chassis_num); |
200 | debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); | 200 | debug("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); |
201 | debug ("%s - middle_num: %x\n", __func__, ptr->middle_num); | 201 | debug("%s - middle_num: %x\n", __func__, ptr->middle_num); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | static void __init print_ebda_hpc (void) | 205 | static void __init print_ebda_hpc(void) |
206 | { | 206 | { |
207 | struct controller *hpc_ptr; | 207 | struct controller *hpc_ptr; |
208 | u16 index; | 208 | u16 index; |
209 | 209 | ||
210 | list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) { | 210 | list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) { |
211 | for (index = 0; index < hpc_ptr->slot_count; index++) { | 211 | for (index = 0; index < hpc_ptr->slot_count; index++) { |
212 | debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); | 212 | debug("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); |
213 | debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); | 213 | debug("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); |
214 | debug ("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index); | 214 | debug("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index); |
215 | debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); | 215 | debug("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); |
216 | } | 216 | } |
217 | 217 | ||
218 | for (index = 0; index < hpc_ptr->bus_count; index++) | 218 | for (index = 0; index < hpc_ptr->bus_count; index++) |
219 | debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); | 219 | debug("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); |
220 | 220 | ||
221 | debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); | 221 | debug("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); |
222 | switch (hpc_ptr->ctlr_type) { | 222 | switch (hpc_ptr->ctlr_type) { |
223 | case 1: | 223 | case 1: |
224 | debug ("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus); | 224 | debug("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus); |
225 | debug ("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun); | 225 | debug("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun); |
226 | debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); | 226 | debug("%s - irq: %x\n", __func__, hpc_ptr->irq); |
227 | break; | 227 | break; |
228 | 228 | ||
229 | case 0: | 229 | case 0: |
230 | debug ("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start); | 230 | debug("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start); |
231 | debug ("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end); | 231 | debug("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end); |
232 | debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); | 232 | debug("%s - irq: %x\n", __func__, hpc_ptr->irq); |
233 | break; | 233 | break; |
234 | 234 | ||
235 | case 2: | 235 | case 2: |
236 | case 4: | 236 | case 4: |
237 | debug ("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar); | 237 | debug("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar); |
238 | debug ("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr); | 238 | debug("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr); |
239 | debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); | 239 | debug("%s - irq: %x\n", __func__, hpc_ptr->irq); |
240 | break; | 240 | break; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | int __init ibmphp_access_ebda (void) | 245 | int __init ibmphp_access_ebda(void) |
246 | { | 246 | { |
247 | u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz; | 247 | u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz; |
248 | u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base; | 248 | u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base; |
@@ -252,12 +252,12 @@ int __init ibmphp_access_ebda (void) | |||
252 | rio_complete = 0; | 252 | rio_complete = 0; |
253 | hs_complete = 0; | 253 | hs_complete = 0; |
254 | 254 | ||
255 | io_mem = ioremap ((0x40 << 4) + 0x0e, 2); | 255 | io_mem = ioremap((0x40 << 4) + 0x0e, 2); |
256 | if (!io_mem ) | 256 | if (!io_mem) |
257 | return -ENOMEM; | 257 | return -ENOMEM; |
258 | ebda_seg = readw (io_mem); | 258 | ebda_seg = readw(io_mem); |
259 | iounmap (io_mem); | 259 | iounmap(io_mem); |
260 | debug ("returned ebda segment: %x\n", ebda_seg); | 260 | debug("returned ebda segment: %x\n", ebda_seg); |
261 | 261 | ||
262 | io_mem = ioremap(ebda_seg<<4, 1); | 262 | io_mem = ioremap(ebda_seg<<4, 1); |
263 | if (!io_mem) | 263 | if (!io_mem) |
@@ -269,7 +269,7 @@ int __init ibmphp_access_ebda (void) | |||
269 | return -ENOMEM; | 269 | return -ENOMEM; |
270 | 270 | ||
271 | io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024)); | 271 | io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024)); |
272 | if (!io_mem ) | 272 | if (!io_mem) |
273 | return -ENOMEM; | 273 | return -ENOMEM; |
274 | next_offset = 0x180; | 274 | next_offset = 0x180; |
275 | 275 | ||
@@ -281,12 +281,12 @@ int __init ibmphp_access_ebda (void) | |||
281 | "ibmphp_ebda: next read is beyond ebda_sz\n")) | 281 | "ibmphp_ebda: next read is beyond ebda_sz\n")) |
282 | break; | 282 | break; |
283 | 283 | ||
284 | next_offset = readw (io_mem + offset); /* offset of next blk */ | 284 | next_offset = readw(io_mem + offset); /* offset of next blk */ |
285 | 285 | ||
286 | offset += 2; | 286 | offset += 2; |
287 | if (next_offset == 0) /* 0 indicate it's last blk */ | 287 | if (next_offset == 0) /* 0 indicate it's last blk */ |
288 | break; | 288 | break; |
289 | blk_id = readw (io_mem + offset); /* this blk id */ | 289 | blk_id = readw(io_mem + offset); /* this blk id */ |
290 | 290 | ||
291 | offset += 2; | 291 | offset += 2; |
292 | /* check if it is hot swap block or rio block */ | 292 | /* check if it is hot swap block or rio block */ |
@@ -294,31 +294,31 @@ int __init ibmphp_access_ebda (void) | |||
294 | continue; | 294 | continue; |
295 | /* found hs table */ | 295 | /* found hs table */ |
296 | if (blk_id == 0x4853) { | 296 | if (blk_id == 0x4853) { |
297 | debug ("now enter hot swap block---\n"); | 297 | debug("now enter hot swap block---\n"); |
298 | debug ("hot blk id: %x\n", blk_id); | 298 | debug("hot blk id: %x\n", blk_id); |
299 | format = readb (io_mem + offset); | 299 | format = readb(io_mem + offset); |
300 | 300 | ||
301 | offset += 1; | 301 | offset += 1; |
302 | if (format != 4) | 302 | if (format != 4) |
303 | goto error_nodev; | 303 | goto error_nodev; |
304 | debug ("hot blk format: %x\n", format); | 304 | debug("hot blk format: %x\n", format); |
305 | /* hot swap sub blk */ | 305 | /* hot swap sub blk */ |
306 | base = offset; | 306 | base = offset; |
307 | 307 | ||
308 | sub_addr = base; | 308 | sub_addr = base; |
309 | re = readw (io_mem + sub_addr); /* next sub blk */ | 309 | re = readw(io_mem + sub_addr); /* next sub blk */ |
310 | 310 | ||
311 | sub_addr += 2; | 311 | sub_addr += 2; |
312 | rc_id = readw (io_mem + sub_addr); /* sub blk id */ | 312 | rc_id = readw(io_mem + sub_addr); /* sub blk id */ |
313 | 313 | ||
314 | sub_addr += 2; | 314 | sub_addr += 2; |
315 | if (rc_id != 0x5243) | 315 | if (rc_id != 0x5243) |
316 | goto error_nodev; | 316 | goto error_nodev; |
317 | /* rc sub blk signature */ | 317 | /* rc sub blk signature */ |
318 | num_ctlrs = readb (io_mem + sub_addr); | 318 | num_ctlrs = readb(io_mem + sub_addr); |
319 | 319 | ||
320 | sub_addr += 1; | 320 | sub_addr += 1; |
321 | hpc_list_ptr = alloc_ebda_hpc_list (); | 321 | hpc_list_ptr = alloc_ebda_hpc_list(); |
322 | if (!hpc_list_ptr) { | 322 | if (!hpc_list_ptr) { |
323 | rc = -ENOMEM; | 323 | rc = -ENOMEM; |
324 | goto out; | 324 | goto out; |
@@ -326,28 +326,28 @@ int __init ibmphp_access_ebda (void) | |||
326 | hpc_list_ptr->format = format; | 326 | hpc_list_ptr->format = format; |
327 | hpc_list_ptr->num_ctlrs = num_ctlrs; | 327 | hpc_list_ptr->num_ctlrs = num_ctlrs; |
328 | hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */ | 328 | hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */ |
329 | debug ("info about hpc descriptor---\n"); | 329 | debug("info about hpc descriptor---\n"); |
330 | debug ("hot blk format: %x\n", format); | 330 | debug("hot blk format: %x\n", format); |
331 | debug ("num of controller: %x\n", num_ctlrs); | 331 | debug("num of controller: %x\n", num_ctlrs); |
332 | debug ("offset of hpc data structure entries: %x\n ", sub_addr); | 332 | debug("offset of hpc data structure entries: %x\n ", sub_addr); |
333 | 333 | ||
334 | sub_addr = base + re; /* re sub blk */ | 334 | sub_addr = base + re; /* re sub blk */ |
335 | /* FIXME: rc is never used/checked */ | 335 | /* FIXME: rc is never used/checked */ |
336 | rc = readw (io_mem + sub_addr); /* next sub blk */ | 336 | rc = readw(io_mem + sub_addr); /* next sub blk */ |
337 | 337 | ||
338 | sub_addr += 2; | 338 | sub_addr += 2; |
339 | re_id = readw (io_mem + sub_addr); /* sub blk id */ | 339 | re_id = readw(io_mem + sub_addr); /* sub blk id */ |
340 | 340 | ||
341 | sub_addr += 2; | 341 | sub_addr += 2; |
342 | if (re_id != 0x5245) | 342 | if (re_id != 0x5245) |
343 | goto error_nodev; | 343 | goto error_nodev; |
344 | 344 | ||
345 | /* signature of re */ | 345 | /* signature of re */ |
346 | num_entries = readw (io_mem + sub_addr); | 346 | num_entries = readw(io_mem + sub_addr); |
347 | 347 | ||
348 | sub_addr += 2; /* offset of RSRC_ENTRIES blk */ | 348 | sub_addr += 2; /* offset of RSRC_ENTRIES blk */ |
349 | rsrc_list_ptr = alloc_ebda_rsrc_list (); | 349 | rsrc_list_ptr = alloc_ebda_rsrc_list(); |
350 | if (!rsrc_list_ptr ) { | 350 | if (!rsrc_list_ptr) { |
351 | rc = -ENOMEM; | 351 | rc = -ENOMEM; |
352 | goto out; | 352 | goto out; |
353 | } | 353 | } |
@@ -355,26 +355,26 @@ int __init ibmphp_access_ebda (void) | |||
355 | rsrc_list_ptr->num_entries = num_entries; | 355 | rsrc_list_ptr->num_entries = num_entries; |
356 | rsrc_list_ptr->phys_addr = sub_addr; | 356 | rsrc_list_ptr->phys_addr = sub_addr; |
357 | 357 | ||
358 | debug ("info about rsrc descriptor---\n"); | 358 | debug("info about rsrc descriptor---\n"); |
359 | debug ("format: %x\n", format); | 359 | debug("format: %x\n", format); |
360 | debug ("num of rsrc: %x\n", num_entries); | 360 | debug("num of rsrc: %x\n", num_entries); |
361 | debug ("offset of rsrc data structure entries: %x\n ", sub_addr); | 361 | debug("offset of rsrc data structure entries: %x\n ", sub_addr); |
362 | 362 | ||
363 | hs_complete = 1; | 363 | hs_complete = 1; |
364 | } else { | 364 | } else { |
365 | /* found rio table, blk_id == 0x4752 */ | 365 | /* found rio table, blk_id == 0x4752 */ |
366 | debug ("now enter io table ---\n"); | 366 | debug("now enter io table ---\n"); |
367 | debug ("rio blk id: %x\n", blk_id); | 367 | debug("rio blk id: %x\n", blk_id); |
368 | 368 | ||
369 | rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); | 369 | rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); |
370 | if (!rio_table_ptr) { | 370 | if (!rio_table_ptr) { |
371 | rc = -ENOMEM; | 371 | rc = -ENOMEM; |
372 | goto out; | 372 | goto out; |
373 | } | 373 | } |
374 | rio_table_ptr->ver_num = readb (io_mem + offset); | 374 | rio_table_ptr->ver_num = readb(io_mem + offset); |
375 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); | 375 | rio_table_ptr->scal_count = readb(io_mem + offset + 1); |
376 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); | 376 | rio_table_ptr->riodev_count = readb(io_mem + offset + 2); |
377 | rio_table_ptr->offset = offset +3 ; | 377 | rio_table_ptr->offset = offset + 3 ; |
378 | 378 | ||
379 | debug("info about rio table hdr ---\n"); | 379 | debug("info about rio table hdr ---\n"); |
380 | debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ", | 380 | debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ", |
@@ -390,28 +390,28 @@ int __init ibmphp_access_ebda (void) | |||
390 | 390 | ||
391 | if (rio_table_ptr) { | 391 | if (rio_table_ptr) { |
392 | if (rio_complete && rio_table_ptr->ver_num == 3) { | 392 | if (rio_complete && rio_table_ptr->ver_num == 3) { |
393 | rc = ebda_rio_table (); | 393 | rc = ebda_rio_table(); |
394 | if (rc) | 394 | if (rc) |
395 | goto out; | 395 | goto out; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | rc = ebda_rsrc_controller (); | 398 | rc = ebda_rsrc_controller(); |
399 | if (rc) | 399 | if (rc) |
400 | goto out; | 400 | goto out; |
401 | 401 | ||
402 | rc = ebda_rsrc_rsrc (); | 402 | rc = ebda_rsrc_rsrc(); |
403 | goto out; | 403 | goto out; |
404 | error_nodev: | 404 | error_nodev: |
405 | rc = -ENODEV; | 405 | rc = -ENODEV; |
406 | out: | 406 | out: |
407 | iounmap (io_mem); | 407 | iounmap(io_mem); |
408 | return rc; | 408 | return rc; |
409 | } | 409 | } |
410 | 410 | ||
411 | /* | 411 | /* |
412 | * map info of scalability details and rio details from physical address | 412 | * map info of scalability details and rio details from physical address |
413 | */ | 413 | */ |
414 | static int __init ebda_rio_table (void) | 414 | static int __init ebda_rio_table(void) |
415 | { | 415 | { |
416 | u16 offset; | 416 | u16 offset; |
417 | u8 i; | 417 | u8 i; |
@@ -425,39 +425,39 @@ static int __init ebda_rio_table (void) | |||
425 | rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); | 425 | rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); |
426 | if (!rio_detail_ptr) | 426 | if (!rio_detail_ptr) |
427 | return -ENOMEM; | 427 | return -ENOMEM; |
428 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); | 428 | rio_detail_ptr->rio_node_id = readb(io_mem + offset); |
429 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); | 429 | rio_detail_ptr->bbar = readl(io_mem + offset + 1); |
430 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); | 430 | rio_detail_ptr->rio_type = readb(io_mem + offset + 5); |
431 | rio_detail_ptr->owner_id = readb (io_mem + offset + 6); | 431 | rio_detail_ptr->owner_id = readb(io_mem + offset + 6); |
432 | rio_detail_ptr->port0_node_connect = readb (io_mem + offset + 7); | 432 | rio_detail_ptr->port0_node_connect = readb(io_mem + offset + 7); |
433 | rio_detail_ptr->port0_port_connect = readb (io_mem + offset + 8); | 433 | rio_detail_ptr->port0_port_connect = readb(io_mem + offset + 8); |
434 | rio_detail_ptr->port1_node_connect = readb (io_mem + offset + 9); | 434 | rio_detail_ptr->port1_node_connect = readb(io_mem + offset + 9); |
435 | rio_detail_ptr->port1_port_connect = readb (io_mem + offset + 10); | 435 | rio_detail_ptr->port1_port_connect = readb(io_mem + offset + 10); |
436 | rio_detail_ptr->first_slot_num = readb (io_mem + offset + 11); | 436 | rio_detail_ptr->first_slot_num = readb(io_mem + offset + 11); |
437 | rio_detail_ptr->status = readb (io_mem + offset + 12); | 437 | rio_detail_ptr->status = readb(io_mem + offset + 12); |
438 | rio_detail_ptr->wpindex = readb (io_mem + offset + 13); | 438 | rio_detail_ptr->wpindex = readb(io_mem + offset + 13); |
439 | rio_detail_ptr->chassis_num = readb (io_mem + offset + 14); | 439 | rio_detail_ptr->chassis_num = readb(io_mem + offset + 14); |
440 | // debug ("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status); | 440 | // debug("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status); |
441 | //create linked list of chassis | 441 | //create linked list of chassis |
442 | if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5) | 442 | if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5) |
443 | list_add (&rio_detail_ptr->rio_detail_list, &rio_vg_head); | 443 | list_add(&rio_detail_ptr->rio_detail_list, &rio_vg_head); |
444 | //create linked list of expansion box | 444 | //create linked list of expansion box |
445 | else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7) | 445 | else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7) |
446 | list_add (&rio_detail_ptr->rio_detail_list, &rio_lo_head); | 446 | list_add(&rio_detail_ptr->rio_detail_list, &rio_lo_head); |
447 | else | 447 | else |
448 | // not in my concern | 448 | // not in my concern |
449 | kfree (rio_detail_ptr); | 449 | kfree(rio_detail_ptr); |
450 | offset += 15; | 450 | offset += 15; |
451 | } | 451 | } |
452 | print_lo_info (); | 452 | print_lo_info(); |
453 | print_vg_info (); | 453 | print_vg_info(); |
454 | return 0; | 454 | return 0; |
455 | } | 455 | } |
456 | 456 | ||
457 | /* | 457 | /* |
458 | * reorganizing linked list of chassis | 458 | * reorganizing linked list of chassis |
459 | */ | 459 | */ |
460 | static struct opt_rio *search_opt_vg (u8 chassis_num) | 460 | static struct opt_rio *search_opt_vg(u8 chassis_num) |
461 | { | 461 | { |
462 | struct opt_rio *ptr; | 462 | struct opt_rio *ptr; |
463 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { | 463 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { |
@@ -467,13 +467,13 @@ static struct opt_rio *search_opt_vg (u8 chassis_num) | |||
467 | return NULL; | 467 | return NULL; |
468 | } | 468 | } |
469 | 469 | ||
470 | static int __init combine_wpg_for_chassis (void) | 470 | static int __init combine_wpg_for_chassis(void) |
471 | { | 471 | { |
472 | struct opt_rio *opt_rio_ptr = NULL; | 472 | struct opt_rio *opt_rio_ptr = NULL; |
473 | struct rio_detail *rio_detail_ptr = NULL; | 473 | struct rio_detail *rio_detail_ptr = NULL; |
474 | 474 | ||
475 | list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { | 475 | list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { |
476 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); | 476 | opt_rio_ptr = search_opt_vg(rio_detail_ptr->chassis_num); |
477 | if (!opt_rio_ptr) { | 477 | if (!opt_rio_ptr) { |
478 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); | 478 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); |
479 | if (!opt_rio_ptr) | 479 | if (!opt_rio_ptr) |
@@ -482,20 +482,20 @@ static int __init combine_wpg_for_chassis (void) | |||
482 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; | 482 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; |
483 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 483 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
484 | opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num; | 484 | opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num; |
485 | list_add (&opt_rio_ptr->opt_rio_list, &opt_vg_head); | 485 | list_add(&opt_rio_ptr->opt_rio_list, &opt_vg_head); |
486 | } else { | 486 | } else { |
487 | opt_rio_ptr->first_slot_num = min (opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num); | 487 | opt_rio_ptr->first_slot_num = min(opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num); |
488 | opt_rio_ptr->middle_num = max (opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num); | 488 | opt_rio_ptr->middle_num = max(opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | print_opt_vg (); | 491 | print_opt_vg(); |
492 | return 0; | 492 | return 0; |
493 | } | 493 | } |
494 | 494 | ||
495 | /* | 495 | /* |
496 | * reorganizing linked list of expansion box | 496 | * reorganizing linked list of expansion box |
497 | */ | 497 | */ |
498 | static struct opt_rio_lo *search_opt_lo (u8 chassis_num) | 498 | static struct opt_rio_lo *search_opt_lo(u8 chassis_num) |
499 | { | 499 | { |
500 | struct opt_rio_lo *ptr; | 500 | struct opt_rio_lo *ptr; |
501 | list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) { | 501 | list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) { |
@@ -505,13 +505,13 @@ static struct opt_rio_lo *search_opt_lo (u8 chassis_num) | |||
505 | return NULL; | 505 | return NULL; |
506 | } | 506 | } |
507 | 507 | ||
508 | static int combine_wpg_for_expansion (void) | 508 | static int combine_wpg_for_expansion(void) |
509 | { | 509 | { |
510 | struct opt_rio_lo *opt_rio_lo_ptr = NULL; | 510 | struct opt_rio_lo *opt_rio_lo_ptr = NULL; |
511 | struct rio_detail *rio_detail_ptr = NULL; | 511 | struct rio_detail *rio_detail_ptr = NULL; |
512 | 512 | ||
513 | list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { | 513 | list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { |
514 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); | 514 | opt_rio_lo_ptr = search_opt_lo(rio_detail_ptr->chassis_num); |
515 | if (!opt_rio_lo_ptr) { | 515 | if (!opt_rio_lo_ptr) { |
516 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); | 516 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); |
517 | if (!opt_rio_lo_ptr) | 517 | if (!opt_rio_lo_ptr) |
@@ -522,10 +522,10 @@ static int combine_wpg_for_expansion (void) | |||
522 | opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num; | 522 | opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num; |
523 | opt_rio_lo_ptr->pack_count = 1; | 523 | opt_rio_lo_ptr->pack_count = 1; |
524 | 524 | ||
525 | list_add (&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head); | 525 | list_add(&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head); |
526 | } else { | 526 | } else { |
527 | opt_rio_lo_ptr->first_slot_num = min (opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num); | 527 | opt_rio_lo_ptr->first_slot_num = min(opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num); |
528 | opt_rio_lo_ptr->middle_num = max (opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num); | 528 | opt_rio_lo_ptr->middle_num = max(opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num); |
529 | opt_rio_lo_ptr->pack_count = 2; | 529 | opt_rio_lo_ptr->pack_count = 2; |
530 | } | 530 | } |
531 | } | 531 | } |
@@ -538,7 +538,7 @@ static int combine_wpg_for_expansion (void) | |||
538 | * Arguments: slot_num, 1st slot number of the chassis we think we are on, | 538 | * Arguments: slot_num, 1st slot number of the chassis we think we are on, |
539 | * var (0 = chassis, 1 = expansion box) | 539 | * var (0 = chassis, 1 = expansion box) |
540 | */ | 540 | */ |
541 | static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) | 541 | static int first_slot_num(u8 slot_num, u8 first_slot, u8 var) |
542 | { | 542 | { |
543 | struct opt_rio *opt_vg_ptr = NULL; | 543 | struct opt_rio *opt_vg_ptr = NULL; |
544 | struct opt_rio_lo *opt_lo_ptr = NULL; | 544 | struct opt_rio_lo *opt_lo_ptr = NULL; |
@@ -562,25 +562,25 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) | |||
562 | return rc; | 562 | return rc; |
563 | } | 563 | } |
564 | 564 | ||
565 | static struct opt_rio_lo *find_rxe_num (u8 slot_num) | 565 | static struct opt_rio_lo *find_rxe_num(u8 slot_num) |
566 | { | 566 | { |
567 | struct opt_rio_lo *opt_lo_ptr; | 567 | struct opt_rio_lo *opt_lo_ptr; |
568 | 568 | ||
569 | list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { | 569 | list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { |
570 | //check to see if this slot_num belongs to expansion box | 570 | //check to see if this slot_num belongs to expansion box |
571 | if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) | 571 | if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_lo_ptr->first_slot_num, 1))) |
572 | return opt_lo_ptr; | 572 | return opt_lo_ptr; |
573 | } | 573 | } |
574 | return NULL; | 574 | return NULL; |
575 | } | 575 | } |
576 | 576 | ||
577 | static struct opt_rio *find_chassis_num (u8 slot_num) | 577 | static struct opt_rio *find_chassis_num(u8 slot_num) |
578 | { | 578 | { |
579 | struct opt_rio *opt_vg_ptr; | 579 | struct opt_rio *opt_vg_ptr; |
580 | 580 | ||
581 | list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { | 581 | list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { |
582 | //check to see if this slot_num belongs to chassis | 582 | //check to see if this slot_num belongs to chassis |
583 | if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) | 583 | if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_vg_ptr->first_slot_num, 0))) |
584 | return opt_vg_ptr; | 584 | return opt_vg_ptr; |
585 | } | 585 | } |
586 | return NULL; | 586 | return NULL; |
@@ -589,7 +589,7 @@ static struct opt_rio *find_chassis_num (u8 slot_num) | |||
589 | /* This routine will find out how many slots are in the chassis, so that | 589 | /* This routine will find out how many slots are in the chassis, so that |
590 | * the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc | 590 | * the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc |
591 | */ | 591 | */ |
592 | static u8 calculate_first_slot (u8 slot_num) | 592 | static u8 calculate_first_slot(u8 slot_num) |
593 | { | 593 | { |
594 | u8 first_slot = 1; | 594 | u8 first_slot = 1; |
595 | struct slot *slot_cur; | 595 | struct slot *slot_cur; |
@@ -606,7 +606,7 @@ static u8 calculate_first_slot (u8 slot_num) | |||
606 | 606 | ||
607 | #define SLOT_NAME_SIZE 30 | 607 | #define SLOT_NAME_SIZE 30 |
608 | 608 | ||
609 | static char *create_file_name (struct slot *slot_cur) | 609 | static char *create_file_name(struct slot *slot_cur) |
610 | { | 610 | { |
611 | struct opt_rio *opt_vg_ptr = NULL; | 611 | struct opt_rio *opt_vg_ptr = NULL; |
612 | struct opt_rio_lo *opt_lo_ptr = NULL; | 612 | struct opt_rio_lo *opt_lo_ptr = NULL; |
@@ -618,18 +618,18 @@ static char *create_file_name (struct slot *slot_cur) | |||
618 | u8 flag = 0; | 618 | u8 flag = 0; |
619 | 619 | ||
620 | if (!slot_cur) { | 620 | if (!slot_cur) { |
621 | err ("Structure passed is empty\n"); | 621 | err("Structure passed is empty\n"); |
622 | return NULL; | 622 | return NULL; |
623 | } | 623 | } |
624 | 624 | ||
625 | slot_num = slot_cur->number; | 625 | slot_num = slot_cur->number; |
626 | 626 | ||
627 | memset (str, 0, sizeof(str)); | 627 | memset(str, 0, sizeof(str)); |
628 | 628 | ||
629 | if (rio_table_ptr) { | 629 | if (rio_table_ptr) { |
630 | if (rio_table_ptr->ver_num == 3) { | 630 | if (rio_table_ptr->ver_num == 3) { |
631 | opt_vg_ptr = find_chassis_num (slot_num); | 631 | opt_vg_ptr = find_chassis_num(slot_num); |
632 | opt_lo_ptr = find_rxe_num (slot_num); | 632 | opt_lo_ptr = find_rxe_num(slot_num); |
633 | } | 633 | } |
634 | } | 634 | } |
635 | if (opt_vg_ptr) { | 635 | if (opt_vg_ptr) { |
@@ -662,7 +662,7 @@ static char *create_file_name (struct slot *slot_cur) | |||
662 | } | 662 | } |
663 | if (!flag) { | 663 | if (!flag) { |
664 | if (slot_cur->ctrl->ctlr_type == 4) { | 664 | if (slot_cur->ctrl->ctlr_type == 4) { |
665 | first_slot = calculate_first_slot (slot_num); | 665 | first_slot = calculate_first_slot(slot_num); |
666 | which = 1; | 666 | which = 1; |
667 | } else { | 667 | } else { |
668 | which = 0; | 668 | which = 0; |
@@ -698,7 +698,7 @@ static int fillslotinfo(struct hotplug_slot *hotplug_slot) | |||
698 | hotplug_slot->info->latch_status = SLOT_LATCH(slot->status); | 698 | hotplug_slot->info->latch_status = SLOT_LATCH(slot->status); |
699 | 699 | ||
700 | // pci board - present:1 not:0 | 700 | // pci board - present:1 not:0 |
701 | if (SLOT_PRESENT (slot->status)) | 701 | if (SLOT_PRESENT(slot->status)) |
702 | hotplug_slot->info->adapter_status = 1; | 702 | hotplug_slot->info->adapter_status = 1; |
703 | else | 703 | else |
704 | hotplug_slot->info->adapter_status = 0; | 704 | hotplug_slot->info->adapter_status = 0; |
@@ -729,7 +729,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
729 | /* we don't want to actually remove the resources, since free_resources will do just that */ | 729 | /* we don't want to actually remove the resources, since free_resources will do just that */ |
730 | ibmphp_unconfigure_card(&slot, -1); | 730 | ibmphp_unconfigure_card(&slot, -1); |
731 | 731 | ||
732 | kfree (slot); | 732 | kfree(slot); |
733 | } | 733 | } |
734 | 734 | ||
735 | static struct pci_driver ibmphp_driver; | 735 | static struct pci_driver ibmphp_driver; |
@@ -739,7 +739,7 @@ static struct pci_driver ibmphp_driver; | |||
739 | * each hpc from physical address to a list of hot plug controllers based on | 739 | * each hpc from physical address to a list of hot plug controllers based on |
740 | * hpc descriptors. | 740 | * hpc descriptors. |
741 | */ | 741 | */ |
742 | static int __init ebda_rsrc_controller (void) | 742 | static int __init ebda_rsrc_controller(void) |
743 | { | 743 | { |
744 | u16 addr, addr_slot, addr_bus; | 744 | u16 addr, addr_slot, addr_bus; |
745 | u8 ctlr_id, temp, bus_index; | 745 | u8 ctlr_id, temp, bus_index; |
@@ -757,25 +757,25 @@ static int __init ebda_rsrc_controller (void) | |||
757 | addr = hpc_list_ptr->phys_addr; | 757 | addr = hpc_list_ptr->phys_addr; |
758 | for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { | 758 | for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { |
759 | bus_index = 1; | 759 | bus_index = 1; |
760 | ctlr_id = readb (io_mem + addr); | 760 | ctlr_id = readb(io_mem + addr); |
761 | addr += 1; | 761 | addr += 1; |
762 | slot_num = readb (io_mem + addr); | 762 | slot_num = readb(io_mem + addr); |
763 | 763 | ||
764 | addr += 1; | 764 | addr += 1; |
765 | addr_slot = addr; /* offset of slot structure */ | 765 | addr_slot = addr; /* offset of slot structure */ |
766 | addr += (slot_num * 4); | 766 | addr += (slot_num * 4); |
767 | 767 | ||
768 | bus_num = readb (io_mem + addr); | 768 | bus_num = readb(io_mem + addr); |
769 | 769 | ||
770 | addr += 1; | 770 | addr += 1; |
771 | addr_bus = addr; /* offset of bus */ | 771 | addr_bus = addr; /* offset of bus */ |
772 | addr += (bus_num * 9); /* offset of ctlr_type */ | 772 | addr += (bus_num * 9); /* offset of ctlr_type */ |
773 | temp = readb (io_mem + addr); | 773 | temp = readb(io_mem + addr); |
774 | 774 | ||
775 | addr += 1; | 775 | addr += 1; |
776 | /* init hpc structure */ | 776 | /* init hpc structure */ |
777 | hpc_ptr = alloc_ebda_hpc (slot_num, bus_num); | 777 | hpc_ptr = alloc_ebda_hpc(slot_num, bus_num); |
778 | if (!hpc_ptr ) { | 778 | if (!hpc_ptr) { |
779 | rc = -ENOMEM; | 779 | rc = -ENOMEM; |
780 | goto error_no_hpc; | 780 | goto error_no_hpc; |
781 | } | 781 | } |
@@ -783,23 +783,23 @@ static int __init ebda_rsrc_controller (void) | |||
783 | hpc_ptr->ctlr_relative_id = ctlr; | 783 | hpc_ptr->ctlr_relative_id = ctlr; |
784 | hpc_ptr->slot_count = slot_num; | 784 | hpc_ptr->slot_count = slot_num; |
785 | hpc_ptr->bus_count = bus_num; | 785 | hpc_ptr->bus_count = bus_num; |
786 | debug ("now enter ctlr data structure ---\n"); | 786 | debug("now enter ctlr data structure ---\n"); |
787 | debug ("ctlr id: %x\n", ctlr_id); | 787 | debug("ctlr id: %x\n", ctlr_id); |
788 | debug ("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id); | 788 | debug("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id); |
789 | debug ("count of slots controlled by this ctlr: %x\n", slot_num); | 789 | debug("count of slots controlled by this ctlr: %x\n", slot_num); |
790 | debug ("count of buses controlled by this ctlr: %x\n", bus_num); | 790 | debug("count of buses controlled by this ctlr: %x\n", bus_num); |
791 | 791 | ||
792 | /* init slot structure, fetch slot, bus, cap... */ | 792 | /* init slot structure, fetch slot, bus, cap... */ |
793 | slot_ptr = hpc_ptr->slots; | 793 | slot_ptr = hpc_ptr->slots; |
794 | for (slot = 0; slot < slot_num; slot++) { | 794 | for (slot = 0; slot < slot_num; slot++) { |
795 | slot_ptr->slot_num = readb (io_mem + addr_slot); | 795 | slot_ptr->slot_num = readb(io_mem + addr_slot); |
796 | slot_ptr->slot_bus_num = readb (io_mem + addr_slot + slot_num); | 796 | slot_ptr->slot_bus_num = readb(io_mem + addr_slot + slot_num); |
797 | slot_ptr->ctl_index = readb (io_mem + addr_slot + 2*slot_num); | 797 | slot_ptr->ctl_index = readb(io_mem + addr_slot + 2*slot_num); |
798 | slot_ptr->slot_cap = readb (io_mem + addr_slot + 3*slot_num); | 798 | slot_ptr->slot_cap = readb(io_mem + addr_slot + 3*slot_num); |
799 | 799 | ||
800 | // create bus_info lined list --- if only one slot per bus: slot_min = slot_max | 800 | // create bus_info lined list --- if only one slot per bus: slot_min = slot_max |
801 | 801 | ||
802 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); | 802 | bus_info_ptr2 = ibmphp_find_same_bus_num(slot_ptr->slot_bus_num); |
803 | if (!bus_info_ptr2) { | 803 | if (!bus_info_ptr2) { |
804 | bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); | 804 | bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); |
805 | if (!bus_info_ptr1) { | 805 | if (!bus_info_ptr1) { |
@@ -816,11 +816,11 @@ static int __init ebda_rsrc_controller (void) | |||
816 | 816 | ||
817 | bus_info_ptr1->controller_id = hpc_ptr->ctlr_id; | 817 | bus_info_ptr1->controller_id = hpc_ptr->ctlr_id; |
818 | 818 | ||
819 | list_add_tail (&bus_info_ptr1->bus_info_list, &bus_info_head); | 819 | list_add_tail(&bus_info_ptr1->bus_info_list, &bus_info_head); |
820 | 820 | ||
821 | } else { | 821 | } else { |
822 | bus_info_ptr2->slot_min = min (bus_info_ptr2->slot_min, slot_ptr->slot_num); | 822 | bus_info_ptr2->slot_min = min(bus_info_ptr2->slot_min, slot_ptr->slot_num); |
823 | bus_info_ptr2->slot_max = max (bus_info_ptr2->slot_max, slot_ptr->slot_num); | 823 | bus_info_ptr2->slot_max = max(bus_info_ptr2->slot_max, slot_ptr->slot_num); |
824 | bus_info_ptr2->slot_count += 1; | 824 | bus_info_ptr2->slot_count += 1; |
825 | 825 | ||
826 | } | 826 | } |
@@ -834,17 +834,17 @@ static int __init ebda_rsrc_controller (void) | |||
834 | /* init bus structure */ | 834 | /* init bus structure */ |
835 | bus_ptr = hpc_ptr->buses; | 835 | bus_ptr = hpc_ptr->buses; |
836 | for (bus = 0; bus < bus_num; bus++) { | 836 | for (bus = 0; bus < bus_num; bus++) { |
837 | bus_ptr->bus_num = readb (io_mem + addr_bus + bus); | 837 | bus_ptr->bus_num = readb(io_mem + addr_bus + bus); |
838 | bus_ptr->slots_at_33_conv = readb (io_mem + addr_bus + bus_num + 8 * bus); | 838 | bus_ptr->slots_at_33_conv = readb(io_mem + addr_bus + bus_num + 8 * bus); |
839 | bus_ptr->slots_at_66_conv = readb (io_mem + addr_bus + bus_num + 8 * bus + 1); | 839 | bus_ptr->slots_at_66_conv = readb(io_mem + addr_bus + bus_num + 8 * bus + 1); |
840 | 840 | ||
841 | bus_ptr->slots_at_66_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 2); | 841 | bus_ptr->slots_at_66_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 2); |
842 | 842 | ||
843 | bus_ptr->slots_at_100_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 3); | 843 | bus_ptr->slots_at_100_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 3); |
844 | 844 | ||
845 | bus_ptr->slots_at_133_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 4); | 845 | bus_ptr->slots_at_133_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 4); |
846 | 846 | ||
847 | bus_info_ptr2 = ibmphp_find_same_bus_num (bus_ptr->bus_num); | 847 | bus_info_ptr2 = ibmphp_find_same_bus_num(bus_ptr->bus_num); |
848 | if (bus_info_ptr2) { | 848 | if (bus_info_ptr2) { |
849 | bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv; | 849 | bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv; |
850 | bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv; | 850 | bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv; |
@@ -859,33 +859,33 @@ static int __init ebda_rsrc_controller (void) | |||
859 | 859 | ||
860 | switch (hpc_ptr->ctlr_type) { | 860 | switch (hpc_ptr->ctlr_type) { |
861 | case 1: | 861 | case 1: |
862 | hpc_ptr->u.pci_ctlr.bus = readb (io_mem + addr); | 862 | hpc_ptr->u.pci_ctlr.bus = readb(io_mem + addr); |
863 | hpc_ptr->u.pci_ctlr.dev_fun = readb (io_mem + addr + 1); | 863 | hpc_ptr->u.pci_ctlr.dev_fun = readb(io_mem + addr + 1); |
864 | hpc_ptr->irq = readb (io_mem + addr + 2); | 864 | hpc_ptr->irq = readb(io_mem + addr + 2); |
865 | addr += 3; | 865 | addr += 3; |
866 | debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", | 866 | debug("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", |
867 | hpc_ptr->u.pci_ctlr.bus, | 867 | hpc_ptr->u.pci_ctlr.bus, |
868 | hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); | 868 | hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); |
869 | break; | 869 | break; |
870 | 870 | ||
871 | case 0: | 871 | case 0: |
872 | hpc_ptr->u.isa_ctlr.io_start = readw (io_mem + addr); | 872 | hpc_ptr->u.isa_ctlr.io_start = readw(io_mem + addr); |
873 | hpc_ptr->u.isa_ctlr.io_end = readw (io_mem + addr + 2); | 873 | hpc_ptr->u.isa_ctlr.io_end = readw(io_mem + addr + 2); |
874 | if (!request_region (hpc_ptr->u.isa_ctlr.io_start, | 874 | if (!request_region(hpc_ptr->u.isa_ctlr.io_start, |
875 | (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1), | 875 | (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1), |
876 | "ibmphp")) { | 876 | "ibmphp")) { |
877 | rc = -ENODEV; | 877 | rc = -ENODEV; |
878 | goto error_no_hp_slot; | 878 | goto error_no_hp_slot; |
879 | } | 879 | } |
880 | hpc_ptr->irq = readb (io_mem + addr + 4); | 880 | hpc_ptr->irq = readb(io_mem + addr + 4); |
881 | addr += 5; | 881 | addr += 5; |
882 | break; | 882 | break; |
883 | 883 | ||
884 | case 2: | 884 | case 2: |
885 | case 4: | 885 | case 4: |
886 | hpc_ptr->u.wpeg_ctlr.wpegbbar = readl (io_mem + addr); | 886 | hpc_ptr->u.wpeg_ctlr.wpegbbar = readl(io_mem + addr); |
887 | hpc_ptr->u.wpeg_ctlr.i2c_addr = readb (io_mem + addr + 4); | 887 | hpc_ptr->u.wpeg_ctlr.i2c_addr = readb(io_mem + addr + 4); |
888 | hpc_ptr->irq = readb (io_mem + addr + 5); | 888 | hpc_ptr->irq = readb(io_mem + addr + 5); |
889 | addr += 6; | 889 | addr += 6; |
890 | break; | 890 | break; |
891 | default: | 891 | default: |
@@ -894,8 +894,8 @@ static int __init ebda_rsrc_controller (void) | |||
894 | } | 894 | } |
895 | 895 | ||
896 | //reorganize chassis' linked list | 896 | //reorganize chassis' linked list |
897 | combine_wpg_for_chassis (); | 897 | combine_wpg_for_chassis(); |
898 | combine_wpg_for_expansion (); | 898 | combine_wpg_for_expansion(); |
899 | hpc_ptr->revision = 0xff; | 899 | hpc_ptr->revision = 0xff; |
900 | hpc_ptr->options = 0xff; | 900 | hpc_ptr->options = 0xff; |
901 | hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num; | 901 | hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num; |
@@ -940,7 +940,7 @@ static int __init ebda_rsrc_controller (void) | |||
940 | 940 | ||
941 | tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num; | 941 | tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num; |
942 | 942 | ||
943 | bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num); | 943 | bus_info_ptr1 = ibmphp_find_same_bus_num(hpc_ptr->slots[index].slot_bus_num); |
944 | if (!bus_info_ptr1) { | 944 | if (!bus_info_ptr1) { |
945 | kfree(tmp_slot); | 945 | kfree(tmp_slot); |
946 | rc = -ENODEV; | 946 | rc = -ENODEV; |
@@ -961,18 +961,18 @@ static int __init ebda_rsrc_controller (void) | |||
961 | if (rc) | 961 | if (rc) |
962 | goto error; | 962 | goto error; |
963 | 963 | ||
964 | rc = ibmphp_init_devno ((struct slot **) &hp_slot_ptr->private); | 964 | rc = ibmphp_init_devno((struct slot **) &hp_slot_ptr->private); |
965 | if (rc) | 965 | if (rc) |
966 | goto error; | 966 | goto error; |
967 | hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops; | 967 | hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops; |
968 | 968 | ||
969 | // end of registering ibm slot with hotplug core | 969 | // end of registering ibm slot with hotplug core |
970 | 970 | ||
971 | list_add (& ((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head); | 971 | list_add(&((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head); |
972 | } | 972 | } |
973 | 973 | ||
974 | print_bus_info (); | 974 | print_bus_info(); |
975 | list_add (&hpc_ptr->ebda_hpc_list, &ebda_hpc_head ); | 975 | list_add(&hpc_ptr->ebda_hpc_list, &ebda_hpc_head); |
976 | 976 | ||
977 | } /* each hpc */ | 977 | } /* each hpc */ |
978 | 978 | ||
@@ -982,20 +982,20 @@ static int __init ebda_rsrc_controller (void) | |||
982 | pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name); | 982 | pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name); |
983 | } | 983 | } |
984 | 984 | ||
985 | print_ebda_hpc (); | 985 | print_ebda_hpc(); |
986 | print_ibm_slot (); | 986 | print_ibm_slot(); |
987 | return 0; | 987 | return 0; |
988 | 988 | ||
989 | error: | 989 | error: |
990 | kfree (hp_slot_ptr->private); | 990 | kfree(hp_slot_ptr->private); |
991 | error_no_slot: | 991 | error_no_slot: |
992 | kfree (hp_slot_ptr->info); | 992 | kfree(hp_slot_ptr->info); |
993 | error_no_hp_info: | 993 | error_no_hp_info: |
994 | kfree (hp_slot_ptr); | 994 | kfree(hp_slot_ptr); |
995 | error_no_hp_slot: | 995 | error_no_hp_slot: |
996 | free_ebda_hpc (hpc_ptr); | 996 | free_ebda_hpc(hpc_ptr); |
997 | error_no_hpc: | 997 | error_no_hpc: |
998 | iounmap (io_mem); | 998 | iounmap(io_mem); |
999 | return rc; | 999 | return rc; |
1000 | } | 1000 | } |
1001 | 1001 | ||
@@ -1003,7 +1003,7 @@ error_no_hpc: | |||
1003 | * map info (bus, devfun, start addr, end addr..) of i/o, memory, | 1003 | * map info (bus, devfun, start addr, end addr..) of i/o, memory, |
1004 | * pfm from the physical addr to a list of resource. | 1004 | * pfm from the physical addr to a list of resource. |
1005 | */ | 1005 | */ |
1006 | static int __init ebda_rsrc_rsrc (void) | 1006 | static int __init ebda_rsrc_rsrc(void) |
1007 | { | 1007 | { |
1008 | u16 addr; | 1008 | u16 addr; |
1009 | short rsrc; | 1009 | short rsrc; |
@@ -1011,69 +1011,69 @@ static int __init ebda_rsrc_rsrc (void) | |||
1011 | struct ebda_pci_rsrc *rsrc_ptr; | 1011 | struct ebda_pci_rsrc *rsrc_ptr; |
1012 | 1012 | ||
1013 | addr = rsrc_list_ptr->phys_addr; | 1013 | addr = rsrc_list_ptr->phys_addr; |
1014 | debug ("now entering rsrc land\n"); | 1014 | debug("now entering rsrc land\n"); |
1015 | debug ("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr); | 1015 | debug("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr); |
1016 | 1016 | ||
1017 | for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) { | 1017 | for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) { |
1018 | type = readb (io_mem + addr); | 1018 | type = readb(io_mem + addr); |
1019 | 1019 | ||
1020 | addr += 1; | 1020 | addr += 1; |
1021 | rsrc_type = type & EBDA_RSRC_TYPE_MASK; | 1021 | rsrc_type = type & EBDA_RSRC_TYPE_MASK; |
1022 | 1022 | ||
1023 | if (rsrc_type == EBDA_IO_RSRC_TYPE) { | 1023 | if (rsrc_type == EBDA_IO_RSRC_TYPE) { |
1024 | rsrc_ptr = alloc_ebda_pci_rsrc (); | 1024 | rsrc_ptr = alloc_ebda_pci_rsrc(); |
1025 | if (!rsrc_ptr) { | 1025 | if (!rsrc_ptr) { |
1026 | iounmap (io_mem); | 1026 | iounmap(io_mem); |
1027 | return -ENOMEM; | 1027 | return -ENOMEM; |
1028 | } | 1028 | } |
1029 | rsrc_ptr->rsrc_type = type; | 1029 | rsrc_ptr->rsrc_type = type; |
1030 | 1030 | ||
1031 | rsrc_ptr->bus_num = readb (io_mem + addr); | 1031 | rsrc_ptr->bus_num = readb(io_mem + addr); |
1032 | rsrc_ptr->dev_fun = readb (io_mem + addr + 1); | 1032 | rsrc_ptr->dev_fun = readb(io_mem + addr + 1); |
1033 | rsrc_ptr->start_addr = readw (io_mem + addr + 2); | 1033 | rsrc_ptr->start_addr = readw(io_mem + addr + 2); |
1034 | rsrc_ptr->end_addr = readw (io_mem + addr + 4); | 1034 | rsrc_ptr->end_addr = readw(io_mem + addr + 4); |
1035 | addr += 6; | 1035 | addr += 6; |
1036 | 1036 | ||
1037 | debug ("rsrc from io type ----\n"); | 1037 | debug("rsrc from io type ----\n"); |
1038 | debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", | 1038 | debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", |
1039 | rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); | 1039 | rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); |
1040 | 1040 | ||
1041 | list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); | 1041 | list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) { | 1044 | if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) { |
1045 | rsrc_ptr = alloc_ebda_pci_rsrc (); | 1045 | rsrc_ptr = alloc_ebda_pci_rsrc(); |
1046 | if (!rsrc_ptr ) { | 1046 | if (!rsrc_ptr) { |
1047 | iounmap (io_mem); | 1047 | iounmap(io_mem); |
1048 | return -ENOMEM; | 1048 | return -ENOMEM; |
1049 | } | 1049 | } |
1050 | rsrc_ptr->rsrc_type = type; | 1050 | rsrc_ptr->rsrc_type = type; |
1051 | 1051 | ||
1052 | rsrc_ptr->bus_num = readb (io_mem + addr); | 1052 | rsrc_ptr->bus_num = readb(io_mem + addr); |
1053 | rsrc_ptr->dev_fun = readb (io_mem + addr + 1); | 1053 | rsrc_ptr->dev_fun = readb(io_mem + addr + 1); |
1054 | rsrc_ptr->start_addr = readl (io_mem + addr + 2); | 1054 | rsrc_ptr->start_addr = readl(io_mem + addr + 2); |
1055 | rsrc_ptr->end_addr = readl (io_mem + addr + 6); | 1055 | rsrc_ptr->end_addr = readl(io_mem + addr + 6); |
1056 | addr += 10; | 1056 | addr += 10; |
1057 | 1057 | ||
1058 | debug ("rsrc from mem or pfm ---\n"); | 1058 | debug("rsrc from mem or pfm ---\n"); |
1059 | debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", | 1059 | debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", |
1060 | rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); | 1060 | rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); |
1061 | 1061 | ||
1062 | list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); | 1062 | list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); |
1063 | } | 1063 | } |
1064 | } | 1064 | } |
1065 | kfree (rsrc_list_ptr); | 1065 | kfree(rsrc_list_ptr); |
1066 | rsrc_list_ptr = NULL; | 1066 | rsrc_list_ptr = NULL; |
1067 | print_ebda_pci_rsrc (); | 1067 | print_ebda_pci_rsrc(); |
1068 | return 0; | 1068 | return 0; |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | u16 ibmphp_get_total_controllers (void) | 1071 | u16 ibmphp_get_total_controllers(void) |
1072 | { | 1072 | { |
1073 | return hpc_list_ptr->num_ctlrs; | 1073 | return hpc_list_ptr->num_ctlrs; |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) | 1076 | struct slot *ibmphp_get_slot_from_physical_num(u8 physical_num) |
1077 | { | 1077 | { |
1078 | struct slot *slot; | 1078 | struct slot *slot; |
1079 | 1079 | ||
@@ -1090,7 +1090,7 @@ struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) | |||
1090 | * - the total number of the slots based on each bus | 1090 | * - the total number of the slots based on each bus |
1091 | * (if only one slot per bus slot_min = slot_max ) | 1091 | * (if only one slot per bus slot_min = slot_max ) |
1092 | */ | 1092 | */ |
1093 | struct bus_info *ibmphp_find_same_bus_num (u32 num) | 1093 | struct bus_info *ibmphp_find_same_bus_num(u32 num) |
1094 | { | 1094 | { |
1095 | struct bus_info *ptr; | 1095 | struct bus_info *ptr; |
1096 | 1096 | ||
@@ -1104,7 +1104,7 @@ struct bus_info *ibmphp_find_same_bus_num (u32 num) | |||
1104 | /* Finding relative bus number, in order to map corresponding | 1104 | /* Finding relative bus number, in order to map corresponding |
1105 | * bus register | 1105 | * bus register |
1106 | */ | 1106 | */ |
1107 | int ibmphp_get_bus_index (u8 num) | 1107 | int ibmphp_get_bus_index(u8 num) |
1108 | { | 1108 | { |
1109 | struct bus_info *ptr; | 1109 | struct bus_info *ptr; |
1110 | 1110 | ||
@@ -1115,45 +1115,39 @@ int ibmphp_get_bus_index (u8 num) | |||
1115 | return -ENODEV; | 1115 | return -ENODEV; |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | void ibmphp_free_bus_info_queue (void) | 1118 | void ibmphp_free_bus_info_queue(void) |
1119 | { | 1119 | { |
1120 | struct bus_info *bus_info; | 1120 | struct bus_info *bus_info, *next; |
1121 | struct list_head *list; | ||
1122 | struct list_head *next; | ||
1123 | 1121 | ||
1124 | list_for_each_safe (list, next, &bus_info_head ) { | 1122 | list_for_each_entry_safe(bus_info, next, &bus_info_head, |
1125 | bus_info = list_entry (list, struct bus_info, bus_info_list); | 1123 | bus_info_list) { |
1126 | kfree (bus_info); | 1124 | kfree (bus_info); |
1127 | } | 1125 | } |
1128 | } | 1126 | } |
1129 | 1127 | ||
1130 | void ibmphp_free_ebda_hpc_queue (void) | 1128 | void ibmphp_free_ebda_hpc_queue(void) |
1131 | { | 1129 | { |
1132 | struct controller *controller = NULL; | 1130 | struct controller *controller = NULL, *next; |
1133 | struct list_head *list; | ||
1134 | struct list_head *next; | ||
1135 | int pci_flag = 0; | 1131 | int pci_flag = 0; |
1136 | 1132 | ||
1137 | list_for_each_safe (list, next, &ebda_hpc_head) { | 1133 | list_for_each_entry_safe(controller, next, &ebda_hpc_head, |
1138 | controller = list_entry (list, struct controller, ebda_hpc_list); | 1134 | ebda_hpc_list) { |
1139 | if (controller->ctlr_type == 0) | 1135 | if (controller->ctlr_type == 0) |
1140 | release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); | 1136 | release_region(controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); |
1141 | else if ((controller->ctlr_type == 1) && (!pci_flag)) { | 1137 | else if ((controller->ctlr_type == 1) && (!pci_flag)) { |
1142 | ++pci_flag; | 1138 | ++pci_flag; |
1143 | pci_unregister_driver (&ibmphp_driver); | 1139 | pci_unregister_driver(&ibmphp_driver); |
1144 | } | 1140 | } |
1145 | free_ebda_hpc (controller); | 1141 | free_ebda_hpc(controller); |
1146 | } | 1142 | } |
1147 | } | 1143 | } |
1148 | 1144 | ||
1149 | void ibmphp_free_ebda_pci_rsrc_queue (void) | 1145 | void ibmphp_free_ebda_pci_rsrc_queue(void) |
1150 | { | 1146 | { |
1151 | struct ebda_pci_rsrc *resource; | 1147 | struct ebda_pci_rsrc *resource, *next; |
1152 | struct list_head *list; | ||
1153 | struct list_head *next; | ||
1154 | 1148 | ||
1155 | list_for_each_safe (list, next, &ibmphp_ebda_pci_rsrc_head) { | 1149 | list_for_each_entry_safe(resource, next, &ibmphp_ebda_pci_rsrc_head, |
1156 | resource = list_entry (list, struct ebda_pci_rsrc, ebda_pci_rsrc_list); | 1150 | ebda_pci_rsrc_list) { |
1157 | kfree (resource); | 1151 | kfree (resource); |
1158 | resource = NULL; | 1152 | resource = NULL; |
1159 | } | 1153 | } |
@@ -1171,14 +1165,14 @@ static struct pci_device_id id_table[] = { | |||
1171 | 1165 | ||
1172 | MODULE_DEVICE_TABLE(pci, id_table); | 1166 | MODULE_DEVICE_TABLE(pci, id_table); |
1173 | 1167 | ||
1174 | static int ibmphp_probe (struct pci_dev *, const struct pci_device_id *); | 1168 | static int ibmphp_probe(struct pci_dev *, const struct pci_device_id *); |
1175 | static struct pci_driver ibmphp_driver = { | 1169 | static struct pci_driver ibmphp_driver = { |
1176 | .name = "ibmphp", | 1170 | .name = "ibmphp", |
1177 | .id_table = id_table, | 1171 | .id_table = id_table, |
1178 | .probe = ibmphp_probe, | 1172 | .probe = ibmphp_probe, |
1179 | }; | 1173 | }; |
1180 | 1174 | ||
1181 | int ibmphp_register_pci (void) | 1175 | int ibmphp_register_pci(void) |
1182 | { | 1176 | { |
1183 | struct controller *ctrl; | 1177 | struct controller *ctrl; |
1184 | int rc = 0; | 1178 | int rc = 0; |
@@ -1191,18 +1185,18 @@ int ibmphp_register_pci (void) | |||
1191 | } | 1185 | } |
1192 | return rc; | 1186 | return rc; |
1193 | } | 1187 | } |
1194 | static int ibmphp_probe (struct pci_dev *dev, const struct pci_device_id *ids) | 1188 | static int ibmphp_probe(struct pci_dev *dev, const struct pci_device_id *ids) |
1195 | { | 1189 | { |
1196 | struct controller *ctrl; | 1190 | struct controller *ctrl; |
1197 | 1191 | ||
1198 | debug ("inside ibmphp_probe\n"); | 1192 | debug("inside ibmphp_probe\n"); |
1199 | 1193 | ||
1200 | list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { | 1194 | list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { |
1201 | if (ctrl->ctlr_type == 1) { | 1195 | if (ctrl->ctlr_type == 1) { |
1202 | if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { | 1196 | if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { |
1203 | ctrl->ctrl_dev = dev; | 1197 | ctrl->ctrl_dev = dev; |
1204 | debug ("found device!!!\n"); | 1198 | debug("found device!!!\n"); |
1205 | debug ("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); | 1199 | debug("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); |
1206 | return 0; | 1200 | return 0; |
1207 | } | 1201 | } |
1208 | } | 1202 | } |
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c index 220876715a08..a6b458e4ab46 100644 --- a/drivers/pci/hotplug/ibmphp_hpc.c +++ b/drivers/pci/hotplug/ibmphp_hpc.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include "ibmphp.h" | 40 | #include "ibmphp.h" |
41 | 41 | ||
42 | static int to_debug = 0; | 42 | static int to_debug = 0; |
43 | #define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) | 43 | #define debug_polling(fmt, arg...) do { if (to_debug) debug(fmt, arg); } while (0) |
44 | 44 | ||
45 | //---------------------------------------------------------------------------- | 45 | //---------------------------------------------------------------------------- |
46 | // timeout values | 46 | // timeout values |
@@ -110,16 +110,16 @@ static struct task_struct *ibmphp_poll_thread; | |||
110 | //---------------------------------------------------------------------------- | 110 | //---------------------------------------------------------------------------- |
111 | // local function prototypes | 111 | // local function prototypes |
112 | //---------------------------------------------------------------------------- | 112 | //---------------------------------------------------------------------------- |
113 | static u8 i2c_ctrl_read (struct controller *, void __iomem *, u8); | 113 | static u8 i2c_ctrl_read(struct controller *, void __iomem *, u8); |
114 | static u8 i2c_ctrl_write (struct controller *, void __iomem *, u8, u8); | 114 | static u8 i2c_ctrl_write(struct controller *, void __iomem *, u8, u8); |
115 | static u8 hpc_writecmdtoindex (u8, u8); | 115 | static u8 hpc_writecmdtoindex(u8, u8); |
116 | static u8 hpc_readcmdtoindex (u8, u8); | 116 | static u8 hpc_readcmdtoindex(u8, u8); |
117 | static void get_hpc_access (void); | 117 | static void get_hpc_access(void); |
118 | static void free_hpc_access (void); | 118 | static void free_hpc_access(void); |
119 | static int poll_hpc(void *data); | 119 | static int poll_hpc(void *data); |
120 | static int process_changeinstatus (struct slot *, struct slot *); | 120 | static int process_changeinstatus(struct slot *, struct slot *); |
121 | static int process_changeinlatch (u8, u8, struct controller *); | 121 | static int process_changeinlatch(u8, u8, struct controller *); |
122 | static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *); | 122 | static int hpc_wait_ctlr_notworking(int, struct controller *, void __iomem *, u8 *); |
123 | //---------------------------------------------------------------------------- | 123 | //---------------------------------------------------------------------------- |
124 | 124 | ||
125 | 125 | ||
@@ -128,16 +128,16 @@ static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u | |||
128 | * | 128 | * |
129 | * Action: initialize semaphores and variables | 129 | * Action: initialize semaphores and variables |
130 | *---------------------------------------------------------------------*/ | 130 | *---------------------------------------------------------------------*/ |
131 | void __init ibmphp_hpc_initvars (void) | 131 | void __init ibmphp_hpc_initvars(void) |
132 | { | 132 | { |
133 | debug ("%s - Entry\n", __func__); | 133 | debug("%s - Entry\n", __func__); |
134 | 134 | ||
135 | mutex_init(&sem_hpcaccess); | 135 | mutex_init(&sem_hpcaccess); |
136 | sema_init(&semOperations, 1); | 136 | sema_init(&semOperations, 1); |
137 | sema_init(&sem_exit, 0); | 137 | sema_init(&sem_exit, 0); |
138 | to_debug = 0; | 138 | to_debug = 0; |
139 | 139 | ||
140 | debug ("%s - Exit\n", __func__); | 140 | debug("%s - Exit\n", __func__); |
141 | } | 141 | } |
142 | 142 | ||
143 | /*---------------------------------------------------------------------- | 143 | /*---------------------------------------------------------------------- |
@@ -146,7 +146,7 @@ void __init ibmphp_hpc_initvars (void) | |||
146 | * Action: read from HPC over I2C | 146 | * Action: read from HPC over I2C |
147 | * | 147 | * |
148 | *---------------------------------------------------------------------*/ | 148 | *---------------------------------------------------------------------*/ |
149 | static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index) | 149 | static u8 i2c_ctrl_read(struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index) |
150 | { | 150 | { |
151 | u8 status; | 151 | u8 status; |
152 | int i; | 152 | int i; |
@@ -155,7 +155,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
155 | unsigned long ultemp; | 155 | unsigned long ultemp; |
156 | unsigned long data; // actual data HILO format | 156 | unsigned long data; // actual data HILO format |
157 | 157 | ||
158 | debug_polling ("%s - Entry WPGBbar[%p] index[%x] \n", __func__, WPGBbar, index); | 158 | debug_polling("%s - Entry WPGBbar[%p] index[%x] \n", __func__, WPGBbar, index); |
159 | 159 | ||
160 | //-------------------------------------------------------------------- | 160 | //-------------------------------------------------------------------- |
161 | // READ - step 1 | 161 | // READ - step 1 |
@@ -178,28 +178,28 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
178 | ultemp = ultemp << 8; | 178 | ultemp = ultemp << 8; |
179 | data |= ultemp; | 179 | data |= ultemp; |
180 | } else { | 180 | } else { |
181 | err ("this controller type is not supported \n"); | 181 | err("this controller type is not supported \n"); |
182 | return HPC_ERROR; | 182 | return HPC_ERROR; |
183 | } | 183 | } |
184 | 184 | ||
185 | wpg_data = swab32 (data); // swap data before writing | 185 | wpg_data = swab32(data); // swap data before writing |
186 | wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; | 186 | wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; |
187 | writel (wpg_data, wpg_addr); | 187 | writel(wpg_data, wpg_addr); |
188 | 188 | ||
189 | //-------------------------------------------------------------------- | 189 | //-------------------------------------------------------------------- |
190 | // READ - step 2 : clear the message buffer | 190 | // READ - step 2 : clear the message buffer |
191 | data = 0x00000000; | 191 | data = 0x00000000; |
192 | wpg_data = swab32 (data); | 192 | wpg_data = swab32(data); |
193 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; | 193 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; |
194 | writel (wpg_data, wpg_addr); | 194 | writel(wpg_data, wpg_addr); |
195 | 195 | ||
196 | //-------------------------------------------------------------------- | 196 | //-------------------------------------------------------------------- |
197 | // READ - step 3 : issue start operation, I2C master control bit 30:ON | 197 | // READ - step 3 : issue start operation, I2C master control bit 30:ON |
198 | // 2020 : [20] OR operation at [20] offset 0x20 | 198 | // 2020 : [20] OR operation at [20] offset 0x20 |
199 | data = WPG_I2CMCNTL_STARTOP_MASK; | 199 | data = WPG_I2CMCNTL_STARTOP_MASK; |
200 | wpg_data = swab32 (data); | 200 | wpg_data = swab32(data); |
201 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; | 201 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; |
202 | writel (wpg_data, wpg_addr); | 202 | writel(wpg_data, wpg_addr); |
203 | 203 | ||
204 | //-------------------------------------------------------------------- | 204 | //-------------------------------------------------------------------- |
205 | // READ - step 4 : wait until start operation bit clears | 205 | // READ - step 4 : wait until start operation bit clears |
@@ -207,14 +207,14 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
207 | while (i) { | 207 | while (i) { |
208 | msleep(10); | 208 | msleep(10); |
209 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; | 209 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; |
210 | wpg_data = readl (wpg_addr); | 210 | wpg_data = readl(wpg_addr); |
211 | data = swab32 (wpg_data); | 211 | data = swab32(wpg_data); |
212 | if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) | 212 | if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) |
213 | break; | 213 | break; |
214 | i--; | 214 | i--; |
215 | } | 215 | } |
216 | if (i == 0) { | 216 | if (i == 0) { |
217 | debug ("%s - Error : WPG timeout\n", __func__); | 217 | debug("%s - Error : WPG timeout\n", __func__); |
218 | return HPC_ERROR; | 218 | return HPC_ERROR; |
219 | } | 219 | } |
220 | //-------------------------------------------------------------------- | 220 | //-------------------------------------------------------------------- |
@@ -223,26 +223,26 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
223 | while (i) { | 223 | while (i) { |
224 | msleep(10); | 224 | msleep(10); |
225 | wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; | 225 | wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; |
226 | wpg_data = readl (wpg_addr); | 226 | wpg_data = readl(wpg_addr); |
227 | data = swab32 (wpg_data); | 227 | data = swab32(wpg_data); |
228 | if (HPC_I2CSTATUS_CHECK (data)) | 228 | if (HPC_I2CSTATUS_CHECK(data)) |
229 | break; | 229 | break; |
230 | i--; | 230 | i--; |
231 | } | 231 | } |
232 | if (i == 0) { | 232 | if (i == 0) { |
233 | debug ("ctrl_read - Exit Error:I2C timeout\n"); | 233 | debug("ctrl_read - Exit Error:I2C timeout\n"); |
234 | return HPC_ERROR; | 234 | return HPC_ERROR; |
235 | } | 235 | } |
236 | 236 | ||
237 | //-------------------------------------------------------------------- | 237 | //-------------------------------------------------------------------- |
238 | // READ - step 6 : get DATA | 238 | // READ - step 6 : get DATA |
239 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; | 239 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; |
240 | wpg_data = readl (wpg_addr); | 240 | wpg_data = readl(wpg_addr); |
241 | data = swab32 (wpg_data); | 241 | data = swab32(wpg_data); |
242 | 242 | ||
243 | status = (u8) data; | 243 | status = (u8) data; |
244 | 244 | ||
245 | debug_polling ("%s - Exit index[%x] status[%x]\n", __func__, index, status); | 245 | debug_polling("%s - Exit index[%x] status[%x]\n", __func__, index, status); |
246 | 246 | ||
247 | return (status); | 247 | return (status); |
248 | } | 248 | } |
@@ -254,7 +254,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
254 | * | 254 | * |
255 | * Return 0 or error codes | 255 | * Return 0 or error codes |
256 | *---------------------------------------------------------------------*/ | 256 | *---------------------------------------------------------------------*/ |
257 | static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd) | 257 | static u8 i2c_ctrl_write(struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd) |
258 | { | 258 | { |
259 | u8 rc; | 259 | u8 rc; |
260 | void __iomem *wpg_addr; // base addr + offset | 260 | void __iomem *wpg_addr; // base addr + offset |
@@ -263,7 +263,7 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
263 | unsigned long data; // actual data HILO format | 263 | unsigned long data; // actual data HILO format |
264 | int i; | 264 | int i; |
265 | 265 | ||
266 | debug_polling ("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __func__, WPGBbar, index, cmd); | 266 | debug_polling("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __func__, WPGBbar, index, cmd); |
267 | 267 | ||
268 | rc = 0; | 268 | rc = 0; |
269 | //-------------------------------------------------------------------- | 269 | //-------------------------------------------------------------------- |
@@ -289,28 +289,28 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
289 | ultemp = ultemp << 8; | 289 | ultemp = ultemp << 8; |
290 | data |= ultemp; | 290 | data |= ultemp; |
291 | } else { | 291 | } else { |
292 | err ("this controller type is not supported \n"); | 292 | err("this controller type is not supported \n"); |
293 | return HPC_ERROR; | 293 | return HPC_ERROR; |
294 | } | 294 | } |
295 | 295 | ||
296 | wpg_data = swab32 (data); // swap data before writing | 296 | wpg_data = swab32(data); // swap data before writing |
297 | wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; | 297 | wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; |
298 | writel (wpg_data, wpg_addr); | 298 | writel(wpg_data, wpg_addr); |
299 | 299 | ||
300 | //-------------------------------------------------------------------- | 300 | //-------------------------------------------------------------------- |
301 | // WRITE - step 2 : clear the message buffer | 301 | // WRITE - step 2 : clear the message buffer |
302 | data = 0x00000000 | (unsigned long)cmd; | 302 | data = 0x00000000 | (unsigned long)cmd; |
303 | wpg_data = swab32 (data); | 303 | wpg_data = swab32(data); |
304 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; | 304 | wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; |
305 | writel (wpg_data, wpg_addr); | 305 | writel(wpg_data, wpg_addr); |
306 | 306 | ||
307 | //-------------------------------------------------------------------- | 307 | //-------------------------------------------------------------------- |
308 | // WRITE - step 3 : issue start operation,I2C master control bit 30:ON | 308 | // WRITE - step 3 : issue start operation,I2C master control bit 30:ON |
309 | // 2020 : [20] OR operation at [20] offset 0x20 | 309 | // 2020 : [20] OR operation at [20] offset 0x20 |
310 | data = WPG_I2CMCNTL_STARTOP_MASK; | 310 | data = WPG_I2CMCNTL_STARTOP_MASK; |
311 | wpg_data = swab32 (data); | 311 | wpg_data = swab32(data); |
312 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; | 312 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; |
313 | writel (wpg_data, wpg_addr); | 313 | writel(wpg_data, wpg_addr); |
314 | 314 | ||
315 | //-------------------------------------------------------------------- | 315 | //-------------------------------------------------------------------- |
316 | // WRITE - step 4 : wait until start operation bit clears | 316 | // WRITE - step 4 : wait until start operation bit clears |
@@ -318,14 +318,14 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
318 | while (i) { | 318 | while (i) { |
319 | msleep(10); | 319 | msleep(10); |
320 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; | 320 | wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; |
321 | wpg_data = readl (wpg_addr); | 321 | wpg_data = readl(wpg_addr); |
322 | data = swab32 (wpg_data); | 322 | data = swab32(wpg_data); |
323 | if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) | 323 | if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) |
324 | break; | 324 | break; |
325 | i--; | 325 | i--; |
326 | } | 326 | } |
327 | if (i == 0) { | 327 | if (i == 0) { |
328 | debug ("%s - Exit Error:WPG timeout\n", __func__); | 328 | debug("%s - Exit Error:WPG timeout\n", __func__); |
329 | rc = HPC_ERROR; | 329 | rc = HPC_ERROR; |
330 | } | 330 | } |
331 | 331 | ||
@@ -335,25 +335,25 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 | |||
335 | while (i) { | 335 | while (i) { |
336 | msleep(10); | 336 | msleep(10); |
337 | wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; | 337 | wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; |
338 | wpg_data = readl (wpg_addr); | 338 | wpg_data = readl(wpg_addr); |
339 | data = swab32 (wpg_data); | 339 | data = swab32(wpg_data); |
340 | if (HPC_I2CSTATUS_CHECK (data)) | 340 | if (HPC_I2CSTATUS_CHECK(data)) |
341 | break; | 341 | break; |
342 | i--; | 342 | i--; |
343 | } | 343 | } |
344 | if (i == 0) { | 344 | if (i == 0) { |
345 | debug ("ctrl_read - Error : I2C timeout\n"); | 345 | debug("ctrl_read - Error : I2C timeout\n"); |
346 | rc = HPC_ERROR; | 346 | rc = HPC_ERROR; |
347 | } | 347 | } |
348 | 348 | ||
349 | debug_polling ("%s Exit rc[%x]\n", __func__, rc); | 349 | debug_polling("%s Exit rc[%x]\n", __func__, rc); |
350 | return (rc); | 350 | return (rc); |
351 | } | 351 | } |
352 | 352 | ||
353 | //------------------------------------------------------------ | 353 | //------------------------------------------------------------ |
354 | // Read from ISA type HPC | 354 | // Read from ISA type HPC |
355 | //------------------------------------------------------------ | 355 | //------------------------------------------------------------ |
356 | static u8 isa_ctrl_read (struct controller *ctlr_ptr, u8 offset) | 356 | static u8 isa_ctrl_read(struct controller *ctlr_ptr, u8 offset) |
357 | { | 357 | { |
358 | u16 start_address; | 358 | u16 start_address; |
359 | u16 end_address; | 359 | u16 end_address; |
@@ -361,56 +361,56 @@ static u8 isa_ctrl_read (struct controller *ctlr_ptr, u8 offset) | |||
361 | 361 | ||
362 | start_address = ctlr_ptr->u.isa_ctlr.io_start; | 362 | start_address = ctlr_ptr->u.isa_ctlr.io_start; |
363 | end_address = ctlr_ptr->u.isa_ctlr.io_end; | 363 | end_address = ctlr_ptr->u.isa_ctlr.io_end; |
364 | data = inb (start_address + offset); | 364 | data = inb(start_address + offset); |
365 | return data; | 365 | return data; |
366 | } | 366 | } |
367 | 367 | ||
368 | //-------------------------------------------------------------- | 368 | //-------------------------------------------------------------- |
369 | // Write to ISA type HPC | 369 | // Write to ISA type HPC |
370 | //-------------------------------------------------------------- | 370 | //-------------------------------------------------------------- |
371 | static void isa_ctrl_write (struct controller *ctlr_ptr, u8 offset, u8 data) | 371 | static void isa_ctrl_write(struct controller *ctlr_ptr, u8 offset, u8 data) |
372 | { | 372 | { |
373 | u16 start_address; | 373 | u16 start_address; |
374 | u16 port_address; | 374 | u16 port_address; |
375 | 375 | ||
376 | start_address = ctlr_ptr->u.isa_ctlr.io_start; | 376 | start_address = ctlr_ptr->u.isa_ctlr.io_start; |
377 | port_address = start_address + (u16) offset; | 377 | port_address = start_address + (u16) offset; |
378 | outb (data, port_address); | 378 | outb(data, port_address); |
379 | } | 379 | } |
380 | 380 | ||
381 | static u8 pci_ctrl_read (struct controller *ctrl, u8 offset) | 381 | static u8 pci_ctrl_read(struct controller *ctrl, u8 offset) |
382 | { | 382 | { |
383 | u8 data = 0x00; | 383 | u8 data = 0x00; |
384 | debug ("inside pci_ctrl_read\n"); | 384 | debug("inside pci_ctrl_read\n"); |
385 | if (ctrl->ctrl_dev) | 385 | if (ctrl->ctrl_dev) |
386 | pci_read_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); | 386 | pci_read_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); |
387 | return data; | 387 | return data; |
388 | } | 388 | } |
389 | 389 | ||
390 | static u8 pci_ctrl_write (struct controller *ctrl, u8 offset, u8 data) | 390 | static u8 pci_ctrl_write(struct controller *ctrl, u8 offset, u8 data) |
391 | { | 391 | { |
392 | u8 rc = -ENODEV; | 392 | u8 rc = -ENODEV; |
393 | debug ("inside pci_ctrl_write\n"); | 393 | debug("inside pci_ctrl_write\n"); |
394 | if (ctrl->ctrl_dev) { | 394 | if (ctrl->ctrl_dev) { |
395 | pci_write_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); | 395 | pci_write_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); |
396 | rc = 0; | 396 | rc = 0; |
397 | } | 397 | } |
398 | return rc; | 398 | return rc; |
399 | } | 399 | } |
400 | 400 | ||
401 | static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset) | 401 | static u8 ctrl_read(struct controller *ctlr, void __iomem *base, u8 offset) |
402 | { | 402 | { |
403 | u8 rc; | 403 | u8 rc; |
404 | switch (ctlr->ctlr_type) { | 404 | switch (ctlr->ctlr_type) { |
405 | case 0: | 405 | case 0: |
406 | rc = isa_ctrl_read (ctlr, offset); | 406 | rc = isa_ctrl_read(ctlr, offset); |
407 | break; | 407 | break; |
408 | case 1: | 408 | case 1: |
409 | rc = pci_ctrl_read (ctlr, offset); | 409 | rc = pci_ctrl_read(ctlr, offset); |
410 | break; | 410 | break; |
411 | case 2: | 411 | case 2: |
412 | case 4: | 412 | case 4: |
413 | rc = i2c_ctrl_read (ctlr, base, offset); | 413 | rc = i2c_ctrl_read(ctlr, base, offset); |
414 | break; | 414 | break; |
415 | default: | 415 | default: |
416 | return -ENODEV; | 416 | return -ENODEV; |
@@ -418,7 +418,7 @@ static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset) | |||
418 | return rc; | 418 | return rc; |
419 | } | 419 | } |
420 | 420 | ||
421 | static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 data) | 421 | static u8 ctrl_write(struct controller *ctlr, void __iomem *base, u8 offset, u8 data) |
422 | { | 422 | { |
423 | u8 rc = 0; | 423 | u8 rc = 0; |
424 | switch (ctlr->ctlr_type) { | 424 | switch (ctlr->ctlr_type) { |
@@ -426,7 +426,7 @@ static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 | |||
426 | isa_ctrl_write(ctlr, offset, data); | 426 | isa_ctrl_write(ctlr, offset, data); |
427 | break; | 427 | break; |
428 | case 1: | 428 | case 1: |
429 | rc = pci_ctrl_write (ctlr, offset, data); | 429 | rc = pci_ctrl_write(ctlr, offset, data); |
430 | break; | 430 | break; |
431 | case 2: | 431 | case 2: |
432 | case 4: | 432 | case 4: |
@@ -444,7 +444,7 @@ static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 | |||
444 | * | 444 | * |
445 | * Return index, HPC_ERROR | 445 | * Return index, HPC_ERROR |
446 | *---------------------------------------------------------------------*/ | 446 | *---------------------------------------------------------------------*/ |
447 | static u8 hpc_writecmdtoindex (u8 cmd, u8 index) | 447 | static u8 hpc_writecmdtoindex(u8 cmd, u8 index) |
448 | { | 448 | { |
449 | u8 rc; | 449 | u8 rc; |
450 | 450 | ||
@@ -476,7 +476,7 @@ static u8 hpc_writecmdtoindex (u8 cmd, u8 index) | |||
476 | break; | 476 | break; |
477 | 477 | ||
478 | default: | 478 | default: |
479 | err ("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd); | 479 | err("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd); |
480 | rc = HPC_ERROR; | 480 | rc = HPC_ERROR; |
481 | } | 481 | } |
482 | 482 | ||
@@ -490,7 +490,7 @@ static u8 hpc_writecmdtoindex (u8 cmd, u8 index) | |||
490 | * | 490 | * |
491 | * Return index, HPC_ERROR | 491 | * Return index, HPC_ERROR |
492 | *---------------------------------------------------------------------*/ | 492 | *---------------------------------------------------------------------*/ |
493 | static u8 hpc_readcmdtoindex (u8 cmd, u8 index) | 493 | static u8 hpc_readcmdtoindex(u8 cmd, u8 index) |
494 | { | 494 | { |
495 | u8 rc; | 495 | u8 rc; |
496 | 496 | ||
@@ -533,78 +533,77 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index) | |||
533 | * | 533 | * |
534 | * Return 0 or error codes | 534 | * Return 0 or error codes |
535 | *---------------------------------------------------------------------*/ | 535 | *---------------------------------------------------------------------*/ |
536 | int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus) | 536 | int ibmphp_hpc_readslot(struct slot *pslot, u8 cmd, u8 *pstatus) |
537 | { | 537 | { |
538 | void __iomem *wpg_bbar = NULL; | 538 | void __iomem *wpg_bbar = NULL; |
539 | struct controller *ctlr_ptr; | 539 | struct controller *ctlr_ptr; |
540 | struct list_head *pslotlist; | ||
541 | u8 index, status; | 540 | u8 index, status; |
542 | int rc = 0; | 541 | int rc = 0; |
543 | int busindex; | 542 | int busindex; |
544 | 543 | ||
545 | debug_polling ("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus); | 544 | debug_polling("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus); |
546 | 545 | ||
547 | if ((pslot == NULL) | 546 | if ((pslot == NULL) |
548 | || ((pstatus == NULL) && (cmd != READ_ALLSTAT) && (cmd != READ_BUSSTATUS))) { | 547 | || ((pstatus == NULL) && (cmd != READ_ALLSTAT) && (cmd != READ_BUSSTATUS))) { |
549 | rc = -EINVAL; | 548 | rc = -EINVAL; |
550 | err ("%s - Error invalid pointer, rc[%d]\n", __func__, rc); | 549 | err("%s - Error invalid pointer, rc[%d]\n", __func__, rc); |
551 | return rc; | 550 | return rc; |
552 | } | 551 | } |
553 | 552 | ||
554 | if (cmd == READ_BUSSTATUS) { | 553 | if (cmd == READ_BUSSTATUS) { |
555 | busindex = ibmphp_get_bus_index (pslot->bus); | 554 | busindex = ibmphp_get_bus_index(pslot->bus); |
556 | if (busindex < 0) { | 555 | if (busindex < 0) { |
557 | rc = -EINVAL; | 556 | rc = -EINVAL; |
558 | err ("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); | 557 | err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); |
559 | return rc; | 558 | return rc; |
560 | } else | 559 | } else |
561 | index = (u8) busindex; | 560 | index = (u8) busindex; |
562 | } else | 561 | } else |
563 | index = pslot->ctlr_index; | 562 | index = pslot->ctlr_index; |
564 | 563 | ||
565 | index = hpc_readcmdtoindex (cmd, index); | 564 | index = hpc_readcmdtoindex(cmd, index); |
566 | 565 | ||
567 | if (index == HPC_ERROR) { | 566 | if (index == HPC_ERROR) { |
568 | rc = -EINVAL; | 567 | rc = -EINVAL; |
569 | err ("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc); | 568 | err("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc); |
570 | return rc; | 569 | return rc; |
571 | } | 570 | } |
572 | 571 | ||
573 | ctlr_ptr = pslot->ctrl; | 572 | ctlr_ptr = pslot->ctrl; |
574 | 573 | ||
575 | get_hpc_access (); | 574 | get_hpc_access(); |
576 | 575 | ||
577 | //-------------------------------------------------------------------- | 576 | //-------------------------------------------------------------------- |
578 | // map physical address to logical address | 577 | // map physical address to logical address |
579 | //-------------------------------------------------------------------- | 578 | //-------------------------------------------------------------------- |
580 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) | 579 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) |
581 | wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); | 580 | wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); |
582 | 581 | ||
583 | //-------------------------------------------------------------------- | 582 | //-------------------------------------------------------------------- |
584 | // check controller status before reading | 583 | // check controller status before reading |
585 | //-------------------------------------------------------------------- | 584 | //-------------------------------------------------------------------- |
586 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); | 585 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); |
587 | if (!rc) { | 586 | if (!rc) { |
588 | switch (cmd) { | 587 | switch (cmd) { |
589 | case READ_ALLSTAT: | 588 | case READ_ALLSTAT: |
590 | // update the slot structure | 589 | // update the slot structure |
591 | pslot->ctrl->status = status; | 590 | pslot->ctrl->status = status; |
592 | pslot->status = ctrl_read (ctlr_ptr, wpg_bbar, index); | 591 | pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); |
593 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, | 592 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, |
594 | &status); | 593 | &status); |
595 | if (!rc) | 594 | if (!rc) |
596 | pslot->ext_status = ctrl_read (ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX); | 595 | pslot->ext_status = ctrl_read(ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX); |
597 | 596 | ||
598 | break; | 597 | break; |
599 | 598 | ||
600 | case READ_SLOTSTATUS: | 599 | case READ_SLOTSTATUS: |
601 | // DO NOT update the slot structure | 600 | // DO NOT update the slot structure |
602 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 601 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
603 | break; | 602 | break; |
604 | 603 | ||
605 | case READ_EXTSLOTSTATUS: | 604 | case READ_EXTSLOTSTATUS: |
606 | // DO NOT update the slot structure | 605 | // DO NOT update the slot structure |
607 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 606 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
608 | break; | 607 | break; |
609 | 608 | ||
610 | case READ_CTLRSTATUS: | 609 | case READ_CTLRSTATUS: |
@@ -613,36 +612,36 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus) | |||
613 | break; | 612 | break; |
614 | 613 | ||
615 | case READ_BUSSTATUS: | 614 | case READ_BUSSTATUS: |
616 | pslot->busstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 615 | pslot->busstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
617 | break; | 616 | break; |
618 | case READ_REVLEVEL: | 617 | case READ_REVLEVEL: |
619 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 618 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
620 | break; | 619 | break; |
621 | case READ_HPCOPTIONS: | 620 | case READ_HPCOPTIONS: |
622 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 621 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
623 | break; | 622 | break; |
624 | case READ_SLOTLATCHLOWREG: | 623 | case READ_SLOTLATCHLOWREG: |
625 | // DO NOT update the slot structure | 624 | // DO NOT update the slot structure |
626 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); | 625 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index); |
627 | break; | 626 | break; |
628 | 627 | ||
629 | // Not used | 628 | // Not used |
630 | case READ_ALLSLOT: | 629 | case READ_ALLSLOT: |
631 | list_for_each (pslotlist, &ibmphp_slot_head) { | 630 | list_for_each_entry(pslot, &ibmphp_slot_head, |
632 | pslot = list_entry (pslotlist, struct slot, ibm_slot_list); | 631 | ibm_slot_list) { |
633 | index = pslot->ctlr_index; | 632 | index = pslot->ctlr_index; |
634 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, | 633 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, |
635 | wpg_bbar, &status); | 634 | wpg_bbar, &status); |
636 | if (!rc) { | 635 | if (!rc) { |
637 | pslot->status = ctrl_read (ctlr_ptr, wpg_bbar, index); | 636 | pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index); |
638 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, | 637 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, |
639 | ctlr_ptr, wpg_bbar, &status); | 638 | ctlr_ptr, wpg_bbar, &status); |
640 | if (!rc) | 639 | if (!rc) |
641 | pslot->ext_status = | 640 | pslot->ext_status = |
642 | ctrl_read (ctlr_ptr, wpg_bbar, | 641 | ctrl_read(ctlr_ptr, wpg_bbar, |
643 | index + WPG_1ST_EXTSLOT_INDEX); | 642 | index + WPG_1ST_EXTSLOT_INDEX); |
644 | } else { | 643 | } else { |
645 | err ("%s - Error ctrl_read failed\n", __func__); | 644 | err("%s - Error ctrl_read failed\n", __func__); |
646 | rc = -EINVAL; | 645 | rc = -EINVAL; |
647 | break; | 646 | break; |
648 | } | 647 | } |
@@ -659,11 +658,11 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus) | |||
659 | 658 | ||
660 | // remove physical to logical address mapping | 659 | // remove physical to logical address mapping |
661 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) | 660 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) |
662 | iounmap (wpg_bbar); | 661 | iounmap(wpg_bbar); |
663 | 662 | ||
664 | free_hpc_access (); | 663 | free_hpc_access(); |
665 | 664 | ||
666 | debug_polling ("%s - Exit rc[%d]\n", __func__, rc); | 665 | debug_polling("%s - Exit rc[%d]\n", __func__, rc); |
667 | return rc; | 666 | return rc; |
668 | } | 667 | } |
669 | 668 | ||
@@ -672,7 +671,7 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus) | |||
672 | * | 671 | * |
673 | * Action: issue a WRITE command to HPC | 672 | * Action: issue a WRITE command to HPC |
674 | *---------------------------------------------------------------------*/ | 673 | *---------------------------------------------------------------------*/ |
675 | int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | 674 | int ibmphp_hpc_writeslot(struct slot *pslot, u8 cmd) |
676 | { | 675 | { |
677 | void __iomem *wpg_bbar = NULL; | 676 | void __iomem *wpg_bbar = NULL; |
678 | struct controller *ctlr_ptr; | 677 | struct controller *ctlr_ptr; |
@@ -682,55 +681,55 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | |||
682 | int rc = 0; | 681 | int rc = 0; |
683 | int timeout; | 682 | int timeout; |
684 | 683 | ||
685 | debug_polling ("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd); | 684 | debug_polling("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd); |
686 | if (pslot == NULL) { | 685 | if (pslot == NULL) { |
687 | rc = -EINVAL; | 686 | rc = -EINVAL; |
688 | err ("%s - Error Exit rc[%d]\n", __func__, rc); | 687 | err("%s - Error Exit rc[%d]\n", __func__, rc); |
689 | return rc; | 688 | return rc; |
690 | } | 689 | } |
691 | 690 | ||
692 | if ((cmd == HPC_BUS_33CONVMODE) || (cmd == HPC_BUS_66CONVMODE) || | 691 | if ((cmd == HPC_BUS_33CONVMODE) || (cmd == HPC_BUS_66CONVMODE) || |
693 | (cmd == HPC_BUS_66PCIXMODE) || (cmd == HPC_BUS_100PCIXMODE) || | 692 | (cmd == HPC_BUS_66PCIXMODE) || (cmd == HPC_BUS_100PCIXMODE) || |
694 | (cmd == HPC_BUS_133PCIXMODE)) { | 693 | (cmd == HPC_BUS_133PCIXMODE)) { |
695 | busindex = ibmphp_get_bus_index (pslot->bus); | 694 | busindex = ibmphp_get_bus_index(pslot->bus); |
696 | if (busindex < 0) { | 695 | if (busindex < 0) { |
697 | rc = -EINVAL; | 696 | rc = -EINVAL; |
698 | err ("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); | 697 | err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); |
699 | return rc; | 698 | return rc; |
700 | } else | 699 | } else |
701 | index = (u8) busindex; | 700 | index = (u8) busindex; |
702 | } else | 701 | } else |
703 | index = pslot->ctlr_index; | 702 | index = pslot->ctlr_index; |
704 | 703 | ||
705 | index = hpc_writecmdtoindex (cmd, index); | 704 | index = hpc_writecmdtoindex(cmd, index); |
706 | 705 | ||
707 | if (index == HPC_ERROR) { | 706 | if (index == HPC_ERROR) { |
708 | rc = -EINVAL; | 707 | rc = -EINVAL; |
709 | err ("%s - Error Exit rc[%d]\n", __func__, rc); | 708 | err("%s - Error Exit rc[%d]\n", __func__, rc); |
710 | return rc; | 709 | return rc; |
711 | } | 710 | } |
712 | 711 | ||
713 | ctlr_ptr = pslot->ctrl; | 712 | ctlr_ptr = pslot->ctrl; |
714 | 713 | ||
715 | get_hpc_access (); | 714 | get_hpc_access(); |
716 | 715 | ||
717 | //-------------------------------------------------------------------- | 716 | //-------------------------------------------------------------------- |
718 | // map physical address to logical address | 717 | // map physical address to logical address |
719 | //-------------------------------------------------------------------- | 718 | //-------------------------------------------------------------------- |
720 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { | 719 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { |
721 | wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); | 720 | wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); |
722 | 721 | ||
723 | debug ("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__, | 722 | debug("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__, |
724 | ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, | 723 | ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, |
725 | ctlr_ptr->u.wpeg_ctlr.i2c_addr); | 724 | ctlr_ptr->u.wpeg_ctlr.i2c_addr); |
726 | } | 725 | } |
727 | //-------------------------------------------------------------------- | 726 | //-------------------------------------------------------------------- |
728 | // check controller status before writing | 727 | // check controller status before writing |
729 | //-------------------------------------------------------------------- | 728 | //-------------------------------------------------------------------- |
730 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); | 729 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); |
731 | if (!rc) { | 730 | if (!rc) { |
732 | 731 | ||
733 | ctrl_write (ctlr_ptr, wpg_bbar, index, cmd); | 732 | ctrl_write(ctlr_ptr, wpg_bbar, index, cmd); |
734 | 733 | ||
735 | //-------------------------------------------------------------------- | 734 | //-------------------------------------------------------------------- |
736 | // check controller is still not working on the command | 735 | // check controller is still not working on the command |
@@ -738,11 +737,11 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | |||
738 | timeout = CMD_COMPLETE_TOUT_SEC; | 737 | timeout = CMD_COMPLETE_TOUT_SEC; |
739 | done = 0; | 738 | done = 0; |
740 | while (!done) { | 739 | while (!done) { |
741 | rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, | 740 | rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, |
742 | &status); | 741 | &status); |
743 | if (!rc) { | 742 | if (!rc) { |
744 | if (NEEDTOCHECK_CMDSTATUS (cmd)) { | 743 | if (NEEDTOCHECK_CMDSTATUS(cmd)) { |
745 | if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) | 744 | if (CTLR_FINISHED(status) == HPC_CTLR_FINISHED_YES) |
746 | done = 1; | 745 | done = 1; |
747 | } else | 746 | } else |
748 | done = 1; | 747 | done = 1; |
@@ -751,7 +750,7 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | |||
751 | msleep(1000); | 750 | msleep(1000); |
752 | if (timeout < 1) { | 751 | if (timeout < 1) { |
753 | done = 1; | 752 | done = 1; |
754 | err ("%s - Error command complete timeout\n", __func__); | 753 | err("%s - Error command complete timeout\n", __func__); |
755 | rc = -EFAULT; | 754 | rc = -EFAULT; |
756 | } else | 755 | } else |
757 | timeout--; | 756 | timeout--; |
@@ -763,10 +762,10 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | |||
763 | 762 | ||
764 | // remove physical to logical address mapping | 763 | // remove physical to logical address mapping |
765 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) | 764 | if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) |
766 | iounmap (wpg_bbar); | 765 | iounmap(wpg_bbar); |
767 | free_hpc_access (); | 766 | free_hpc_access(); |
768 | 767 | ||
769 | debug_polling ("%s - Exit rc[%d]\n", __func__, rc); | 768 | debug_polling("%s - Exit rc[%d]\n", __func__, rc); |
770 | return rc; | 769 | return rc; |
771 | } | 770 | } |
772 | 771 | ||
@@ -775,7 +774,7 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) | |||
775 | * | 774 | * |
776 | * Action: make sure only one process can access HPC at one time | 775 | * Action: make sure only one process can access HPC at one time |
777 | *---------------------------------------------------------------------*/ | 776 | *---------------------------------------------------------------------*/ |
778 | static void get_hpc_access (void) | 777 | static void get_hpc_access(void) |
779 | { | 778 | { |
780 | mutex_lock(&sem_hpcaccess); | 779 | mutex_lock(&sem_hpcaccess); |
781 | } | 780 | } |
@@ -783,7 +782,7 @@ static void get_hpc_access (void) | |||
783 | /*---------------------------------------------------------------------- | 782 | /*---------------------------------------------------------------------- |
784 | * Name: free_hpc_access() | 783 | * Name: free_hpc_access() |
785 | *---------------------------------------------------------------------*/ | 784 | *---------------------------------------------------------------------*/ |
786 | void free_hpc_access (void) | 785 | void free_hpc_access(void) |
787 | { | 786 | { |
788 | mutex_unlock(&sem_hpcaccess); | 787 | mutex_unlock(&sem_hpcaccess); |
789 | } | 788 | } |
@@ -793,21 +792,21 @@ void free_hpc_access (void) | |||
793 | * | 792 | * |
794 | * Action: make sure only one process can change the data structure | 793 | * Action: make sure only one process can change the data structure |
795 | *---------------------------------------------------------------------*/ | 794 | *---------------------------------------------------------------------*/ |
796 | void ibmphp_lock_operations (void) | 795 | void ibmphp_lock_operations(void) |
797 | { | 796 | { |
798 | down (&semOperations); | 797 | down(&semOperations); |
799 | to_debug = 1; | 798 | to_debug = 1; |
800 | } | 799 | } |
801 | 800 | ||
802 | /*---------------------------------------------------------------------- | 801 | /*---------------------------------------------------------------------- |
803 | * Name: ibmphp_unlock_operations() | 802 | * Name: ibmphp_unlock_operations() |
804 | *---------------------------------------------------------------------*/ | 803 | *---------------------------------------------------------------------*/ |
805 | void ibmphp_unlock_operations (void) | 804 | void ibmphp_unlock_operations(void) |
806 | { | 805 | { |
807 | debug ("%s - Entry\n", __func__); | 806 | debug("%s - Entry\n", __func__); |
808 | up (&semOperations); | 807 | up(&semOperations); |
809 | to_debug = 0; | 808 | to_debug = 0; |
810 | debug ("%s - Exit\n", __func__); | 809 | debug("%s - Exit\n", __func__); |
811 | } | 810 | } |
812 | 811 | ||
813 | /*---------------------------------------------------------------------- | 812 | /*---------------------------------------------------------------------- |
@@ -820,7 +819,6 @@ static int poll_hpc(void *data) | |||
820 | { | 819 | { |
821 | struct slot myslot; | 820 | struct slot myslot; |
822 | struct slot *pslot = NULL; | 821 | struct slot *pslot = NULL; |
823 | struct list_head *pslotlist; | ||
824 | int rc; | 822 | int rc; |
825 | int poll_state = POLL_LATCH_REGISTER; | 823 | int poll_state = POLL_LATCH_REGISTER; |
826 | u8 oldlatchlow = 0x00; | 824 | u8 oldlatchlow = 0x00; |
@@ -828,28 +826,28 @@ static int poll_hpc(void *data) | |||
828 | int poll_count = 0; | 826 | int poll_count = 0; |
829 | u8 ctrl_count = 0x00; | 827 | u8 ctrl_count = 0x00; |
830 | 828 | ||
831 | debug ("%s - Entry\n", __func__); | 829 | debug("%s - Entry\n", __func__); |
832 | 830 | ||
833 | while (!kthread_should_stop()) { | 831 | while (!kthread_should_stop()) { |
834 | /* try to get the lock to do some kind of hardware access */ | 832 | /* try to get the lock to do some kind of hardware access */ |
835 | down (&semOperations); | 833 | down(&semOperations); |
836 | 834 | ||
837 | switch (poll_state) { | 835 | switch (poll_state) { |
838 | case POLL_LATCH_REGISTER: | 836 | case POLL_LATCH_REGISTER: |
839 | oldlatchlow = curlatchlow; | 837 | oldlatchlow = curlatchlow; |
840 | ctrl_count = 0x00; | 838 | ctrl_count = 0x00; |
841 | list_for_each (pslotlist, &ibmphp_slot_head) { | 839 | list_for_each_entry(pslot, &ibmphp_slot_head, |
840 | ibm_slot_list) { | ||
842 | if (ctrl_count >= ibmphp_get_total_controllers()) | 841 | if (ctrl_count >= ibmphp_get_total_controllers()) |
843 | break; | 842 | break; |
844 | pslot = list_entry (pslotlist, struct slot, ibm_slot_list); | ||
845 | if (pslot->ctrl->ctlr_relative_id == ctrl_count) { | 843 | if (pslot->ctrl->ctlr_relative_id == ctrl_count) { |
846 | ctrl_count++; | 844 | ctrl_count++; |
847 | if (READ_SLOT_LATCH (pslot->ctrl)) { | 845 | if (READ_SLOT_LATCH(pslot->ctrl)) { |
848 | rc = ibmphp_hpc_readslot (pslot, | 846 | rc = ibmphp_hpc_readslot(pslot, |
849 | READ_SLOTLATCHLOWREG, | 847 | READ_SLOTLATCHLOWREG, |
850 | &curlatchlow); | 848 | &curlatchlow); |
851 | if (oldlatchlow != curlatchlow) | 849 | if (oldlatchlow != curlatchlow) |
852 | process_changeinlatch (oldlatchlow, | 850 | process_changeinlatch(oldlatchlow, |
853 | curlatchlow, | 851 | curlatchlow, |
854 | pslot->ctrl); | 852 | pslot->ctrl); |
855 | } | 853 | } |
@@ -859,25 +857,25 @@ static int poll_hpc(void *data) | |||
859 | poll_state = POLL_SLEEP; | 857 | poll_state = POLL_SLEEP; |
860 | break; | 858 | break; |
861 | case POLL_SLOTS: | 859 | case POLL_SLOTS: |
862 | list_for_each (pslotlist, &ibmphp_slot_head) { | 860 | list_for_each_entry(pslot, &ibmphp_slot_head, |
863 | pslot = list_entry (pslotlist, struct slot, ibm_slot_list); | 861 | ibm_slot_list) { |
864 | // make a copy of the old status | 862 | // make a copy of the old status |
865 | memcpy ((void *) &myslot, (void *) pslot, | 863 | memcpy((void *) &myslot, (void *) pslot, |
866 | sizeof (struct slot)); | 864 | sizeof(struct slot)); |
867 | rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); | 865 | rc = ibmphp_hpc_readslot(pslot, READ_ALLSTAT, NULL); |
868 | if ((myslot.status != pslot->status) | 866 | if ((myslot.status != pslot->status) |
869 | || (myslot.ext_status != pslot->ext_status)) | 867 | || (myslot.ext_status != pslot->ext_status)) |
870 | process_changeinstatus (pslot, &myslot); | 868 | process_changeinstatus(pslot, &myslot); |
871 | } | 869 | } |
872 | ctrl_count = 0x00; | 870 | ctrl_count = 0x00; |
873 | list_for_each (pslotlist, &ibmphp_slot_head) { | 871 | list_for_each_entry(pslot, &ibmphp_slot_head, |
872 | ibm_slot_list) { | ||
874 | if (ctrl_count >= ibmphp_get_total_controllers()) | 873 | if (ctrl_count >= ibmphp_get_total_controllers()) |
875 | break; | 874 | break; |
876 | pslot = list_entry (pslotlist, struct slot, ibm_slot_list); | ||
877 | if (pslot->ctrl->ctlr_relative_id == ctrl_count) { | 875 | if (pslot->ctrl->ctlr_relative_id == ctrl_count) { |
878 | ctrl_count++; | 876 | ctrl_count++; |
879 | if (READ_SLOT_LATCH (pslot->ctrl)) | 877 | if (READ_SLOT_LATCH(pslot->ctrl)) |
880 | rc = ibmphp_hpc_readslot (pslot, | 878 | rc = ibmphp_hpc_readslot(pslot, |
881 | READ_SLOTLATCHLOWREG, | 879 | READ_SLOTLATCHLOWREG, |
882 | &curlatchlow); | 880 | &curlatchlow); |
883 | } | 881 | } |
@@ -887,13 +885,13 @@ static int poll_hpc(void *data) | |||
887 | break; | 885 | break; |
888 | case POLL_SLEEP: | 886 | case POLL_SLEEP: |
889 | /* don't sleep with a lock on the hardware */ | 887 | /* don't sleep with a lock on the hardware */ |
890 | up (&semOperations); | 888 | up(&semOperations); |
891 | msleep(POLL_INTERVAL_SEC * 1000); | 889 | msleep(POLL_INTERVAL_SEC * 1000); |
892 | 890 | ||
893 | if (kthread_should_stop()) | 891 | if (kthread_should_stop()) |
894 | goto out_sleep; | 892 | goto out_sleep; |
895 | 893 | ||
896 | down (&semOperations); | 894 | down(&semOperations); |
897 | 895 | ||
898 | if (poll_count >= POLL_LATCH_CNT) { | 896 | if (poll_count >= POLL_LATCH_CNT) { |
899 | poll_count = 0; | 897 | poll_count = 0; |
@@ -903,13 +901,13 @@ static int poll_hpc(void *data) | |||
903 | break; | 901 | break; |
904 | } | 902 | } |
905 | /* give up the hardware semaphore */ | 903 | /* give up the hardware semaphore */ |
906 | up (&semOperations); | 904 | up(&semOperations); |
907 | /* sleep for a short time just for good measure */ | 905 | /* sleep for a short time just for good measure */ |
908 | out_sleep: | 906 | out_sleep: |
909 | msleep(100); | 907 | msleep(100); |
910 | } | 908 | } |
911 | up (&sem_exit); | 909 | up(&sem_exit); |
912 | debug ("%s - Exit\n", __func__); | 910 | debug("%s - Exit\n", __func__); |
913 | return 0; | 911 | return 0; |
914 | } | 912 | } |
915 | 913 | ||
@@ -929,14 +927,14 @@ out_sleep: | |||
929 | * | 927 | * |
930 | * Notes: | 928 | * Notes: |
931 | *---------------------------------------------------------------------*/ | 929 | *---------------------------------------------------------------------*/ |
932 | static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | 930 | static int process_changeinstatus(struct slot *pslot, struct slot *poldslot) |
933 | { | 931 | { |
934 | u8 status; | 932 | u8 status; |
935 | int rc = 0; | 933 | int rc = 0; |
936 | u8 disable = 0; | 934 | u8 disable = 0; |
937 | u8 update = 0; | 935 | u8 update = 0; |
938 | 936 | ||
939 | debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); | 937 | debug("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); |
940 | 938 | ||
941 | // bit 0 - HPC_SLOT_POWER | 939 | // bit 0 - HPC_SLOT_POWER |
942 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) | 940 | if ((pslot->status & 0x01) != (poldslot->status & 0x01)) |
@@ -958,7 +956,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
958 | // bit 5 - HPC_SLOT_PWRGD | 956 | // bit 5 - HPC_SLOT_PWRGD |
959 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) | 957 | if ((pslot->status & 0x20) != (poldslot->status & 0x20)) |
960 | // OFF -> ON: ignore, ON -> OFF: disable slot | 958 | // OFF -> ON: ignore, ON -> OFF: disable slot |
961 | if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) | 959 | if ((poldslot->status & 0x20) && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status))) |
962 | disable = 1; | 960 | disable = 1; |
963 | 961 | ||
964 | // bit 6 - HPC_SLOT_BUS_SPEED | 962 | // bit 6 - HPC_SLOT_BUS_SPEED |
@@ -969,20 +967,20 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
969 | update = 1; | 967 | update = 1; |
970 | // OPEN -> CLOSE | 968 | // OPEN -> CLOSE |
971 | if (pslot->status & 0x80) { | 969 | if (pslot->status & 0x80) { |
972 | if (SLOT_PWRGD (pslot->status)) { | 970 | if (SLOT_PWRGD(pslot->status)) { |
973 | // power goes on and off after closing latch | 971 | // power goes on and off after closing latch |
974 | // check again to make sure power is still ON | 972 | // check again to make sure power is still ON |
975 | msleep(1000); | 973 | msleep(1000); |
976 | rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); | 974 | rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS, &status); |
977 | if (SLOT_PWRGD (status)) | 975 | if (SLOT_PWRGD(status)) |
978 | update = 1; | 976 | update = 1; |
979 | else // overwrite power in pslot to OFF | 977 | else // overwrite power in pslot to OFF |
980 | pslot->status &= ~HPC_SLOT_POWER; | 978 | pslot->status &= ~HPC_SLOT_POWER; |
981 | } | 979 | } |
982 | } | 980 | } |
983 | // CLOSE -> OPEN | 981 | // CLOSE -> OPEN |
984 | else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) | 982 | else if ((SLOT_PWRGD(poldslot->status) == HPC_SLOT_PWRGD_GOOD) |
985 | && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { | 983 | && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status))) { |
986 | disable = 1; | 984 | disable = 1; |
987 | } | 985 | } |
988 | // else - ignore | 986 | // else - ignore |
@@ -992,15 +990,15 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
992 | update = 1; | 990 | update = 1; |
993 | 991 | ||
994 | if (disable) { | 992 | if (disable) { |
995 | debug ("process_changeinstatus - disable slot\n"); | 993 | debug("process_changeinstatus - disable slot\n"); |
996 | pslot->flag = 0; | 994 | pslot->flag = 0; |
997 | rc = ibmphp_do_disable_slot (pslot); | 995 | rc = ibmphp_do_disable_slot(pslot); |
998 | } | 996 | } |
999 | 997 | ||
1000 | if (update || disable) | 998 | if (update || disable) |
1001 | ibmphp_update_slot_info (pslot); | 999 | ibmphp_update_slot_info(pslot); |
1002 | 1000 | ||
1003 | debug ("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); | 1001 | debug("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); |
1004 | 1002 | ||
1005 | return rc; | 1003 | return rc; |
1006 | } | 1004 | } |
@@ -1015,32 +1013,32 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) | |||
1015 | * Return 0 or error codes | 1013 | * Return 0 or error codes |
1016 | * Value: | 1014 | * Value: |
1017 | *---------------------------------------------------------------------*/ | 1015 | *---------------------------------------------------------------------*/ |
1018 | static int process_changeinlatch (u8 old, u8 new, struct controller *ctrl) | 1016 | static int process_changeinlatch(u8 old, u8 new, struct controller *ctrl) |
1019 | { | 1017 | { |
1020 | struct slot myslot, *pslot; | 1018 | struct slot myslot, *pslot; |
1021 | u8 i; | 1019 | u8 i; |
1022 | u8 mask; | 1020 | u8 mask; |
1023 | int rc = 0; | 1021 | int rc = 0; |
1024 | 1022 | ||
1025 | debug ("%s - Entry old[%x], new[%x]\n", __func__, old, new); | 1023 | debug("%s - Entry old[%x], new[%x]\n", __func__, old, new); |
1026 | // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots | 1024 | // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots |
1027 | 1025 | ||
1028 | for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) { | 1026 | for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) { |
1029 | mask = 0x01 << i; | 1027 | mask = 0x01 << i; |
1030 | if ((mask & old) != (mask & new)) { | 1028 | if ((mask & old) != (mask & new)) { |
1031 | pslot = ibmphp_get_slot_from_physical_num (i); | 1029 | pslot = ibmphp_get_slot_from_physical_num(i); |
1032 | if (pslot) { | 1030 | if (pslot) { |
1033 | memcpy ((void *) &myslot, (void *) pslot, sizeof (struct slot)); | 1031 | memcpy((void *) &myslot, (void *) pslot, sizeof(struct slot)); |
1034 | rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); | 1032 | rc = ibmphp_hpc_readslot(pslot, READ_ALLSTAT, NULL); |
1035 | debug ("%s - call process_changeinstatus for slot[%d]\n", __func__, i); | 1033 | debug("%s - call process_changeinstatus for slot[%d]\n", __func__, i); |
1036 | process_changeinstatus (pslot, &myslot); | 1034 | process_changeinstatus(pslot, &myslot); |
1037 | } else { | 1035 | } else { |
1038 | rc = -EINVAL; | 1036 | rc = -EINVAL; |
1039 | err ("%s - Error bad pointer for slot[%d]\n", __func__, i); | 1037 | err("%s - Error bad pointer for slot[%d]\n", __func__, i); |
1040 | } | 1038 | } |
1041 | } | 1039 | } |
1042 | } | 1040 | } |
1043 | debug ("%s - Exit rc[%d]\n", __func__, rc); | 1041 | debug("%s - Exit rc[%d]\n", __func__, rc); |
1044 | return rc; | 1042 | return rc; |
1045 | } | 1043 | } |
1046 | 1044 | ||
@@ -1049,13 +1047,13 @@ static int process_changeinlatch (u8 old, u8 new, struct controller *ctrl) | |||
1049 | * | 1047 | * |
1050 | * Action: start polling thread | 1048 | * Action: start polling thread |
1051 | *---------------------------------------------------------------------*/ | 1049 | *---------------------------------------------------------------------*/ |
1052 | int __init ibmphp_hpc_start_poll_thread (void) | 1050 | int __init ibmphp_hpc_start_poll_thread(void) |
1053 | { | 1051 | { |
1054 | debug ("%s - Entry\n", __func__); | 1052 | debug("%s - Entry\n", __func__); |
1055 | 1053 | ||
1056 | ibmphp_poll_thread = kthread_run(poll_hpc, NULL, "hpc_poll"); | 1054 | ibmphp_poll_thread = kthread_run(poll_hpc, NULL, "hpc_poll"); |
1057 | if (IS_ERR(ibmphp_poll_thread)) { | 1055 | if (IS_ERR(ibmphp_poll_thread)) { |
1058 | err ("%s - Error, thread not started\n", __func__); | 1056 | err("%s - Error, thread not started\n", __func__); |
1059 | return PTR_ERR(ibmphp_poll_thread); | 1057 | return PTR_ERR(ibmphp_poll_thread); |
1060 | } | 1058 | } |
1061 | return 0; | 1059 | return 0; |
@@ -1066,30 +1064,30 @@ int __init ibmphp_hpc_start_poll_thread (void) | |||
1066 | * | 1064 | * |
1067 | * Action: stop polling thread and cleanup | 1065 | * Action: stop polling thread and cleanup |
1068 | *---------------------------------------------------------------------*/ | 1066 | *---------------------------------------------------------------------*/ |
1069 | void __exit ibmphp_hpc_stop_poll_thread (void) | 1067 | void __exit ibmphp_hpc_stop_poll_thread(void) |
1070 | { | 1068 | { |
1071 | debug ("%s - Entry\n", __func__); | 1069 | debug("%s - Entry\n", __func__); |
1072 | 1070 | ||
1073 | kthread_stop(ibmphp_poll_thread); | 1071 | kthread_stop(ibmphp_poll_thread); |
1074 | debug ("before locking operations \n"); | 1072 | debug("before locking operations\n"); |
1075 | ibmphp_lock_operations (); | 1073 | ibmphp_lock_operations(); |
1076 | debug ("after locking operations \n"); | 1074 | debug("after locking operations\n"); |
1077 | 1075 | ||
1078 | // wait for poll thread to exit | 1076 | // wait for poll thread to exit |
1079 | debug ("before sem_exit down \n"); | 1077 | debug("before sem_exit down\n"); |
1080 | down (&sem_exit); | 1078 | down(&sem_exit); |
1081 | debug ("after sem_exit down \n"); | 1079 | debug("after sem_exit down\n"); |
1082 | 1080 | ||
1083 | // cleanup | 1081 | // cleanup |
1084 | debug ("before free_hpc_access \n"); | 1082 | debug("before free_hpc_access\n"); |
1085 | free_hpc_access (); | 1083 | free_hpc_access(); |
1086 | debug ("after free_hpc_access \n"); | 1084 | debug("after free_hpc_access\n"); |
1087 | ibmphp_unlock_operations (); | 1085 | ibmphp_unlock_operations(); |
1088 | debug ("after unlock operations \n"); | 1086 | debug("after unlock operations\n"); |
1089 | up (&sem_exit); | 1087 | up(&sem_exit); |
1090 | debug ("after sem exit up\n"); | 1088 | debug("after sem exit up\n"); |
1091 | 1089 | ||
1092 | debug ("%s - Exit\n", __func__); | 1090 | debug("%s - Exit\n", __func__); |
1093 | } | 1091 | } |
1094 | 1092 | ||
1095 | /*---------------------------------------------------------------------- | 1093 | /*---------------------------------------------------------------------- |
@@ -1100,32 +1098,32 @@ void __exit ibmphp_hpc_stop_poll_thread (void) | |||
1100 | * Return 0, HPC_ERROR | 1098 | * Return 0, HPC_ERROR |
1101 | * Value: | 1099 | * Value: |
1102 | *---------------------------------------------------------------------*/ | 1100 | *---------------------------------------------------------------------*/ |
1103 | static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar, | 1101 | static int hpc_wait_ctlr_notworking(int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar, |
1104 | u8 *pstatus) | 1102 | u8 *pstatus) |
1105 | { | 1103 | { |
1106 | int rc = 0; | 1104 | int rc = 0; |
1107 | u8 done = 0; | 1105 | u8 done = 0; |
1108 | 1106 | ||
1109 | debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); | 1107 | debug_polling("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); |
1110 | 1108 | ||
1111 | while (!done) { | 1109 | while (!done) { |
1112 | *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); | 1110 | *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); |
1113 | if (*pstatus == HPC_ERROR) { | 1111 | if (*pstatus == HPC_ERROR) { |
1114 | rc = HPC_ERROR; | 1112 | rc = HPC_ERROR; |
1115 | done = 1; | 1113 | done = 1; |
1116 | } | 1114 | } |
1117 | if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) | 1115 | if (CTLR_WORKING(*pstatus) == HPC_CTLR_WORKING_NO) |
1118 | done = 1; | 1116 | done = 1; |
1119 | if (!done) { | 1117 | if (!done) { |
1120 | msleep(1000); | 1118 | msleep(1000); |
1121 | if (timeout < 1) { | 1119 | if (timeout < 1) { |
1122 | done = 1; | 1120 | done = 1; |
1123 | err ("HPCreadslot - Error ctlr timeout\n"); | 1121 | err("HPCreadslot - Error ctlr timeout\n"); |
1124 | rc = HPC_ERROR; | 1122 | rc = HPC_ERROR; |
1125 | } else | 1123 | } else |
1126 | timeout--; | 1124 | timeout--; |
1127 | } | 1125 | } |
1128 | } | 1126 | } |
1129 | debug_polling ("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus); | 1127 | debug_polling("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus); |
1130 | return rc; | 1128 | return rc; |
1131 | } | 1129 | } |
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 814cea22a9fa..dc1876feb06f 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -37,8 +37,8 @@ | |||
37 | static int configure_device(struct pci_func *); | 37 | static int configure_device(struct pci_func *); |
38 | static int configure_bridge(struct pci_func **, u8); | 38 | static int configure_bridge(struct pci_func **, u8); |
39 | static struct res_needed *scan_behind_bridge(struct pci_func *, u8); | 39 | static struct res_needed *scan_behind_bridge(struct pci_func *, u8); |
40 | static int add_new_bus (struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8); | 40 | static int add_new_bus(struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8); |
41 | static u8 find_sec_number (u8 primary_busno, u8 slotno); | 41 | static u8 find_sec_number(u8 primary_busno, u8 slotno); |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * NOTE..... If BIOS doesn't provide default routing, we assign: | 44 | * NOTE..... If BIOS doesn't provide default routing, we assign: |
@@ -47,7 +47,7 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno); | |||
47 | * We also assign the same irq numbers for multi function devices. | 47 | * We also assign the same irq numbers for multi function devices. |
48 | * These are PIC mode, so shouldn't matter n.e.ways (hopefully) | 48 | * These are PIC mode, so shouldn't matter n.e.ways (hopefully) |
49 | */ | 49 | */ |
50 | static void assign_alt_irq (struct pci_func *cur_func, u8 class_code) | 50 | static void assign_alt_irq(struct pci_func *cur_func, u8 class_code) |
51 | { | 51 | { |
52 | int j; | 52 | int j; |
53 | for (j = 0; j < 4; j++) { | 53 | for (j = 0; j < 4; j++) { |
@@ -78,7 +78,7 @@ static void assign_alt_irq (struct pci_func *cur_func, u8 class_code) | |||
78 | * if there is an error, will need to go through all previous functions and | 78 | * if there is an error, will need to go through all previous functions and |
79 | * unconfigure....or can add some code into unconfigure_card.... | 79 | * unconfigure....or can add some code into unconfigure_card.... |
80 | */ | 80 | */ |
81 | int ibmphp_configure_card (struct pci_func *func, u8 slotno) | 81 | int ibmphp_configure_card(struct pci_func *func, u8 slotno) |
82 | { | 82 | { |
83 | u16 vendor_id; | 83 | u16 vendor_id; |
84 | u32 class; | 84 | u32 class; |
@@ -92,7 +92,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
92 | u8 flag; | 92 | u8 flag; |
93 | u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */ | 93 | u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */ |
94 | 94 | ||
95 | debug ("inside configure_card, func->busno = %x\n", func->busno); | 95 | debug("inside configure_card, func->busno = %x\n", func->busno); |
96 | 96 | ||
97 | device = func->device; | 97 | device = func->device; |
98 | cur_func = func; | 98 | cur_func = func; |
@@ -109,15 +109,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
109 | 109 | ||
110 | cur_func->function = function; | 110 | cur_func->function = function; |
111 | 111 | ||
112 | debug ("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n", | 112 | debug("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n", |
113 | cur_func->busno, cur_func->device, cur_func->function); | 113 | cur_func->busno, cur_func->device, cur_func->function); |
114 | 114 | ||
115 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 115 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
116 | 116 | ||
117 | debug ("vendor_id is %x\n", vendor_id); | 117 | debug("vendor_id is %x\n", vendor_id); |
118 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 118 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
119 | /* found correct device!!! */ | 119 | /* found correct device!!! */ |
120 | debug ("found valid device, vendor_id = %x\n", vendor_id); | 120 | debug("found valid device, vendor_id = %x\n", vendor_id); |
121 | 121 | ||
122 | ++valid_device; | 122 | ++valid_device; |
123 | 123 | ||
@@ -126,29 +126,29 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
126 | * |_=> 0 = single function device, 1 = multi-function device | 126 | * |_=> 0 = single function device, 1 = multi-function device |
127 | */ | 127 | */ |
128 | 128 | ||
129 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 129 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
130 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 130 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
131 | 131 | ||
132 | class_code = class >> 24; | 132 | class_code = class >> 24; |
133 | debug ("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code); | 133 | debug("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code); |
134 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 134 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
135 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 135 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
136 | err ("The device %x is VGA compatible and as is not supported for hot plugging. " | 136 | err("The device %x is VGA compatible and as is not supported for hot plugging. " |
137 | "Please choose another device.\n", cur_func->device); | 137 | "Please choose another device.\n", cur_func->device); |
138 | return -ENODEV; | 138 | return -ENODEV; |
139 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 139 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
140 | err ("The device %x is not supported for hot plugging. Please choose another device.\n", | 140 | err("The device %x is not supported for hot plugging. Please choose another device.\n", |
141 | cur_func->device); | 141 | cur_func->device); |
142 | return -ENODEV; | 142 | return -ENODEV; |
143 | } | 143 | } |
144 | switch (hdr_type) { | 144 | switch (hdr_type) { |
145 | case PCI_HEADER_TYPE_NORMAL: | 145 | case PCI_HEADER_TYPE_NORMAL: |
146 | debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); | 146 | debug("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); |
147 | assign_alt_irq (cur_func, class_code); | 147 | assign_alt_irq(cur_func, class_code); |
148 | rc = configure_device(cur_func); | 148 | rc = configure_device(cur_func); |
149 | if (rc < 0) { | 149 | if (rc < 0) { |
150 | /* We need to do this in case some other BARs were properly inserted */ | 150 | /* We need to do this in case some other BARs were properly inserted */ |
151 | err ("was not able to configure devfunc %x on bus %x.\n", | 151 | err("was not able to configure devfunc %x on bus %x.\n", |
152 | cur_func->device, cur_func->busno); | 152 | cur_func->device, cur_func->busno); |
153 | cleanup_count = 6; | 153 | cleanup_count = 6; |
154 | goto error; | 154 | goto error; |
@@ -157,18 +157,18 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
157 | function = 0x8; | 157 | function = 0x8; |
158 | break; | 158 | break; |
159 | case PCI_HEADER_TYPE_MULTIDEVICE: | 159 | case PCI_HEADER_TYPE_MULTIDEVICE: |
160 | assign_alt_irq (cur_func, class_code); | 160 | assign_alt_irq(cur_func, class_code); |
161 | rc = configure_device(cur_func); | 161 | rc = configure_device(cur_func); |
162 | if (rc < 0) { | 162 | if (rc < 0) { |
163 | /* We need to do this in case some other BARs were properly inserted */ | 163 | /* We need to do this in case some other BARs were properly inserted */ |
164 | err ("was not able to configure devfunc %x on bus %x...bailing out\n", | 164 | err("was not able to configure devfunc %x on bus %x...bailing out\n", |
165 | cur_func->device, cur_func->busno); | 165 | cur_func->device, cur_func->busno); |
166 | cleanup_count = 6; | 166 | cleanup_count = 6; |
167 | goto error; | 167 | goto error; |
168 | } | 168 | } |
169 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 169 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
170 | if (!newfunc) { | 170 | if (!newfunc) { |
171 | err ("out of system memory\n"); | 171 | err("out of system memory\n"); |
172 | return -ENOMEM; | 172 | return -ENOMEM; |
173 | } | 173 | } |
174 | newfunc->busno = cur_func->busno; | 174 | newfunc->busno = cur_func->busno; |
@@ -181,32 +181,32 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
181 | case PCI_HEADER_TYPE_MULTIBRIDGE: | 181 | case PCI_HEADER_TYPE_MULTIBRIDGE: |
182 | class >>= 8; | 182 | class >>= 8; |
183 | if (class != PCI_CLASS_BRIDGE_PCI) { | 183 | if (class != PCI_CLASS_BRIDGE_PCI) { |
184 | err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", | 184 | err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", |
185 | cur_func->device); | 185 | cur_func->device); |
186 | return -ENODEV; | 186 | return -ENODEV; |
187 | } | 187 | } |
188 | assign_alt_irq (cur_func, class_code); | 188 | assign_alt_irq(cur_func, class_code); |
189 | rc = configure_bridge (&cur_func, slotno); | 189 | rc = configure_bridge(&cur_func, slotno); |
190 | if (rc == -ENODEV) { | 190 | if (rc == -ENODEV) { |
191 | err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); | 191 | err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); |
192 | err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); | 192 | err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); |
193 | return rc; | 193 | return rc; |
194 | } | 194 | } |
195 | if (rc) { | 195 | if (rc) { |
196 | /* We need to do this in case some other BARs were properly inserted */ | 196 | /* We need to do this in case some other BARs were properly inserted */ |
197 | err ("was not able to hot-add PPB properly.\n"); | 197 | err("was not able to hot-add PPB properly.\n"); |
198 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ | 198 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ |
199 | cleanup_count = 2; | 199 | cleanup_count = 2; |
200 | goto error; | 200 | goto error; |
201 | } | 201 | } |
202 | 202 | ||
203 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 203 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
204 | flag = 0; | 204 | flag = 0; |
205 | for (i = 0; i < 32; i++) { | 205 | for (i = 0; i < 32; i++) { |
206 | if (func->devices[i]) { | 206 | if (func->devices[i]) { |
207 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 207 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
208 | if (!newfunc) { | 208 | if (!newfunc) { |
209 | err ("out of system memory\n"); | 209 | err("out of system memory\n"); |
210 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | } | 211 | } |
212 | newfunc->busno = sec_number; | 212 | newfunc->busno = sec_number; |
@@ -220,7 +220,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
220 | } else | 220 | } else |
221 | cur_func->next = newfunc; | 221 | cur_func->next = newfunc; |
222 | 222 | ||
223 | rc = ibmphp_configure_card (newfunc, slotno); | 223 | rc = ibmphp_configure_card(newfunc, slotno); |
224 | /* This could only happen if kmalloc failed */ | 224 | /* This could only happen if kmalloc failed */ |
225 | if (rc) { | 225 | if (rc) { |
226 | /* We need to do this in case bridge itself got configured properly, but devices behind it failed */ | 226 | /* We need to do this in case bridge itself got configured properly, but devices behind it failed */ |
@@ -234,53 +234,53 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
234 | 234 | ||
235 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 235 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
236 | if (!newfunc) { | 236 | if (!newfunc) { |
237 | err ("out of system memory\n"); | 237 | err("out of system memory\n"); |
238 | return -ENOMEM; | 238 | return -ENOMEM; |
239 | } | 239 | } |
240 | newfunc->busno = cur_func->busno; | 240 | newfunc->busno = cur_func->busno; |
241 | newfunc->device = device; | 241 | newfunc->device = device; |
242 | for (j = 0; j < 4; j++) | 242 | for (j = 0; j < 4; j++) |
243 | newfunc->irq[j] = cur_func->irq[j]; | 243 | newfunc->irq[j] = cur_func->irq[j]; |
244 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; | 244 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next); |
245 | prev_func->next = newfunc; | 245 | prev_func->next = newfunc; |
246 | cur_func = newfunc; | 246 | cur_func = newfunc; |
247 | break; | 247 | break; |
248 | case PCI_HEADER_TYPE_BRIDGE: | 248 | case PCI_HEADER_TYPE_BRIDGE: |
249 | class >>= 8; | 249 | class >>= 8; |
250 | debug ("class now is %x\n", class); | 250 | debug("class now is %x\n", class); |
251 | if (class != PCI_CLASS_BRIDGE_PCI) { | 251 | if (class != PCI_CLASS_BRIDGE_PCI) { |
252 | err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", | 252 | err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", |
253 | cur_func->device); | 253 | cur_func->device); |
254 | return -ENODEV; | 254 | return -ENODEV; |
255 | } | 255 | } |
256 | 256 | ||
257 | assign_alt_irq (cur_func, class_code); | 257 | assign_alt_irq(cur_func, class_code); |
258 | 258 | ||
259 | debug ("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno); | 259 | debug("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno); |
260 | rc = configure_bridge (&cur_func, slotno); | 260 | rc = configure_bridge(&cur_func, slotno); |
261 | if (rc == -ENODEV) { | 261 | if (rc == -ENODEV) { |
262 | err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); | 262 | err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); |
263 | err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); | 263 | err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); |
264 | return rc; | 264 | return rc; |
265 | } | 265 | } |
266 | if (rc) { | 266 | if (rc) { |
267 | /* We need to do this in case some other BARs were properly inserted */ | 267 | /* We need to do this in case some other BARs were properly inserted */ |
268 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ | 268 | func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ |
269 | err ("was not able to hot-add PPB properly.\n"); | 269 | err("was not able to hot-add PPB properly.\n"); |
270 | cleanup_count = 2; | 270 | cleanup_count = 2; |
271 | goto error; | 271 | goto error; |
272 | } | 272 | } |
273 | debug ("cur_func->busno = %x, device = %x, function = %x\n", | 273 | debug("cur_func->busno = %x, device = %x, function = %x\n", |
274 | cur_func->busno, device, function); | 274 | cur_func->busno, device, function); |
275 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 275 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
276 | debug ("after configuring bridge..., sec_number = %x\n", sec_number); | 276 | debug("after configuring bridge..., sec_number = %x\n", sec_number); |
277 | flag = 0; | 277 | flag = 0; |
278 | for (i = 0; i < 32; i++) { | 278 | for (i = 0; i < 32; i++) { |
279 | if (func->devices[i]) { | 279 | if (func->devices[i]) { |
280 | debug ("inside for loop, device is %x\n", i); | 280 | debug("inside for loop, device is %x\n", i); |
281 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 281 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
282 | if (!newfunc) { | 282 | if (!newfunc) { |
283 | err (" out of system memory\n"); | 283 | err(" out of system memory\n"); |
284 | return -ENOMEM; | 284 | return -ENOMEM; |
285 | } | 285 | } |
286 | newfunc->busno = sec_number; | 286 | newfunc->busno = sec_number; |
@@ -289,12 +289,12 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
289 | newfunc->irq[j] = cur_func->irq[j]; | 289 | newfunc->irq[j] = cur_func->irq[j]; |
290 | 290 | ||
291 | if (flag) { | 291 | if (flag) { |
292 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; | 292 | for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next); |
293 | prev_func->next = newfunc; | 293 | prev_func->next = newfunc; |
294 | } else | 294 | } else |
295 | cur_func->next = newfunc; | 295 | cur_func->next = newfunc; |
296 | 296 | ||
297 | rc = ibmphp_configure_card (newfunc, slotno); | 297 | rc = ibmphp_configure_card(newfunc, slotno); |
298 | 298 | ||
299 | /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */ | 299 | /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */ |
300 | if (rc) { | 300 | if (rc) { |
@@ -310,7 +310,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
310 | function = 0x8; | 310 | function = 0x8; |
311 | break; | 311 | break; |
312 | default: | 312 | default: |
313 | err ("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type); | 313 | err("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type); |
314 | return -ENXIO; | 314 | return -ENXIO; |
315 | break; | 315 | break; |
316 | } /* end of switch */ | 316 | } /* end of switch */ |
@@ -318,7 +318,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
318 | } /* end of for */ | 318 | } /* end of for */ |
319 | 319 | ||
320 | if (!valid_device) { | 320 | if (!valid_device) { |
321 | err ("Cannot find any valid devices on the card. Or unable to read from card.\n"); | 321 | err("Cannot find any valid devices on the card. Or unable to read from card.\n"); |
322 | return -ENODEV; | 322 | return -ENODEV; |
323 | } | 323 | } |
324 | 324 | ||
@@ -327,13 +327,13 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) | |||
327 | error: | 327 | error: |
328 | for (i = 0; i < cleanup_count; i++) { | 328 | for (i = 0; i < cleanup_count; i++) { |
329 | if (cur_func->io[i]) { | 329 | if (cur_func->io[i]) { |
330 | ibmphp_remove_resource (cur_func->io[i]); | 330 | ibmphp_remove_resource(cur_func->io[i]); |
331 | cur_func->io[i] = NULL; | 331 | cur_func->io[i] = NULL; |
332 | } else if (cur_func->pfmem[i]) { | 332 | } else if (cur_func->pfmem[i]) { |
333 | ibmphp_remove_resource (cur_func->pfmem[i]); | 333 | ibmphp_remove_resource(cur_func->pfmem[i]); |
334 | cur_func->pfmem[i] = NULL; | 334 | cur_func->pfmem[i] = NULL; |
335 | } else if (cur_func->mem[i]) { | 335 | } else if (cur_func->mem[i]) { |
336 | ibmphp_remove_resource (cur_func->mem[i]); | 336 | ibmphp_remove_resource(cur_func->mem[i]); |
337 | cur_func->mem[i] = NULL; | 337 | cur_func->mem[i] = NULL; |
338 | } | 338 | } |
339 | } | 339 | } |
@@ -345,7 +345,7 @@ error: | |||
345 | * Input: pointer to the pci_func | 345 | * Input: pointer to the pci_func |
346 | * Output: configured PCI, 0, or error | 346 | * Output: configured PCI, 0, or error |
347 | */ | 347 | */ |
348 | static int configure_device (struct pci_func *func) | 348 | static int configure_device(struct pci_func *func) |
349 | { | 349 | { |
350 | u32 bar[6]; | 350 | u32 bar[6]; |
351 | u32 address[] = { | 351 | u32 address[] = { |
@@ -366,7 +366,7 @@ static int configure_device (struct pci_func *func) | |||
366 | struct resource_node *pfmem[6]; | 366 | struct resource_node *pfmem[6]; |
367 | unsigned int devfn; | 367 | unsigned int devfn; |
368 | 368 | ||
369 | debug ("%s - inside\n", __func__); | 369 | debug("%s - inside\n", __func__); |
370 | 370 | ||
371 | devfn = PCI_DEVFN(func->device, func->function); | 371 | devfn = PCI_DEVFN(func->device, func->function); |
372 | ibmphp_pci_bus->number = func->busno; | 372 | ibmphp_pci_bus->number = func->busno; |
@@ -386,27 +386,27 @@ static int configure_device (struct pci_func *func) | |||
386 | pcibios_write_config_dword(cur_func->busno, cur_func->device, | 386 | pcibios_write_config_dword(cur_func->busno, cur_func->device, |
387 | PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); | 387 | PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); |
388 | */ | 388 | */ |
389 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 389 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
390 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 390 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
391 | 391 | ||
392 | if (!bar[count]) /* This BAR is not implemented */ | 392 | if (!bar[count]) /* This BAR is not implemented */ |
393 | continue; | 393 | continue; |
394 | 394 | ||
395 | debug ("Device %x BAR %d wants %x\n", func->device, count, bar[count]); | 395 | debug("Device %x BAR %d wants %x\n", func->device, count, bar[count]); |
396 | 396 | ||
397 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 397 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
398 | /* This is IO */ | 398 | /* This is IO */ |
399 | debug ("inside IO SPACE\n"); | 399 | debug("inside IO SPACE\n"); |
400 | 400 | ||
401 | len[count] = bar[count] & 0xFFFFFFFC; | 401 | len[count] = bar[count] & 0xFFFFFFFC; |
402 | len[count] = ~len[count] + 1; | 402 | len[count] = ~len[count] + 1; |
403 | 403 | ||
404 | debug ("len[count] in IO %x, count %d\n", len[count], count); | 404 | debug("len[count] in IO %x, count %d\n", len[count], count); |
405 | 405 | ||
406 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 406 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
407 | 407 | ||
408 | if (!io[count]) { | 408 | if (!io[count]) { |
409 | err ("out of system memory\n"); | 409 | err("out of system memory\n"); |
410 | return -ENOMEM; | 410 | return -ENOMEM; |
411 | } | 411 | } |
412 | io[count]->type = IO; | 412 | io[count]->type = IO; |
@@ -414,36 +414,36 @@ static int configure_device (struct pci_func *func) | |||
414 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); | 414 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); |
415 | io[count]->len = len[count]; | 415 | io[count]->len = len[count]; |
416 | if (ibmphp_check_resource(io[count], 0) == 0) { | 416 | if (ibmphp_check_resource(io[count], 0) == 0) { |
417 | ibmphp_add_resource (io[count]); | 417 | ibmphp_add_resource(io[count]); |
418 | func->io[count] = io[count]; | 418 | func->io[count] = io[count]; |
419 | } else { | 419 | } else { |
420 | err ("cannot allocate requested io for bus %x device %x function %x len %x\n", | 420 | err("cannot allocate requested io for bus %x device %x function %x len %x\n", |
421 | func->busno, func->device, func->function, len[count]); | 421 | func->busno, func->device, func->function, len[count]); |
422 | kfree (io[count]); | 422 | kfree(io[count]); |
423 | return -EIO; | 423 | return -EIO; |
424 | } | 424 | } |
425 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); | 425 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start); |
426 | 426 | ||
427 | /* _______________This is for debugging purposes only_____________________ */ | 427 | /* _______________This is for debugging purposes only_____________________ */ |
428 | debug ("b4 writing, the IO address is %x\n", func->io[count]->start); | 428 | debug("b4 writing, the IO address is %x\n", func->io[count]->start); |
429 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 429 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
430 | debug ("after writing.... the start address is %x\n", bar[count]); | 430 | debug("after writing.... the start address is %x\n", bar[count]); |
431 | /* _________________________________________________________________________*/ | 431 | /* _________________________________________________________________________*/ |
432 | 432 | ||
433 | } else { | 433 | } else { |
434 | /* This is Memory */ | 434 | /* This is Memory */ |
435 | if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 435 | if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
436 | /* pfmem */ | 436 | /* pfmem */ |
437 | debug ("PFMEM SPACE\n"); | 437 | debug("PFMEM SPACE\n"); |
438 | 438 | ||
439 | len[count] = bar[count] & 0xFFFFFFF0; | 439 | len[count] = bar[count] & 0xFFFFFFF0; |
440 | len[count] = ~len[count] + 1; | 440 | len[count] = ~len[count] + 1; |
441 | 441 | ||
442 | debug ("len[count] in PFMEM %x, count %d\n", len[count], count); | 442 | debug("len[count] in PFMEM %x, count %d\n", len[count], count); |
443 | 443 | ||
444 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 444 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
445 | if (!pfmem[count]) { | 445 | if (!pfmem[count]) { |
446 | err ("out of system memory\n"); | 446 | err("out of system memory\n"); |
447 | return -ENOMEM; | 447 | return -ENOMEM; |
448 | } | 448 | } |
449 | pfmem[count]->type = PFMEM; | 449 | pfmem[count]->type = PFMEM; |
@@ -452,64 +452,64 @@ static int configure_device (struct pci_func *func) | |||
452 | func->function); | 452 | func->function); |
453 | pfmem[count]->len = len[count]; | 453 | pfmem[count]->len = len[count]; |
454 | pfmem[count]->fromMem = 0; | 454 | pfmem[count]->fromMem = 0; |
455 | if (ibmphp_check_resource (pfmem[count], 0) == 0) { | 455 | if (ibmphp_check_resource(pfmem[count], 0) == 0) { |
456 | ibmphp_add_resource (pfmem[count]); | 456 | ibmphp_add_resource(pfmem[count]); |
457 | func->pfmem[count] = pfmem[count]; | 457 | func->pfmem[count] = pfmem[count]; |
458 | } else { | 458 | } else { |
459 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 459 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
460 | if (!mem_tmp) { | 460 | if (!mem_tmp) { |
461 | err ("out of system memory\n"); | 461 | err("out of system memory\n"); |
462 | kfree (pfmem[count]); | 462 | kfree(pfmem[count]); |
463 | return -ENOMEM; | 463 | return -ENOMEM; |
464 | } | 464 | } |
465 | mem_tmp->type = MEM; | 465 | mem_tmp->type = MEM; |
466 | mem_tmp->busno = pfmem[count]->busno; | 466 | mem_tmp->busno = pfmem[count]->busno; |
467 | mem_tmp->devfunc = pfmem[count]->devfunc; | 467 | mem_tmp->devfunc = pfmem[count]->devfunc; |
468 | mem_tmp->len = pfmem[count]->len; | 468 | mem_tmp->len = pfmem[count]->len; |
469 | debug ("there's no pfmem... going into mem.\n"); | 469 | debug("there's no pfmem... going into mem.\n"); |
470 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 470 | if (ibmphp_check_resource(mem_tmp, 0) == 0) { |
471 | ibmphp_add_resource (mem_tmp); | 471 | ibmphp_add_resource(mem_tmp); |
472 | pfmem[count]->fromMem = 1; | 472 | pfmem[count]->fromMem = 1; |
473 | pfmem[count]->rangeno = mem_tmp->rangeno; | 473 | pfmem[count]->rangeno = mem_tmp->rangeno; |
474 | pfmem[count]->start = mem_tmp->start; | 474 | pfmem[count]->start = mem_tmp->start; |
475 | pfmem[count]->end = mem_tmp->end; | 475 | pfmem[count]->end = mem_tmp->end; |
476 | ibmphp_add_pfmem_from_mem (pfmem[count]); | 476 | ibmphp_add_pfmem_from_mem(pfmem[count]); |
477 | func->pfmem[count] = pfmem[count]; | 477 | func->pfmem[count] = pfmem[count]; |
478 | } else { | 478 | } else { |
479 | err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", | 479 | err("cannot allocate requested pfmem for bus %x, device %x, len %x\n", |
480 | func->busno, func->device, len[count]); | 480 | func->busno, func->device, len[count]); |
481 | kfree (mem_tmp); | 481 | kfree(mem_tmp); |
482 | kfree (pfmem[count]); | 482 | kfree(pfmem[count]); |
483 | return -EIO; | 483 | return -EIO; |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); | 487 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); |
488 | 488 | ||
489 | /*_______________This is for debugging purposes only______________________________*/ | 489 | /*_______________This is for debugging purposes only______________________________*/ |
490 | debug ("b4 writing, start address is %x\n", func->pfmem[count]->start); | 490 | debug("b4 writing, start address is %x\n", func->pfmem[count]->start); |
491 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 491 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
492 | debug ("after writing, start address is %x\n", bar[count]); | 492 | debug("after writing, start address is %x\n", bar[count]); |
493 | /*_________________________________________________________________________________*/ | 493 | /*_________________________________________________________________________________*/ |
494 | 494 | ||
495 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ | 495 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ |
496 | debug ("inside the mem 64 case, count %d\n", count); | 496 | debug("inside the mem 64 case, count %d\n", count); |
497 | count += 1; | 497 | count += 1; |
498 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 498 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
499 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 499 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
500 | } | 500 | } |
501 | } else { | 501 | } else { |
502 | /* regular memory */ | 502 | /* regular memory */ |
503 | debug ("REGULAR MEM SPACE\n"); | 503 | debug("REGULAR MEM SPACE\n"); |
504 | 504 | ||
505 | len[count] = bar[count] & 0xFFFFFFF0; | 505 | len[count] = bar[count] & 0xFFFFFFF0; |
506 | len[count] = ~len[count] + 1; | 506 | len[count] = ~len[count] + 1; |
507 | 507 | ||
508 | debug ("len[count] in Mem %x, count %d\n", len[count], count); | 508 | debug("len[count] in Mem %x, count %d\n", len[count], count); |
509 | 509 | ||
510 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 510 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
511 | if (!mem[count]) { | 511 | if (!mem[count]) { |
512 | err ("out of system memory\n"); | 512 | err("out of system memory\n"); |
513 | return -ENOMEM; | 513 | return -ENOMEM; |
514 | } | 514 | } |
515 | mem[count]->type = MEM; | 515 | mem[count]->type = MEM; |
@@ -517,43 +517,43 @@ static int configure_device (struct pci_func *func) | |||
517 | mem[count]->devfunc = PCI_DEVFN(func->device, | 517 | mem[count]->devfunc = PCI_DEVFN(func->device, |
518 | func->function); | 518 | func->function); |
519 | mem[count]->len = len[count]; | 519 | mem[count]->len = len[count]; |
520 | if (ibmphp_check_resource (mem[count], 0) == 0) { | 520 | if (ibmphp_check_resource(mem[count], 0) == 0) { |
521 | ibmphp_add_resource (mem[count]); | 521 | ibmphp_add_resource(mem[count]); |
522 | func->mem[count] = mem[count]; | 522 | func->mem[count] = mem[count]; |
523 | } else { | 523 | } else { |
524 | err ("cannot allocate requested mem for bus %x, device %x, len %x\n", | 524 | err("cannot allocate requested mem for bus %x, device %x, len %x\n", |
525 | func->busno, func->device, len[count]); | 525 | func->busno, func->device, len[count]); |
526 | kfree (mem[count]); | 526 | kfree(mem[count]); |
527 | return -EIO; | 527 | return -EIO; |
528 | } | 528 | } |
529 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); | 529 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); |
530 | /* _______________________This is for debugging purposes only _______________________*/ | 530 | /* _______________________This is for debugging purposes only _______________________*/ |
531 | debug ("b4 writing, start address is %x\n", func->mem[count]->start); | 531 | debug("b4 writing, start address is %x\n", func->mem[count]->start); |
532 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 532 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
533 | debug ("after writing, the address is %x\n", bar[count]); | 533 | debug("after writing, the address is %x\n", bar[count]); |
534 | /* __________________________________________________________________________________*/ | 534 | /* __________________________________________________________________________________*/ |
535 | 535 | ||
536 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 536 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
537 | /* takes up another dword */ | 537 | /* takes up another dword */ |
538 | debug ("inside mem 64 case, reg. mem, count %d\n", count); | 538 | debug("inside mem 64 case, reg. mem, count %d\n", count); |
539 | count += 1; | 539 | count += 1; |
540 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 540 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
541 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 541 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | } /* end of mem */ | 544 | } /* end of mem */ |
545 | } /* end of for */ | 545 | } /* end of for */ |
546 | 546 | ||
547 | func->bus = 0; /* To indicate that this is not a PPB */ | 547 | func->bus = 0; /* To indicate that this is not a PPB */ |
548 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); | 548 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); |
549 | if ((irq > 0x00) && (irq < 0x05)) | 549 | if ((irq > 0x00) && (irq < 0x05)) |
550 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); | 550 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); |
551 | 551 | ||
552 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); | 552 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); |
553 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); | 553 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); |
554 | 554 | ||
555 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); | 555 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); |
556 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); | 556 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); |
557 | 557 | ||
558 | return 0; | 558 | return 0; |
559 | } | 559 | } |
@@ -563,7 +563,7 @@ static int configure_device (struct pci_func *func) | |||
563 | * Parameters: pci_func | 563 | * Parameters: pci_func |
564 | * Returns: | 564 | * Returns: |
565 | ******************************************************************************/ | 565 | ******************************************************************************/ |
566 | static int configure_bridge (struct pci_func **func_passed, u8 slotno) | 566 | static int configure_bridge(struct pci_func **func_passed, u8 slotno) |
567 | { | 567 | { |
568 | int count; | 568 | int count; |
569 | int i; | 569 | int i; |
@@ -597,7 +597,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
597 | u8 irq; | 597 | u8 irq; |
598 | int retval; | 598 | int retval; |
599 | 599 | ||
600 | debug ("%s - enter\n", __func__); | 600 | debug("%s - enter\n", __func__); |
601 | 601 | ||
602 | devfn = PCI_DEVFN(func->function, func->device); | 602 | devfn = PCI_DEVFN(func->function, func->device); |
603 | ibmphp_pci_bus->number = func->busno; | 603 | ibmphp_pci_bus->number = func->busno; |
@@ -606,43 +606,43 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
606 | * behind it | 606 | * behind it |
607 | */ | 607 | */ |
608 | 608 | ||
609 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); | 609 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); |
610 | 610 | ||
611 | /* _____________________For debugging purposes only __________________________ | 611 | /* _____________________For debugging purposes only __________________________ |
612 | pci_bus_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); | 612 | pci_bus_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); |
613 | debug ("primary # written into the bridge is %x\n", pri_number); | 613 | debug("primary # written into the bridge is %x\n", pri_number); |
614 | ___________________________________________________________________________*/ | 614 | ___________________________________________________________________________*/ |
615 | 615 | ||
616 | /* in EBDA, only get allocated 1 additional bus # per slot */ | 616 | /* in EBDA, only get allocated 1 additional bus # per slot */ |
617 | sec_number = find_sec_number (func->busno, slotno); | 617 | sec_number = find_sec_number(func->busno, slotno); |
618 | if (sec_number == 0xff) { | 618 | if (sec_number == 0xff) { |
619 | err ("cannot allocate secondary bus number for the bridged device\n"); | 619 | err("cannot allocate secondary bus number for the bridged device\n"); |
620 | return -EINVAL; | 620 | return -EINVAL; |
621 | } | 621 | } |
622 | 622 | ||
623 | debug ("after find_sec_number, the number we got is %x\n", sec_number); | 623 | debug("after find_sec_number, the number we got is %x\n", sec_number); |
624 | debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); | 624 | debug("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); |
625 | 625 | ||
626 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); | 626 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); |
627 | 627 | ||
628 | /* __________________For debugging purposes only __________________________________ | 628 | /* __________________For debugging purposes only __________________________________ |
629 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 629 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
630 | debug ("sec_number after write/read is %x\n", sec_number); | 630 | debug("sec_number after write/read is %x\n", sec_number); |
631 | ________________________________________________________________________________*/ | 631 | ________________________________________________________________________________*/ |
632 | 632 | ||
633 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); | 633 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); |
634 | 634 | ||
635 | /* __________________For debugging purposes only ____________________________________ | 635 | /* __________________For debugging purposes only ____________________________________ |
636 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); | 636 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); |
637 | debug ("subordinate number after write/read is %x\n", sec_number); | 637 | debug("subordinate number after write/read is %x\n", sec_number); |
638 | __________________________________________________________________________________*/ | 638 | __________________________________________________________________________________*/ |
639 | 639 | ||
640 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); | 640 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); |
641 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); | 641 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); |
642 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); | 642 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); |
643 | 643 | ||
644 | debug ("func->busno is %x\n", func->busno); | 644 | debug("func->busno is %x\n", func->busno); |
645 | debug ("sec_number after writing is %x\n", sec_number); | 645 | debug("sec_number after writing is %x\n", sec_number); |
646 | 646 | ||
647 | 647 | ||
648 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 648 | /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@@ -652,29 +652,29 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
652 | 652 | ||
653 | /* First we need to allocate mem/io for the bridge itself in case it needs it */ | 653 | /* First we need to allocate mem/io for the bridge itself in case it needs it */ |
654 | for (count = 0; address[count]; count++) { /* for 2 BARs */ | 654 | for (count = 0; address[count]; count++) { /* for 2 BARs */ |
655 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 655 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
656 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 656 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
657 | 657 | ||
658 | if (!bar[count]) { | 658 | if (!bar[count]) { |
659 | /* This BAR is not implemented */ | 659 | /* This BAR is not implemented */ |
660 | debug ("so we come here then, eh?, count = %d\n", count); | 660 | debug("so we come here then, eh?, count = %d\n", count); |
661 | continue; | 661 | continue; |
662 | } | 662 | } |
663 | // tmp_bar = bar[count]; | 663 | // tmp_bar = bar[count]; |
664 | 664 | ||
665 | debug ("Bar %d wants %x\n", count, bar[count]); | 665 | debug("Bar %d wants %x\n", count, bar[count]); |
666 | 666 | ||
667 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 667 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
668 | /* This is IO */ | 668 | /* This is IO */ |
669 | len[count] = bar[count] & 0xFFFFFFFC; | 669 | len[count] = bar[count] & 0xFFFFFFFC; |
670 | len[count] = ~len[count] + 1; | 670 | len[count] = ~len[count] + 1; |
671 | 671 | ||
672 | debug ("len[count] in IO = %x\n", len[count]); | 672 | debug("len[count] in IO = %x\n", len[count]); |
673 | 673 | ||
674 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 674 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
675 | 675 | ||
676 | if (!bus_io[count]) { | 676 | if (!bus_io[count]) { |
677 | err ("out of system memory\n"); | 677 | err("out of system memory\n"); |
678 | retval = -ENOMEM; | 678 | retval = -ENOMEM; |
679 | goto error; | 679 | goto error; |
680 | } | 680 | } |
@@ -683,17 +683,17 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
683 | bus_io[count]->devfunc = PCI_DEVFN(func->device, | 683 | bus_io[count]->devfunc = PCI_DEVFN(func->device, |
684 | func->function); | 684 | func->function); |
685 | bus_io[count]->len = len[count]; | 685 | bus_io[count]->len = len[count]; |
686 | if (ibmphp_check_resource (bus_io[count], 0) == 0) { | 686 | if (ibmphp_check_resource(bus_io[count], 0) == 0) { |
687 | ibmphp_add_resource (bus_io[count]); | 687 | ibmphp_add_resource(bus_io[count]); |
688 | func->io[count] = bus_io[count]; | 688 | func->io[count] = bus_io[count]; |
689 | } else { | 689 | } else { |
690 | err ("cannot allocate requested io for bus %x, device %x, len %x\n", | 690 | err("cannot allocate requested io for bus %x, device %x, len %x\n", |
691 | func->busno, func->device, len[count]); | 691 | func->busno, func->device, len[count]); |
692 | kfree (bus_io[count]); | 692 | kfree(bus_io[count]); |
693 | return -EIO; | 693 | return -EIO; |
694 | } | 694 | } |
695 | 695 | ||
696 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); | 696 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start); |
697 | 697 | ||
698 | } else { | 698 | } else { |
699 | /* This is Memory */ | 699 | /* This is Memory */ |
@@ -702,11 +702,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
702 | len[count] = bar[count] & 0xFFFFFFF0; | 702 | len[count] = bar[count] & 0xFFFFFFF0; |
703 | len[count] = ~len[count] + 1; | 703 | len[count] = ~len[count] + 1; |
704 | 704 | ||
705 | debug ("len[count] in PFMEM = %x\n", len[count]); | 705 | debug("len[count] in PFMEM = %x\n", len[count]); |
706 | 706 | ||
707 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 707 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
708 | if (!bus_pfmem[count]) { | 708 | if (!bus_pfmem[count]) { |
709 | err ("out of system memory\n"); | 709 | err("out of system memory\n"); |
710 | retval = -ENOMEM; | 710 | retval = -ENOMEM; |
711 | goto error; | 711 | goto error; |
712 | } | 712 | } |
@@ -716,13 +716,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
716 | func->function); | 716 | func->function); |
717 | bus_pfmem[count]->len = len[count]; | 717 | bus_pfmem[count]->len = len[count]; |
718 | bus_pfmem[count]->fromMem = 0; | 718 | bus_pfmem[count]->fromMem = 0; |
719 | if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { | 719 | if (ibmphp_check_resource(bus_pfmem[count], 0) == 0) { |
720 | ibmphp_add_resource (bus_pfmem[count]); | 720 | ibmphp_add_resource(bus_pfmem[count]); |
721 | func->pfmem[count] = bus_pfmem[count]; | 721 | func->pfmem[count] = bus_pfmem[count]; |
722 | } else { | 722 | } else { |
723 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 723 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
724 | if (!mem_tmp) { | 724 | if (!mem_tmp) { |
725 | err ("out of system memory\n"); | 725 | err("out of system memory\n"); |
726 | retval = -ENOMEM; | 726 | retval = -ENOMEM; |
727 | goto error; | 727 | goto error; |
728 | } | 728 | } |
@@ -730,28 +730,28 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
730 | mem_tmp->busno = bus_pfmem[count]->busno; | 730 | mem_tmp->busno = bus_pfmem[count]->busno; |
731 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; | 731 | mem_tmp->devfunc = bus_pfmem[count]->devfunc; |
732 | mem_tmp->len = bus_pfmem[count]->len; | 732 | mem_tmp->len = bus_pfmem[count]->len; |
733 | if (ibmphp_check_resource (mem_tmp, 0) == 0) { | 733 | if (ibmphp_check_resource(mem_tmp, 0) == 0) { |
734 | ibmphp_add_resource (mem_tmp); | 734 | ibmphp_add_resource(mem_tmp); |
735 | bus_pfmem[count]->fromMem = 1; | 735 | bus_pfmem[count]->fromMem = 1; |
736 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; | 736 | bus_pfmem[count]->rangeno = mem_tmp->rangeno; |
737 | ibmphp_add_pfmem_from_mem (bus_pfmem[count]); | 737 | ibmphp_add_pfmem_from_mem(bus_pfmem[count]); |
738 | func->pfmem[count] = bus_pfmem[count]; | 738 | func->pfmem[count] = bus_pfmem[count]; |
739 | } else { | 739 | } else { |
740 | err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", | 740 | err("cannot allocate requested pfmem for bus %x, device %x, len %x\n", |
741 | func->busno, func->device, len[count]); | 741 | func->busno, func->device, len[count]); |
742 | kfree (mem_tmp); | 742 | kfree(mem_tmp); |
743 | kfree (bus_pfmem[count]); | 743 | kfree(bus_pfmem[count]); |
744 | return -EIO; | 744 | return -EIO; |
745 | } | 745 | } |
746 | } | 746 | } |
747 | 747 | ||
748 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); | 748 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); |
749 | 749 | ||
750 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 750 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
751 | /* takes up another dword */ | 751 | /* takes up another dword */ |
752 | count += 1; | 752 | count += 1; |
753 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 753 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
754 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 754 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
755 | 755 | ||
756 | } | 756 | } |
757 | } else { | 757 | } else { |
@@ -759,11 +759,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
759 | len[count] = bar[count] & 0xFFFFFFF0; | 759 | len[count] = bar[count] & 0xFFFFFFF0; |
760 | len[count] = ~len[count] + 1; | 760 | len[count] = ~len[count] + 1; |
761 | 761 | ||
762 | debug ("len[count] in Memory is %x\n", len[count]); | 762 | debug("len[count] in Memory is %x\n", len[count]); |
763 | 763 | ||
764 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 764 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
765 | if (!bus_mem[count]) { | 765 | if (!bus_mem[count]) { |
766 | err ("out of system memory\n"); | 766 | err("out of system memory\n"); |
767 | retval = -ENOMEM; | 767 | retval = -ENOMEM; |
768 | goto error; | 768 | goto error; |
769 | } | 769 | } |
@@ -772,23 +772,23 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
772 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, | 772 | bus_mem[count]->devfunc = PCI_DEVFN(func->device, |
773 | func->function); | 773 | func->function); |
774 | bus_mem[count]->len = len[count]; | 774 | bus_mem[count]->len = len[count]; |
775 | if (ibmphp_check_resource (bus_mem[count], 0) == 0) { | 775 | if (ibmphp_check_resource(bus_mem[count], 0) == 0) { |
776 | ibmphp_add_resource (bus_mem[count]); | 776 | ibmphp_add_resource(bus_mem[count]); |
777 | func->mem[count] = bus_mem[count]; | 777 | func->mem[count] = bus_mem[count]; |
778 | } else { | 778 | } else { |
779 | err ("cannot allocate requested mem for bus %x, device %x, len %x\n", | 779 | err("cannot allocate requested mem for bus %x, device %x, len %x\n", |
780 | func->busno, func->device, len[count]); | 780 | func->busno, func->device, len[count]); |
781 | kfree (bus_mem[count]); | 781 | kfree(bus_mem[count]); |
782 | return -EIO; | 782 | return -EIO; |
783 | } | 783 | } |
784 | 784 | ||
785 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); | 785 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); |
786 | 786 | ||
787 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 787 | if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
788 | /* takes up another dword */ | 788 | /* takes up another dword */ |
789 | count += 1; | 789 | count += 1; |
790 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ | 790 | /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ |
791 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); | 791 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000); |
792 | 792 | ||
793 | } | 793 | } |
794 | } | 794 | } |
@@ -796,45 +796,45 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
796 | } /* end of for */ | 796 | } /* end of for */ |
797 | 797 | ||
798 | /* Now need to see how much space the devices behind the bridge needed */ | 798 | /* Now need to see how much space the devices behind the bridge needed */ |
799 | amount_needed = scan_behind_bridge (func, sec_number); | 799 | amount_needed = scan_behind_bridge(func, sec_number); |
800 | if (amount_needed == NULL) | 800 | if (amount_needed == NULL) |
801 | return -ENOMEM; | 801 | return -ENOMEM; |
802 | 802 | ||
803 | ibmphp_pci_bus->number = func->busno; | 803 | ibmphp_pci_bus->number = func->busno; |
804 | debug ("after coming back from scan_behind_bridge\n"); | 804 | debug("after coming back from scan_behind_bridge\n"); |
805 | debug ("amount_needed->not_correct = %x\n", amount_needed->not_correct); | 805 | debug("amount_needed->not_correct = %x\n", amount_needed->not_correct); |
806 | debug ("amount_needed->io = %x\n", amount_needed->io); | 806 | debug("amount_needed->io = %x\n", amount_needed->io); |
807 | debug ("amount_needed->mem = %x\n", amount_needed->mem); | 807 | debug("amount_needed->mem = %x\n", amount_needed->mem); |
808 | debug ("amount_needed->pfmem = %x\n", amount_needed->pfmem); | 808 | debug("amount_needed->pfmem = %x\n", amount_needed->pfmem); |
809 | 809 | ||
810 | if (amount_needed->not_correct) { | 810 | if (amount_needed->not_correct) { |
811 | debug ("amount_needed is not correct\n"); | 811 | debug("amount_needed is not correct\n"); |
812 | for (count = 0; address[count]; count++) { | 812 | for (count = 0; address[count]; count++) { |
813 | /* for 2 BARs */ | 813 | /* for 2 BARs */ |
814 | if (bus_io[count]) { | 814 | if (bus_io[count]) { |
815 | ibmphp_remove_resource (bus_io[count]); | 815 | ibmphp_remove_resource(bus_io[count]); |
816 | func->io[count] = NULL; | 816 | func->io[count] = NULL; |
817 | } else if (bus_pfmem[count]) { | 817 | } else if (bus_pfmem[count]) { |
818 | ibmphp_remove_resource (bus_pfmem[count]); | 818 | ibmphp_remove_resource(bus_pfmem[count]); |
819 | func->pfmem[count] = NULL; | 819 | func->pfmem[count] = NULL; |
820 | } else if (bus_mem[count]) { | 820 | } else if (bus_mem[count]) { |
821 | ibmphp_remove_resource (bus_mem[count]); | 821 | ibmphp_remove_resource(bus_mem[count]); |
822 | func->mem[count] = NULL; | 822 | func->mem[count] = NULL; |
823 | } | 823 | } |
824 | } | 824 | } |
825 | kfree (amount_needed); | 825 | kfree(amount_needed); |
826 | return -ENODEV; | 826 | return -ENODEV; |
827 | } | 827 | } |
828 | 828 | ||
829 | if (!amount_needed->io) { | 829 | if (!amount_needed->io) { |
830 | debug ("it doesn't want IO?\n"); | 830 | debug("it doesn't want IO?\n"); |
831 | flag_io = 1; | 831 | flag_io = 1; |
832 | } else { | 832 | } else { |
833 | debug ("it wants %x IO behind the bridge\n", amount_needed->io); | 833 | debug("it wants %x IO behind the bridge\n", amount_needed->io); |
834 | io = kzalloc(sizeof(*io), GFP_KERNEL); | 834 | io = kzalloc(sizeof(*io), GFP_KERNEL); |
835 | 835 | ||
836 | if (!io) { | 836 | if (!io) { |
837 | err ("out of system memory\n"); | 837 | err("out of system memory\n"); |
838 | retval = -ENOMEM; | 838 | retval = -ENOMEM; |
839 | goto error; | 839 | goto error; |
840 | } | 840 | } |
@@ -842,21 +842,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
842 | io->busno = func->busno; | 842 | io->busno = func->busno; |
843 | io->devfunc = PCI_DEVFN(func->device, func->function); | 843 | io->devfunc = PCI_DEVFN(func->device, func->function); |
844 | io->len = amount_needed->io; | 844 | io->len = amount_needed->io; |
845 | if (ibmphp_check_resource (io, 1) == 0) { | 845 | if (ibmphp_check_resource(io, 1) == 0) { |
846 | debug ("were we able to add io\n"); | 846 | debug("were we able to add io\n"); |
847 | ibmphp_add_resource (io); | 847 | ibmphp_add_resource(io); |
848 | flag_io = 1; | 848 | flag_io = 1; |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | if (!amount_needed->mem) { | 852 | if (!amount_needed->mem) { |
853 | debug ("it doesn't want n.e.memory?\n"); | 853 | debug("it doesn't want n.e.memory?\n"); |
854 | flag_mem = 1; | 854 | flag_mem = 1; |
855 | } else { | 855 | } else { |
856 | debug ("it wants %x memory behind the bridge\n", amount_needed->mem); | 856 | debug("it wants %x memory behind the bridge\n", amount_needed->mem); |
857 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); | 857 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
858 | if (!mem) { | 858 | if (!mem) { |
859 | err ("out of system memory\n"); | 859 | err("out of system memory\n"); |
860 | retval = -ENOMEM; | 860 | retval = -ENOMEM; |
861 | goto error; | 861 | goto error; |
862 | } | 862 | } |
@@ -864,21 +864,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
864 | mem->busno = func->busno; | 864 | mem->busno = func->busno; |
865 | mem->devfunc = PCI_DEVFN(func->device, func->function); | 865 | mem->devfunc = PCI_DEVFN(func->device, func->function); |
866 | mem->len = amount_needed->mem; | 866 | mem->len = amount_needed->mem; |
867 | if (ibmphp_check_resource (mem, 1) == 0) { | 867 | if (ibmphp_check_resource(mem, 1) == 0) { |
868 | ibmphp_add_resource (mem); | 868 | ibmphp_add_resource(mem); |
869 | flag_mem = 1; | 869 | flag_mem = 1; |
870 | debug ("were we able to add mem\n"); | 870 | debug("were we able to add mem\n"); |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | if (!amount_needed->pfmem) { | 874 | if (!amount_needed->pfmem) { |
875 | debug ("it doesn't want n.e.pfmem mem?\n"); | 875 | debug("it doesn't want n.e.pfmem mem?\n"); |
876 | flag_pfmem = 1; | 876 | flag_pfmem = 1; |
877 | } else { | 877 | } else { |
878 | debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); | 878 | debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); |
879 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); | 879 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); |
880 | if (!pfmem) { | 880 | if (!pfmem) { |
881 | err ("out of system memory\n"); | 881 | err("out of system memory\n"); |
882 | retval = -ENOMEM; | 882 | retval = -ENOMEM; |
883 | goto error; | 883 | goto error; |
884 | } | 884 | } |
@@ -887,13 +887,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
887 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); | 887 | pfmem->devfunc = PCI_DEVFN(func->device, func->function); |
888 | pfmem->len = amount_needed->pfmem; | 888 | pfmem->len = amount_needed->pfmem; |
889 | pfmem->fromMem = 0; | 889 | pfmem->fromMem = 0; |
890 | if (ibmphp_check_resource (pfmem, 1) == 0) { | 890 | if (ibmphp_check_resource(pfmem, 1) == 0) { |
891 | ibmphp_add_resource (pfmem); | 891 | ibmphp_add_resource(pfmem); |
892 | flag_pfmem = 1; | 892 | flag_pfmem = 1; |
893 | } else { | 893 | } else { |
894 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 894 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
895 | if (!mem_tmp) { | 895 | if (!mem_tmp) { |
896 | err ("out of system memory\n"); | 896 | err("out of system memory\n"); |
897 | retval = -ENOMEM; | 897 | retval = -ENOMEM; |
898 | goto error; | 898 | goto error; |
899 | } | 899 | } |
@@ -901,18 +901,18 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
901 | mem_tmp->busno = pfmem->busno; | 901 | mem_tmp->busno = pfmem->busno; |
902 | mem_tmp->devfunc = pfmem->devfunc; | 902 | mem_tmp->devfunc = pfmem->devfunc; |
903 | mem_tmp->len = pfmem->len; | 903 | mem_tmp->len = pfmem->len; |
904 | if (ibmphp_check_resource (mem_tmp, 1) == 0) { | 904 | if (ibmphp_check_resource(mem_tmp, 1) == 0) { |
905 | ibmphp_add_resource (mem_tmp); | 905 | ibmphp_add_resource(mem_tmp); |
906 | pfmem->fromMem = 1; | 906 | pfmem->fromMem = 1; |
907 | pfmem->rangeno = mem_tmp->rangeno; | 907 | pfmem->rangeno = mem_tmp->rangeno; |
908 | ibmphp_add_pfmem_from_mem (pfmem); | 908 | ibmphp_add_pfmem_from_mem(pfmem); |
909 | flag_pfmem = 1; | 909 | flag_pfmem = 1; |
910 | } | 910 | } |
911 | } | 911 | } |
912 | } | 912 | } |
913 | 913 | ||
914 | debug ("b4 if (flag_io && flag_mem && flag_pfmem)\n"); | 914 | debug("b4 if (flag_io && flag_mem && flag_pfmem)\n"); |
915 | debug ("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem); | 915 | debug("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem); |
916 | 916 | ||
917 | if (flag_io && flag_mem && flag_pfmem) { | 917 | if (flag_io && flag_mem && flag_pfmem) { |
918 | /* If on bootup, there was a bridged card in this slot, | 918 | /* If on bootup, there was a bridged card in this slot, |
@@ -920,127 +920,127 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
920 | * back again, there's no way for us to remove the bus | 920 | * back again, there's no way for us to remove the bus |
921 | * struct, so no need to kmalloc, can use existing node | 921 | * struct, so no need to kmalloc, can use existing node |
922 | */ | 922 | */ |
923 | bus = ibmphp_find_res_bus (sec_number); | 923 | bus = ibmphp_find_res_bus(sec_number); |
924 | if (!bus) { | 924 | if (!bus) { |
925 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | 925 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); |
926 | if (!bus) { | 926 | if (!bus) { |
927 | err ("out of system memory\n"); | 927 | err("out of system memory\n"); |
928 | retval = -ENOMEM; | 928 | retval = -ENOMEM; |
929 | goto error; | 929 | goto error; |
930 | } | 930 | } |
931 | bus->busno = sec_number; | 931 | bus->busno = sec_number; |
932 | debug ("b4 adding new bus\n"); | 932 | debug("b4 adding new bus\n"); |
933 | rc = add_new_bus (bus, io, mem, pfmem, func->busno); | 933 | rc = add_new_bus(bus, io, mem, pfmem, func->busno); |
934 | } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem)) | 934 | } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem)) |
935 | rc = add_new_bus (bus, io, mem, pfmem, 0xFF); | 935 | rc = add_new_bus(bus, io, mem, pfmem, 0xFF); |
936 | else { | 936 | else { |
937 | err ("expected bus structure not empty?\n"); | 937 | err("expected bus structure not empty?\n"); |
938 | retval = -EIO; | 938 | retval = -EIO; |
939 | goto error; | 939 | goto error; |
940 | } | 940 | } |
941 | if (rc) { | 941 | if (rc) { |
942 | if (rc == -ENOMEM) { | 942 | if (rc == -ENOMEM) { |
943 | ibmphp_remove_bus (bus, func->busno); | 943 | ibmphp_remove_bus(bus, func->busno); |
944 | kfree (amount_needed); | 944 | kfree(amount_needed); |
945 | return rc; | 945 | return rc; |
946 | } | 946 | } |
947 | retval = rc; | 947 | retval = rc; |
948 | goto error; | 948 | goto error; |
949 | } | 949 | } |
950 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); | 950 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); |
951 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); | 951 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); |
952 | 952 | ||
953 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { | 953 | if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { |
954 | debug ("io 32\n"); | 954 | debug("io 32\n"); |
955 | need_io_upper = 1; | 955 | need_io_upper = 1; |
956 | } | 956 | } |
957 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { | 957 | if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { |
958 | debug ("pfmem 64\n"); | 958 | debug("pfmem 64\n"); |
959 | need_pfmem_upper = 1; | 959 | need_pfmem_upper = 1; |
960 | } | 960 | } |
961 | 961 | ||
962 | if (bus->noIORanges) { | 962 | if (bus->noIORanges) { |
963 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); | 963 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); |
964 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); | 964 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); |
965 | 965 | ||
966 | /* _______________This is for debugging purposes only ____________________ | 966 | /* _______________This is for debugging purposes only ____________________ |
967 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); | 967 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); |
968 | debug ("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); | 968 | debug("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); |
969 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); | 969 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); |
970 | debug ("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); | 970 | debug("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); |
971 | ________________________________________________________________________*/ | 971 | ________________________________________________________________________*/ |
972 | 972 | ||
973 | if (need_io_upper) { /* since can't support n.e.ways */ | 973 | if (need_io_upper) { /* since can't support n.e.ways */ |
974 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); | 974 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); |
975 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); | 975 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); |
976 | } | 976 | } |
977 | } else { | 977 | } else { |
978 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); | 978 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); |
979 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); | 979 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); |
980 | } | 980 | } |
981 | 981 | ||
982 | if (bus->noMemRanges) { | 982 | if (bus->noMemRanges) { |
983 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); | 983 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); |
984 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); | 984 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); |
985 | 985 | ||
986 | /* ____________________This is for debugging purposes only ________________________ | 986 | /* ____________________This is for debugging purposes only ________________________ |
987 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); | 987 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); |
988 | debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 988 | debug("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
989 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); | 989 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); |
990 | debug ("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 990 | debug("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
991 | __________________________________________________________________________________*/ | 991 | __________________________________________________________________________________*/ |
992 | 992 | ||
993 | } else { | 993 | } else { |
994 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); | 994 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); |
995 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); | 995 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); |
996 | } | 996 | } |
997 | if (bus->noPFMemRanges) { | 997 | if (bus->noPFMemRanges) { |
998 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); | 998 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); |
999 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); | 999 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); |
1000 | 1000 | ||
1001 | /* __________________________This is for debugging purposes only _______________________ | 1001 | /* __________________________This is for debugging purposes only _______________________ |
1002 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); | 1002 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); |
1003 | debug ("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 1003 | debug("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
1004 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); | 1004 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); |
1005 | debug ("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); | 1005 | debug("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); |
1006 | ______________________________________________________________________________________*/ | 1006 | ______________________________________________________________________________________*/ |
1007 | 1007 | ||
1008 | if (need_pfmem_upper) { /* since can't support n.e.ways */ | 1008 | if (need_pfmem_upper) { /* since can't support n.e.ways */ |
1009 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); | 1009 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); |
1010 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); | 1010 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); |
1011 | } | 1011 | } |
1012 | } else { | 1012 | } else { |
1013 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); | 1013 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); |
1014 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); | 1014 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | debug ("b4 writing control information\n"); | 1017 | debug("b4 writing control information\n"); |
1018 | 1018 | ||
1019 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); | 1019 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); |
1020 | if ((irq > 0x00) && (irq < 0x05)) | 1020 | if ((irq > 0x00) && (irq < 0x05)) |
1021 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); | 1021 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); |
1022 | /* | 1022 | /* |
1023 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); | 1023 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); |
1024 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); | 1024 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); |
1025 | pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); | 1025 | pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); |
1026 | */ | 1026 | */ |
1027 | 1027 | ||
1028 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); | 1028 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); |
1029 | pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); | 1029 | pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); |
1030 | for (i = 0; i < 32; i++) { | 1030 | for (i = 0; i < 32; i++) { |
1031 | if (amount_needed->devices[i]) { | 1031 | if (amount_needed->devices[i]) { |
1032 | debug ("device where devices[i] is 1 = %x\n", i); | 1032 | debug("device where devices[i] is 1 = %x\n", i); |
1033 | func->devices[i] = 1; | 1033 | func->devices[i] = 1; |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | func->bus = 1; /* For unconfiguring, to indicate it's PPB */ | 1036 | func->bus = 1; /* For unconfiguring, to indicate it's PPB */ |
1037 | func_passed = &func; | 1037 | func_passed = &func; |
1038 | debug ("func->busno b4 returning is %x\n", func->busno); | 1038 | debug("func->busno b4 returning is %x\n", func->busno); |
1039 | debug ("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno); | 1039 | debug("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno); |
1040 | kfree (amount_needed); | 1040 | kfree(amount_needed); |
1041 | return 0; | 1041 | return 0; |
1042 | } else { | 1042 | } else { |
1043 | err ("Configuring bridge was unsuccessful...\n"); | 1043 | err("Configuring bridge was unsuccessful...\n"); |
1044 | mem_tmp = NULL; | 1044 | mem_tmp = NULL; |
1045 | retval = -EIO; | 1045 | retval = -EIO; |
1046 | goto error; | 1046 | goto error; |
@@ -1049,20 +1049,20 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) | |||
1049 | error: | 1049 | error: |
1050 | kfree(amount_needed); | 1050 | kfree(amount_needed); |
1051 | if (pfmem) | 1051 | if (pfmem) |
1052 | ibmphp_remove_resource (pfmem); | 1052 | ibmphp_remove_resource(pfmem); |
1053 | if (io) | 1053 | if (io) |
1054 | ibmphp_remove_resource (io); | 1054 | ibmphp_remove_resource(io); |
1055 | if (mem) | 1055 | if (mem) |
1056 | ibmphp_remove_resource (mem); | 1056 | ibmphp_remove_resource(mem); |
1057 | for (i = 0; i < 2; i++) { /* for 2 BARs */ | 1057 | for (i = 0; i < 2; i++) { /* for 2 BARs */ |
1058 | if (bus_io[i]) { | 1058 | if (bus_io[i]) { |
1059 | ibmphp_remove_resource (bus_io[i]); | 1059 | ibmphp_remove_resource(bus_io[i]); |
1060 | func->io[i] = NULL; | 1060 | func->io[i] = NULL; |
1061 | } else if (bus_pfmem[i]) { | 1061 | } else if (bus_pfmem[i]) { |
1062 | ibmphp_remove_resource (bus_pfmem[i]); | 1062 | ibmphp_remove_resource(bus_pfmem[i]); |
1063 | func->pfmem[i] = NULL; | 1063 | func->pfmem[i] = NULL; |
1064 | } else if (bus_mem[i]) { | 1064 | } else if (bus_mem[i]) { |
1065 | ibmphp_remove_resource (bus_mem[i]); | 1065 | ibmphp_remove_resource(bus_mem[i]); |
1066 | func->mem[i] = NULL; | 1066 | func->mem[i] = NULL; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
@@ -1075,7 +1075,7 @@ error: | |||
1075 | * Input: bridge function | 1075 | * Input: bridge function |
1076 | * Output: amount of resources needed | 1076 | * Output: amount of resources needed |
1077 | *****************************************************************************/ | 1077 | *****************************************************************************/ |
1078 | static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | 1078 | static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno) |
1079 | { | 1079 | { |
1080 | int count, len[6]; | 1080 | int count, len[6]; |
1081 | u16 vendor_id; | 1081 | u16 vendor_id; |
@@ -1102,36 +1102,36 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1102 | 1102 | ||
1103 | ibmphp_pci_bus->number = busno; | 1103 | ibmphp_pci_bus->number = busno; |
1104 | 1104 | ||
1105 | debug ("the bus_no behind the bridge is %x\n", busno); | 1105 | debug("the bus_no behind the bridge is %x\n", busno); |
1106 | debug ("scanning devices behind the bridge...\n"); | 1106 | debug("scanning devices behind the bridge...\n"); |
1107 | for (device = 0; device < 32; device++) { | 1107 | for (device = 0; device < 32; device++) { |
1108 | amount->devices[device] = 0; | 1108 | amount->devices[device] = 0; |
1109 | for (function = 0; function < 8; function++) { | 1109 | for (function = 0; function < 8; function++) { |
1110 | devfn = PCI_DEVFN(device, function); | 1110 | devfn = PCI_DEVFN(device, function); |
1111 | 1111 | ||
1112 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 1112 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
1113 | 1113 | ||
1114 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 1114 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
1115 | /* found correct device!!! */ | 1115 | /* found correct device!!! */ |
1116 | howmany++; | 1116 | howmany++; |
1117 | 1117 | ||
1118 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 1118 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
1119 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 1119 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
1120 | 1120 | ||
1121 | debug ("hdr_type behind the bridge is %x\n", hdr_type); | 1121 | debug("hdr_type behind the bridge is %x\n", hdr_type); |
1122 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 1122 | if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) { |
1123 | err ("embedded bridges not supported for hot-plugging.\n"); | 1123 | err("embedded bridges not supported for hot-plugging.\n"); |
1124 | amount->not_correct = 1; | 1124 | amount->not_correct = 1; |
1125 | return amount; | 1125 | return amount; |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 1128 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
1129 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1129 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1130 | err ("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device); | 1130 | err("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device); |
1131 | amount->not_correct = 1; | 1131 | amount->not_correct = 1; |
1132 | return amount; | 1132 | return amount; |
1133 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1133 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1134 | err ("The device %x is not supported for hot plugging. Please choose another device.\n", device); | 1134 | err("The device %x is not supported for hot plugging. Please choose another device.\n", device); |
1135 | amount->not_correct = 1; | 1135 | amount->not_correct = 1; |
1136 | return amount; | 1136 | return amount; |
1137 | } | 1137 | } |
@@ -1141,23 +1141,23 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1141 | for (count = 0; address[count]; count++) { | 1141 | for (count = 0; address[count]; count++) { |
1142 | /* for 6 BARs */ | 1142 | /* for 6 BARs */ |
1143 | /* | 1143 | /* |
1144 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, address[count], &tmp); | 1144 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, address[count], &tmp); |
1145 | if (tmp & 0x01) // IO | 1145 | if (tmp & 0x01) // IO |
1146 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); | 1146 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); |
1147 | else // MEMORY | 1147 | else // MEMORY |
1148 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1148 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1149 | */ | 1149 | */ |
1150 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1150 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1151 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); | 1151 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]); |
1152 | 1152 | ||
1153 | debug ("what is bar[count]? %x, count = %d\n", bar[count], count); | 1153 | debug("what is bar[count]? %x, count = %d\n", bar[count], count); |
1154 | 1154 | ||
1155 | if (!bar[count]) /* This BAR is not implemented */ | 1155 | if (!bar[count]) /* This BAR is not implemented */ |
1156 | continue; | 1156 | continue; |
1157 | 1157 | ||
1158 | //tmp_bar = bar[count]; | 1158 | //tmp_bar = bar[count]; |
1159 | 1159 | ||
1160 | debug ("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]); | 1160 | debug("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]); |
1161 | 1161 | ||
1162 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { | 1162 | if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { |
1163 | /* This is IO */ | 1163 | /* This is IO */ |
@@ -1211,7 +1211,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1211 | * Change: we also call these functions even if we configured the card ourselves (i.e., not | 1211 | * Change: we also call these functions even if we configured the card ourselves (i.e., not |
1212 | * the bootup case), since it should work same way | 1212 | * the bootup case), since it should work same way |
1213 | */ | 1213 | */ |
1214 | static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | 1214 | static int unconfigure_boot_device(u8 busno, u8 device, u8 function) |
1215 | { | 1215 | { |
1216 | u32 start_address; | 1216 | u32 start_address; |
1217 | u32 address[] = { | 1217 | u32 address[] = { |
@@ -1234,30 +1234,30 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1234 | u32 tmp_address; | 1234 | u32 tmp_address; |
1235 | unsigned int devfn; | 1235 | unsigned int devfn; |
1236 | 1236 | ||
1237 | debug ("%s - enter\n", __func__); | 1237 | debug("%s - enter\n", __func__); |
1238 | 1238 | ||
1239 | bus = ibmphp_find_res_bus (busno); | 1239 | bus = ibmphp_find_res_bus(busno); |
1240 | if (!bus) { | 1240 | if (!bus) { |
1241 | debug ("cannot find corresponding bus.\n"); | 1241 | debug("cannot find corresponding bus.\n"); |
1242 | return -EINVAL; | 1242 | return -EINVAL; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | devfn = PCI_DEVFN(device, function); | 1245 | devfn = PCI_DEVFN(device, function); |
1246 | ibmphp_pci_bus->number = busno; | 1246 | ibmphp_pci_bus->number = busno; |
1247 | for (count = 0; address[count]; count++) { /* for 6 BARs */ | 1247 | for (count = 0; address[count]; count++) { /* for 6 BARs */ |
1248 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); | 1248 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address); |
1249 | 1249 | ||
1250 | /* We can do this here, b/c by that time the device driver of the card has been stopped */ | 1250 | /* We can do this here, b/c by that time the device driver of the card has been stopped */ |
1251 | 1251 | ||
1252 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); | 1252 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); |
1253 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &size); | 1253 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &size); |
1254 | pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], start_address); | 1254 | pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], start_address); |
1255 | 1255 | ||
1256 | debug ("start_address is %x\n", start_address); | 1256 | debug("start_address is %x\n", start_address); |
1257 | debug ("busno, device, function %x %x %x\n", busno, device, function); | 1257 | debug("busno, device, function %x %x %x\n", busno, device, function); |
1258 | if (!size) { | 1258 | if (!size) { |
1259 | /* This BAR is not implemented */ | 1259 | /* This BAR is not implemented */ |
1260 | debug ("is this bar no implemented?, count = %d\n", count); | 1260 | debug("is this bar no implemented?, count = %d\n", count); |
1261 | continue; | 1261 | continue; |
1262 | } | 1262 | } |
1263 | tmp_address = start_address; | 1263 | tmp_address = start_address; |
@@ -1267,24 +1267,24 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1267 | size = size & 0xFFFFFFFC; | 1267 | size = size & 0xFFFFFFFC; |
1268 | size = ~size + 1; | 1268 | size = ~size + 1; |
1269 | end_address = start_address + size - 1; | 1269 | end_address = start_address + size - 1; |
1270 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1270 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1271 | err ("cannot find corresponding IO resource to remove\n"); | 1271 | err("cannot find corresponding IO resource to remove\n"); |
1272 | return -EIO; | 1272 | return -EIO; |
1273 | } | 1273 | } |
1274 | debug ("io->start = %x\n", io->start); | 1274 | debug("io->start = %x\n", io->start); |
1275 | temp_end = io->end; | 1275 | temp_end = io->end; |
1276 | start_address = io->end + 1; | 1276 | start_address = io->end + 1; |
1277 | ibmphp_remove_resource (io); | 1277 | ibmphp_remove_resource(io); |
1278 | /* This is needed b/c of the old I/O restrictions in the BIOS */ | 1278 | /* This is needed b/c of the old I/O restrictions in the BIOS */ |
1279 | while (temp_end < end_address) { | 1279 | while (temp_end < end_address) { |
1280 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1280 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1281 | err ("cannot find corresponding IO resource to remove\n"); | 1281 | err("cannot find corresponding IO resource to remove\n"); |
1282 | return -EIO; | 1282 | return -EIO; |
1283 | } | 1283 | } |
1284 | debug ("io->start = %x\n", io->start); | 1284 | debug("io->start = %x\n", io->start); |
1285 | temp_end = io->end; | 1285 | temp_end = io->end; |
1286 | start_address = io->end + 1; | 1286 | start_address = io->end + 1; |
1287 | ibmphp_remove_resource (io); | 1287 | ibmphp_remove_resource(io); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ | 1290 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ |
@@ -1292,29 +1292,29 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1292 | /* This is Memory */ | 1292 | /* This is Memory */ |
1293 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 1293 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
1294 | /* pfmem */ | 1294 | /* pfmem */ |
1295 | debug ("start address of pfmem is %x\n", start_address); | 1295 | debug("start address of pfmem is %x\n", start_address); |
1296 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1296 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1297 | 1297 | ||
1298 | if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { | 1298 | if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) { |
1299 | err ("cannot find corresponding PFMEM resource to remove\n"); | 1299 | err("cannot find corresponding PFMEM resource to remove\n"); |
1300 | return -EIO; | 1300 | return -EIO; |
1301 | } | 1301 | } |
1302 | if (pfmem) { | 1302 | if (pfmem) { |
1303 | debug ("pfmem->start = %x\n", pfmem->start); | 1303 | debug("pfmem->start = %x\n", pfmem->start); |
1304 | 1304 | ||
1305 | ibmphp_remove_resource(pfmem); | 1305 | ibmphp_remove_resource(pfmem); |
1306 | } | 1306 | } |
1307 | } else { | 1307 | } else { |
1308 | /* regular memory */ | 1308 | /* regular memory */ |
1309 | debug ("start address of mem is %x\n", start_address); | 1309 | debug("start address of mem is %x\n", start_address); |
1310 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1310 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1311 | 1311 | ||
1312 | if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { | 1312 | if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) { |
1313 | err ("cannot find corresponding MEM resource to remove\n"); | 1313 | err("cannot find corresponding MEM resource to remove\n"); |
1314 | return -EIO; | 1314 | return -EIO; |
1315 | } | 1315 | } |
1316 | if (mem) { | 1316 | if (mem) { |
1317 | debug ("mem->start = %x\n", mem->start); | 1317 | debug("mem->start = %x\n", mem->start); |
1318 | 1318 | ||
1319 | ibmphp_remove_resource(mem); | 1319 | ibmphp_remove_resource(mem); |
1320 | } | 1320 | } |
@@ -1329,7 +1329,7 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) | |||
1329 | return 0; | 1329 | return 0; |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | 1332 | static int unconfigure_boot_bridge(u8 busno, u8 device, u8 function) |
1333 | { | 1333 | { |
1334 | int count; | 1334 | int count; |
1335 | int bus_no, pri_no, sub_no, sec_no = 0; | 1335 | int bus_no, pri_no, sub_no, sec_no = 0; |
@@ -1349,40 +1349,40 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1349 | devfn = PCI_DEVFN(device, function); | 1349 | devfn = PCI_DEVFN(device, function); |
1350 | ibmphp_pci_bus->number = busno; | 1350 | ibmphp_pci_bus->number = busno; |
1351 | bus_no = (int) busno; | 1351 | bus_no = (int) busno; |
1352 | debug ("busno is %x\n", busno); | 1352 | debug("busno is %x\n", busno); |
1353 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); | 1353 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); |
1354 | debug ("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number); | 1354 | debug("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number); |
1355 | 1355 | ||
1356 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); | 1356 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); |
1357 | debug ("sec_number is %x\n", sec_number); | 1357 | debug("sec_number is %x\n", sec_number); |
1358 | sec_no = (int) sec_number; | 1358 | sec_no = (int) sec_number; |
1359 | pri_no = (int) pri_number; | 1359 | pri_no = (int) pri_number; |
1360 | if (pri_no != bus_no) { | 1360 | if (pri_no != bus_no) { |
1361 | err ("primary numbers in our structures and pci config space don't match.\n"); | 1361 | err("primary numbers in our structures and pci config space don't match.\n"); |
1362 | return -EINVAL; | 1362 | return -EINVAL; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); | 1365 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); |
1366 | sub_no = (int) sub_number; | 1366 | sub_no = (int) sub_number; |
1367 | debug ("sub_no is %d, sec_no is %d\n", sub_no, sec_no); | 1367 | debug("sub_no is %d, sec_no is %d\n", sub_no, sec_no); |
1368 | if (sec_no != sub_number) { | 1368 | if (sec_no != sub_number) { |
1369 | err ("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n"); | 1369 | err("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n"); |
1370 | return -ENODEV; | 1370 | return -ENODEV; |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | bus = ibmphp_find_res_bus (sec_number); | 1373 | bus = ibmphp_find_res_bus(sec_number); |
1374 | if (!bus) { | 1374 | if (!bus) { |
1375 | err ("cannot find Bus structure for the bridged device\n"); | 1375 | err("cannot find Bus structure for the bridged device\n"); |
1376 | return -EINVAL; | 1376 | return -EINVAL; |
1377 | } | 1377 | } |
1378 | debug("bus->busno is %x\n", bus->busno); | 1378 | debug("bus->busno is %x\n", bus->busno); |
1379 | debug("sec_number is %x\n", sec_number); | 1379 | debug("sec_number is %x\n", sec_number); |
1380 | 1380 | ||
1381 | ibmphp_remove_bus (bus, busno); | 1381 | ibmphp_remove_bus(bus, busno); |
1382 | 1382 | ||
1383 | for (count = 0; address[count]; count++) { | 1383 | for (count = 0; address[count]; count++) { |
1384 | /* for 2 BARs */ | 1384 | /* for 2 BARs */ |
1385 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); | 1385 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address); |
1386 | 1386 | ||
1387 | if (!start_address) { | 1387 | if (!start_address) { |
1388 | /* This BAR is not implemented */ | 1388 | /* This BAR is not implemented */ |
@@ -1394,14 +1394,14 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1394 | if (start_address & PCI_BASE_ADDRESS_SPACE_IO) { | 1394 | if (start_address & PCI_BASE_ADDRESS_SPACE_IO) { |
1395 | /* This is IO */ | 1395 | /* This is IO */ |
1396 | start_address &= PCI_BASE_ADDRESS_IO_MASK; | 1396 | start_address &= PCI_BASE_ADDRESS_IO_MASK; |
1397 | if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { | 1397 | if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { |
1398 | err ("cannot find corresponding IO resource to remove\n"); | 1398 | err("cannot find corresponding IO resource to remove\n"); |
1399 | return -EIO; | 1399 | return -EIO; |
1400 | } | 1400 | } |
1401 | if (io) | 1401 | if (io) |
1402 | debug ("io->start = %x\n", io->start); | 1402 | debug("io->start = %x\n", io->start); |
1403 | 1403 | ||
1404 | ibmphp_remove_resource (io); | 1404 | ibmphp_remove_resource(io); |
1405 | 1405 | ||
1406 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ | 1406 | /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ |
1407 | } else { | 1407 | } else { |
@@ -1409,24 +1409,24 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1409 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { | 1409 | if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { |
1410 | /* pfmem */ | 1410 | /* pfmem */ |
1411 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1411 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1412 | if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { | 1412 | if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) { |
1413 | err ("cannot find corresponding PFMEM resource to remove\n"); | 1413 | err("cannot find corresponding PFMEM resource to remove\n"); |
1414 | return -EINVAL; | 1414 | return -EINVAL; |
1415 | } | 1415 | } |
1416 | if (pfmem) { | 1416 | if (pfmem) { |
1417 | debug ("pfmem->start = %x\n", pfmem->start); | 1417 | debug("pfmem->start = %x\n", pfmem->start); |
1418 | 1418 | ||
1419 | ibmphp_remove_resource(pfmem); | 1419 | ibmphp_remove_resource(pfmem); |
1420 | } | 1420 | } |
1421 | } else { | 1421 | } else { |
1422 | /* regular memory */ | 1422 | /* regular memory */ |
1423 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; | 1423 | start_address &= PCI_BASE_ADDRESS_MEM_MASK; |
1424 | if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { | 1424 | if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) { |
1425 | err ("cannot find corresponding MEM resource to remove\n"); | 1425 | err("cannot find corresponding MEM resource to remove\n"); |
1426 | return -EINVAL; | 1426 | return -EINVAL; |
1427 | } | 1427 | } |
1428 | if (mem) { | 1428 | if (mem) { |
1429 | debug ("mem->start = %x\n", mem->start); | 1429 | debug("mem->start = %x\n", mem->start); |
1430 | 1430 | ||
1431 | ibmphp_remove_resource(mem); | 1431 | ibmphp_remove_resource(mem); |
1432 | } | 1432 | } |
@@ -1437,11 +1437,11 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) | |||
1437 | } | 1437 | } |
1438 | } /* end of mem */ | 1438 | } /* end of mem */ |
1439 | } /* end of for */ | 1439 | } /* end of for */ |
1440 | debug ("%s - exiting, returning success\n", __func__); | 1440 | debug("%s - exiting, returning success\n", __func__); |
1441 | return 0; | 1441 | return 0; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | static int unconfigure_boot_card (struct slot *slot_cur) | 1444 | static int unconfigure_boot_card(struct slot *slot_cur) |
1445 | { | 1445 | { |
1446 | u16 vendor_id; | 1446 | u16 vendor_id; |
1447 | u32 class; | 1447 | u32 class; |
@@ -1453,57 +1453,57 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1453 | unsigned int devfn; | 1453 | unsigned int devfn; |
1454 | u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ | 1454 | u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ |
1455 | 1455 | ||
1456 | debug ("%s - enter\n", __func__); | 1456 | debug("%s - enter\n", __func__); |
1457 | 1457 | ||
1458 | device = slot_cur->device; | 1458 | device = slot_cur->device; |
1459 | busno = slot_cur->bus; | 1459 | busno = slot_cur->bus; |
1460 | 1460 | ||
1461 | debug ("b4 for loop, device is %x\n", device); | 1461 | debug("b4 for loop, device is %x\n", device); |
1462 | /* For every function on the card */ | 1462 | /* For every function on the card */ |
1463 | for (function = 0x0; function < 0x08; function++) { | 1463 | for (function = 0x0; function < 0x08; function++) { |
1464 | devfn = PCI_DEVFN(device, function); | 1464 | devfn = PCI_DEVFN(device, function); |
1465 | ibmphp_pci_bus->number = busno; | 1465 | ibmphp_pci_bus->number = busno; |
1466 | 1466 | ||
1467 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 1467 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
1468 | 1468 | ||
1469 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 1469 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
1470 | /* found correct device!!! */ | 1470 | /* found correct device!!! */ |
1471 | ++valid_device; | 1471 | ++valid_device; |
1472 | 1472 | ||
1473 | debug ("%s - found correct device\n", __func__); | 1473 | debug("%s - found correct device\n", __func__); |
1474 | 1474 | ||
1475 | /* header: x x x x x x x x | 1475 | /* header: x x x x x x x x |
1476 | * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge | 1476 | * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge |
1477 | * |_=> 0 = single function device, 1 = multi-function device | 1477 | * |_=> 0 = single function device, 1 = multi-function device |
1478 | */ | 1478 | */ |
1479 | 1479 | ||
1480 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 1480 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
1481 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 1481 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
1482 | 1482 | ||
1483 | debug ("hdr_type %x, class %x\n", hdr_type, class); | 1483 | debug("hdr_type %x, class %x\n", hdr_type, class); |
1484 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ | 1484 | class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ |
1485 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { | 1485 | if (class == PCI_CLASS_NOT_DEFINED_VGA) { |
1486 | err ("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function); | 1486 | err("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function); |
1487 | return -ENODEV; | 1487 | return -ENODEV; |
1488 | } else if (class == PCI_CLASS_DISPLAY_VGA) { | 1488 | } else if (class == PCI_CLASS_DISPLAY_VGA) { |
1489 | err ("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function); | 1489 | err("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function); |
1490 | return -ENODEV; | 1490 | return -ENODEV; |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | switch (hdr_type) { | 1493 | switch (hdr_type) { |
1494 | case PCI_HEADER_TYPE_NORMAL: | 1494 | case PCI_HEADER_TYPE_NORMAL: |
1495 | rc = unconfigure_boot_device (busno, device, function); | 1495 | rc = unconfigure_boot_device(busno, device, function); |
1496 | if (rc) { | 1496 | if (rc) { |
1497 | err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", | 1497 | err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", |
1498 | device, function, busno); | 1498 | device, function, busno); |
1499 | return rc; | 1499 | return rc; |
1500 | } | 1500 | } |
1501 | function = 0x8; | 1501 | function = 0x8; |
1502 | break; | 1502 | break; |
1503 | case PCI_HEADER_TYPE_MULTIDEVICE: | 1503 | case PCI_HEADER_TYPE_MULTIDEVICE: |
1504 | rc = unconfigure_boot_device (busno, device, function); | 1504 | rc = unconfigure_boot_device(busno, device, function); |
1505 | if (rc) { | 1505 | if (rc) { |
1506 | err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", | 1506 | err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", |
1507 | device, function, busno); | 1507 | device, function, busno); |
1508 | return rc; | 1508 | return rc; |
1509 | } | 1509 | } |
@@ -1511,12 +1511,12 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1511 | case PCI_HEADER_TYPE_BRIDGE: | 1511 | case PCI_HEADER_TYPE_BRIDGE: |
1512 | class >>= 8; | 1512 | class >>= 8; |
1513 | if (class != PCI_CLASS_BRIDGE_PCI) { | 1513 | if (class != PCI_CLASS_BRIDGE_PCI) { |
1514 | err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); | 1514 | err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); |
1515 | return -ENODEV; | 1515 | return -ENODEV; |
1516 | } | 1516 | } |
1517 | rc = unconfigure_boot_bridge (busno, device, function); | 1517 | rc = unconfigure_boot_bridge(busno, device, function); |
1518 | if (rc != 0) { | 1518 | if (rc != 0) { |
1519 | err ("was not able to hot-remove PPB properly.\n"); | 1519 | err("was not able to hot-remove PPB properly.\n"); |
1520 | return rc; | 1520 | return rc; |
1521 | } | 1521 | } |
1522 | 1522 | ||
@@ -1525,17 +1525,17 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1525 | case PCI_HEADER_TYPE_MULTIBRIDGE: | 1525 | case PCI_HEADER_TYPE_MULTIBRIDGE: |
1526 | class >>= 8; | 1526 | class >>= 8; |
1527 | if (class != PCI_CLASS_BRIDGE_PCI) { | 1527 | if (class != PCI_CLASS_BRIDGE_PCI) { |
1528 | err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); | 1528 | err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); |
1529 | return -ENODEV; | 1529 | return -ENODEV; |
1530 | } | 1530 | } |
1531 | rc = unconfigure_boot_bridge (busno, device, function); | 1531 | rc = unconfigure_boot_bridge(busno, device, function); |
1532 | if (rc != 0) { | 1532 | if (rc != 0) { |
1533 | err ("was not able to hot-remove PPB properly.\n"); | 1533 | err("was not able to hot-remove PPB properly.\n"); |
1534 | return rc; | 1534 | return rc; |
1535 | } | 1535 | } |
1536 | break; | 1536 | break; |
1537 | default: | 1537 | default: |
1538 | err ("MAJOR PROBLEM!!!! Cannot read device's header\n"); | 1538 | err("MAJOR PROBLEM!!!! Cannot read device's header\n"); |
1539 | return -1; | 1539 | return -1; |
1540 | break; | 1540 | break; |
1541 | } /* end of switch */ | 1541 | } /* end of switch */ |
@@ -1543,7 +1543,7 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1543 | } /* end of for */ | 1543 | } /* end of for */ |
1544 | 1544 | ||
1545 | if (!valid_device) { | 1545 | if (!valid_device) { |
1546 | err ("Could not find device to unconfigure. Or could not read the card.\n"); | 1546 | err("Could not find device to unconfigure. Or could not read the card.\n"); |
1547 | return -1; | 1547 | return -1; |
1548 | } | 1548 | } |
1549 | return 0; | 1549 | return 0; |
@@ -1558,7 +1558,7 @@ static int unconfigure_boot_card (struct slot *slot_cur) | |||
1558 | * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! | 1558 | * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! |
1559 | * Returns: 0, -1, -ENODEV | 1559 | * Returns: 0, -1, -ENODEV |
1560 | */ | 1560 | */ |
1561 | int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | 1561 | int ibmphp_unconfigure_card(struct slot **slot_cur, int the_end) |
1562 | { | 1562 | { |
1563 | int i; | 1563 | int i; |
1564 | int count; | 1564 | int count; |
@@ -1567,11 +1567,11 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1567 | struct pci_func *cur_func = NULL; | 1567 | struct pci_func *cur_func = NULL; |
1568 | struct pci_func *temp_func; | 1568 | struct pci_func *temp_func; |
1569 | 1569 | ||
1570 | debug ("%s - enter\n", __func__); | 1570 | debug("%s - enter\n", __func__); |
1571 | 1571 | ||
1572 | if (!the_end) { | 1572 | if (!the_end) { |
1573 | /* Need to unconfigure the card */ | 1573 | /* Need to unconfigure the card */ |
1574 | rc = unconfigure_boot_card (sl); | 1574 | rc = unconfigure_boot_card(sl); |
1575 | if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) { | 1575 | if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) { |
1576 | /* In all other cases, will still need to get rid of func structure if it exists */ | 1576 | /* In all other cases, will still need to get rid of func structure if it exists */ |
1577 | return rc; | 1577 | return rc; |
@@ -1591,34 +1591,34 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1591 | 1591 | ||
1592 | for (i = 0; i < count; i++) { | 1592 | for (i = 0; i < count; i++) { |
1593 | if (cur_func->io[i]) { | 1593 | if (cur_func->io[i]) { |
1594 | debug ("io[%d] exists\n", i); | 1594 | debug("io[%d] exists\n", i); |
1595 | if (the_end > 0) | 1595 | if (the_end > 0) |
1596 | ibmphp_remove_resource (cur_func->io[i]); | 1596 | ibmphp_remove_resource(cur_func->io[i]); |
1597 | cur_func->io[i] = NULL; | 1597 | cur_func->io[i] = NULL; |
1598 | } | 1598 | } |
1599 | if (cur_func->mem[i]) { | 1599 | if (cur_func->mem[i]) { |
1600 | debug ("mem[%d] exists\n", i); | 1600 | debug("mem[%d] exists\n", i); |
1601 | if (the_end > 0) | 1601 | if (the_end > 0) |
1602 | ibmphp_remove_resource (cur_func->mem[i]); | 1602 | ibmphp_remove_resource(cur_func->mem[i]); |
1603 | cur_func->mem[i] = NULL; | 1603 | cur_func->mem[i] = NULL; |
1604 | } | 1604 | } |
1605 | if (cur_func->pfmem[i]) { | 1605 | if (cur_func->pfmem[i]) { |
1606 | debug ("pfmem[%d] exists\n", i); | 1606 | debug("pfmem[%d] exists\n", i); |
1607 | if (the_end > 0) | 1607 | if (the_end > 0) |
1608 | ibmphp_remove_resource (cur_func->pfmem[i]); | 1608 | ibmphp_remove_resource(cur_func->pfmem[i]); |
1609 | cur_func->pfmem[i] = NULL; | 1609 | cur_func->pfmem[i] = NULL; |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | temp_func = cur_func->next; | 1613 | temp_func = cur_func->next; |
1614 | kfree (cur_func); | 1614 | kfree(cur_func); |
1615 | cur_func = temp_func; | 1615 | cur_func = temp_func; |
1616 | } | 1616 | } |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | sl->func = NULL; | 1619 | sl->func = NULL; |
1620 | *slot_cur = sl; | 1620 | *slot_cur = sl; |
1621 | debug ("%s - exit\n", __func__); | 1621 | debug("%s - exit\n", __func__); |
1622 | return 0; | 1622 | return 0; |
1623 | } | 1623 | } |
1624 | 1624 | ||
@@ -1630,7 +1630,7 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) | |||
1630 | * Output: bus added to the correct spot | 1630 | * Output: bus added to the correct spot |
1631 | * 0, -1, error | 1631 | * 0, -1, error |
1632 | */ | 1632 | */ |
1633 | static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) | 1633 | static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) |
1634 | { | 1634 | { |
1635 | struct range_node *io_range = NULL; | 1635 | struct range_node *io_range = NULL; |
1636 | struct range_node *mem_range = NULL; | 1636 | struct range_node *mem_range = NULL; |
@@ -1639,18 +1639,18 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1639 | 1639 | ||
1640 | /* Trying to find the parent bus number */ | 1640 | /* Trying to find the parent bus number */ |
1641 | if (parent_busno != 0xFF) { | 1641 | if (parent_busno != 0xFF) { |
1642 | cur_bus = ibmphp_find_res_bus (parent_busno); | 1642 | cur_bus = ibmphp_find_res_bus(parent_busno); |
1643 | if (!cur_bus) { | 1643 | if (!cur_bus) { |
1644 | err ("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); | 1644 | err("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); |
1645 | return -ENODEV; | 1645 | return -ENODEV; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | list_add (&bus->bus_list, &cur_bus->bus_list); | 1648 | list_add(&bus->bus_list, &cur_bus->bus_list); |
1649 | } | 1649 | } |
1650 | if (io) { | 1650 | if (io) { |
1651 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); | 1651 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); |
1652 | if (!io_range) { | 1652 | if (!io_range) { |
1653 | err ("out of system memory\n"); | 1653 | err("out of system memory\n"); |
1654 | return -ENOMEM; | 1654 | return -ENOMEM; |
1655 | } | 1655 | } |
1656 | io_range->start = io->start; | 1656 | io_range->start = io->start; |
@@ -1662,7 +1662,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1662 | if (mem) { | 1662 | if (mem) { |
1663 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); | 1663 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); |
1664 | if (!mem_range) { | 1664 | if (!mem_range) { |
1665 | err ("out of system memory\n"); | 1665 | err("out of system memory\n"); |
1666 | return -ENOMEM; | 1666 | return -ENOMEM; |
1667 | } | 1667 | } |
1668 | mem_range->start = mem->start; | 1668 | mem_range->start = mem->start; |
@@ -1674,7 +1674,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1674 | if (pfmem) { | 1674 | if (pfmem) { |
1675 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); | 1675 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); |
1676 | if (!pfmem_range) { | 1676 | if (!pfmem_range) { |
1677 | err ("out of system memory\n"); | 1677 | err("out of system memory\n"); |
1678 | return -ENOMEM; | 1678 | return -ENOMEM; |
1679 | } | 1679 | } |
1680 | pfmem_range->start = pfmem->start; | 1680 | pfmem_range->start = pfmem->start; |
@@ -1691,27 +1691,27 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r | |||
1691 | * Parameters: bus_number of the primary bus | 1691 | * Parameters: bus_number of the primary bus |
1692 | * Returns: bus_number of the secondary bus or 0xff in case of failure | 1692 | * Returns: bus_number of the secondary bus or 0xff in case of failure |
1693 | */ | 1693 | */ |
1694 | static u8 find_sec_number (u8 primary_busno, u8 slotno) | 1694 | static u8 find_sec_number(u8 primary_busno, u8 slotno) |
1695 | { | 1695 | { |
1696 | int min, max; | 1696 | int min, max; |
1697 | u8 busno; | 1697 | u8 busno; |
1698 | struct bus_info *bus; | 1698 | struct bus_info *bus; |
1699 | struct bus_node *bus_cur; | 1699 | struct bus_node *bus_cur; |
1700 | 1700 | ||
1701 | bus = ibmphp_find_same_bus_num (primary_busno); | 1701 | bus = ibmphp_find_same_bus_num(primary_busno); |
1702 | if (!bus) { | 1702 | if (!bus) { |
1703 | err ("cannot get slot range of the bus from the BIOS\n"); | 1703 | err("cannot get slot range of the bus from the BIOS\n"); |
1704 | return 0xff; | 1704 | return 0xff; |
1705 | } | 1705 | } |
1706 | max = bus->slot_max; | 1706 | max = bus->slot_max; |
1707 | min = bus->slot_min; | 1707 | min = bus->slot_min; |
1708 | if ((slotno > max) || (slotno < min)) { | 1708 | if ((slotno > max) || (slotno < min)) { |
1709 | err ("got the wrong range\n"); | 1709 | err("got the wrong range\n"); |
1710 | return 0xff; | 1710 | return 0xff; |
1711 | } | 1711 | } |
1712 | busno = (u8) (slotno - (u8) min); | 1712 | busno = (u8) (slotno - (u8) min); |
1713 | busno += primary_busno + 0x01; | 1713 | busno += primary_busno + 0x01; |
1714 | bus_cur = ibmphp_find_res_bus (busno); | 1714 | bus_cur = ibmphp_find_res_bus(busno); |
1715 | /* either there is no such bus number, or there are no ranges, which | 1715 | /* either there is no such bus number, or there are no ranges, which |
1716 | * can only happen if we removed the bridged device in previous load | 1716 | * can only happen if we removed the bridged device in previous load |
1717 | * of the driver, and now only have the skeleton bus struct | 1717 | * of the driver, and now only have the skeleton bus struct |
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index f279060cf6e2..aee6e41001e1 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c | |||
@@ -36,28 +36,28 @@ | |||
36 | 36 | ||
37 | static int flags = 0; /* for testing */ | 37 | static int flags = 0; /* for testing */ |
38 | 38 | ||
39 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno); | 39 | static void update_resources(struct bus_node *bus_cur, int type, int rangeno); |
40 | static int once_over (void); | 40 | static int once_over(void); |
41 | static int remove_ranges (struct bus_node *, struct bus_node *); | 41 | static int remove_ranges(struct bus_node *, struct bus_node *); |
42 | static int update_bridge_ranges (struct bus_node **); | 42 | static int update_bridge_ranges(struct bus_node **); |
43 | static int add_bus_range (int type, struct range_node *, struct bus_node *); | 43 | static int add_bus_range(int type, struct range_node *, struct bus_node *); |
44 | static void fix_resources (struct bus_node *); | 44 | static void fix_resources(struct bus_node *); |
45 | static struct bus_node *find_bus_wprev (u8, struct bus_node **, u8); | 45 | static struct bus_node *find_bus_wprev(u8, struct bus_node **, u8); |
46 | 46 | ||
47 | static LIST_HEAD(gbuses); | 47 | static LIST_HEAD(gbuses); |
48 | 48 | ||
49 | static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc *curr, u8 busno, int flag) | 49 | static struct bus_node * __init alloc_error_bus(struct ebda_pci_rsrc *curr, u8 busno, int flag) |
50 | { | 50 | { |
51 | struct bus_node *newbus; | 51 | struct bus_node *newbus; |
52 | 52 | ||
53 | if (!(curr) && !(flag)) { | 53 | if (!(curr) && !(flag)) { |
54 | err ("NULL pointer passed\n"); | 54 | err("NULL pointer passed\n"); |
55 | return NULL; | 55 | return NULL; |
56 | } | 56 | } |
57 | 57 | ||
58 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); | 58 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
59 | if (!newbus) { | 59 | if (!newbus) { |
60 | err ("out of system memory\n"); | 60 | err("out of system memory\n"); |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
@@ -65,22 +65,22 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc *curr, u8 | |||
65 | newbus->busno = busno; | 65 | newbus->busno = busno; |
66 | else | 66 | else |
67 | newbus->busno = curr->bus_num; | 67 | newbus->busno = curr->bus_num; |
68 | list_add_tail (&newbus->bus_list, &gbuses); | 68 | list_add_tail(&newbus->bus_list, &gbuses); |
69 | return newbus; | 69 | return newbus; |
70 | } | 70 | } |
71 | 71 | ||
72 | static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc *curr) | 72 | static struct resource_node * __init alloc_resources(struct ebda_pci_rsrc *curr) |
73 | { | 73 | { |
74 | struct resource_node *rs; | 74 | struct resource_node *rs; |
75 | 75 | ||
76 | if (!curr) { | 76 | if (!curr) { |
77 | err ("NULL passed to allocate\n"); | 77 | err("NULL passed to allocate\n"); |
78 | return NULL; | 78 | return NULL; |
79 | } | 79 | } |
80 | 80 | ||
81 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 81 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
82 | if (!rs) { | 82 | if (!rs) { |
83 | err ("out of system memory\n"); | 83 | err("out of system memory\n"); |
84 | return NULL; | 84 | return NULL; |
85 | } | 85 | } |
86 | rs->busno = curr->bus_num; | 86 | rs->busno = curr->bus_num; |
@@ -91,7 +91,7 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc *curr | |||
91 | return rs; | 91 | return rs; |
92 | } | 92 | } |
93 | 93 | ||
94 | static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node **new_range, struct ebda_pci_rsrc *curr, int flag, u8 first_bus) | 94 | static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node **new_range, struct ebda_pci_rsrc *curr, int flag, u8 first_bus) |
95 | { | 95 | { |
96 | struct bus_node *newbus; | 96 | struct bus_node *newbus; |
97 | struct range_node *newrange; | 97 | struct range_node *newrange; |
@@ -100,7 +100,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
100 | if (first_bus) { | 100 | if (first_bus) { |
101 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); | 101 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
102 | if (!newbus) { | 102 | if (!newbus) { |
103 | err ("out of system memory.\n"); | 103 | err("out of system memory.\n"); |
104 | return -ENOMEM; | 104 | return -ENOMEM; |
105 | } | 105 | } |
106 | newbus->busno = curr->bus_num; | 106 | newbus->busno = curr->bus_num; |
@@ -122,8 +122,8 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
122 | newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 122 | newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
123 | if (!newrange) { | 123 | if (!newrange) { |
124 | if (first_bus) | 124 | if (first_bus) |
125 | kfree (newbus); | 125 | kfree(newbus); |
126 | err ("out of system memory\n"); | 126 | err("out of system memory\n"); |
127 | return -ENOMEM; | 127 | return -ENOMEM; |
128 | } | 128 | } |
129 | newrange->start = curr->start_addr; | 129 | newrange->start = curr->start_addr; |
@@ -133,8 +133,8 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
133 | newrange->rangeno = 1; | 133 | newrange->rangeno = 1; |
134 | else { | 134 | else { |
135 | /* need to insert our range */ | 135 | /* need to insert our range */ |
136 | add_bus_range (flag, newrange, newbus); | 136 | add_bus_range(flag, newrange, newbus); |
137 | debug ("%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, newrange->end); | 137 | debug("%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, newrange->end); |
138 | } | 138 | } |
139 | 139 | ||
140 | switch (flag) { | 140 | switch (flag) { |
@@ -143,9 +143,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
143 | if (first_bus) | 143 | if (first_bus) |
144 | newbus->noMemRanges = 1; | 144 | newbus->noMemRanges = 1; |
145 | else { | 145 | else { |
146 | debug ("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 146 | debug("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
147 | ++newbus->noMemRanges; | 147 | ++newbus->noMemRanges; |
148 | fix_resources (newbus); | 148 | fix_resources(newbus); |
149 | } | 149 | } |
150 | break; | 150 | break; |
151 | case IO: | 151 | case IO: |
@@ -153,9 +153,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
153 | if (first_bus) | 153 | if (first_bus) |
154 | newbus->noIORanges = 1; | 154 | newbus->noIORanges = 1; |
155 | else { | 155 | else { |
156 | debug ("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 156 | debug("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
157 | ++newbus->noIORanges; | 157 | ++newbus->noIORanges; |
158 | fix_resources (newbus); | 158 | fix_resources(newbus); |
159 | } | 159 | } |
160 | break; | 160 | break; |
161 | case PFMEM: | 161 | case PFMEM: |
@@ -163,9 +163,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
163 | if (first_bus) | 163 | if (first_bus) |
164 | newbus->noPFMemRanges = 1; | 164 | newbus->noPFMemRanges = 1; |
165 | else { | 165 | else { |
166 | debug ("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 166 | debug("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
167 | ++newbus->noPFMemRanges; | 167 | ++newbus->noPFMemRanges; |
168 | fix_resources (newbus); | 168 | fix_resources(newbus); |
169 | } | 169 | } |
170 | 170 | ||
171 | break; | 171 | break; |
@@ -183,7 +183,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
183 | * 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem | 183 | * 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem |
184 | * are not sorted. (no need since use mem node). To not change the entire code, we | 184 | * are not sorted. (no need since use mem node). To not change the entire code, we |
185 | * also add mem node whenever this case happens so as not to change | 185 | * also add mem node whenever this case happens so as not to change |
186 | * ibmphp_check_mem_resource etc (and since it really is taking Mem resource) | 186 | * ibmphp_check_mem_resource etc(and since it really is taking Mem resource) |
187 | */ | 187 | */ |
188 | 188 | ||
189 | /***************************************************************************** | 189 | /***************************************************************************** |
@@ -196,25 +196,23 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node | |||
196 | * Input: ptr to the head of the resource list from EBDA | 196 | * Input: ptr to the head of the resource list from EBDA |
197 | * Output: 0, -1 or error codes | 197 | * Output: 0, -1 or error codes |
198 | ***************************************************************************/ | 198 | ***************************************************************************/ |
199 | int __init ibmphp_rsrc_init (void) | 199 | int __init ibmphp_rsrc_init(void) |
200 | { | 200 | { |
201 | struct ebda_pci_rsrc *curr; | 201 | struct ebda_pci_rsrc *curr; |
202 | struct range_node *newrange = NULL; | 202 | struct range_node *newrange = NULL; |
203 | struct bus_node *newbus = NULL; | 203 | struct bus_node *newbus = NULL; |
204 | struct bus_node *bus_cur; | 204 | struct bus_node *bus_cur; |
205 | struct bus_node *bus_prev; | 205 | struct bus_node *bus_prev; |
206 | struct list_head *tmp; | ||
207 | struct resource_node *new_io = NULL; | 206 | struct resource_node *new_io = NULL; |
208 | struct resource_node *new_mem = NULL; | 207 | struct resource_node *new_mem = NULL; |
209 | struct resource_node *new_pfmem = NULL; | 208 | struct resource_node *new_pfmem = NULL; |
210 | int rc; | 209 | int rc; |
211 | struct list_head *tmp_ebda; | ||
212 | 210 | ||
213 | list_for_each (tmp_ebda, &ibmphp_ebda_pci_rsrc_head) { | 211 | list_for_each_entry(curr, &ibmphp_ebda_pci_rsrc_head, |
214 | curr = list_entry (tmp_ebda, struct ebda_pci_rsrc, ebda_pci_rsrc_list); | 212 | ebda_pci_rsrc_list) { |
215 | if (!(curr->rsrc_type & PCIDEVMASK)) { | 213 | if (!(curr->rsrc_type & PCIDEVMASK)) { |
216 | /* EBDA still lists non PCI devices, so ignore... */ | 214 | /* EBDA still lists non PCI devices, so ignore... */ |
217 | debug ("this is not a PCI DEVICE in rsrc_init, please take care\n"); | 215 | debug("this is not a PCI DEVICE in rsrc_init, please take care\n"); |
218 | // continue; | 216 | // continue; |
219 | } | 217 | } |
220 | 218 | ||
@@ -223,17 +221,17 @@ int __init ibmphp_rsrc_init (void) | |||
223 | /* memory */ | 221 | /* memory */ |
224 | if ((curr->rsrc_type & RESTYPE) == MMASK) { | 222 | if ((curr->rsrc_type & RESTYPE) == MMASK) { |
225 | /* no bus structure exists in place yet */ | 223 | /* no bus structure exists in place yet */ |
226 | if (list_empty (&gbuses)) { | 224 | if (list_empty(&gbuses)) { |
227 | rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); | 225 | rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); |
228 | if (rc) | 226 | if (rc) |
229 | return rc; | 227 | return rc; |
230 | list_add_tail (&newbus->bus_list, &gbuses); | 228 | list_add_tail(&newbus->bus_list, &gbuses); |
231 | debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 229 | debug("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
232 | } else { | 230 | } else { |
233 | bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); | 231 | bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); |
234 | /* found our bus */ | 232 | /* found our bus */ |
235 | if (bus_cur) { | 233 | if (bus_cur) { |
236 | rc = alloc_bus_range (&bus_cur, &newrange, curr, MEM, 0); | 234 | rc = alloc_bus_range(&bus_cur, &newrange, curr, MEM, 0); |
237 | if (rc) | 235 | if (rc) |
238 | return rc; | 236 | return rc; |
239 | } else { | 237 | } else { |
@@ -242,24 +240,24 @@ int __init ibmphp_rsrc_init (void) | |||
242 | if (rc) | 240 | if (rc) |
243 | return rc; | 241 | return rc; |
244 | 242 | ||
245 | list_add_tail (&newbus->bus_list, &gbuses); | 243 | list_add_tail(&newbus->bus_list, &gbuses); |
246 | debug ("New Bus, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 244 | debug("New Bus, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
247 | } | 245 | } |
248 | } | 246 | } |
249 | } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { | 247 | } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { |
250 | /* prefetchable memory */ | 248 | /* prefetchable memory */ |
251 | if (list_empty (&gbuses)) { | 249 | if (list_empty(&gbuses)) { |
252 | /* no bus structure exists in place yet */ | 250 | /* no bus structure exists in place yet */ |
253 | rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); | 251 | rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); |
254 | if (rc) | 252 | if (rc) |
255 | return rc; | 253 | return rc; |
256 | list_add_tail (&newbus->bus_list, &gbuses); | 254 | list_add_tail(&newbus->bus_list, &gbuses); |
257 | debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 255 | debug("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
258 | } else { | 256 | } else { |
259 | bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); | 257 | bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); |
260 | if (bus_cur) { | 258 | if (bus_cur) { |
261 | /* found our bus */ | 259 | /* found our bus */ |
262 | rc = alloc_bus_range (&bus_cur, &newrange, curr, PFMEM, 0); | 260 | rc = alloc_bus_range(&bus_cur, &newrange, curr, PFMEM, 0); |
263 | if (rc) | 261 | if (rc) |
264 | return rc; | 262 | return rc; |
265 | } else { | 263 | } else { |
@@ -267,23 +265,23 @@ int __init ibmphp_rsrc_init (void) | |||
267 | rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); | 265 | rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); |
268 | if (rc) | 266 | if (rc) |
269 | return rc; | 267 | return rc; |
270 | list_add_tail (&newbus->bus_list, &gbuses); | 268 | list_add_tail(&newbus->bus_list, &gbuses); |
271 | debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 269 | debug("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
272 | } | 270 | } |
273 | } | 271 | } |
274 | } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { | 272 | } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { |
275 | /* IO */ | 273 | /* IO */ |
276 | if (list_empty (&gbuses)) { | 274 | if (list_empty(&gbuses)) { |
277 | /* no bus structure exists in place yet */ | 275 | /* no bus structure exists in place yet */ |
278 | rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); | 276 | rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); |
279 | if (rc) | 277 | if (rc) |
280 | return rc; | 278 | return rc; |
281 | list_add_tail (&newbus->bus_list, &gbuses); | 279 | list_add_tail(&newbus->bus_list, &gbuses); |
282 | debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 280 | debug("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
283 | } else { | 281 | } else { |
284 | bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); | 282 | bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); |
285 | if (bus_cur) { | 283 | if (bus_cur) { |
286 | rc = alloc_bus_range (&bus_cur, &newrange, curr, IO, 0); | 284 | rc = alloc_bus_range(&bus_cur, &newrange, curr, IO, 0); |
287 | if (rc) | 285 | if (rc) |
288 | return rc; | 286 | return rc; |
289 | } else { | 287 | } else { |
@@ -291,8 +289,8 @@ int __init ibmphp_rsrc_init (void) | |||
291 | rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); | 289 | rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); |
292 | if (rc) | 290 | if (rc) |
293 | return rc; | 291 | return rc; |
294 | list_add_tail (&newbus->bus_list, &gbuses); | 292 | list_add_tail(&newbus->bus_list, &gbuses); |
295 | debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); | 293 | debug("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); |
296 | } | 294 | } |
297 | } | 295 | } |
298 | 296 | ||
@@ -304,7 +302,7 @@ int __init ibmphp_rsrc_init (void) | |||
304 | /* regular pci device resource */ | 302 | /* regular pci device resource */ |
305 | if ((curr->rsrc_type & RESTYPE) == MMASK) { | 303 | if ((curr->rsrc_type & RESTYPE) == MMASK) { |
306 | /* Memory resource */ | 304 | /* Memory resource */ |
307 | new_mem = alloc_resources (curr); | 305 | new_mem = alloc_resources(curr); |
308 | if (!new_mem) | 306 | if (!new_mem) |
309 | return -ENOMEM; | 307 | return -ENOMEM; |
310 | new_mem->type = MEM; | 308 | new_mem->type = MEM; |
@@ -315,25 +313,25 @@ int __init ibmphp_rsrc_init (void) | |||
315 | * assign a -1 and then update once the range | 313 | * assign a -1 and then update once the range |
316 | * actually appears... | 314 | * actually appears... |
317 | */ | 315 | */ |
318 | if (ibmphp_add_resource (new_mem) < 0) { | 316 | if (ibmphp_add_resource(new_mem) < 0) { |
319 | newbus = alloc_error_bus (curr, 0, 0); | 317 | newbus = alloc_error_bus(curr, 0, 0); |
320 | if (!newbus) | 318 | if (!newbus) |
321 | return -ENOMEM; | 319 | return -ENOMEM; |
322 | newbus->firstMem = new_mem; | 320 | newbus->firstMem = new_mem; |
323 | ++newbus->needMemUpdate; | 321 | ++newbus->needMemUpdate; |
324 | new_mem->rangeno = -1; | 322 | new_mem->rangeno = -1; |
325 | } | 323 | } |
326 | debug ("Memory resource for device %x, bus %x, [%x - %x]\n", new_mem->devfunc, new_mem->busno, new_mem->start, new_mem->end); | 324 | debug("Memory resource for device %x, bus %x, [%x - %x]\n", new_mem->devfunc, new_mem->busno, new_mem->start, new_mem->end); |
327 | 325 | ||
328 | } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { | 326 | } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { |
329 | /* PFMemory resource */ | 327 | /* PFMemory resource */ |
330 | new_pfmem = alloc_resources (curr); | 328 | new_pfmem = alloc_resources(curr); |
331 | if (!new_pfmem) | 329 | if (!new_pfmem) |
332 | return -ENOMEM; | 330 | return -ENOMEM; |
333 | new_pfmem->type = PFMEM; | 331 | new_pfmem->type = PFMEM; |
334 | new_pfmem->fromMem = 0; | 332 | new_pfmem->fromMem = 0; |
335 | if (ibmphp_add_resource (new_pfmem) < 0) { | 333 | if (ibmphp_add_resource(new_pfmem) < 0) { |
336 | newbus = alloc_error_bus (curr, 0, 0); | 334 | newbus = alloc_error_bus(curr, 0, 0); |
337 | if (!newbus) | 335 | if (!newbus) |
338 | return -ENOMEM; | 336 | return -ENOMEM; |
339 | newbus->firstPFMem = new_pfmem; | 337 | newbus->firstPFMem = new_pfmem; |
@@ -341,10 +339,10 @@ int __init ibmphp_rsrc_init (void) | |||
341 | new_pfmem->rangeno = -1; | 339 | new_pfmem->rangeno = -1; |
342 | } | 340 | } |
343 | 341 | ||
344 | debug ("PFMemory resource for device %x, bus %x, [%x - %x]\n", new_pfmem->devfunc, new_pfmem->busno, new_pfmem->start, new_pfmem->end); | 342 | debug("PFMemory resource for device %x, bus %x, [%x - %x]\n", new_pfmem->devfunc, new_pfmem->busno, new_pfmem->start, new_pfmem->end); |
345 | } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { | 343 | } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { |
346 | /* IO resource */ | 344 | /* IO resource */ |
347 | new_io = alloc_resources (curr); | 345 | new_io = alloc_resources(curr); |
348 | if (!new_io) | 346 | if (!new_io) |
349 | return -ENOMEM; | 347 | return -ENOMEM; |
350 | new_io->type = IO; | 348 | new_io->type = IO; |
@@ -356,27 +354,26 @@ int __init ibmphp_rsrc_init (void) | |||
356 | * Can assign a -1 and then update once the | 354 | * Can assign a -1 and then update once the |
357 | * range actually appears... | 355 | * range actually appears... |
358 | */ | 356 | */ |
359 | if (ibmphp_add_resource (new_io) < 0) { | 357 | if (ibmphp_add_resource(new_io) < 0) { |
360 | newbus = alloc_error_bus (curr, 0, 0); | 358 | newbus = alloc_error_bus(curr, 0, 0); |
361 | if (!newbus) | 359 | if (!newbus) |
362 | return -ENOMEM; | 360 | return -ENOMEM; |
363 | newbus->firstIO = new_io; | 361 | newbus->firstIO = new_io; |
364 | ++newbus->needIOUpdate; | 362 | ++newbus->needIOUpdate; |
365 | new_io->rangeno = -1; | 363 | new_io->rangeno = -1; |
366 | } | 364 | } |
367 | debug ("IO resource for device %x, bus %x, [%x - %x]\n", new_io->devfunc, new_io->busno, new_io->start, new_io->end); | 365 | debug("IO resource for device %x, bus %x, [%x - %x]\n", new_io->devfunc, new_io->busno, new_io->start, new_io->end); |
368 | } | 366 | } |
369 | } | 367 | } |
370 | } | 368 | } |
371 | 369 | ||
372 | list_for_each (tmp, &gbuses) { | 370 | list_for_each_entry(bus_cur, &gbuses, bus_list) { |
373 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | ||
374 | /* This is to get info about PPB resources, since EBDA doesn't put this info into the primary bus info */ | 371 | /* This is to get info about PPB resources, since EBDA doesn't put this info into the primary bus info */ |
375 | rc = update_bridge_ranges (&bus_cur); | 372 | rc = update_bridge_ranges(&bus_cur); |
376 | if (rc) | 373 | if (rc) |
377 | return rc; | 374 | return rc; |
378 | } | 375 | } |
379 | return once_over (); /* This is to align ranges (so no -1) */ | 376 | return once_over(); /* This is to align ranges (so no -1) */ |
380 | } | 377 | } |
381 | 378 | ||
382 | /******************************************************************************** | 379 | /******************************************************************************** |
@@ -387,7 +384,7 @@ int __init ibmphp_rsrc_init (void) | |||
387 | * Input: type of the resource, range to add, current bus | 384 | * Input: type of the resource, range to add, current bus |
388 | * Output: 0 or -1, bus and range ptrs | 385 | * Output: 0 or -1, bus and range ptrs |
389 | ********************************************************************************/ | 386 | ********************************************************************************/ |
390 | static int add_bus_range (int type, struct range_node *range, struct bus_node *bus_cur) | 387 | static int add_bus_range(int type, struct range_node *range, struct bus_node *bus_cur) |
391 | { | 388 | { |
392 | struct range_node *range_cur = NULL; | 389 | struct range_node *range_cur = NULL; |
393 | struct range_node *range_prev; | 390 | struct range_node *range_prev; |
@@ -452,7 +449,7 @@ static int add_bus_range (int type, struct range_node *range, struct bus_node *b | |||
452 | range_cur = range_cur->next; | 449 | range_cur = range_cur->next; |
453 | } | 450 | } |
454 | 451 | ||
455 | update_resources (bus_cur, type, i_init + 1); | 452 | update_resources(bus_cur, type, i_init + 1); |
456 | return 0; | 453 | return 0; |
457 | } | 454 | } |
458 | 455 | ||
@@ -462,7 +459,7 @@ static int add_bus_range (int type, struct range_node *range, struct bus_node *b | |||
462 | * | 459 | * |
463 | * Input: bus, type of the resource, the rangeno starting from which to update | 460 | * Input: bus, type of the resource, the rangeno starting from which to update |
464 | ******************************************************************************/ | 461 | ******************************************************************************/ |
465 | static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | 462 | static void update_resources(struct bus_node *bus_cur, int type, int rangeno) |
466 | { | 463 | { |
467 | struct resource_node *res = NULL; | 464 | struct resource_node *res = NULL; |
468 | u8 eol = 0; /* end of list indicator */ | 465 | u8 eol = 0; /* end of list indicator */ |
@@ -506,9 +503,9 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno) | |||
506 | } | 503 | } |
507 | } | 504 | } |
508 | 505 | ||
509 | static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct range_node *range) | 506 | static void fix_me(struct resource_node *res, struct bus_node *bus_cur, struct range_node *range) |
510 | { | 507 | { |
511 | char * str = ""; | 508 | char *str = ""; |
512 | switch (res->type) { | 509 | switch (res->type) { |
513 | case IO: | 510 | case IO: |
514 | str = "io"; | 511 | str = "io"; |
@@ -526,7 +523,7 @@ static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct | |||
526 | while (range) { | 523 | while (range) { |
527 | if ((res->start >= range->start) && (res->end <= range->end)) { | 524 | if ((res->start >= range->start) && (res->end <= range->end)) { |
528 | res->rangeno = range->rangeno; | 525 | res->rangeno = range->rangeno; |
529 | debug ("%s->rangeno in fix_resources is %d\n", str, res->rangeno); | 526 | debug("%s->rangeno in fix_resources is %d\n", str, res->rangeno); |
530 | switch (res->type) { | 527 | switch (res->type) { |
531 | case IO: | 528 | case IO: |
532 | --bus_cur->needIOUpdate; | 529 | --bus_cur->needIOUpdate; |
@@ -561,27 +558,27 @@ static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct | |||
561 | * Input: current bus | 558 | * Input: current bus |
562 | * Output: none, list of resources for that bus are fixed if can be | 559 | * Output: none, list of resources for that bus are fixed if can be |
563 | *******************************************************************************/ | 560 | *******************************************************************************/ |
564 | static void fix_resources (struct bus_node *bus_cur) | 561 | static void fix_resources(struct bus_node *bus_cur) |
565 | { | 562 | { |
566 | struct range_node *range; | 563 | struct range_node *range; |
567 | struct resource_node *res; | 564 | struct resource_node *res; |
568 | 565 | ||
569 | debug ("%s - bus_cur->busno = %d\n", __func__, bus_cur->busno); | 566 | debug("%s - bus_cur->busno = %d\n", __func__, bus_cur->busno); |
570 | 567 | ||
571 | if (bus_cur->needIOUpdate) { | 568 | if (bus_cur->needIOUpdate) { |
572 | res = bus_cur->firstIO; | 569 | res = bus_cur->firstIO; |
573 | range = bus_cur->rangeIO; | 570 | range = bus_cur->rangeIO; |
574 | fix_me (res, bus_cur, range); | 571 | fix_me(res, bus_cur, range); |
575 | } | 572 | } |
576 | if (bus_cur->needMemUpdate) { | 573 | if (bus_cur->needMemUpdate) { |
577 | res = bus_cur->firstMem; | 574 | res = bus_cur->firstMem; |
578 | range = bus_cur->rangeMem; | 575 | range = bus_cur->rangeMem; |
579 | fix_me (res, bus_cur, range); | 576 | fix_me(res, bus_cur, range); |
580 | } | 577 | } |
581 | if (bus_cur->needPFMemUpdate) { | 578 | if (bus_cur->needPFMemUpdate) { |
582 | res = bus_cur->firstPFMem; | 579 | res = bus_cur->firstPFMem; |
583 | range = bus_cur->rangePFMem; | 580 | range = bus_cur->rangePFMem; |
584 | fix_me (res, bus_cur, range); | 581 | fix_me(res, bus_cur, range); |
585 | } | 582 | } |
586 | } | 583 | } |
587 | 584 | ||
@@ -594,7 +591,7 @@ static void fix_resources (struct bus_node *bus_cur) | |||
594 | * Output: ptrs assigned (to the node) | 591 | * Output: ptrs assigned (to the node) |
595 | * 0 or -1 | 592 | * 0 or -1 |
596 | *******************************************************************************/ | 593 | *******************************************************************************/ |
597 | int ibmphp_add_resource (struct resource_node *res) | 594 | int ibmphp_add_resource(struct resource_node *res) |
598 | { | 595 | { |
599 | struct resource_node *res_cur; | 596 | struct resource_node *res_cur; |
600 | struct resource_node *res_prev; | 597 | struct resource_node *res_prev; |
@@ -602,18 +599,18 @@ int ibmphp_add_resource (struct resource_node *res) | |||
602 | struct range_node *range_cur = NULL; | 599 | struct range_node *range_cur = NULL; |
603 | struct resource_node *res_start = NULL; | 600 | struct resource_node *res_start = NULL; |
604 | 601 | ||
605 | debug ("%s - enter\n", __func__); | 602 | debug("%s - enter\n", __func__); |
606 | 603 | ||
607 | if (!res) { | 604 | if (!res) { |
608 | err ("NULL passed to add\n"); | 605 | err("NULL passed to add\n"); |
609 | return -ENODEV; | 606 | return -ENODEV; |
610 | } | 607 | } |
611 | 608 | ||
612 | bus_cur = find_bus_wprev (res->busno, NULL, 0); | 609 | bus_cur = find_bus_wprev(res->busno, NULL, 0); |
613 | 610 | ||
614 | if (!bus_cur) { | 611 | if (!bus_cur) { |
615 | /* didn't find a bus, something's wrong!!! */ | 612 | /* didn't find a bus, something's wrong!!! */ |
616 | debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); | 613 | debug("no bus in the system, either pci_dev's wrong or allocation failed\n"); |
617 | return -ENODEV; | 614 | return -ENODEV; |
618 | } | 615 | } |
619 | 616 | ||
@@ -632,7 +629,7 @@ int ibmphp_add_resource (struct resource_node *res) | |||
632 | res_start = bus_cur->firstPFMem; | 629 | res_start = bus_cur->firstPFMem; |
633 | break; | 630 | break; |
634 | default: | 631 | default: |
635 | err ("cannot read the type of the resource to add... problem\n"); | 632 | err("cannot read the type of the resource to add... problem\n"); |
636 | return -EINVAL; | 633 | return -EINVAL; |
637 | } | 634 | } |
638 | while (range_cur) { | 635 | while (range_cur) { |
@@ -663,7 +660,7 @@ int ibmphp_add_resource (struct resource_node *res) | |||
663 | res->rangeno = -1; | 660 | res->rangeno = -1; |
664 | } | 661 | } |
665 | 662 | ||
666 | debug ("The range is %d\n", res->rangeno); | 663 | debug("The range is %d\n", res->rangeno); |
667 | if (!res_start) { | 664 | if (!res_start) { |
668 | /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */ | 665 | /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */ |
669 | switch (res->type) { | 666 | switch (res->type) { |
@@ -683,7 +680,7 @@ int ibmphp_add_resource (struct resource_node *res) | |||
683 | res_cur = res_start; | 680 | res_cur = res_start; |
684 | res_prev = NULL; | 681 | res_prev = NULL; |
685 | 682 | ||
686 | debug ("res_cur->rangeno is %d\n", res_cur->rangeno); | 683 | debug("res_cur->rangeno is %d\n", res_cur->rangeno); |
687 | 684 | ||
688 | while (res_cur) { | 685 | while (res_cur) { |
689 | if (res_cur->rangeno >= res->rangeno) | 686 | if (res_cur->rangeno >= res->rangeno) |
@@ -697,7 +694,7 @@ int ibmphp_add_resource (struct resource_node *res) | |||
697 | 694 | ||
698 | if (!res_cur) { | 695 | if (!res_cur) { |
699 | /* at the end of the resource list */ | 696 | /* at the end of the resource list */ |
700 | debug ("i should be here, [%x - %x]\n", res->start, res->end); | 697 | debug("i should be here, [%x - %x]\n", res->start, res->end); |
701 | res_prev->nextRange = res; | 698 | res_prev->nextRange = res; |
702 | res->next = NULL; | 699 | res->next = NULL; |
703 | res->nextRange = NULL; | 700 | res->nextRange = NULL; |
@@ -765,7 +762,7 @@ int ibmphp_add_resource (struct resource_node *res) | |||
765 | } | 762 | } |
766 | } | 763 | } |
767 | 764 | ||
768 | debug ("%s - exit\n", __func__); | 765 | debug("%s - exit\n", __func__); |
769 | return 0; | 766 | return 0; |
770 | } | 767 | } |
771 | 768 | ||
@@ -776,23 +773,23 @@ int ibmphp_add_resource (struct resource_node *res) | |||
776 | * Output: modified resource list | 773 | * Output: modified resource list |
777 | * 0 or error code | 774 | * 0 or error code |
778 | ****************************************************************************/ | 775 | ****************************************************************************/ |
779 | int ibmphp_remove_resource (struct resource_node *res) | 776 | int ibmphp_remove_resource(struct resource_node *res) |
780 | { | 777 | { |
781 | struct bus_node *bus_cur; | 778 | struct bus_node *bus_cur; |
782 | struct resource_node *res_cur = NULL; | 779 | struct resource_node *res_cur = NULL; |
783 | struct resource_node *res_prev; | 780 | struct resource_node *res_prev; |
784 | struct resource_node *mem_cur; | 781 | struct resource_node *mem_cur; |
785 | char * type = ""; | 782 | char *type = ""; |
786 | 783 | ||
787 | if (!res) { | 784 | if (!res) { |
788 | err ("resource to remove is NULL\n"); | 785 | err("resource to remove is NULL\n"); |
789 | return -ENODEV; | 786 | return -ENODEV; |
790 | } | 787 | } |
791 | 788 | ||
792 | bus_cur = find_bus_wprev (res->busno, NULL, 0); | 789 | bus_cur = find_bus_wprev(res->busno, NULL, 0); |
793 | 790 | ||
794 | if (!bus_cur) { | 791 | if (!bus_cur) { |
795 | err ("cannot find corresponding bus of the io resource to remove bailing out...\n"); | 792 | err("cannot find corresponding bus of the io resource to remove bailing out...\n"); |
796 | return -ENODEV; | 793 | return -ENODEV; |
797 | } | 794 | } |
798 | 795 | ||
@@ -810,7 +807,7 @@ int ibmphp_remove_resource (struct resource_node *res) | |||
810 | type = "pfmem"; | 807 | type = "pfmem"; |
811 | break; | 808 | break; |
812 | default: | 809 | default: |
813 | err ("unknown type for resource to remove\n"); | 810 | err("unknown type for resource to remove\n"); |
814 | return -EINVAL; | 811 | return -EINVAL; |
815 | } | 812 | } |
816 | res_prev = NULL; | 813 | res_prev = NULL; |
@@ -848,16 +845,16 @@ int ibmphp_remove_resource (struct resource_node *res) | |||
848 | mem_cur = mem_cur->nextRange; | 845 | mem_cur = mem_cur->nextRange; |
849 | } | 846 | } |
850 | if (!mem_cur) { | 847 | if (!mem_cur) { |
851 | err ("cannot find corresponding mem node for pfmem...\n"); | 848 | err("cannot find corresponding mem node for pfmem...\n"); |
852 | return -EINVAL; | 849 | return -EINVAL; |
853 | } | 850 | } |
854 | 851 | ||
855 | ibmphp_remove_resource (mem_cur); | 852 | ibmphp_remove_resource(mem_cur); |
856 | if (!res_prev) | 853 | if (!res_prev) |
857 | bus_cur->firstPFMemFromMem = res_cur->next; | 854 | bus_cur->firstPFMemFromMem = res_cur->next; |
858 | else | 855 | else |
859 | res_prev->next = res_cur->next; | 856 | res_prev->next = res_cur->next; |
860 | kfree (res_cur); | 857 | kfree(res_cur); |
861 | return 0; | 858 | return 0; |
862 | } | 859 | } |
863 | res_prev = res_cur; | 860 | res_prev = res_cur; |
@@ -867,11 +864,11 @@ int ibmphp_remove_resource (struct resource_node *res) | |||
867 | res_cur = res_cur->nextRange; | 864 | res_cur = res_cur->nextRange; |
868 | } | 865 | } |
869 | if (!res_cur) { | 866 | if (!res_cur) { |
870 | err ("cannot find pfmem to delete...\n"); | 867 | err("cannot find pfmem to delete...\n"); |
871 | return -EINVAL; | 868 | return -EINVAL; |
872 | } | 869 | } |
873 | } else { | 870 | } else { |
874 | err ("the %s resource is not in the list to be deleted...\n", type); | 871 | err("the %s resource is not in the list to be deleted...\n", type); |
875 | return -EINVAL; | 872 | return -EINVAL; |
876 | } | 873 | } |
877 | } | 874 | } |
@@ -914,7 +911,7 @@ int ibmphp_remove_resource (struct resource_node *res) | |||
914 | break; | 911 | break; |
915 | } | 912 | } |
916 | } | 913 | } |
917 | kfree (res_cur); | 914 | kfree(res_cur); |
918 | return 0; | 915 | return 0; |
919 | } else { | 916 | } else { |
920 | if (res_cur->next) { | 917 | if (res_cur->next) { |
@@ -929,14 +926,14 @@ int ibmphp_remove_resource (struct resource_node *res) | |||
929 | res_prev->next = NULL; | 926 | res_prev->next = NULL; |
930 | res_prev->nextRange = NULL; | 927 | res_prev->nextRange = NULL; |
931 | } | 928 | } |
932 | kfree (res_cur); | 929 | kfree(res_cur); |
933 | return 0; | 930 | return 0; |
934 | } | 931 | } |
935 | 932 | ||
936 | return 0; | 933 | return 0; |
937 | } | 934 | } |
938 | 935 | ||
939 | static struct range_node *find_range (struct bus_node *bus_cur, struct resource_node *res) | 936 | static struct range_node *find_range(struct bus_node *bus_cur, struct resource_node *res) |
940 | { | 937 | { |
941 | struct range_node *range = NULL; | 938 | struct range_node *range = NULL; |
942 | 939 | ||
@@ -951,7 +948,7 @@ static struct range_node *find_range (struct bus_node *bus_cur, struct resource_ | |||
951 | range = bus_cur->rangePFMem; | 948 | range = bus_cur->rangePFMem; |
952 | break; | 949 | break; |
953 | default: | 950 | default: |
954 | err ("cannot read resource type in find_range\n"); | 951 | err("cannot read resource type in find_range\n"); |
955 | } | 952 | } |
956 | 953 | ||
957 | while (range) { | 954 | while (range) { |
@@ -971,7 +968,7 @@ static struct range_node *find_range (struct bus_node *bus_cur, struct resource_ | |||
971 | * Output: the correct start and end address are inputted into the resource node, | 968 | * Output: the correct start and end address are inputted into the resource node, |
972 | * 0 or -EINVAL | 969 | * 0 or -EINVAL |
973 | *****************************************************************************/ | 970 | *****************************************************************************/ |
974 | int ibmphp_check_resource (struct resource_node *res, u8 bridge) | 971 | int ibmphp_check_resource(struct resource_node *res, u8 bridge) |
975 | { | 972 | { |
976 | struct bus_node *bus_cur; | 973 | struct bus_node *bus_cur; |
977 | struct range_node *range = NULL; | 974 | struct range_node *range = NULL; |
@@ -995,16 +992,16 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
995 | } else | 992 | } else |
996 | tmp_divide = res->len; | 993 | tmp_divide = res->len; |
997 | 994 | ||
998 | bus_cur = find_bus_wprev (res->busno, NULL, 0); | 995 | bus_cur = find_bus_wprev(res->busno, NULL, 0); |
999 | 996 | ||
1000 | if (!bus_cur) { | 997 | if (!bus_cur) { |
1001 | /* didn't find a bus, something's wrong!!! */ | 998 | /* didn't find a bus, something's wrong!!! */ |
1002 | debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); | 999 | debug("no bus in the system, either pci_dev's wrong or allocation failed\n"); |
1003 | return -EINVAL; | 1000 | return -EINVAL; |
1004 | } | 1001 | } |
1005 | 1002 | ||
1006 | debug ("%s - enter\n", __func__); | 1003 | debug("%s - enter\n", __func__); |
1007 | debug ("bus_cur->busno is %d\n", bus_cur->busno); | 1004 | debug("bus_cur->busno is %d\n", bus_cur->busno); |
1008 | 1005 | ||
1009 | /* This is a quick fix to not mess up with the code very much. i.e., | 1006 | /* This is a quick fix to not mess up with the code very much. i.e., |
1010 | * 2000-2fff, len = 1000, but when we compare, we need it to be fff */ | 1007 | * 2000-2fff, len = 1000, but when we compare, we need it to be fff */ |
@@ -1024,17 +1021,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1024 | noranges = bus_cur->noPFMemRanges; | 1021 | noranges = bus_cur->noPFMemRanges; |
1025 | break; | 1022 | break; |
1026 | default: | 1023 | default: |
1027 | err ("wrong type of resource to check\n"); | 1024 | err("wrong type of resource to check\n"); |
1028 | return -EINVAL; | 1025 | return -EINVAL; |
1029 | } | 1026 | } |
1030 | res_prev = NULL; | 1027 | res_prev = NULL; |
1031 | 1028 | ||
1032 | while (res_cur) { | 1029 | while (res_cur) { |
1033 | range = find_range (bus_cur, res_cur); | 1030 | range = find_range(bus_cur, res_cur); |
1034 | debug ("%s - rangeno = %d\n", __func__, res_cur->rangeno); | 1031 | debug("%s - rangeno = %d\n", __func__, res_cur->rangeno); |
1035 | 1032 | ||
1036 | if (!range) { | 1033 | if (!range) { |
1037 | err ("no range for the device exists... bailing out...\n"); | 1034 | err("no range for the device exists... bailing out...\n"); |
1038 | return -EINVAL; | 1035 | return -EINVAL; |
1039 | } | 1036 | } |
1040 | 1037 | ||
@@ -1044,7 +1041,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1044 | len_tmp = res_cur->start - 1 - range->start; | 1041 | len_tmp = res_cur->start - 1 - range->start; |
1045 | 1042 | ||
1046 | if ((res_cur->start != range->start) && (len_tmp >= res->len)) { | 1043 | if ((res_cur->start != range->start) && (len_tmp >= res->len)) { |
1047 | debug ("len_tmp = %x\n", len_tmp); | 1044 | debug("len_tmp = %x\n", len_tmp); |
1048 | 1045 | ||
1049 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1046 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1050 | 1047 | ||
@@ -1072,7 +1069,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1072 | } | 1069 | } |
1073 | 1070 | ||
1074 | if (flag && len_cur == res->len) { | 1071 | if (flag && len_cur == res->len) { |
1075 | debug ("but we are not here, right?\n"); | 1072 | debug("but we are not here, right?\n"); |
1076 | res->start = start_cur; | 1073 | res->start = start_cur; |
1077 | res->len += 1; /* To restore the balance */ | 1074 | res->len += 1; /* To restore the balance */ |
1078 | res->end = res->start + res->len - 1; | 1075 | res->end = res->start + res->len - 1; |
@@ -1086,7 +1083,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1086 | len_tmp = range->end - (res_cur->end + 1); | 1083 | len_tmp = range->end - (res_cur->end + 1); |
1087 | 1084 | ||
1088 | if ((range->end != res_cur->end) && (len_tmp >= res->len)) { | 1085 | if ((range->end != res_cur->end) && (len_tmp >= res->len)) { |
1089 | debug ("len_tmp = %x\n", len_tmp); | 1086 | debug("len_tmp = %x\n", len_tmp); |
1090 | if ((len_tmp < len_cur) || (len_cur == 0)) { | 1087 | if ((len_tmp < len_cur) || (len_cur == 0)) { |
1091 | 1088 | ||
1092 | if (((res_cur->end + 1) % tmp_divide) == 0) { | 1089 | if (((res_cur->end + 1) % tmp_divide) == 0) { |
@@ -1262,7 +1259,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1262 | 1259 | ||
1263 | if ((!range) && (len_cur == 0)) { | 1260 | if ((!range) && (len_cur == 0)) { |
1264 | /* have gone through the list of devices and ranges and haven't found n.e.thing */ | 1261 | /* have gone through the list of devices and ranges and haven't found n.e.thing */ |
1265 | err ("no appropriate range.. bailing out...\n"); | 1262 | err("no appropriate range.. bailing out...\n"); |
1266 | return -EINVAL; | 1263 | return -EINVAL; |
1267 | } else if (len_cur) { | 1264 | } else if (len_cur) { |
1268 | res->start = start_cur; | 1265 | res->start = start_cur; |
@@ -1273,7 +1270,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1273 | } | 1270 | } |
1274 | 1271 | ||
1275 | if (!res_cur) { | 1272 | if (!res_cur) { |
1276 | debug ("prev->rangeno = %d, noranges = %d\n", res_prev->rangeno, noranges); | 1273 | debug("prev->rangeno = %d, noranges = %d\n", res_prev->rangeno, noranges); |
1277 | if (res_prev->rangeno < noranges) { | 1274 | if (res_prev->rangeno < noranges) { |
1278 | /* if there're more ranges out there to check */ | 1275 | /* if there're more ranges out there to check */ |
1279 | switch (res->type) { | 1276 | switch (res->type) { |
@@ -1328,7 +1325,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1328 | 1325 | ||
1329 | if ((!range) && (len_cur == 0)) { | 1326 | if ((!range) && (len_cur == 0)) { |
1330 | /* have gone through the list of devices and ranges and haven't found n.e.thing */ | 1327 | /* have gone through the list of devices and ranges and haven't found n.e.thing */ |
1331 | err ("no appropriate range.. bailing out...\n"); | 1328 | err("no appropriate range.. bailing out...\n"); |
1332 | return -EINVAL; | 1329 | return -EINVAL; |
1333 | } else if (len_cur) { | 1330 | } else if (len_cur) { |
1334 | res->start = start_cur; | 1331 | res->start = start_cur; |
@@ -1345,7 +1342,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1345 | return 0; | 1342 | return 0; |
1346 | } else { | 1343 | } else { |
1347 | /* have gone through the list of devices and haven't found n.e.thing */ | 1344 | /* have gone through the list of devices and haven't found n.e.thing */ |
1348 | err ("no appropriate range.. bailing out...\n"); | 1345 | err("no appropriate range.. bailing out...\n"); |
1349 | return -EINVAL; | 1346 | return -EINVAL; |
1350 | } | 1347 | } |
1351 | } | 1348 | } |
@@ -1359,23 +1356,23 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge) | |||
1359 | * Input: Bus | 1356 | * Input: Bus |
1360 | * Output: 0, -ENODEV | 1357 | * Output: 0, -ENODEV |
1361 | ********************************************************************************/ | 1358 | ********************************************************************************/ |
1362 | int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | 1359 | int ibmphp_remove_bus(struct bus_node *bus, u8 parent_busno) |
1363 | { | 1360 | { |
1364 | struct resource_node *res_cur; | 1361 | struct resource_node *res_cur; |
1365 | struct resource_node *res_tmp; | 1362 | struct resource_node *res_tmp; |
1366 | struct bus_node *prev_bus; | 1363 | struct bus_node *prev_bus; |
1367 | int rc; | 1364 | int rc; |
1368 | 1365 | ||
1369 | prev_bus = find_bus_wprev (parent_busno, NULL, 0); | 1366 | prev_bus = find_bus_wprev(parent_busno, NULL, 0); |
1370 | 1367 | ||
1371 | if (!prev_bus) { | 1368 | if (!prev_bus) { |
1372 | debug ("something terribly wrong. Cannot find parent bus to the one to remove\n"); | 1369 | debug("something terribly wrong. Cannot find parent bus to the one to remove\n"); |
1373 | return -ENODEV; | 1370 | return -ENODEV; |
1374 | } | 1371 | } |
1375 | 1372 | ||
1376 | debug ("In ibmphp_remove_bus... prev_bus->busno is %x\n", prev_bus->busno); | 1373 | debug("In ibmphp_remove_bus... prev_bus->busno is %x\n", prev_bus->busno); |
1377 | 1374 | ||
1378 | rc = remove_ranges (bus, prev_bus); | 1375 | rc = remove_ranges(bus, prev_bus); |
1379 | if (rc) | 1376 | if (rc) |
1380 | return rc; | 1377 | return rc; |
1381 | 1378 | ||
@@ -1387,7 +1384,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | |||
1387 | res_cur = res_cur->next; | 1384 | res_cur = res_cur->next; |
1388 | else | 1385 | else |
1389 | res_cur = res_cur->nextRange; | 1386 | res_cur = res_cur->nextRange; |
1390 | kfree (res_tmp); | 1387 | kfree(res_tmp); |
1391 | res_tmp = NULL; | 1388 | res_tmp = NULL; |
1392 | } | 1389 | } |
1393 | bus->firstIO = NULL; | 1390 | bus->firstIO = NULL; |
@@ -1400,7 +1397,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | |||
1400 | res_cur = res_cur->next; | 1397 | res_cur = res_cur->next; |
1401 | else | 1398 | else |
1402 | res_cur = res_cur->nextRange; | 1399 | res_cur = res_cur->nextRange; |
1403 | kfree (res_tmp); | 1400 | kfree(res_tmp); |
1404 | res_tmp = NULL; | 1401 | res_tmp = NULL; |
1405 | } | 1402 | } |
1406 | bus->firstMem = NULL; | 1403 | bus->firstMem = NULL; |
@@ -1413,7 +1410,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | |||
1413 | res_cur = res_cur->next; | 1410 | res_cur = res_cur->next; |
1414 | else | 1411 | else |
1415 | res_cur = res_cur->nextRange; | 1412 | res_cur = res_cur->nextRange; |
1416 | kfree (res_tmp); | 1413 | kfree(res_tmp); |
1417 | res_tmp = NULL; | 1414 | res_tmp = NULL; |
1418 | } | 1415 | } |
1419 | bus->firstPFMem = NULL; | 1416 | bus->firstPFMem = NULL; |
@@ -1425,14 +1422,14 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | |||
1425 | res_tmp = res_cur; | 1422 | res_tmp = res_cur; |
1426 | res_cur = res_cur->next; | 1423 | res_cur = res_cur->next; |
1427 | 1424 | ||
1428 | kfree (res_tmp); | 1425 | kfree(res_tmp); |
1429 | res_tmp = NULL; | 1426 | res_tmp = NULL; |
1430 | } | 1427 | } |
1431 | bus->firstPFMemFromMem = NULL; | 1428 | bus->firstPFMemFromMem = NULL; |
1432 | } | 1429 | } |
1433 | 1430 | ||
1434 | list_del (&bus->bus_list); | 1431 | list_del(&bus->bus_list); |
1435 | kfree (bus); | 1432 | kfree(bus); |
1436 | return 0; | 1433 | return 0; |
1437 | } | 1434 | } |
1438 | 1435 | ||
@@ -1442,7 +1439,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) | |||
1442 | * Input: current bus, previous bus | 1439 | * Input: current bus, previous bus |
1443 | * Output: 0, -EINVAL | 1440 | * Output: 0, -EINVAL |
1444 | ******************************************************************************/ | 1441 | ******************************************************************************/ |
1445 | static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) | 1442 | static int remove_ranges(struct bus_node *bus_cur, struct bus_node *bus_prev) |
1446 | { | 1443 | { |
1447 | struct range_node *range_cur; | 1444 | struct range_node *range_cur; |
1448 | struct range_node *range_tmp; | 1445 | struct range_node *range_tmp; |
@@ -1452,13 +1449,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) | |||
1452 | if (bus_cur->noIORanges) { | 1449 | if (bus_cur->noIORanges) { |
1453 | range_cur = bus_cur->rangeIO; | 1450 | range_cur = bus_cur->rangeIO; |
1454 | for (i = 0; i < bus_cur->noIORanges; i++) { | 1451 | for (i = 0; i < bus_cur->noIORanges; i++) { |
1455 | if (ibmphp_find_resource (bus_prev, range_cur->start, &res, IO) < 0) | 1452 | if (ibmphp_find_resource(bus_prev, range_cur->start, &res, IO) < 0) |
1456 | return -EINVAL; | 1453 | return -EINVAL; |
1457 | ibmphp_remove_resource (res); | 1454 | ibmphp_remove_resource(res); |
1458 | 1455 | ||
1459 | range_tmp = range_cur; | 1456 | range_tmp = range_cur; |
1460 | range_cur = range_cur->next; | 1457 | range_cur = range_cur->next; |
1461 | kfree (range_tmp); | 1458 | kfree(range_tmp); |
1462 | range_tmp = NULL; | 1459 | range_tmp = NULL; |
1463 | } | 1460 | } |
1464 | bus_cur->rangeIO = NULL; | 1461 | bus_cur->rangeIO = NULL; |
@@ -1466,13 +1463,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) | |||
1466 | if (bus_cur->noMemRanges) { | 1463 | if (bus_cur->noMemRanges) { |
1467 | range_cur = bus_cur->rangeMem; | 1464 | range_cur = bus_cur->rangeMem; |
1468 | for (i = 0; i < bus_cur->noMemRanges; i++) { | 1465 | for (i = 0; i < bus_cur->noMemRanges; i++) { |
1469 | if (ibmphp_find_resource (bus_prev, range_cur->start, &res, MEM) < 0) | 1466 | if (ibmphp_find_resource(bus_prev, range_cur->start, &res, MEM) < 0) |
1470 | return -EINVAL; | 1467 | return -EINVAL; |
1471 | 1468 | ||
1472 | ibmphp_remove_resource (res); | 1469 | ibmphp_remove_resource(res); |
1473 | range_tmp = range_cur; | 1470 | range_tmp = range_cur; |
1474 | range_cur = range_cur->next; | 1471 | range_cur = range_cur->next; |
1475 | kfree (range_tmp); | 1472 | kfree(range_tmp); |
1476 | range_tmp = NULL; | 1473 | range_tmp = NULL; |
1477 | } | 1474 | } |
1478 | bus_cur->rangeMem = NULL; | 1475 | bus_cur->rangeMem = NULL; |
@@ -1480,13 +1477,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) | |||
1480 | if (bus_cur->noPFMemRanges) { | 1477 | if (bus_cur->noPFMemRanges) { |
1481 | range_cur = bus_cur->rangePFMem; | 1478 | range_cur = bus_cur->rangePFMem; |
1482 | for (i = 0; i < bus_cur->noPFMemRanges; i++) { | 1479 | for (i = 0; i < bus_cur->noPFMemRanges; i++) { |
1483 | if (ibmphp_find_resource (bus_prev, range_cur->start, &res, PFMEM) < 0) | 1480 | if (ibmphp_find_resource(bus_prev, range_cur->start, &res, PFMEM) < 0) |
1484 | return -EINVAL; | 1481 | return -EINVAL; |
1485 | 1482 | ||
1486 | ibmphp_remove_resource (res); | 1483 | ibmphp_remove_resource(res); |
1487 | range_tmp = range_cur; | 1484 | range_tmp = range_cur; |
1488 | range_cur = range_cur->next; | 1485 | range_cur = range_cur->next; |
1489 | kfree (range_tmp); | 1486 | kfree(range_tmp); |
1490 | range_tmp = NULL; | 1487 | range_tmp = NULL; |
1491 | } | 1488 | } |
1492 | bus_cur->rangePFMem = NULL; | 1489 | bus_cur->rangePFMem = NULL; |
@@ -1498,13 +1495,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) | |||
1498 | * find the resource node in the bus | 1495 | * find the resource node in the bus |
1499 | * Input: Resource needed, start address of the resource, type of resource | 1496 | * Input: Resource needed, start address of the resource, type of resource |
1500 | */ | 1497 | */ |
1501 | int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resource_node **res, int flag) | 1498 | int ibmphp_find_resource(struct bus_node *bus, u32 start_address, struct resource_node **res, int flag) |
1502 | { | 1499 | { |
1503 | struct resource_node *res_cur = NULL; | 1500 | struct resource_node *res_cur = NULL; |
1504 | char * type = ""; | 1501 | char *type = ""; |
1505 | 1502 | ||
1506 | if (!bus) { | 1503 | if (!bus) { |
1507 | err ("The bus passed in NULL to find resource\n"); | 1504 | err("The bus passed in NULL to find resource\n"); |
1508 | return -ENODEV; | 1505 | return -ENODEV; |
1509 | } | 1506 | } |
1510 | 1507 | ||
@@ -1522,7 +1519,7 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour | |||
1522 | type = "pfmem"; | 1519 | type = "pfmem"; |
1523 | break; | 1520 | break; |
1524 | default: | 1521 | default: |
1525 | err ("wrong type of flag\n"); | 1522 | err("wrong type of flag\n"); |
1526 | return -EINVAL; | 1523 | return -EINVAL; |
1527 | } | 1524 | } |
1528 | 1525 | ||
@@ -1548,17 +1545,17 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour | |||
1548 | res_cur = res_cur->next; | 1545 | res_cur = res_cur->next; |
1549 | } | 1546 | } |
1550 | if (!res_cur) { | 1547 | if (!res_cur) { |
1551 | debug ("SOS...cannot find %s resource in the bus.\n", type); | 1548 | debug("SOS...cannot find %s resource in the bus.\n", type); |
1552 | return -EINVAL; | 1549 | return -EINVAL; |
1553 | } | 1550 | } |
1554 | } else { | 1551 | } else { |
1555 | debug ("SOS... cannot find %s resource in the bus.\n", type); | 1552 | debug("SOS... cannot find %s resource in the bus.\n", type); |
1556 | return -EINVAL; | 1553 | return -EINVAL; |
1557 | } | 1554 | } |
1558 | } | 1555 | } |
1559 | 1556 | ||
1560 | if (*res) | 1557 | if (*res) |
1561 | debug ("*res->start = %x\n", (*res)->start); | 1558 | debug("*res->start = %x\n", (*res)->start); |
1562 | 1559 | ||
1563 | return 0; | 1560 | return 0; |
1564 | } | 1561 | } |
@@ -1569,21 +1566,18 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour | |||
1569 | * Parameters: none | 1566 | * Parameters: none |
1570 | * Returns: none | 1567 | * Returns: none |
1571 | ***********************************************************************/ | 1568 | ***********************************************************************/ |
1572 | void ibmphp_free_resources (void) | 1569 | void ibmphp_free_resources(void) |
1573 | { | 1570 | { |
1574 | struct bus_node *bus_cur = NULL; | 1571 | struct bus_node *bus_cur = NULL, *next; |
1575 | struct bus_node *bus_tmp; | 1572 | struct bus_node *bus_tmp; |
1576 | struct range_node *range_cur; | 1573 | struct range_node *range_cur; |
1577 | struct range_node *range_tmp; | 1574 | struct range_node *range_tmp; |
1578 | struct resource_node *res_cur; | 1575 | struct resource_node *res_cur; |
1579 | struct resource_node *res_tmp; | 1576 | struct resource_node *res_tmp; |
1580 | struct list_head *tmp; | ||
1581 | struct list_head *next; | ||
1582 | int i = 0; | 1577 | int i = 0; |
1583 | flags = 1; | 1578 | flags = 1; |
1584 | 1579 | ||
1585 | list_for_each_safe (tmp, next, &gbuses) { | 1580 | list_for_each_entry_safe(bus_cur, next, &gbuses, bus_list) { |
1586 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | ||
1587 | if (bus_cur->noIORanges) { | 1581 | if (bus_cur->noIORanges) { |
1588 | range_cur = bus_cur->rangeIO; | 1582 | range_cur = bus_cur->rangeIO; |
1589 | for (i = 0; i < bus_cur->noIORanges; i++) { | 1583 | for (i = 0; i < bus_cur->noIORanges; i++) { |
@@ -1591,7 +1585,7 @@ void ibmphp_free_resources (void) | |||
1591 | break; | 1585 | break; |
1592 | range_tmp = range_cur; | 1586 | range_tmp = range_cur; |
1593 | range_cur = range_cur->next; | 1587 | range_cur = range_cur->next; |
1594 | kfree (range_tmp); | 1588 | kfree(range_tmp); |
1595 | range_tmp = NULL; | 1589 | range_tmp = NULL; |
1596 | } | 1590 | } |
1597 | } | 1591 | } |
@@ -1602,7 +1596,7 @@ void ibmphp_free_resources (void) | |||
1602 | break; | 1596 | break; |
1603 | range_tmp = range_cur; | 1597 | range_tmp = range_cur; |
1604 | range_cur = range_cur->next; | 1598 | range_cur = range_cur->next; |
1605 | kfree (range_tmp); | 1599 | kfree(range_tmp); |
1606 | range_tmp = NULL; | 1600 | range_tmp = NULL; |
1607 | } | 1601 | } |
1608 | } | 1602 | } |
@@ -1613,7 +1607,7 @@ void ibmphp_free_resources (void) | |||
1613 | break; | 1607 | break; |
1614 | range_tmp = range_cur; | 1608 | range_tmp = range_cur; |
1615 | range_cur = range_cur->next; | 1609 | range_cur = range_cur->next; |
1616 | kfree (range_tmp); | 1610 | kfree(range_tmp); |
1617 | range_tmp = NULL; | 1611 | range_tmp = NULL; |
1618 | } | 1612 | } |
1619 | } | 1613 | } |
@@ -1626,7 +1620,7 @@ void ibmphp_free_resources (void) | |||
1626 | res_cur = res_cur->next; | 1620 | res_cur = res_cur->next; |
1627 | else | 1621 | else |
1628 | res_cur = res_cur->nextRange; | 1622 | res_cur = res_cur->nextRange; |
1629 | kfree (res_tmp); | 1623 | kfree(res_tmp); |
1630 | res_tmp = NULL; | 1624 | res_tmp = NULL; |
1631 | } | 1625 | } |
1632 | bus_cur->firstIO = NULL; | 1626 | bus_cur->firstIO = NULL; |
@@ -1639,7 +1633,7 @@ void ibmphp_free_resources (void) | |||
1639 | res_cur = res_cur->next; | 1633 | res_cur = res_cur->next; |
1640 | else | 1634 | else |
1641 | res_cur = res_cur->nextRange; | 1635 | res_cur = res_cur->nextRange; |
1642 | kfree (res_tmp); | 1636 | kfree(res_tmp); |
1643 | res_tmp = NULL; | 1637 | res_tmp = NULL; |
1644 | } | 1638 | } |
1645 | bus_cur->firstMem = NULL; | 1639 | bus_cur->firstMem = NULL; |
@@ -1652,7 +1646,7 @@ void ibmphp_free_resources (void) | |||
1652 | res_cur = res_cur->next; | 1646 | res_cur = res_cur->next; |
1653 | else | 1647 | else |
1654 | res_cur = res_cur->nextRange; | 1648 | res_cur = res_cur->nextRange; |
1655 | kfree (res_tmp); | 1649 | kfree(res_tmp); |
1656 | res_tmp = NULL; | 1650 | res_tmp = NULL; |
1657 | } | 1651 | } |
1658 | bus_cur->firstPFMem = NULL; | 1652 | bus_cur->firstPFMem = NULL; |
@@ -1664,15 +1658,15 @@ void ibmphp_free_resources (void) | |||
1664 | res_tmp = res_cur; | 1658 | res_tmp = res_cur; |
1665 | res_cur = res_cur->next; | 1659 | res_cur = res_cur->next; |
1666 | 1660 | ||
1667 | kfree (res_tmp); | 1661 | kfree(res_tmp); |
1668 | res_tmp = NULL; | 1662 | res_tmp = NULL; |
1669 | } | 1663 | } |
1670 | bus_cur->firstPFMemFromMem = NULL; | 1664 | bus_cur->firstPFMemFromMem = NULL; |
1671 | } | 1665 | } |
1672 | 1666 | ||
1673 | bus_tmp = bus_cur; | 1667 | bus_tmp = bus_cur; |
1674 | list_del (&bus_cur->bus_list); | 1668 | list_del(&bus_cur->bus_list); |
1675 | kfree (bus_tmp); | 1669 | kfree(bus_tmp); |
1676 | bus_tmp = NULL; | 1670 | bus_tmp = NULL; |
1677 | } | 1671 | } |
1678 | } | 1672 | } |
@@ -1685,16 +1679,14 @@ void ibmphp_free_resources (void) | |||
1685 | * a new Mem node | 1679 | * a new Mem node |
1686 | * This routine is called right after initialization | 1680 | * This routine is called right after initialization |
1687 | *******************************************************************************/ | 1681 | *******************************************************************************/ |
1688 | static int __init once_over (void) | 1682 | static int __init once_over(void) |
1689 | { | 1683 | { |
1690 | struct resource_node *pfmem_cur; | 1684 | struct resource_node *pfmem_cur; |
1691 | struct resource_node *pfmem_prev; | 1685 | struct resource_node *pfmem_prev; |
1692 | struct resource_node *mem; | 1686 | struct resource_node *mem; |
1693 | struct bus_node *bus_cur; | 1687 | struct bus_node *bus_cur; |
1694 | struct list_head *tmp; | ||
1695 | 1688 | ||
1696 | list_for_each (tmp, &gbuses) { | 1689 | list_for_each_entry(bus_cur, &gbuses, bus_list) { |
1697 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | ||
1698 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { | 1690 | if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { |
1699 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { | 1691 | for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) { |
1700 | pfmem_cur->fromMem = 1; | 1692 | pfmem_cur->fromMem = 1; |
@@ -1716,7 +1708,7 @@ static int __init once_over (void) | |||
1716 | 1708 | ||
1717 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 1709 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
1718 | if (!mem) { | 1710 | if (!mem) { |
1719 | err ("out of system memory\n"); | 1711 | err("out of system memory\n"); |
1720 | return -ENOMEM; | 1712 | return -ENOMEM; |
1721 | } | 1713 | } |
1722 | mem->type = MEM; | 1714 | mem->type = MEM; |
@@ -1725,8 +1717,8 @@ static int __init once_over (void) | |||
1725 | mem->start = pfmem_cur->start; | 1717 | mem->start = pfmem_cur->start; |
1726 | mem->end = pfmem_cur->end; | 1718 | mem->end = pfmem_cur->end; |
1727 | mem->len = pfmem_cur->len; | 1719 | mem->len = pfmem_cur->len; |
1728 | if (ibmphp_add_resource (mem) < 0) | 1720 | if (ibmphp_add_resource(mem) < 0) |
1729 | err ("Trouble...trouble... EBDA allocated pfmem from mem, but system doesn't display it has this space... unless not PCI device...\n"); | 1721 | err("Trouble...trouble... EBDA allocated pfmem from mem, but system doesn't display it has this space... unless not PCI device...\n"); |
1730 | pfmem_cur->rangeno = mem->rangeno; | 1722 | pfmem_cur->rangeno = mem->rangeno; |
1731 | } /* end for pfmem */ | 1723 | } /* end for pfmem */ |
1732 | } /* end if */ | 1724 | } /* end if */ |
@@ -1734,12 +1726,12 @@ static int __init once_over (void) | |||
1734 | return 0; | 1726 | return 0; |
1735 | } | 1727 | } |
1736 | 1728 | ||
1737 | int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem) | 1729 | int ibmphp_add_pfmem_from_mem(struct resource_node *pfmem) |
1738 | { | 1730 | { |
1739 | struct bus_node *bus_cur = find_bus_wprev (pfmem->busno, NULL, 0); | 1731 | struct bus_node *bus_cur = find_bus_wprev(pfmem->busno, NULL, 0); |
1740 | 1732 | ||
1741 | if (!bus_cur) { | 1733 | if (!bus_cur) { |
1742 | err ("cannot find bus of pfmem to add...\n"); | 1734 | err("cannot find bus of pfmem to add...\n"); |
1743 | return -ENODEV; | 1735 | return -ENODEV; |
1744 | } | 1736 | } |
1745 | 1737 | ||
@@ -1759,22 +1751,18 @@ int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem) | |||
1759 | * Parameters: bus_number | 1751 | * Parameters: bus_number |
1760 | * Returns: Bus pointer or NULL | 1752 | * Returns: Bus pointer or NULL |
1761 | */ | 1753 | */ |
1762 | struct bus_node *ibmphp_find_res_bus (u8 bus_number) | 1754 | struct bus_node *ibmphp_find_res_bus(u8 bus_number) |
1763 | { | 1755 | { |
1764 | return find_bus_wprev (bus_number, NULL, 0); | 1756 | return find_bus_wprev(bus_number, NULL, 0); |
1765 | } | 1757 | } |
1766 | 1758 | ||
1767 | static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u8 flag) | 1759 | static struct bus_node *find_bus_wprev(u8 bus_number, struct bus_node **prev, u8 flag) |
1768 | { | 1760 | { |
1769 | struct bus_node *bus_cur; | 1761 | struct bus_node *bus_cur; |
1770 | struct list_head *tmp; | ||
1771 | struct list_head *tmp_prev; | ||
1772 | 1762 | ||
1773 | list_for_each (tmp, &gbuses) { | 1763 | list_for_each_entry(bus_cur, &gbuses, bus_list) { |
1774 | tmp_prev = tmp->prev; | ||
1775 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | ||
1776 | if (flag) | 1764 | if (flag) |
1777 | *prev = list_entry (tmp_prev, struct bus_node, bus_list); | 1765 | *prev = list_prev_entry(bus_cur, bus_list); |
1778 | if (bus_cur->busno == bus_number) | 1766 | if (bus_cur->busno == bus_number) |
1779 | return bus_cur; | 1767 | return bus_cur; |
1780 | } | 1768 | } |
@@ -1782,23 +1770,21 @@ static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u | |||
1782 | return NULL; | 1770 | return NULL; |
1783 | } | 1771 | } |
1784 | 1772 | ||
1785 | void ibmphp_print_test (void) | 1773 | void ibmphp_print_test(void) |
1786 | { | 1774 | { |
1787 | int i = 0; | 1775 | int i = 0; |
1788 | struct bus_node *bus_cur = NULL; | 1776 | struct bus_node *bus_cur = NULL; |
1789 | struct range_node *range; | 1777 | struct range_node *range; |
1790 | struct resource_node *res; | 1778 | struct resource_node *res; |
1791 | struct list_head *tmp; | ||
1792 | 1779 | ||
1793 | debug_pci ("*****************START**********************\n"); | 1780 | debug_pci("*****************START**********************\n"); |
1794 | 1781 | ||
1795 | if ((!list_empty(&gbuses)) && flags) { | 1782 | if ((!list_empty(&gbuses)) && flags) { |
1796 | err ("The GBUSES is not NULL?!?!?!?!?\n"); | 1783 | err("The GBUSES is not NULL?!?!?!?!?\n"); |
1797 | return; | 1784 | return; |
1798 | } | 1785 | } |
1799 | 1786 | ||
1800 | list_for_each (tmp, &gbuses) { | 1787 | list_for_each_entry(bus_cur, &gbuses, bus_list) { |
1801 | bus_cur = list_entry (tmp, struct bus_node, bus_list); | ||
1802 | debug_pci ("This is bus # %d. There are\n", bus_cur->busno); | 1788 | debug_pci ("This is bus # %d. There are\n", bus_cur->busno); |
1803 | debug_pci ("IORanges = %d\t", bus_cur->noIORanges); | 1789 | debug_pci ("IORanges = %d\t", bus_cur->noIORanges); |
1804 | debug_pci ("MemRanges = %d\t", bus_cur->noMemRanges); | 1790 | debug_pci ("MemRanges = %d\t", bus_cur->noMemRanges); |
@@ -1807,42 +1793,42 @@ void ibmphp_print_test (void) | |||
1807 | if (bus_cur->rangeIO) { | 1793 | if (bus_cur->rangeIO) { |
1808 | range = bus_cur->rangeIO; | 1794 | range = bus_cur->rangeIO; |
1809 | for (i = 0; i < bus_cur->noIORanges; i++) { | 1795 | for (i = 0; i < bus_cur->noIORanges; i++) { |
1810 | debug_pci ("rangeno is %d\n", range->rangeno); | 1796 | debug_pci("rangeno is %d\n", range->rangeno); |
1811 | debug_pci ("[%x - %x]\n", range->start, range->end); | 1797 | debug_pci("[%x - %x]\n", range->start, range->end); |
1812 | range = range->next; | 1798 | range = range->next; |
1813 | } | 1799 | } |
1814 | } | 1800 | } |
1815 | 1801 | ||
1816 | debug_pci ("The Mem Ranges are as follows:\n"); | 1802 | debug_pci("The Mem Ranges are as follows:\n"); |
1817 | if (bus_cur->rangeMem) { | 1803 | if (bus_cur->rangeMem) { |
1818 | range = bus_cur->rangeMem; | 1804 | range = bus_cur->rangeMem; |
1819 | for (i = 0; i < bus_cur->noMemRanges; i++) { | 1805 | for (i = 0; i < bus_cur->noMemRanges; i++) { |
1820 | debug_pci ("rangeno is %d\n", range->rangeno); | 1806 | debug_pci("rangeno is %d\n", range->rangeno); |
1821 | debug_pci ("[%x - %x]\n", range->start, range->end); | 1807 | debug_pci("[%x - %x]\n", range->start, range->end); |
1822 | range = range->next; | 1808 | range = range->next; |
1823 | } | 1809 | } |
1824 | } | 1810 | } |
1825 | 1811 | ||
1826 | debug_pci ("The PFMem Ranges are as follows:\n"); | 1812 | debug_pci("The PFMem Ranges are as follows:\n"); |
1827 | 1813 | ||
1828 | if (bus_cur->rangePFMem) { | 1814 | if (bus_cur->rangePFMem) { |
1829 | range = bus_cur->rangePFMem; | 1815 | range = bus_cur->rangePFMem; |
1830 | for (i = 0; i < bus_cur->noPFMemRanges; i++) { | 1816 | for (i = 0; i < bus_cur->noPFMemRanges; i++) { |
1831 | debug_pci ("rangeno is %d\n", range->rangeno); | 1817 | debug_pci("rangeno is %d\n", range->rangeno); |
1832 | debug_pci ("[%x - %x]\n", range->start, range->end); | 1818 | debug_pci("[%x - %x]\n", range->start, range->end); |
1833 | range = range->next; | 1819 | range = range->next; |
1834 | } | 1820 | } |
1835 | } | 1821 | } |
1836 | 1822 | ||
1837 | debug_pci ("The resources on this bus are as follows\n"); | 1823 | debug_pci("The resources on this bus are as follows\n"); |
1838 | 1824 | ||
1839 | debug_pci ("IO...\n"); | 1825 | debug_pci("IO...\n"); |
1840 | if (bus_cur->firstIO) { | 1826 | if (bus_cur->firstIO) { |
1841 | res = bus_cur->firstIO; | 1827 | res = bus_cur->firstIO; |
1842 | while (res) { | 1828 | while (res) { |
1843 | debug_pci ("The range # is %d\n", res->rangeno); | 1829 | debug_pci("The range # is %d\n", res->rangeno); |
1844 | debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); | 1830 | debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); |
1845 | debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); | 1831 | debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); |
1846 | if (res->next) | 1832 | if (res->next) |
1847 | res = res->next; | 1833 | res = res->next; |
1848 | else if (res->nextRange) | 1834 | else if (res->nextRange) |
@@ -1851,13 +1837,13 @@ void ibmphp_print_test (void) | |||
1851 | break; | 1837 | break; |
1852 | } | 1838 | } |
1853 | } | 1839 | } |
1854 | debug_pci ("Mem...\n"); | 1840 | debug_pci("Mem...\n"); |
1855 | if (bus_cur->firstMem) { | 1841 | if (bus_cur->firstMem) { |
1856 | res = bus_cur->firstMem; | 1842 | res = bus_cur->firstMem; |
1857 | while (res) { | 1843 | while (res) { |
1858 | debug_pci ("The range # is %d\n", res->rangeno); | 1844 | debug_pci("The range # is %d\n", res->rangeno); |
1859 | debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); | 1845 | debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); |
1860 | debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); | 1846 | debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); |
1861 | if (res->next) | 1847 | if (res->next) |
1862 | res = res->next; | 1848 | res = res->next; |
1863 | else if (res->nextRange) | 1849 | else if (res->nextRange) |
@@ -1866,13 +1852,13 @@ void ibmphp_print_test (void) | |||
1866 | break; | 1852 | break; |
1867 | } | 1853 | } |
1868 | } | 1854 | } |
1869 | debug_pci ("PFMem...\n"); | 1855 | debug_pci("PFMem...\n"); |
1870 | if (bus_cur->firstPFMem) { | 1856 | if (bus_cur->firstPFMem) { |
1871 | res = bus_cur->firstPFMem; | 1857 | res = bus_cur->firstPFMem; |
1872 | while (res) { | 1858 | while (res) { |
1873 | debug_pci ("The range # is %d\n", res->rangeno); | 1859 | debug_pci("The range # is %d\n", res->rangeno); |
1874 | debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); | 1860 | debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); |
1875 | debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); | 1861 | debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); |
1876 | if (res->next) | 1862 | if (res->next) |
1877 | res = res->next; | 1863 | res = res->next; |
1878 | else if (res->nextRange) | 1864 | else if (res->nextRange) |
@@ -1882,23 +1868,23 @@ void ibmphp_print_test (void) | |||
1882 | } | 1868 | } |
1883 | } | 1869 | } |
1884 | 1870 | ||
1885 | debug_pci ("PFMemFromMem...\n"); | 1871 | debug_pci("PFMemFromMem...\n"); |
1886 | if (bus_cur->firstPFMemFromMem) { | 1872 | if (bus_cur->firstPFMemFromMem) { |
1887 | res = bus_cur->firstPFMemFromMem; | 1873 | res = bus_cur->firstPFMemFromMem; |
1888 | while (res) { | 1874 | while (res) { |
1889 | debug_pci ("The range # is %d\n", res->rangeno); | 1875 | debug_pci("The range # is %d\n", res->rangeno); |
1890 | debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); | 1876 | debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); |
1891 | debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); | 1877 | debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); |
1892 | res = res->next; | 1878 | res = res->next; |
1893 | } | 1879 | } |
1894 | } | 1880 | } |
1895 | } | 1881 | } |
1896 | debug_pci ("***********************END***********************\n"); | 1882 | debug_pci("***********************END***********************\n"); |
1897 | } | 1883 | } |
1898 | 1884 | ||
1899 | static int range_exists_already (struct range_node * range, struct bus_node * bus_cur, u8 type) | 1885 | static int range_exists_already(struct range_node *range, struct bus_node *bus_cur, u8 type) |
1900 | { | 1886 | { |
1901 | struct range_node * range_cur = NULL; | 1887 | struct range_node *range_cur = NULL; |
1902 | switch (type) { | 1888 | switch (type) { |
1903 | case IO: | 1889 | case IO: |
1904 | range_cur = bus_cur->rangeIO; | 1890 | range_cur = bus_cur->rangeIO; |
@@ -1910,7 +1896,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu | |||
1910 | range_cur = bus_cur->rangePFMem; | 1896 | range_cur = bus_cur->rangePFMem; |
1911 | break; | 1897 | break; |
1912 | default: | 1898 | default: |
1913 | err ("wrong type passed to find out if range already exists\n"); | 1899 | err("wrong type passed to find out if range already exists\n"); |
1914 | return -ENODEV; | 1900 | return -ENODEV; |
1915 | } | 1901 | } |
1916 | 1902 | ||
@@ -1937,7 +1923,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu | |||
1937 | * behind them All these are TO DO. | 1923 | * behind them All these are TO DO. |
1938 | * Also need to add more error checkings... (from fnc returns etc) | 1924 | * Also need to add more error checkings... (from fnc returns etc) |
1939 | */ | 1925 | */ |
1940 | static int __init update_bridge_ranges (struct bus_node **bus) | 1926 | static int __init update_bridge_ranges(struct bus_node **bus) |
1941 | { | 1927 | { |
1942 | u8 sec_busno, device, function, hdr_type, start_io_address, end_io_address; | 1928 | u8 sec_busno, device, function, hdr_type, start_io_address, end_io_address; |
1943 | u16 vendor_id, upper_io_start, upper_io_end, start_mem_address, end_mem_address; | 1929 | u16 vendor_id, upper_io_start, upper_io_end, start_mem_address, end_mem_address; |
@@ -1955,17 +1941,17 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
1955 | return -ENODEV; | 1941 | return -ENODEV; |
1956 | ibmphp_pci_bus->number = bus_cur->busno; | 1942 | ibmphp_pci_bus->number = bus_cur->busno; |
1957 | 1943 | ||
1958 | debug ("inside %s\n", __func__); | 1944 | debug("inside %s\n", __func__); |
1959 | debug ("bus_cur->busno = %x\n", bus_cur->busno); | 1945 | debug("bus_cur->busno = %x\n", bus_cur->busno); |
1960 | 1946 | ||
1961 | for (device = 0; device < 32; device++) { | 1947 | for (device = 0; device < 32; device++) { |
1962 | for (function = 0x00; function < 0x08; function++) { | 1948 | for (function = 0x00; function < 0x08; function++) { |
1963 | devfn = PCI_DEVFN(device, function); | 1949 | devfn = PCI_DEVFN(device, function); |
1964 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); | 1950 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); |
1965 | 1951 | ||
1966 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { | 1952 | if (vendor_id != PCI_VENDOR_ID_NOTVALID) { |
1967 | /* found correct device!!! */ | 1953 | /* found correct device!!! */ |
1968 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); | 1954 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); |
1969 | 1955 | ||
1970 | switch (hdr_type) { | 1956 | switch (hdr_type) { |
1971 | case PCI_HEADER_TYPE_NORMAL: | 1957 | case PCI_HEADER_TYPE_NORMAL: |
@@ -1984,18 +1970,18 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
1984 | temp++; | 1970 | temp++; |
1985 | } | 1971 | } |
1986 | */ | 1972 | */ |
1987 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno); | 1973 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno); |
1988 | bus_sec = find_bus_wprev (sec_busno, NULL, 0); | 1974 | bus_sec = find_bus_wprev(sec_busno, NULL, 0); |
1989 | /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */ | 1975 | /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */ |
1990 | if (!bus_sec) { | 1976 | if (!bus_sec) { |
1991 | bus_sec = alloc_error_bus (NULL, sec_busno, 1); | 1977 | bus_sec = alloc_error_bus(NULL, sec_busno, 1); |
1992 | /* the rest will be populated during NVRAM call */ | 1978 | /* the rest will be populated during NVRAM call */ |
1993 | return 0; | 1979 | return 0; |
1994 | } | 1980 | } |
1995 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &start_io_address); | 1981 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &start_io_address); |
1996 | pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &end_io_address); | 1982 | pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &end_io_address); |
1997 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, &upper_io_start); | 1983 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, &upper_io_start); |
1998 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, &upper_io_end); | 1984 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, &upper_io_end); |
1999 | start_address = (start_io_address & PCI_IO_RANGE_MASK) << 8; | 1985 | start_address = (start_io_address & PCI_IO_RANGE_MASK) << 8; |
2000 | start_address |= (upper_io_start << 16); | 1986 | start_address |= (upper_io_start << 16); |
2001 | end_address = (end_io_address & PCI_IO_RANGE_MASK) << 8; | 1987 | end_address = (end_io_address & PCI_IO_RANGE_MASK) << 8; |
@@ -2004,18 +1990,18 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2004 | if ((start_address) && (start_address <= end_address)) { | 1990 | if ((start_address) && (start_address <= end_address)) { |
2005 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 1991 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2006 | if (!range) { | 1992 | if (!range) { |
2007 | err ("out of system memory\n"); | 1993 | err("out of system memory\n"); |
2008 | return -ENOMEM; | 1994 | return -ENOMEM; |
2009 | } | 1995 | } |
2010 | range->start = start_address; | 1996 | range->start = start_address; |
2011 | range->end = end_address + 0xfff; | 1997 | range->end = end_address + 0xfff; |
2012 | 1998 | ||
2013 | if (bus_sec->noIORanges > 0) { | 1999 | if (bus_sec->noIORanges > 0) { |
2014 | if (!range_exists_already (range, bus_sec, IO)) { | 2000 | if (!range_exists_already(range, bus_sec, IO)) { |
2015 | add_bus_range (IO, range, bus_sec); | 2001 | add_bus_range(IO, range, bus_sec); |
2016 | ++bus_sec->noIORanges; | 2002 | ++bus_sec->noIORanges; |
2017 | } else { | 2003 | } else { |
2018 | kfree (range); | 2004 | kfree(range); |
2019 | range = NULL; | 2005 | range = NULL; |
2020 | } | 2006 | } |
2021 | } else { | 2007 | } else { |
@@ -2024,13 +2010,13 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2024 | bus_sec->rangeIO = range; | 2010 | bus_sec->rangeIO = range; |
2025 | ++bus_sec->noIORanges; | 2011 | ++bus_sec->noIORanges; |
2026 | } | 2012 | } |
2027 | fix_resources (bus_sec); | 2013 | fix_resources(bus_sec); |
2028 | 2014 | ||
2029 | if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { | 2015 | if (ibmphp_find_resource(bus_cur, start_address, &io, IO)) { |
2030 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 2016 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2031 | if (!io) { | 2017 | if (!io) { |
2032 | kfree (range); | 2018 | kfree(range); |
2033 | err ("out of system memory\n"); | 2019 | err("out of system memory\n"); |
2034 | return -ENOMEM; | 2020 | return -ENOMEM; |
2035 | } | 2021 | } |
2036 | io->type = IO; | 2022 | io->type = IO; |
@@ -2039,12 +2025,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2039 | io->start = start_address; | 2025 | io->start = start_address; |
2040 | io->end = end_address + 0xfff; | 2026 | io->end = end_address + 0xfff; |
2041 | io->len = io->end - io->start + 1; | 2027 | io->len = io->end - io->start + 1; |
2042 | ibmphp_add_resource (io); | 2028 | ibmphp_add_resource(io); |
2043 | } | 2029 | } |
2044 | } | 2030 | } |
2045 | 2031 | ||
2046 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address); | 2032 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address); |
2047 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address); | 2033 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address); |
2048 | 2034 | ||
2049 | start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; | 2035 | start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; |
2050 | end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; | 2036 | end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; |
@@ -2053,18 +2039,18 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2053 | 2039 | ||
2054 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 2040 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2055 | if (!range) { | 2041 | if (!range) { |
2056 | err ("out of system memory\n"); | 2042 | err("out of system memory\n"); |
2057 | return -ENOMEM; | 2043 | return -ENOMEM; |
2058 | } | 2044 | } |
2059 | range->start = start_address; | 2045 | range->start = start_address; |
2060 | range->end = end_address + 0xfffff; | 2046 | range->end = end_address + 0xfffff; |
2061 | 2047 | ||
2062 | if (bus_sec->noMemRanges > 0) { | 2048 | if (bus_sec->noMemRanges > 0) { |
2063 | if (!range_exists_already (range, bus_sec, MEM)) { | 2049 | if (!range_exists_already(range, bus_sec, MEM)) { |
2064 | add_bus_range (MEM, range, bus_sec); | 2050 | add_bus_range(MEM, range, bus_sec); |
2065 | ++bus_sec->noMemRanges; | 2051 | ++bus_sec->noMemRanges; |
2066 | } else { | 2052 | } else { |
2067 | kfree (range); | 2053 | kfree(range); |
2068 | range = NULL; | 2054 | range = NULL; |
2069 | } | 2055 | } |
2070 | } else { | 2056 | } else { |
@@ -2074,13 +2060,13 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2074 | ++bus_sec->noMemRanges; | 2060 | ++bus_sec->noMemRanges; |
2075 | } | 2061 | } |
2076 | 2062 | ||
2077 | fix_resources (bus_sec); | 2063 | fix_resources(bus_sec); |
2078 | 2064 | ||
2079 | if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { | 2065 | if (ibmphp_find_resource(bus_cur, start_address, &mem, MEM)) { |
2080 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 2066 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2081 | if (!mem) { | 2067 | if (!mem) { |
2082 | kfree (range); | 2068 | kfree(range); |
2083 | err ("out of system memory\n"); | 2069 | err("out of system memory\n"); |
2084 | return -ENOMEM; | 2070 | return -ENOMEM; |
2085 | } | 2071 | } |
2086 | mem->type = MEM; | 2072 | mem->type = MEM; |
@@ -2089,13 +2075,13 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2089 | mem->start = start_address; | 2075 | mem->start = start_address; |
2090 | mem->end = end_address + 0xfffff; | 2076 | mem->end = end_address + 0xfffff; |
2091 | mem->len = mem->end - mem->start + 1; | 2077 | mem->len = mem->end - mem->start + 1; |
2092 | ibmphp_add_resource (mem); | 2078 | ibmphp_add_resource(mem); |
2093 | } | 2079 | } |
2094 | } | 2080 | } |
2095 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &start_mem_address); | 2081 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &start_mem_address); |
2096 | pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &end_mem_address); | 2082 | pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &end_mem_address); |
2097 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, &upper_start); | 2083 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, &upper_start); |
2098 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, &upper_end); | 2084 | pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, &upper_end); |
2099 | start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; | 2085 | start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; |
2100 | end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; | 2086 | end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; |
2101 | #if BITS_PER_LONG == 64 | 2087 | #if BITS_PER_LONG == 64 |
@@ -2107,18 +2093,18 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2107 | 2093 | ||
2108 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 2094 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2109 | if (!range) { | 2095 | if (!range) { |
2110 | err ("out of system memory\n"); | 2096 | err("out of system memory\n"); |
2111 | return -ENOMEM; | 2097 | return -ENOMEM; |
2112 | } | 2098 | } |
2113 | range->start = start_address; | 2099 | range->start = start_address; |
2114 | range->end = end_address + 0xfffff; | 2100 | range->end = end_address + 0xfffff; |
2115 | 2101 | ||
2116 | if (bus_sec->noPFMemRanges > 0) { | 2102 | if (bus_sec->noPFMemRanges > 0) { |
2117 | if (!range_exists_already (range, bus_sec, PFMEM)) { | 2103 | if (!range_exists_already(range, bus_sec, PFMEM)) { |
2118 | add_bus_range (PFMEM, range, bus_sec); | 2104 | add_bus_range(PFMEM, range, bus_sec); |
2119 | ++bus_sec->noPFMemRanges; | 2105 | ++bus_sec->noPFMemRanges; |
2120 | } else { | 2106 | } else { |
2121 | kfree (range); | 2107 | kfree(range); |
2122 | range = NULL; | 2108 | range = NULL; |
2123 | } | 2109 | } |
2124 | } else { | 2110 | } else { |
@@ -2128,12 +2114,12 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2128 | ++bus_sec->noPFMemRanges; | 2114 | ++bus_sec->noPFMemRanges; |
2129 | } | 2115 | } |
2130 | 2116 | ||
2131 | fix_resources (bus_sec); | 2117 | fix_resources(bus_sec); |
2132 | if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { | 2118 | if (ibmphp_find_resource(bus_cur, start_address, &pfmem, PFMEM)) { |
2133 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 2119 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2134 | if (!pfmem) { | 2120 | if (!pfmem) { |
2135 | kfree (range); | 2121 | kfree(range); |
2136 | err ("out of system memory\n"); | 2122 | err("out of system memory\n"); |
2137 | return -ENOMEM; | 2123 | return -ENOMEM; |
2138 | } | 2124 | } |
2139 | pfmem->type = PFMEM; | 2125 | pfmem->type = PFMEM; |
@@ -2144,7 +2130,7 @@ static int __init update_bridge_ranges (struct bus_node **bus) | |||
2144 | pfmem->len = pfmem->end - pfmem->start + 1; | 2130 | pfmem->len = pfmem->end - pfmem->start + 1; |
2145 | pfmem->fromMem = 0; | 2131 | pfmem->fromMem = 0; |
2146 | 2132 | ||
2147 | ibmphp_add_resource (pfmem); | 2133 | ibmphp_add_resource(pfmem); |
2148 | } | 2134 | } |
2149 | } | 2135 | } |
2150 | break; | 2136 | break; |
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c index d1fab97d6b01..9acd1997c6fe 100644 --- a/drivers/pci/hotplug/pci_hotplug_core.c +++ b/drivers/pci/hotplug/pci_hotplug_core.c | |||
@@ -45,10 +45,10 @@ | |||
45 | 45 | ||
46 | #define MY_NAME "pci_hotplug" | 46 | #define MY_NAME "pci_hotplug" |
47 | 47 | ||
48 | #define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0) | 48 | #define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt, MY_NAME, __func__, ## arg); } while (0) |
49 | #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) | 49 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
50 | #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) | 50 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
52 | 52 | ||
53 | 53 | ||
54 | /* local variables */ | 54 | /* local variables */ |
@@ -226,7 +226,7 @@ static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf, | |||
226 | u32 test; | 226 | u32 test; |
227 | int retval = 0; | 227 | int retval = 0; |
228 | 228 | ||
229 | ltest = simple_strtoul (buf, NULL, 10); | 229 | ltest = simple_strtoul(buf, NULL, 10); |
230 | test = (u32)(ltest & 0xffffffff); | 230 | test = (u32)(ltest & 0xffffffff); |
231 | dbg("test = %d\n", test); | 231 | dbg("test = %d\n", test); |
232 | 232 | ||
@@ -396,10 +396,8 @@ static void fs_remove_slot(struct pci_slot *pci_slot) | |||
396 | static struct hotplug_slot *get_slot_from_name(const char *name) | 396 | static struct hotplug_slot *get_slot_from_name(const char *name) |
397 | { | 397 | { |
398 | struct hotplug_slot *slot; | 398 | struct hotplug_slot *slot; |
399 | struct list_head *tmp; | ||
400 | 399 | ||
401 | list_for_each(tmp, &pci_hotplug_slot_list) { | 400 | list_for_each_entry(slot, &pci_hotplug_slot_list, slot_list) { |
402 | slot = list_entry(tmp, struct hotplug_slot, slot_list); | ||
403 | if (strcmp(hotplug_slot_name(slot), name) == 0) | 401 | if (strcmp(hotplug_slot_name(slot), name) == 0) |
404 | return slot; | 402 | return slot; |
405 | } | 403 | } |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 62d6fe6c3714..e764918641ae 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -47,14 +47,14 @@ extern bool pciehp_debug; | |||
47 | #define dbg(format, arg...) \ | 47 | #define dbg(format, arg...) \ |
48 | do { \ | 48 | do { \ |
49 | if (pciehp_debug) \ | 49 | if (pciehp_debug) \ |
50 | printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); \ | 50 | printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg); \ |
51 | } while (0) | 51 | } while (0) |
52 | #define err(format, arg...) \ | 52 | #define err(format, arg...) \ |
53 | printk(KERN_ERR "%s: " format, MY_NAME , ## arg) | 53 | printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
54 | #define info(format, arg...) \ | 54 | #define info(format, arg...) \ |
55 | printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 55 | printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
56 | #define warn(format, arg...) \ | 56 | #define warn(format, arg...) \ |
57 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 57 | printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
58 | 58 | ||
59 | #define ctrl_dbg(ctrl, format, arg...) \ | 59 | #define ctrl_dbg(ctrl, format, arg...) \ |
60 | do { \ | 60 | do { \ |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 612b21a14df5..ac531e674a05 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -62,14 +62,14 @@ MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if OSHP is missing"); | |||
62 | 62 | ||
63 | #define PCIE_MODULE_NAME "pciehp" | 63 | #define PCIE_MODULE_NAME "pciehp" |
64 | 64 | ||
65 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 65 | static int set_attention_status(struct hotplug_slot *slot, u8 value); |
66 | static int enable_slot (struct hotplug_slot *slot); | 66 | static int enable_slot(struct hotplug_slot *slot); |
67 | static int disable_slot (struct hotplug_slot *slot); | 67 | static int disable_slot(struct hotplug_slot *slot); |
68 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | 68 | static int get_power_status(struct hotplug_slot *slot, u8 *value); |
69 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 69 | static int get_attention_status(struct hotplug_slot *slot, u8 *value); |
70 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 70 | static int get_latch_status(struct hotplug_slot *slot, u8 *value); |
71 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 71 | static int get_adapter_status(struct hotplug_slot *slot, u8 *value); |
72 | static int reset_slot (struct hotplug_slot *slot, int probe); | 72 | static int reset_slot(struct hotplug_slot *slot, int probe); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * release_slot - free up the memory used by a slot | 75 | * release_slot - free up the memory used by a slot |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 4c8f4cde6854..880978b6d534 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -511,7 +511,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot) | |||
511 | case STATIC_STATE: | 511 | case STATIC_STATE: |
512 | p_slot->state = POWEROFF_STATE; | 512 | p_slot->state = POWEROFF_STATE; |
513 | mutex_unlock(&p_slot->lock); | 513 | mutex_unlock(&p_slot->lock); |
514 | mutex_lock(&p_slot->hotplug_lock); | ||
514 | retval = pciehp_disable_slot(p_slot); | 515 | retval = pciehp_disable_slot(p_slot); |
516 | mutex_unlock(&p_slot->hotplug_lock); | ||
515 | mutex_lock(&p_slot->lock); | 517 | mutex_lock(&p_slot->lock); |
516 | p_slot->state = STATIC_STATE; | 518 | p_slot->state = STATIC_STATE; |
517 | break; | 519 | break; |
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c index d062c008fc95..172ed89200cd 100644 --- a/drivers/pci/hotplug/pcihp_skeleton.c +++ b/drivers/pci/hotplug/pcihp_skeleton.c | |||
@@ -52,11 +52,11 @@ static LIST_HEAD(slot_list); | |||
52 | do { \ | 52 | do { \ |
53 | if (debug) \ | 53 | if (debug) \ |
54 | printk(KERN_DEBUG "%s: " format "\n", \ | 54 | printk(KERN_DEBUG "%s: " format "\n", \ |
55 | MY_NAME , ## arg); \ | 55 | MY_NAME, ## arg); \ |
56 | } while (0) | 56 | } while (0) |
57 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 57 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg) |
58 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 58 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg) |
59 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 59 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg) |
60 | 60 | ||
61 | /* local variables */ | 61 | /* local variables */ |
62 | static bool debug; | 62 | static bool debug; |
@@ -72,14 +72,14 @@ MODULE_LICENSE("GPL"); | |||
72 | module_param(debug, bool, 0644); | 72 | module_param(debug, bool, 0644); |
73 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | 73 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); |
74 | 74 | ||
75 | static int enable_slot (struct hotplug_slot *slot); | 75 | static int enable_slot(struct hotplug_slot *slot); |
76 | static int disable_slot (struct hotplug_slot *slot); | 76 | static int disable_slot(struct hotplug_slot *slot); |
77 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 77 | static int set_attention_status(struct hotplug_slot *slot, u8 value); |
78 | static int hardware_test (struct hotplug_slot *slot, u32 value); | 78 | static int hardware_test(struct hotplug_slot *slot, u32 value); |
79 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | 79 | static int get_power_status(struct hotplug_slot *slot, u8 *value); |
80 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 80 | static int get_attention_status(struct hotplug_slot *slot, u8 *value); |
81 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 81 | static int get_latch_status(struct hotplug_slot *slot, u8 *value); |
82 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 82 | static int get_adapter_status(struct hotplug_slot *slot, u8 *value); |
83 | 83 | ||
84 | static struct hotplug_slot_ops skel_hotplug_slot_ops = { | 84 | static struct hotplug_slot_ops skel_hotplug_slot_ops = { |
85 | .enable_slot = enable_slot, | 85 | .enable_slot = enable_slot, |
@@ -321,17 +321,14 @@ error: | |||
321 | 321 | ||
322 | static void __exit cleanup_slots(void) | 322 | static void __exit cleanup_slots(void) |
323 | { | 323 | { |
324 | struct list_head *tmp; | 324 | struct slot *slot, *next; |
325 | struct list_head *next; | ||
326 | struct slot *slot; | ||
327 | 325 | ||
328 | /* | 326 | /* |
329 | * Unregister all of our slots with the pci_hotplug subsystem. | 327 | * Unregister all of our slots with the pci_hotplug subsystem. |
330 | * Memory will be freed in release_slot() callback after slot's | 328 | * Memory will be freed in release_slot() callback after slot's |
331 | * lifespan is finished. | 329 | * lifespan is finished. |
332 | */ | 330 | */ |
333 | list_for_each_safe(tmp, next, &slot_list) { | 331 | list_for_each_entry_safe(slot, next, &slot_list, slot_list) { |
334 | slot = list_entry(tmp, struct slot, slot_list); | ||
335 | list_del(&slot->slot_list); | 332 | list_del(&slot->slot_list); |
336 | pci_hp_deregister(slot->hotplug_slot); | 333 | pci_hp_deregister(slot->hotplug_slot); |
337 | } | 334 | } |
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index e12bafdc42e0..b46b57d870fc 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c | |||
@@ -114,11 +114,10 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type) | |||
114 | */ | 114 | */ |
115 | static struct slot *find_php_slot(struct device_node *dn) | 115 | static struct slot *find_php_slot(struct device_node *dn) |
116 | { | 116 | { |
117 | struct list_head *tmp, *n; | 117 | struct slot *slot, *next; |
118 | struct slot *slot; | ||
119 | 118 | ||
120 | list_for_each_safe(tmp, n, &rpaphp_slot_head) { | 119 | list_for_each_entry_safe(slot, next, &rpaphp_slot_head, |
121 | slot = list_entry(tmp, struct slot, rpaphp_slot_list); | 120 | rpaphp_slot_list) { |
122 | if (slot->dn == dn) | 121 | if (slot->dn == dn) |
123 | return slot; | 122 | return slot; |
124 | } | 123 | } |
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index b2593e876a09..7db024e68fe6 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h | |||
@@ -51,11 +51,11 @@ extern bool rpaphp_debug; | |||
51 | do { \ | 51 | do { \ |
52 | if (rpaphp_debug) \ | 52 | if (rpaphp_debug) \ |
53 | printk(KERN_DEBUG "%s: " format, \ | 53 | printk(KERN_DEBUG "%s: " format, \ |
54 | MY_NAME , ## arg); \ | 54 | MY_NAME, ## arg); \ |
55 | } while (0) | 55 | } while (0) |
56 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) | 56 | #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
57 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 57 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
58 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 58 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
59 | 59 | ||
60 | /* slot states */ | 60 | /* slot states */ |
61 | 61 | ||
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index f2945fa73d4f..611f6056221a 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -94,7 +94,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
94 | int retval, level; | 94 | int retval, level; |
95 | struct slot *slot = (struct slot *)hotplug_slot->private; | 95 | struct slot *slot = (struct slot *)hotplug_slot->private; |
96 | 96 | ||
97 | retval = rtas_get_power_level (slot->power_domain, &level); | 97 | retval = rtas_get_power_level(slot->power_domain, &level); |
98 | if (!retval) | 98 | if (!retval) |
99 | *value = level; | 99 | *value = level; |
100 | return retval; | 100 | return retval; |
@@ -356,8 +356,7 @@ EXPORT_SYMBOL_GPL(rpaphp_add_slot); | |||
356 | 356 | ||
357 | static void __exit cleanup_slots(void) | 357 | static void __exit cleanup_slots(void) |
358 | { | 358 | { |
359 | struct list_head *tmp, *n; | 359 | struct slot *slot, *next; |
360 | struct slot *slot; | ||
361 | 360 | ||
362 | /* | 361 | /* |
363 | * Unregister all of our slots with the pci_hotplug subsystem, | 362 | * Unregister all of our slots with the pci_hotplug subsystem, |
@@ -365,8 +364,8 @@ static void __exit cleanup_slots(void) | |||
365 | * memory will be freed in release_slot callback. | 364 | * memory will be freed in release_slot callback. |
366 | */ | 365 | */ |
367 | 366 | ||
368 | list_for_each_safe(tmp, n, &rpaphp_slot_head) { | 367 | list_for_each_entry_safe(slot, next, &rpaphp_slot_head, |
369 | slot = list_entry(tmp, struct slot, rpaphp_slot_list); | 368 | rpaphp_slot_list) { |
370 | list_del(&slot->rpaphp_slot_list); | 369 | list_del(&slot->rpaphp_slot_list); |
371 | pci_hp_deregister(slot->hotplug_slot); | 370 | pci_hp_deregister(slot->hotplug_slot); |
372 | } | 371 | } |
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 9243f3e7a1c9..7836d6913e67 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c | |||
@@ -126,7 +126,7 @@ int rpaphp_enable_slot(struct slot *slot) | |||
126 | if (rpaphp_debug) { | 126 | if (rpaphp_debug) { |
127 | struct pci_dev *dev; | 127 | struct pci_dev *dev; |
128 | dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name); | 128 | dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name); |
129 | list_for_each_entry (dev, &bus->devices, bus_list) | 129 | list_for_each_entry(dev, &bus->devices, bus_list) |
130 | dbg("\t%s\n", pci_name(dev)); | 130 | dbg("\t%s\n", pci_name(dev)); |
131 | } | 131 | } |
132 | } | 132 | } |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index a6082cc263f7..6937c725b00b 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -48,7 +48,7 @@ void dealloc_slot_struct(struct slot *slot) | |||
48 | } | 48 | } |
49 | 49 | ||
50 | struct slot *alloc_slot_struct(struct device_node *dn, | 50 | struct slot *alloc_slot_struct(struct device_node *dn, |
51 | int drc_index, char *drc_name, int power_domain) | 51 | int drc_index, char *drc_name, int power_domain) |
52 | { | 52 | { |
53 | struct slot *slot; | 53 | struct slot *slot; |
54 | 54 | ||
diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c index d77e46bca54c..eb5efaef06ea 100644 --- a/drivers/pci/hotplug/s390_pci_hpc.c +++ b/drivers/pci/hotplug/s390_pci_hpc.c | |||
@@ -201,11 +201,10 @@ error: | |||
201 | 201 | ||
202 | void zpci_exit_slot(struct zpci_dev *zdev) | 202 | void zpci_exit_slot(struct zpci_dev *zdev) |
203 | { | 203 | { |
204 | struct list_head *tmp, *n; | 204 | struct slot *slot, *next; |
205 | struct slot *slot; | ||
206 | 205 | ||
207 | list_for_each_safe(tmp, n, &s390_hotplug_slot_list) { | 206 | list_for_each_entry_safe(slot, next, &s390_hotplug_slot_list, |
208 | slot = list_entry(tmp, struct slot, slot_list); | 207 | slot_list) { |
209 | if (slot->zdev != zdev) | 208 | if (slot->zdev != zdev) |
210 | continue; | 209 | continue; |
211 | list_del(&slot->slot_list); | 210 | list_del(&slot->slot_list); |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index c32fb786d48e..339bce0403dd 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -99,7 +99,7 @@ static ssize_t path_show(struct pci_slot *pci_slot, char *buf) | |||
99 | if (!slot) | 99 | if (!slot) |
100 | return retval; | 100 | return retval; |
101 | 101 | ||
102 | retval = sprintf (buf, "%s\n", slot->physical_path); | 102 | retval = sprintf(buf, "%s\n", slot->physical_path); |
103 | return retval; | 103 | return retval; |
104 | } | 104 | } |
105 | 105 | ||
@@ -313,7 +313,7 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
313 | } | 313 | } |
314 | 314 | ||
315 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { | 315 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { |
316 | dev_dbg(&slot->pci_bus->self->dev,"remove failed rc = %d\n", rc); | 316 | dev_dbg(&slot->pci_bus->self->dev, "remove failed rc = %d\n", rc); |
317 | } | 317 | } |
318 | 318 | ||
319 | return rc; | 319 | return rc; |
@@ -488,7 +488,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
488 | 488 | ||
489 | /* free the ACPI resources for the slot */ | 489 | /* free the ACPI resources for the slot */ |
490 | if (SN_ACPI_BASE_SUPPORT() && | 490 | if (SN_ACPI_BASE_SUPPORT() && |
491 | PCI_CONTROLLER(slot->pci_bus)->companion) { | 491 | PCI_CONTROLLER(slot->pci_bus)->companion) { |
492 | unsigned long long adr; | 492 | unsigned long long adr; |
493 | struct acpi_device *device; | 493 | struct acpi_device *device; |
494 | acpi_handle phandle; | 494 | acpi_handle phandle; |
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 5897d516427b..4da8fc601467 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -50,14 +50,14 @@ extern bool shpchp_debug; | |||
50 | #define dbg(format, arg...) \ | 50 | #define dbg(format, arg...) \ |
51 | do { \ | 51 | do { \ |
52 | if (shpchp_debug) \ | 52 | if (shpchp_debug) \ |
53 | printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); \ | 53 | printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg); \ |
54 | } while (0) | 54 | } while (0) |
55 | #define err(format, arg...) \ | 55 | #define err(format, arg...) \ |
56 | printk(KERN_ERR "%s: " format, MY_NAME , ## arg) | 56 | printk(KERN_ERR "%s: " format, MY_NAME, ## arg) |
57 | #define info(format, arg...) \ | 57 | #define info(format, arg...) \ |
58 | printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 58 | printk(KERN_INFO "%s: " format, MY_NAME, ## arg) |
59 | #define warn(format, arg...) \ | 59 | #define warn(format, arg...) \ |
60 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 60 | printk(KERN_WARNING "%s: " format, MY_NAME, ## arg) |
61 | 61 | ||
62 | #define ctrl_dbg(ctrl, format, arg...) \ | 62 | #define ctrl_dbg(ctrl, format, arg...) \ |
63 | do { \ | 63 | do { \ |
@@ -84,7 +84,7 @@ struct slot { | |||
84 | u8 presence_save; | 84 | u8 presence_save; |
85 | u8 pwr_save; | 85 | u8 pwr_save; |
86 | struct controller *ctrl; | 86 | struct controller *ctrl; |
87 | struct hpc_ops *hpc_ops; | 87 | const struct hpc_ops *hpc_ops; |
88 | struct hotplug_slot *hotplug_slot; | 88 | struct hotplug_slot *hotplug_slot; |
89 | struct list_head slot_list; | 89 | struct list_head slot_list; |
90 | struct delayed_work work; /* work for button event */ | 90 | struct delayed_work work; /* work for button event */ |
@@ -106,7 +106,7 @@ struct controller { | |||
106 | int slot_num_inc; /* 1 or -1 */ | 106 | int slot_num_inc; /* 1 or -1 */ |
107 | struct pci_dev *pci_dev; | 107 | struct pci_dev *pci_dev; |
108 | struct list_head slot_list; | 108 | struct list_head slot_list; |
109 | struct hpc_ops *hpc_ops; | 109 | const struct hpc_ops *hpc_ops; |
110 | wait_queue_head_t queue; /* sleep & wake process */ | 110 | wait_queue_head_t queue; /* sleep & wake process */ |
111 | u8 slot_device_offset; | 111 | u8 slot_device_offset; |
112 | u32 pcix_misc2_reg; /* for amd pogo errata */ | 112 | u32 pcix_misc2_reg; /* for amd pogo errata */ |
@@ -295,7 +295,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) | |||
295 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); | 295 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); |
296 | } | 296 | } |
297 | /* restore MiscII register */ | 297 | /* restore MiscII register */ |
298 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp ); | 298 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp); |
299 | 299 | ||
300 | if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK) | 300 | if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK) |
301 | pcix_misc2_temp |= SERRFATALENABLE_MASK; | 301 | pcix_misc2_temp |= SERRFATALENABLE_MASK; |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 294ef4b10cf1..3454dc7385f1 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -57,13 +57,13 @@ MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds"); | |||
57 | 57 | ||
58 | #define SHPC_MODULE_NAME "shpchp" | 58 | #define SHPC_MODULE_NAME "shpchp" |
59 | 59 | ||
60 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | 60 | static int set_attention_status(struct hotplug_slot *slot, u8 value); |
61 | static int enable_slot (struct hotplug_slot *slot); | 61 | static int enable_slot(struct hotplug_slot *slot); |
62 | static int disable_slot (struct hotplug_slot *slot); | 62 | static int disable_slot(struct hotplug_slot *slot); |
63 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | 63 | static int get_power_status(struct hotplug_slot *slot, u8 *value); |
64 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | 64 | static int get_attention_status(struct hotplug_slot *slot, u8 *value); |
65 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | 65 | static int get_latch_status(struct hotplug_slot *slot, u8 *value); |
66 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | 66 | static int get_adapter_status(struct hotplug_slot *slot, u8 *value); |
67 | 67 | ||
68 | static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { | 68 | static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { |
69 | .set_attention_status = set_attention_status, | 69 | .set_attention_status = set_attention_status, |
@@ -178,12 +178,9 @@ error: | |||
178 | 178 | ||
179 | void cleanup_slots(struct controller *ctrl) | 179 | void cleanup_slots(struct controller *ctrl) |
180 | { | 180 | { |
181 | struct list_head *tmp; | 181 | struct slot *slot, *next; |
182 | struct list_head *next; | ||
183 | struct slot *slot; | ||
184 | 182 | ||
185 | list_for_each_safe(tmp, next, &ctrl->slot_list) { | 183 | list_for_each_entry_safe(slot, next, &ctrl->slot_list, slot_list) { |
186 | slot = list_entry(tmp, struct slot, slot_list); | ||
187 | list_del(&slot->slot_list); | 184 | list_del(&slot->slot_list); |
188 | cancel_delayed_work(&slot->work); | 185 | cancel_delayed_work(&slot->work); |
189 | destroy_workqueue(slot->wq); | 186 | destroy_workqueue(slot->wq); |
@@ -194,7 +191,7 @@ void cleanup_slots(struct controller *ctrl) | |||
194 | /* | 191 | /* |
195 | * set_attention_status - Turns the Amber LED for a slot on, off or blink | 192 | * set_attention_status - Turns the Amber LED for a slot on, off or blink |
196 | */ | 193 | */ |
197 | static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | 194 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) |
198 | { | 195 | { |
199 | struct slot *slot = get_slot(hotplug_slot); | 196 | struct slot *slot = get_slot(hotplug_slot); |
200 | 197 | ||
@@ -207,7 +204,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
207 | return 0; | 204 | return 0; |
208 | } | 205 | } |
209 | 206 | ||
210 | static int enable_slot (struct hotplug_slot *hotplug_slot) | 207 | static int enable_slot(struct hotplug_slot *hotplug_slot) |
211 | { | 208 | { |
212 | struct slot *slot = get_slot(hotplug_slot); | 209 | struct slot *slot = get_slot(hotplug_slot); |
213 | 210 | ||
@@ -217,7 +214,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot) | |||
217 | return shpchp_sysfs_enable_slot(slot); | 214 | return shpchp_sysfs_enable_slot(slot); |
218 | } | 215 | } |
219 | 216 | ||
220 | static int disable_slot (struct hotplug_slot *hotplug_slot) | 217 | static int disable_slot(struct hotplug_slot *hotplug_slot) |
221 | { | 218 | { |
222 | struct slot *slot = get_slot(hotplug_slot); | 219 | struct slot *slot = get_slot(hotplug_slot); |
223 | 220 | ||
@@ -227,7 +224,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot) | |||
227 | return shpchp_sysfs_disable_slot(slot); | 224 | return shpchp_sysfs_disable_slot(slot); |
228 | } | 225 | } |
229 | 226 | ||
230 | static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | 227 | static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) |
231 | { | 228 | { |
232 | struct slot *slot = get_slot(hotplug_slot); | 229 | struct slot *slot = get_slot(hotplug_slot); |
233 | int retval; | 230 | int retval; |
@@ -242,7 +239,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
242 | return 0; | 239 | return 0; |
243 | } | 240 | } |
244 | 241 | ||
245 | static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | 242 | static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) |
246 | { | 243 | { |
247 | struct slot *slot = get_slot(hotplug_slot); | 244 | struct slot *slot = get_slot(hotplug_slot); |
248 | int retval; | 245 | int retval; |
@@ -257,7 +254,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
257 | return 0; | 254 | return 0; |
258 | } | 255 | } |
259 | 256 | ||
260 | static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | 257 | static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) |
261 | { | 258 | { |
262 | struct slot *slot = get_slot(hotplug_slot); | 259 | struct slot *slot = get_slot(hotplug_slot); |
263 | int retval; | 260 | int retval; |
@@ -272,7 +269,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
272 | return 0; | 269 | return 0; |
273 | } | 270 | } |
274 | 271 | ||
275 | static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | 272 | static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) |
276 | { | 273 | { |
277 | struct slot *slot = get_slot(hotplug_slot); | 274 | struct slot *slot = get_slot(hotplug_slot); |
278 | int retval; | 275 | int retval; |
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 7d223e9080ef..de0ea474fb73 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -542,7 +542,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value) | |||
542 | u8 slot_cmd = 0; | 542 | u8 slot_cmd = 0; |
543 | 543 | ||
544 | switch (value) { | 544 | switch (value) { |
545 | case 0 : | 545 | case 0: |
546 | slot_cmd = SET_ATTN_OFF; /* OFF */ | 546 | slot_cmd = SET_ATTN_OFF; /* OFF */ |
547 | break; | 547 | break; |
548 | case 1: | 548 | case 1: |
@@ -910,7 +910,7 @@ static int shpc_get_max_bus_speed(struct controller *ctrl) | |||
910 | return retval; | 910 | return retval; |
911 | } | 911 | } |
912 | 912 | ||
913 | static struct hpc_ops shpchp_hpc_ops = { | 913 | static const struct hpc_ops shpchp_hpc_ops = { |
914 | .power_on_slot = hpc_power_on_slot, | 914 | .power_on_slot = hpc_power_on_slot, |
915 | .slot_enable = hpc_slot_enable, | 915 | .slot_enable = hpc_slot_enable, |
916 | .slot_disable = hpc_slot_disable, | 916 | .slot_disable = hpc_slot_disable, |
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c index 52875b360463..7efb56a28c9f 100644 --- a/drivers/pci/hotplug/shpchp_sysfs.c +++ b/drivers/pci/hotplug/shpchp_sysfs.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | /* A few routines that create sysfs entries for the hot plug controller */ | 36 | /* A few routines that create sysfs entries for the hot plug controller */ |
37 | 37 | ||
38 | static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) | 38 | static ssize_t show_ctrl(struct device *dev, struct device_attribute *attr, char *buf) |
39 | { | 39 | { |
40 | struct pci_dev *pdev; | 40 | struct pci_dev *pdev; |
41 | char *out = buf; | 41 | char *out = buf; |
@@ -43,7 +43,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha | |||
43 | struct resource *res; | 43 | struct resource *res; |
44 | struct pci_bus *bus; | 44 | struct pci_bus *bus; |
45 | 45 | ||
46 | pdev = container_of (dev, struct pci_dev, dev); | 46 | pdev = to_pci_dev(dev); |
47 | bus = pdev->subordinate; | 47 | bus = pdev->subordinate; |
48 | 48 | ||
49 | out += sprintf(buf, "Free resources: memory\n"); | 49 | out += sprintf(buf, "Free resources: memory\n"); |
@@ -83,11 +83,11 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha | |||
83 | 83 | ||
84 | return out - buf; | 84 | return out - buf; |
85 | } | 85 | } |
86 | static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); | 86 | static DEVICE_ATTR(ctrl, S_IRUGO, show_ctrl, NULL); |
87 | 87 | ||
88 | int shpchp_create_ctrl_files (struct controller *ctrl) | 88 | int shpchp_create_ctrl_files(struct controller *ctrl) |
89 | { | 89 | { |
90 | return device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); | 90 | return device_create_file(&ctrl->pci_dev->dev, &dev_attr_ctrl); |
91 | } | 91 | } |
92 | 92 | ||
93 | void shpchp_remove_ctrl_files(struct controller *ctrl) | 93 | void shpchp_remove_ctrl_files(struct controller *ctrl) |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 7a0df3fdbfae..a080f4496fe2 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -1026,10 +1026,6 @@ int pci_msi_enabled(void) | |||
1026 | } | 1026 | } |
1027 | EXPORT_SYMBOL(pci_msi_enabled); | 1027 | EXPORT_SYMBOL(pci_msi_enabled); |
1028 | 1028 | ||
1029 | void pci_msi_init_pci_dev(struct pci_dev *dev) | ||
1030 | { | ||
1031 | } | ||
1032 | |||
1033 | /** | 1029 | /** |
1034 | * pci_enable_msi_range - configure device's MSI capability structure | 1030 | * pci_enable_msi_range - configure device's MSI capability structure |
1035 | * @dev: device to configure | 1031 | * @dev: device to configure |
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index 024b5c179348..0ae74d96ed85 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c | |||
@@ -77,7 +77,7 @@ static umode_t smbios_instance_string_exist(struct kobject *kobj, | |||
77 | struct device *dev; | 77 | struct device *dev; |
78 | struct pci_dev *pdev; | 78 | struct pci_dev *pdev; |
79 | 79 | ||
80 | dev = container_of(kobj, struct device, kobj); | 80 | dev = kobj_to_dev(kobj); |
81 | pdev = to_pci_dev(dev); | 81 | pdev = to_pci_dev(dev); |
82 | 82 | ||
83 | return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE) ? | 83 | return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE) ? |
@@ -221,7 +221,7 @@ static umode_t acpi_index_string_exist(struct kobject *kobj, | |||
221 | { | 221 | { |
222 | struct device *dev; | 222 | struct device *dev; |
223 | 223 | ||
224 | dev = container_of(kobj, struct device, kobj); | 224 | dev = kobj_to_dev(kobj); |
225 | 225 | ||
226 | if (device_has_dsm(dev)) | 226 | if (device_has_dsm(dev)) |
227 | return S_IRUGO; | 227 | return S_IRUGO; |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index eead54cd01b2..95d9e7bd933b 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -630,8 +630,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, | |||
630 | struct bin_attribute *bin_attr, char *buf, | 630 | struct bin_attribute *bin_attr, char *buf, |
631 | loff_t off, size_t count) | 631 | loff_t off, size_t count) |
632 | { | 632 | { |
633 | struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, | 633 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
634 | kobj)); | ||
635 | unsigned int size = 64; | 634 | unsigned int size = 64; |
636 | loff_t init_off = off; | 635 | loff_t init_off = off; |
637 | u8 *data = (u8 *) buf; | 636 | u8 *data = (u8 *) buf; |
@@ -707,8 +706,7 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj, | |||
707 | struct bin_attribute *bin_attr, char *buf, | 706 | struct bin_attribute *bin_attr, char *buf, |
708 | loff_t off, size_t count) | 707 | loff_t off, size_t count) |
709 | { | 708 | { |
710 | struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, | 709 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
711 | kobj)); | ||
712 | unsigned int size = count; | 710 | unsigned int size = count; |
713 | loff_t init_off = off; | 711 | loff_t init_off = off; |
714 | u8 *data = (u8 *) buf; | 712 | u8 *data = (u8 *) buf; |
@@ -769,8 +767,7 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj, | |||
769 | struct bin_attribute *bin_attr, char *buf, | 767 | struct bin_attribute *bin_attr, char *buf, |
770 | loff_t off, size_t count) | 768 | loff_t off, size_t count) |
771 | { | 769 | { |
772 | struct pci_dev *dev = | 770 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
773 | to_pci_dev(container_of(kobj, struct device, kobj)); | ||
774 | 771 | ||
775 | if (off > bin_attr->size) | 772 | if (off > bin_attr->size) |
776 | count = 0; | 773 | count = 0; |
@@ -784,8 +781,7 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj, | |||
784 | struct bin_attribute *bin_attr, char *buf, | 781 | struct bin_attribute *bin_attr, char *buf, |
785 | loff_t off, size_t count) | 782 | loff_t off, size_t count) |
786 | { | 783 | { |
787 | struct pci_dev *dev = | 784 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
788 | to_pci_dev(container_of(kobj, struct device, kobj)); | ||
789 | 785 | ||
790 | if (off > bin_attr->size) | 786 | if (off > bin_attr->size) |
791 | count = 0; | 787 | count = 0; |
@@ -812,8 +808,7 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj, | |||
812 | struct bin_attribute *bin_attr, char *buf, | 808 | struct bin_attribute *bin_attr, char *buf, |
813 | loff_t off, size_t count) | 809 | loff_t off, size_t count) |
814 | { | 810 | { |
815 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 811 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
816 | kobj)); | ||
817 | 812 | ||
818 | /* Only support 1, 2 or 4 byte accesses */ | 813 | /* Only support 1, 2 or 4 byte accesses */ |
819 | if (count != 1 && count != 2 && count != 4) | 814 | if (count != 1 && count != 2 && count != 4) |
@@ -838,8 +833,7 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj, | |||
838 | struct bin_attribute *bin_attr, char *buf, | 833 | struct bin_attribute *bin_attr, char *buf, |
839 | loff_t off, size_t count) | 834 | loff_t off, size_t count) |
840 | { | 835 | { |
841 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 836 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
842 | kobj)); | ||
843 | 837 | ||
844 | /* Only support 1, 2 or 4 byte accesses */ | 838 | /* Only support 1, 2 or 4 byte accesses */ |
845 | if (count != 1 && count != 2 && count != 4) | 839 | if (count != 1 && count != 2 && count != 4) |
@@ -863,8 +857,7 @@ static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, | |||
863 | struct bin_attribute *attr, | 857 | struct bin_attribute *attr, |
864 | struct vm_area_struct *vma) | 858 | struct vm_area_struct *vma) |
865 | { | 859 | { |
866 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 860 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
867 | kobj)); | ||
868 | 861 | ||
869 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); | 862 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); |
870 | } | 863 | } |
@@ -884,8 +877,7 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, | |||
884 | struct bin_attribute *attr, | 877 | struct bin_attribute *attr, |
885 | struct vm_area_struct *vma) | 878 | struct vm_area_struct *vma) |
886 | { | 879 | { |
887 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 880 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
888 | kobj)); | ||
889 | 881 | ||
890 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); | 882 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); |
891 | } | 883 | } |
@@ -1000,8 +992,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, | |||
1000 | static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | 992 | static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, |
1001 | struct vm_area_struct *vma, int write_combine) | 993 | struct vm_area_struct *vma, int write_combine) |
1002 | { | 994 | { |
1003 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 995 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1004 | struct device, kobj)); | ||
1005 | struct resource *res = attr->private; | 996 | struct resource *res = attr->private; |
1006 | enum pci_mmap_state mmap_type; | 997 | enum pci_mmap_state mmap_type; |
1007 | resource_size_t start, end; | 998 | resource_size_t start, end; |
@@ -1054,8 +1045,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj, | |||
1054 | struct bin_attribute *attr, char *buf, | 1045 | struct bin_attribute *attr, char *buf, |
1055 | loff_t off, size_t count, bool write) | 1046 | loff_t off, size_t count, bool write) |
1056 | { | 1047 | { |
1057 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 1048 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1058 | struct device, kobj)); | ||
1059 | struct resource *res = attr->private; | 1049 | struct resource *res = attr->private; |
1060 | unsigned long port = off; | 1050 | unsigned long port = off; |
1061 | int i; | 1051 | int i; |
@@ -1225,7 +1215,7 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj, | |||
1225 | struct bin_attribute *bin_attr, char *buf, | 1215 | struct bin_attribute *bin_attr, char *buf, |
1226 | loff_t off, size_t count) | 1216 | loff_t off, size_t count) |
1227 | { | 1217 | { |
1228 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 1218 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1229 | 1219 | ||
1230 | if ((off == 0) && (*buf == '0') && (count == 2)) | 1220 | if ((off == 0) && (*buf == '0') && (count == 2)) |
1231 | pdev->rom_attr_enabled = 0; | 1221 | pdev->rom_attr_enabled = 0; |
@@ -1251,7 +1241,7 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj, | |||
1251 | struct bin_attribute *bin_attr, char *buf, | 1241 | struct bin_attribute *bin_attr, char *buf, |
1252 | loff_t off, size_t count) | 1242 | loff_t off, size_t count) |
1253 | { | 1243 | { |
1254 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 1244 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1255 | void __iomem *rom; | 1245 | void __iomem *rom; |
1256 | size_t size; | 1246 | size_t size; |
1257 | 1247 | ||
@@ -1372,10 +1362,10 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) | |||
1372 | if (!sysfs_initialized) | 1362 | if (!sysfs_initialized) |
1373 | return -EACCES; | 1363 | return -EACCES; |
1374 | 1364 | ||
1375 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) | 1365 | if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) |
1376 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1377 | else | ||
1378 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 1366 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
1367 | else | ||
1368 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1379 | if (retval) | 1369 | if (retval) |
1380 | goto err; | 1370 | goto err; |
1381 | 1371 | ||
@@ -1427,10 +1417,10 @@ err_rom_file: | |||
1427 | err_resource_files: | 1417 | err_resource_files: |
1428 | pci_remove_resource_files(pdev); | 1418 | pci_remove_resource_files(pdev); |
1429 | err_config_file: | 1419 | err_config_file: |
1430 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) | 1420 | if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) |
1431 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1432 | else | ||
1433 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 1421 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
1422 | else | ||
1423 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1434 | err: | 1424 | err: |
1435 | return retval; | 1425 | return retval; |
1436 | } | 1426 | } |
@@ -1464,10 +1454,10 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) | |||
1464 | 1454 | ||
1465 | pci_remove_capabilities_sysfs(pdev); | 1455 | pci_remove_capabilities_sysfs(pdev); |
1466 | 1456 | ||
1467 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) | 1457 | if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) |
1468 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1469 | else | ||
1470 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 1458 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
1459 | else | ||
1460 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | ||
1471 | 1461 | ||
1472 | pci_remove_resource_files(pdev); | 1462 | pci_remove_resource_files(pdev); |
1473 | 1463 | ||
@@ -1511,7 +1501,7 @@ static struct attribute *pci_dev_dev_attrs[] = { | |||
1511 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | 1501 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, |
1512 | struct attribute *a, int n) | 1502 | struct attribute *a, int n) |
1513 | { | 1503 | { |
1514 | struct device *dev = container_of(kobj, struct device, kobj); | 1504 | struct device *dev = kobj_to_dev(kobj); |
1515 | struct pci_dev *pdev = to_pci_dev(dev); | 1505 | struct pci_dev *pdev = to_pci_dev(dev); |
1516 | 1506 | ||
1517 | if (a == &vga_attr.attr) | 1507 | if (a == &vga_attr.attr) |
@@ -1530,7 +1520,7 @@ static struct attribute *pci_dev_hp_attrs[] = { | |||
1530 | static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, | 1520 | static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, |
1531 | struct attribute *a, int n) | 1521 | struct attribute *a, int n) |
1532 | { | 1522 | { |
1533 | struct device *dev = container_of(kobj, struct device, kobj); | 1523 | struct device *dev = kobj_to_dev(kobj); |
1534 | struct pci_dev *pdev = to_pci_dev(dev); | 1524 | struct pci_dev *pdev = to_pci_dev(dev); |
1535 | 1525 | ||
1536 | if (pdev->is_virtfn) | 1526 | if (pdev->is_virtfn) |
@@ -1554,7 +1544,7 @@ static struct attribute *sriov_dev_attrs[] = { | |||
1554 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, | 1544 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, |
1555 | struct attribute *a, int n) | 1545 | struct attribute *a, int n) |
1556 | { | 1546 | { |
1557 | struct device *dev = container_of(kobj, struct device, kobj); | 1547 | struct device *dev = kobj_to_dev(kobj); |
1558 | 1548 | ||
1559 | if (!dev_is_pf(dev)) | 1549 | if (!dev_is_pf(dev)) |
1560 | return 0; | 1550 | return 0; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d1a7105b9276..602eb4223510 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1417,7 +1417,7 @@ struct pci_devres { | |||
1417 | 1417 | ||
1418 | static void pcim_release(struct device *gendev, void *res) | 1418 | static void pcim_release(struct device *gendev, void *res) |
1419 | { | 1419 | { |
1420 | struct pci_dev *dev = container_of(gendev, struct pci_dev, dev); | 1420 | struct pci_dev *dev = to_pci_dev(gendev); |
1421 | struct pci_devres *this = res; | 1421 | struct pci_devres *this = res; |
1422 | int i; | 1422 | int i; |
1423 | 1423 | ||
@@ -1534,7 +1534,7 @@ void __weak pcibios_release_device(struct pci_dev *dev) {} | |||
1534 | * is the default implementation. Architecture implementations can | 1534 | * is the default implementation. Architecture implementations can |
1535 | * override this. | 1535 | * override this. |
1536 | */ | 1536 | */ |
1537 | void __weak pcibios_disable_device (struct pci_dev *dev) {} | 1537 | void __weak pcibios_disable_device(struct pci_dev *dev) {} |
1538 | 1538 | ||
1539 | /** | 1539 | /** |
1540 | * pcibios_penalize_isa_irq - penalize an ISA IRQ | 1540 | * pcibios_penalize_isa_irq - penalize an ISA IRQ |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f6f151a42147..9a1660f592ef 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -144,10 +144,8 @@ extern unsigned int pci_pm_d3_delay; | |||
144 | 144 | ||
145 | #ifdef CONFIG_PCI_MSI | 145 | #ifdef CONFIG_PCI_MSI |
146 | void pci_no_msi(void); | 146 | void pci_no_msi(void); |
147 | void pci_msi_init_pci_dev(struct pci_dev *dev); | ||
148 | #else | 147 | #else |
149 | static inline void pci_no_msi(void) { } | 148 | static inline void pci_no_msi(void) { } |
150 | static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } | ||
151 | #endif | 149 | #endif |
152 | 150 | ||
153 | static inline void pci_msi_set_enable(struct pci_dev *dev, int enable) | 151 | static inline void pci_msi_set_enable(struct pci_dev *dev, int enable) |
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c index 182224acedbe..20db790465dd 100644 --- a/drivers/pci/pcie/aer/aer_inject.c +++ b/drivers/pci/pcie/aer/aer_inject.c | |||
@@ -41,12 +41,12 @@ struct aer_error_inj { | |||
41 | u32 header_log1; | 41 | u32 header_log1; |
42 | u32 header_log2; | 42 | u32 header_log2; |
43 | u32 header_log3; | 43 | u32 header_log3; |
44 | u16 domain; | 44 | u32 domain; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | struct aer_error { | 47 | struct aer_error { |
48 | struct list_head list; | 48 | struct list_head list; |
49 | u16 domain; | 49 | u32 domain; |
50 | unsigned int bus; | 50 | unsigned int bus; |
51 | unsigned int devfn; | 51 | unsigned int devfn; |
52 | int pos_cap_err; | 52 | int pos_cap_err; |
@@ -74,7 +74,7 @@ static LIST_HEAD(pci_bus_ops_list); | |||
74 | /* Protect einjected and pci_bus_ops_list */ | 74 | /* Protect einjected and pci_bus_ops_list */ |
75 | static DEFINE_SPINLOCK(inject_lock); | 75 | static DEFINE_SPINLOCK(inject_lock); |
76 | 76 | ||
77 | static void aer_error_init(struct aer_error *err, u16 domain, | 77 | static void aer_error_init(struct aer_error *err, u32 domain, |
78 | unsigned int bus, unsigned int devfn, | 78 | unsigned int bus, unsigned int devfn, |
79 | int pos_cap_err) | 79 | int pos_cap_err) |
80 | { | 80 | { |
@@ -86,7 +86,7 @@ static void aer_error_init(struct aer_error *err, u16 domain, | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /* inject_lock must be held before calling */ | 88 | /* inject_lock must be held before calling */ |
89 | static struct aer_error *__find_aer_error(u16 domain, unsigned int bus, | 89 | static struct aer_error *__find_aer_error(u32 domain, unsigned int bus, |
90 | unsigned int devfn) | 90 | unsigned int devfn) |
91 | { | 91 | { |
92 | struct aer_error *err; | 92 | struct aer_error *err; |
@@ -106,7 +106,7 @@ static struct aer_error *__find_aer_error_by_dev(struct pci_dev *dev) | |||
106 | int domain = pci_domain_nr(dev->bus); | 106 | int domain = pci_domain_nr(dev->bus); |
107 | if (domain < 0) | 107 | if (domain < 0) |
108 | return NULL; | 108 | return NULL; |
109 | return __find_aer_error((u16)domain, dev->bus->number, dev->devfn); | 109 | return __find_aer_error(domain, dev->bus->number, dev->devfn); |
110 | } | 110 | } |
111 | 111 | ||
112 | /* inject_lock must be held before calling */ | 112 | /* inject_lock must be held before calling */ |
@@ -196,7 +196,7 @@ static int pci_read_aer(struct pci_bus *bus, unsigned int devfn, int where, | |||
196 | domain = pci_domain_nr(bus); | 196 | domain = pci_domain_nr(bus); |
197 | if (domain < 0) | 197 | if (domain < 0) |
198 | goto out; | 198 | goto out; |
199 | err = __find_aer_error((u16)domain, bus->number, devfn); | 199 | err = __find_aer_error(domain, bus->number, devfn); |
200 | if (!err) | 200 | if (!err) |
201 | goto out; | 201 | goto out; |
202 | 202 | ||
@@ -228,7 +228,7 @@ static int pci_write_aer(struct pci_bus *bus, unsigned int devfn, int where, | |||
228 | domain = pci_domain_nr(bus); | 228 | domain = pci_domain_nr(bus); |
229 | if (domain < 0) | 229 | if (domain < 0) |
230 | goto out; | 230 | goto out; |
231 | err = __find_aer_error((u16)domain, bus->number, devfn); | 231 | err = __find_aer_error(domain, bus->number, devfn); |
232 | if (!err) | 232 | if (!err) |
233 | goto out; | 233 | goto out; |
234 | 234 | ||
@@ -329,7 +329,7 @@ static int aer_inject(struct aer_error_inj *einj) | |||
329 | u32 sever, cor_mask, uncor_mask, cor_mask_orig = 0, uncor_mask_orig = 0; | 329 | u32 sever, cor_mask, uncor_mask, cor_mask_orig = 0, uncor_mask_orig = 0; |
330 | int ret = 0; | 330 | int ret = 0; |
331 | 331 | ||
332 | dev = pci_get_domain_bus_and_slot((int)einj->domain, einj->bus, devfn); | 332 | dev = pci_get_domain_bus_and_slot(einj->domain, einj->bus, devfn); |
333 | if (!dev) | 333 | if (!dev) |
334 | return -ENODEV; | 334 | return -ENODEV; |
335 | rpdev = pcie_find_root_port(dev); | 335 | rpdev = pcie_find_root_port(dev); |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index fba785e9df75..712392504ed9 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -246,7 +246,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
246 | !dev->driver->err_handler || | 246 | !dev->driver->err_handler || |
247 | !dev->driver->err_handler->error_detected) { | 247 | !dev->driver->err_handler->error_detected) { |
248 | if (result_data->state == pci_channel_io_frozen && | 248 | if (result_data->state == pci_channel_io_frozen && |
249 | !(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) { | 249 | dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { |
250 | /* | 250 | /* |
251 | * In case of fatal recovery, if one of down- | 251 | * In case of fatal recovery, if one of down- |
252 | * stream device has no driver. We might be | 252 | * stream device has no driver. We might be |
@@ -269,7 +269,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
269 | * without recovery. | 269 | * without recovery. |
270 | */ | 270 | */ |
271 | 271 | ||
272 | if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) | 272 | if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) |
273 | vote = PCI_ERS_RESULT_NO_AER_DRIVER; | 273 | vote = PCI_ERS_RESULT_NO_AER_DRIVER; |
274 | else | 274 | else |
275 | vote = PCI_ERS_RESULT_NONE; | 275 | vote = PCI_ERS_RESULT_NONE; |
@@ -369,7 +369,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, | |||
369 | else | 369 | else |
370 | result_data.result = PCI_ERS_RESULT_RECOVERED; | 370 | result_data.result = PCI_ERS_RESULT_RECOVERED; |
371 | 371 | ||
372 | if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 372 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
373 | /* | 373 | /* |
374 | * If the error is reported by a bridge, we think this error | 374 | * If the error is reported by a bridge, we think this error |
375 | * is related to the downstream link of the bridge, so we | 375 | * is related to the downstream link of the bridge, so we |
@@ -440,7 +440,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) | |||
440 | pci_ers_result_t status; | 440 | pci_ers_result_t status; |
441 | struct pcie_port_service_driver *driver; | 441 | struct pcie_port_service_driver *driver; |
442 | 442 | ||
443 | if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 443 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
444 | /* Reset this port for all subordinates */ | 444 | /* Reset this port for all subordinates */ |
445 | udev = dev; | 445 | udev = dev; |
446 | } else { | 446 | } else { |
@@ -660,7 +660,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) | |||
660 | &info->mask); | 660 | &info->mask); |
661 | if (!(info->status & ~info->mask)) | 661 | if (!(info->status & ~info->mask)) |
662 | return 0; | 662 | return 0; |
663 | } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE || | 663 | } else if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
664 | info->severity == AER_NONFATAL) { | 664 | info->severity == AER_NONFATAL) { |
665 | 665 | ||
666 | /* Link is still healthy for IO reads */ | 666 | /* Link is still healthy for IO reads */ |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 317e3558a35e..2dfe7fdb77e7 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -834,21 +834,15 @@ static ssize_t link_state_store(struct device *dev, | |||
834 | { | 834 | { |
835 | struct pci_dev *pdev = to_pci_dev(dev); | 835 | struct pci_dev *pdev = to_pci_dev(dev); |
836 | struct pcie_link_state *link, *root = pdev->link_state->root; | 836 | struct pcie_link_state *link, *root = pdev->link_state->root; |
837 | u32 val, state = 0; | 837 | u32 state; |
838 | |||
839 | if (kstrtouint(buf, 10, &val)) | ||
840 | return -EINVAL; | ||
841 | 838 | ||
842 | if (aspm_disabled) | 839 | if (aspm_disabled) |
843 | return -EPERM; | 840 | return -EPERM; |
844 | if (n < 1 || val > 3) | ||
845 | return -EINVAL; | ||
846 | 841 | ||
847 | /* Convert requested state to ASPM state */ | 842 | if (kstrtouint(buf, 10, &state)) |
848 | if (val & PCIE_LINK_STATE_L0S) | 843 | return -EINVAL; |
849 | state |= ASPM_STATE_L0S; | 844 | if ((state & ~ASPM_STATE_ALL) != 0) |
850 | if (val & PCIE_LINK_STATE_L1) | 845 | return -EINVAL; |
851 | state |= ASPM_STATE_L1; | ||
852 | 846 | ||
853 | down_read(&pci_bus_sem); | 847 | down_read(&pci_bus_sem); |
854 | mutex_lock(&aspm_lock); | 848 | mutex_lock(&aspm_lock); |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 553a029e37f1..6d7ab9bb0d5a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1109,14 +1109,11 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev) | |||
1109 | int pos = PCI_CFG_SPACE_SIZE; | 1109 | int pos = PCI_CFG_SPACE_SIZE; |
1110 | 1110 | ||
1111 | if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) | 1111 | if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) |
1112 | goto fail; | 1112 | return PCI_CFG_SPACE_SIZE; |
1113 | if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) | 1113 | if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) |
1114 | goto fail; | 1114 | return PCI_CFG_SPACE_SIZE; |
1115 | 1115 | ||
1116 | return PCI_CFG_SPACE_EXP_SIZE; | 1116 | return PCI_CFG_SPACE_EXP_SIZE; |
1117 | |||
1118 | fail: | ||
1119 | return PCI_CFG_SPACE_SIZE; | ||
1120 | } | 1117 | } |
1121 | 1118 | ||
1122 | int pci_cfg_space_size(struct pci_dev *dev) | 1119 | int pci_cfg_space_size(struct pci_dev *dev) |
@@ -1129,25 +1126,23 @@ int pci_cfg_space_size(struct pci_dev *dev) | |||
1129 | if (class == PCI_CLASS_BRIDGE_HOST) | 1126 | if (class == PCI_CLASS_BRIDGE_HOST) |
1130 | return pci_cfg_space_size_ext(dev); | 1127 | return pci_cfg_space_size_ext(dev); |
1131 | 1128 | ||
1132 | if (!pci_is_pcie(dev)) { | 1129 | if (pci_is_pcie(dev)) |
1133 | pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); | 1130 | return pci_cfg_space_size_ext(dev); |
1134 | if (!pos) | ||
1135 | goto fail; | ||
1136 | 1131 | ||
1137 | pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); | 1132 | pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); |
1138 | if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))) | 1133 | if (!pos) |
1139 | goto fail; | 1134 | return PCI_CFG_SPACE_SIZE; |
1140 | } | ||
1141 | 1135 | ||
1142 | return pci_cfg_space_size_ext(dev); | 1136 | pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); |
1137 | if (status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ)) | ||
1138 | return pci_cfg_space_size_ext(dev); | ||
1143 | 1139 | ||
1144 | fail: | ||
1145 | return PCI_CFG_SPACE_SIZE; | 1140 | return PCI_CFG_SPACE_SIZE; |
1146 | } | 1141 | } |
1147 | 1142 | ||
1148 | #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) | 1143 | #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) |
1149 | 1144 | ||
1150 | void pci_msi_setup_pci_dev(struct pci_dev *dev) | 1145 | static void pci_msi_setup_pci_dev(struct pci_dev *dev) |
1151 | { | 1146 | { |
1152 | /* | 1147 | /* |
1153 | * Disable the MSI hardware to avoid screaming interrupts | 1148 | * Disable the MSI hardware to avoid screaming interrupts |
@@ -1214,8 +1209,6 @@ int pci_setup_device(struct pci_dev *dev) | |||
1214 | /* "Unknown power state" */ | 1209 | /* "Unknown power state" */ |
1215 | dev->current_state = PCI_UNKNOWN; | 1210 | dev->current_state = PCI_UNKNOWN; |
1216 | 1211 | ||
1217 | pci_msi_setup_pci_dev(dev); | ||
1218 | |||
1219 | /* Early fixups, before probing the BARs */ | 1212 | /* Early fixups, before probing the BARs */ |
1220 | pci_fixup_device(pci_fixup_early, dev); | 1213 | pci_fixup_device(pci_fixup_early, dev); |
1221 | /* device class may be changed after fixup */ | 1214 | /* device class may be changed after fixup */ |
@@ -1605,8 +1598,8 @@ static void pci_init_capabilities(struct pci_dev *dev) | |||
1605 | /* Enhanced Allocation */ | 1598 | /* Enhanced Allocation */ |
1606 | pci_ea_init(dev); | 1599 | pci_ea_init(dev); |
1607 | 1600 | ||
1608 | /* MSI/MSI-X list */ | 1601 | /* Setup MSI caps & disable MSI/MSI-X interrupts */ |
1609 | pci_msi_init_pci_dev(dev); | 1602 | pci_msi_setup_pci_dev(dev); |
1610 | 1603 | ||
1611 | /* Buffers for saving PCIe and PCI-X capabilities */ | 1604 | /* Buffers for saving PCIe and PCI-X capabilities */ |
1612 | pci_allocate_cap_save_buffers(dev); | 1605 | pci_allocate_cap_save_buffers(dev); |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index c2dd52ea4198..0575a1e026b4 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -287,6 +287,18 @@ static void quirk_citrine(struct pci_dev *dev) | |||
287 | } | 287 | } |
288 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine); | 288 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine); |
289 | 289 | ||
290 | /* | ||
291 | * This chip can cause bus lockups if config addresses above 0x600 | ||
292 | * are read or written. | ||
293 | */ | ||
294 | static void quirk_nfp6000(struct pci_dev *dev) | ||
295 | { | ||
296 | dev->cfg_size = 0x600; | ||
297 | } | ||
298 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP4000, quirk_nfp6000); | ||
299 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000, quirk_nfp6000); | ||
300 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000_VF, quirk_nfp6000); | ||
301 | |||
290 | /* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */ | 302 | /* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */ |
291 | static void quirk_extend_bar_to_page(struct pci_dev *dev) | 303 | static void quirk_extend_bar_to_page(struct pci_dev *dev) |
292 | { | 304 | { |
@@ -3622,6 +3634,10 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642, | |||
3622 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON, | 3634 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON, |
3623 | PCI_DEVICE_ID_JMICRON_JMB388_ESD, | 3635 | PCI_DEVICE_ID_JMICRON_JMB388_ESD, |
3624 | quirk_dma_func1_alias); | 3636 | quirk_dma_func1_alias); |
3637 | /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c117 */ | ||
3638 | DECLARE_PCI_FIXUP_HEADER(0x1c28, /* Lite-On */ | ||
3639 | 0x0122, /* Plextor M6E (Marvell 88SS9183)*/ | ||
3640 | quirk_dma_func1_alias); | ||
3625 | 3641 | ||
3626 | /* | 3642 | /* |
3627 | * Some devices DMA with the wrong devfn, not just the wrong function. | 3643 | * Some devices DMA with the wrong devfn, not just the wrong function. |
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index eb0ad530dc43..9eaca39ef38d 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -77,25 +77,24 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) | |||
77 | do { | 77 | do { |
78 | void __iomem *pds; | 78 | void __iomem *pds; |
79 | /* Standard PCI ROMs start out with these bytes 55 AA */ | 79 | /* Standard PCI ROMs start out with these bytes 55 AA */ |
80 | if (readb(image) != 0x55) { | 80 | if (readw(image) != 0xAA55) { |
81 | dev_err(&pdev->dev, "Invalid ROM contents\n"); | 81 | dev_err(&pdev->dev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", |
82 | readw(image)); | ||
82 | break; | 83 | break; |
83 | } | 84 | } |
84 | if (readb(image + 1) != 0xAA) | 85 | /* get the PCI data structure and check its "PCIR" signature */ |
85 | break; | ||
86 | /* get the PCI data structure and check its signature */ | ||
87 | pds = image + readw(image + 24); | 86 | pds = image + readw(image + 24); |
88 | if (readb(pds) != 'P') | 87 | if (readl(pds) != 0x52494350) { |
89 | break; | 88 | dev_err(&pdev->dev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", |
90 | if (readb(pds + 1) != 'C') | 89 | readl(pds)); |
91 | break; | ||
92 | if (readb(pds + 2) != 'I') | ||
93 | break; | ||
94 | if (readb(pds + 3) != 'R') | ||
95 | break; | 90 | break; |
91 | } | ||
96 | last_image = readb(pds + 21) & 0x80; | 92 | last_image = readb(pds + 21) & 0x80; |
97 | length = readw(pds + 16); | 93 | length = readw(pds + 16); |
98 | image += length * 512; | 94 | image += length * 512; |
95 | /* Avoid iterating through memory outside the resource window */ | ||
96 | if (image > rom + size) | ||
97 | break; | ||
99 | } while (length && !last_image); | 98 | } while (length && !last_image); |
100 | 99 | ||
101 | /* never return a size larger than the PCI resource window */ | 100 | /* never return a size larger than the PCI resource window */ |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1723ac1b30e1..7796d0a5befa 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -442,7 +442,7 @@ static void __assign_resources_sorted(struct list_head *head, | |||
442 | break; | 442 | break; |
443 | } | 443 | } |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | } | 447 | } |
448 | 448 | ||
diff --git a/include/linux/msi.h b/include/linux/msi.h index 1c6342ab8c0e..a2a0068a8387 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h | |||
@@ -187,7 +187,7 @@ struct msi_domain_info; | |||
187 | * @msi_free: Domain specific function to free a MSI interrupts | 187 | * @msi_free: Domain specific function to free a MSI interrupts |
188 | * @msi_check: Callback for verification of the domain/info/dev data | 188 | * @msi_check: Callback for verification of the domain/info/dev data |
189 | * @msi_prepare: Prepare the allocation of the interrupts in the domain | 189 | * @msi_prepare: Prepare the allocation of the interrupts in the domain |
190 | * @msi_finish: Optional callbacl to finalize the allocation | 190 | * @msi_finish: Optional callback to finalize the allocation |
191 | * @set_desc: Set the msi descriptor for an interrupt | 191 | * @set_desc: Set the msi descriptor for an interrupt |
192 | * @handle_error: Optional error handler if the allocation fails | 192 | * @handle_error: Optional error handler if the allocation fails |
193 | * | 193 | * |
@@ -195,7 +195,7 @@ struct msi_domain_info; | |||
195 | * msi_create_irq_domain() and related interfaces | 195 | * msi_create_irq_domain() and related interfaces |
196 | * | 196 | * |
197 | * @msi_check, @msi_prepare, @msi_finish, @set_desc and @handle_error | 197 | * @msi_check, @msi_prepare, @msi_finish, @set_desc and @handle_error |
198 | * are callbacks used by msi_irq_domain_alloc_irqs() and related | 198 | * are callbacks used by msi_domain_alloc_irqs() and related |
199 | * interfaces which are based on msi_desc. | 199 | * interfaces which are based on msi_desc. |
200 | */ | 200 | */ |
201 | struct msi_domain_ops { | 201 | struct msi_domain_ops { |
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 2c51ee78b1c0..f6e9e85164e8 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h | |||
@@ -59,6 +59,13 @@ static inline void of_pci_check_probe_only(void) { } | |||
59 | int of_pci_get_host_bridge_resources(struct device_node *dev, | 59 | int of_pci_get_host_bridge_resources(struct device_node *dev, |
60 | unsigned char busno, unsigned char bus_max, | 60 | unsigned char busno, unsigned char bus_max, |
61 | struct list_head *resources, resource_size_t *io_base); | 61 | struct list_head *resources, resource_size_t *io_base); |
62 | #else | ||
63 | static inline int of_pci_get_host_bridge_resources(struct device_node *dev, | ||
64 | unsigned char busno, unsigned char bus_max, | ||
65 | struct list_head *resources, resource_size_t *io_base) | ||
66 | { | ||
67 | return -EINVAL; | ||
68 | } | ||
62 | #endif | 69 | #endif |
63 | 70 | ||
64 | #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) | 71 | #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) |
diff --git a/include/linux/pci.h b/include/linux/pci.h index d86378c226fb..27df4a6585da 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -1257,8 +1257,6 @@ struct msix_entry { | |||
1257 | u16 entry; /* driver uses to specify entry, OS writes */ | 1257 | u16 entry; /* driver uses to specify entry, OS writes */ |
1258 | }; | 1258 | }; |
1259 | 1259 | ||
1260 | void pci_msi_setup_pci_dev(struct pci_dev *dev); | ||
1261 | |||
1262 | #ifdef CONFIG_PCI_MSI | 1260 | #ifdef CONFIG_PCI_MSI |
1263 | int pci_msi_vec_count(struct pci_dev *dev); | 1261 | int pci_msi_vec_count(struct pci_dev *dev); |
1264 | void pci_msi_shutdown(struct pci_dev *dev); | 1262 | void pci_msi_shutdown(struct pci_dev *dev); |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 1acbefc4bbda..37f05cb1dfd6 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -2496,6 +2496,11 @@ | |||
2496 | #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff | 2496 | #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff |
2497 | 2497 | ||
2498 | #define PCI_VENDOR_ID_NETRONOME 0x19ee | 2498 | #define PCI_VENDOR_ID_NETRONOME 0x19ee |
2499 | #define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200 | ||
2500 | #define PCI_DEVICE_ID_NETRONOME_NFP3240 0x3240 | ||
2501 | #define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000 | ||
2502 | #define PCI_DEVICE_ID_NETRONOME_NFP6000 0x6000 | ||
2503 | #define PCI_DEVICE_ID_NETRONOME_NFP6000_VF 0x6003 | ||
2499 | 2504 | ||
2500 | #define PCI_VENDOR_ID_QMI 0x1a32 | 2505 | #define PCI_VENDOR_ID_QMI 0x1a32 |
2501 | 2506 | ||
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8cf95de1ab3f..6e655f7acd3b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -1061,6 +1061,7 @@ void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, | |||
1061 | __irq_set_handler(virq, handler, 0, handler_name); | 1061 | __irq_set_handler(virq, handler, 0, handler_name); |
1062 | irq_set_handler_data(virq, handler_data); | 1062 | irq_set_handler_data(virq, handler_data); |
1063 | } | 1063 | } |
1064 | EXPORT_SYMBOL(irq_domain_set_info); | ||
1064 | 1065 | ||
1065 | /** | 1066 | /** |
1066 | * irq_domain_reset_irq_data - Clear hwirq, chip and chip_data in @irq_data | 1067 | * irq_domain_reset_irq_data - Clear hwirq, chip and chip_data in @irq_data |
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 15b249e7c673..38e89ce7b071 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c | |||
@@ -109,9 +109,11 @@ static int msi_domain_alloc(struct irq_domain *domain, unsigned int virq, | |||
109 | if (irq_find_mapping(domain, hwirq) > 0) | 109 | if (irq_find_mapping(domain, hwirq) > 0) |
110 | return -EEXIST; | 110 | return -EEXIST; |
111 | 111 | ||
112 | ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg); | 112 | if (domain->parent) { |
113 | if (ret < 0) | 113 | ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg); |
114 | return ret; | 114 | if (ret < 0) |
115 | return ret; | ||
116 | } | ||
115 | 117 | ||
116 | for (i = 0; i < nr_irqs; i++) { | 118 | for (i = 0; i < nr_irqs; i++) { |
117 | ret = ops->msi_init(domain, info, virq + i, hwirq + i, arg); | 119 | ret = ops->msi_init(domain, info, virq + i, hwirq + i, arg); |