18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/init.h> 108c2ecf20Sopenharmony_ci#include <linux/memblock.h> 118c2ecf20Sopenharmony_ci#include <linux/smp.h> 128c2ecf20Sopenharmony_ci#include <asm/bootinfo.h> 138c2ecf20Sopenharmony_ci#include <asm/bmips.h> 148c2ecf20Sopenharmony_ci#include <asm/smp-ops.h> 158c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 168c2ecf20Sopenharmony_ci#include <bcm63xx_board.h> 178c2ecf20Sopenharmony_ci#include <bcm63xx_cpu.h> 188c2ecf20Sopenharmony_ci#include <bcm63xx_io.h> 198c2ecf20Sopenharmony_ci#include <bcm63xx_regs.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_civoid __init prom_init(void) 228c2ecf20Sopenharmony_ci{ 238c2ecf20Sopenharmony_ci u32 reg, mask; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci bcm63xx_cpu_init(); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci /* stop any running watchdog */ 288c2ecf20Sopenharmony_ci bcm_wdt_writel(WDT_STOP_1, WDT_CTL_REG); 298c2ecf20Sopenharmony_ci bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci /* disable all hardware blocks clock for now */ 328c2ecf20Sopenharmony_ci if (BCMCPU_IS_3368()) 338c2ecf20Sopenharmony_ci mask = CKCTL_3368_ALL_SAFE_EN; 348c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6328()) 358c2ecf20Sopenharmony_ci mask = CKCTL_6328_ALL_SAFE_EN; 368c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6338()) 378c2ecf20Sopenharmony_ci mask = CKCTL_6338_ALL_SAFE_EN; 388c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6345()) 398c2ecf20Sopenharmony_ci mask = CKCTL_6345_ALL_SAFE_EN; 408c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6348()) 418c2ecf20Sopenharmony_ci mask = CKCTL_6348_ALL_SAFE_EN; 428c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6358()) 438c2ecf20Sopenharmony_ci mask = CKCTL_6358_ALL_SAFE_EN; 448c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6362()) 458c2ecf20Sopenharmony_ci mask = CKCTL_6362_ALL_SAFE_EN; 468c2ecf20Sopenharmony_ci else if (BCMCPU_IS_6368()) 478c2ecf20Sopenharmony_ci mask = CKCTL_6368_ALL_SAFE_EN; 488c2ecf20Sopenharmony_ci else 498c2ecf20Sopenharmony_ci mask = 0; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci reg = bcm_perf_readl(PERF_CKCTL_REG); 528c2ecf20Sopenharmony_ci reg &= ~mask; 538c2ecf20Sopenharmony_ci bcm_perf_writel(reg, PERF_CKCTL_REG); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci /* do low level board init */ 568c2ecf20Sopenharmony_ci board_prom_init(); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci /* set up SMP */ 598c2ecf20Sopenharmony_ci if (!register_bmips_smp_ops()) { 608c2ecf20Sopenharmony_ci /* 618c2ecf20Sopenharmony_ci * BCM6328 might not have its second CPU enabled, while BCM3368 628c2ecf20Sopenharmony_ci * and BCM6358 need special handling for their shared TLB, so 638c2ecf20Sopenharmony_ci * disable SMP for now. 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci if (BCMCPU_IS_6328()) { 668c2ecf20Sopenharmony_ci reg = bcm_readl(BCM_6328_OTP_BASE + 678c2ecf20Sopenharmony_ci OTP_USER_BITS_6328_REG(3)); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci if (reg & OTP_6328_REG3_TP1_DISABLED) 708c2ecf20Sopenharmony_ci bmips_smp_enabled = 0; 718c2ecf20Sopenharmony_ci } else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) { 728c2ecf20Sopenharmony_ci bmips_smp_enabled = 0; 738c2ecf20Sopenharmony_ci } 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci if (!bmips_smp_enabled) 768c2ecf20Sopenharmony_ci return; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci /* 798c2ecf20Sopenharmony_ci * The bootloader has set up the CPU1 reset vector at 808c2ecf20Sopenharmony_ci * 0xa000_0200. 818c2ecf20Sopenharmony_ci * This conflicts with the special interrupt vector (IV). 828c2ecf20Sopenharmony_ci * The bootloader has also set up CPU1 to respond to the wrong 838c2ecf20Sopenharmony_ci * IPI interrupt. 848c2ecf20Sopenharmony_ci * Here we will start up CPU1 in the background and ask it to 858c2ecf20Sopenharmony_ci * reconfigure itself then go back to sleep. 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_ci memcpy((void *)0xa0000200, bmips_smp_movevec, 0x20); 888c2ecf20Sopenharmony_ci __sync(); 898c2ecf20Sopenharmony_ci set_c0_cause(C_SW0); 908c2ecf20Sopenharmony_ci cpumask_set_cpu(1, &bmips_booted_mask); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* 938c2ecf20Sopenharmony_ci * FIXME: we really should have some sort of hazard barrier here 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_ci } 968c2ecf20Sopenharmony_ci} 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_civoid __init prom_free_prom_memory(void) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci} 101