setup.c 31 KB

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