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>
36 #ifdef CONFIG_CAVIUM_DECODE_RSL
37 extern void cvmx_interrupt_rsl_decode(void);
38 extern int __cvmx_interrupt_ecc_report_single_bit_errors
;
39 extern void cvmx_interrupt_rsl_enable(void);
42 extern struct plat_smp_ops octeon_smp_ops
;
45 extern void pci_console_init(const char *arg
);
48 static unsigned long long MAX_MEMORY
= 512ull << 20;
50 struct octeon_boot_descriptor
*octeon_boot_desc_ptr
;
52 struct cvmx_bootinfo
*octeon_bootinfo
;
53 EXPORT_SYMBOL(octeon_bootinfo
);
55 #ifdef CONFIG_CAVIUM_RESERVE32
56 uint64_t octeon_reserve32_memory
;
57 EXPORT_SYMBOL(octeon_reserve32_memory
);
60 static int octeon_uart
;
62 extern asmlinkage
void handle_int(void);
63 extern asmlinkage
void plat_irq_dispatch(void);
66 * Return non zero if we are currently running in the Octeon simulator
70 int octeon_is_simulation(void)
72 return octeon_bootinfo
->board_type
== CVMX_BOARD_TYPE_SIM
;
74 EXPORT_SYMBOL(octeon_is_simulation
);
77 * Return true if Octeon is in PCI Host mode. This means
78 * Linux can control the PCI bus.
80 * Returns Non zero if Octeon in host mode.
82 int octeon_is_pci_host(void)
85 return octeon_bootinfo
->config_flags
& CVMX_BOOTINFO_CFG_FLAG_PCI_HOST
;
92 * Get the clock rate of Octeon
94 * Returns Clock rate in HZ
96 uint64_t octeon_get_clock_rate(void)
98 if (octeon_is_simulation())
99 octeon_bootinfo
->eclock_hz
= 6000000;
100 return octeon_bootinfo
->eclock_hz
;
102 EXPORT_SYMBOL(octeon_get_clock_rate
);
105 * Write to the LCD display connected to the bootbus. This display
106 * exists on most Cavium evaluation boards. If it doesn't exist, then
107 * this function doesn't do anything.
109 * @s: String to write
111 void octeon_write_lcd(const char *s
)
113 if (octeon_bootinfo
->led_display_base_addr
) {
114 void __iomem
*lcd_address
=
115 ioremap_nocache(octeon_bootinfo
->led_display_base_addr
,
118 for (i
= 0; i
< 8; i
++, s
++) {
120 iowrite8(*s
, lcd_address
+ i
);
122 iowrite8(' ', lcd_address
+ i
);
124 iounmap(lcd_address
);
129 * Return the console uart passed by the bootloader
131 * Returns uart (0 or 1)
133 int octeon_get_boot_uart(void)
136 #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
139 uart
= (octeon_boot_desc_ptr
->flags
& OCTEON_BL_FLAG_CONSOLE_UART1
) ?
146 * Get the coremask Linux was booted on.
150 int octeon_get_boot_coremask(void)
152 return octeon_boot_desc_ptr
->core_mask
;
156 * Check the hardware BIST results for a CPU
158 void octeon_check_cpu_bist(void)
160 const int coreid
= cvmx_get_core_num();
161 unsigned long long mask
;
162 unsigned long long bist_val
;
164 /* Check BIST results for COP0 registers */
165 mask
= 0x1f00000000ull
;
166 bist_val
= read_octeon_c0_icacheerr();
168 pr_err("Core%d BIST Failure: CacheErr(icache) = 0x%llx\n",
171 bist_val
= read_octeon_c0_dcacheerr();
173 pr_err("Core%d L1 Dcache parity error: "
174 "CacheErr(dcache) = 0x%llx\n",
177 mask
= 0xfc00000000000000ull
;
178 bist_val
= read_c0_cvmmemctl();
180 pr_err("Core%d BIST Failure: COP0_CVM_MEM_CTL = 0x%llx\n",
183 write_octeon_c0_dcacheerr(0);
189 * @command: Command to pass to the bootloader. Currently ignored.
191 static void octeon_restart(char *command
)
193 /* Disable all watchdogs before soft reset. They don't get cleared */
196 for_each_online_cpu(cpu
)
197 cvmx_write_csr(CVMX_CIU_WDOGX(cpu_logical_map(cpu
)), 0);
199 cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
204 cvmx_write_csr(CVMX_CIU_SOFT_RST
, 1);
209 * Permanently stop a core.
213 static void octeon_kill_core(void *arg
)
216 if (octeon_is_simulation()) {
217 /* The simulator needs the watchdog to stop for dead cores */
218 cvmx_write_csr(CVMX_CIU_WDOGX(cvmx_get_core_num()), 0);
219 /* A break instruction causes the simulator stop a core */
220 asm volatile ("sync\nbreak");
228 static void octeon_halt(void)
230 smp_call_function(octeon_kill_core
, NULL
, 0);
232 switch (octeon_bootinfo
->board_type
) {
233 case CVMX_BOARD_TYPE_NAO38
:
234 /* Driving a 1 to GPIO 12 shuts off this board */
235 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(12), 1);
236 cvmx_write_csr(CVMX_GPIO_TX_SET
, 0x1000);
239 octeon_write_lcd("PowerOff");
243 octeon_kill_core(NULL
);
247 * Handle all the error condition interrupts that might occur.
250 #ifdef CONFIG_CAVIUM_DECODE_RSL
251 static irqreturn_t
octeon_rlm_interrupt(int cpl
, void *dev_id
)
253 cvmx_interrupt_rsl_decode();
259 * Return a string representing the system type
263 const char *octeon_board_type_string(void)
265 static char name
[80];
266 sprintf(name
, "%s (%s)",
267 cvmx_board_type_to_string(octeon_bootinfo
->board_type
),
268 octeon_model_get_string(read_c0_prid()));
272 const char *get_system_type(void)
273 __attribute__ ((alias("octeon_board_type_string")));
275 void octeon_user_io_init(void)
277 union octeon_cvmemctl cvmmemctl
;
278 union cvmx_iob_fau_timeout fau_timeout
;
279 union cvmx_pow_nw_tim nm_tim
;
282 /* Get the current settings for CP0_CVMMEMCTL_REG */
283 cvmmemctl
.u64
= read_c0_cvmmemctl();
284 /* R/W If set, marked write-buffer entries time out the same
285 * as as other entries; if clear, marked write-buffer entries
286 * use the maximum timeout. */
287 cvmmemctl
.s
.dismarkwblongto
= 1;
288 /* R/W If set, a merged store does not clear the write-buffer
289 * entry timeout state. */
290 cvmmemctl
.s
.dismrgclrwbto
= 0;
291 /* R/W Two bits that are the MSBs of the resultant CVMSEG LM
292 * word location for an IOBDMA. The other 8 bits come from the
293 * SCRADDR field of the IOBDMA. */
294 cvmmemctl
.s
.iobdmascrmsb
= 0;
295 /* R/W If set, SYNCWS and SYNCS only order marked stores; if
296 * clear, SYNCWS and SYNCS only order unmarked
297 * stores. SYNCWSMARKED has no effect when DISSYNCWS is
299 cvmmemctl
.s
.syncwsmarked
= 0;
300 /* R/W If set, SYNCWS acts as SYNCW and SYNCS acts as SYNC. */
301 cvmmemctl
.s
.dissyncws
= 0;
302 /* R/W If set, no stall happens on write buffer full. */
303 if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2
))
304 cvmmemctl
.s
.diswbfst
= 1;
306 cvmmemctl
.s
.diswbfst
= 0;
307 /* R/W If set (and SX set), supervisor-level loads/stores can
308 * use XKPHYS addresses with <48>==0 */
309 cvmmemctl
.s
.xkmemenas
= 0;
311 /* R/W If set (and UX set), user-level loads/stores can use
312 * XKPHYS addresses with VA<48>==0 */
313 cvmmemctl
.s
.xkmemenau
= 0;
315 /* R/W If set (and SX set), supervisor-level loads/stores can
316 * use XKPHYS addresses with VA<48>==1 */
317 cvmmemctl
.s
.xkioenas
= 0;
319 /* R/W If set (and UX set), user-level loads/stores can use
320 * XKPHYS addresses with VA<48>==1 */
321 cvmmemctl
.s
.xkioenau
= 0;
323 /* R/W If set, all stores act as SYNCW (NOMERGE must be set
324 * when this is set) RW, reset to 0. */
325 cvmmemctl
.s
.allsyncw
= 0;
327 /* R/W If set, no stores merge, and all stores reach the
328 * coherent bus in order. */
329 cvmmemctl
.s
.nomerge
= 0;
330 /* R/W Selects the bit in the counter used for DID time-outs 0
331 * = 231, 1 = 230, 2 = 229, 3 = 214. Actual time-out is
332 * between 1x and 2x this interval. For example, with
333 * DIDTTO=3, expiration interval is between 16K and 32K. */
334 cvmmemctl
.s
.didtto
= 0;
335 /* R/W If set, the (mem) CSR clock never turns off. */
336 cvmmemctl
.s
.csrckalwys
= 0;
337 /* R/W If set, mclk never turns off. */
338 cvmmemctl
.s
.mclkalwys
= 0;
339 /* R/W Selects the bit in the counter used for write buffer
340 * flush time-outs (WBFLT+11) is the bit position in an
341 * internal counter used to determine expiration. The write
342 * buffer expires between 1x and 2x this interval. For
343 * example, with WBFLT = 0, a write buffer expires between 2K
344 * and 4K cycles after the write buffer entry is allocated. */
345 cvmmemctl
.s
.wbfltime
= 0;
346 /* R/W If set, do not put Istream in the L2 cache. */
347 cvmmemctl
.s
.istrnol2
= 0;
348 /* R/W The write buffer threshold. */
349 cvmmemctl
.s
.wbthresh
= 10;
350 /* R/W If set, CVMSEG is available for loads/stores in
351 * kernel/debug mode. */
352 #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
353 cvmmemctl
.s
.cvmsegenak
= 1;
355 cvmmemctl
.s
.cvmsegenak
= 0;
357 /* R/W If set, CVMSEG is available for loads/stores in
358 * supervisor mode. */
359 cvmmemctl
.s
.cvmsegenas
= 0;
360 /* R/W If set, CVMSEG is available for loads/stores in user
362 cvmmemctl
.s
.cvmsegenau
= 0;
363 /* R/W Size of local memory in cache blocks, 54 (6912 bytes)
364 * is max legal value. */
365 cvmmemctl
.s
.lmemsz
= CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
;
368 if (smp_processor_id() == 0)
369 pr_notice("CVMSEG size: %d cache lines (%d bytes)\n",
370 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
,
371 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
* 128);
373 write_c0_cvmmemctl(cvmmemctl
.u64
);
375 /* Move the performance counter interrupts to IRQ 6 */
376 cvmctl
= read_c0_cvmctl();
379 write_c0_cvmctl(cvmctl
);
381 /* Set a default for the hardware timeouts */
383 fau_timeout
.s
.tout_val
= 0xfff;
384 /* Disable tagwait FAU timeout */
385 fau_timeout
.s
.tout_enb
= 0;
386 cvmx_write_csr(CVMX_IOB_FAU_TIMEOUT
, fau_timeout
.u64
);
391 cvmx_write_csr(CVMX_POW_NW_TIM
, nm_tim
.u64
);
393 write_octeon_c0_icacheerr(0);
394 write_c0_derraddr1(0);
398 * Early entry point for arch setup
400 void __init
prom_init(void)
402 struct cvmx_sysinfo
*sysinfo
;
403 const int coreid
= cvmx_get_core_num();
406 struct uart_port octeon_port
;
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_GDB_CONSOLE
583 strcat(arcs_cmdline
, " console=gdb");
585 #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
586 strcat(arcs_cmdline
, " console=ttyS0,115200");
588 if (octeon_uart
== 1)
589 strcat(arcs_cmdline
, " console=ttyS1,115200");
591 strcat(arcs_cmdline
, " console=ttyS0,115200");
596 if (octeon_is_simulation()) {
598 * The simulator uses a mtdram device pre filled with
599 * the filesystem. Also specify the calibration delay
600 * to avoid calculating it every time.
602 strcat(arcs_cmdline
, " rw root=1f00"
603 " lpj=60176 slram=root,0x40000000,+1073741824");
606 mips_hpt_frequency
= octeon_get_clock_rate();
608 octeon_init_cvmcount();
610 _machine_restart
= octeon_restart
;
611 _machine_halt
= octeon_halt
;
613 memset(&octeon_port
, 0, sizeof(octeon_port
));
615 * For early_serial_setup we don't set the port type or
618 octeon_port
.flags
= ASYNC_SKIP_TEST
| UPF_SHARE_IRQ
;
619 octeon_port
.iotype
= UPIO_MEM
;
620 /* I/O addresses are every 8 bytes */
621 octeon_port
.regshift
= 3;
622 /* Clock rate of the chip */
623 octeon_port
.uartclk
= mips_hpt_frequency
;
624 octeon_port
.fifosize
= 64;
625 octeon_port
.mapbase
= 0x0001180000000800ull
+ (1024 * octeon_uart
);
626 octeon_port
.membase
= cvmx_phys_to_ptr(octeon_port
.mapbase
);
627 octeon_port
.serial_in
= octeon_serial_in
;
628 octeon_port
.serial_out
= octeon_serial_out
;
629 #ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
630 octeon_port
.line
= 0;
632 octeon_port
.line
= octeon_uart
;
634 octeon_port
.irq
= 42 + octeon_uart
;
635 early_serial_setup(&octeon_port
);
637 octeon_user_io_init();
638 register_smp_ops(&octeon_smp_ops
);
641 void __init
plat_mem_setup(void)
643 uint64_t mem_alloc_size
;
649 /* First add the init memory we will be returning. */
650 memory
= __pa_symbol(&__init_begin
) & PAGE_MASK
;
651 mem_alloc_size
= (__pa_symbol(&__init_end
) & PAGE_MASK
) - memory
;
652 if (mem_alloc_size
> 0) {
653 add_memory_region(memory
, mem_alloc_size
, BOOT_MEM_RAM
);
654 total
+= mem_alloc_size
;
658 * The Mips memory init uses the first memory location for
659 * some memory vectors. When SPARSEMEM is in use, it doesn't
660 * verify that the size is big enough for the final
661 * vectors. Making the smallest chuck 4MB seems to be enough
662 * to consistantly work.
664 mem_alloc_size
= 4 << 20;
665 if (mem_alloc_size
> MAX_MEMORY
)
666 mem_alloc_size
= MAX_MEMORY
;
669 * When allocating memory, we want incrementing addresses from
670 * bootmem_alloc so the code in add_memory_region can merge
671 * regions next to each other.
674 while ((boot_mem_map
.nr_map
< BOOT_MEM_MAP_MAX
)
675 && (total
< MAX_MEMORY
)) {
676 #if defined(CONFIG_64BIT) || defined(CONFIG_64BIT_PHYS_ADDR)
677 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
,
678 __pa_symbol(&__init_end
), -1,
680 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
681 #elif defined(CONFIG_HIGHMEM)
682 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
, 0, 1ull << 31,
684 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
686 memory
= cvmx_bootmem_phy_alloc(mem_alloc_size
, 0, 512 << 20,
688 CVMX_BOOTMEM_FLAG_NO_LOCKING
);
692 * This function automatically merges address
693 * regions next to each other if they are
694 * received in incrementing order.
696 add_memory_region(memory
, mem_alloc_size
, BOOT_MEM_RAM
);
697 total
+= mem_alloc_size
;
702 cvmx_bootmem_unlock();
704 #ifdef CONFIG_CAVIUM_RESERVE32
706 * Now that we've allocated the kernel memory it is safe to
707 * free the reserved region. We free it here so that builtin
708 * drivers can use the memory.
710 if (octeon_reserve32_memory
)
711 cvmx_bootmem_free_named("CAVIUM_RESERVE32");
712 #endif /* CONFIG_CAVIUM_RESERVE32 */
715 panic("Unable to allocate memory from "
716 "cvmx_bootmem_phy_alloc\n");
720 int prom_putchar(char c
)
724 /* Spin until there is room */
726 lsrval
= cvmx_read_csr(CVMX_MIO_UARTX_LSR(octeon_uart
));
727 } while ((lsrval
& 0x20) == 0);
730 cvmx_write_csr(CVMX_MIO_UARTX_THR(octeon_uart
), c
);
734 void prom_free_prom_memory(void)
736 #ifdef CONFIG_CAVIUM_DECODE_RSL
737 cvmx_interrupt_rsl_enable();
739 /* Add an interrupt handler for general failures. */
740 if (request_irq(OCTEON_IRQ_RML
, octeon_rlm_interrupt
, IRQF_SHARED
,
741 "RML/RSL", octeon_rlm_interrupt
)) {
742 panic("Unable to request_irq(OCTEON_IRQ_RML)\n");