PageRenderTime 32ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/mips/loongson/common/reset.c

http://github.com/mirrors/linux
C | 71 lines | 46 code | 12 blank | 13 comment | 2 complexity | 8fb8a26f58043d9c36d49c294cd18863 MD5 | raw file
 1/*
 2 * This program is free software; you can redistribute	it and/or modify it
 3 * under  the terms of	the GNU General	 Public License as published by the
 4 * Free Software Foundation;  either version 2 of the  License, or (at your
 5 * option) any later version.
 6 *
 7 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
 8 * Author: Fuxin Zhang, zhangfx@lemote.com
 9 * Copyright (C) 2009 Lemote, Inc.
10 * Author: Zhangjin Wu, wuzhangjin@gmail.com
11 */
12#include <linux/init.h>
13#include <linux/pm.h>
14
15#include <asm/idle.h>
16#include <asm/reboot.h>
17
18#include <loongson.h>
19
20static inline void loongson_reboot(void)
21{
22#ifndef CONFIG_CPU_JUMP_WORKAROUNDS
23	((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
24#else
25	void (*func)(void);
26
27	func = (void *)ioremap_nocache(LOONGSON_BOOT_BASE, 4);
28
29	__asm__ __volatile__(
30	"	.set	noat						\n"
31	"	jr	%[func]						\n"
32	"	.set	at						\n"
33	: /* No outputs */
34	: [func] "r" (func));
35#endif
36}
37
38static void loongson_restart(char *command)
39{
40	/* do preparation for reboot */
41	mach_prepare_reboot();
42
43	/* reboot via jumping to boot base address */
44	loongson_reboot();
45}
46
47static void loongson_poweroff(void)
48{
49	mach_prepare_shutdown();
50	unreachable();
51}
52
53static void loongson_halt(void)
54{
55	pr_notice("\n\n** You can safely turn off the power now **\n\n");
56	while (1) {
57		if (cpu_wait)
58			cpu_wait();
59	}
60}
61
62static int __init mips_reboot_setup(void)
63{
64	_machine_restart = loongson_restart;
65	_machine_halt = loongson_halt;
66	pm_power_off = loongson_poweroff;
67
68	return 0;
69}
70
71arch_initcall(mips_reboot_setup);