diff options
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_nvram.c')
-rw-r--r-- | drivers/pci/hotplug/cpqphp_nvram.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index 76e110f0e3a6..76ba8a1c774d 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c | |||
@@ -94,12 +94,13 @@ static u8 evbuffer[1024]; | |||
94 | 94 | ||
95 | static void __iomem *compaq_int15_entry_point; | 95 | static void __iomem *compaq_int15_entry_point; |
96 | 96 | ||
97 | static spinlock_t int15_lock; /* lock for ordering int15_bios_call() */ | 97 | /* lock for ordering int15_bios_call() */ |
98 | static spinlock_t int15_lock; | ||
98 | 99 | ||
99 | 100 | ||
100 | /* This is a series of function that deals with | 101 | /* This is a series of function that deals with |
101 | setting & getting the hotplug resource table in some environment variable. | 102 | * setting & getting the hotplug resource table in some environment variable. |
102 | */ | 103 | */ |
103 | 104 | ||
104 | /* | 105 | /* |
105 | * We really shouldn't be doing this unless there is a _very_ good reason to!!! | 106 | * We really shouldn't be doing this unless there is a _very_ good reason to!!! |
@@ -210,14 +211,16 @@ static int load_HRT (void __iomem *rom_start) | |||
210 | 211 | ||
211 | available = 1024; | 212 | available = 1024; |
212 | 213 | ||
213 | // Now load the EV | 214 | /* Now load the EV */ |
214 | temp_dword = available; | 215 | temp_dword = available; |
215 | 216 | ||
216 | rc = access_EV(READ_EV, "CQTHPS", evbuffer, &temp_dword); | 217 | rc = access_EV(READ_EV, "CQTHPS", evbuffer, &temp_dword); |
217 | 218 | ||
218 | evbuffer_length = temp_dword; | 219 | evbuffer_length = temp_dword; |
219 | 220 | ||
220 | // We're maintaining the resource lists so write FF to invalidate old info | 221 | /* We're maintaining the resource lists so write FF to invalidate old |
222 | * info | ||
223 | */ | ||
221 | temp_dword = 1; | 224 | temp_dword = 1; |
222 | 225 | ||
223 | rc = access_EV(WRITE_EV, "CQTHPS", &temp_byte, &temp_dword); | 226 | rc = access_EV(WRITE_EV, "CQTHPS", &temp_byte, &temp_dword); |
@@ -264,12 +267,12 @@ static u32 store_HRT (void __iomem *rom_start) | |||
264 | 267 | ||
265 | ctrl = cpqhp_ctrl_list; | 268 | ctrl = cpqhp_ctrl_list; |
266 | 269 | ||
267 | // The revision of this structure | 270 | /* The revision of this structure */ |
268 | rc = add_byte( &pFill, 1 + ctrl->push_flag, &usedbytes, &available); | 271 | rc = add_byte( &pFill, 1 + ctrl->push_flag, &usedbytes, &available); |
269 | if (rc) | 272 | if (rc) |
270 | return(rc); | 273 | return(rc); |
271 | 274 | ||
272 | // The number of controllers | 275 | /* The number of controllers */ |
273 | rc = add_byte( &pFill, 1, &usedbytes, &available); | 276 | rc = add_byte( &pFill, 1, &usedbytes, &available); |
274 | if (rc) | 277 | if (rc) |
275 | return(rc); | 278 | return(rc); |
@@ -279,27 +282,27 @@ static u32 store_HRT (void __iomem *rom_start) | |||
279 | 282 | ||
280 | numCtrl++; | 283 | numCtrl++; |
281 | 284 | ||
282 | // The bus number | 285 | /* The bus number */ |
283 | rc = add_byte( &pFill, ctrl->bus, &usedbytes, &available); | 286 | rc = add_byte( &pFill, ctrl->bus, &usedbytes, &available); |
284 | if (rc) | 287 | if (rc) |
285 | return(rc); | 288 | return(rc); |
286 | 289 | ||
287 | // The device Number | 290 | /* The device Number */ |
288 | rc = add_byte( &pFill, PCI_SLOT(ctrl->pci_dev->devfn), &usedbytes, &available); | 291 | rc = add_byte( &pFill, PCI_SLOT(ctrl->pci_dev->devfn), &usedbytes, &available); |
289 | if (rc) | 292 | if (rc) |
290 | return(rc); | 293 | return(rc); |
291 | 294 | ||
292 | // The function Number | 295 | /* The function Number */ |
293 | rc = add_byte( &pFill, PCI_FUNC(ctrl->pci_dev->devfn), &usedbytes, &available); | 296 | rc = add_byte( &pFill, PCI_FUNC(ctrl->pci_dev->devfn), &usedbytes, &available); |
294 | if (rc) | 297 | if (rc) |
295 | return(rc); | 298 | return(rc); |
296 | 299 | ||
297 | // Skip the number of available entries | 300 | /* Skip the number of available entries */ |
298 | rc = add_dword( &pFill, 0, &usedbytes, &available); | 301 | rc = add_dword( &pFill, 0, &usedbytes, &available); |
299 | if (rc) | 302 | if (rc) |
300 | return(rc); | 303 | return(rc); |
301 | 304 | ||
302 | // Figure out memory Available | 305 | /* Figure out memory Available */ |
303 | 306 | ||
304 | resNode = ctrl->mem_head; | 307 | resNode = ctrl->mem_head; |
305 | 308 | ||
@@ -308,12 +311,12 @@ static u32 store_HRT (void __iomem *rom_start) | |||
308 | while (resNode) { | 311 | while (resNode) { |
309 | loop ++; | 312 | loop ++; |
310 | 313 | ||
311 | // base | 314 | /* base */ |
312 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); | 315 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); |
313 | if (rc) | 316 | if (rc) |
314 | return(rc); | 317 | return(rc); |
315 | 318 | ||
316 | // length | 319 | /* length */ |
317 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); | 320 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); |
318 | if (rc) | 321 | if (rc) |
319 | return(rc); | 322 | return(rc); |
@@ -321,10 +324,10 @@ static u32 store_HRT (void __iomem *rom_start) | |||
321 | resNode = resNode->next; | 324 | resNode = resNode->next; |
322 | } | 325 | } |
323 | 326 | ||
324 | // Fill in the number of entries | 327 | /* Fill in the number of entries */ |
325 | p_ev_ctrl->mem_avail = loop; | 328 | p_ev_ctrl->mem_avail = loop; |
326 | 329 | ||
327 | // Figure out prefetchable memory Available | 330 | /* Figure out prefetchable memory Available */ |
328 | 331 | ||
329 | resNode = ctrl->p_mem_head; | 332 | resNode = ctrl->p_mem_head; |
330 | 333 | ||
@@ -333,12 +336,12 @@ static u32 store_HRT (void __iomem *rom_start) | |||
333 | while (resNode) { | 336 | while (resNode) { |
334 | loop ++; | 337 | loop ++; |
335 | 338 | ||
336 | // base | 339 | /* base */ |
337 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); | 340 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); |
338 | if (rc) | 341 | if (rc) |
339 | return(rc); | 342 | return(rc); |
340 | 343 | ||
341 | // length | 344 | /* length */ |
342 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); | 345 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); |
343 | if (rc) | 346 | if (rc) |
344 | return(rc); | 347 | return(rc); |
@@ -346,10 +349,10 @@ static u32 store_HRT (void __iomem *rom_start) | |||
346 | resNode = resNode->next; | 349 | resNode = resNode->next; |
347 | } | 350 | } |
348 | 351 | ||
349 | // Fill in the number of entries | 352 | /* Fill in the number of entries */ |
350 | p_ev_ctrl->p_mem_avail = loop; | 353 | p_ev_ctrl->p_mem_avail = loop; |
351 | 354 | ||
352 | // Figure out IO Available | 355 | /* Figure out IO Available */ |
353 | 356 | ||
354 | resNode = ctrl->io_head; | 357 | resNode = ctrl->io_head; |
355 | 358 | ||
@@ -358,12 +361,12 @@ static u32 store_HRT (void __iomem *rom_start) | |||
358 | while (resNode) { | 361 | while (resNode) { |
359 | loop ++; | 362 | loop ++; |
360 | 363 | ||
361 | // base | 364 | /* base */ |
362 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); | 365 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); |
363 | if (rc) | 366 | if (rc) |
364 | return(rc); | 367 | return(rc); |
365 | 368 | ||
366 | // length | 369 | /* length */ |
367 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); | 370 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); |
368 | if (rc) | 371 | if (rc) |
369 | return(rc); | 372 | return(rc); |
@@ -371,10 +374,10 @@ static u32 store_HRT (void __iomem *rom_start) | |||
371 | resNode = resNode->next; | 374 | resNode = resNode->next; |
372 | } | 375 | } |
373 | 376 | ||
374 | // Fill in the number of entries | 377 | /* Fill in the number of entries */ |
375 | p_ev_ctrl->io_avail = loop; | 378 | p_ev_ctrl->io_avail = loop; |
376 | 379 | ||
377 | // Figure out bus Available | 380 | /* Figure out bus Available */ |
378 | 381 | ||
379 | resNode = ctrl->bus_head; | 382 | resNode = ctrl->bus_head; |
380 | 383 | ||
@@ -383,12 +386,12 @@ static u32 store_HRT (void __iomem *rom_start) | |||
383 | while (resNode) { | 386 | while (resNode) { |
384 | loop ++; | 387 | loop ++; |
385 | 388 | ||
386 | // base | 389 | /* base */ |
387 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); | 390 | rc = add_dword( &pFill, resNode->base, &usedbytes, &available); |
388 | if (rc) | 391 | if (rc) |
389 | return(rc); | 392 | return(rc); |
390 | 393 | ||
391 | // length | 394 | /* length */ |
392 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); | 395 | rc = add_dword( &pFill, resNode->length, &usedbytes, &available); |
393 | if (rc) | 396 | if (rc) |
394 | return(rc); | 397 | return(rc); |
@@ -396,7 +399,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
396 | resNode = resNode->next; | 399 | resNode = resNode->next; |
397 | } | 400 | } |
398 | 401 | ||
399 | // Fill in the number of entries | 402 | /* Fill in the number of entries */ |
400 | p_ev_ctrl->bus_avail = loop; | 403 | p_ev_ctrl->bus_avail = loop; |
401 | 404 | ||
402 | ctrl = ctrl->next; | 405 | ctrl = ctrl->next; |
@@ -404,7 +407,7 @@ static u32 store_HRT (void __iomem *rom_start) | |||
404 | 407 | ||
405 | p_EV_header->num_of_ctrl = numCtrl; | 408 | p_EV_header->num_of_ctrl = numCtrl; |
406 | 409 | ||
407 | // Now store the EV | 410 | /* Now store the EV */ |
408 | 411 | ||
409 | temp_dword = usedbytes; | 412 | temp_dword = usedbytes; |
410 | 413 | ||
@@ -449,20 +452,21 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
449 | struct ev_hrt_header *p_EV_header; | 452 | struct ev_hrt_header *p_EV_header; |
450 | 453 | ||
451 | if (!evbuffer_init) { | 454 | if (!evbuffer_init) { |
452 | // Read the resource list information in from NVRAM | 455 | /* Read the resource list information in from NVRAM */ |
453 | if (load_HRT(rom_start)) | 456 | if (load_HRT(rom_start)) |
454 | memset (evbuffer, 0, 1024); | 457 | memset (evbuffer, 0, 1024); |
455 | 458 | ||
456 | evbuffer_init = 1; | 459 | evbuffer_init = 1; |
457 | } | 460 | } |
458 | 461 | ||
459 | // If we saved information in NVRAM, use it now | 462 | /* If we saved information in NVRAM, use it now */ |
460 | p_EV_header = (struct ev_hrt_header *) evbuffer; | 463 | p_EV_header = (struct ev_hrt_header *) evbuffer; |
461 | 464 | ||
462 | // The following code is for systems where version 1.0 of this | 465 | /* The following code is for systems where version 1.0 of this |
463 | // driver has been loaded, but doesn't support the hardware. | 466 | * driver has been loaded, but doesn't support the hardware. |
464 | // In that case, the driver would incorrectly store something | 467 | * In that case, the driver would incorrectly store something |
465 | // in NVRAM. | 468 | * in NVRAM. |
469 | */ | ||
466 | if ((p_EV_header->Version == 2) || | 470 | if ((p_EV_header->Version == 2) || |
467 | ((p_EV_header->Version == 1) && !ctrl->push_flag)) { | 471 | ((p_EV_header->Version == 1) && !ctrl->push_flag)) { |
468 | p_byte = &(p_EV_header->next); | 472 | p_byte = &(p_EV_header->next); |
@@ -491,7 +495,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
491 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 495 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) |
492 | return 2; | 496 | return 2; |
493 | 497 | ||
494 | // Skip forward to the next entry | 498 | /* Skip forward to the next entry */ |
495 | p_byte += (nummem + numpmem + numio + numbus) * 8; | 499 | p_byte += (nummem + numpmem + numio + numbus) * 8; |
496 | 500 | ||
497 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) | 501 | if (p_byte > ((u8*)p_EV_header + evbuffer_length)) |
@@ -629,8 +633,9 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) | |||
629 | ctrl->bus_head = bus_node; | 633 | ctrl->bus_head = bus_node; |
630 | } | 634 | } |
631 | 635 | ||
632 | // If all of the following fail, we don't have any resources for | 636 | /* If all of the following fail, we don't have any resources for |
633 | // hot plug add | 637 | * hot plug add |
638 | */ | ||
634 | rc = 1; | 639 | rc = 1; |
635 | rc &= cpqhp_resource_sort_and_combine(&(ctrl->mem_head)); | 640 | rc &= cpqhp_resource_sort_and_combine(&(ctrl->mem_head)); |
636 | rc &= cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head)); | 641 | rc &= cpqhp_resource_sort_and_combine(&(ctrl->p_mem_head)); |