Path: blob/master/arch/mips/mti-malta/malta-setup.c
10817 views
/*1* Carsten Langgaard, [email protected]2* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.3* Copyright (C) 2008 Dmitri Vorobiev4*5* This program is free software; you can distribute it and/or modify it6* under the terms of the GNU General Public License (Version 2) as7* published by the Free Software Foundation.8*9* This program is distributed in the hope it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* for more details.13*14* You should have received a copy of the GNU General Public License along15* with this program; if not, write to the Free Software Foundation, Inc.,16* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.17*/18#include <linux/cpu.h>19#include <linux/init.h>20#include <linux/sched.h>21#include <linux/ioport.h>22#include <linux/irq.h>23#include <linux/pci.h>24#include <linux/screen_info.h>25#include <linux/time.h>2627#include <asm/bootinfo.h>28#include <asm/mips-boards/generic.h>29#include <asm/mips-boards/prom.h>30#include <asm/mips-boards/malta.h>31#include <asm/mips-boards/maltaint.h>32#include <asm/dma.h>33#include <asm/traps.h>34#ifdef CONFIG_VT35#include <linux/console.h>36#endif3738extern void malta_be_init(void);39extern int malta_be_handler(struct pt_regs *regs, int is_fixup);4041static struct resource standard_io_resources[] = {42{43.name = "dma1",44.start = 0x00,45.end = 0x1f,46.flags = IORESOURCE_BUSY47},48{49.name = "timer",50.start = 0x40,51.end = 0x5f,52.flags = IORESOURCE_BUSY53},54{55.name = "keyboard",56.start = 0x60,57.end = 0x6f,58.flags = IORESOURCE_BUSY59},60{61.name = "dma page reg",62.start = 0x80,63.end = 0x8f,64.flags = IORESOURCE_BUSY65},66{67.name = "dma2",68.start = 0xc0,69.end = 0xdf,70.flags = IORESOURCE_BUSY71},72};7374const char *get_system_type(void)75{76return "MIPS Malta";77}7879#if defined(CONFIG_MIPS_MT_SMTC)80const char display_string[] = " SMTC LINUX ON MALTA ";81#else82const char display_string[] = " LINUX ON MALTA ";83#endif /* CONFIG_MIPS_MT_SMTC */8485#ifdef CONFIG_BLK_DEV_FD86static void __init fd_activate(void)87{88/*89* Activate Floppy Controller in the SMSC FDC37M817 Super I/O90* Controller.91* Done by YAMON 2.00 onwards92*/93/* Entering config state. */94SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG);9596/* Activate floppy controller. */97SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG);98SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG);99SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG);100SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG);101102/* Exit config state. */103SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG);104}105#endif106107#ifdef CONFIG_BLK_DEV_IDE108static void __init pci_clock_check(void)109{110unsigned int __iomem *jmpr_p =111(unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));112int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;113static const int pciclocks[] __initdata = {11433, 20, 25, 30, 12, 16, 37, 10115};116int pciclock = pciclocks[jmpr];117char *argptr = prom_getcmdline();118119if (pciclock != 33 && !strstr(argptr, "idebus=")) {120printk(KERN_WARNING "WARNING: PCI clock is %dMHz, "121"setting idebus\n", pciclock);122argptr += strlen(argptr);123sprintf(argptr, " idebus=%d", pciclock);124if (pciclock < 20 || pciclock > 66)125printk(KERN_WARNING "WARNING: IDE timing "126"calculations will be incorrect\n");127}128}129#endif130131#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)132static void __init screen_info_setup(void)133{134screen_info = (struct screen_info) {135.orig_x = 0,136.orig_y = 25,137.ext_mem_k = 0,138.orig_video_page = 0,139.orig_video_mode = 0,140.orig_video_cols = 80,141.unused2 = 0,142.orig_video_ega_bx = 0,143.unused3 = 0,144.orig_video_lines = 25,145.orig_video_isVGA = VIDEO_TYPE_VGAC,146.orig_video_points = 16147};148}149#endif150151static void __init bonito_quirks_setup(void)152{153char *argptr;154155argptr = prom_getcmdline();156if (strstr(argptr, "debug")) {157BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE;158printk(KERN_INFO "Enabled Bonito debug mode\n");159} else160BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE;161162#ifdef CONFIG_DMA_COHERENT163if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) {164BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN;165printk(KERN_INFO "Enabled Bonito CPU coherency\n");166167argptr = prom_getcmdline();168if (strstr(argptr, "iobcuncached")) {169BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;170BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &171~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |172BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);173printk(KERN_INFO "Disabled Bonito IOBC coherency\n");174} else {175BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN;176BONITO_PCIMEMBASECFG |=177(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |178BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);179printk(KERN_INFO "Enabled Bonito IOBC coherency\n");180}181} else182panic("Hardware DMA cache coherency not supported");183#endif184}185186void __init plat_mem_setup(void)187{188unsigned int i;189190mips_pcibios_init();191192/* Request I/O space for devices used on the Malta board. */193for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)194request_resource(&ioport_resource, standard_io_resources+i);195196/*197* Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.198*/199enable_dma(4);200201#ifdef CONFIG_DMA_COHERENT202if (mips_revision_sconid != MIPS_REVISION_SCON_BONITO)203panic("Hardware DMA cache coherency not supported");204#endif205206if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO)207bonito_quirks_setup();208209#ifdef CONFIG_BLK_DEV_IDE210pci_clock_check();211#endif212213#ifdef CONFIG_BLK_DEV_FD214fd_activate();215#endif216217#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)218screen_info_setup();219#endif220221board_be_init = malta_be_init;222board_be_handler = malta_be_handler;223}224225226