prom.c (9b4f2e9576658c4e52d95dc8d309f51b2e2db096) | prom.c (a4dc7ff08915a2035aa6d6decc53fa1deaa410bb) |
---|---|
1/* 2 * Procedures for creating, accessing and interpreting the device tree. 3 * 4 * Paul Mackerras August 1996. 5 * Copyright (C) 1996-2005 Paul Mackerras. 6 * 7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. 8 * {engebret|bergner}@us.ibm.com --- 743 unchanged lines hidden (view full) --- 752 753 /* break now */ 754 return 1; 755} 756 757static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp) 758{ 759 cell_t *p = *cellp; | 1/* 2 * Procedures for creating, accessing and interpreting the device tree. 3 * 4 * Paul Mackerras August 1996. 5 * Copyright (C) 1996-2005 Paul Mackerras. 6 * 7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. 8 * {engebret|bergner}@us.ibm.com --- 743 unchanged lines hidden (view full) --- 752 753 /* break now */ 754 return 1; 755} 756 757static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp) 758{ 759 cell_t *p = *cellp; |
760 unsigned long r; | |
761 | 760 |
762 /* Ignore more than 2 cells */ 763 while (s > sizeof(unsigned long) / 4) { 764 p++; 765 s--; 766 } 767 r = *p++; 768#ifdef CONFIG_PPC64 769 if (s > 1) { 770 r <<= 32; 771 r |= *(p++); 772 s--; 773 } 774#endif 775 776 *cellp = p; 777 return r; | 761 *cellp = p + s; 762 return of_read_ulong(p, s); |
778} 779 780 781static int __init early_init_dt_scan_memory(unsigned long node, 782 const char *uname, int depth, void *data) 783{ 784 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 785 cell_t *reg, *endp; --- 151 unchanged lines hidden (view full) --- 937 DBG(" <- early_init_devtree()\n"); 938} 939 940#undef printk 941 942int 943prom_n_addr_cells(struct device_node* np) 944{ | 763} 764 765 766static int __init early_init_dt_scan_memory(unsigned long node, 767 const char *uname, int depth, void *data) 768{ 769 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 770 cell_t *reg, *endp; --- 151 unchanged lines hidden (view full) --- 922 DBG(" <- early_init_devtree()\n"); 923} 924 925#undef printk 926 927int 928prom_n_addr_cells(struct device_node* np) 929{ |
945 int* ip; | 930 const int *ip; |
946 do { 947 if (np->parent) 948 np = np->parent; | 931 do { 932 if (np->parent) 933 np = np->parent; |
949 ip = (int *) get_property(np, "#address-cells", NULL); | 934 ip = get_property(np, "#address-cells", NULL); |
950 if (ip != NULL) 951 return *ip; 952 } while (np->parent); 953 /* No #address-cells property for the root node, default to 1 */ 954 return 1; 955} 956EXPORT_SYMBOL(prom_n_addr_cells); 957 958int 959prom_n_size_cells(struct device_node* np) 960{ | 935 if (ip != NULL) 936 return *ip; 937 } while (np->parent); 938 /* No #address-cells property for the root node, default to 1 */ 939 return 1; 940} 941EXPORT_SYMBOL(prom_n_addr_cells); 942 943int 944prom_n_size_cells(struct device_node* np) 945{ |
961 int* ip; | 946 const int* ip; |
962 do { 963 if (np->parent) 964 np = np->parent; | 947 do { 948 if (np->parent) 949 np = np->parent; |
965 ip = (int *) get_property(np, "#size-cells", NULL); | 950 ip = get_property(np, "#size-cells", NULL); |
966 if (ip != NULL) 967 return *ip; 968 } while (np->parent); 969 /* No #size-cells property for the root node, default to 1 */ 970 return 1; 971} 972EXPORT_SYMBOL(prom_n_size_cells); 973 --- 55 unchanged lines hidden (view full) --- 1029/** Checks if the given "compat" string matches one of the strings in 1030 * the device's "compatible" property 1031 */ 1032int device_is_compatible(struct device_node *device, const char *compat) 1033{ 1034 const char* cp; 1035 int cplen, l; 1036 | 951 if (ip != NULL) 952 return *ip; 953 } while (np->parent); 954 /* No #size-cells property for the root node, default to 1 */ 955 return 1; 956} 957EXPORT_SYMBOL(prom_n_size_cells); 958 --- 55 unchanged lines hidden (view full) --- 1014/** Checks if the given "compat" string matches one of the strings in 1015 * the device's "compatible" property 1016 */ 1017int device_is_compatible(struct device_node *device, const char *compat) 1018{ 1019 const char* cp; 1020 int cplen, l; 1021 |
1037 cp = (char *) get_property(device, "compatible", &cplen); | 1022 cp = get_property(device, "compatible", &cplen); |
1038 if (cp == NULL) 1039 return 0; 1040 while (cplen > 0) { 1041 if (strncasecmp(cp, compat, strlen(compat)) == 0) 1042 return 1; 1043 l = strlen(cp) + 1; 1044 cp += l; 1045 cplen -= l; --- 398 unchanged lines hidden (view full) --- 1444 * Fix up the uninitialized fields in a new device node: 1445 * name, type and pci-specific fields 1446 */ 1447 1448static int of_finish_dynamic_node(struct device_node *node) 1449{ 1450 struct device_node *parent = of_get_parent(node); 1451 int err = 0; | 1023 if (cp == NULL) 1024 return 0; 1025 while (cplen > 0) { 1026 if (strncasecmp(cp, compat, strlen(compat)) == 0) 1027 return 1; 1028 l = strlen(cp) + 1; 1029 cp += l; 1030 cplen -= l; --- 398 unchanged lines hidden (view full) --- 1429 * Fix up the uninitialized fields in a new device node: 1430 * name, type and pci-specific fields 1431 */ 1432 1433static int of_finish_dynamic_node(struct device_node *node) 1434{ 1435 struct device_node *parent = of_get_parent(node); 1436 int err = 0; |
1452 phandle *ibm_phandle; | 1437 const phandle *ibm_phandle; |
1453 1454 node->name = get_property(node, "name", NULL); 1455 node->type = get_property(node, "device_type", NULL); 1456 1457 if (!parent) { 1458 err = -ENODEV; 1459 goto out; 1460 } 1461 1462 /* We don't support that function on PowerMac, at least 1463 * not yet 1464 */ 1465 if (machine_is(powermac)) 1466 return -ENODEV; 1467 1468 /* fix up new node's linux_phandle field */ | 1438 1439 node->name = get_property(node, "name", NULL); 1440 node->type = get_property(node, "device_type", NULL); 1441 1442 if (!parent) { 1443 err = -ENODEV; 1444 goto out; 1445 } 1446 1447 /* We don't support that function on PowerMac, at least 1448 * not yet 1449 */ 1450 if (machine_is(powermac)) 1451 return -ENODEV; 1452 1453 /* fix up new node's linux_phandle field */ |
1469 if ((ibm_phandle = (unsigned int *)get_property(node, 1470 "ibm,phandle", NULL))) | 1454 if ((ibm_phandle = get_property(node, "ibm,phandle", NULL))) |
1471 node->linux_phandle = *ibm_phandle; 1472 1473out: 1474 of_node_put(parent); 1475 return err; 1476} 1477 1478static int prom_reconfig_notifier(struct notifier_block *nb, --- 44 unchanged lines hidden (view full) --- 1523 1524 return pp; 1525} 1526 1527/* 1528 * Find a property with a given name for a given node 1529 * and return the value. 1530 */ | 1455 node->linux_phandle = *ibm_phandle; 1456 1457out: 1458 of_node_put(parent); 1459 return err; 1460} 1461 1462static int prom_reconfig_notifier(struct notifier_block *nb, --- 44 unchanged lines hidden (view full) --- 1507 1508 return pp; 1509} 1510 1511/* 1512 * Find a property with a given name for a given node 1513 * and return the value. 1514 */ |
1531void *get_property(struct device_node *np, const char *name, int *lenp) | 1515const void *get_property(struct device_node *np, const char *name, int *lenp) |
1532{ 1533 struct property *pp = of_find_property(np,name,lenp); 1534 return pp ? pp->value : NULL; 1535} 1536EXPORT_SYMBOL(get_property); 1537 1538/* 1539 * Add a property to a node --- 113 unchanged lines hidden (view full) --- 1653struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) 1654{ 1655 int hardid; 1656 struct device_node *np; 1657 1658 hardid = get_hard_smp_processor_id(cpu); 1659 1660 for_each_node_by_type(np, "cpu") { | 1516{ 1517 struct property *pp = of_find_property(np,name,lenp); 1518 return pp ? pp->value : NULL; 1519} 1520EXPORT_SYMBOL(get_property); 1521 1522/* 1523 * Add a property to a node --- 113 unchanged lines hidden (view full) --- 1637struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) 1638{ 1639 int hardid; 1640 struct device_node *np; 1641 1642 hardid = get_hard_smp_processor_id(cpu); 1643 1644 for_each_node_by_type(np, "cpu") { |
1661 u32 *intserv; | 1645 const u32 *intserv; |
1662 unsigned int plen, t; 1663 1664 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist 1665 * fallback to "reg" property and assume no threads 1666 */ | 1646 unsigned int plen, t; 1647 1648 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist 1649 * fallback to "reg" property and assume no threads 1650 */ |
1667 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", 1668 &plen); | 1651 intserv = get_property(np, "ibm,ppc-interrupt-server#s", 1652 &plen); |
1669 if (intserv == NULL) { | 1653 if (intserv == NULL) { |
1670 u32 *reg = (u32 *)get_property(np, "reg", NULL); | 1654 const u32 *reg = get_property(np, "reg", NULL); |
1671 if (reg == NULL) 1672 continue; 1673 if (*reg == hardid) { 1674 if (thread) 1675 *thread = 0; 1676 return np; 1677 } 1678 } else { --- 36 unchanged lines hidden --- | 1655 if (reg == NULL) 1656 continue; 1657 if (*reg == hardid) { 1658 if (thread) 1659 *thread = 0; 1660 return np; 1661 } 1662 } else { --- 36 unchanged lines hidden --- |