diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2014-09-12 17:23:14 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-09-12 22:01:27 -0400 |
commit | 9ce90ea5c0d512ff66693b238167b56dbaef786b (patch) | |
tree | 7cc4ddf40415114108f1a8b1a0e78ef150bfb645 /drivers/pci/hotplug | |
parent | 1197ba22c57df96bf3cac0bb2a936fb695370f35 (diff) |
PCI: Move pci_get_hp_params() to drivers/pci/pci-acpi.c
Move pci_get_hp_params() and related functions from
drivers/pci/hotplug/acpi_pcihp.c to drivers/pci/pci-acpi.c.
Previously, pci_get_hp_params() was used only by hotplug drivers. But
future changes will move this into the normal device enumeration process,
so it will be used even when CONFIG_HOTPLUG_PCI is not set.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r-- | drivers/pci/hotplug/acpi_pcihp.c | 251 |
1 files changed, 0 insertions, 251 deletions
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index a94d850ae228..2ac9a28d7fa1 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -46,215 +46,6 @@ | |||
46 | 46 | ||
47 | static bool debug_acpi; | 47 | static bool debug_acpi; |
48 | 48 | ||
49 | static acpi_status | ||
50 | decode_type0_hpx_record(union acpi_object *record, struct hotplug_params *hpx) | ||
51 | { | ||
52 | int i; | ||
53 | union acpi_object *fields = record->package.elements; | ||
54 | u32 revision = fields[1].integer.value; | ||
55 | |||
56 | switch (revision) { | ||
57 | case 1: | ||
58 | if (record->package.count != 6) | ||
59 | return AE_ERROR; | ||
60 | for (i = 2; i < 6; i++) | ||
61 | if (fields[i].type != ACPI_TYPE_INTEGER) | ||
62 | return AE_ERROR; | ||
63 | hpx->t0 = &hpx->type0_data; | ||
64 | hpx->t0->revision = revision; | ||
65 | hpx->t0->cache_line_size = fields[2].integer.value; | ||
66 | hpx->t0->latency_timer = fields[3].integer.value; | ||
67 | hpx->t0->enable_serr = fields[4].integer.value; | ||
68 | hpx->t0->enable_perr = fields[5].integer.value; | ||
69 | break; | ||
70 | default: | ||
71 | printk(KERN_WARNING | ||
72 | "%s: Type 0 Revision %d record not supported\n", | ||
73 | __func__, revision); | ||
74 | return AE_ERROR; | ||
75 | } | ||
76 | return AE_OK; | ||
77 | } | ||
78 | |||
79 | static acpi_status | ||
80 | decode_type1_hpx_record(union acpi_object *record, struct hotplug_params *hpx) | ||
81 | { | ||
82 | int i; | ||
83 | union acpi_object *fields = record->package.elements; | ||
84 | u32 revision = fields[1].integer.value; | ||
85 | |||
86 | switch (revision) { | ||
87 | case 1: | ||
88 | if (record->package.count != 5) | ||
89 | return AE_ERROR; | ||
90 | for (i = 2; i < 5; i++) | ||
91 | if (fields[i].type != ACPI_TYPE_INTEGER) | ||
92 | return AE_ERROR; | ||
93 | hpx->t1 = &hpx->type1_data; | ||
94 | hpx->t1->revision = revision; | ||
95 | hpx->t1->max_mem_read = fields[2].integer.value; | ||
96 | hpx->t1->avg_max_split = fields[3].integer.value; | ||
97 | hpx->t1->tot_max_split = fields[4].integer.value; | ||
98 | break; | ||
99 | default: | ||
100 | printk(KERN_WARNING | ||
101 | "%s: Type 1 Revision %d record not supported\n", | ||
102 | __func__, revision); | ||
103 | return AE_ERROR; | ||
104 | } | ||
105 | return AE_OK; | ||
106 | } | ||
107 | |||
108 | static acpi_status | ||
109 | decode_type2_hpx_record(union acpi_object *record, struct hotplug_params *hpx) | ||
110 | { | ||
111 | int i; | ||
112 | union acpi_object *fields = record->package.elements; | ||
113 | u32 revision = fields[1].integer.value; | ||
114 | |||
115 | switch (revision) { | ||
116 | case 1: | ||
117 | if (record->package.count != 18) | ||
118 | return AE_ERROR; | ||
119 | for (i = 2; i < 18; i++) | ||
120 | if (fields[i].type != ACPI_TYPE_INTEGER) | ||
121 | return AE_ERROR; | ||
122 | hpx->t2 = &hpx->type2_data; | ||
123 | hpx->t2->revision = revision; | ||
124 | hpx->t2->unc_err_mask_and = fields[2].integer.value; | ||
125 | hpx->t2->unc_err_mask_or = fields[3].integer.value; | ||
126 | hpx->t2->unc_err_sever_and = fields[4].integer.value; | ||
127 | hpx->t2->unc_err_sever_or = fields[5].integer.value; | ||
128 | hpx->t2->cor_err_mask_and = fields[6].integer.value; | ||
129 | hpx->t2->cor_err_mask_or = fields[7].integer.value; | ||
130 | hpx->t2->adv_err_cap_and = fields[8].integer.value; | ||
131 | hpx->t2->adv_err_cap_or = fields[9].integer.value; | ||
132 | hpx->t2->pci_exp_devctl_and = fields[10].integer.value; | ||
133 | hpx->t2->pci_exp_devctl_or = fields[11].integer.value; | ||
134 | hpx->t2->pci_exp_lnkctl_and = fields[12].integer.value; | ||
135 | hpx->t2->pci_exp_lnkctl_or = fields[13].integer.value; | ||
136 | hpx->t2->sec_unc_err_sever_and = fields[14].integer.value; | ||
137 | hpx->t2->sec_unc_err_sever_or = fields[15].integer.value; | ||
138 | hpx->t2->sec_unc_err_mask_and = fields[16].integer.value; | ||
139 | hpx->t2->sec_unc_err_mask_or = fields[17].integer.value; | ||
140 | break; | ||
141 | default: | ||
142 | printk(KERN_WARNING | ||
143 | "%s: Type 2 Revision %d record not supported\n", | ||
144 | __func__, revision); | ||
145 | return AE_ERROR; | ||
146 | } | ||
147 | return AE_OK; | ||
148 | } | ||
149 | |||
150 | static acpi_status | ||
151 | acpi_run_hpx(acpi_handle handle, struct hotplug_params *hpx) | ||
152 | { | ||
153 | acpi_status status; | ||
154 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
155 | union acpi_object *package, *record, *fields; | ||
156 | u32 type; | ||
157 | int i; | ||
158 | |||
159 | /* Clear the return buffer with zeros */ | ||
160 | memset(hpx, 0, sizeof(struct hotplug_params)); | ||
161 | |||
162 | status = acpi_evaluate_object(handle, "_HPX", NULL, &buffer); | ||
163 | if (ACPI_FAILURE(status)) | ||
164 | return status; | ||
165 | |||
166 | package = (union acpi_object *)buffer.pointer; | ||
167 | if (package->type != ACPI_TYPE_PACKAGE) { | ||
168 | status = AE_ERROR; | ||
169 | goto exit; | ||
170 | } | ||
171 | |||
172 | for (i = 0; i < package->package.count; i++) { | ||
173 | record = &package->package.elements[i]; | ||
174 | if (record->type != ACPI_TYPE_PACKAGE) { | ||
175 | status = AE_ERROR; | ||
176 | goto exit; | ||
177 | } | ||
178 | |||
179 | fields = record->package.elements; | ||
180 | if (fields[0].type != ACPI_TYPE_INTEGER || | ||
181 | fields[1].type != ACPI_TYPE_INTEGER) { | ||
182 | status = AE_ERROR; | ||
183 | goto exit; | ||
184 | } | ||
185 | |||
186 | type = fields[0].integer.value; | ||
187 | switch (type) { | ||
188 | case 0: | ||
189 | status = decode_type0_hpx_record(record, hpx); | ||
190 | if (ACPI_FAILURE(status)) | ||
191 | goto exit; | ||
192 | break; | ||
193 | case 1: | ||
194 | status = decode_type1_hpx_record(record, hpx); | ||
195 | if (ACPI_FAILURE(status)) | ||
196 | goto exit; | ||
197 | break; | ||
198 | case 2: | ||
199 | status = decode_type2_hpx_record(record, hpx); | ||
200 | if (ACPI_FAILURE(status)) | ||
201 | goto exit; | ||
202 | break; | ||
203 | default: | ||
204 | printk(KERN_ERR "%s: Type %d record not supported\n", | ||
205 | __func__, type); | ||
206 | status = AE_ERROR; | ||
207 | goto exit; | ||
208 | } | ||
209 | } | ||
210 | exit: | ||
211 | kfree(buffer.pointer); | ||
212 | return status; | ||
213 | } | ||
214 | |||
215 | static acpi_status | ||
216 | acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) | ||
217 | { | ||
218 | acpi_status status; | ||
219 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
220 | union acpi_object *package, *fields; | ||
221 | int i; | ||
222 | |||
223 | memset(hpp, 0, sizeof(struct hotplug_params)); | ||
224 | |||
225 | status = acpi_evaluate_object(handle, "_HPP", NULL, &buffer); | ||
226 | if (ACPI_FAILURE(status)) | ||
227 | return status; | ||
228 | |||
229 | package = (union acpi_object *) buffer.pointer; | ||
230 | if (package->type != ACPI_TYPE_PACKAGE || | ||
231 | package->package.count != 4) { | ||
232 | status = AE_ERROR; | ||
233 | goto exit; | ||
234 | } | ||
235 | |||
236 | fields = package->package.elements; | ||
237 | for (i = 0; i < 4; i++) { | ||
238 | if (fields[i].type != ACPI_TYPE_INTEGER) { | ||
239 | status = AE_ERROR; | ||
240 | goto exit; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | hpp->t0 = &hpp->type0_data; | ||
245 | hpp->t0->revision = 1; | ||
246 | hpp->t0->cache_line_size = fields[0].integer.value; | ||
247 | hpp->t0->latency_timer = fields[1].integer.value; | ||
248 | hpp->t0->enable_serr = fields[2].integer.value; | ||
249 | hpp->t0->enable_perr = fields[3].integer.value; | ||
250 | |||
251 | exit: | ||
252 | kfree(buffer.pointer); | ||
253 | return status; | ||
254 | } | ||
255 | |||
256 | |||
257 | |||
258 | /* acpi_run_oshp - get control of hotplug from the firmware | 49 | /* acpi_run_oshp - get control of hotplug from the firmware |
259 | * | 50 | * |
260 | * @handle - the handle of the hotplug controller. | 51 | * @handle - the handle of the hotplug controller. |
@@ -283,48 +74,6 @@ static acpi_status acpi_run_oshp(acpi_handle handle) | |||
283 | return status; | 74 | return status; |
284 | } | 75 | } |
285 | 76 | ||
286 | /* pci_get_hp_params | ||
287 | * | ||
288 | * @dev - the pci_dev for which we want parameters | ||
289 | * @hpp - allocated by the caller | ||
290 | */ | ||
291 | int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp) | ||
292 | { | ||
293 | acpi_status status; | ||
294 | acpi_handle handle, phandle; | ||
295 | struct pci_bus *pbus; | ||
296 | |||
297 | handle = NULL; | ||
298 | for (pbus = dev->bus; pbus; pbus = pbus->parent) { | ||
299 | handle = acpi_pci_get_bridge_handle(pbus); | ||
300 | if (handle) | ||
301 | break; | ||
302 | } | ||
303 | |||
304 | /* | ||
305 | * _HPP settings apply to all child buses, until another _HPP is | ||
306 | * encountered. If we don't find an _HPP for the input pci dev, | ||
307 | * look for it in the parent device scope since that would apply to | ||
308 | * this pci dev. | ||
309 | */ | ||
310 | while (handle) { | ||
311 | status = acpi_run_hpx(handle, hpp); | ||
312 | if (ACPI_SUCCESS(status)) | ||
313 | return 0; | ||
314 | status = acpi_run_hpp(handle, hpp); | ||
315 | if (ACPI_SUCCESS(status)) | ||
316 | return 0; | ||
317 | if (acpi_is_root_bridge(handle)) | ||
318 | break; | ||
319 | status = acpi_get_parent(handle, &phandle); | ||
320 | if (ACPI_FAILURE(status)) | ||
321 | break; | ||
322 | handle = phandle; | ||
323 | } | ||
324 | return -ENODEV; | ||
325 | } | ||
326 | EXPORT_SYMBOL_GPL(pci_get_hp_params); | ||
327 | |||
328 | /** | 77 | /** |
329 | * acpi_get_hp_hw_control_from_firmware | 78 | * acpi_get_hp_hw_control_from_firmware |
330 | * @dev: the pci_dev of the bridge that has a hotplug controller | 79 | * @dev: the pci_dev of the bridge that has a hotplug controller |