1e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon/* 2e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon * This file is subject to the terms and conditions of the GNU General Public 3e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon * License. See the file "COPYING" in the main directory of this archive 4e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon * for more details. 5e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon * 6e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 7e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon */ 8e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 9e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <linux/init.h> 10e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <linux/bootmem.h> 11a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee#include <linux/smp.h> 12e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <asm/bootinfo.h> 13a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee#include <asm/bmips.h> 14a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee#include <asm/smp-ops.h> 15a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee#include <asm/mipsregs.h> 16e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <bcm63xx_board.h> 17e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <bcm63xx_cpu.h> 18e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <bcm63xx_io.h> 19e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <bcm63xx_regs.h> 20e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon#include <bcm63xx_gpio.h> 21e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 22e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizonvoid __init prom_init(void) 23e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon{ 24e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon u32 reg, mask; 25e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 26e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon bcm63xx_cpu_init(); 27e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 28e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon /* stop any running watchdog */ 29e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon bcm_wdt_writel(WDT_STOP_1, WDT_CTL_REG); 30e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG); 31e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 32e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon /* disable all hardware blocks clock for now */ 337b9334215f53135fb9cbdf0b44833cbc8e7d57b2Florian Fainelli if (BCMCPU_IS_3368()) 347b9334215f53135fb9cbdf0b44833cbc8e7d57b2Florian Fainelli mask = CKCTL_3368_ALL_SAFE_EN; 357b9334215f53135fb9cbdf0b44833cbc8e7d57b2Florian Fainelli else if (BCMCPU_IS_6328()) 36e5766aea5b9b7519654261c27b639f567b5415b4Jonas Gorski mask = CKCTL_6328_ALL_SAFE_EN; 37e5766aea5b9b7519654261c27b639f567b5415b4Jonas Gorski else if (BCMCPU_IS_6338()) 38e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon mask = CKCTL_6338_ALL_SAFE_EN; 39e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon else if (BCMCPU_IS_6345()) 40e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon mask = CKCTL_6345_ALL_SAFE_EN; 41e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon else if (BCMCPU_IS_6348()) 42e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon mask = CKCTL_6348_ALL_SAFE_EN; 4304712f3ff6e3a42ef658b55b0f99478f4f0682e3Maxime Bizon else if (BCMCPU_IS_6358()) 44e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon mask = CKCTL_6358_ALL_SAFE_EN; 452c8aaf71b0a4738ae8cb70d9367089bdb892aea3Jonas Gorski else if (BCMCPU_IS_6362()) 462c8aaf71b0a4738ae8cb70d9367089bdb892aea3Jonas Gorski mask = CKCTL_6362_ALL_SAFE_EN; 4704712f3ff6e3a42ef658b55b0f99478f4f0682e3Maxime Bizon else if (BCMCPU_IS_6368()) 4804712f3ff6e3a42ef658b55b0f99478f4f0682e3Maxime Bizon mask = CKCTL_6368_ALL_SAFE_EN; 4904712f3ff6e3a42ef658b55b0f99478f4f0682e3Maxime Bizon else 5004712f3ff6e3a42ef658b55b0f99478f4f0682e3Maxime Bizon mask = 0; 51e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 52e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon reg = bcm_perf_readl(PERF_CKCTL_REG); 53e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon reg &= ~mask; 54e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon bcm_perf_writel(reg, PERF_CKCTL_REG); 55e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 56e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon /* register gpiochip */ 57e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon bcm63xx_gpio_init(); 58e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 59e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon /* do low level board init */ 60e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon board_prom_init(); 61a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee 6210102692803530025ee7862e9df300b88187cfd0Jonas Gorski /* set up SMP */ 6310102692803530025ee7862e9df300b88187cfd0Jonas Gorski if (!register_bmips_smp_ops()) { 64a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee /* 650e983d7b90e1272cde588529453fec1ceb822e4cJonas Gorski * BCM6328 might not have its second CPU enabled, while BCM3368 660e983d7b90e1272cde588529453fec1ceb822e4cJonas Gorski * and BCM6358 need special handling for their shared TLB, so 670e983d7b90e1272cde588529453fec1ceb822e4cJonas Gorski * disable SMP for now. 68a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee */ 69a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee if (BCMCPU_IS_6328()) { 707ac836ce2aa7b931f6347e554cb65f9e9cc1da57Jonas Gorski reg = bcm_readl(BCM_6328_OTP_BASE + 717ac836ce2aa7b931f6347e554cb65f9e9cc1da57Jonas Gorski OTP_USER_BITS_6328_REG(3)); 727ac836ce2aa7b931f6347e554cb65f9e9cc1da57Jonas Gorski 737ac836ce2aa7b931f6347e554cb65f9e9cc1da57Jonas Gorski if (reg & OTP_6328_REG3_TP1_DISABLED) 747ac836ce2aa7b931f6347e554cb65f9e9cc1da57Jonas Gorski bmips_smp_enabled = 0; 750e983d7b90e1272cde588529453fec1ceb822e4cJonas Gorski } else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) { 76a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee bmips_smp_enabled = 0; 77a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee } 78a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee 79a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee if (!bmips_smp_enabled) 80a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee return; 81a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee 82a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee /* 83a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * The bootloader has set up the CPU1 reset vector at 84a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * 0xa000_0200. 85a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * This conflicts with the special interrupt vector (IV). 86a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * The bootloader has also set up CPU1 to respond to the wrong 87a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * IPI interrupt. 88a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * Here we will start up CPU1 in the background and ask it to 89a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * reconfigure itself then go back to sleep. 90a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee */ 91a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20); 92a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee __sync(); 93a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee set_c0_cause(C_SW0); 94a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee cpumask_set_cpu(1, &bmips_booted_mask); 95a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee 96a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee /* 97a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee * FIXME: we really should have some sort of hazard barrier here 98a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee */ 99a068dde168e0c618e1dc2151a0922254ec3bbf04Kevin Cernekee } 100e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon} 101e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon 102e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizonvoid __init prom_free_prom_memory(void) 103e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon{ 104e7300d04bd0809eb7ea10a2ed8c729459f816e36Maxime Bizon} 105