setup.c 19 KB

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