2 * PS3 repository routines.
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <asm/lv1call.h>
26 PS3_VENDOR_ID_NONE = 0,
27 PS3_VENDOR_ID_SONY = 0x8000000000000000UL,
31 PS3_LPAR_ID_CURRENT = 0,
35 #define dump_field(_a, _b) _dump_field(_a, _b, __func__, __LINE__)
36 static void _dump_field(const char *hdr, u64 n, const char* func, int line)
40 const char *const in = (const char *)&n;
43 for (i = 0; i < 8; i++)
44 s[i] = (in[i] <= 126 && in[i] >= 32) ? in[i] : '.';
47 pr_debug("%s:%d: %s%016lx : %s\n", func, line, hdr, n, s);
51 #define dump_node_name(_a, _b, _c, _d, _e) \
52 _dump_node_name(_a, _b, _c, _d, _e, __func__, __LINE__)
53 static void _dump_node_name (unsigned int lpar_id, u64 n1, u64 n2, u64 n3,
54 u64 n4, const char* func, int line)
56 pr_debug("%s:%d: lpar: %u\n", func, line, lpar_id);
57 _dump_field("n1: ", n1, func, line);
58 _dump_field("n2: ", n2, func, line);
59 _dump_field("n3: ", n3, func, line);
60 _dump_field("n4: ", n4, func, line);
63 #define dump_node(_a, _b, _c, _d, _e, _f, _g) \
64 _dump_node(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
65 static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
66 u64 v1, u64 v2, const char* func, int line)
68 pr_debug("%s:%d: lpar: %u\n", func, line, lpar_id);
69 _dump_field("n1: ", n1, func, line);
70 _dump_field("n2: ", n2, func, line);
71 _dump_field("n3: ", n3, func, line);
72 _dump_field("n4: ", n4, func, line);
73 pr_debug("%s:%d: v1: %016lx\n", func, line, v1);
74 pr_debug("%s:%d: v2: %016lx\n", func, line, v2);
78 * make_first_field - Make the first field of a repository node name.
79 * @text: Text portion of the field.
80 * @index: Numeric index portion of the field. Use zero for 'don't care'.
82 * This routine sets the vendor id to zero (non-vendor specific).
83 * Returns field value.
86 static u64 make_first_field(const char *text, u64 index)
90 strncpy((char *)&n, text, 8);
91 return PS3_VENDOR_ID_NONE + (n >> 32) + index;
95 * make_field - Make subsequent fields of a repository node name.
96 * @text: Text portion of the field. Use "" for 'don't care'.
97 * @index: Numeric index portion of the field. Use zero for 'don't care'.
99 * Returns field value.
102 static u64 make_field(const char *text, u64 index)
106 strncpy((char *)&n, text, 8);
111 * read_node - Read a repository node from raw fields.
112 * @n1: First field of node name.
113 * @n2: Second field of node name. Use zero for 'don't care'.
114 * @n3: Third field of node name. Use zero for 'don't care'.
115 * @n4: Fourth field of node name. Use zero for 'don't care'.
116 * @v1: First repository value (high word).
117 * @v2: Second repository value (low word). Optional parameter, use zero
121 static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
128 if (lpar_id == PS3_LPAR_ID_CURRENT) {
130 lv1_get_logical_partition_id(&id);
134 result = lv1_get_repository_node_value(lpar_id, n1, n2, n3, n4, &v1,
138 pr_debug("%s:%d: lv1_get_repository_node_value failed: %s\n",
139 __func__, __LINE__, ps3_result(result));
140 dump_node_name(lpar_id, n1, n2, n3, n4);
144 dump_node(lpar_id, n1, n2, n3, n4, v1, v2);
152 pr_debug("%s:%d: warning: discarding non-zero v1: %016lx\n",
153 __func__, __LINE__, v1);
155 pr_debug("%s:%d: warning: discarding non-zero v2: %016lx\n",
156 __func__, __LINE__, v2);
161 int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
164 return read_node(PS3_LPAR_ID_PME,
165 make_first_field("bus", bus_index),
166 make_field(bus_str, 0),
171 int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id)
175 result = read_node(PS3_LPAR_ID_PME,
176 make_first_field("bus", bus_index),
183 int ps3_repository_read_bus_type(unsigned int bus_index,
184 enum ps3_bus_type *bus_type)
189 result = read_node(PS3_LPAR_ID_PME,
190 make_first_field("bus", bus_index),
191 make_field("type", 0),
198 int ps3_repository_read_bus_num_dev(unsigned int bus_index,
199 unsigned int *num_dev)
204 result = read_node(PS3_LPAR_ID_PME,
205 make_first_field("bus", bus_index),
206 make_field("num_dev", 0),
213 int ps3_repository_read_dev_str(unsigned int bus_index,
214 unsigned int dev_index, const char *dev_str, u64 *value)
216 return read_node(PS3_LPAR_ID_PME,
217 make_first_field("bus", bus_index),
218 make_field("dev", dev_index),
219 make_field(dev_str, 0),
224 int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
229 result = read_node(PS3_LPAR_ID_PME,
230 make_first_field("bus", bus_index),
231 make_field("dev", dev_index),
238 int ps3_repository_read_dev_type(unsigned int bus_index,
239 unsigned int dev_index, enum ps3_dev_type *dev_type)
244 result = read_node(PS3_LPAR_ID_PME,
245 make_first_field("bus", bus_index),
246 make_field("dev", dev_index),
247 make_field("type", 0),
254 int ps3_repository_read_dev_intr(unsigned int bus_index,
255 unsigned int dev_index, unsigned int intr_index,
256 enum ps3_interrupt_type *intr_type, unsigned int* interrupt_id)
262 result = read_node(PS3_LPAR_ID_PME,
263 make_first_field("bus", bus_index),
264 make_field("dev", dev_index),
265 make_field("intr", intr_index),
273 int ps3_repository_read_dev_reg_type(unsigned int bus_index,
274 unsigned int dev_index, unsigned int reg_index,
275 enum ps3_reg_type *reg_type)
280 result = read_node(PS3_LPAR_ID_PME,
281 make_first_field("bus", bus_index),
282 make_field("dev", dev_index),
283 make_field("reg", reg_index),
284 make_field("type", 0),
290 int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
291 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr, u64 *len)
293 return read_node(PS3_LPAR_ID_PME,
294 make_first_field("bus", bus_index),
295 make_field("dev", dev_index),
296 make_field("reg", reg_index),
297 make_field("data", 0),
301 int ps3_repository_read_dev_reg(unsigned int bus_index,
302 unsigned int dev_index, unsigned int reg_index,
303 enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len)
305 int result = ps3_repository_read_dev_reg_type(bus_index, dev_index,
306 reg_index, reg_type);
307 return result ? result
308 : ps3_repository_read_dev_reg_addr(bus_index, dev_index,
309 reg_index, bus_addr, len);
314 int ps3_repository_find_device(struct ps3_repository_device *repo)
317 struct ps3_repository_device tmp = *repo;
318 unsigned int num_dev;
320 BUG_ON(repo->bus_index > 10);
321 BUG_ON(repo->dev_index > 10);
323 result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev);
326 pr_debug("%s:%d read_bus_num_dev failed\n", __func__, __LINE__);
330 pr_debug("%s:%d: bus_type %u, bus_index %u, bus_id %lu, num_dev %u\n",
331 __func__, __LINE__, tmp.bus_type, tmp.bus_index, tmp.bus_id,
334 if (tmp.dev_index >= num_dev) {
335 pr_debug("%s:%d: no device found\n", __func__, __LINE__);
339 result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index,
343 pr_debug("%s:%d read_dev_type failed\n", __func__, __LINE__);
347 if (tmp.bus_type == PS3_BUS_TYPE_STORAGE) {
349 * A storage device may show up in the repository before the
350 * hypervisor has finished probing its type and regions
352 unsigned int num_regions;
354 if (tmp.dev_type == PS3_DEV_TYPE_STOR_DUMMY) {
355 pr_debug("%s:%u storage device not ready\n", __func__,
360 result = ps3_repository_read_stor_dev_num_regions(tmp.bus_index,
364 pr_debug("%s:%d read_stor_dev_num_regions failed\n",
370 pr_debug("%s:%u storage device has no regions yet\n",
376 result = ps3_repository_read_dev_id(tmp.bus_index, tmp.dev_index,
380 pr_debug("%s:%d ps3_repository_read_dev_id failed\n", __func__,
385 pr_debug("%s:%d: found: dev_type %u, dev_index %u, dev_id %lu\n",
386 __func__, __LINE__, tmp.dev_type, tmp.dev_index, tmp.dev_id);
392 int ps3_repository_find_device_by_id(struct ps3_repository_device *repo,
393 u64 bus_id, u64 dev_id)
395 int result = -ENODEV;
396 struct ps3_repository_device tmp;
397 unsigned int num_dev;
399 pr_debug(" -> %s:%u: find device by id %lu:%lu\n", __func__, __LINE__,
402 for (tmp.bus_index = 0; tmp.bus_index < 10; tmp.bus_index++) {
403 result = ps3_repository_read_bus_id(tmp.bus_index,
406 pr_debug("%s:%u read_bus_id(%u) failed\n", __func__,
407 __LINE__, tmp.bus_index);
411 if (tmp.bus_id == bus_id)
414 pr_debug("%s:%u: skip, bus_id %lu\n", __func__, __LINE__,
417 pr_debug(" <- %s:%u: bus not found\n", __func__, __LINE__);
421 result = ps3_repository_read_bus_type(tmp.bus_index, &tmp.bus_type);
423 pr_debug("%s:%u read_bus_type(%u) failed\n", __func__,
424 __LINE__, tmp.bus_index);
428 result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev);
430 pr_debug("%s:%u read_bus_num_dev failed\n", __func__,
435 for (tmp.dev_index = 0; tmp.dev_index < num_dev; tmp.dev_index++) {
436 result = ps3_repository_read_dev_id(tmp.bus_index,
440 pr_debug("%s:%u read_dev_id(%u:%u) failed\n", __func__,
441 __LINE__, tmp.bus_index, tmp.dev_index);
445 if (tmp.dev_id == dev_id)
448 pr_debug("%s:%u: skip, dev_id %lu\n", __func__, __LINE__,
451 pr_debug(" <- %s:%u: dev not found\n", __func__, __LINE__);
455 result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index,
458 pr_debug("%s:%u read_dev_type failed\n", __func__, __LINE__);
462 pr_debug(" <- %s:%u: found: type (%u:%u) index (%u:%u) id (%lu:%lu)\n",
463 __func__, __LINE__, tmp.bus_type, tmp.dev_type, tmp.bus_index,
464 tmp.dev_index, tmp.bus_id, tmp.dev_id);
469 int __devinit ps3_repository_find_devices(enum ps3_bus_type bus_type,
470 int (*callback)(const struct ps3_repository_device *repo))
473 struct ps3_repository_device repo;
475 pr_debug(" -> %s:%d: find bus_type %u\n", __func__, __LINE__, bus_type);
477 for (repo.bus_index = 0; repo.bus_index < 10; repo.bus_index++) {
479 result = ps3_repository_read_bus_type(repo.bus_index,
483 pr_debug("%s:%d read_bus_type(%u) failed\n",
484 __func__, __LINE__, repo.bus_index);
488 if (repo.bus_type != bus_type) {
489 pr_debug("%s:%d: skip, bus_type %u\n", __func__,
490 __LINE__, repo.bus_type);
494 result = ps3_repository_read_bus_id(repo.bus_index,
498 pr_debug("%s:%d read_bus_id(%u) failed\n",
499 __func__, __LINE__, repo.bus_index);
503 for (repo.dev_index = 0; ; repo.dev_index++) {
504 result = ps3_repository_find_device(&repo);
506 if (result == -ENODEV) {
512 result = callback(&repo);
515 pr_debug("%s:%d: abort at callback\n", __func__,
523 pr_debug(" <- %s:%d\n", __func__, __LINE__);
527 int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
528 unsigned int *bus_index)
531 enum ps3_bus_type type;
534 for (i = from; i < 10; i++) {
535 error = ps3_repository_read_bus_type(i, &type);
537 pr_debug("%s:%d read_bus_type failed\n",
539 *bus_index = UINT_MAX;
542 if (type == bus_type) {
547 *bus_index = UINT_MAX;
551 int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
552 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id)
555 unsigned int res_index;
557 pr_debug("%s:%d: find intr_type %u\n", __func__, __LINE__, intr_type);
559 *interrupt_id = UINT_MAX;
561 for (res_index = 0; res_index < 10; res_index++) {
562 enum ps3_interrupt_type t;
565 result = ps3_repository_read_dev_intr(repo->bus_index,
566 repo->dev_index, res_index, &t, &id);
569 pr_debug("%s:%d read_dev_intr failed\n",
574 if (t == intr_type) {
583 pr_debug("%s:%d: found intr_type %u at res_index %u\n",
584 __func__, __LINE__, intr_type, res_index);
589 int ps3_repository_find_reg(const struct ps3_repository_device *repo,
590 enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len)
593 unsigned int res_index;
595 pr_debug("%s:%d: find reg_type %u\n", __func__, __LINE__, reg_type);
597 *bus_addr = *len = 0;
599 for (res_index = 0; res_index < 10; res_index++) {
604 result = ps3_repository_read_dev_reg(repo->bus_index,
605 repo->dev_index, res_index, &t, &a, &l);
608 pr_debug("%s:%d read_dev_reg failed\n",
623 pr_debug("%s:%d: found reg_type %u at res_index %u\n",
624 __func__, __LINE__, reg_type, res_index);
629 int ps3_repository_read_stor_dev_port(unsigned int bus_index,
630 unsigned int dev_index, u64 *port)
632 return read_node(PS3_LPAR_ID_PME,
633 make_first_field("bus", bus_index),
634 make_field("dev", dev_index),
635 make_field("port", 0),
639 int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
640 unsigned int dev_index, u64 *blk_size)
642 return read_node(PS3_LPAR_ID_PME,
643 make_first_field("bus", bus_index),
644 make_field("dev", dev_index),
645 make_field("blk_size", 0),
649 int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
650 unsigned int dev_index, u64 *num_blocks)
652 return read_node(PS3_LPAR_ID_PME,
653 make_first_field("bus", bus_index),
654 make_field("dev", dev_index),
655 make_field("n_blocks", 0),
659 int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
660 unsigned int dev_index, unsigned int *num_regions)
665 result = read_node(PS3_LPAR_ID_PME,
666 make_first_field("bus", bus_index),
667 make_field("dev", dev_index),
668 make_field("n_regs", 0),
674 int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
675 unsigned int dev_index, unsigned int region_index,
676 unsigned int *region_id)
681 result = read_node(PS3_LPAR_ID_PME,
682 make_first_field("bus", bus_index),
683 make_field("dev", dev_index),
684 make_field("region", region_index),
691 int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
692 unsigned int dev_index, unsigned int region_index, u64 *region_size)
694 return read_node(PS3_LPAR_ID_PME,
695 make_first_field("bus", bus_index),
696 make_field("dev", dev_index),
697 make_field("region", region_index),
698 make_field("size", 0),
702 int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
703 unsigned int dev_index, unsigned int region_index, u64 *region_start)
705 return read_node(PS3_LPAR_ID_PME,
706 make_first_field("bus", bus_index),
707 make_field("dev", dev_index),
708 make_field("region", region_index),
709 make_field("start", 0),
713 int ps3_repository_read_stor_dev_info(unsigned int bus_index,
714 unsigned int dev_index, u64 *port, u64 *blk_size,
715 u64 *num_blocks, unsigned int *num_regions)
719 result = ps3_repository_read_stor_dev_port(bus_index, dev_index, port);
723 result = ps3_repository_read_stor_dev_blk_size(bus_index, dev_index,
728 result = ps3_repository_read_stor_dev_num_blocks(bus_index, dev_index,
733 result = ps3_repository_read_stor_dev_num_regions(bus_index, dev_index,
738 int ps3_repository_read_stor_dev_region(unsigned int bus_index,
739 unsigned int dev_index, unsigned int region_index,
740 unsigned int *region_id, u64 *region_start, u64 *region_size)
744 result = ps3_repository_read_stor_dev_region_id(bus_index, dev_index,
745 region_index, region_id);
749 result = ps3_repository_read_stor_dev_region_start(bus_index, dev_index,
750 region_index, region_start);
754 result = ps3_repository_read_stor_dev_region_size(bus_index, dev_index,
755 region_index, region_size);
759 int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size)
761 return read_node(PS3_LPAR_ID_CURRENT,
762 make_first_field("bi", 0),
765 make_field("rm_size", 0),
769 int ps3_repository_read_region_total(u64 *region_total)
771 return read_node(PS3_LPAR_ID_CURRENT,
772 make_first_field("bi", 0),
773 make_field("rgntotal", 0),
779 * ps3_repository_read_mm_info - Read mm info for single pu system.
780 * @rm_base: Real mode memory base address.
781 * @rm_size: Real mode memory size.
782 * @region_total: Maximum memory region size.
785 int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total)
790 lv1_get_logical_ppe_id(&ppe_id);
792 result = ps3_repository_read_rm_size(ppe_id, rm_size);
793 return result ? result
794 : ps3_repository_read_region_total(region_total);
798 * ps3_repository_read_num_spu_reserved - Number of physical spus reserved.
799 * @num_spu: Number of physical spus.
802 int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved)
807 result = read_node(PS3_LPAR_ID_CURRENT,
808 make_first_field("bi", 0),
809 make_field("spun", 0),
812 *num_spu_reserved = v1;
817 * ps3_repository_read_num_spu_resource_id - Number of spu resource reservations.
818 * @num_resource_id: Number of spu resource ids.
821 int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
826 result = read_node(PS3_LPAR_ID_CURRENT,
827 make_first_field("bi", 0),
828 make_field("spursvn", 0),
831 *num_resource_id = v1;
836 * ps3_repository_read_spu_resource_id - spu resource reservation id value.
837 * @res_index: Resource reservation index.
838 * @resource_type: Resource reservation type.
839 * @resource_id: Resource reservation id.
842 int ps3_repository_read_spu_resource_id(unsigned int res_index,
843 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id)
849 result = read_node(PS3_LPAR_ID_CURRENT,
850 make_first_field("bi", 0),
851 make_field("spursv", 0),
860 int ps3_repository_read_boot_dat_address(u64 *address)
862 return read_node(PS3_LPAR_ID_CURRENT,
863 make_first_field("bi", 0),
864 make_field("boot_dat", 0),
865 make_field("address", 0),
870 int ps3_repository_read_boot_dat_size(unsigned int *size)
875 result = read_node(PS3_LPAR_ID_CURRENT,
876 make_first_field("bi", 0),
877 make_field("boot_dat", 0),
878 make_field("size", 0),
885 int ps3_repository_read_vuart_av_port(unsigned int *port)
890 result = read_node(PS3_LPAR_ID_CURRENT,
891 make_first_field("bi", 0),
892 make_field("vir_uart", 0),
893 make_field("port", 0),
894 make_field("avset", 0),
900 int ps3_repository_read_vuart_sysmgr_port(unsigned int *port)
905 result = read_node(PS3_LPAR_ID_CURRENT,
906 make_first_field("bi", 0),
907 make_field("vir_uart", 0),
908 make_field("port", 0),
909 make_field("sysmgr", 0),
916 * ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area.
917 * address: lpar address of cell_ext_os_area
918 * @size: size of cell_ext_os_area
921 int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size)
926 result = ps3_repository_read_boot_dat_address(lpar_addr);
927 return result ? result
928 : ps3_repository_read_boot_dat_size(size);
931 int ps3_repository_read_num_be(unsigned int *num_be)
936 result = read_node(PS3_LPAR_ID_PME,
937 make_first_field("ben", 0),
946 int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id)
948 return read_node(PS3_LPAR_ID_PME,
949 make_first_field("be", be_index),
956 int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq)
958 return read_node(PS3_LPAR_ID_PME,
959 make_first_field("be", 0),
961 make_field("clock", 0),
966 int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq)
972 result = ps3_repository_read_be_node_id(0, &node_id);
973 return result ? result
974 : ps3_repository_read_tb_freq(node_id, tb_freq);
979 int ps3_repository_dump_resource_info(const struct ps3_repository_device *repo)
982 unsigned int res_index;
984 pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
985 repo->bus_index, repo->dev_index);
987 for (res_index = 0; res_index < 10; res_index++) {
988 enum ps3_interrupt_type intr_type;
989 unsigned int interrupt_id;
991 result = ps3_repository_read_dev_intr(repo->bus_index,
992 repo->dev_index, res_index, &intr_type, &interrupt_id);
995 if (result != LV1_NO_ENTRY)
996 pr_debug("%s:%d ps3_repository_read_dev_intr"
997 " (%u:%u) failed\n", __func__, __LINE__,
998 repo->bus_index, repo->dev_index);
1002 pr_debug("%s:%d (%u:%u) intr_type %u, interrupt_id %u\n",
1003 __func__, __LINE__, repo->bus_index, repo->dev_index,
1004 intr_type, interrupt_id);
1007 for (res_index = 0; res_index < 10; res_index++) {
1008 enum ps3_reg_type reg_type;
1012 result = ps3_repository_read_dev_reg(repo->bus_index,
1013 repo->dev_index, res_index, ®_type, &bus_addr, &len);
1016 if (result != LV1_NO_ENTRY)
1017 pr_debug("%s:%d ps3_repository_read_dev_reg"
1018 " (%u:%u) failed\n", __func__, __LINE__,
1019 repo->bus_index, repo->dev_index);
1023 pr_debug("%s:%d (%u:%u) reg_type %u, bus_addr %lxh, len %lxh\n",
1024 __func__, __LINE__, repo->bus_index, repo->dev_index,
1025 reg_type, bus_addr, len);
1028 pr_debug(" <- %s:%d\n", __func__, __LINE__);
1032 static int dump_stor_dev_info(struct ps3_repository_device *repo)
1035 unsigned int num_regions, region_index;
1036 u64 port, blk_size, num_blocks;
1038 pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
1039 repo->bus_index, repo->dev_index);
1041 result = ps3_repository_read_stor_dev_info(repo->bus_index,
1042 repo->dev_index, &port, &blk_size, &num_blocks, &num_regions);
1044 pr_debug("%s:%d ps3_repository_read_stor_dev_info"
1045 " (%u:%u) failed\n", __func__, __LINE__,
1046 repo->bus_index, repo->dev_index);
1050 pr_debug("%s:%d (%u:%u): port %lu, blk_size %lu, num_blocks "
1051 "%lu, num_regions %u\n",
1052 __func__, __LINE__, repo->bus_index, repo->dev_index, port,
1053 blk_size, num_blocks, num_regions);
1055 for (region_index = 0; region_index < num_regions; region_index++) {
1056 unsigned int region_id;
1057 u64 region_start, region_size;
1059 result = ps3_repository_read_stor_dev_region(repo->bus_index,
1060 repo->dev_index, region_index, ®ion_id,
1061 ®ion_start, ®ion_size);
1063 pr_debug("%s:%d ps3_repository_read_stor_dev_region"
1064 " (%u:%u) failed\n", __func__, __LINE__,
1065 repo->bus_index, repo->dev_index);
1069 pr_debug("%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n",
1070 __func__, __LINE__, repo->bus_index, repo->dev_index,
1071 region_id, region_start, region_size);
1075 pr_debug(" <- %s:%d\n", __func__, __LINE__);
1079 static int dump_device_info(struct ps3_repository_device *repo,
1080 unsigned int num_dev)
1084 pr_debug(" -> %s:%d: bus_%u\n", __func__, __LINE__, repo->bus_index);
1086 for (repo->dev_index = 0; repo->dev_index < num_dev;
1087 repo->dev_index++) {
1089 result = ps3_repository_read_dev_type(repo->bus_index,
1090 repo->dev_index, &repo->dev_type);
1093 pr_debug("%s:%d ps3_repository_read_dev_type"
1094 " (%u:%u) failed\n", __func__, __LINE__,
1095 repo->bus_index, repo->dev_index);
1099 result = ps3_repository_read_dev_id(repo->bus_index,
1100 repo->dev_index, &repo->dev_id);
1103 pr_debug("%s:%d ps3_repository_read_dev_id"
1104 " (%u:%u) failed\n", __func__, __LINE__,
1105 repo->bus_index, repo->dev_index);
1109 pr_debug("%s:%d (%u:%u): dev_type %u, dev_id %lu\n", __func__,
1110 __LINE__, repo->bus_index, repo->dev_index,
1111 repo->dev_type, repo->dev_id);
1113 ps3_repository_dump_resource_info(repo);
1115 if (repo->bus_type == PS3_BUS_TYPE_STORAGE)
1116 dump_stor_dev_info(repo);
1119 pr_debug(" <- %s:%d\n", __func__, __LINE__);
1123 int ps3_repository_dump_bus_info(void)
1126 struct ps3_repository_device repo;
1128 pr_debug(" -> %s:%d\n", __func__, __LINE__);
1130 memset(&repo, 0, sizeof(repo));
1132 for (repo.bus_index = 0; repo.bus_index < 10; repo.bus_index++) {
1133 unsigned int num_dev;
1135 result = ps3_repository_read_bus_type(repo.bus_index,
1139 pr_debug("%s:%d read_bus_type(%u) failed\n",
1140 __func__, __LINE__, repo.bus_index);
1144 result = ps3_repository_read_bus_id(repo.bus_index,
1148 pr_debug("%s:%d read_bus_id(%u) failed\n",
1149 __func__, __LINE__, repo.bus_index);
1153 if (repo.bus_index != repo.bus_id)
1154 pr_debug("%s:%d bus_index != bus_id\n",
1155 __func__, __LINE__);
1157 result = ps3_repository_read_bus_num_dev(repo.bus_index,
1161 pr_debug("%s:%d read_bus_num_dev(%u) failed\n",
1162 __func__, __LINE__, repo.bus_index);
1166 pr_debug("%s:%d bus_%u: bus_type %u, bus_id %lu, num_dev %u\n",
1167 __func__, __LINE__, repo.bus_index, repo.bus_type,
1168 repo.bus_id, num_dev);
1170 dump_device_info(&repo, num_dev);
1173 pr_debug(" <- %s:%d\n", __func__, __LINE__);
1177 #endif /* defined(DEBUG) */