setup.c revision 363737d66427c18edb321a06933ac999d9ce5d7f
1711fa8096863e4b50bb97f9ebc44606dc2182ac3Paul Mundt/* 211c1965687b0a472add948d4240dfe65a2fcb298Paul Mundt * arch/sh/kernel/setup.c 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This file handles the architecture-dependent parts of initialization 511c1965687b0a472add948d4240dfe65a2fcb298Paul Mundt * 611c1965687b0a472add948d4240dfe65a2fcb298Paul Mundt * Copyright (C) 1999 Niibe Yutaka 719d8f84f86af867abee174be8bf1e4941a59143dPaul Mundt * Copyright (C) 2002 - 2010 Paul Mundt 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 9894673ee6122a3ce1958e1fe096901ba5356a96bJon Smirl#include <linux/screen_info.h> 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/ioport.h> 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/init.h> 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/initrd.h> 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/bootmem.h> 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/console.h> 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/root_dev.h> 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/utsname.h> 1701066625e9ae39742c92e21163f7f2a818e02762Paul Mundt#include <linux/nodemask.h> 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/cpu.h> 1922a9835c350782a5c3257343713932af3ac92ee0Dave Hansen#include <linux/pfn.h> 20711fa8096863e4b50bb97f9ebc44606dc2182ac3Paul Mundt#include <linux/fs.h> 2101066625e9ae39742c92e21163f7f2a818e02762Paul Mundt#include <linux/mm.h> 224d5ade5b29c618e97a8988efb6967cb4dd0e2183Paul Mundt#include <linux/kexec.h> 2398d877c487a75af78f74780703aa6b174780788dPaul Mundt#include <linux/module.h> 240016a126accb32f1663eaeba966eb76c98f8929bPaul Mundt#include <linux/smp.h> 25b9e393c2babb8b6956de52fc580b7c23f3629232Paul Mundt#include <linux/err.h> 26daf423db3b6afd90ecdd776dbc32c0b57cc78edbSimon Horman#include <linux/crash_dump.h> 27fa43972fab24a3c050e880a7831f9378c6cebc0bPaul Mundt#include <linux/mmzone.h> 28cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt#include <linux/clk.h> 29cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt#include <linux/delay.h> 3087a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm#include <linux/platform_device.h> 3195f72d1ed41a66f1c1c29c24d479de81a0bea36fYinghai Lu#include <linux/memblock.h> 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/uaccess.h> 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/io.h> 347a302a9674593259866de4a9d5ae8edc03dc1934Paul Mundt#include <asm/page.h> 35cd01204b82933754a7276838656420477f64d4b8Paul Mundt#include <asm/elf.h> 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/sections.h> 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/irq.h> 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/setup.h> 39de02797aa744c96a90f47be7bc081ce2f74b17fdPaul Mundt#include <asm/clock.h> 40c9f4a3f53b5d61f86eae3512abdf948878ca3498Paul Mundt#include <asm/smp.h> 4101066625e9ae39742c92e21163f7f2a818e02762Paul Mundt#include <asm/mmu_context.h> 4219d8f84f86af867abee174be8bf1e4941a59143dPaul Mundt#include <asm/mmzone.h> 439cc1cf380e15f7314f8defb849b8e926d5755f8bPaul Mundt#include <asm/sparsemem.h> 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Initialize loops_per_jiffy as 10000000 (1000MIPS). 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This value will be used at the very early stage of serial setup. 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The bigger value means no problem. 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 502d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundtstruct sh_cpuinfo cpu_data[NR_CPUS] __read_mostly = { 512d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundt [0] = { 522d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundt .type = CPU_SH_NONE, 53e82da214d2fe3dc2610df966100c4f36bc0fad91Paul Mundt .family = CPU_FAMILY_UNKNOWN, 542d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundt .loops_per_jiffy = 10000000, 552f98492c5375e906e48c78d88351f45bb11b6a8aPaul Mundt .phys_bits = MAX_PHYSMEM_BITS, 562d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundt }, 572d4a73d5b91528322631830784f4eb7897fb5e41Paul Mundt}; 582d4a73d5b91528322631830784f4eb7897fb5e41Paul MundtEXPORT_SYMBOL(cpu_data); 5982f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt 6082f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt/* 6182f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt * The machine vector. First entry in .machvec.init, or clobbered by 6282f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt * sh_mv= on the command line, prior to .machvec.init teardown. 6382f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt */ 64fd8f20e8e2f8f1d9201086bff444c8d35f0a6a45Paul Mundtstruct sh_machine_vector sh_mv = { .mv_name = "generic", }; 65971ac16d56301c7150771409607846f9facc2f13Paul MundtEXPORT_SYMBOL(sh_mv); 6682f81f4784479df17a80caff4a7156da0a2f7deaPaul Mundt 672c7834a6f15fe6c50ed4766f1bb6f9183b9e2740Paul Mundt#ifdef CONFIG_VT 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct screen_info screen_info; 692c7834a6f15fe6c50ed4766f1bb6f9183b9e2740Paul Mundt#endif 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int root_mountflags; 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7365463b73b14ed43368dc5961a6c3dcb0d98cfe1fPaul Mundt#define RAMDISK_IMAGE_START_MASK 0x07FF 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RAMDISK_PROMPT_FLAG 0x8000 7565463b73b14ed43368dc5961a6c3dcb0d98cfe1fPaul Mundt#define RAMDISK_LOAD_FLAG 0x4000 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7753c82622c2db808c015953336faecefc0ebf29bcAlon Bar-Levstatic char __initdata command_line[COMMAND_LINE_SIZE] = { 0, }; 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7969d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundtstatic struct resource code_resource = { 8069d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt .name = "Kernel code", 8169d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 8269d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt}; 8369d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt 8469d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundtstatic struct resource data_resource = { 8569d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt .name = "Kernel data", 8669d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 8769d1ef4caf77da7164d3e392bf0a8057b42cf26ePaul Mundt}; 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 893d83984e99d80672b1d2e3c7dfdd393631883428Magnus Dammstatic struct resource bss_resource = { 903d83984e99d80672b1d2e3c7dfdd393631883428Magnus Damm .name = "Kernel bss", 913d83984e99d80672b1d2e3c7dfdd393631883428Magnus Damm .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 923d83984e99d80672b1d2e3c7dfdd393631883428Magnus Damm}; 933d83984e99d80672b1d2e3c7dfdd393631883428Magnus Damm 9498d877c487a75af78f74780703aa6b174780788dPaul Mundtunsigned long memory_start; 9598d877c487a75af78f74780703aa6b174780788dPaul MundtEXPORT_SYMBOL(memory_start); 967e5186eaae8eebc0101d539791dbff92256455eePaul Mundtunsigned long memory_end = 0; 9798d877c487a75af78f74780703aa6b174780788dPaul MundtEXPORT_SYMBOL(memory_end); 985e2ff328c0668794ff408a4632f5b8a62827571fPaul Mundtunsigned long memory_limit = 0; 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1000146ba78b9339c27ed12545f9bdc208604354bb3Magnus Dammstatic struct resource mem_resources[MAX_NUMNODES]; 1010146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm 102cd01204b82933754a7276838656420477f64d4b8Paul Mundtint l1i_cache_shape, l1d_cache_shape, l2_cache_shape; 103cd01204b82933754a7276838656420477f64d4b8Paul Mundt 1049655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundtstatic int __init early_parse_mem(char *p) 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1065e2ff328c0668794ff408a4632f5b8a62827571fPaul Mundt if (!p) 1075e2ff328c0668794ff408a4632f5b8a62827571fPaul Mundt return 1; 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1095e2ff328c0668794ff408a4632f5b8a62827571fPaul Mundt memory_limit = PAGE_ALIGN(memparse(p, &p)); 11080a68a43d90e2221599b507b6b26c3cba1957687Stuart Menefy 1115e2ff328c0668794ff408a4632f5b8a62827571fPaul Mundt pr_notice("Memory limited to %ldMB\n", memory_limit >> 20); 1122c7834a6f15fe6c50ed4766f1bb6f9183b9e2740Paul Mundt 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1159655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundtearly_param("mem", early_parse_mem); 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1174bc277ac9cae60e11fe2e557e4ea4acb56d3dc9aPaul Mundtvoid __init check_for_initrd(void) 1189b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt{ 1199b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt#ifdef CONFIG_BLK_DEV_INITRD 1209b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt unsigned long start, end; 1219b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1229b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt /* 1239b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt * Check for the rare cases where boot loaders adhere to the boot 1249b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt * ABI. 1259b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt */ 1269b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt if (!LOADER_TYPE || !INITRD_START || !INITRD_SIZE) 1279b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt goto disable; 1289b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1299b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt start = INITRD_START + __MEMORY_START; 1309b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt end = start + INITRD_SIZE; 1319b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1329b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt if (unlikely(end <= start)) 1339b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt goto disable; 1349b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt if (unlikely(start & ~PAGE_MASK)) { 1359b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt pr_err("initrd must be page aligned\n"); 1369b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt goto disable; 1379b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt } 1389b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 139901c28c257eb8903a7d66c900df163e2c13ca995Nobuhiro Iwamatsu if (unlikely(start < __MEMORY_START)) { 140901c28c257eb8903a7d66c900df163e2c13ca995Nobuhiro Iwamatsu pr_err("initrd start (%08lx) < __MEMORY_START(%x)\n", 141901c28c257eb8903a7d66c900df163e2c13ca995Nobuhiro Iwamatsu start, __MEMORY_START); 1429b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt goto disable; 1439b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt } 1449b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 14595f72d1ed41a66f1c1c29c24d479de81a0bea36fYinghai Lu if (unlikely(end > memblock_end_of_DRAM())) { 1469b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt pr_err("initrd extends beyond end of memory " 1479b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt "(0x%08lx > 0x%08lx)\ndisabling initrd\n", 14895f72d1ed41a66f1c1c29c24d479de81a0bea36fYinghai Lu end, (unsigned long)memblock_end_of_DRAM()); 1499b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt goto disable; 1509b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt } 1519b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1529b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt /* 15325985edcedea6396277003854657b5f3cb31a628Lucas De Marchi * If we got this far in spite of the boot loader's best efforts 1549b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt * to the contrary, assume we actually have a valid initrd and 1559b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt * fix up the root dev. 1569b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt */ 1579b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt ROOT_DEV = Root_RAM0; 1589b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1599b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt /* 1609b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt * Address sanitization 1619b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt */ 162901c28c257eb8903a7d66c900df163e2c13ca995Nobuhiro Iwamatsu initrd_start = (unsigned long)__va(start); 1639b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt initrd_end = initrd_start + INITRD_SIZE; 1649b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 16595f72d1ed41a66f1c1c29c24d479de81a0bea36fYinghai Lu memblock_reserve(__pa(initrd_start), INITRD_SIZE); 1669b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1679b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt return; 1689b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 1699b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundtdisable: 1709b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt pr_info("initrd disabled\n"); 1719b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt initrd_start = initrd_end = 0; 1729b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt#endif 1739b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt} 1749b7a37853a8cd69829eb1d9715a6c09aae01eeecPaul Mundt 175cf204fa797cf968de8043491cd469ad0321d0940Paul Mundtvoid __cpuinit calibrate_delay(void) 176cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt{ 177cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt struct clk *clk = clk_get(NULL, "cpu_clk"); 178cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt 179cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt if (IS_ERR(clk)) 180cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt panic("Need a sane CPU clock definition!"); 181cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt 182cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt loops_per_jiffy = (clk_get_rate(clk) >> 1) / HZ; 183cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt 184cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt printk(KERN_INFO "Calibrating delay loop (skipped)... " 185cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt "%lu.%02lu BogoMIPS PRESET (lpj=%lu)\n", 186cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt loops_per_jiffy/(500000/HZ), 187cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt (loops_per_jiffy/(5000/HZ)) % 100, 188cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt loops_per_jiffy); 189cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt} 190cf204fa797cf968de8043491cd469ad0321d0940Paul Mundt 1910146ba78b9339c27ed12545f9bdc208604354bb3Magnus Dammvoid __init __add_active_range(unsigned int nid, unsigned long start_pfn, 1920146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm unsigned long end_pfn) 1930146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm{ 1940146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm struct resource *res = &mem_resources[nid]; 19521823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt unsigned long start, end; 1960146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm 1970146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm WARN_ON(res->name); /* max one active range per node for now */ 1980146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm 19921823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt start = start_pfn << PAGE_SHIFT; 20021823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt end = end_pfn << PAGE_SHIFT; 20121823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt 2020146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm res->name = "System RAM"; 20321823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt res->start = start; 20421823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt res->end = end - 1; 2050146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 20621823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt 2070146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm if (request_resource(&iomem_resource, res)) { 2080146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm pr_err("unable to request memory_resource 0x%lx 0x%lx\n", 2090146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm start_pfn, end_pfn); 2100146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm return; 2110146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm } 2120146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm 2130146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm /* 21441309b7a22805f1650c600723d729af453d52719Simon Horman * We don't know which RAM region contains kernel data or 21541309b7a22805f1650c600723d729af453d52719Simon Horman * the reserved crashkernel region, so try it repeatedly 21641309b7a22805f1650c600723d729af453d52719Simon Horman * and let the resource manager test it. 2170146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm */ 2180146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm request_resource(res, &code_resource); 2190146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm request_resource(res, &data_resource); 2200146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm request_resource(res, &bss_resource); 22141309b7a22805f1650c600723d729af453d52719Simon Horman#ifdef CONFIG_KEXEC 22241309b7a22805f1650c600723d729af453d52719Simon Horman request_resource(res, &crashk_res); 22341309b7a22805f1650c600723d729af453d52719Simon Horman#endif 2240146ba78b9339c27ed12545f9bdc208604354bb3Magnus Damm 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 22621823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt * Also make sure that there is a PMB mapping that covers this 22721823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt * range before we attempt to activate it, to avoid reset by MMU. 22821823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt * We can hit this path with NUMA or memory hot-add. 2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 23021823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt pmb_bolt_mapping((unsigned long)__va(start), start, end - start, 23121823259a70b7a2a21eea1d48c25a6f38896dd11Paul Mundt PAGE_KERNEL); 232c601a51af10f714292f42eab45fa8c9154dc1414Matt Fleming 233534cfbee295222e188c391db5187ca9a6ab0c035Tejun Heo memblock_set_node(PFN_PHYS(start_pfn), 234534cfbee295222e188c391db5187ca9a6ab0c035Tejun Heo PFN_PHYS(end_pfn - start_pfn), nid); 23501066625e9ae39742c92e21163f7f2a818e02762Paul Mundt} 23601066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 23719d8f84f86af867abee174be8bf1e4941a59143dPaul Mundtvoid __init __weak plat_early_device_setup(void) 23887a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm{ 23987a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm} 24087a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm 24101066625e9ae39742c92e21163f7f2a818e02762Paul Mundtvoid __init setup_arch(char **cmdline_p) 24201066625e9ae39742c92e21163f7f2a818e02762Paul Mundt{ 24301066625e9ae39742c92e21163f7f2a818e02762Paul Mundt enable_mmu(); 24401066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 24501066625e9ae39742c92e21163f7f2a818e02762Paul Mundt ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); 24601066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 2470105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt printk(KERN_NOTICE "Boot params:\n" 2480105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... MOUNT_ROOT_RDONLY - %08lx\n" 2490105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... RAMDISK_FLAGS - %08lx\n" 2500105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... ORIG_ROOT_DEV - %08lx\n" 2510105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... LOADER_TYPE - %08lx\n" 2520105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... INITRD_START - %08lx\n" 2530105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt "... INITRD_SIZE - %08lx\n", 2540105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt MOUNT_ROOT_RDONLY, RAMDISK_FLAGS, 2550105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt ORIG_ROOT_DEV, LOADER_TYPE, 2560105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt INITRD_START, INITRD_SIZE); 2570105346cc763a6e34e80feb6adb36ed9781150d4Paul Mundt 25801066625e9ae39742c92e21163f7f2a818e02762Paul Mundt#ifdef CONFIG_BLK_DEV_RAM 25901066625e9ae39742c92e21163f7f2a818e02762Paul Mundt rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; 26001066625e9ae39742c92e21163f7f2a818e02762Paul Mundt rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); 26101066625e9ae39742c92e21163f7f2a818e02762Paul Mundt rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); 26201066625e9ae39742c92e21163f7f2a818e02762Paul Mundt#endif 26301066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 26401066625e9ae39742c92e21163f7f2a818e02762Paul Mundt if (!MOUNT_ROOT_RDONLY) 26501066625e9ae39742c92e21163f7f2a818e02762Paul Mundt root_mountflags &= ~MS_RDONLY; 26601066625e9ae39742c92e21163f7f2a818e02762Paul Mundt init_mm.start_code = (unsigned long) _text; 26701066625e9ae39742c92e21163f7f2a818e02762Paul Mundt init_mm.end_code = (unsigned long) _etext; 26801066625e9ae39742c92e21163f7f2a818e02762Paul Mundt init_mm.end_data = (unsigned long) _edata; 26901066625e9ae39742c92e21163f7f2a818e02762Paul Mundt init_mm.brk = (unsigned long) _end; 27001066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 27101066625e9ae39742c92e21163f7f2a818e02762Paul Mundt code_resource.start = virt_to_phys(_text); 27201066625e9ae39742c92e21163f7f2a818e02762Paul Mundt code_resource.end = virt_to_phys(_etext)-1; 27301066625e9ae39742c92e21163f7f2a818e02762Paul Mundt data_resource.start = virt_to_phys(_etext); 27401066625e9ae39742c92e21163f7f2a818e02762Paul Mundt data_resource.end = virt_to_phys(_edata)-1; 2753d83984e99d80672b1d2e3c7dfdd393631883428Magnus Damm bss_resource.start = virt_to_phys(__bss_start); 276363737d66427c18edb321a06933ac999d9ce5d7fGeert Uytterhoeven bss_resource.end = virt_to_phys(__bss_stop)-1; 27701066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 278d724a9c9d572e092d1ce820463f082697487b874Pawel Moll#ifdef CONFIG_CMDLINE_OVERWRITE 279ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line)); 280ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt#else 281ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt strlcpy(command_line, COMMAND_LINE, sizeof(command_line)); 282d724a9c9d572e092d1ce820463f082697487b874Pawel Moll#ifdef CONFIG_CMDLINE_EXTEND 283d724a9c9d572e092d1ce820463f082697487b874Pawel Moll strlcat(command_line, " ", sizeof(command_line)); 284d724a9c9d572e092d1ce820463f082697487b874Pawel Moll strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line)); 285d724a9c9d572e092d1ce820463f082697487b874Pawel Moll#endif 286ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt#endif 2879655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundt 288ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt /* Save unparsed command line copy for /proc/cmdline */ 289ba36197cf4ff68f631bb1b3d4cc442d567279fe3Paul Mundt memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); 2909655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundt *cmdline_p = command_line; 2919655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundt 29201066625e9ae39742c92e21163f7f2a818e02762Paul Mundt parse_early_param(); 29301066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 29487a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm plat_early_device_setup(); 29587a00dc059e3af46303f1f56b0e8df41af988c7bMagnus Damm 2969655ad03af2d232c3b26e7562ab4f8c29b107e49Paul Mundt sh_mv_setup(); 29701066625e9ae39742c92e21163f7f2a818e02762Paul Mundt 2984bc277ac9cae60e11fe2e557e4ea4acb56d3dc9aPaul Mundt /* Let earlyprintk output early console messages */ 2994bc277ac9cae60e11fe2e557e4ea4acb56d3dc9aPaul Mundt early_platform_driver_probe("earlyprintk", 1, 1); 300dfbb9042801eaeb4df9015bb86224291a39a0f52Paul Mundt 3014bc277ac9cae60e11fe2e557e4ea4acb56d3dc9aPaul Mundt paging_init(); 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_DUMMY_CONSOLE 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds conswitchp = &dummy_con; 3051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Perform the machine specific initialisation */ 3082c7834a6f15fe6c50ed4766f1bb6f9183b9e2740Paul Mundt if (likely(sh_mv.mv_setup)) 3092c7834a6f15fe6c50ed4766f1bb6f9183b9e2740Paul Mundt sh_mv.mv_setup(cmdline_p); 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3110016a126accb32f1663eaeba966eb76c98f8929bPaul Mundt plat_smp_setup(); 312dfbb9042801eaeb4df9015bb86224291a39a0f52Paul Mundt} 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 314eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm/* processor boot mode configuration */ 315eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Dammint generic_mode_pins(void) 316eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm{ 317eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm pr_warning("generic_mode_pins(): missing mode pin configuration\n"); 318eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm return 0; 319eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm} 320eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm 321eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Dammint test_mode_pin(int pin) 322eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm{ 3230d4fdbb64f472ef31195714993f1263f77cf85caMagnus Damm return sh_mv.mv_mode_pins() & pin; 324eb9b9b56eed280e65a9e194aaeb50a5a75111859Magnus Damm} 325