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