aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/prom.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-11-06 22:42:09 -0500
committerPaul Mackerras <paulus@samba.org>2005-11-06 22:42:09 -0500
commitc6135234550ed89a6fd0e8cb229633967e41d649 (patch)
tree22cef33e314839c4fb30d6fc888c0caa2a0f6602 /arch/ppc64/kernel/prom.c
parent76032de898f34db55b5048349db56557828a1390 (diff)
parent0b154bb7d0cce80e9c0bcf11d4f9e71b59409d26 (diff)
Merge ../linux-2.6
Diffstat (limited to 'arch/ppc64/kernel/prom.c')
-rw-r--r--arch/ppc64/kernel/prom.c94
1 files changed, 33 insertions, 61 deletions
diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
index a4cb97a25819..0e8961dea3bc 100644
--- a/arch/ppc64/kernel/prom.c
+++ b/arch/ppc64/kernel/prom.c
@@ -634,10 +634,10 @@ static inline char *find_flat_dt_string(u32 offset)
634 * used to extract the memory informations at boot before we can 634 * used to extract the memory informations at boot before we can
635 * unflatten the tree 635 * unflatten the tree
636 */ 636 */
637static int __init scan_flat_dt(int (*it)(unsigned long node, 637int __init of_scan_flat_dt(int (*it)(unsigned long node,
638 const char *uname, int depth, 638 const char *uname, int depth,
639 void *data), 639 void *data),
640 void *data) 640 void *data)
641{ 641{
642 unsigned long p = ((unsigned long)initial_boot_params) + 642 unsigned long p = ((unsigned long)initial_boot_params) +
643 initial_boot_params->off_dt_struct; 643 initial_boot_params->off_dt_struct;
@@ -694,8 +694,8 @@ static int __init scan_flat_dt(int (*it)(unsigned long node,
694 * This function can be used within scan_flattened_dt callback to get 694 * This function can be used within scan_flattened_dt callback to get
695 * access to properties 695 * access to properties
696 */ 696 */
697static void* __init get_flat_dt_prop(unsigned long node, const char *name, 697void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
698 unsigned long *size) 698 unsigned long *size)
699{ 699{
700 unsigned long p = node; 700 unsigned long p = node;
701 701
@@ -995,7 +995,7 @@ void __init unflatten_device_tree(void)
995static int __init early_init_dt_scan_cpus(unsigned long node, 995static int __init early_init_dt_scan_cpus(unsigned long node,
996 const char *uname, int depth, void *data) 996 const char *uname, int depth, void *data)
997{ 997{
998 char *type = get_flat_dt_prop(node, "device_type", NULL); 998 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
999 u32 *prop; 999 u32 *prop;
1000 unsigned long size; 1000 unsigned long size;
1001 1001
@@ -1003,17 +1003,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
1003 if (type == NULL || strcmp(type, "cpu") != 0) 1003 if (type == NULL || strcmp(type, "cpu") != 0)
1004 return 0; 1004 return 0;
1005 1005
1006 /* On LPAR, look for the first ibm,pft-size property for the hash table size
1007 */
1008 if (systemcfg->platform == PLATFORM_PSERIES_LPAR && ppc64_pft_size == 0) {
1009 u32 *pft_size;
1010 pft_size = (u32 *)get_flat_dt_prop(node, "ibm,pft-size", NULL);
1011 if (pft_size != NULL) {
1012 /* pft_size[0] is the NUMA CEC cookie */
1013 ppc64_pft_size = pft_size[1];
1014 }
1015 }
1016
1017 if (initial_boot_params && initial_boot_params->version >= 2) { 1006 if (initial_boot_params && initial_boot_params->version >= 2) {
1018 /* version 2 of the kexec param format adds the phys cpuid 1007 /* version 2 of the kexec param format adds the phys cpuid
1019 * of booted proc. 1008 * of booted proc.
@@ -1022,8 +1011,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
1022 boot_cpuid = 0; 1011 boot_cpuid = 0;
1023 } else { 1012 } else {
1024 /* Check if it's the boot-cpu, set it's hw index in paca now */ 1013 /* Check if it's the boot-cpu, set it's hw index in paca now */
1025 if (get_flat_dt_prop(node, "linux,boot-cpu", NULL) != NULL) { 1014 if (of_get_flat_dt_prop(node, "linux,boot-cpu", NULL)
1026 u32 *prop = get_flat_dt_prop(node, "reg", NULL); 1015 != NULL) {
1016 u32 *prop = of_get_flat_dt_prop(node, "reg", NULL);
1027 set_hard_smp_processor_id(0, prop == NULL ? 0 : *prop); 1017 set_hard_smp_processor_id(0, prop == NULL ? 0 : *prop);
1028 boot_cpuid_phys = get_hard_smp_processor_id(0); 1018 boot_cpuid_phys = get_hard_smp_processor_id(0);
1029 } 1019 }
@@ -1031,14 +1021,14 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
1031 1021
1032#ifdef CONFIG_ALTIVEC 1022#ifdef CONFIG_ALTIVEC
1033 /* Check if we have a VMX and eventually update CPU features */ 1023 /* Check if we have a VMX and eventually update CPU features */
1034 prop = (u32 *)get_flat_dt_prop(node, "ibm,vmx", NULL); 1024 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,vmx", NULL);
1035 if (prop && (*prop) > 0) { 1025 if (prop && (*prop) > 0) {
1036 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC; 1026 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC;
1037 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 1027 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
1038 } 1028 }
1039 1029
1040 /* Same goes for Apple's "altivec" property */ 1030 /* Same goes for Apple's "altivec" property */
1041 prop = (u32 *)get_flat_dt_prop(node, "altivec", NULL); 1031 prop = (u32 *)of_get_flat_dt_prop(node, "altivec", NULL);
1042 if (prop) { 1032 if (prop) {
1043 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC; 1033 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC;
1044 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 1034 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
@@ -1050,7 +1040,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
1050 * this by looking at the size of the ibm,ppc-interrupt-server#s 1040 * this by looking at the size of the ibm,ppc-interrupt-server#s
1051 * property 1041 * property
1052 */ 1042 */
1053 prop = (u32 *)get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s", 1043 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s",
1054 &size); 1044 &size);
1055 cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT; 1045 cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT;
1056 if (prop && ((size / sizeof(u32)) > 1)) 1046 if (prop && ((size / sizeof(u32)) > 1))
@@ -1071,26 +1061,26 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
1071 return 0; 1061 return 0;
1072 1062
1073 /* get platform type */ 1063 /* get platform type */
1074 prop = (u32 *)get_flat_dt_prop(node, "linux,platform", NULL); 1064 prop = (u32 *)of_get_flat_dt_prop(node, "linux,platform", NULL);
1075 if (prop == NULL) 1065 if (prop == NULL)
1076 return 0; 1066 return 0;
1077 systemcfg->platform = *prop; 1067 systemcfg->platform = *prop;
1078 1068
1079 /* check if iommu is forced on or off */ 1069 /* check if iommu is forced on or off */
1080 if (get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL) 1070 if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL)
1081 iommu_is_off = 1; 1071 iommu_is_off = 1;
1082 if (get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != NULL) 1072 if (of_get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != NULL)
1083 iommu_force_on = 1; 1073 iommu_force_on = 1;
1084 1074
1085 prop64 = (u64*)get_flat_dt_prop(node, "linux,memory-limit", NULL); 1075 prop64 = (u64*)of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
1086 if (prop64) 1076 if (prop64)
1087 memory_limit = *prop64; 1077 memory_limit = *prop64;
1088 1078
1089 prop64 = (u64*)get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); 1079 prop64 = (u64*)of_get_flat_dt_prop(node, "linux,tce-alloc-start",NULL);
1090 if (prop64) 1080 if (prop64)
1091 tce_alloc_start = *prop64; 1081 tce_alloc_start = *prop64;
1092 1082
1093 prop64 = (u64*)get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); 1083 prop64 = (u64*)of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL);
1094 if (prop64) 1084 if (prop64)
1095 tce_alloc_end = *prop64; 1085 tce_alloc_end = *prop64;
1096 1086
@@ -1101,9 +1091,12 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
1101 { 1091 {
1102 u64 *basep, *entryp; 1092 u64 *basep, *entryp;
1103 1093
1104 basep = (u64*)get_flat_dt_prop(node, "linux,rtas-base", NULL); 1094 basep = (u64*)of_get_flat_dt_prop(node,
1105 entryp = (u64*)get_flat_dt_prop(node, "linux,rtas-entry", NULL); 1095 "linux,rtas-base", NULL);
1106 prop = (u32*)get_flat_dt_prop(node, "linux,rtas-size", NULL); 1096 entryp = (u64*)of_get_flat_dt_prop(node,
1097 "linux,rtas-entry", NULL);
1098 prop = (u32*)of_get_flat_dt_prop(node,
1099 "linux,rtas-size", NULL);
1107 if (basep && entryp && prop) { 1100 if (basep && entryp && prop) {
1108 rtas.base = *basep; 1101 rtas.base = *basep;
1109 rtas.entry = *entryp; 1102 rtas.entry = *entryp;
@@ -1124,11 +1117,11 @@ static int __init early_init_dt_scan_root(unsigned long node,
1124 if (depth != 0) 1117 if (depth != 0)
1125 return 0; 1118 return 0;
1126 1119
1127 prop = (u32 *)get_flat_dt_prop(node, "#size-cells", NULL); 1120 prop = (u32 *)of_get_flat_dt_prop(node, "#size-cells", NULL);
1128 dt_root_size_cells = (prop == NULL) ? 1 : *prop; 1121 dt_root_size_cells = (prop == NULL) ? 1 : *prop;
1129 DBG("dt_root_size_cells = %x\n", dt_root_size_cells); 1122 DBG("dt_root_size_cells = %x\n", dt_root_size_cells);
1130 1123
1131 prop = (u32 *)get_flat_dt_prop(node, "#address-cells", NULL); 1124 prop = (u32 *)of_get_flat_dt_prop(node, "#address-cells", NULL);
1132 dt_root_addr_cells = (prop == NULL) ? 2 : *prop; 1125 dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
1133 DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells); 1126 DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells);
1134 1127
@@ -1160,7 +1153,7 @@ static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
1160static int __init early_init_dt_scan_memory(unsigned long node, 1153static int __init early_init_dt_scan_memory(unsigned long node,
1161 const char *uname, int depth, void *data) 1154 const char *uname, int depth, void *data)
1162{ 1155{
1163 char *type = get_flat_dt_prop(node, "device_type", NULL); 1156 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
1164 cell_t *reg, *endp; 1157 cell_t *reg, *endp;
1165 unsigned long l; 1158 unsigned long l;
1166 1159
@@ -1168,7 +1161,7 @@ static int __init early_init_dt_scan_memory(unsigned long node,
1168 if (type == NULL || strcmp(type, "memory") != 0) 1161 if (type == NULL || strcmp(type, "memory") != 0)
1169 return 0; 1162 return 0;
1170 1163
1171 reg = (cell_t *)get_flat_dt_prop(node, "reg", &l); 1164 reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l);
1172 if (reg == NULL) 1165 if (reg == NULL)
1173 return 0; 1166 return 0;
1174 1167
@@ -1224,19 +1217,16 @@ void __init early_init_devtree(void *params)
1224 /* Setup flat device-tree pointer */ 1217 /* Setup flat device-tree pointer */
1225 initial_boot_params = params; 1218 initial_boot_params = params;
1226 1219
1227 /* By default, hash size is not set */
1228 ppc64_pft_size = 0;
1229
1230 /* Retreive various informations from the /chosen node of the 1220 /* Retreive various informations from the /chosen node of the
1231 * device-tree, including the platform type, initrd location and 1221 * device-tree, including the platform type, initrd location and
1232 * size, TCE reserve, and more ... 1222 * size, TCE reserve, and more ...
1233 */ 1223 */
1234 scan_flat_dt(early_init_dt_scan_chosen, NULL); 1224 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
1235 1225
1236 /* Scan memory nodes and rebuild LMBs */ 1226 /* Scan memory nodes and rebuild LMBs */
1237 lmb_init(); 1227 lmb_init();
1238 scan_flat_dt(early_init_dt_scan_root, NULL); 1228 of_scan_flat_dt(early_init_dt_scan_root, NULL);
1239 scan_flat_dt(early_init_dt_scan_memory, NULL); 1229 of_scan_flat_dt(early_init_dt_scan_memory, NULL);
1240 lmb_enforce_memory_limit(memory_limit); 1230 lmb_enforce_memory_limit(memory_limit);
1241 lmb_analyze(); 1231 lmb_analyze();
1242 systemcfg->physicalMemorySize = lmb_phys_mem_size(); 1232 systemcfg->physicalMemorySize = lmb_phys_mem_size();
@@ -1252,26 +1242,8 @@ void __init early_init_devtree(void *params)
1252 /* Retreive hash table size from flattened tree plus other 1242 /* Retreive hash table size from flattened tree plus other
1253 * CPU related informations (altivec support, boot CPU ID, ...) 1243 * CPU related informations (altivec support, boot CPU ID, ...)
1254 */ 1244 */
1255 scan_flat_dt(early_init_dt_scan_cpus, NULL); 1245 of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
1256
1257 /* If hash size wasn't obtained above, we calculate it now based on
1258 * the total RAM size
1259 */
1260 if (ppc64_pft_size == 0) {
1261 unsigned long rnd_mem_size, pteg_count;
1262
1263 /* round mem_size up to next power of 2 */
1264 rnd_mem_size = 1UL << __ilog2(systemcfg->physicalMemorySize);
1265 if (rnd_mem_size < systemcfg->physicalMemorySize)
1266 rnd_mem_size <<= 1;
1267
1268 /* # pages / 2 */
1269 pteg_count = max(rnd_mem_size >> (12 + 1), 1UL << 11);
1270
1271 ppc64_pft_size = __ilog2(pteg_count << 7);
1272 }
1273 1246
1274 DBG("Hash pftSize: %x\n", (int)ppc64_pft_size);
1275 DBG(" <- early_init_devtree()\n"); 1247 DBG(" <- early_init_devtree()\n");
1276} 1248}
1277 1249