setup.c 19 KB

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