setup.c 31 KB

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