diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2007-01-26 22:07:51 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-02-06 22:03:17 -0500 |
commit | 6c7be7d385f4911895877e0f0697c598f600136f (patch) | |
tree | d8bffe6e30b7bffc66ffe74e636ad30a322122cd /arch | |
parent | eebb81c13aa831a623e903bbae97a23fe9be93eb (diff) |
[POWERPC] ps3: repository storage support
Handle storage-related repository data:
- Add missing implementations of ps3_repository_read_stor_*() repository
accessors.
- Dump storage properties in debug mode
- Add PS3_DEV_TYPE_STOR_{DISK,ROM,FLASH} device types (which are identical to
the corresponding SCSI device types) to enum ps3_dev_type
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/ps3/repository.c | 185 |
1 files changed, 183 insertions, 2 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 | ||
371 | static int dump_device_info(unsigned int bus_index, unsigned int num_dev) | 371 | static 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, ®ion_id, ®ion_start, | ||
400 | ®ion_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 | |||
413 | out: | ||
414 | pr_debug(" <- %s:%d\n", __func__, __LINE__); | ||
415 | return result; | ||
416 | } | ||
417 | |||
418 | static 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 | ||
711 | int 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 | |||
721 | int 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 | |||
731 | int 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 | |||
741 | int 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 | |||
756 | int 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 | |||
773 | int 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 | |||
784 | int 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 | |||
795 | int 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 | |||
820 | int 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 | |||
660 | int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size) | 841 | int 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, |