Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Mike Corrigan <mikejc@us.ibm.com> |
| 3 | * Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu> |
| 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Description: |
| 6 | * Architecture- / platform-specific boot-time initialization code for |
| 7 | * the IBM iSeries LPAR. Adapted from original code by Grant Erickson and |
| 8 | * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek |
| 9 | * <dan@net4x.com>. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License |
| 13 | * as published by the Free Software Foundation; either version |
| 14 | * 2 of the License, or (at your option) any later version. |
| 15 | */ |
| 16 | |
| 17 | #undef DEBUG |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/init.h> |
| 20 | #include <linux/threads.h> |
| 21 | #include <linux/smp.h> |
| 22 | #include <linux/param.h> |
| 23 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/seq_file.h> |
| 25 | #include <linux/kdev_t.h> |
| 26 | #include <linux/major.h> |
| 27 | #include <linux/root_dev.h> |
Stephen Rothwell | bec7c45 | 2005-11-01 11:45:19 +1100 | [diff] [blame] | 28 | #include <linux/kernel.h> |
Tony Breeds | 1ad7499 | 2007-09-21 13:26:03 +1000 | [diff] [blame] | 29 | #include <linux/hrtimer.h> |
| 30 | #include <linux/tick.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #include <asm/processor.h> |
| 33 | #include <asm/machdep.h> |
| 34 | #include <asm/page.h> |
| 35 | #include <asm/mmu.h> |
| 36 | #include <asm/pgtable.h> |
| 37 | #include <asm/mmu_context.h> |
| 38 | #include <asm/cputable.h> |
| 39 | #include <asm/sections.h> |
| 40 | #include <asm/iommu.h> |
Stephen Rothwell | aed3135 | 2005-08-03 14:43:21 +1000 | [diff] [blame] | 41 | #include <asm/firmware.h> |
Paul Mackerras | 49b0985 | 2005-11-10 15:53:40 +1100 | [diff] [blame] | 42 | #include <asm/system.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <asm/time.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <asm/paca.h> |
| 45 | #include <asm/cache.h> |
Stephen Rothwell | 0bc0ffd | 2005-06-21 17:15:36 -0700 | [diff] [blame] | 46 | #include <asm/abs_addr.h> |
Kelly Daly | 15b1718 | 2005-11-02 11:55:28 +1100 | [diff] [blame] | 47 | #include <asm/iseries/hv_lp_config.h> |
Kelly Daly | c0a8d05 | 2005-11-02 11:11:11 +1100 | [diff] [blame] | 48 | #include <asm/iseries/hv_call_event.h> |
Kelly Daly | 8021b8a | 2005-11-02 11:41:12 +1100 | [diff] [blame] | 49 | #include <asm/iseries/hv_call_xm.h> |
Kelly Daly | 8875ccf | 2005-11-02 14:13:34 +1100 | [diff] [blame] | 50 | #include <asm/iseries/it_lp_queue.h> |
Kelly Daly | bbc8b62 | 2005-11-02 15:10:38 +1100 | [diff] [blame] | 51 | #include <asm/iseries/mf.h> |
Kelly Daly | e45423e | 2005-11-02 12:08:31 +1100 | [diff] [blame] | 52 | #include <asm/iseries/hv_lp_event.h> |
Kelly Daly | c43a55f | 2005-11-02 15:02:47 +1100 | [diff] [blame] | 53 | #include <asm/iseries/lpar_map.h> |
Michael Ellerman | bf6a711 | 2006-01-11 11:54:08 +1100 | [diff] [blame] | 54 | #include <asm/udbg.h> |
Stephen Rothwell | 7d01c88 | 2006-04-04 14:49:48 +1000 | [diff] [blame] | 55 | #include <asm/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
David Gibson | f11b7bd | 2005-11-01 15:30:26 +1100 | [diff] [blame] | 57 | #include "naca.h" |
Stephen Rothwell | c8b8497 | 2005-09-27 18:44:42 +1000 | [diff] [blame] | 58 | #include "setup.h" |
Stephen Rothwell | b08567cb | 2005-09-28 23:37:01 +1000 | [diff] [blame] | 59 | #include "irq.h" |
| 60 | #include "vpd_areas.h" |
| 61 | #include "processor_vpd.h" |
Michael Ellerman | 06a36db | 2006-07-13 17:52:17 +1000 | [diff] [blame] | 62 | #include "it_lp_naca.h" |
Stephen Rothwell | b08567cb | 2005-09-28 23:37:01 +1000 | [diff] [blame] | 63 | #include "main_store.h" |
| 64 | #include "call_sm.h" |
Stephen Rothwell | 0e29bb1 | 2005-10-14 17:09:16 +1000 | [diff] [blame] | 65 | #include "call_hpt.h" |
Stephen Rothwell | 26b6d5b | 2007-11-19 17:06:56 +1100 | [diff] [blame] | 66 | #include "pci.h" |
Stephen Rothwell | c8b8497 | 2005-09-27 18:44:42 +1000 | [diff] [blame] | 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #ifdef DEBUG |
Michael Ellerman | bf6a711 | 2006-01-11 11:54:08 +1100 | [diff] [blame] | 69 | #define DBG(fmt...) udbg_printf(fmt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #else |
| 71 | #define DBG(fmt...) |
| 72 | #endif |
| 73 | |
| 74 | /* Function Prototypes */ |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 75 | static unsigned long build_iSeries_Memory_Map(void); |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 76 | static void iseries_shared_idle(void); |
| 77 | static void iseries_dedicated_idle(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | struct MemoryBlock { |
| 81 | unsigned long absStart; |
| 82 | unsigned long absEnd; |
| 83 | unsigned long logicalStart; |
| 84 | unsigned long logicalEnd; |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | * Process the main store vpd to determine where the holes in memory are |
| 89 | * and return the number of physical blocks and fill in the array of |
| 90 | * block data. |
| 91 | */ |
| 92 | static unsigned long iSeries_process_Condor_mainstore_vpd( |
| 93 | struct MemoryBlock *mb_array, unsigned long max_entries) |
| 94 | { |
| 95 | unsigned long holeFirstChunk, holeSizeChunks; |
| 96 | unsigned long numMemoryBlocks = 1; |
| 97 | struct IoHriMainStoreSegment4 *msVpd = |
| 98 | (struct IoHriMainStoreSegment4 *)xMsVpd; |
| 99 | unsigned long holeStart = msVpd->nonInterleavedBlocksStartAdr; |
| 100 | unsigned long holeEnd = msVpd->nonInterleavedBlocksEndAdr; |
| 101 | unsigned long holeSize = holeEnd - holeStart; |
| 102 | |
| 103 | printk("Mainstore_VPD: Condor\n"); |
| 104 | /* |
| 105 | * Determine if absolute memory has any |
| 106 | * holes so that we can interpret the |
| 107 | * access map we get back from the hypervisor |
| 108 | * correctly. |
| 109 | */ |
| 110 | mb_array[0].logicalStart = 0; |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 111 | mb_array[0].logicalEnd = 0x100000000UL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | mb_array[0].absStart = 0; |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 113 | mb_array[0].absEnd = 0x100000000UL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | if (holeSize) { |
| 116 | numMemoryBlocks = 2; |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 117 | holeStart = holeStart & 0x000fffffffffffffUL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | holeStart = addr_to_chunk(holeStart); |
| 119 | holeFirstChunk = holeStart; |
| 120 | holeSize = addr_to_chunk(holeSize); |
| 121 | holeSizeChunks = holeSize; |
| 122 | printk( "Main store hole: start chunk = %0lx, size = %0lx chunks\n", |
| 123 | holeFirstChunk, holeSizeChunks ); |
| 124 | mb_array[0].logicalEnd = holeFirstChunk; |
| 125 | mb_array[0].absEnd = holeFirstChunk; |
| 126 | mb_array[1].logicalStart = holeFirstChunk; |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 127 | mb_array[1].logicalEnd = 0x100000000UL - holeSizeChunks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | mb_array[1].absStart = holeFirstChunk + holeSizeChunks; |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 129 | mb_array[1].absEnd = 0x100000000UL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | } |
| 131 | return numMemoryBlocks; |
| 132 | } |
| 133 | |
| 134 | #define MaxSegmentAreas 32 |
| 135 | #define MaxSegmentAdrRangeBlocks 128 |
| 136 | #define MaxAreaRangeBlocks 4 |
| 137 | |
| 138 | static unsigned long iSeries_process_Regatta_mainstore_vpd( |
| 139 | struct MemoryBlock *mb_array, unsigned long max_entries) |
| 140 | { |
| 141 | struct IoHriMainStoreSegment5 *msVpdP = |
| 142 | (struct IoHriMainStoreSegment5 *)xMsVpd; |
| 143 | unsigned long numSegmentBlocks = 0; |
| 144 | u32 existsBits = msVpdP->msAreaExists; |
| 145 | unsigned long area_num; |
| 146 | |
| 147 | printk("Mainstore_VPD: Regatta\n"); |
| 148 | |
| 149 | for (area_num = 0; area_num < MaxSegmentAreas; ++area_num ) { |
| 150 | unsigned long numAreaBlocks; |
| 151 | struct IoHriMainStoreArea4 *currentArea; |
| 152 | |
| 153 | if (existsBits & 0x80000000) { |
| 154 | unsigned long block_num; |
| 155 | |
| 156 | currentArea = &msVpdP->msAreaArray[area_num]; |
| 157 | numAreaBlocks = currentArea->numAdrRangeBlocks; |
| 158 | printk("ms_vpd: processing area %2ld blocks=%ld", |
| 159 | area_num, numAreaBlocks); |
| 160 | for (block_num = 0; block_num < numAreaBlocks; |
| 161 | ++block_num ) { |
| 162 | /* Process an address range block */ |
| 163 | struct MemoryBlock tempBlock; |
| 164 | unsigned long i; |
| 165 | |
| 166 | tempBlock.absStart = |
| 167 | (unsigned long)currentArea->xAdrRangeBlock[block_num].blockStart; |
| 168 | tempBlock.absEnd = |
| 169 | (unsigned long)currentArea->xAdrRangeBlock[block_num].blockEnd; |
| 170 | tempBlock.logicalStart = 0; |
| 171 | tempBlock.logicalEnd = 0; |
| 172 | printk("\n block %ld absStart=%016lx absEnd=%016lx", |
| 173 | block_num, tempBlock.absStart, |
| 174 | tempBlock.absEnd); |
| 175 | |
| 176 | for (i = 0; i < numSegmentBlocks; ++i) { |
| 177 | if (mb_array[i].absStart == |
| 178 | tempBlock.absStart) |
| 179 | break; |
| 180 | } |
| 181 | if (i == numSegmentBlocks) { |
| 182 | if (numSegmentBlocks == max_entries) |
| 183 | panic("iSeries_process_mainstore_vpd: too many memory blocks"); |
| 184 | mb_array[numSegmentBlocks] = tempBlock; |
| 185 | ++numSegmentBlocks; |
| 186 | } else |
| 187 | printk(" (duplicate)"); |
| 188 | } |
| 189 | printk("\n"); |
| 190 | } |
| 191 | existsBits <<= 1; |
| 192 | } |
| 193 | /* Now sort the blocks found into ascending sequence */ |
| 194 | if (numSegmentBlocks > 1) { |
| 195 | unsigned long m, n; |
| 196 | |
| 197 | for (m = 0; m < numSegmentBlocks - 1; ++m) { |
| 198 | for (n = numSegmentBlocks - 1; m < n; --n) { |
| 199 | if (mb_array[n].absStart < |
| 200 | mb_array[n-1].absStart) { |
| 201 | struct MemoryBlock tempBlock; |
| 202 | |
| 203 | tempBlock = mb_array[n]; |
| 204 | mb_array[n] = mb_array[n-1]; |
| 205 | mb_array[n-1] = tempBlock; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | /* |
| 211 | * Assign "logical" addresses to each block. These |
| 212 | * addresses correspond to the hypervisor "bitmap" space. |
| 213 | * Convert all addresses into units of 256K chunks. |
| 214 | */ |
| 215 | { |
| 216 | unsigned long i, nextBitmapAddress; |
| 217 | |
| 218 | printk("ms_vpd: %ld sorted memory blocks\n", numSegmentBlocks); |
| 219 | nextBitmapAddress = 0; |
| 220 | for (i = 0; i < numSegmentBlocks; ++i) { |
| 221 | unsigned long length = mb_array[i].absEnd - |
| 222 | mb_array[i].absStart; |
| 223 | |
| 224 | mb_array[i].logicalStart = nextBitmapAddress; |
| 225 | mb_array[i].logicalEnd = nextBitmapAddress + length; |
| 226 | nextBitmapAddress += length; |
| 227 | printk(" Bitmap range: %016lx - %016lx\n" |
| 228 | " Absolute range: %016lx - %016lx\n", |
| 229 | mb_array[i].logicalStart, |
| 230 | mb_array[i].logicalEnd, |
| 231 | mb_array[i].absStart, mb_array[i].absEnd); |
| 232 | mb_array[i].absStart = addr_to_chunk(mb_array[i].absStart & |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 233 | 0x000fffffffffffffUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | mb_array[i].absEnd = addr_to_chunk(mb_array[i].absEnd & |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 235 | 0x000fffffffffffffUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | mb_array[i].logicalStart = |
| 237 | addr_to_chunk(mb_array[i].logicalStart); |
| 238 | mb_array[i].logicalEnd = addr_to_chunk(mb_array[i].logicalEnd); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return numSegmentBlocks; |
| 243 | } |
| 244 | |
| 245 | static unsigned long iSeries_process_mainstore_vpd(struct MemoryBlock *mb_array, |
| 246 | unsigned long max_entries) |
| 247 | { |
| 248 | unsigned long i; |
| 249 | unsigned long mem_blocks = 0; |
| 250 | |
| 251 | if (cpu_has_feature(CPU_FTR_SLB)) |
| 252 | mem_blocks = iSeries_process_Regatta_mainstore_vpd(mb_array, |
| 253 | max_entries); |
| 254 | else |
| 255 | mem_blocks = iSeries_process_Condor_mainstore_vpd(mb_array, |
| 256 | max_entries); |
| 257 | |
| 258 | printk("Mainstore_VPD: numMemoryBlocks = %ld \n", mem_blocks); |
| 259 | for (i = 0; i < mem_blocks; ++i) { |
| 260 | printk("Mainstore_VPD: block %3ld logical chunks %016lx - %016lx\n" |
| 261 | " abs chunks %016lx - %016lx\n", |
| 262 | i, mb_array[i].logicalStart, mb_array[i].logicalEnd, |
| 263 | mb_array[i].absStart, mb_array[i].absEnd); |
| 264 | } |
| 265 | return mem_blocks; |
| 266 | } |
| 267 | |
| 268 | static void __init iSeries_get_cmdline(void) |
| 269 | { |
| 270 | char *p, *q; |
| 271 | |
| 272 | /* copy the command line parameter from the primary VSP */ |
| 273 | HvCallEvent_dmaToSp(cmd_line, 2 * 64* 1024, 256, |
| 274 | HvLpDma_Direction_RemoteToLocal); |
| 275 | |
| 276 | p = cmd_line; |
| 277 | q = cmd_line + 255; |
| 278 | while(p < q) { |
| 279 | if (!*p || *p == '\n') |
| 280 | break; |
| 281 | ++p; |
| 282 | } |
| 283 | *p = 0; |
| 284 | } |
| 285 | |
| 286 | static void __init iSeries_init_early(void) |
| 287 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | DBG(" -> iSeries_init_early()\n"); |
| 289 | |
Tony Breeds | 71712b4 | 2007-06-22 16:54:30 +1000 | [diff] [blame] | 290 | /* Snapshot the timebase, for use in later recalibration */ |
| 291 | iSeries_time_init_early(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
| 293 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | * Initialize the DMA/TCE management |
| 295 | */ |
| 296 | iommu_init_early_iSeries(); |
| 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | /* Initialize machine-dependency vectors */ |
| 299 | #ifdef CONFIG_SMP |
| 300 | smp_init_iSeries(); |
| 301 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | /* Associate Lp Event Queue 0 with processor 0 */ |
| 304 | HvCallEvent_setLpEventQueueInterruptProc(0, 0); |
| 305 | |
| 306 | mf_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | DBG(" <- iSeries_init_early()\n"); |
| 309 | } |
| 310 | |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 311 | struct mschunks_map mschunks_map = { |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 312 | /* XXX We don't use these, but Piranha might need them. */ |
| 313 | .chunk_size = MSCHUNKS_CHUNK_SIZE, |
| 314 | .chunk_shift = MSCHUNKS_CHUNK_SHIFT, |
| 315 | .chunk_mask = MSCHUNKS_OFFSET_MASK, |
| 316 | }; |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 317 | EXPORT_SYMBOL(mschunks_map); |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 318 | |
Stephen Rothwell | 5db9abd | 2007-11-19 17:10:57 +1100 | [diff] [blame] | 319 | static void mschunks_alloc(unsigned long num_chunks) |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 320 | { |
| 321 | klimit = _ALIGN(klimit, sizeof(u32)); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 322 | mschunks_map.mapping = (u32 *)klimit; |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 323 | klimit += num_chunks * sizeof(u32); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 324 | mschunks_map.num_chunks = num_chunks; |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 325 | } |
| 326 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | /* |
| 328 | * The iSeries may have very large memories ( > 128 GB ) and a partition |
| 329 | * may get memory in "chunks" that may be anywhere in the 2**52 real |
| 330 | * address space. The chunks are 256K in size. To map this to the |
| 331 | * memory model Linux expects, the AS/400 specific code builds a |
| 332 | * translation table to translate what Linux thinks are "physical" |
| 333 | * addresses to the actual real addresses. This allows us to make |
| 334 | * it appear to Linux that we have contiguous memory starting at |
| 335 | * physical address zero while in fact this could be far from the truth. |
| 336 | * To avoid confusion, I'll let the words physical and/or real address |
| 337 | * apply to the Linux addresses while I'll use "absolute address" to |
| 338 | * refer to the actual hardware real address. |
| 339 | * |
| 340 | * build_iSeries_Memory_Map gets information from the Hypervisor and |
| 341 | * looks at the Main Store VPD to determine the absolute addresses |
| 342 | * of the memory that has been assigned to our partition and builds |
| 343 | * a table used to translate Linux's physical addresses to these |
| 344 | * absolute addresses. Absolute addresses are needed when |
| 345 | * communicating with the hypervisor (e.g. to build HPT entries) |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 346 | * |
| 347 | * Returns the physical memory size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | */ |
| 349 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 350 | static unsigned long __init build_iSeries_Memory_Map(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | { |
| 352 | u32 loadAreaFirstChunk, loadAreaLastChunk, loadAreaSize; |
| 353 | u32 nextPhysChunk; |
| 354 | u32 hptFirstChunk, hptLastChunk, hptSizeChunks, hptSizePages; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | u32 totalChunks,moreChunks; |
| 356 | u32 currChunk, thisChunk, absChunk; |
| 357 | u32 currDword; |
| 358 | u32 chunkBit; |
| 359 | u64 map; |
| 360 | struct MemoryBlock mb[32]; |
| 361 | unsigned long numMemoryBlocks, curBlock; |
| 362 | |
| 363 | /* Chunk size on iSeries is 256K bytes */ |
| 364 | totalChunks = (u32)HvLpConfig_getMsChunks(); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 365 | mschunks_alloc(totalChunks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | /* |
| 368 | * Get absolute address of our load area |
| 369 | * and map it to physical address 0 |
| 370 | * This guarantees that the loadarea ends up at physical 0 |
| 371 | * otherwise, it might not be returned by PLIC as the first |
| 372 | * chunks |
| 373 | */ |
| 374 | |
| 375 | loadAreaFirstChunk = (u32)addr_to_chunk(itLpNaca.xLoadAreaAddr); |
| 376 | loadAreaSize = itLpNaca.xLoadAreaChunks; |
| 377 | |
| 378 | /* |
| 379 | * Only add the pages already mapped here. |
| 380 | * Otherwise we might add the hpt pages |
| 381 | * The rest of the pages of the load area |
| 382 | * aren't in the HPT yet and can still |
| 383 | * be assigned an arbitrary physical address |
| 384 | */ |
| 385 | if ((loadAreaSize * 64) > HvPagesToMap) |
| 386 | loadAreaSize = HvPagesToMap / 64; |
| 387 | |
| 388 | loadAreaLastChunk = loadAreaFirstChunk + loadAreaSize - 1; |
| 389 | |
| 390 | /* |
| 391 | * TODO Do we need to do something if the HPT is in the 64MB load area? |
| 392 | * This would be required if the itLpNaca.xLoadAreaChunks includes |
| 393 | * the HPT size |
| 394 | */ |
| 395 | |
| 396 | printk("Mapping load area - physical addr = 0000000000000000\n" |
| 397 | " absolute addr = %016lx\n", |
| 398 | chunk_to_addr(loadAreaFirstChunk)); |
| 399 | printk("Load area size %dK\n", loadAreaSize * 256); |
| 400 | |
| 401 | for (nextPhysChunk = 0; nextPhysChunk < loadAreaSize; ++nextPhysChunk) |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 402 | mschunks_map.mapping[nextPhysChunk] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | loadAreaFirstChunk + nextPhysChunk; |
| 404 | |
| 405 | /* |
| 406 | * Get absolute address of our HPT and remember it so |
| 407 | * we won't map it to any physical address |
| 408 | */ |
| 409 | hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); |
| 410 | hptSizePages = (u32)HvCallHpt_getHptPages(); |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 411 | hptSizeChunks = hptSizePages >> |
| 412 | (MSCHUNKS_CHUNK_SHIFT - HW_PAGE_SHIFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | hptLastChunk = hptFirstChunk + hptSizeChunks - 1; |
| 414 | |
| 415 | printk("HPT absolute addr = %016lx, size = %dK\n", |
| 416 | chunk_to_addr(hptFirstChunk), hptSizeChunks * 256); |
| 417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | * Determine if absolute memory has any |
| 420 | * holes so that we can interpret the |
| 421 | * access map we get back from the hypervisor |
| 422 | * correctly. |
| 423 | */ |
| 424 | numMemoryBlocks = iSeries_process_mainstore_vpd(mb, 32); |
| 425 | |
| 426 | /* |
| 427 | * Process the main store access map from the hypervisor |
| 428 | * to build up our physical -> absolute translation table |
| 429 | */ |
| 430 | curBlock = 0; |
| 431 | currChunk = 0; |
| 432 | currDword = 0; |
| 433 | moreChunks = totalChunks; |
| 434 | |
| 435 | while (moreChunks) { |
| 436 | map = HvCallSm_get64BitsOfAccessMap(itLpNaca.xLpIndex, |
| 437 | currDword); |
| 438 | thisChunk = currChunk; |
| 439 | while (map) { |
| 440 | chunkBit = map >> 63; |
| 441 | map <<= 1; |
| 442 | if (chunkBit) { |
| 443 | --moreChunks; |
| 444 | while (thisChunk >= mb[curBlock].logicalEnd) { |
| 445 | ++curBlock; |
| 446 | if (curBlock >= numMemoryBlocks) |
| 447 | panic("out of memory blocks"); |
| 448 | } |
| 449 | if (thisChunk < mb[curBlock].logicalStart) |
| 450 | panic("memory block error"); |
| 451 | |
| 452 | absChunk = mb[curBlock].absStart + |
| 453 | (thisChunk - mb[curBlock].logicalStart); |
| 454 | if (((absChunk < hptFirstChunk) || |
| 455 | (absChunk > hptLastChunk)) && |
| 456 | ((absChunk < loadAreaFirstChunk) || |
| 457 | (absChunk > loadAreaLastChunk))) { |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 458 | mschunks_map.mapping[nextPhysChunk] = |
| 459 | absChunk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | ++nextPhysChunk; |
| 461 | } |
| 462 | } |
| 463 | ++thisChunk; |
| 464 | } |
| 465 | ++currDword; |
| 466 | currChunk += 64; |
| 467 | } |
| 468 | |
| 469 | /* |
| 470 | * main store size (in chunks) is |
| 471 | * totalChunks - hptSizeChunks |
| 472 | * which should be equal to |
| 473 | * nextPhysChunk |
| 474 | */ |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 475 | return chunk_to_addr(nextPhysChunk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | * Document me. |
| 480 | */ |
| 481 | static void __init iSeries_setup_arch(void) |
| 482 | { |
David Gibson | 3356bb9 | 2006-01-13 10:26:42 +1100 | [diff] [blame] | 483 | if (get_lppaca()->shared_proc) { |
Michael Ellerman | 9f49758 | 2005-09-23 14:10:59 +1000 | [diff] [blame] | 484 | ppc_md.idle_loop = iseries_shared_idle; |
Olof Johansson | 4baaf0c | 2006-04-12 15:23:22 -0500 | [diff] [blame] | 485 | printk(KERN_DEBUG "Using shared processor idle loop\n"); |
Michael Ellerman | 9f49758 | 2005-09-23 14:10:59 +1000 | [diff] [blame] | 486 | } else { |
| 487 | ppc_md.idle_loop = iseries_dedicated_idle; |
Olof Johansson | 4baaf0c | 2006-04-12 15:23:22 -0500 | [diff] [blame] | 488 | printk(KERN_DEBUG "Using dedicated idle loop\n"); |
Michael Ellerman | 9f49758 | 2005-09-23 14:10:59 +1000 | [diff] [blame] | 489 | } |
| 490 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | /* Setup the Lp Event Queue */ |
Michael Ellerman | 512d31d | 2005-06-30 15:08:27 +1000 | [diff] [blame] | 492 | setup_hvlpevent_queue(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | printk("Max logical processors = %d\n", |
| 495 | itVpdAreas.xSlicMaxLogicalProcs); |
| 496 | printk("Max physical processors = %d\n", |
| 497 | itVpdAreas.xSlicMaxPhysicalProcs); |
Stephen Rothwell | cb99302 | 2007-12-07 02:00:45 +1100 | [diff] [blame] | 498 | |
| 499 | iSeries_pcibios_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Paul Mackerras | d8699e6 | 2005-10-20 17:02:01 +1000 | [diff] [blame] | 502 | static void iSeries_show_cpuinfo(struct seq_file *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | { |
| 504 | seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n"); |
| 505 | } |
| 506 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | static void __init iSeries_progress(char * st, unsigned short code) |
| 508 | { |
| 509 | printk("Progress: [%04x] - %s\n", (unsigned)code, st); |
Michael Ellerman | 260de22 | 2006-03-21 20:46:02 +1100 | [diff] [blame] | 510 | mf_display_progress(code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | static void __init iSeries_fixup_klimit(void) |
| 514 | { |
| 515 | /* |
| 516 | * Change klimit to take into account any ram disk |
| 517 | * that may be included |
| 518 | */ |
| 519 | if (naca.xRamDisk) |
| 520 | klimit = KERNELBASE + (u64)naca.xRamDisk + |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 521 | (naca.xRamDiskSize * HW_PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | static int __init iSeries_src_init(void) |
| 525 | { |
| 526 | /* clear the progress line */ |
Stephen Rothwell | e75b171 | 2007-01-04 17:06:21 +1100 | [diff] [blame] | 527 | if (firmware_has_feature(FW_FEATURE_ISERIES)) |
| 528 | ppc_md.progress(" ", 0xffff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | late_initcall(iSeries_src_init); |
| 533 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 534 | static inline void process_iSeries_events(void) |
| 535 | { |
| 536 | asm volatile ("li 0,0x5555; sc" : : : "r0", "r3"); |
| 537 | } |
| 538 | |
| 539 | static void yield_shared_processor(void) |
| 540 | { |
| 541 | unsigned long tb; |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 542 | |
| 543 | HvCall_setEnabledInterrupts(HvCall_MaskIPI | |
| 544 | HvCall_MaskLpEvent | |
| 545 | HvCall_MaskLpProd | |
| 546 | HvCall_MaskTimeout); |
| 547 | |
| 548 | tb = get_tb(); |
| 549 | /* Compute future tb value when yield should expire */ |
| 550 | HvCall_yieldProcessor(HvCall_YieldTimed, tb+tb_ticks_per_jiffy); |
| 551 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 552 | /* |
| 553 | * The decrementer stops during the yield. Force a fake decrementer |
| 554 | * here and let the timer_interrupt code sort out the actual time. |
| 555 | */ |
David Gibson | 3356bb9 | 2006-01-13 10:26:42 +1100 | [diff] [blame] | 556 | get_lppaca()->int_dword.fields.decr_int = 1; |
Anton Blanchard | cb2c9b2 | 2006-02-13 14:48:35 +1100 | [diff] [blame] | 557 | ppc64_runlatch_on(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 558 | process_iSeries_events(); |
| 559 | } |
| 560 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 561 | static void iseries_shared_idle(void) |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 562 | { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 563 | while (1) { |
Thomas Gleixner | b8f8c3c | 2008-07-18 17:27:28 +0200 | [diff] [blame^] | 564 | tick_nohz_stop_sched_tick(1); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 565 | while (!need_resched() && !hvlpevent_is_pending()) { |
| 566 | local_irq_disable(); |
| 567 | ppc64_runlatch_off(); |
| 568 | |
| 569 | /* Recheck with irqs off */ |
| 570 | if (!need_resched() && !hvlpevent_is_pending()) |
| 571 | yield_shared_processor(); |
| 572 | |
| 573 | HMT_medium(); |
| 574 | local_irq_enable(); |
| 575 | } |
| 576 | |
| 577 | ppc64_runlatch_on(); |
Tony Breeds | 1ad7499 | 2007-09-21 13:26:03 +1000 | [diff] [blame] | 578 | tick_nohz_restart_sched_tick(); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 579 | |
| 580 | if (hvlpevent_is_pending()) |
| 581 | process_iSeries_events(); |
| 582 | |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 583 | preempt_enable_no_resched(); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 584 | schedule(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 585 | preempt_disable(); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 586 | } |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Paul Mackerras | 143a1de | 2005-10-19 23:11:21 +1000 | [diff] [blame] | 589 | static void iseries_dedicated_idle(void) |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 590 | { |
Nick Piggin | 64c7c8f | 2005-11-08 21:39:04 -0800 | [diff] [blame] | 591 | set_thread_flag(TIF_POLLING_NRFLAG); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 592 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 593 | while (1) { |
Thomas Gleixner | b8f8c3c | 2008-07-18 17:27:28 +0200 | [diff] [blame^] | 594 | tick_nohz_stop_sched_tick(1); |
Nick Piggin | 64c7c8f | 2005-11-08 21:39:04 -0800 | [diff] [blame] | 595 | if (!need_resched()) { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 596 | while (!need_resched()) { |
| 597 | ppc64_runlatch_off(); |
| 598 | HMT_low(); |
| 599 | |
| 600 | if (hvlpevent_is_pending()) { |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 601 | HMT_medium(); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 602 | ppc64_runlatch_on(); |
| 603 | process_iSeries_events(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 604 | } |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 605 | } |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 606 | |
| 607 | HMT_medium(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | ppc64_runlatch_on(); |
Tony Breeds | 1ad7499 | 2007-09-21 13:26:03 +1000 | [diff] [blame] | 611 | tick_nohz_restart_sched_tick(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 612 | preempt_enable_no_resched(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 613 | schedule(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 614 | preempt_disable(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 615 | } |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 618 | static void __iomem *iseries_ioremap(phys_addr_t address, unsigned long size, |
Benjamin Herrenschmidt | 4cb3cee | 2006-11-11 17:25:10 +1100 | [diff] [blame] | 619 | unsigned long flags) |
| 620 | { |
| 621 | return (void __iomem *)address; |
| 622 | } |
| 623 | |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 624 | static void iseries_iounmap(volatile void __iomem *token) |
Benjamin Herrenschmidt | 4cb3cee | 2006-11-11 17:25:10 +1100 | [diff] [blame] | 625 | { |
| 626 | } |
| 627 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 628 | static int __init iseries_probe(void) |
Michael Ellerman | 4762713 | 2005-09-23 14:59:04 +1000 | [diff] [blame] | 629 | { |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 630 | unsigned long root = of_get_flat_dt_root(); |
| 631 | if (!of_flat_dt_is_compatible(root, "IBM,iSeries")) |
Michael Ellerman | 57cfb81 | 2006-03-21 20:45:59 +1100 | [diff] [blame] | 632 | return 0; |
| 633 | |
Michael Ellerman | 7d0daae | 2006-06-23 18:16:38 +1000 | [diff] [blame] | 634 | hpte_init_iSeries(); |
Stephen Rothwell | 0470466 | 2006-11-30 11:46:22 +1100 | [diff] [blame] | 635 | /* iSeries does not support 16M pages */ |
| 636 | cur_cpu_spec->cpu_features &= ~CPU_FTR_16M_PAGE; |
Michael Ellerman | 7d0daae | 2006-06-23 18:16:38 +1000 | [diff] [blame] | 637 | |
Michael Ellerman | 57cfb81 | 2006-03-21 20:45:59 +1100 | [diff] [blame] | 638 | return 1; |
Michael Ellerman | 4762713 | 2005-09-23 14:59:04 +1000 | [diff] [blame] | 639 | } |
| 640 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 641 | define_machine(iseries) { |
Benjamin Herrenschmidt | 50c9bc2 | 2007-12-20 14:54:55 +1100 | [diff] [blame] | 642 | .name = "iSeries", |
| 643 | .setup_arch = iSeries_setup_arch, |
| 644 | .show_cpuinfo = iSeries_show_cpuinfo, |
| 645 | .init_IRQ = iSeries_init_IRQ, |
| 646 | .get_irq = iSeries_get_irq, |
| 647 | .init_early = iSeries_init_early, |
| 648 | .pcibios_fixup = iSeries_pci_final_fixup, |
| 649 | .pcibios_fixup_resources= iSeries_pcibios_fixup_resources, |
| 650 | .restart = mf_reboot, |
| 651 | .power_off = mf_power_off, |
| 652 | .halt = mf_power_off, |
| 653 | .get_boot_time = iSeries_get_boot_time, |
| 654 | .set_rtc_time = iSeries_set_rtc_time, |
| 655 | .get_rtc_time = iSeries_get_rtc_time, |
| 656 | .calibrate_decr = generic_calibrate_decr, |
| 657 | .progress = iSeries_progress, |
| 658 | .probe = iseries_probe, |
| 659 | .ioremap = iseries_ioremap, |
| 660 | .iounmap = iseries_iounmap, |
Michael Ellerman | 9f49758 | 2005-09-23 14:10:59 +1000 | [diff] [blame] | 661 | /* XXX Implement enable_pmcs for iSeries */ |
| 662 | }; |
| 663 | |
Michael Ellerman | 4762713 | 2005-09-23 14:59:04 +1000 | [diff] [blame] | 664 | void * __init iSeries_early_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | { |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 666 | unsigned long phys_mem_size; |
| 667 | |
Benjamin Herrenschmidt | 42c4aaa | 2006-10-24 16:42:40 +1000 | [diff] [blame] | 668 | /* Identify CPU type. This is done again by the common code later |
| 669 | * on but calling this function multiple times is fine. |
| 670 | */ |
Paul Mackerras | 974a76f | 2006-11-10 20:38:53 +1100 | [diff] [blame] | 671 | identify_cpu(0, mfspr(SPRN_PVR)); |
Benjamin Herrenschmidt | 42c4aaa | 2006-10-24 16:42:40 +1000 | [diff] [blame] | 672 | |
Stephen Rothwell | ef26a46 | 2006-09-25 13:27:17 +1000 | [diff] [blame] | 673 | powerpc_firmware_features |= FW_FEATURE_ISERIES; |
| 674 | powerpc_firmware_features |= FW_FEATURE_LPAR; |
| 675 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | iSeries_fixup_klimit(); |
Michael Ellerman | c0a5949 | 2005-09-23 14:56:09 +1000 | [diff] [blame] | 677 | |
Michael Ellerman | 4762713 | 2005-09-23 14:59:04 +1000 | [diff] [blame] | 678 | /* |
| 679 | * Initialize the table which translate Linux physical addresses to |
| 680 | * AS/400 absolute addresses |
| 681 | */ |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 682 | phys_mem_size = build_iSeries_Memory_Map(); |
Michael Ellerman | 4762713 | 2005-09-23 14:59:04 +1000 | [diff] [blame] | 683 | |
Stephen Rothwell | bec7c45 | 2005-11-01 11:45:19 +1100 | [diff] [blame] | 684 | iSeries_get_cmdline(); |
| 685 | |
Stephen Rothwell | c81014f | 2006-05-19 17:00:04 +1000 | [diff] [blame] | 686 | return (void *) __pa(build_flat_dt(phys_mem_size)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | } |
Stephen Rothwell | bec7c45 | 2005-11-01 11:45:19 +1100 | [diff] [blame] | 688 | |
Michael Ellerman | bf6a711 | 2006-01-11 11:54:08 +1100 | [diff] [blame] | 689 | static void hvputc(char c) |
| 690 | { |
| 691 | if (c == '\n') |
| 692 | hvputc('\r'); |
| 693 | |
| 694 | HvCall_writeLogBuffer(&c, 1); |
| 695 | } |
| 696 | |
| 697 | void __init udbg_init_iseries(void) |
| 698 | { |
| 699 | udbg_putc = hvputc; |
| 700 | } |