setup.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  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. mb();
  376. if (octeon_is_simulation()) {
  377. /* The simulator needs the watchdog to stop for dead cores */
  378. cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
  379. /* A break instruction causes the simulator stop a core */
  380. asm volatile ("sync\nbreak");
  381. }
  382. }
  383. /**
  384. * Halt the system
  385. */
  386. static void octeon_halt(void)
  387. {
  388. smp_call_function(octeon_kill_core, NULL, 0);
  389. switch (octeon_bootinfo->board_type) {
  390. case CVMX_BOARD_TYPE_NAO38:
  391. /* Driving a 1 to GPIO 12 shuts off this board */
  392. cvmx_write_csr(CVMX_GPIO_BIT_CFGX(12), 1);
  393. cvmx_write_csr(CVMX_GPIO_TX_SET, 0x1000);
  394. break;
  395. default:
  396. octeon_write_lcd("PowerOff");
  397. break;
  398. }
  399. octeon_kill_core(NULL);
  400. }
  401. /**
  402. * Handle all the error condition interrupts that might occur.
  403. *
  404. */
  405. #ifdef CONFIG_CAVIUM_DECODE_RSL
  406. static irqreturn_t octeon_rlm_interrupt(int cpl, void *dev_id)
  407. {
  408. cvmx_interrupt_rsl_decode();
  409. return IRQ_HANDLED;
  410. }
  411. #endif
  412. /**
  413. * Return a string representing the system type
  414. *
  415. * Returns
  416. */
  417. const char *octeon_board_type_string(void)
  418. {
  419. static char name[80];
  420. sprintf(name, "%s (%s)",
  421. cvmx_board_type_to_string(octeon_bootinfo->board_type),
  422. octeon_model_get_string(read_c0_prid()));
  423. return name;
  424. }
  425. const char *get_system_type(void)
  426. __attribute__ ((alias("octeon_board_type_string")));
  427. void octeon_user_io_init(void)
  428. {
  429. union octeon_cvmemctl cvmmemctl;
  430. union cvmx_iob_fau_timeout fau_timeout;
  431. union cvmx_pow_nw_tim nm_tim;
  432. /* Get the current settings for CP0_CVMMEMCTL_REG */
  433. cvmmemctl.u64 = read_c0_cvmmemctl();
  434. /* R/W If set, marked write-buffer entries time out the same
  435. * as as other entries; if clear, marked write-buffer entries
  436. * use the maximum timeout. */
  437. cvmmemctl.s.dismarkwblongto = 1;
  438. /* R/W If set, a merged store does not clear the write-buffer
  439. * entry timeout state. */
  440. cvmmemctl.s.dismrgclrwbto = 0;
  441. /* R/W Two bits that are the MSBs of the resultant CVMSEG LM
  442. * word location for an IOBDMA. The other 8 bits come from the
  443. * SCRADDR field of the IOBDMA. */
  444. cvmmemctl.s.iobdmascrmsb = 0;
  445. /* R/W If set, SYNCWS and SYNCS only order marked stores; if
  446. * clear, SYNCWS and SYNCS only order unmarked
  447. * stores. SYNCWSMARKED has no effect when DISSYNCWS is
  448. * set. */
  449. cvmmemctl.s.syncwsmarked = 0;
  450. /* R/W If set, SYNCWS acts as SYNCW and SYNCS acts as SYNC. */
  451. cvmmemctl.s.dissyncws = 0;
  452. /* R/W If set, no stall happens on write buffer full. */
  453. if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2))
  454. cvmmemctl.s.diswbfst = 1;
  455. else
  456. cvmmemctl.s.diswbfst = 0;
  457. /* R/W If set (and SX set), supervisor-level loads/stores can
  458. * use XKPHYS addresses with <48>==0 */
  459. cvmmemctl.s.xkmemenas = 0;
  460. /* R/W If set (and UX set), user-level loads/stores can use
  461. * XKPHYS addresses with VA<48>==0 */
  462. cvmmemctl.s.xkmemenau = 0;
  463. /* R/W If set (and SX set), supervisor-level loads/stores can
  464. * use XKPHYS addresses with VA<48>==1 */
  465. cvmmemctl.s.xkioenas = 0;
  466. /* R/W If set (and UX set), user-level loads/stores can use
  467. * XKPHYS addresses with VA<48>==1 */
  468. cvmmemctl.s.xkioenau = 0;
  469. /* R/W If set, all stores act as SYNCW (NOMERGE must be set
  470. * when this is set) RW, reset to 0. */
  471. cvmmemctl.s.allsyncw = 0;
  472. /* R/W If set, no stores merge, and all stores reach the
  473. * coherent bus in order. */
  474. cvmmemctl.s.nomerge = 0;
  475. /* R/W Selects the bit in the counter used for DID time-outs 0
  476. * = 231, 1 = 230, 2 = 229, 3 = 214. Actual time-out is
  477. * between 1x and 2x this interval. For example, with
  478. * DIDTTO=3, expiration interval is between 16K and 32K. */
  479. cvmmemctl.s.didtto = 0;
  480. /* R/W If set, the (mem) CSR clock never turns off. */
  481. cvmmemctl.s.csrckalwys = 0;
  482. /* R/W If set, mclk never turns off. */
  483. cvmmemctl.s.mclkalwys = 0;
  484. /* R/W Selects the bit in the counter used for write buffer
  485. * flush time-outs (WBFLT+11) is the bit position in an
  486. * internal counter used to determine expiration. The write
  487. * buffer expires between 1x and 2x this interval. For
  488. * example, with WBFLT = 0, a write buffer expires between 2K
  489. * and 4K cycles after the write buffer entry is allocated. */
  490. cvmmemctl.s.wbfltime = 0;
  491. /* R/W If set, do not put Istream in the L2 cache. */
  492. cvmmemctl.s.istrnol2 = 0;
  493. /*
  494. * R/W The write buffer threshold. As per erratum Core-14752
  495. * for CN63XX, a sc/scd might fail if the write buffer is
  496. * full. Lowering WBTHRESH greatly lowers the chances of the
  497. * write buffer ever being full and triggering the erratum.
  498. */
  499. if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X))
  500. cvmmemctl.s.wbthresh = 4;
  501. else
  502. cvmmemctl.s.wbthresh = 10;
  503. /* R/W If set, CVMSEG is available for loads/stores in
  504. * kernel/debug mode. */
  505. #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
  506. cvmmemctl.s.cvmsegenak = 1;
  507. #else
  508. cvmmemctl.s.cvmsegenak = 0;
  509. #endif
  510. /* R/W If set, CVMSEG is available for loads/stores in
  511. * supervisor mode. */
  512. cvmmemctl.s.cvmsegenas = 0;
  513. /* R/W If set, CVMSEG is available for loads/stores in user
  514. * mode. */
  515. cvmmemctl.s.cvmsegenau = 0;
  516. /* R/W Size of local memory in cache blocks, 54 (6912 bytes)
  517. * is max legal value. */
  518. cvmmemctl.s.lmemsz = CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE;
  519. write_c0_cvmmemctl(cvmmemctl.u64);
  520. if (smp_processor_id() == 0)
  521. pr_notice("CVMSEG size: %d cache lines (%d bytes)\n",
  522. CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE,
  523. CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE * 128);
  524. /* Set a default for the hardware timeouts */
  525. fau_timeout.u64 = 0;
  526. fau_timeout.s.tout_val = 0xfff;
  527. /* Disable tagwait FAU timeout */
  528. fau_timeout.s.tout_enb = 0;
  529. cvmx_write_csr(CVMX_IOB_FAU_TIMEOUT, fau_timeout.u64);
  530. nm_tim.u64 = 0;
  531. /* 4096 cycles */
  532. nm_tim.s.nw_tim = 3;
  533. cvmx_write_csr(CVMX_POW_NW_TIM, nm_tim.u64);
  534. write_octeon_c0_icacheerr(0);
  535. write_c0_derraddr1(0);
  536. }
  537. /**
  538. * Early entry point for arch setup
  539. */
  540. void __init prom_init(void)
  541. {
  542. struct cvmx_sysinfo *sysinfo;
  543. const char *arg;
  544. char *p;
  545. int i;
  546. int argc;
  547. #ifdef CONFIG_CAVIUM_RESERVE32
  548. int64_t addr = -1;
  549. #endif
  550. /*
  551. * The bootloader passes a pointer to the boot descriptor in
  552. * $a3, this is available as fw_arg3.
  553. */
  554. octeon_boot_desc_ptr = (struct octeon_boot_descriptor *)fw_arg3;
  555. octeon_bootinfo =
  556. cvmx_phys_to_ptr(octeon_boot_desc_ptr->cvmx_desc_vaddr);
  557. cvmx_bootmem_init(cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr));
  558. sysinfo = cvmx_sysinfo_get();
  559. memset(sysinfo, 0, sizeof(*sysinfo));
  560. sysinfo->system_dram_size = octeon_bootinfo->dram_size << 20;
  561. sysinfo->phy_mem_desc_ptr =
  562. cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr);
  563. sysinfo->core_mask = octeon_bootinfo->core_mask;
  564. sysinfo->exception_base_addr = octeon_bootinfo->exception_base_addr;
  565. sysinfo->cpu_clock_hz = octeon_bootinfo->eclock_hz;
  566. sysinfo->dram_data_rate_hz = octeon_bootinfo->dclock_hz * 2;
  567. sysinfo->board_type = octeon_bootinfo->board_type;
  568. sysinfo->board_rev_major = octeon_bootinfo->board_rev_major;
  569. sysinfo->board_rev_minor = octeon_bootinfo->board_rev_minor;
  570. memcpy(sysinfo->mac_addr_base, octeon_bootinfo->mac_addr_base,
  571. sizeof(sysinfo->mac_addr_base));
  572. sysinfo->mac_addr_count = octeon_bootinfo->mac_addr_count;
  573. memcpy(sysinfo->board_serial_number,
  574. octeon_bootinfo->board_serial_number,
  575. sizeof(sysinfo->board_serial_number));
  576. sysinfo->compact_flash_common_base_addr =
  577. octeon_bootinfo->compact_flash_common_base_addr;
  578. sysinfo->compact_flash_attribute_base_addr =
  579. octeon_bootinfo->compact_flash_attribute_base_addr;
  580. sysinfo->led_display_base_addr = octeon_bootinfo->led_display_base_addr;
  581. sysinfo->dfa_ref_clock_hz = octeon_bootinfo->dfa_ref_clock_hz;
  582. sysinfo->bootloader_config_flags = octeon_bootinfo->config_flags;
  583. if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
  584. /* I/O clock runs at a different rate than the CPU. */
  585. union cvmx_mio_rst_boot rst_boot;
  586. rst_boot.u64 = cvmx_read_csr(CVMX_MIO_RST_BOOT);
  587. octeon_io_clock_rate = 50000000 * rst_boot.s.pnr_mul;
  588. } else {
  589. octeon_io_clock_rate = sysinfo->cpu_clock_hz;
  590. }
  591. /*
  592. * Only enable the LED controller if we're running on a CN38XX, CN58XX,
  593. * or CN56XX. The CN30XX and CN31XX don't have an LED controller.
  594. */
  595. if (!octeon_is_simulation() &&
  596. octeon_has_feature(OCTEON_FEATURE_LED_CONTROLLER)) {
  597. cvmx_write_csr(CVMX_LED_EN, 0);
  598. cvmx_write_csr(CVMX_LED_PRT, 0);
  599. cvmx_write_csr(CVMX_LED_DBG, 0);
  600. cvmx_write_csr(CVMX_LED_PRT_FMT, 0);
  601. cvmx_write_csr(CVMX_LED_UDD_CNTX(0), 32);
  602. cvmx_write_csr(CVMX_LED_UDD_CNTX(1), 32);
  603. cvmx_write_csr(CVMX_LED_UDD_DATX(0), 0);
  604. cvmx_write_csr(CVMX_LED_UDD_DATX(1), 0);
  605. cvmx_write_csr(CVMX_LED_EN, 1);
  606. }
  607. #ifdef CONFIG_CAVIUM_RESERVE32
  608. /*
  609. * We need to temporarily allocate all memory in the reserve32
  610. * region. This makes sure the kernel doesn't allocate this
  611. * memory when it is getting memory from the
  612. * bootloader. Later, after the memory allocations are
  613. * complete, the reserve32 will be freed.
  614. *
  615. * Allocate memory for RESERVED32 aligned on 2MB boundary. This
  616. * is in case we later use hugetlb entries with it.
  617. */
  618. addr = cvmx_bootmem_phy_named_block_alloc(CONFIG_CAVIUM_RESERVE32 << 20,
  619. 0, 0, 2 << 20,
  620. "CAVIUM_RESERVE32", 0);
  621. if (addr < 0)
  622. pr_err("Failed to allocate CAVIUM_RESERVE32 memory area\n");
  623. else
  624. octeon_reserve32_memory = addr;
  625. #endif
  626. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2
  627. if (cvmx_read_csr(CVMX_L2D_FUS3) & (3ull << 34)) {
  628. pr_info("Skipping L2 locking due to reduced L2 cache size\n");
  629. } else {
  630. uint32_t ebase = read_c0_ebase() & 0x3ffff000;
  631. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_TLB
  632. /* TLB refill */
  633. cvmx_l2c_lock_mem_region(ebase, 0x100);
  634. #endif
  635. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_EXCEPTION
  636. /* General exception */
  637. cvmx_l2c_lock_mem_region(ebase + 0x180, 0x80);
  638. #endif
  639. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_LOW_LEVEL_INTERRUPT
  640. /* Interrupt handler */
  641. cvmx_l2c_lock_mem_region(ebase + 0x200, 0x80);
  642. #endif
  643. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_INTERRUPT
  644. cvmx_l2c_lock_mem_region(__pa_symbol(handle_int), 0x100);
  645. cvmx_l2c_lock_mem_region(__pa_symbol(plat_irq_dispatch), 0x80);
  646. #endif
  647. #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_MEMCPY
  648. cvmx_l2c_lock_mem_region(__pa_symbol(memcpy), 0x480);
  649. #endif
  650. }
  651. #endif
  652. octeon_check_cpu_bist();
  653. octeon_uart = octeon_get_boot_uart();
  654. #ifdef CONFIG_SMP
  655. octeon_write_lcd("LinuxSMP");
  656. #else
  657. octeon_write_lcd("Linux");
  658. #endif
  659. #ifdef CONFIG_CAVIUM_GDB
  660. /*
  661. * When debugging the linux kernel, force the cores to enter
  662. * the debug exception handler to break in.
  663. */
  664. if (octeon_get_boot_debug_flag()) {
  665. cvmx_write_csr(CVMX_CIU_DINT, 1 << cvmx_get_core_num());
  666. cvmx_read_csr(CVMX_CIU_DINT);
  667. }
  668. #endif
  669. octeon_setup_delays();
  670. /*
  671. * BIST should always be enabled when doing a soft reset. L2
  672. * Cache locking for instance is not cleared unless BIST is
  673. * enabled. Unfortunately due to a chip errata G-200 for
  674. * Cn38XX and CN31XX, BIST msut be disabled on these parts.
  675. */
  676. if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2) ||
  677. OCTEON_IS_MODEL(OCTEON_CN31XX))
  678. cvmx_write_csr(CVMX_CIU_SOFT_BIST, 0);
  679. else
  680. cvmx_write_csr(CVMX_CIU_SOFT_BIST, 1);
  681. /* Default to 64MB in the simulator to speed things up */
  682. if (octeon_is_simulation())
  683. MAX_MEMORY = 64ull << 20;
  684. arg = strstr(arcs_cmdline, "mem=");
  685. if (arg) {
  686. MAX_MEMORY = memparse(arg + 4, &p);
  687. if (MAX_MEMORY == 0)
  688. MAX_MEMORY = 32ull << 30;
  689. if (*p == '@')
  690. RESERVE_LOW_MEM = memparse(p + 1, &p);
  691. }
  692. arcs_cmdline[0] = 0;
  693. argc = octeon_boot_desc_ptr->argc;
  694. for (i = 0; i < argc; i++) {
  695. const char *arg =
  696. cvmx_phys_to_ptr(octeon_boot_desc_ptr->argv[i]);
  697. if ((strncmp(arg, "MEM=", 4) == 0) ||
  698. (strncmp(arg, "mem=", 4) == 0)) {
  699. MAX_MEMORY = memparse(arg + 4, &p);
  700. if (MAX_MEMORY == 0)
  701. MAX_MEMORY = 32ull << 30;
  702. if (*p == '@')
  703. RESERVE_LOW_MEM = memparse(p + 1, &p);
  704. } else if (strcmp(arg, "ecc_verbose") == 0) {
  705. #ifdef CONFIG_CAVIUM_REPORT_SINGLE_BIT_ECC
  706. __cvmx_interrupt_ecc_report_single_bit_errors = 1;
  707. pr_notice("Reporting of single bit ECC errors is "
  708. "turned on\n");
  709. #endif
  710. #ifdef CONFIG_KEXEC
  711. } else if (strncmp(arg, "crashkernel=", 12) == 0) {
  712. crashk_size = memparse(arg+12, &p);
  713. if (*p == '@')
  714. crashk_base = memparse(p+1, &p);
  715. strcat(arcs_cmdline, " ");
  716. strcat(arcs_cmdline, arg);
  717. /*
  718. * To do: switch parsing to new style, something like:
  719. * parse_crashkernel(arg, sysinfo->system_dram_size,
  720. * &crashk_size, &crashk_base);
  721. */
  722. #endif
  723. } else if (strlen(arcs_cmdline) + strlen(arg) + 1 <
  724. sizeof(arcs_cmdline) - 1) {
  725. strcat(arcs_cmdline, " ");
  726. strcat(arcs_cmdline, arg);
  727. }
  728. }
  729. if (strstr(arcs_cmdline, "console=") == NULL) {
  730. #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
  731. strcat(arcs_cmdline, " console=ttyS0,115200");
  732. #else
  733. if (octeon_uart == 1)
  734. strcat(arcs_cmdline, " console=ttyS1,115200");
  735. else
  736. strcat(arcs_cmdline, " console=ttyS0,115200");
  737. #endif
  738. }
  739. if (octeon_is_simulation()) {
  740. /*
  741. * The simulator uses a mtdram device pre filled with
  742. * the filesystem. Also specify the calibration delay
  743. * to avoid calculating it every time.
  744. */
  745. strcat(arcs_cmdline, " rw root=1f00 slram=root,0x40000000,+1073741824");
  746. }
  747. mips_hpt_frequency = octeon_get_clock_rate();
  748. octeon_init_cvmcount();
  749. _machine_restart = octeon_restart;
  750. _machine_halt = octeon_halt;
  751. #ifdef CONFIG_KEXEC
  752. _machine_kexec_shutdown = octeon_shutdown;
  753. _machine_crash_shutdown = octeon_crash_shutdown;
  754. _machine_kexec_prepare = octeon_kexec_prepare;
  755. #endif
  756. octeon_user_io_init();
  757. register_smp_ops(&octeon_smp_ops);
  758. }
  759. /* Exclude a single page from the regions obtained in plat_mem_setup. */
  760. #ifndef CONFIG_CRASH_DUMP
  761. static __init void memory_exclude_page(u64 addr, u64 *mem, u64 *size)
  762. {
  763. if (addr > *mem && addr < *mem + *size) {
  764. u64 inc = addr - *mem;
  765. add_memory_region(*mem, inc, BOOT_MEM_RAM);
  766. *mem += inc;
  767. *size -= inc;
  768. }
  769. if (addr == *mem && *size > PAGE_SIZE) {
  770. *mem += PAGE_SIZE;
  771. *size -= PAGE_SIZE;
  772. }
  773. }
  774. #endif /* CONFIG_CRASH_DUMP */
  775. void __init plat_mem_setup(void)
  776. {
  777. uint64_t mem_alloc_size;
  778. uint64_t total;
  779. uint64_t crashk_end;
  780. #ifndef CONFIG_CRASH_DUMP
  781. int64_t memory;
  782. uint64_t kernel_start;
  783. uint64_t kernel_size;
  784. #endif
  785. total = 0;
  786. crashk_end = 0;
  787. /*
  788. * The Mips memory init uses the first memory location for
  789. * some memory vectors. When SPARSEMEM is in use, it doesn't
  790. * verify that the size is big enough for the final
  791. * vectors. Making the smallest chuck 4MB seems to be enough
  792. * to consistently work.
  793. */
  794. mem_alloc_size = 4 << 20;
  795. if (mem_alloc_size > MAX_MEMORY)
  796. mem_alloc_size = MAX_MEMORY;
  797. /* Crashkernel ignores bootmem list. It relies on mem=X@Y option */
  798. #ifdef CONFIG_CRASH_DUMP
  799. add_memory_region(RESERVE_LOW_MEM, MAX_MEMORY, BOOT_MEM_RAM);
  800. total += MAX_MEMORY;
  801. #else
  802. #ifdef CONFIG_KEXEC
  803. if (crashk_size > 0) {
  804. add_memory_region(crashk_base, crashk_size, BOOT_MEM_RAM);
  805. crashk_end = crashk_base + crashk_size;
  806. }
  807. #endif
  808. /*
  809. * When allocating memory, we want incrementing addresses from
  810. * bootmem_alloc so the code in add_memory_region can merge
  811. * regions next to each other.
  812. */
  813. cvmx_bootmem_lock();
  814. while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX)
  815. && (total < MAX_MEMORY)) {
  816. memory = cvmx_bootmem_phy_alloc(mem_alloc_size,
  817. __pa_symbol(&__init_end), -1,
  818. 0x100000,
  819. CVMX_BOOTMEM_FLAG_NO_LOCKING);
  820. if (memory >= 0) {
  821. u64 size = mem_alloc_size;
  822. #ifdef CONFIG_KEXEC
  823. uint64_t end;
  824. #endif
  825. /*
  826. * exclude a page at the beginning and end of
  827. * the 256MB PCIe 'hole' so the kernel will not
  828. * try to allocate multi-page buffers that
  829. * span the discontinuity.
  830. */
  831. memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE,
  832. &memory, &size);
  833. memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE +
  834. CVMX_PCIE_BAR1_PHYS_SIZE,
  835. &memory, &size);
  836. #ifdef CONFIG_KEXEC
  837. end = memory + mem_alloc_size;
  838. /*
  839. * This function automatically merges address regions
  840. * next to each other if they are received in
  841. * incrementing order
  842. */
  843. if (memory < crashk_base && end > crashk_end) {
  844. /* region is fully in */
  845. add_memory_region(memory,
  846. crashk_base - memory,
  847. BOOT_MEM_RAM);
  848. total += crashk_base - memory;
  849. add_memory_region(crashk_end,
  850. end - crashk_end,
  851. BOOT_MEM_RAM);
  852. total += end - crashk_end;
  853. continue;
  854. }
  855. if (memory >= crashk_base && end <= crashk_end)
  856. /*
  857. * Entire memory region is within the new
  858. * kernel's memory, ignore it.
  859. */
  860. continue;
  861. if (memory > crashk_base && memory < crashk_end &&
  862. end > crashk_end) {
  863. /*
  864. * Overlap with the beginning of the region,
  865. * reserve the beginning.
  866. */
  867. mem_alloc_size -= crashk_end - memory;
  868. memory = crashk_end;
  869. } else if (memory < crashk_base && end > crashk_base &&
  870. end < crashk_end)
  871. /*
  872. * Overlap with the beginning of the region,
  873. * chop of end.
  874. */
  875. mem_alloc_size -= end - crashk_base;
  876. #endif
  877. add_memory_region(memory, mem_alloc_size, BOOT_MEM_RAM);
  878. total += mem_alloc_size;
  879. /* Recovering mem_alloc_size */
  880. mem_alloc_size = 4 << 20;
  881. } else {
  882. break;
  883. }
  884. }
  885. cvmx_bootmem_unlock();
  886. /* Add the memory region for the kernel. */
  887. kernel_start = (unsigned long) _text;
  888. kernel_size = ALIGN(_end - _text, 0x100000);
  889. /* Adjust for physical offset. */
  890. kernel_start &= ~0xffffffff80000000ULL;
  891. add_memory_region(kernel_start, kernel_size, BOOT_MEM_RAM);
  892. #endif /* CONFIG_CRASH_DUMP */
  893. #ifdef CONFIG_CAVIUM_RESERVE32
  894. /*
  895. * Now that we've allocated the kernel memory it is safe to
  896. * free the reserved region. We free it here so that builtin
  897. * drivers can use the memory.
  898. */
  899. if (octeon_reserve32_memory)
  900. cvmx_bootmem_free_named("CAVIUM_RESERVE32");
  901. #endif /* CONFIG_CAVIUM_RESERVE32 */
  902. if (total == 0)
  903. panic("Unable to allocate memory from "
  904. "cvmx_bootmem_phy_alloc\n");
  905. }
  906. /*
  907. * Emit one character to the boot UART. Exported for use by the
  908. * watchdog timer.
  909. */
  910. int prom_putchar(char c)
  911. {
  912. uint64_t lsrval;
  913. /* Spin until there is room */
  914. do {
  915. lsrval = cvmx_read_csr(CVMX_MIO_UARTX_LSR(octeon_uart));
  916. } while ((lsrval & 0x20) == 0);
  917. /* Write the byte */
  918. cvmx_write_csr(CVMX_MIO_UARTX_THR(octeon_uart), c & 0xffull);
  919. return 1;
  920. }
  921. EXPORT_SYMBOL(prom_putchar);
  922. void prom_free_prom_memory(void)
  923. {
  924. if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X)) {
  925. /* Check for presence of Core-14449 fix. */
  926. u32 insn;
  927. u32 *foo;
  928. foo = &insn;
  929. asm volatile("# before" : : : "memory");
  930. prefetch(foo);
  931. asm volatile(
  932. ".set push\n\t"
  933. ".set noreorder\n\t"
  934. "bal 1f\n\t"
  935. "nop\n"
  936. "1:\tlw %0,-12($31)\n\t"
  937. ".set pop\n\t"
  938. : "=r" (insn) : : "$31", "memory");
  939. if ((insn >> 26) != 0x33)
  940. panic("No PREF instruction at Core-14449 probe point.");
  941. if (((insn >> 16) & 0x1f) != 28)
  942. panic("Core-14449 WAR not in place (%04x).\n"
  943. "Please build kernel with proper options (CONFIG_CAVIUM_CN63XXP1).", insn);
  944. }
  945. #ifdef CONFIG_CAVIUM_DECODE_RSL
  946. cvmx_interrupt_rsl_enable();
  947. /* Add an interrupt handler for general failures. */
  948. if (request_irq(OCTEON_IRQ_RML, octeon_rlm_interrupt, IRQF_SHARED,
  949. "RML/RSL", octeon_rlm_interrupt)) {
  950. panic("Unable to request_irq(OCTEON_IRQ_RML)");
  951. }
  952. #endif
  953. }
  954. int octeon_prune_device_tree(void);
  955. extern const char __dtb_octeon_3xxx_begin;
  956. extern const char __dtb_octeon_3xxx_end;
  957. extern const char __dtb_octeon_68xx_begin;
  958. extern const char __dtb_octeon_68xx_end;
  959. void __init device_tree_init(void)
  960. {
  961. int dt_size;
  962. struct boot_param_header *fdt;
  963. bool do_prune;
  964. if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
  965. fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
  966. if (fdt_check_header(fdt))
  967. panic("Corrupt Device Tree passed to kernel.");
  968. dt_size = be32_to_cpu(fdt->totalsize);
  969. do_prune = false;
  970. } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
  971. fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin;
  972. dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin;
  973. do_prune = true;
  974. } else {
  975. fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin;
  976. dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
  977. do_prune = true;
  978. }
  979. /* Copy the default tree from init memory. */
  980. initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
  981. if (initial_boot_params == NULL)
  982. panic("Could not allocate initial_boot_params\n");
  983. memcpy(initial_boot_params, fdt, dt_size);
  984. if (do_prune) {
  985. octeon_prune_device_tree();
  986. pr_info("Using internal Device Tree.\n");
  987. } else {
  988. pr_info("Using passed Device Tree.\n");
  989. }
  990. unflatten_device_tree();
  991. }
  992. static int __initdata disable_octeon_edac_p;
  993. static int __init disable_octeon_edac(char *str)
  994. {
  995. disable_octeon_edac_p = 1;
  996. return 0;
  997. }
  998. early_param("disable_octeon_edac", disable_octeon_edac);
  999. static char *edac_device_names[] = {
  1000. "octeon_l2c_edac",
  1001. "octeon_pc_edac",
  1002. };
  1003. static int __init edac_devinit(void)
  1004. {
  1005. struct platform_device *dev;
  1006. int i, err = 0;
  1007. int num_lmc;
  1008. char *name;
  1009. if (disable_octeon_edac_p)
  1010. return 0;
  1011. for (i = 0; i < ARRAY_SIZE(edac_device_names); i++) {
  1012. name = edac_device_names[i];
  1013. dev = platform_device_register_simple(name, -1, NULL, 0);
  1014. if (IS_ERR(dev)) {
  1015. pr_err("Registation of %s failed!\n", name);
  1016. err = PTR_ERR(dev);
  1017. }
  1018. }
  1019. num_lmc = OCTEON_IS_MODEL(OCTEON_CN68XX) ? 4 :
  1020. (OCTEON_IS_MODEL(OCTEON_CN56XX) ? 2 : 1);
  1021. for (i = 0; i < num_lmc; i++) {
  1022. dev = platform_device_register_simple("octeon_lmc_edac",
  1023. i, NULL, 0);
  1024. if (IS_ERR(dev)) {
  1025. pr_err("Registation of octeon_lmc_edac %d failed!\n", i);
  1026. err = PTR_ERR(dev);
  1027. }
  1028. }
  1029. return err;
  1030. }
  1031. device_initcall(edac_devinit);