setup.c 18.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 *    Copyright (c) 2000 Mike Corrigan <mikejc@us.ibm.com>
 *    Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
 *
 *    Description:
 *      Architecture- / platform-specific boot-time initialization code for
 *      the IBM iSeries LPAR.  Adapted from original code by Grant Erickson and
 *      code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
 *      <dan@net4x.com>.
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License
 *      as published by the Free Software Foundation; either version
 *      2 of the License, or (at your option) any later version.
 */

#undef DEBUG

#include <linux/init.h>
#include <linux/threads.h>
#include <linux/smp.h>
#include <linux/param.h>
#include <linux/string.h>
#include <linux/seq_file.h>
#include <linux/kdev_t.h>
26
#include <linux/kexec.h>
L
Linus Torvalds 已提交
27 28
#include <linux/major.h>
#include <linux/root_dev.h>
29
#include <linux/kernel.h>
30 31
#include <linux/hrtimer.h>
#include <linux/tick.h>
L
Linus Torvalds 已提交
32 33 34 35 36 37 38 39 40 41

#include <asm/processor.h>
#include <asm/machdep.h>
#include <asm/page.h>
#include <asm/mmu.h>
#include <asm/pgtable.h>
#include <asm/mmu_context.h>
#include <asm/cputable.h>
#include <asm/sections.h>
#include <asm/iommu.h>
42
#include <asm/firmware.h>
43
#include <asm/system.h>
L
Linus Torvalds 已提交
44 45 46
#include <asm/time.h>
#include <asm/paca.h>
#include <asm/cache.h>
47
#include <asm/abs_addr.h>
48
#include <asm/iseries/hv_lp_config.h>
49
#include <asm/iseries/hv_call_event.h>
50
#include <asm/iseries/hv_call_xm.h>
51
#include <asm/iseries/it_lp_queue.h>
52
#include <asm/iseries/mf.h>
53
#include <asm/iseries/hv_lp_event.h>
54
#include <asm/iseries/lpar_map.h>
55
#include <asm/udbg.h>
56
#include <asm/irq.h>
L
Linus Torvalds 已提交
57

58
#include "naca.h"
59
#include "setup.h"
60 61 62
#include "irq.h"
#include "vpd_areas.h"
#include "processor_vpd.h"
63
#include "it_lp_naca.h"
64 65
#include "main_store.h"
#include "call_sm.h"
66
#include "call_hpt.h"
67
#include "pci.h"
68

L
Linus Torvalds 已提交
69
#ifdef DEBUG
70
#define DBG(fmt...) udbg_printf(fmt)
L
Linus Torvalds 已提交
71 72 73 74 75
#else
#define DBG(fmt...)
#endif

/* Function Prototypes */
76
static unsigned long build_iSeries_Memory_Map(void);
P
Paul Mackerras 已提交
77 78
static void iseries_shared_idle(void);
static void iseries_dedicated_idle(void);
L
Linus Torvalds 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111


struct MemoryBlock {
	unsigned long absStart;
	unsigned long absEnd;
	unsigned long logicalStart;
	unsigned long logicalEnd;
};

/*
 * Process the main store vpd to determine where the holes in memory are
 * and return the number of physical blocks and fill in the array of
 * block data.
 */
static unsigned long iSeries_process_Condor_mainstore_vpd(
		struct MemoryBlock *mb_array, unsigned long max_entries)
{
	unsigned long holeFirstChunk, holeSizeChunks;
	unsigned long numMemoryBlocks = 1;
	struct IoHriMainStoreSegment4 *msVpd =
		(struct IoHriMainStoreSegment4 *)xMsVpd;
	unsigned long holeStart = msVpd->nonInterleavedBlocksStartAdr;
	unsigned long holeEnd = msVpd->nonInterleavedBlocksEndAdr;
	unsigned long holeSize = holeEnd - holeStart;

	printk("Mainstore_VPD: Condor\n");
	/*
	 * Determine if absolute memory has any
	 * holes so that we can interpret the
	 * access map we get back from the hypervisor
	 * correctly.
	 */
	mb_array[0].logicalStart = 0;
112
	mb_array[0].logicalEnd = 0x100000000UL;
L
Linus Torvalds 已提交
113
	mb_array[0].absStart = 0;
114
	mb_array[0].absEnd = 0x100000000UL;
L
Linus Torvalds 已提交
115 116 117

	if (holeSize) {
		numMemoryBlocks = 2;
118
		holeStart = holeStart & 0x000fffffffffffffUL;
L
Linus Torvalds 已提交
119 120 121 122 123 124 125 126 127
		holeStart = addr_to_chunk(holeStart);
		holeFirstChunk = holeStart;
		holeSize = addr_to_chunk(holeSize);
		holeSizeChunks = holeSize;
		printk( "Main store hole: start chunk = %0lx, size = %0lx chunks\n",
				holeFirstChunk, holeSizeChunks );
		mb_array[0].logicalEnd = holeFirstChunk;
		mb_array[0].absEnd = holeFirstChunk;
		mb_array[1].logicalStart = holeFirstChunk;
128
		mb_array[1].logicalEnd = 0x100000000UL - holeSizeChunks;
L
Linus Torvalds 已提交
129
		mb_array[1].absStart = holeFirstChunk + holeSizeChunks;
130
		mb_array[1].absEnd = 0x100000000UL;
L
Linus Torvalds 已提交
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
	}
	return numMemoryBlocks;
}

#define MaxSegmentAreas			32
#define MaxSegmentAdrRangeBlocks	128
#define MaxAreaRangeBlocks		4

static unsigned long iSeries_process_Regatta_mainstore_vpd(
		struct MemoryBlock *mb_array, unsigned long max_entries)
{
	struct IoHriMainStoreSegment5 *msVpdP =
		(struct IoHriMainStoreSegment5 *)xMsVpd;
	unsigned long numSegmentBlocks = 0;
	u32 existsBits = msVpdP->msAreaExists;
	unsigned long area_num;

	printk("Mainstore_VPD: Regatta\n");

	for (area_num = 0; area_num < MaxSegmentAreas; ++area_num ) {
		unsigned long numAreaBlocks;
		struct IoHriMainStoreArea4 *currentArea;

		if (existsBits & 0x80000000) {
			unsigned long block_num;

			currentArea = &msVpdP->msAreaArray[area_num];
			numAreaBlocks = currentArea->numAdrRangeBlocks;
			printk("ms_vpd: processing area %2ld  blocks=%ld",
					area_num, numAreaBlocks);
			for (block_num = 0; block_num < numAreaBlocks;
					++block_num ) {
				/* Process an address range block */
				struct MemoryBlock tempBlock;
				unsigned long i;

				tempBlock.absStart =
					(unsigned long)currentArea->xAdrRangeBlock[block_num].blockStart;
				tempBlock.absEnd =
					(unsigned long)currentArea->xAdrRangeBlock[block_num].blockEnd;
				tempBlock.logicalStart = 0;
				tempBlock.logicalEnd   = 0;
				printk("\n          block %ld absStart=%016lx absEnd=%016lx",
						block_num, tempBlock.absStart,
						tempBlock.absEnd);

				for (i = 0; i < numSegmentBlocks; ++i) {
					if (mb_array[i].absStart ==
							tempBlock.absStart)
						break;
				}
				if (i == numSegmentBlocks) {
					if (numSegmentBlocks == max_entries)
						panic("iSeries_process_mainstore_vpd: too many memory blocks");
					mb_array[numSegmentBlocks] = tempBlock;
					++numSegmentBlocks;
				} else
					printk(" (duplicate)");
			}
			printk("\n");
		}
		existsBits <<= 1;
	}
	/* Now sort the blocks found into ascending sequence */
	if (numSegmentBlocks > 1) {
		unsigned long m, n;

		for (m = 0; m < numSegmentBlocks - 1; ++m) {
			for (n = numSegmentBlocks - 1; m < n; --n) {
				if (mb_array[n].absStart <
						mb_array[n-1].absStart) {
					struct MemoryBlock tempBlock;

					tempBlock = mb_array[n];
					mb_array[n] = mb_array[n-1];
					mb_array[n-1] = tempBlock;
				}
			}
		}
	}
	/*
	 * Assign "logical" addresses to each block.  These
	 * addresses correspond to the hypervisor "bitmap" space.
	 * Convert all addresses into units of 256K chunks.
	 */
	{
	unsigned long i, nextBitmapAddress;

	printk("ms_vpd: %ld sorted memory blocks\n", numSegmentBlocks);
	nextBitmapAddress = 0;
	for (i = 0; i < numSegmentBlocks; ++i) {
		unsigned long length = mb_array[i].absEnd -
			mb_array[i].absStart;

		mb_array[i].logicalStart = nextBitmapAddress;
		mb_array[i].logicalEnd = nextBitmapAddress + length;
		nextBitmapAddress += length;
		printk("          Bitmap range: %016lx - %016lx\n"
				"        Absolute range: %016lx - %016lx\n",
				mb_array[i].logicalStart,
				mb_array[i].logicalEnd,
				mb_array[i].absStart, mb_array[i].absEnd);
		mb_array[i].absStart = addr_to_chunk(mb_array[i].absStart &
234
				0x000fffffffffffffUL);
L
Linus Torvalds 已提交
235
		mb_array[i].absEnd = addr_to_chunk(mb_array[i].absEnd &
236
				0x000fffffffffffffUL);
L
Linus Torvalds 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
		mb_array[i].logicalStart =
			addr_to_chunk(mb_array[i].logicalStart);
		mb_array[i].logicalEnd = addr_to_chunk(mb_array[i].logicalEnd);
	}
	}

	return numSegmentBlocks;
}

static unsigned long iSeries_process_mainstore_vpd(struct MemoryBlock *mb_array,
		unsigned long max_entries)
{
	unsigned long i;
	unsigned long mem_blocks = 0;

252
	if (mmu_has_feature(MMU_FTR_SLB))
L
Linus Torvalds 已提交
253 254 255 256 257 258
		mem_blocks = iSeries_process_Regatta_mainstore_vpd(mb_array,
				max_entries);
	else
		mem_blocks = iSeries_process_Condor_mainstore_vpd(mb_array,
				max_entries);

259
	printk("Mainstore_VPD: numMemoryBlocks = %ld\n", mem_blocks);
L
Linus Torvalds 已提交
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
	for (i = 0; i < mem_blocks; ++i) {
		printk("Mainstore_VPD: block %3ld logical chunks %016lx - %016lx\n"
		       "                             abs chunks %016lx - %016lx\n",
			i, mb_array[i].logicalStart, mb_array[i].logicalEnd,
			mb_array[i].absStart, mb_array[i].absEnd);
	}
	return mem_blocks;
}

static void __init iSeries_get_cmdline(void)
{
	char *p, *q;

	/* copy the command line parameter from the primary VSP  */
	HvCallEvent_dmaToSp(cmd_line, 2 * 64* 1024, 256,
			HvLpDma_Direction_RemoteToLocal);

	p = cmd_line;
	q = cmd_line + 255;
	while(p < q) {
		if (!*p || *p == '\n')
			break;
		++p;
	}
	*p = 0;
}

static void __init iSeries_init_early(void)
{
	DBG(" -> iSeries_init_early()\n");

291 292
	/* Snapshot the timebase, for use in later recalibration */
	iSeries_time_init_early();
L
Linus Torvalds 已提交
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311

	/*
	 * Initialize the DMA/TCE management
	 */
	iommu_init_early_iSeries();

	/* Initialize machine-dependency vectors */
#ifdef CONFIG_SMP
	smp_init_iSeries();
#endif

	/* Associate Lp Event Queue 0 with processor 0 */
	HvCallEvent_setLpEventQueueInterruptProc(0, 0);

	mf_init();

	DBG(" <- iSeries_init_early()\n");
}

312
struct mschunks_map mschunks_map = {
313 314 315 316 317
	/* XXX We don't use these, but Piranha might need them. */
	.chunk_size  = MSCHUNKS_CHUNK_SIZE,
	.chunk_shift = MSCHUNKS_CHUNK_SHIFT,
	.chunk_mask  = MSCHUNKS_OFFSET_MASK,
};
318
EXPORT_SYMBOL(mschunks_map);
319

320
static void mschunks_alloc(unsigned long num_chunks)
321 322
{
	klimit = _ALIGN(klimit, sizeof(u32));
323
	mschunks_map.mapping = (u32 *)klimit;
324
	klimit += num_chunks * sizeof(u32);
325
	mschunks_map.num_chunks = num_chunks;
326 327
}

L
Linus Torvalds 已提交
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
/*
 * The iSeries may have very large memories ( > 128 GB ) and a partition
 * may get memory in "chunks" that may be anywhere in the 2**52 real
 * address space.  The chunks are 256K in size.  To map this to the
 * memory model Linux expects, the AS/400 specific code builds a
 * translation table to translate what Linux thinks are "physical"
 * addresses to the actual real addresses.  This allows us to make
 * it appear to Linux that we have contiguous memory starting at
 * physical address zero while in fact this could be far from the truth.
 * To avoid confusion, I'll let the words physical and/or real address
 * apply to the Linux addresses while I'll use "absolute address" to
 * refer to the actual hardware real address.
 *
 * build_iSeries_Memory_Map gets information from the Hypervisor and
 * looks at the Main Store VPD to determine the absolute addresses
 * of the memory that has been assigned to our partition and builds
 * a table used to translate Linux's physical addresses to these
 * absolute addresses.  Absolute addresses are needed when
 * communicating with the hypervisor (e.g. to build HPT entries)
347 348
 *
 * Returns the physical memory size
L
Linus Torvalds 已提交
349 350
 */

351
static unsigned long __init build_iSeries_Memory_Map(void)
L
Linus Torvalds 已提交
352 353 354 355 356 357 358 359 360 361 362 363 364 365
{
	u32 loadAreaFirstChunk, loadAreaLastChunk, loadAreaSize;
	u32 nextPhysChunk;
	u32 hptFirstChunk, hptLastChunk, hptSizeChunks, hptSizePages;
	u32 totalChunks,moreChunks;
	u32 currChunk, thisChunk, absChunk;
	u32 currDword;
	u32 chunkBit;
	u64 map;
	struct MemoryBlock mb[32];
	unsigned long numMemoryBlocks, curBlock;

	/* Chunk size on iSeries is 256K bytes */
	totalChunks = (u32)HvLpConfig_getMsChunks();
366
	mschunks_alloc(totalChunks);
L
Linus Torvalds 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402

	/*
	 * Get absolute address of our load area
	 * and map it to physical address 0
	 * This guarantees that the loadarea ends up at physical 0
	 * otherwise, it might not be returned by PLIC as the first
	 * chunks
	 */

	loadAreaFirstChunk = (u32)addr_to_chunk(itLpNaca.xLoadAreaAddr);
	loadAreaSize =  itLpNaca.xLoadAreaChunks;

	/*
	 * Only add the pages already mapped here.
	 * Otherwise we might add the hpt pages
	 * The rest of the pages of the load area
	 * aren't in the HPT yet and can still
	 * be assigned an arbitrary physical address
	 */
	if ((loadAreaSize * 64) > HvPagesToMap)
		loadAreaSize = HvPagesToMap / 64;

	loadAreaLastChunk = loadAreaFirstChunk + loadAreaSize - 1;

	/*
	 * TODO Do we need to do something if the HPT is in the 64MB load area?
	 * This would be required if the itLpNaca.xLoadAreaChunks includes
	 * the HPT size
	 */

	printk("Mapping load area - physical addr = 0000000000000000\n"
		"                    absolute addr = %016lx\n",
		chunk_to_addr(loadAreaFirstChunk));
	printk("Load area size %dK\n", loadAreaSize * 256);

	for (nextPhysChunk = 0; nextPhysChunk < loadAreaSize; ++nextPhysChunk)
403
		mschunks_map.mapping[nextPhysChunk] =
L
Linus Torvalds 已提交
404 405 406 407 408 409 410 411
			loadAreaFirstChunk + nextPhysChunk;

	/*
	 * Get absolute address of our HPT and remember it so
	 * we won't map it to any physical address
	 */
	hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress());
	hptSizePages = (u32)HvCallHpt_getHptPages();
412 413
	hptSizeChunks = hptSizePages >>
		(MSCHUNKS_CHUNK_SHIFT - HW_PAGE_SHIFT);
L
Linus Torvalds 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
	hptLastChunk = hptFirstChunk + hptSizeChunks - 1;

	printk("HPT absolute addr = %016lx, size = %dK\n",
			chunk_to_addr(hptFirstChunk), hptSizeChunks * 256);

	/*
	 * Determine if absolute memory has any
	 * holes so that we can interpret the
	 * access map we get back from the hypervisor
	 * correctly.
	 */
	numMemoryBlocks = iSeries_process_mainstore_vpd(mb, 32);

	/*
	 * Process the main store access map from the hypervisor
	 * to build up our physical -> absolute translation table
	 */
	curBlock = 0;
	currChunk = 0;
	currDword = 0;
	moreChunks = totalChunks;

	while (moreChunks) {
		map = HvCallSm_get64BitsOfAccessMap(itLpNaca.xLpIndex,
				currDword);
		thisChunk = currChunk;
		while (map) {
			chunkBit = map >> 63;
			map <<= 1;
			if (chunkBit) {
				--moreChunks;
				while (thisChunk >= mb[curBlock].logicalEnd) {
					++curBlock;
					if (curBlock >= numMemoryBlocks)
						panic("out of memory blocks");
				}
				if (thisChunk < mb[curBlock].logicalStart)
					panic("memory block error");

				absChunk = mb[curBlock].absStart +
					(thisChunk - mb[curBlock].logicalStart);
				if (((absChunk < hptFirstChunk) ||
				     (absChunk > hptLastChunk)) &&
				    ((absChunk < loadAreaFirstChunk) ||
				     (absChunk > loadAreaLastChunk))) {
459 460
					mschunks_map.mapping[nextPhysChunk] =
						absChunk;
L
Linus Torvalds 已提交
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
					++nextPhysChunk;
				}
			}
			++thisChunk;
		}
		++currDword;
		currChunk += 64;
	}

	/*
	 * main store size (in chunks) is
	 *   totalChunks - hptSizeChunks
	 * which should be equal to
	 *   nextPhysChunk
	 */
476
	return chunk_to_addr(nextPhysChunk);
L
Linus Torvalds 已提交
477 478 479 480 481 482 483
}

/*
 * Document me.
 */
static void __init iSeries_setup_arch(void)
{
484
	if (get_lppaca()->shared_proc) {
485
		ppc_md.idle_loop = iseries_shared_idle;
486
		printk(KERN_DEBUG "Using shared processor idle loop\n");
487 488
	} else {
		ppc_md.idle_loop = iseries_dedicated_idle;
489
		printk(KERN_DEBUG "Using dedicated idle loop\n");
490 491
	}

L
Linus Torvalds 已提交
492
	/* Setup the Lp Event Queue */
493
	setup_hvlpevent_queue();
L
Linus Torvalds 已提交
494 495 496 497 498

	printk("Max  logical processors = %d\n",
			itVpdAreas.xSlicMaxLogicalProcs);
	printk("Max physical processors = %d\n",
			itVpdAreas.xSlicMaxPhysicalProcs);
499 500

	iSeries_pcibios_init();
L
Linus Torvalds 已提交
501 502
}

503
static void iSeries_show_cpuinfo(struct seq_file *m)
L
Linus Torvalds 已提交
504 505 506 507 508 509 510
{
	seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n");
}

static void __init iSeries_progress(char * st, unsigned short code)
{
	printk("Progress: [%04x] - %s\n", (unsigned)code, st);
511
	mf_display_progress(code);
L
Linus Torvalds 已提交
512 513 514 515 516 517 518 519 520 521
}

static void __init iSeries_fixup_klimit(void)
{
	/*
	 * Change klimit to take into account any ram disk
	 * that may be included
	 */
	if (naca.xRamDisk)
		klimit = KERNELBASE + (u64)naca.xRamDisk +
522
			(naca.xRamDiskSize * HW_PAGE_SIZE);
L
Linus Torvalds 已提交
523 524 525 526 527
}

static int __init iSeries_src_init(void)
{
        /* clear the progress line */
528 529
	if (firmware_has_feature(FW_FEATURE_ISERIES))
		ppc_md.progress(" ", 0xffff);
L
Linus Torvalds 已提交
530 531 532 533 534
        return 0;
}

late_initcall(iSeries_src_init);

535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
static inline void process_iSeries_events(void)
{
	asm volatile ("li 0,0x5555; sc" : : : "r0", "r3");
}

static void yield_shared_processor(void)
{
	unsigned long tb;

	HvCall_setEnabledInterrupts(HvCall_MaskIPI |
				    HvCall_MaskLpEvent |
				    HvCall_MaskLpProd |
				    HvCall_MaskTimeout);

	tb = get_tb();
	/* Compute future tb value when yield should expire */
	HvCall_yieldProcessor(HvCall_YieldTimed, tb+tb_ticks_per_jiffy);

	/*
	 * The decrementer stops during the yield.  Force a fake decrementer
	 * here and let the timer_interrupt code sort out the actual time.
	 */
557
	get_lppaca()->int_dword.fields.decr_int = 1;
558
	ppc64_runlatch_on();
559 560 561
	process_iSeries_events();
}

P
Paul Mackerras 已提交
562
static void iseries_shared_idle(void)
563
{
564
	while (1) {
565
		tick_nohz_stop_sched_tick(1);
566 567 568 569 570 571 572
		while (!need_resched() && !hvlpevent_is_pending()) {
			local_irq_disable();
			ppc64_runlatch_off();

			/* Recheck with irqs off */
			if (!need_resched() && !hvlpevent_is_pending())
				yield_shared_processor();
573

574 575 576 577 578
			HMT_medium();
			local_irq_enable();
		}

		ppc64_runlatch_on();
579
		tick_nohz_restart_sched_tick();
580

581 582 583
		if (hvlpevent_is_pending())
			process_iSeries_events();

584
		preempt_enable_no_resched();
585
		schedule();
586
		preempt_disable();
587 588 589
	}
}

P
Paul Mackerras 已提交
590
static void iseries_dedicated_idle(void)
591
{
592
	set_thread_flag(TIF_POLLING_NRFLAG);
593 594

	while (1) {
595
		tick_nohz_stop_sched_tick(1);
596
		if (!need_resched()) {
597 598 599 600 601
			while (!need_resched()) {
				ppc64_runlatch_off();
				HMT_low();

				if (hvlpevent_is_pending()) {
602
					HMT_medium();
603 604
					ppc64_runlatch_on();
					process_iSeries_events();
605 606
				}
			}
607 608

			HMT_medium();
609 610 611
		}

		ppc64_runlatch_on();
612
		tick_nohz_restart_sched_tick();
613
		preempt_enable_no_resched();
614
		schedule();
615
		preempt_disable();
616 617 618
	}
}

619
static void __iomem *iseries_ioremap(phys_addr_t address, unsigned long size,
620
				     unsigned long flags, void *caller)
621 622 623 624
{
	return (void __iomem *)address;
}

625
static void iseries_iounmap(volatile void __iomem *token)
626 627 628
{
}

629
static int __init iseries_probe(void)
630
{
631 632
	unsigned long root = of_get_flat_dt_root();
	if (!of_flat_dt_is_compatible(root, "IBM,iSeries"))
633 634
		return 0;

635
	hpte_init_iSeries();
636
	/* iSeries does not support 16M pages */
637
	cur_cpu_spec->mmu_features &= ~MMU_FTR_16M_PAGE;
638

639
	return 1;
640 641
}

642 643 644 645 646 647 648
#ifdef CONFIG_KEXEC
static int iseries_kexec_prepare(struct kimage *image)
{
	return -ENOSYS;
}
#endif

649
define_machine(iseries) {
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
	.name			= "iSeries",
	.setup_arch		= iSeries_setup_arch,
	.show_cpuinfo		= iSeries_show_cpuinfo,
	.init_IRQ		= iSeries_init_IRQ,
	.get_irq		= iSeries_get_irq,
	.init_early		= iSeries_init_early,
	.pcibios_fixup		= iSeries_pci_final_fixup,
	.pcibios_fixup_resources= iSeries_pcibios_fixup_resources,
	.restart		= mf_reboot,
	.power_off		= mf_power_off,
	.halt			= mf_power_off,
	.get_boot_time		= iSeries_get_boot_time,
	.set_rtc_time		= iSeries_set_rtc_time,
	.get_rtc_time		= iSeries_get_rtc_time,
	.calibrate_decr		= generic_calibrate_decr,
	.progress		= iSeries_progress,
	.probe			= iseries_probe,
	.ioremap		= iseries_ioremap,
	.iounmap		= iseries_iounmap,
669 670 671
#ifdef CONFIG_KEXEC
	.machine_kexec_prepare	= iseries_kexec_prepare,
#endif
672 673 674
	/* XXX Implement enable_pmcs for iSeries */
};

675
void * __init iSeries_early_setup(void)
L
Linus Torvalds 已提交
676
{
677 678
	unsigned long phys_mem_size;

679 680 681
	/* Identify CPU type. This is done again by the common code later
	 * on but calling this function multiple times is fine.
	 */
682
	identify_cpu(0, mfspr(SPRN_PVR));
683
	initialise_paca(&boot_paca, 0);
684

685 686 687
	powerpc_firmware_features |= FW_FEATURE_ISERIES;
	powerpc_firmware_features |= FW_FEATURE_LPAR;

L
Linus Torvalds 已提交
688
	iSeries_fixup_klimit();
689

690 691 692 693
	/*
	 * Initialize the table which translate Linux physical addresses to
	 * AS/400 absolute addresses
	 */
694
	phys_mem_size = build_iSeries_Memory_Map();
695

696 697
	iSeries_get_cmdline();

698
	return (void *) __pa(build_flat_dt(phys_mem_size));
L
Linus Torvalds 已提交
699
}
700

701 702 703 704 705 706 707 708 709 710 711 712
static void hvputc(char c)
{
	if (c == '\n')
		hvputc('\r');

	HvCall_writeLogBuffer(&c, 1);
}

void __init udbg_init_iseries(void)
{
	udbg_putc = hvputc;
}