Path: blob/master/arch/mips/loongson/lemote-2f/reset.c
10818 views
/* Board-specific reboot/shutdown routines1*2* Copyright (c) 2009 Philippe Vachon <[email protected]>3*4* Copyright (C) 2009 Lemote Inc.5* Author: Wu Zhangjin, [email protected]6*7* This program is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License as published by the9* Free Software Foundation; either version 2 of the License, or (at your10* option) any later version.11*/1213#include <linux/io.h>14#include <linux/delay.h>15#include <linux/types.h>1617#include <asm/bootinfo.h>1819#include <loongson.h>2021#include <cs5536/cs5536.h>22#include "ec_kb3310b.h"2324static void reset_cpu(void)25{26/*27* reset cpu to full speed, this is needed when enabling cpu frequency28* scalling29*/30LOONGSON_CHIPCFG0 |= 0x7;31}3233/* reset support for fuloong2f */3435static void fl2f_reboot(void)36{37reset_cpu();3839/* send a reset signal to south bridge.40*41* NOTE: if enable "Power Management" in kernel, rtl8169 will not reset42* normally with this reset operation and it will not work in PMON, but43* you can type halt command and then reboot, seems the hardware reset44* logic not work normally.45*/46{47u32 hi, lo;48_rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), &hi, &lo);49lo |= 0x00000001;50_wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), hi, lo);51}52}5354static void fl2f_shutdown(void)55{56u32 hi, lo, val;57int gpio_base;5859/* get gpio base */60_rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO), &hi, &lo);61gpio_base = lo & 0xff00;6263/* make cs5536 gpio13 output enable */64val = inl(gpio_base + GPIOL_OUT_EN);65val &= ~(1 << (16 + 13));66val |= (1 << 13);67outl(val, gpio_base + GPIOL_OUT_EN);68mmiowb();69/* make cs5536 gpio13 output low level voltage. */70val = inl(gpio_base + GPIOL_OUT_VAL) & ~(1 << (13));71val |= (1 << (16 + 13));72outl(val, gpio_base + GPIOL_OUT_VAL);73mmiowb();74}7576/* reset support for yeeloong2f and mengloong2f notebook */7778void ml2f_reboot(void)79{80reset_cpu();8182/* sending an reset signal to EC(embedded controller) */83ec_write(REG_RESET, BIT_RESET_ON);84}8586#define yl2f89_reboot ml2f_reboot8788/* menglong(7inches) laptop has different shutdown logic from 8.9inches */89#define EC_SHUTDOWN_IO_PORT_HIGH 0xff2d90#define EC_SHUTDOWN_IO_PORT_LOW 0xff2e91#define EC_SHUTDOWN_IO_PORT_DATA 0xff2f92#define REG_SHUTDOWN_HIGH 0xFC93#define REG_SHUTDOWN_LOW 0x2994#define BIT_SHUTDOWN_ON (1 << 1)9596static void ml2f_shutdown(void)97{98u8 val;99u64 i;100101outb(REG_SHUTDOWN_HIGH, EC_SHUTDOWN_IO_PORT_HIGH);102outb(REG_SHUTDOWN_LOW, EC_SHUTDOWN_IO_PORT_LOW);103mmiowb();104val = inb(EC_SHUTDOWN_IO_PORT_DATA);105outb(val & (~BIT_SHUTDOWN_ON), EC_SHUTDOWN_IO_PORT_DATA);106mmiowb();107/* need enough wait here... how many microseconds needs? */108for (i = 0; i < 0x10000; i++)109delay();110outb(val | BIT_SHUTDOWN_ON, EC_SHUTDOWN_IO_PORT_DATA);111mmiowb();112}113114static void yl2f89_shutdown(void)115{116/* cpu-gpio0 output low */117LOONGSON_GPIODATA &= ~0x00000001;118/* cpu-gpio0 as output */119LOONGSON_GPIOIE &= ~0x00000001;120}121122void mach_prepare_reboot(void)123{124switch (mips_machtype) {125case MACH_LEMOTE_FL2F:126case MACH_LEMOTE_NAS:127case MACH_LEMOTE_LL2F:128fl2f_reboot();129break;130case MACH_LEMOTE_ML2F7:131ml2f_reboot();132break;133case MACH_LEMOTE_YL2F89:134yl2f89_reboot();135break;136default:137break;138}139}140141void mach_prepare_shutdown(void)142{143switch (mips_machtype) {144case MACH_LEMOTE_FL2F:145case MACH_LEMOTE_NAS:146case MACH_LEMOTE_LL2F:147fl2f_shutdown();148break;149case MACH_LEMOTE_ML2F7:150ml2f_shutdown();151break;152case MACH_LEMOTE_YL2F89:153yl2f89_shutdown();154break;155default:156break;157}158}159160161