Path: blob/master/arch/mips/pmc-sierra/msp71xx/msp_setup.c
15118 views
/*1* The generic setup file for PMC-Sierra MSP processors2*3* Copyright 2005-2007 PMC-Sierra, Inc,4* Author: Jun Sun, [email protected] or [email protected]5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License as published by the8* Free Software Foundation; either version 2 of the License, or (at your9* option) any later version.10*/1112#include <asm/bootinfo.h>13#include <asm/cacheflush.h>14#include <asm/r4kcache.h>15#include <asm/reboot.h>16#include <asm/time.h>1718#include <msp_prom.h>19#include <msp_regs.h>2021#if defined(CONFIG_PMC_MSP7120_GW)22#include <msp_regops.h>23#define MSP_BOARD_RESET_GPIO 924#endif2526extern void msp_serial_setup(void);27extern void pmctwiled_setup(void);2829#if defined(CONFIG_PMC_MSP7120_EVAL) || \30defined(CONFIG_PMC_MSP7120_GW) || \31defined(CONFIG_PMC_MSP7120_FPGA)32/*33* Performs the reset for MSP7120-based boards34*/35void msp7120_reset(void)36{37void *start, *end, *iptr;38register int i;3940/* Diasble all interrupts */41local_irq_disable();42#ifdef CONFIG_SYS_SUPPORTS_MULTITHREADING43dvpe();44#endif4546/* Cache the reset code of this function */47__asm__ __volatile__ (48" .set push \n"49" .set mips3 \n"50" la %0,startpoint \n"51" la %1,endpoint \n"52" .set pop \n"53: "=r" (start), "=r" (end)54:55);5657for (iptr = (void *)((unsigned int)start & ~(L1_CACHE_BYTES - 1));58iptr < end; iptr += L1_CACHE_BYTES)59cache_op(Fill, iptr);6061__asm__ __volatile__ (62"startpoint: \n"63);6465/* Put the DDRC into self-refresh mode */66DDRC_INDIRECT_WRITE(DDRC_CTL(10), 0xb, 1 << 16);6768/*69* IMPORTANT!70* DO NOT do anything from here on out that might even71* think about fetching from RAM - i.e., don't call any72* non-inlined functions, and be VERY sure that any inline73* functions you do call do NOT access any sort of RAM74* anywhere!75*/7677/* Wait a bit for the DDRC to settle */78for (i = 0; i < 100000000; i++);7980#if defined(CONFIG_PMC_MSP7120_GW)81/*82* Set GPIO 9 HI, (tied to board reset logic)83* GPIO 9 is the 4th GPIO of register 384*85* NOTE: We cannot use the higher-level msp_gpio_mode()/out()86* as GPIO char driver may not be enabled and it would look up87* data inRAM!88*/89set_value_reg32(GPIO_CFG3_REG, 0xf000, 0x8000);90set_reg32(GPIO_DATA3_REG, 8);9192/*93* In case GPIO9 doesn't reset the board (jumper configurable!)94* fallback to device reset below.95*/96#endif97/* Set bit 1 of the MSP7120 reset register */98*RST_SET_REG = 0x00000001;99100__asm__ __volatile__ (101"endpoint: \n"102);103}104#endif105106void msp_restart(char *command)107{108printk(KERN_WARNING "Now rebooting .......\n");109110#if defined(CONFIG_PMC_MSP7120_EVAL) || \111defined(CONFIG_PMC_MSP7120_GW) || \112defined(CONFIG_PMC_MSP7120_FPGA)113msp7120_reset();114#else115/* No chip-specific reset code, just jump to the ROM reset vector */116set_c0_status(ST0_BEV | ST0_ERL);117change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);118flush_cache_all();119write_c0_wired(0);120121__asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));122#endif123}124125void msp_halt(void)126{127printk(KERN_WARNING "\n** You can safely turn off the power\n");128while (1)129/* If possible call official function to get CPU WARs */130if (cpu_wait)131(*cpu_wait)();132else133__asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");134}135136void msp_power_off(void)137{138msp_halt();139}140141void __init plat_mem_setup(void)142{143_machine_restart = msp_restart;144_machine_halt = msp_halt;145pm_power_off = msp_power_off;146}147148extern struct plat_smp_ops msp_smtc_smp_ops;149150void __init prom_init(void)151{152unsigned long family;153unsigned long revision;154155prom_argc = fw_arg0;156prom_argv = (char **)fw_arg1;157prom_envp = (char **)fw_arg2;158159/*160* Someday we can use this with PMON2000 to get a161* platform call prom routines for output etc. without162* having to use grody hacks. For now it's unused.163*164* struct callvectors *cv = (struct callvectors *) fw_arg3;165*/166family = identify_family();167revision = identify_revision();168169switch (family) {170case FAMILY_FPGA:171if (FPGA_IS_MSP4200(revision)) {172/* Old-style revision ID */173mips_machtype = MACH_MSP4200_FPGA;174} else {175mips_machtype = MACH_MSP_OTHER;176}177break;178179case FAMILY_MSP4200:180#if defined(CONFIG_PMC_MSP4200_EVAL)181mips_machtype = MACH_MSP4200_EVAL;182#elif defined(CONFIG_PMC_MSP4200_GW)183mips_machtype = MACH_MSP4200_GW;184#else185mips_machtype = MACH_MSP_OTHER;186#endif187break;188189case FAMILY_MSP4200_FPGA:190mips_machtype = MACH_MSP4200_FPGA;191break;192193case FAMILY_MSP7100:194#if defined(CONFIG_PMC_MSP7120_EVAL)195mips_machtype = MACH_MSP7120_EVAL;196#elif defined(CONFIG_PMC_MSP7120_GW)197mips_machtype = MACH_MSP7120_GW;198#else199mips_machtype = MACH_MSP_OTHER;200#endif201break;202203case FAMILY_MSP7100_FPGA:204mips_machtype = MACH_MSP7120_FPGA;205break;206207default:208/* we don't recognize the machine */209mips_machtype = MACH_UNKNOWN;210panic("***Bogosity factor five***, exiting\n");211break;212}213214prom_init_cmdline();215216prom_meminit();217218/*219* Sub-system setup follows.220* Setup functions can either be called here or using the221* subsys_initcall mechanism (i.e. see msp_pci_setup). The222* order in which they are called can be changed by using the223* link order in arch/mips/pmc-sierra/msp71xx/Makefile.224*225* NOTE: Please keep sub-system specific initialization code226* in separate specific files.227*/228msp_serial_setup();229230#ifdef CONFIG_MIPS_MT_SMP231register_smp_ops(&vsmp_smp_ops);232#endif233234#ifdef CONFIG_MIPS_MT_SMTC235register_smp_ops(&msp_smtc_smp_ops);236#endif237238#ifdef CONFIG_PMCTWILED239/*240* Setup LED states before the subsys_initcall loads other241* dependent drivers/modules.242*/243pmctwiled_setup();244#endif245}246247248