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
6 * Copyright (C) 2004-2007 Cavium Networks
7 * Copyright (C) 2008 Wind River Systems
9 #include <linux/init.h>
10 #include <linux/console.h>
11 #include <linux/delay.h>
12 #include <linux/interrupt.h>
14 #include <linux/serial.h>
15 #include <linux/smp.h>
16 #include <linux/types.h>
17 #include <linux/string.h> /* for memset */
18 #include <linux/tty.h>
19 #include <linux/time.h>
20 #include <linux/platform_device.h>
21 #include <linux/serial_core.h>
22 #include <linux/serial_8250.h>
24 #include <asm/processor.h>
25 #include <asm/reboot.h>
26 #include <asm/smp-ops.h>
27 #include <asm/system.h>
28 #include <asm/irq_cpu.h>
29 #include <asm/mipsregs.h>
30 #include <asm/bootinfo.h>
31 #include <asm/sections.h>
34 #include <asm/octeon/octeon.h>
35 #include <asm/octeon/pci-octeon.h>
37 #ifdef CONFIG_CAVIUM_DECODE_RSL
38 extern void cvmx_interrupt_rsl_decode(void);
39 extern int __cvmx_interrupt_ecc_report_single_bit_errors
;
40 extern void cvmx_interrupt_rsl_enable(void);
43 extern struct plat_smp_ops octeon_smp_ops
;
46 extern void pci_console_init(const char *arg
);
49 static unsigned long long MAX_MEMORY
= 512ull << 20;
51 struct octeon_boot_descriptor
*octeon_boot_desc_ptr
;
53 struct cvmx_bootinfo
*octeon_bootinfo
;
54 EXPORT_SYMBOL(octeon_bootinfo
);
56 #ifdef CONFIG_CAVIUM_RESERVE32
57 uint64_t octeon_reserve32_memory
;
58 EXPORT_SYMBOL(octeon_reserve32_memory
);
61 static int octeon_uart
;
63 extern asmlinkage
void handle_int(void);
64 extern asmlinkage
void plat_irq_dispatch(void);
67 * Return non zero if we are currently running in the Octeon simulator
71 int octeon_is_simulation(void)
73 return octeon_bootinfo
->board_type
== CVMX_BOARD_TYPE_SIM
;
75 EXPORT_SYMBOL(octeon_is_simulation
);
78 * Return true if Octeon is in PCI Host mode. This means
79 * Linux can control the PCI bus.
81 * Returns Non zero if Octeon in host mode.
83 int octeon_is_pci_host(void)
86 return octeon_bootinfo
->config_flags
& CVMX_BOOTINFO_CFG_FLAG_PCI_HOST
;
93 * Get the clock rate of Octeon
95 * Returns Clock rate in HZ
97 uint64_t octeon_get_clock_rate(void)
99 if (octeon_is_simulation())
100 octeon_bootinfo
->eclock_hz
= 6000000;
101 return octeon_bootinfo
->eclock_hz
;
103 EXPORT_SYMBOL(octeon_get_clock_rate
);
106 * Write to the LCD display connected to the bootbus. This display
107 * exists on most Cavium evaluation boards. If it doesn't exist, then
108 * this function doesn't do anything.
110 * @s: String to write
112 void octeon_write_lcd(const char *s
)
114 if (octeon_bootinfo
->led_display_base_addr
) {
115 void __iomem
*lcd_address
=
116 ioremap_nocache(octeon_bootinfo
->led_display_base_addr
,
119 for (i
= 0; i
< 8; i
++, s
++) {
121 iowrite8(*s
, lcd_address
+ i
);
123 iowrite8(' ', lcd_address
+ i
);
125 iounmap(lcd_address
);
130 * Return the console uart passed by the bootloader
132 * Returns uart (0 or 1)
134 int octeon_get_boot_uart(void)
137 #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
140 uart
= (octeon_boot_desc_ptr
->flags
& OCTEON_BL_FLAG_CONSOLE_UART1
) ?
147 * Get the coremask Linux was booted on.
151 int octeon_get_boot_coremask(void)
153 return octeon_boot_desc_ptr
->core_mask
;
157 * Check the hardware BIST results for a CPU
159 void octeon_check_cpu_bist(void)
161 const int coreid
= cvmx_get_core_num();
162 unsigned long long mask
;
163 unsigned long long bist_val
;
165 /* Check BIST results for COP0 registers */
166 mask
= 0x1f00000000ull
;
167 bist_val
= read_octeon_c0_icacheerr();
169 pr_err("Core%d BIST Failure: CacheErr(icache) = 0x%llx\n",
172 bist_val
= read_octeon_c0_dcacheerr();
174 pr_err("Core%d L1 Dcache parity error: "
175 "CacheErr(dcache) = 0x%llx\n",
178 mask
= 0xfc00000000000000ull
;
179 bist_val
= read_c0_cvmmemctl();
181 pr_err("Core%d BIST Failure: COP0_CVM_MEM_CTL = 0x%llx\n",
184 write_octeon_c0_dcacheerr(0);
190 * @command: Command to pass to the bootloader. Currently ignored.
192 static void octeon_restart(char *command
)
194 /* Disable all watchdogs before soft reset. They don't get cleared */
197 for_each_online_cpu(cpu
)
198 cvmx_write_csr(CVMX_CIU_WDOGX(cpu_logical_map(cpu
)), 0);
200 cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
205 cvmx_write_csr(CVMX_CIU_SOFT_RST
, 1);
210 * Permanently stop a core.
214 static void octeon_kill_core(void *arg
)
217 if (octeon_is_simulation()) {
218 /* The simulator needs the watchdog to stop for dead cores */
219 cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
220 /* A break instruction causes the simulator stop a core */
221 asm volatile ("sync\nbreak");
229 static void octeon_halt(void)
231 smp_call_function(octeon_kill_core
, NULL
, 0);
233 switch (octeon_bootinfo
->board_type
) {
234 case CVMX_BOARD_TYPE_NAO38
:
235 /* Driving a 1 to GPIO 12 shuts off this board */
236 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(12), 1);
237 cvmx_write_csr(CVMX_GPIO_TX_SET
, 0x1000);
240 octeon_write_lcd("PowerOff");
244 octeon_kill_core(NULL
);
248 * Handle all the error condition interrupts that might occur.
251 #ifdef CONFIG_CAVIUM_DECODE_RSL
252 static irqreturn_t
octeon_rlm_interrupt(int cpl
, void *dev_id
)
254 cvmx_interrupt_rsl_decode();
260 * Return a string representing the system type
264 const char *octeon_board_type_string(void)
266 static char name
[80];
267 sprintf(name
, "%s (%s)",
268 cvmx_board_type_to_string(octeon_bootinfo
->board_type
),
269 octeon_model_get_string(read_c0_prid()));
273 const char *get_system_type(void)
274 __attribute__ ((alias("octeon_board_type_string")));
276 void octeon_user_io_init(void)
278 union octeon_cvmemctl cvmmemctl
;
279 union cvmx_iob_fau_timeout fau_timeout
;
280 union cvmx_pow_nw_tim nm_tim
;
283 /* Get the current settings for CP0_CVMMEMCTL_REG */
284 cvmmemctl
.u64
= read_c0_cvmmemctl();
285 /* R/W If set, marked write-buffer entries time out the same
286 * as as other entries; if clear, marked write-buffer entries
287 * use the maximum timeout. */
288 cvmmemctl
.s
.dismarkwblongto
= 1;
289 /* R/W If set, a merged store does not clear the write-buffer
290 * entry timeout state. */
291 cvmmemctl
.s
.dismrgclrwbto
= 0;
292 /* R/W Two bits that are the MSBs of the resultant CVMSEG LM
293 * word location for an IOBDMA. The other 8 bits come from the
294 * SCRADDR field of the IOBDMA. */
295 cvmmemctl
.s
.iobdmascrmsb
= 0;
296 /* R/W If set, SYNCWS and SYNCS only order marked stores; if
297 * clear, SYNCWS and SYNCS only order unmarked
298 * stores. SYNCWSMARKED has no effect when DISSYNCWS is
300 cvmmemctl
.s
.syncwsmarked
= 0;
301 /* R/W If set, SYNCWS acts as SYNCW and SYNCS acts as SYNC. */
302 cvmmemctl
.s
.dissyncws
= 0;
303 /* R/W If set, no stall happens on write buffer full. */
304 if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2
))
305 cvmmemctl
.s
.diswbfst
= 1;
307 cvmmemctl
.s
.diswbfst
= 0;
308 /* R/W If set (and SX set), supervisor-level loads/stores can
309 * use XKPHYS addresses with <48>==0 */
310 cvmmemctl
.s
.xkmemenas
= 0;
312 /* R/W If set (and UX set), user-level loads/stores can use
313 * XKPHYS addresses with VA<48>==0 */
314 cvmmemctl
.s
.xkmemenau
= 0;
316 /* R/W If set (and SX set), supervisor-level loads/stores can
317 * use XKPHYS addresses with VA<48>==1 */
318 cvmmemctl
.s
.xkioenas
= 0;
320 /* R/W If set (and UX set), user-level loads/stores can use
321 * XKPHYS addresses with VA<48>==1 */
322 cvmmemctl
.s
.xkioenau
= 0;
324 /* R/W If set, all stores act as SYNCW (NOMERGE must be set
325 * when this is set) RW, reset to 0. */
326 cvmmemctl
.s
.allsyncw
= 0;
328 /* R/W If set, no stores merge, and all stores reach the
329 * coherent bus in order. */
330 cvmmemctl
.s
.nomerge
= 0;
331 /* R/W Selects the bit in the counter used for DID time-outs 0
332 * = 231, 1 = 230, 2 = 229, 3 = 214. Actual time-out is
333 * between 1x and 2x this interval. For example, with
334 * DIDTTO=3, expiration interval is between 16K and 32K. */
335 cvmmemctl
.s
.didtto
= 0;
336 /* R/W If set, the (mem) CSR clock never turns off. */
337 cvmmemctl
.s
.csrckalwys
= 0;
338 /* R/W If set, mclk never turns off. */
339 cvmmemctl
.s
.mclkalwys
= 0;
340 /* R/W Selects the bit in the counter used for write buffer
341 * flush time-outs (WBFLT+11) is the bit position in an
342 * internal counter used to determine expiration. The write
343 * buffer expires between 1x and 2x this interval. For
344 * example, with WBFLT = 0, a write buffer expires between 2K
345 * and 4K cycles after the write buffer entry is allocated. */
346 cvmmemctl
.s
.wbfltime
= 0;
347 /* R/W If set, do not put Istream in the L2 cache. */
348 cvmmemctl
.s
.istrnol2
= 0;
349 /* R/W The write buffer threshold. */
350 cvmmemctl
.s
.wbthresh
= 10;
351 /* R/W If set, CVMSEG is available for loads/stores in
352 * kernel/debug mode. */
353 #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
354 cvmmemctl
.s
.cvmsegenak
= 1;
356 cvmmemctl
.s
.cvmsegenak
= 0;
358 /* R/W If set, CVMSEG is available for loads/stores in
359 * supervisor mode. */
360 cvmmemctl
.s
.cvmsegenas
= 0;
361 /* R/W If set, CVMSEG is available for loads/stores in user
363 cvmmemctl
.s
.cvmsegenau
= 0;
364 /* R/W Size of local memory in cache blocks, 54 (6912 bytes)
365 * is max legal value. */
366 cvmmemctl
.s
.lmemsz
= CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
;
369 if (smp_processor_id() == 0)
370 pr_notice("CVMSEG size: %d cache lines (%d bytes)\n",
371 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
,
372 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
* 128);
374 write_c0_cvmmemctl(cvmmemctl
.u64
);
376 /* Move the performance counter interrupts to IRQ 6 */
377 cvmctl
= read_c0_cvmctl();
380 write_c0_cvmctl(cvmctl
);
382 /* Set a default for the hardware timeouts */
384 fau_timeout
.s
.tout_val
= 0xfff;
385 /* Disable tagwait FAU timeout */
386 fau_timeout
.s
.tout_enb
= 0;
387 cvmx_write_csr(CVMX_IOB_FAU_TIMEOUT
, fau_timeout
.u64
);
392 cvmx_write_csr(CVMX_POW_NW_TIM
, nm_tim
.u64
);
394 write_octeon_c0_icacheerr(0);
395 write_c0_derraddr1(0);
399 * Early entry point for arch setup
401 void __init
prom_init(void)
403 struct cvmx_sysinfo
*sysinfo
;
404 const int coreid
= cvmx_get_core_num();
407 #ifdef CONFIG_CAVIUM_RESERVE32
411 * The bootloader passes a pointer to the boot descriptor in
412 * $a3, this is available as fw_arg3.
414 octeon_boot_desc_ptr
= (struct octeon_boot_descriptor
*)fw_arg3
;
416 cvmx_phys_to_ptr(octeon_boot_desc_ptr
->cvmx_desc_vaddr
);
417 cvmx_bootmem_init(cvmx_phys_to_ptr(octeon_bootinfo
->phy_mem_desc_addr
));
420 * Only enable the LED controller if we're running on a CN38XX, CN58XX,
421 * or CN56XX. The CN30XX and CN31XX don't have an LED controller.
423 if (!octeon_is_simulation() &&
424 octeon_has_feature(OCTEON_FEATURE_LED_CONTROLLER
)) {
425 cvmx_write_csr(CVMX_LED_EN
, 0);
426 cvmx_write_csr(CVMX_LED_PRT
, 0);
427 cvmx_write_csr(CVMX_LED_DBG
, 0);
428 cvmx_write_csr(CVMX_LED_PRT_FMT
, 0);
429 cvmx_write_csr(CVMX_LED_UDD_CNTX(0), 32);
430 cvmx_write_csr(CVMX_LED_UDD_CNTX(1), 32);
431 cvmx_write_csr(CVMX_LED_UDD_DATX(0), 0);
432 cvmx_write_csr(CVMX_LED_UDD_DATX(1), 0);
433 cvmx_write_csr(CVMX_LED_EN
, 1);
435 #ifdef CONFIG_CAVIUM_RESERVE32
437 * We need to temporarily allocate all memory in the reserve32
438 * region. This makes sure the kernel doesn't allocate this
439 * memory when it is getting memory from the
440 * bootloader. Later, after the memory allocations are
441 * complete, the reserve32 will be freed.
443 * Allocate memory for RESERVED32 aligned on 2MB boundary. This
444 * is in case we later use hugetlb entries with it.
446 addr
= cvmx_bootmem_phy_named_block_alloc(CONFIG_CAVIUM_RESERVE32
<< 20,
448 "CAVIUM_RESERVE32", 0);
450 pr_err("Failed to allocate CAVIUM_RESERVE32 memory area\n");
452 octeon_reserve32_memory
= addr
;
455 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2
456 if (cvmx_read_csr(CVMX_L2D_FUS3
) & (3ull << 34)) {
457 pr_info("Skipping L2 locking due to reduced L2 cache size\n");
459 uint32_t ebase
= read_c0_ebase() & 0x3ffff000;
460 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_TLB
462 cvmx_l2c_lock_mem_region(ebase
, 0x100);
464 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_EXCEPTION
465 /* General exception */
466 cvmx_l2c_lock_mem_region(ebase
+ 0x180, 0x80);
468 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_LOW_LEVEL_INTERRUPT
469 /* Interrupt handler */
470 cvmx_l2c_lock_mem_region(ebase
+ 0x200, 0x80);
472 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_INTERRUPT
473 cvmx_l2c_lock_mem_region(__pa_symbol(handle_int
), 0x100);
474 cvmx_l2c_lock_mem_region(__pa_symbol(plat_irq_dispatch
), 0x80);
476 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_MEMCPY
477 cvmx_l2c_lock_mem_region(__pa_symbol(memcpy
), 0x480);
482 sysinfo
= cvmx_sysinfo_get();
483 memset(sysinfo
, 0, sizeof(*sysinfo
));
484 sysinfo
->system_dram_size
= octeon_bootinfo
->dram_size
<< 20;
485 sysinfo
->phy_mem_desc_ptr
=
486 cvmx_phys_to_ptr(octeon_bootinfo
->phy_mem_desc_addr
);
487 sysinfo
->core_mask
= octeon_bootinfo
->core_mask
;
488 sysinfo
->exception_base_addr
= octeon_bootinfo
->exception_base_addr
;
489 sysinfo
->cpu_clock_hz
= octeon_bootinfo
->eclock_hz
;
490 sysinfo
->dram_data_rate_hz
= octeon_bootinfo
->dclock_hz
* 2;
491 sysinfo
->board_type
= octeon_bootinfo
->board_type
;
492 sysinfo
->board_rev_major
= octeon_bootinfo
->board_rev_major
;
493 sysinfo
->board_rev_minor
= octeon_bootinfo
->board_rev_minor
;
494 memcpy(sysinfo
->mac_addr_base
, octeon_bootinfo
->mac_addr_base
,
495 sizeof(sysinfo
->mac_addr_base
));
496 sysinfo
->mac_addr_count
= octeon_bootinfo
->mac_addr_count
;
497 memcpy(sysinfo
->board_serial_number
,
498 octeon_bootinfo
->board_serial_number
,
499 sizeof(sysinfo
->board_serial_number
));
500 sysinfo
->compact_flash_common_base_addr
=
501 octeon_bootinfo
->compact_flash_common_base_addr
;
502 sysinfo
->compact_flash_attribute_base_addr
=
503 octeon_bootinfo
->compact_flash_attribute_base_addr
;
504 sysinfo
->led_display_base_addr
= octeon_bootinfo
->led_display_base_addr
;
505 sysinfo
->dfa_ref_clock_hz
= octeon_bootinfo
->dfa_ref_clock_hz
;
506 sysinfo
->bootloader_config_flags
= octeon_bootinfo
->config_flags
;
509 octeon_check_cpu_bist();
511 octeon_uart
= octeon_get_boot_uart();
514 * Disable All CIU Interrupts. The ones we need will be
515 * enabled later. Read the SUM register so we know the write
518 cvmx_write_csr(CVMX_CIU_INTX_EN0((coreid
* 2)), 0);
519 cvmx_write_csr(CVMX_CIU_INTX_EN0((coreid
* 2 + 1)), 0);
520 cvmx_write_csr(CVMX_CIU_INTX_EN1((coreid
* 2)), 0);
521 cvmx_write_csr(CVMX_CIU_INTX_EN1((coreid
* 2 + 1)), 0);
522 cvmx_read_csr(CVMX_CIU_INTX_SUM0((coreid
* 2)));
525 octeon_write_lcd("LinuxSMP");
527 octeon_write_lcd("Linux");
530 #ifdef CONFIG_CAVIUM_GDB
532 * When debugging the linux kernel, force the cores to enter
533 * the debug exception handler to break in.
535 if (octeon_get_boot_debug_flag()) {
536 cvmx_write_csr(CVMX_CIU_DINT
, 1 << cvmx_get_core_num());
537 cvmx_read_csr(CVMX_CIU_DINT
);
542 * BIST should always be enabled when doing a soft reset. L2
543 * Cache locking for instance is not cleared unless BIST is
544 * enabled. Unfortunately due to a chip errata G-200 for
545 * Cn38XX and CN31XX, BIST msut be disabled on these parts.
547 if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2
) ||
548 OCTEON_IS_MODEL(OCTEON_CN31XX
))
549 cvmx_write_csr(CVMX_CIU_SOFT_BIST
, 0);
551 cvmx_write_csr(CVMX_CIU_SOFT_BIST
, 1);
553 /* Default to 64MB in the simulator to speed things up */
554 if (octeon_is_simulation())
555 MAX_MEMORY
= 64ull << 20;
558 argc
= octeon_boot_desc_ptr
->argc
;
559 for (i
= 0; i
< argc
; i
++) {
561 cvmx_phys_to_ptr(octeon_boot_desc_ptr
->argv
[i
]);
562 if ((strncmp(arg
, "MEM=", 4) == 0) ||
563 (strncmp(arg
, "mem=", 4) == 0)) {
564 sscanf(arg
+ 4, "%llu", &MAX_MEMORY
);
567 MAX_MEMORY
= 32ull << 30;
568 } else if (strcmp(arg
, "ecc_verbose") == 0) {
569 #ifdef CONFIG_CAVIUM_REPORT_SINGLE_BIT_ECC
570 __cvmx_interrupt_ecc_report_single_bit_errors
= 1;
571 pr_notice("Reporting of single bit ECC errors is "
574 } else if (strlen(arcs_cmdline
) + strlen(arg
) + 1 <
575 sizeof(arcs_cmdline
) - 1) {
576 strcat(arcs_cmdline
, " ");
577 strcat(arcs_cmdline
, arg
);
581 if (strstr(arcs_cmdline
, "console=") == NULL
) {
582 #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
583 strcat(arcs_cmdline
, " console=ttyS0,115200");
585 if (octeon_uart
== 1)
586 strcat(arcs_cmdline
, " console=ttyS1,115200");
588 strcat(arcs_cmdline
, " console=ttyS0,115200");
592 if (octeon_is_simulation()) {
594 * The simulator uses a mtdram device pre filled with
595 * the filesystem. Also specify the calibration delay
596 * to avoid calculating it every time.
598 strcat(arcs_cmdline
, " rw root=1f00 slram=root,0x40000000,+1073741824");
601 mips_hpt_frequency
= octeon_get_clock_rate();
603 octeon_init_cvmcount();
604 octeon_setup_delays();
606 _machine_restart
= octeon_restart
;
607 _machine_halt
= octeon_halt
;
609 octeon_user_io_init();
610 register_smp_ops(&octeon_smp_ops
);
613 /* Exclude a single page from the regions obtained in plat_mem_setup. */
614 static __init
void memory_exclude_page(u64 addr
, u64
*mem
, u64
*size
)
616 if (addr
> *mem
&& addr
< *mem
+ *size
) {
617 u64 inc
= addr
- *mem
;
618 add_memory_region(*mem
, inc
, BOOT_MEM_RAM
);
623 if (addr
== *mem
&& *size
> PAGE_SIZE
) {
629 void __init
plat_mem_setup(void)
631 uint64_t mem_alloc_size
;
637 /* First add the init memory we will be returning. */
638 memory
= __pa_symbol(&__init_begin
) & PAGE_MASK
;
639 mem_alloc_size
= (__pa_symbol(&__init_end
) & PAGE_MASK
) - memory
;
640 if (mem_alloc_size
> 0) {
641 add_memory_region(memory
, mem_alloc_size
, BOOT_MEM_RAM
);
642 total
+= mem_alloc_size
;
646 * The Mips memory init uses the first memory location for
647 * some memory vectors. When SPARSEMEM is in use, it doesn't
648 * verify that the size is big enough for the final
649 * vectors. Making the smallest chuck 4MB seems to be enough
650 * to consistantly work.
652 mem_alloc_size
= 4 << 20;
653 if (mem_alloc_size
> MAX_MEMORY
)
654 mem_alloc_size
= MAX_MEMORY
;
657 * When allocating memory, we want incrementing addresses from
658 * bootmem_alloc so the code in add_memory_region can merge
659 * regions next to each other.
662 while ((boot_mem_map
.nr_map
< BOOT_MEM_MAP_MAX
)
663 && (total
< MAX_MEMORY
)) {
664 #if defined(CONFIG_64BIT) || defined(CONFIG_64BIT_PHYS_ADDR)
665 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
,
666 __pa_symbol(&__init_end
), -1,
668 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
669 #elif defined(CONFIG_HIGHMEM)
670 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
, 0, 1ull << 31,
672 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
674 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
, 0, 512 << 20,
676 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
679 u64 size
= mem_alloc_size
;
682 * exclude a page at the beginning and end of
683 * the 256MB PCIe 'hole' so the kernel will not
684 * try to allocate multi-page buffers that
685 * span the discontinuity.
687 memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE
,
689 memory_exclude_page(CVMX_PCIE_BAR1_PHYS_BASE
+
690 CVMX_PCIE_BAR1_PHYS_SIZE
,
694 * This function automatically merges address
695 * regions next to each other if they are
696 * received in incrementing order.
699 add_memory_region(memory
, size
, BOOT_MEM_RAM
);
700 total
+= mem_alloc_size
;
705 cvmx_bootmem_unlock();
707 #ifdef CONFIG_CAVIUM_RESERVE32
709 * Now that we've allocated the kernel memory it is safe to
710 * free the reserved region. We free it here so that builtin
711 * drivers can use the memory.
713 if (octeon_reserve32_memory
)
714 cvmx_bootmem_free_named("CAVIUM_RESERVE32");
715 #endif /* CONFIG_CAVIUM_RESERVE32 */
718 panic("Unable to allocate memory from "
719 "cvmx_bootmem_phy_alloc\n");
723 * Emit one character to the boot UART. Exported for use by the
726 int prom_putchar(char c
)
730 /* Spin until there is room */
732 lsrval
= cvmx_read_csr(CVMX_MIO_UARTX_LSR(octeon_uart
));
733 } while ((lsrval
& 0x20) == 0);
736 cvmx_write_csr(CVMX_MIO_UARTX_THR(octeon_uart
), c
& 0xffull
);
739 EXPORT_SYMBOL(prom_putchar
);
741 void prom_free_prom_memory(void)
743 #ifdef CONFIG_CAVIUM_DECODE_RSL
744 cvmx_interrupt_rsl_enable();
746 /* Add an interrupt handler for general failures. */
747 if (request_irq(OCTEON_IRQ_RML
, octeon_rlm_interrupt
, IRQF_SHARED
,
748 "RML/RSL", octeon_rlm_interrupt
)) {
749 panic("Unable to request_irq(OCTEON_IRQ_RML)\n");