setup.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2004-2007 Cavium Networks
  7. * Copyright (C) 2008, 2009 Wind River Systems
  8. * written by Ralf Baechle <ralf@linux-mips.org>
  9. */
  10. #include <linux/compiler.h>
  11. #include <linux/vmalloc.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/console.h>
  15. #include <linux/delay.h>
  16. #include <linux/export.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/io.h>
  19. #include <linux/serial.h>
  20. #include <linux/smp.h>
  21. #include <linux/types.h>
  22. #include <linux/string.h> /* for memset */
  23. #include <linux/tty.h>
  24. #include <linux/time.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/serial_core.h>
  27. #include <linux/serial_8250.h>
  28. #include <linux/of_fdt.h>
  29. #include <linux/libfdt.h>
  30. #include <linux/kexec.h>
  31. #include <asm/processor.h>
  32. #include <asm/reboot.h>
  33. #include <asm/smp-ops.h>
  34. #include <asm/irq_cpu.h>
  35. #include <asm/mipsregs.h>
  36. #include <asm/bootinfo.h>
  37. #include <asm/sections.h>
  38. #include <asm/time.h>
  39. #include <asm/octeon/octeon.h>
  40. #include <asm/octeon/pci-octeon.h>
  41. #include <asm/octeon/cvmx-mio-defs.h>
  42. extern struct plat_smp_ops octeon_smp_ops;
  43. #ifdef CONFIG_PCI
  44. extern void pci_console_init(const char *arg);
  45. #endif
  46. static unsigned long long MAX_MEMORY = 512ull << 20;
  47. struct octeon_boot_descriptor *octeon_boot_desc_ptr;
  48. struct cvmx_bootinfo *octeon_bootinfo;
  49. EXPORT_SYMBOL(octeon_bootinfo);
  50. static unsigned long long RESERVE_LOW_MEM = 0ull;
  51. #ifdef CONFIG_KEXEC
  52. #ifdef CONFIG_SMP
  53. /*
  54. * Wait for relocation code is prepared and send
  55. * secondary CPUs to spin until kernel is relocated.
  56. */
  57. static void octeon_kexec_smp_down(void *ignored)
  58. {
  59. int cpu = smp_processor_id();
  60. local_irq_disable();
  61. set_cpu_online(cpu, false);
  62. while (!atomic_read(&kexec_ready_to_reboot))
  63. cpu_relax();
  64. asm volatile (
  65. " sync \n"
  66. " synci ($0) \n");
  67. relocated_kexec_smp_wait(NULL);
  68. }
  69. #endif
  70. #define OCTEON_DDR0_BASE (0x0ULL)
  71. #define OCTEON_DDR0_SIZE (0x010000000ULL)
  72. #define OCTEON_DDR1_BASE (0x410000000ULL)
  73. #define OCTEON_DDR1_SIZE (0x010000000ULL)
  74. #define OCTEON_DDR2_BASE (0x020000000ULL)
  75. #define OCTEON_DDR2_SIZE (0x3e0000000ULL)
  76. #define OCTEON_MAX_PHY_MEM_SIZE (16*1024*1024*1024ULL)
  77. static struct kimage *kimage_ptr;
  78. static void kexec_bootmem_init(uint64_t mem_size, uint32_t low_reserved_bytes)
  79. {
  80. int64_t addr;
  81. struct cvmx_bootmem_desc *bootmem_desc;
  82. bootmem_desc = cvmx_bootmem_get_desc();
  83. if (mem_size > OCTEON_MAX_PHY_MEM_SIZE) {
  84. mem_size = OCTEON_MAX_PHY_MEM_SIZE;
  85. pr_err("Error: requested memory too large,"
  86. "truncating to maximum size\n");
  87. }
  88. bootmem_desc->major_version = CVMX_BOOTMEM_DESC_MAJ_VER;
  89. bootmem_desc->minor_version = CVMX_BOOTMEM_DESC_MIN_VER;
  90. addr = (OCTEON_DDR0_BASE + RESERVE_LOW_MEM + low_reserved_bytes);
  91. bootmem_desc->head_addr = 0;
  92. if (mem_size <= OCTEON_DDR0_SIZE) {
  93. __cvmx_bootmem_phy_free(addr,
  94. mem_size - RESERVE_LOW_MEM -
  95. low_reserved_bytes, 0);
  96. return;
  97. }
  98. __cvmx_bootmem_phy_free(addr,
  99. OCTEON_DDR0_SIZE - RESERVE_LOW_MEM -
  100. low_reserved_bytes, 0);
  101. mem_size -= OCTEON_DDR0_SIZE;
  102. if (mem_size > OCTEON_DDR1_SIZE) {
  103. __cvmx_bootmem_phy_free(OCTEON_DDR1_BASE, OCTEON_DDR1_SIZE, 0);
  104. __cvmx_bootmem_phy_free(OCTEON_DDR2_BASE,
  105. mem_size - OCTEON_DDR1_SIZE, 0);
  106. } else
  107. __cvmx_bootmem_phy_free(OCTEON_DDR1_BASE, mem_size, 0);
  108. }
  109. static int octeon_kexec_prepare(struct kimage *image)
  110. {
  111. int i;
  112. char *bootloader = "kexec";
  113. octeon_boot_desc_ptr->argc = 0;
  114. for (i = 0; i < image->nr_segments; i++) {
  115. if (!strncmp(bootloader, (char *)image->segment[i].buf,
  116. strlen(bootloader))) {
  117. /*
  118. * convert command line string to array
  119. * of parameters (as bootloader does).
  120. */
  121. int argc = 0, offt;
  122. char *str = (char *)image->segment[i].buf;
  123. char *ptr = strchr(str, ' ');
  124. while (ptr && (OCTEON_ARGV_MAX_ARGS > argc)) {
  125. *ptr = '\0';
  126. if (ptr[1] != ' ') {
  127. offt = (int)(ptr - str + 1);
  128. octeon_boot_desc_ptr->argv[argc] =
  129. image->segment[i].mem + offt;
  130. argc++;
  131. }
  132. ptr = strchr(ptr + 1, ' ');
  133. }
  134. octeon_boot_desc_ptr->argc = argc;
  135. break;
  136. }
  137. }
  138. /*
  139. * Information about segments will be needed during pre-boot memory
  140. * initialization.
  141. */
  142. kimage_ptr = image;
  143. return 0;
  144. }
  145. static void octeon_generic_shutdown(void)
  146. {
  147. int i;
  148. #ifdef CONFIG_SMP
  149. int cpu;
  150. #endif
  151. struct cvmx_bootmem_desc *bootmem_desc;
  152. void *named_block_array_ptr;
  153. bootmem_desc = cvmx_bootmem_get_desc();
  154. named_block_array_ptr =
  155. cvmx_phys_to_ptr(bootmem_desc->named_block_array_addr);
  156. #ifdef CONFIG_SMP
  157. /* disable watchdogs */
  158. for_each_online_cpu(cpu)
  159. cvmx_write_csr(CVMX_CIU_WDOGX(cpu_logical_map(cpu)), 0);
  160. #else
  161. cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
  162. #endif
  163. if (kimage_ptr != kexec_crash_image) {
  164. memset(named_block_array_ptr,
  165. 0x0,
  166. CVMX_BOOTMEM_NUM_NAMED_BLOCKS *
  167. sizeof(struct cvmx_bootmem_named_block_desc));
  168. /*
  169. * Mark all memory (except low 0x100000 bytes) as free.
  170. * It is the same thing that bootloader does.
  171. */
  172. kexec_bootmem_init(octeon_bootinfo->dram_size*1024ULL*1024ULL,
  173. 0x100000);
  174. /*
  175. * Allocate all segments to avoid their corruption during boot.
  176. */
  177. for (i = 0; i < kimage_ptr->nr_segments; i++)
  178. cvmx_bootmem_alloc_address(
  179. kimage_ptr->segment[i].memsz + 2*PAGE_SIZE,
  180. kimage_ptr->segment[i].mem - PAGE_SIZE,
  181. PAGE_SIZE);
  182. } else {
  183. /*
  184. * Do not mark all memory as free. Free only named sections
  185. * leaving the rest of memory unchanged.
  186. */
  187. struct cvmx_bootmem_named_block_desc *ptr =
  188. (struct cvmx_bootmem_named_block_desc *)
  189. named_block_array_ptr;
  190. for (i = 0; i < bootmem_desc->named_block_num_blocks; i++)
  191. if (ptr[i].size)
  192. cvmx_bootmem_free_named(ptr[i].name);
  193. }
  194. kexec_args[2] = 1UL; /* running on octeon_main_processor */
  195. kexec_args[3] = (unsigned long)octeon_boot_desc_ptr;
  196. #ifdef CONFIG_SMP
  197. secondary_kexec_args[2] = 0UL; /* running on secondary cpu */
  198. secondary_kexec_args[3] = (unsigned long)octeon_boot_desc_ptr;
  199. #endif
  200. }
  201. static void octeon_shutdown(void)
  202. {
  203. octeon_generic_shutdown();
  204. #ifdef CONFIG_SMP
  205. smp_call_function(octeon_kexec_smp_down, NULL, 0);
  206. smp_wmb();
  207. while (num_online_cpus() > 1) {
  208. cpu_relax();
  209. mdelay(1);
  210. }
  211. #endif
  212. }
  213. static void octeon_crash_shutdown(struct pt_regs *regs)
  214. {
  215. octeon_generic_shutdown();
  216. default_machine_crash_shutdown(regs);
  217. }
  218. #endif /* CONFIG_KEXEC */
  219. #ifdef CONFIG_CAVIUM_RESERVE32
  220. uint64_t octeon_reserve32_memory;
  221. EXPORT_SYMBOL(octeon_reserve32_memory);
  222. #endif
  223. #ifdef CONFIG_KEXEC
  224. /* crashkernel cmdline parameter is parsed _after_ memory setup
  225. * we also parse it here (workaround for EHB5200) */
  226. static uint64_t crashk_size, crashk_base;
  227. #endif
  228. static int octeon_uart;
  229. extern asmlinkage void handle_int(void);
  230. extern asmlinkage void plat_irq_dispatch(void);
  231. /**
  232. * Return non zero if we are currently running in the Octeon simulator
  233. *
  234. * Returns
  235. */
  236. int octeon_is_simulation(void)
  237. {
  238. return octeon_bootinfo->board_type == CVMX_BOARD_TYPE_SIM;
  239. }
  240. EXPORT_SYMBOL(octeon_is_simulation);
  241. /**
  242. * Return true if Octeon is in PCI Host mode. This means
  243. * Linux can control the PCI bus.
  244. *
  245. * Returns Non zero if Octeon in host mode.
  246. */
  247. int octeon_is_pci_host(void)
  248. {
  249. #ifdef CONFIG_PCI
  250. return octeon_bootinfo->config_flags & CVMX_BOOTINFO_CFG_FLAG_PCI_HOST;
  251. #else
  252. return 0;
  253. #endif
  254. }
  255. /**
  256. * Get the clock rate of Octeon
  257. *
  258. * Returns Clock rate in HZ
  259. */
  260. uint64_t octeon_get_clock_rate(void)
  261. {
  262. struct cvmx_sysinfo *sysinfo = cvmx_sysinfo_get();
  263. return sysinfo->cpu_clock_hz;
  264. }
  265. EXPORT_SYMBOL(octeon_get_clock_rate);
  266. static u64 octeon_io_clock_rate;
  267. u64 octeon_get_io_clock_rate(void)
  268. {
  269. return octeon_io_clock_rate;
  270. }
  271. EXPORT_SYMBOL(octeon_get_io_clock_rate);
  272. /**
  273. * Write to the LCD display connected to the bootbus. This display
  274. * exists on most Cavium evaluation boards. If it doesn't exist, then
  275. * this function doesn't do anything.
  276. *
  277. * @s: String to write
  278. */
  279. void octeon_write_lcd(const char *s)
  280. {
  281. if (octeon_bootinfo->led_display_base_addr) {
  282. void __iomem *lcd_address =
  283. ioremap_nocache(octeon_bootinfo->led_display_base_addr,
  284. 8);
  285. int i;
  286. for (i = 0; i < 8; i++, s++) {
  287. if (*s)
  288. iowrite8(*s, lcd_address + i);
  289. else
  290. iowrite8(' ', lcd_address + i);
  291. }
  292. iounmap(lcd_address);
  293. }
  294. }
  295. /**
  296. * Return the console uart passed by the bootloader
  297. *
  298. * Returns uart (0 or 1)
  299. */
  300. int octeon_get_boot_uart(void)
  301. {
  302. int uart;
  303. #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
  304. uart = 1;
  305. #else
  306. uart = (octeon_boot_desc_ptr->flags & OCTEON_BL_FLAG_CONSOLE_UART1) ?
  307. 1 : 0;
  308. #endif
  309. return uart;
  310. }
  311. /**
  312. * Get the coremask Linux was booted on.
  313. *
  314. * Returns Core mask
  315. */
  316. int octeon_get_boot_coremask(void)
  317. {
  318. return octeon_boot_desc_ptr->core_mask;
  319. }
  320. /**
  321. * Check the hardware BIST results for a CPU
  322. */
  323. void octeon_check_cpu_bist(void)
  324. {
  325. const int coreid = cvmx_get_core_num();
  326. unsigned long long mask;
  327. unsigned long long bist_val;
  328. /* Check BIST results for COP0 registers */
  329. mask = 0x1f00000000ull;
  330. bist_val = read_octeon_c0_icacheerr();
  331. if (bist_val & mask)
  332. pr_err("Core%d BIST Failure: CacheErr(icache) = 0x%llx\n",
  333. coreid, bist_val);
  334. bist_val = read_octeon_c0_dcacheerr();
  335. if (bist_val & 1)
  336. pr_err("Core%d L1 Dcache parity error: "
  337. "CacheErr(dcache) = 0x%llx\n",
  338. coreid, bist_val);
  339. mask = 0xfc00000000000000ull;
  340. bist_val = read_c0_cvmmemctl();
  341. if (bist_val & mask)
  342. pr_err("Core%d BIST Failure: COP0_CVM_MEM_CTL = 0x%llx\n",
  343. coreid, bist_val);
  344. write_octeon_c0_dcacheerr(0);
  345. }
  346. /**
  347. * Reboot Octeon
  348. *
  349. * @command: Command to pass to the bootloader. Currently ignored.
  350. */
  351. static void octeon_restart(char *command)
  352. {
  353. /* Disable all watchdogs before soft reset. They don't get cleared */
  354. #ifdef CONFIG_SMP
  355. int cpu;
  356. for_each_online_cpu(cpu)
  357. cvmx_write_csr(CVMX_CIU_WDOGX(cpu_logical_map(cpu)), 0);
  358. #else
  359. cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
  360. #endif
  361. mb();
  362. while (1)
  363. cvmx_write_csr(CVMX_CIU_SOFT_RST, 1);
  364. }
  365. /**
  366. * Permanently stop a core.
  367. *
  368. * @arg: Ignored.
  369. */
  370. static void octeon_kill_core(void *arg)
  371. {
  372. if (octeon_is_simulation())
  373. /* A break instruction causes the simulator stop a core */
  374. asm volatile ("break" ::: "memory");
  375. local_irq_disable();
  376. /* Disable watchdog on this core. */
  377. cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
  378. /* Spin in a low power mode. */
  379. while (true)
  380. asm volatile ("wait" ::: "memory");
  381. }
  382. /**
  383. * Halt the system
  384. */
  385. static void octeon_halt(void)
  386. {
  387. smp_call_function(octeon_kill_core, NULL, 0);
  388. switch (octeon_bootinfo->board_type) {
  389. case CVMX_BOARD_TYPE_NAO38:
  390. /* Driving a 1 to GPIO 12 shuts off this board */
  391. cvmx_write_csr(CVMX_GPIO_BIT_CFGX(12), 1);
  392. cvmx_write_csr(CVMX_GPIO_TX_SET, 0x1000);
  393. break;
  394. default:
  395. octeon_write_lcd("PowerOff");
  396. break;
  397. }
  398. octeon_kill_core(NULL);
  399. }
  400. /**
  401. * Return a string representing the system type
  402. *
  403. * Returns
  404. */
  405. const char *octeon_board_type_string(void)
  406. {
  407. static char name[80];
  408. sprintf(name, "%s (%s)",
  409. cvmx_board_type_to_string(octeon_bootinfo->board_type),
  410. octeon_model_get_string(read_c0_prid()));
  411. return name;
  412. }
  413. const char *get_system_type(void)
  414. __attribute__ ((alias("octeon_board_type_string")));
  415. void octeon_user_io_init(void)
  416. {
  417. union octeon_cvmemctl cvmmemctl;
  418. union cvmx_iob_fau_timeout fau_timeout;
  419. union cvmx_pow_nw_tim nm_tim;
  420. /* Get the current settings for CP0_CVMMEMCTL_REG */
  421. cvmmemctl.u64 = read_c0_cvmmemctl();
  422. /* R/W If set, marked write-buffer entries time out the same
  423. * as as other entries; if clear, marked write-buffer entries
  424. * use the maximum timeout. */
  425. cvmmemctl.s.dismarkwblongto = 1;
  426. /* R/W If set, a merged store does not clear the write-buffer
  427. * entry timeout state. */
  428. cvmmemctl.s.dismrgclrwbto = 0;
  429. /* R/W Two bits that are the MSBs of the resultant CVMSEG LM
  430. * word location for an IOBDMA. The other 8 bits come from the
  431. * SCRADDR field of the IOBDMA. */
  432. cvmmemctl.s.iobdmascrmsb = 0;
  433. /* R/W If set, SYNCWS and SYNCS only order marked stores; if
  434. * clear, SYNCWS and SYNCS only order unmarked
  435. * stores. SYNCWSMARKED has no effect when DISSYNCWS is
  436. * set. */
  437. cvmmemctl.s.syncwsmarked = 0;
  438. /* R/W If set, SYNCWS acts as SYNCW and SYNCS acts as SYNC. */
  439. cvmmemctl.s.dissyncws = 0;
  440. /* R/W If set, no stall happens on write buffer full. */
  441. if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2))
  442. cvmmemctl.s.diswbfst = 1;
  443. else
  444. cvmmemctl.s.diswbfst = 0;
  445. /* R/W If set (and SX set), supervisor-level loads/stores can
  446. * use XKPHYS addresses with <48>==0 */
  447. cvmmemctl.s.xkmemenas = 0;
  448. /* R/W If set (and UX set), user-level loads/stores can use
  449. * XKPHYS addresses with VA<48>==0 */
  450. cvmmemctl.s.xkmemenau = 0;
  451. /* R/W If set (and SX set), supervisor-level loads/stores can
  452. * use XKPHYS addresses with VA<48>==1 */
  453. cvmmemctl.s.xkioenas = 0;
  454. /* R/W If set (and UX set), user-level loads/stores can use
  455. * XKPHYS addresses with VA<48>==1 */
  456. cvmmemctl.s.xkioenau = 0;
  457. /* R/W If set, all stores act as SYNCW (NOMERGE must be set
  458. * when this is set) RW, reset to 0. */
  459. cvmmemctl.s.allsyncw = 0;
  460. /* R/W If set, no stores merge, and all stores reach the
  461. * coherent bus in order. */
  462. cvmmemctl.s.nomerge = 0;
  463. /* R/W Selects the bit in the counter used for DID time-outs 0
  464. * = 231, 1 = 230, 2 = 229, 3 = 214. Actual time-out is
  465. * between 1x and 2x this interval. For example, with
  466. * DIDTTO=3, expiration interval is between 16K and 32K. */
  467. cvmmemctl.s.didtto = 0;
  468. /* R/W If set, the (mem) CSR clock never turns off. */
  469. cvmmemctl.s.csrckalwys = 0;
  470. /* R/W If set, mclk never turns off. */
  471. cvmmemctl.s.mclkalwys = 0;
  472. /* R/W Selects the bit in the counter used for write buffer
  473. * flush time-outs (WBFLT+11) is the bit position in an
  474. * internal counter used to determine expiration. The write
  475. * buffer expires between 1x and 2x this interval. For
  476. * example, with WBFLT = 0, a write buffer expires between 2K
  477. * and 4K cycles after the write buffer entry is allocated. */
  478. cvmmemctl.s.wbfltime = 0;
  479. /* R/W If set, do not put Istream in the L2 cache. */
  480. cvmmemctl.s.istrnol2 = 0;
  481. /*
  482. * R/W The write buffer threshold. As per erratum Core-14752
  483. * for CN63XX, a sc/scd might fail if the write buffer is
  484. * full. Lowering WBTHRESH greatly lowers the chances of the
  485. * write buffer ever being full and triggering the erratum.
  486. */
  487. if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X))
  488. cvmmemctl.s.wbthresh = 4;
  489. else
  490. cvmmemctl.s.wbthresh = 10;
  491. /* R/W If set, CVMSEG is available for loads/stores in
  492. * kernel/debug mode. */
  493. #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
  494. cvmmemctl.s.cvmsegenak = 1;
  495. #else
  496. cvmmemctl.s.cvmsegenak = 0;
  497. #endif
  498. /* R/W If set, CVMSEG is available for loads/stores in
  499. * supervisor mode. */
  500. cvmmemctl.s.cvmsegenas = 0;
  501. /* R/W If set, CVMSEG is available for loads/stores in user
  502. * mode. */
  503. cvmmemctl.s.cvmsegenau = 0;
  504. /* R/W Size of local memory in cache blocks, 54 (6912 bytes)
  505. * is max legal value. */
  506. cvmmemctl.s.lmemsz = CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE;
  507. write_c0_cvmmemctl(cvmmemctl.u64);
  508. if (smp_processor_id() == 0)
  509. pr_notice("CVMSEG size: %d cache lines (%d bytes)\n",
  510. CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE,
  511. CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE * 128);
  512. /* Set a default for the hardware timeouts */
  513. fau_timeout.u64 = 0;
  514. fau_timeout.s.tout_val = 0xfff;
  515. /* Disable tagwait FAU timeout */
  516. fau_timeout.s.tout_enb = 0;
  517. cvmx_write_csr(CVMX_IOB_FAU_TIMEOUT, fau_timeout.u64);
  518. nm_tim.u64 = 0;
  519. /* 4096 cycles */
  520. nm_tim.s.nw_tim = 3;
  521. cvmx_write_csr(CVMX_POW_NW_TIM, nm_tim.u64);
  522. write_octeon_c0_icacheerr(0);
  523. write_c0_derraddr1(0);
  524. }
  525. /**
  526. * Early entry point for arch setup
  527. */
  528. void __init prom_init(void)
  529. {
  530. struct cvmx_sysinfo *sysinfo;
  531. const char *arg;
  532. char *p;
  533. int i;
  534. int argc;
  535. #ifdef CONFIG_CAVIUM_RESERVE32
  536. int64_t addr = -1;
  537. #endif
  538. /*
  539. * The bootloader passes a pointer to the boot descriptor in
  540. * $a3, this is available as fw_arg3.
  541. */
  542. octeon_boot_desc_ptr = (struct octeon_boot_descriptor *)fw_arg3;
  543. octeon_bootinfo =
  544. cvmx_phys_to_ptr(octeon_boot_desc_ptr->cvmx_desc_vaddr);
  545. cvmx_bootmem_init(cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr));
  546. sysinfo = cvmx_sysinfo_get();
  547. memset(sysinfo, 0, sizeof(*sysinfo));
  548. sysinfo->system_dram_size = octeon_bootinfo->dram_size << 20;
  549. sysinfo->phy_mem_desc_ptr =
  550. cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr);
  551. sysinfo->core_mask = octeon_bootinfo->core_mask;
  552. sysinfo->exception_base_addr = octeon_bootinfo->exception_base_addr;
  553. sysinfo->cpu_clock_hz = octeon_bootinfo->eclock_hz;
  554. sysinfo->dram_data_rate_hz = octeon_bootinfo->dclock_hz * 2;
  555. sysinfo->board_type = octeon_bootinfo->board_type;
  556. sysinfo->board_rev_major = octeon_bootinfo->board_rev_major;
  557. sysinfo->board_rev_minor = octeon_bootinfo->board_rev_minor;
  558. memcpy(sysinfo->mac_addr_base, octeon_bootinfo->mac_addr_base,
  559. sizeof(sysinfo->mac_addr_base));
  560. sysinfo->mac_addr_count = octeon_bootinfo->mac_addr_count;
  561. memcpy(sysinfo->board_serial_number,
  562. octeon_bootinfo->board_serial_number,
  563. sizeof(sysinfo->board_serial_number));
  564. sysinfo->compact_flash_common_base_addr =
  565. octeon_bootinfo->compact_flash_common_base_addr;
  566. sysinfo->compact_flash_attribute_base_addr =
  567. octeon_bootinfo->compact_flash_attribute_base_addr;
  568. sysinfo->led_display_base_addr = octeon_bootinfo->led_display_base_addr;
  569. sysinfo->dfa_ref_clock_hz = octeon_bootinfo->dfa_ref_clock_hz;
  570. sysinfo->bootloader_config_flags = octeon_bootinfo->config_flags;
  571. if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
  572. /* I/O clock runs at a different rate than the CPU. */
  573. union cvmx_mio_rst_boot rst_boot;
  574. rst_boot.u64 = cvmx_read_csr(CVMX_MIO_RST_BOOT);
  575. octeon_io_clock_rate = 50000000 * rst_boot.s.pnr_mul;
  576. } else {
  577. octeon_io_clock_rate = sysinfo->cpu_clock_hz;
  578. }
  579. /*
  580. * Only enable the LED controller if we're running on a CN38XX, CN58XX,
  581. * or CN56XX. The CN30XX and CN31XX don't have an LED controller.
  582. */
  583. if (!octeon_is_simulation() &&
  584. octeon_has_feature(OCTEON_FEATURE_LED_CONTROLLER)) {
  585. cvmx_write_csr(CVMX_LED_EN, 0);
  586. cvmx_write_csr(CVMX_LED_PRT, 0);
  587. cvmx_write_csr(CVMX_LED_DBG, 0);
  588. cvmx_write_csr(CVMX_LED_PRT_FMT, 0);
  589. cvmx_write_csr(CVMX_LED_UDD_CNTX(0), 32);
  590. cvmx_write_csr(CVMX_LED_UDD_CNTX(1), 32);
  591. cvmx_write_csr(CVMX_LED_UDD_DATX(0), 0);
  592. cvmx_write_csr(CVMX_LED_UDD_DATX(1), 0);
  593. cvmx_write_csr(CVMX_LED_EN, 1);
  594. }
  595. #ifdef CONFIG_CAVIUM_RESERVE32
  596. /*
  597. * We need to temporarily allocate all memory in the reserve32
  598. * region. This makes sure the kernel doesn't allocate this
  599. * memory when it is getting memory from the
  600. * bootloader. Later, after the memory allocations are
  601. * complete, the reserve32 will be freed.
  602. *
  603. * Allocate memory for RESERVED32 aligned on 2MB boundary. This
  604. * is in case we later use hugetlb entries with it.
  605. */
  606. addr = cvmx_bootmem_phy_named_block_alloc(CONFIG_CAVIUM_RESERVE32 << 20,
  607. 0, 0, 2 << 20,
  608. "CAVIUM_RESERVE32", 0);
  609. if (addr < 0)
  610. pr_err("Failed to allocate CAVIUM_RESERVE32 memory area\n");
  611. else
  612. octeon_reserve32_memory = addr;
  613. #endif
  614. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2
  615. if (cvmx_read_csr(CVMX_L2D_FUS3) & (3ull << 34)) {
  616. pr_info("Skipping L2 locking due to reduced L2 cache size\n");
  617. } else {
  618. uint32_t __maybe_unused ebase = read_c0_ebase() & 0x3ffff000;
  619. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_TLB
  620. /* TLB refill */
  621. cvmx_l2c_lock_mem_region(ebase, 0x100);
  622. #endif
  623. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_EXCEPTION
  624. /* General exception */
  625. cvmx_l2c_lock_mem_region(ebase + 0x180, 0x80);
  626. #endif
  627. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_LOW_LEVEL_INTERRUPT
  628. /* Interrupt handler */
  629. cvmx_l2c_lock_mem_region(ebase + 0x200, 0x80);
  630. #endif
  631. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_INTERRUPT
  632. cvmx_l2c_lock_mem_region(__pa_symbol(handle_int), 0x100);
  633. cvmx_l2c_lock_mem_region(__pa_symbol(plat_irq_dispatch), 0x80);
  634. #endif
  635. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_MEMCPY
  636. cvmx_l2c_lock_mem_region(__pa_symbol(memcpy), 0x480);
  637. #endif
  638. }
  639. #endif
  640. octeon_check_cpu_bist();
  641. octeon_uart = octeon_get_boot_uart();
  642. #ifdef CONFIG_SMP
  643. octeon_write_lcd("LinuxSMP");
  644. #else
  645. octeon_write_lcd("Linux");
  646. #endif
  647. #ifdef CONFIG_CAVIUM_GDB
  648. /*
  649. * When debugging the linux kernel, force the cores to enter
  650. * the debug exception handler to break in.
  651. */
  652. if (octeon_get_boot_debug_flag()) {
  653. cvmx_write_csr(CVMX_CIU_DINT, 1 << cvmx_get_core_num());
  654. cvmx_read_csr(CVMX_CIU_DINT);
  655. }
  656. #endif
  657. octeon_setup_delays();
  658. /*
  659. * BIST should always be enabled when doing a soft reset. L2
  660. * Cache locking for instance is not cleared unless BIST is
  661. * enabled. Unfortunately due to a chip errata G-200 for
  662. * Cn38XX and CN31XX, BIST msut be disabled on these parts.
  663. */
  664. if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2) ||
  665. OCTEON_IS_MODEL(OCTEON_CN31XX))
  666. cvmx_write_csr(CVMX_CIU_SOFT_BIST, 0);
  667. else
  668. cvmx_write_csr(CVMX_CIU_SOFT_BIST, 1);
  669. /* Default to 64MB in the simulator to speed things up */
  670. if (octeon_is_simulation())
  671. MAX_MEMORY = 64ull << 20;
  672. arg = strstr(arcs_cmdline, "mem=");
  673. if (arg) {
  674. MAX_MEMORY = memparse(arg + 4, &p);
  675. if (MAX_MEMORY == 0)
  676. MAX_MEMORY = 32ull << 30;
  677. if (*p == '@')
  678. RESERVE_LOW_MEM = memparse(p + 1, &p);
  679. }
  680. arcs_cmdline[0] = 0;
  681. argc = octeon_boot_desc_ptr->argc;
  682. for (i = 0; i < argc; i++) {
  683. const char *arg =
  684. cvmx_phys_to_ptr(octeon_boot_desc_ptr->argv[i]);
  685. if ((strncmp(arg, "MEM=", 4) == 0) ||
  686. (strncmp(arg, "mem=", 4) == 0)) {
  687. MAX_MEMORY = memparse(arg + 4, &p);
  688. if (MAX_MEMORY == 0)
  689. MAX_MEMORY = 32ull << 30;
  690. if (*p == '@')
  691. RESERVE_LOW_MEM = memparse(p + 1, &p);
  692. } else if (strcmp(arg, "ecc_verbose") == 0) {
  693. #ifdef CONFIG_CAVIUM_REPORT_SINGLE_BIT_ECC
  694. __cvmx_interrupt_ecc_report_single_bit_errors = 1;
  695. pr_notice("Reporting of single bit ECC errors is "
  696. "turned on\n");
  697. #endif
  698. #ifdef CONFIG_KEXEC
  699. } else if (strncmp(arg, "crashkernel=", 12) == 0) {
  700. crashk_size = memparse(arg+12, &p);
  701. if (*p == '@')
  702. crashk_base = memparse(p+1, &p);
  703. strcat(arcs_cmdline, " ");
  704. strcat(arcs_cmdline, arg);
  705. /*
  706. * To do: switch parsing to new style, something like:
  707. * parse_crashkernel(arg, sysinfo->system_dram_size,
  708. * &crashk_size, &crashk_base);
  709. */
  710. #endif
  711. } else if (strlen(arcs_cmdline) + strlen(arg) + 1 <
  712. sizeof(arcs_cmdline) - 1) {
  713. strcat(arcs_cmdline, " ");
  714. strcat(arcs_cmdline, arg);
  715. }
  716. }
  717. if (strstr(arcs_cmdline, "console=") == NULL) {
  718. #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
  719. strcat(arcs_cmdline, " console=ttyS0,115200");
  720. #else
  721. if (octeon_uart == 1)
  722. strcat(arcs_cmdline, " console=ttyS1,115200");
  723. else
  724. strcat(arcs_cmdline, " console=ttyS0,115200");
  725. #endif
  726. }
  727. if (octeon_is_simulation()) {
  728. /*
  729. * The simulator uses a mtdram device pre filled with
  730. * the filesystem. Also specify the calibration delay
  731. * to avoid calculating it every time.
  732. */
  733. strcat(arcs_cmdline, " rw root=1f00 slram=root,0x40000000,+1073741824");
  734. }
  735. mips_hpt_frequency = octeon_get_clock_rate();
  736. octeon_init_cvmcount();
  737. _machine_restart = octeon_restart;
  738. _machine_halt = octeon_halt;
  739. #ifdef CONFIG_KEXEC
  740. _machine_kexec_shutdown = octeon_shutdown;
  741. _machine_crash_shutdown = octeon_crash_shutdown;
  742. _machine_kexec_prepare = octeon_kexec_prepare;
  743. #endif
  744. octeon_user_io_init();
  745. register_smp_ops(&octeon_smp_ops);
  746. }
  747. /* Exclude a single page from the regions obtained in plat_mem_setup. */
  748. #ifndef CONFIG_CRASH_DUMP
  749. static __init void memory_exclude_page(u64 addr, u64 *mem, u64 *size)
  750. {
  751. if (addr > *mem && addr < *mem + *size) {
  752. u64 inc = addr - *mem;
  753. add_memory_region(*mem, inc, BOOT_MEM_RAM);
  754. *mem += inc;
  755. *size -= inc;
  756. }
  757. if (addr == *mem && *size > PAGE_SIZE) {
  758. *mem += PAGE_SIZE;
  759. *size -= PAGE_SIZE;
  760. }
  761. }
  762. #endif /* CONFIG_CRASH_DUMP */
  763. void __init plat_mem_setup(void)
  764. {
  765. uint64_t mem_alloc_size;
  766. uint64_t total;
  767. uint64_t crashk_end;
  768. #ifndef CONFIG_CRASH_DUMP
  769. int64_t memory;
  770. uint64_t kernel_start;
  771. uint64_t kernel_size;
  772. #endif
  773. total = 0;
  774. crashk_end = 0;
  775. /*
  776. * The Mips memory init uses the first memory location for
  777. * some memory vectors. When SPARSEMEM is in use, it doesn't
  778. * verify that the size is big enough for the final
  779. * vectors. Making the smallest chuck 4MB seems to be enough
  780. * to consistently work.
  781. */
  782. mem_alloc_size = 4 << 20;
  783. if (mem_alloc_size > MAX_MEMORY)
  784. mem_alloc_size = MAX_MEMORY;
  785. /* Crashkernel ignores bootmem list. It relies on mem=X@Y option */
  786. #ifdef CONFIG_CRASH_DUMP
  787. add_memory_region(RESERVE_LOW_MEM, MAX_MEMORY, BOOT_MEM_RAM);
  788. total += MAX_MEMORY;
  789. #else
  790. #ifdef CONFIG_KEXEC
  791. if (crashk_size > 0) {
  792. add_memory_region(crashk_base, crashk_size, BOOT_MEM_RAM);
  793. crashk_end = crashk_base + crashk_size;
  794. }
  795. #endif
  796. /*
  797. * When allocating memory, we want incrementing addresses from
  798. * bootmem_alloc so the code in add_memory_region can merge
  799. * regions next to each other.
  800. */
  801. cvmx_bootmem_lock();
  802. while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX)
  803. && (total < MAX_MEMORY)) {
  804. memory = cvmx_bootmem_phy_alloc(mem_alloc_size,
  805. __pa_symbol(&__init_end), -1,
  806. 0x100000,
  807. CVMX_BOOTMEM_FLAG_NO_LOCKING);
  808. if (memory >= 0) {
  809. u64 size = mem_alloc_size;
  810. #ifdef CONFIG_KEXEC
  811. uint64_t end;
  812. #endif
  813. /*
  814. * exclude a page at the beginning and end of
  815. * the 256MB PCIe 'hole' so the kernel will not
  816. * try to allocate multi-page buffers that
  817. * span the discontinuity.
  818. */
  819. memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE,
  820. &memory, &size);
  821. memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE +
  822. CVMX_PCIE_BAR1_PHYS_SIZE,
  823. &memory, &size);
  824. #ifdef CONFIG_KEXEC
  825. end = memory + mem_alloc_size;
  826. /*
  827. * This function automatically merges address regions
  828. * next to each other if they are received in
  829. * incrementing order
  830. */
  831. if (memory < crashk_base && end > crashk_end) {
  832. /* region is fully in */
  833. add_memory_region(memory,
  834. crashk_base - memory,
  835. BOOT_MEM_RAM);
  836. total += crashk_base - memory;
  837. add_memory_region(crashk_end,
  838. end - crashk_end,
  839. BOOT_MEM_RAM);
  840. total += end - crashk_end;
  841. continue;
  842. }
  843. if (memory >= crashk_base && end <= crashk_end)
  844. /*
  845. * Entire memory region is within the new
  846. * kernel's memory, ignore it.
  847. */
  848. continue;
  849. if (memory > crashk_base && memory < crashk_end &&
  850. end > crashk_end) {
  851. /*
  852. * Overlap with the beginning of the region,
  853. * reserve the beginning.
  854. */
  855. mem_alloc_size -= crashk_end - memory;
  856. memory = crashk_end;
  857. } else if (memory < crashk_base && end > crashk_base &&
  858. end < crashk_end)
  859. /*
  860. * Overlap with the beginning of the region,
  861. * chop of end.
  862. */
  863. mem_alloc_size -= end - crashk_base;
  864. #endif
  865. add_memory_region(memory, mem_alloc_size, BOOT_MEM_RAM);
  866. total += mem_alloc_size;
  867. /* Recovering mem_alloc_size */
  868. mem_alloc_size = 4 << 20;
  869. } else {
  870. break;
  871. }
  872. }
  873. cvmx_bootmem_unlock();
  874. /* Add the memory region for the kernel. */
  875. kernel_start = (unsigned long) _text;
  876. kernel_size = _end - _text;
  877. /* Adjust for physical offset. */
  878. kernel_start &= ~0xffffffff80000000ULL;
  879. add_memory_region(kernel_start, kernel_size, BOOT_MEM_RAM);
  880. #endif /* CONFIG_CRASH_DUMP */
  881. #ifdef CONFIG_CAVIUM_RESERVE32
  882. /*
  883. * Now that we've allocated the kernel memory it is safe to
  884. * free the reserved region. We free it here so that builtin
  885. * drivers can use the memory.
  886. */
  887. if (octeon_reserve32_memory)
  888. cvmx_bootmem_free_named("CAVIUM_RESERVE32");
  889. #endif /* CONFIG_CAVIUM_RESERVE32 */
  890. if (total == 0)
  891. panic("Unable to allocate memory from "
  892. "cvmx_bootmem_phy_alloc\n");
  893. }
  894. /*
  895. * Emit one character to the boot UART. Exported for use by the
  896. * watchdog timer.
  897. */
  898. int prom_putchar(char c)
  899. {
  900. uint64_t lsrval;
  901. /* Spin until there is room */
  902. do {
  903. lsrval = cvmx_read_csr(CVMX_MIO_UARTX_LSR(octeon_uart));
  904. } while ((lsrval & 0x20) == 0);
  905. /* Write the byte */
  906. cvmx_write_csr(CVMX_MIO_UARTX_THR(octeon_uart), c & 0xffull);
  907. return 1;
  908. }
  909. EXPORT_SYMBOL(prom_putchar);
  910. void prom_free_prom_memory(void)
  911. {
  912. if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X)) {
  913. /* Check for presence of Core-14449 fix. */
  914. u32 insn;
  915. u32 *foo;
  916. foo = &insn;
  917. asm volatile("# before" : : : "memory");
  918. prefetch(foo);
  919. asm volatile(
  920. ".set push\n\t"
  921. ".set noreorder\n\t"
  922. "bal 1f\n\t"
  923. "nop\n"
  924. "1:\tlw %0,-12($31)\n\t"
  925. ".set pop\n\t"
  926. : "=r" (insn) : : "$31", "memory");
  927. if ((insn >> 26) != 0x33)
  928. panic("No PREF instruction at Core-14449 probe point.");
  929. if (((insn >> 16) & 0x1f) != 28)
  930. panic("Core-14449 WAR not in place (%04x).\n"
  931. "Please build kernel with proper options (CONFIG_CAVIUM_CN63XXP1).", insn);
  932. }
  933. }
  934. int octeon_prune_device_tree(void);
  935. extern const char __dtb_octeon_3xxx_begin;
  936. extern const char __dtb_octeon_3xxx_end;
  937. extern const char __dtb_octeon_68xx_begin;
  938. extern const char __dtb_octeon_68xx_end;
  939. void __init device_tree_init(void)
  940. {
  941. int dt_size;
  942. struct boot_param_header *fdt;
  943. bool do_prune;
  944. if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
  945. fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
  946. if (fdt_check_header(fdt))
  947. panic("Corrupt Device Tree passed to kernel.");
  948. dt_size = be32_to_cpu(fdt->totalsize);
  949. do_prune = false;
  950. } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
  951. fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin;
  952. dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin;
  953. do_prune = true;
  954. } else {
  955. fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin;
  956. dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
  957. do_prune = true;
  958. }
  959. /* Copy the default tree from init memory. */
  960. initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
  961. if (initial_boot_params == NULL)
  962. panic("Could not allocate initial_boot_params\n");
  963. memcpy(initial_boot_params, fdt, dt_size);
  964. if (do_prune) {
  965. octeon_prune_device_tree();
  966. pr_info("Using internal Device Tree.\n");
  967. } else {
  968. pr_info("Using passed Device Tree.\n");
  969. }
  970. unflatten_device_tree();
  971. }
  972. static int __initdata disable_octeon_edac_p;
  973. static int __init disable_octeon_edac(char *str)
  974. {
  975. disable_octeon_edac_p = 1;
  976. return 0;
  977. }
  978. early_param("disable_octeon_edac", disable_octeon_edac);
  979. static char *edac_device_names[] = {
  980. "octeon_l2c_edac",
  981. "octeon_pc_edac",
  982. };
  983. static int __init edac_devinit(void)
  984. {
  985. struct platform_device *dev;
  986. int i, err = 0;
  987. int num_lmc;
  988. char *name;
  989. if (disable_octeon_edac_p)
  990. return 0;
  991. for (i = 0; i < ARRAY_SIZE(edac_device_names); i++) {
  992. name = edac_device_names[i];
  993. dev = platform_device_register_simple(name, -1, NULL, 0);
  994. if (IS_ERR(dev)) {
  995. pr_err("Registation of %s failed!\n", name);
  996. err = PTR_ERR(dev);
  997. }
  998. }
  999. num_lmc = OCTEON_IS_MODEL(OCTEON_CN68XX) ? 4 :
  1000. (OCTEON_IS_MODEL(OCTEON_CN56XX) ? 2 : 1);
  1001. for (i = 0; i < num_lmc; i++) {
  1002. dev = platform_device_register_simple("octeon_lmc_edac",
  1003. i, NULL, 0);
  1004. if (IS_ERR(dev)) {
  1005. pr_err("Registation of octeon_lmc_edac %d failed!\n", i);
  1006. err = PTR_ERR(dev);
  1007. }
  1008. }
  1009. return err;
  1010. }
  1011. device_initcall(edac_devinit);
  1012. static void __initdata *octeon_dummy_iospace;
  1013. static int __init octeon_no_pci_init(void)
  1014. {
  1015. /*
  1016. * Initially assume there is no PCI. The PCI/PCIe platform code will
  1017. * later re-initialize these to correct values if they are present.
  1018. */
  1019. octeon_dummy_iospace = vzalloc(IO_SPACE_LIMIT);
  1020. set_io_port_base((unsigned long)octeon_dummy_iospace);
  1021. ioport_resource.start = MAX_RESOURCE;
  1022. ioport_resource.end = 0;
  1023. return 0;
  1024. }
  1025. core_initcall(octeon_no_pci_init);
  1026. static int __init octeon_no_pci_release(void)
  1027. {
  1028. /*
  1029. * Release the allocated memory if a real IO space is there.
  1030. */
  1031. if ((unsigned long)octeon_dummy_iospace != mips_io_port_base)
  1032. vfree(octeon_dummy_iospace);
  1033. return 0;
  1034. }
  1035. late_initcall(octeon_no_pci_release);