setup.c 19 KB

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