aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/ps3/repository.c185
-rw-r--r--include/asm-powerpc/ps3.h24
2 files changed, 200 insertions, 9 deletions
diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c
index 9ef31a5b7035..2416bfadec9e 100644
--- a/arch/powerpc/platforms/ps3/repository.c
+++ b/arch/powerpc/platforms/ps3/repository.c
@@ -368,7 +368,55 @@ int ps3_repository_dump_resource_info(unsigned int bus_index,
368 return result; 368 return result;
369} 369}
370 370
371static int dump_device_info(unsigned int bus_index, unsigned int num_dev) 371static int dump_stor_dev_info(unsigned int bus_index, unsigned int dev_index)
372{
373 int result = 0;
374 unsigned int num_regions, region_index;
375 u64 port, blk_size, num_blocks;
376
377 pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
378 bus_index, dev_index);
379
380 result = ps3_repository_read_stor_dev_info(bus_index, dev_index, &port,
381 &blk_size, &num_blocks, &num_regions);
382 if (result) {
383 pr_debug("%s:%d ps3_repository_read_stor_dev_info"
384 " (%u:%u) failed\n", __func__, __LINE__,
385 bus_index, dev_index);
386 goto out;
387 }
388
389 pr_debug("%s:%d (%u:%u): port %lu, blk_size %lu, num_blocks "
390 "%lu, num_regions %u\n",
391 __func__, __LINE__, bus_index, dev_index, port,
392 blk_size, num_blocks, num_regions);
393
394 for (region_index = 0; region_index < num_regions; region_index++) {
395 unsigned int region_id;
396 u64 region_start, region_size;
397
398 result = ps3_repository_read_stor_dev_region(bus_index,
399 dev_index, region_index, &region_id, &region_start,
400 &region_size);
401 if (result) {
402 pr_debug("%s:%d ps3_repository_read_stor_dev_region"
403 " (%u:%u) failed\n", __func__, __LINE__,
404 bus_index, dev_index);
405 break;
406 }
407
408 pr_debug("%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n",
409 __func__, __LINE__, bus_index, dev_index, region_id,
410 region_start, region_size);
411 }
412
413out:
414 pr_debug(" <- %s:%d\n", __func__, __LINE__);
415 return result;
416}
417
418static int dump_device_info(unsigned int bus_index, enum ps3_bus_type bus_type,
419 unsigned int num_dev)
372{ 420{
373 int result = 0; 421 int result = 0;
374 unsigned int dev_index; 422 unsigned int dev_index;
@@ -403,6 +451,9 @@ static int dump_device_info(unsigned int bus_index, unsigned int num_dev)
403 __LINE__, bus_index, dev_index, dev_type, dev_id); 451 __LINE__, bus_index, dev_index, dev_type, dev_id);
404 452
405 ps3_repository_dump_resource_info(bus_index, dev_index); 453 ps3_repository_dump_resource_info(bus_index, dev_index);
454
455 if (bus_type == PS3_BUS_TYPE_STORAGE)
456 dump_stor_dev_info(bus_index, dev_index);
406 } 457 }
407 458
408 pr_debug(" <- %s:%d\n", __func__, __LINE__); 459 pr_debug(" <- %s:%d\n", __func__, __LINE__);
@@ -453,7 +504,7 @@ int ps3_repository_dump_bus_info(void)
453 __func__, __LINE__, bus_index, bus_type, bus_id, 504 __func__, __LINE__, bus_index, bus_type, bus_id,
454 num_dev); 505 num_dev);
455 506
456 dump_device_info(bus_index, num_dev); 507 dump_device_info(bus_index, bus_type, num_dev);
457 } 508 }
458 509
459 pr_debug(" <- %s:%d\n", __func__, __LINE__); 510 pr_debug(" <- %s:%d\n", __func__, __LINE__);
@@ -657,6 +708,136 @@ int ps3_repository_find_reg(const struct ps3_repository_device *dev,
657 return result; 708 return result;
658} 709}
659 710
711int ps3_repository_read_stor_dev_port(unsigned int bus_index,
712 unsigned int dev_index, u64 *port)
713{
714 return read_node(PS3_LPAR_ID_PME,
715 make_first_field("bus", bus_index),
716 make_field("dev", dev_index),
717 make_field("port", 0),
718 0, port, 0);
719}
720
721int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
722 unsigned int dev_index, u64 *blk_size)
723{
724 return read_node(PS3_LPAR_ID_PME,
725 make_first_field("bus", bus_index),
726 make_field("dev", dev_index),
727 make_field("blk_size", 0),
728 0, blk_size, 0);
729}
730
731int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
732 unsigned int dev_index, u64 *num_blocks)
733{
734 return read_node(PS3_LPAR_ID_PME,
735 make_first_field("bus", bus_index),
736 make_field("dev", dev_index),
737 make_field("n_blocks", 0),
738 0, num_blocks, 0);
739}
740
741int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
742 unsigned int dev_index, unsigned int *num_regions)
743{
744 int result;
745 u64 v1;
746
747 result = read_node(PS3_LPAR_ID_PME,
748 make_first_field("bus", bus_index),
749 make_field("dev", dev_index),
750 make_field("n_regs", 0),
751 0, &v1, 0);
752 *num_regions = v1;
753 return result;
754}
755
756int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
757 unsigned int dev_index, unsigned int region_index,
758 unsigned int *region_id)
759{
760 int result;
761 u64 v1;
762
763 result = read_node(PS3_LPAR_ID_PME,
764 make_first_field("bus", bus_index),
765 make_field("dev", dev_index),
766 make_field("region", region_index),
767 make_field("id", 0),
768 &v1, 0);
769 *region_id = v1;
770 return result;
771}
772
773int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
774 unsigned int dev_index, unsigned int region_index, u64 *region_size)
775{
776 return read_node(PS3_LPAR_ID_PME,
777 make_first_field("bus", bus_index),
778 make_field("dev", dev_index),
779 make_field("region", region_index),
780 make_field("size", 0),
781 region_size, 0);
782}
783
784int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
785 unsigned int dev_index, unsigned int region_index, u64 *region_start)
786{
787 return read_node(PS3_LPAR_ID_PME,
788 make_first_field("bus", bus_index),
789 make_field("dev", dev_index),
790 make_field("region", region_index),
791 make_field("start", 0),
792 region_start, 0);
793}
794
795int ps3_repository_read_stor_dev_info(unsigned int bus_index,
796 unsigned int dev_index, u64 *port, u64 *blk_size,
797 u64 *num_blocks, unsigned int *num_regions)
798{
799 int result;
800
801 result = ps3_repository_read_stor_dev_port(bus_index, dev_index, port);
802 if (result)
803 return result;
804
805 result = ps3_repository_read_stor_dev_blk_size(bus_index, dev_index,
806 blk_size);
807 if (result)
808 return result;
809
810 result = ps3_repository_read_stor_dev_num_blocks(bus_index, dev_index,
811 num_blocks);
812 if (result)
813 return result;
814
815 result = ps3_repository_read_stor_dev_num_regions(bus_index, dev_index,
816 num_regions);
817 return result;
818}
819
820int ps3_repository_read_stor_dev_region(unsigned int bus_index,
821 unsigned int dev_index, unsigned int region_index,
822 unsigned int *region_id, u64 *region_start, u64 *region_size)
823{
824 int result;
825
826 result = ps3_repository_read_stor_dev_region_id(bus_index, dev_index,
827 region_index, region_id);
828 if (result)
829 return result;
830
831 result = ps3_repository_read_stor_dev_region_start(bus_index, dev_index,
832 region_index, region_start);
833 if (result)
834 return result;
835
836 result = ps3_repository_read_stor_dev_region_size(bus_index, dev_index,
837 region_index, region_size);
838 return result;
839}
840
660int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size) 841int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size)
661{ 842{
662 return read_node(PS3_LPAR_ID_CURRENT, 843 return read_node(PS3_LPAR_ID_CURRENT,
diff --git a/include/asm-powerpc/ps3.h b/include/asm-powerpc/ps3.h
index b56aca28b26d..8fed3a041dee 100644
--- a/include/asm-powerpc/ps3.h
+++ b/include/asm-powerpc/ps3.h
@@ -25,6 +25,7 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <scsi/scsi.h>
28 29
29/** 30/**
30 * struct ps3_device_id - HV bus device identifier from the system repository 31 * struct ps3_device_id - HV bus device identifier from the system repository
@@ -255,9 +256,12 @@ enum ps3_bus_type {
255}; 256};
256 257
257enum ps3_dev_type { 258enum ps3_dev_type {
259 PS3_DEV_TYPE_STOR_DISK = TYPE_DISK, /* 0 */
258 PS3_DEV_TYPE_SB_GELIC = 3, 260 PS3_DEV_TYPE_SB_GELIC = 3,
259 PS3_DEV_TYPE_SB_USB = 4, 261 PS3_DEV_TYPE_SB_USB = 4,
262 PS3_DEV_TYPE_STOR_ROM = TYPE_ROM, /* 5 */
260 PS3_DEV_TYPE_SB_GPIO = 6, 263 PS3_DEV_TYPE_SB_GPIO = 6,
264 PS3_DEV_TYPE_STOR_FLASH = TYPE_RBC, /* 14 */
261}; 265};
262 266
263int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str, 267int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
@@ -327,21 +331,27 @@ int ps3_repository_find_reg(const struct ps3_repository_device *dev,
327 331
328/* repository block device info */ 332/* repository block device info */
329 333
330int ps3_repository_read_dev_port(unsigned int bus_index, 334int ps3_repository_read_stor_dev_port(unsigned int bus_index,
331 unsigned int dev_index, u64 *port); 335 unsigned int dev_index, u64 *port);
332int ps3_repository_read_dev_blk_size(unsigned int bus_index, 336int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
333 unsigned int dev_index, u64 *blk_size); 337 unsigned int dev_index, u64 *blk_size);
334int ps3_repository_read_dev_num_blocks(unsigned int bus_index, 338int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
335 unsigned int dev_index, u64 *num_blocks); 339 unsigned int dev_index, u64 *num_blocks);
336int ps3_repository_read_dev_num_regions(unsigned int bus_index, 340int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
337 unsigned int dev_index, unsigned int *num_regions); 341 unsigned int dev_index, unsigned int *num_regions);
338int ps3_repository_read_dev_region_id(unsigned int bus_index, 342int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
339 unsigned int dev_index, unsigned int region_index, 343 unsigned int dev_index, unsigned int region_index,
340 unsigned int *region_id); 344 unsigned int *region_id);
341int ps3_repository_read_dev_region_size(unsigned int bus_index, 345int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
342 unsigned int dev_index, unsigned int region_index, u64 *region_size); 346 unsigned int dev_index, unsigned int region_index, u64 *region_size);
343int ps3_repository_read_dev_region_start(unsigned int bus_index, 347int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
344 unsigned int dev_index, unsigned int region_index, u64 *region_start); 348 unsigned int dev_index, unsigned int region_index, u64 *region_start);
349int ps3_repository_read_stor_dev_info(unsigned int bus_index,
350 unsigned int dev_index, u64 *port, u64 *blk_size,
351 u64 *num_blocks, unsigned int *num_regions);
352int ps3_repository_read_stor_dev_region(unsigned int bus_index,
353 unsigned int dev_index, unsigned int region_index,
354 unsigned int *region_id, u64 *region_start, u64 *region_size);
345 355
346/* repository pu and memory info */ 356/* repository pu and memory info */
347 357