Path: blob/master/arch/mips/pmc-sierra/yosemite/prom.c
15118 views
/*1* This program is free software; you can redistribute it and/or modify it2* under the terms of the GNU General Public License as published by the3* Free Software Foundation; either version 2 of the License, or (at your4* option) any later version.5*6* Copyright (C) 2003, 2004 PMC-Sierra Inc.7* Author: Manish Lachwani ([email protected])8* Copyright (C) 2004 Ralf Baechle9*/10#include <linux/init.h>11#include <linux/sched.h>12#include <linux/mm.h>13#include <linux/delay.h>14#include <linux/pm.h>15#include <linux/smp.h>1617#include <asm/io.h>18#include <asm/pgtable.h>19#include <asm/processor.h>20#include <asm/reboot.h>21#include <asm/smp-ops.h>22#include <asm/system.h>23#include <asm/bootinfo.h>24#include <asm/pmon.h>2526#ifdef CONFIG_SMP27extern void prom_grab_secondary(void);28#else29#define prom_grab_secondary() do { } while (0)30#endif3132#include "setup.h"3334struct callvectors *debug_vectors;3536extern unsigned long yosemite_base;37extern unsigned long cpu_clock_freq;3839const char *get_system_type(void)40{41return "PMC-Sierra Yosemite";42}4344static void prom_cpu0_exit(void *arg)45{46void *nvram = (void *) YOSEMITE_RTC_BASE;4748/* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */49writeb(0x84, nvram + 0xff7);5051/* wait for the watchdog to go off */52mdelay(100 + (1000 / 16));5354/* if the watchdog fails for some reason, let people know */55printk(KERN_NOTICE "Watchdog reset failed\n");56}5758/*59* Reset the NVRAM over the local bus60*/61static void prom_exit(void)62{63#ifdef CONFIG_SMP64if (smp_processor_id())65/* CPU 1 */66smp_call_function(prom_cpu0_exit, NULL, 1);67#endif68prom_cpu0_exit(NULL);69}7071/*72* Halt the system73*/74static void prom_halt(void)75{76printk(KERN_NOTICE "\n** You can safely turn off the power\n");77while (1)78__asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");79}8081extern struct plat_smp_ops yos_smp_ops;8283/*84* Init routine which accepts the variables from PMON85*/86void __init prom_init(void)87{88int argc = fw_arg0;89char **arg = (char **) fw_arg1;90char **env = (char **) fw_arg2;91struct callvectors *cv = (struct callvectors *) fw_arg3;92int i = 0;9394/* Callbacks for halt, restart */95_machine_restart = (void (*)(char *)) prom_exit;96_machine_halt = prom_halt;97pm_power_off = prom_halt;9899debug_vectors = cv;100arcs_cmdline[0] = '\0';101102/* Get the boot parameters */103for (i = 1; i < argc; i++) {104if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >=105sizeof(arcs_cmdline))106break;107108strcat(arcs_cmdline, arg[i]);109strcat(arcs_cmdline, " ");110}111112#ifdef CONFIG_SERIAL_8250_CONSOLE113if ((strstr(arcs_cmdline, "console=ttyS")) == NULL)114strcat(arcs_cmdline, "console=ttyS0,115200");115#endif116117while (*env) {118if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0)119yosemite_base =120simple_strtol(*env + strlen("ocd_base="), NULL,12116);122123if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)124cpu_clock_freq =125simple_strtol(*env + strlen("cpuclock="), NULL,12610);127128env++;129}130131prom_grab_secondary();132133register_smp_ops(&yos_smp_ops);134}135136void __init prom_free_prom_memory(void)137{138}139140void __init prom_fixup_mem_map(unsigned long start, unsigned long end)141{142}143144145