sandpoint.c

来自「linux-2.4.29操作系统的源码」· C语言 代码 · 共 743 行 · 第 1/2 页

C
743
字号
/* * arch/ppc/platforms/sandpoint.c * * Board setup routines for the Motorola SPS Sandpoint Test Platform. * * Author: Mark A. Greer *         mgreer@mvista.com * * 2000-2003 (c) MontaVista, Software, Inc.  This file is licensed under * the terms of the GNU General Public License version 2.  This program * is licensed "as is" without any warranty of any kind, whether express * or implied. *//* * This file adds support for the Motorola SPS Sandpoint Test Platform. * These boards have a PPMC slot for the processor so any combination * of cpu and host bridge can be attached.  This port is for an 8240 PPMC * module from Motorola SPS and other closely related cpu/host bridge * combinations (e.g., 750/755/7400 with MPC107 host bridge). * The sandpoint itself has a Windbond 83c553 (PCI-ISA bridge, 2 DMA ctlrs, 2 * cascaded 8259 interrupt ctlrs, 8254 Timer/Counter, and an IDE ctlr), a * National 87308 (RTC, 2 UARTs, Keyboard & mouse ctlrs, and a floppy ctlr), * and 4 PCI slots (only 2 of which are usable; the other 2 are keyed for 3.3V * but are really 5V). * * The firmware on the sandpoint is called DINK (not my acronym :).  This port * depends on DINK to do some basic initialization (e.g., initialize the memory * ctlr) and to ensure that the processor is using MAP B (CHRP map). * * The switch settings for the Sandpoint board MUST be as follows: * 	S3: down * 	S4: up * 	S5: up * 	S6: down * * 'down' is in the direction from the PCI slots towards the PPMC slot; * 'up' is in the direction from the PPMC slot towards the PCI slots. * Be careful, the way the sandpoint board is installed in XT chasses will * make the directions reversed. * * Since Motorola listened to our suggestions for improvement, we now have * the Sandpoint X3 board.  All of the PCI slots are available, it uses * the serial interrupt interface (just a hardware thing we need to * configure properly). * * Use the default X3 switch settings.  The interrupts are then: *		EPIC	Source *		  0	SIOINT 		(8259, active low) *		  1	PCI #1 *		  2	PCI #2 *		  3	PCI #3 *		  4	PCI #4 *		  7	Winbond INTC	(IDE interrupt) *		  8	Winbond INTD	(IDE interrupt) * * It is important to note that this code only supports the Sandpoint X3 * (all flavors) platform, and it does not support the X2 anymore.  Code * that at one time worked on the X2 can be found at: * ftp://source.mvista.com/pub/linuxppc/obsolete/sandpoint/ */#include <linux/config.h>#include <linux/stddef.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/errno.h>#include <linux/reboot.h>#include <linux/pci.h>#include <linux/kdev_t.h>#include <linux/major.h>#include <linux/blk.h>#include <linux/console.h>#include <linux/delay.h>#include <linux/irq.h>#include <linux/ide.h>#include <linux/irq.h>#include <linux/seq_file.h>#include <linux/serial.h>#include <asm/system.h>#include <asm/pgtable.h>#include <asm/page.h>#include <asm/time.h>#include <asm/dma.h>#include <asm/io.h>#include <asm/machdep.h>#include <asm/prom.h>#include <asm/smp.h>#include <asm/keyboard.h>#include <asm/vga.h>#include <asm/open_pic.h>#include <asm/i8259.h>#include <asm/todc.h>#include <asm/bootinfo.h>#include <asm/mpc10x.h>#include <asm/pci-bridge.h>#include <asm/ppcboot.h>#include "sandpoint_serial.h"extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);extern int pckbd_getkeycode(unsigned int scancode);extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,			   char raw_mode);extern char pckbd_unexpected_up(unsigned char keycode);extern void pckbd_leds(unsigned char leds);extern void pckbd_init_hw(void);extern unsigned char pckbd_sysrq_xlate[128];extern void gen550_progress(char *, unsigned short);extern void gen550_init(int, struct serial_struct *);unsigned char __res[sizeof (bd_t)];static void sandpoint_halt(void);/* * Define all of the IRQ senses and polarities.  Taken from the * Sandpoint X3 User's manual. */static u_char sandpoint_openpic_initsenses[] __initdata = {	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 0: SIOINT */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 2: PCI Slot 1 */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 3: PCI Slot 2 */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 4: PCI Slot 3 */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 5: PCI Slot 4 */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),	/* 8: IDE (INT C) */	(IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE)	/* 9: IDE (INT D) */};/* * Motorola SPS Sandpoint interrupt routing. */static inline intsandpoint_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){	static char pci_irq_table[][4] =	    /*	     *      PCI IDSEL/INTPIN->INTLINE	     *         A   B   C   D	     */	{		{16,  0,  0,  0},	/* IDSEL 11 - i8259 on Windbond */		{ 0,  0,  0,  0},	/* IDSEL 12 - unused */		{17, 18, 19, 20},	/* IDSEL 13 - PCI slot 1 */		{18, 19, 20, 17},	/* IDSEL 14 - PCI slot 2 */		{19, 20, 17, 18},	/* IDSEL 15 - PCI slot 3 */		{20, 17, 18, 19},	/* IDSEL 16 - PCI slot 4 */	};	const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;	return PCI_IRQ_TABLE_LOOKUP;}static void __initsandpoint_setup_winbond_83553(struct pci_controller *hose){	int devfn;	/*	 * Route IDE interrupts directly to the 8259's IRQ 14 & 15.	 * We can't route the IDE interrupt to PCI INTC# or INTD# because those	 * woule interfere with the PMC's INTC# and INTD# lines.	 */	/*	 * Winbond Fcn 0	 */	devfn = PCI_DEVFN(11, 0);	/* IDE Interrupt Routing Control */	early_write_config_byte(hose, 0, devfn, 0x43, 0xef);	/* PCI Interrupt Routing Control */	early_write_config_word(hose, 0, devfn, 0x44, 0x0000);	/* Want ISA memory cycles to be forwarded to PCI bus.	 * ISA-to-PCI Addr Decoder Control.	 */	early_write_config_byte(hose, 0, devfn, 0x48, 0xf0);	/* Enable RTC and Keyboard address locations. */	early_write_config_byte(hose, 0, devfn, 0x4d, 0x00);	/* Enable Port 92.  */	early_write_config_byte(hose, 0, devfn, 0x4e, 0x06);	/*	 * Winbond Fcn 1	 */	devfn = PCI_DEVFN(11, 1);	/* Put IDE controller into native mode (via PIR). */	early_write_config_byte(hose, 0, devfn, 0x09, 0x8f);	/* Init IRQ routing, enable both ports, disable fast 16, via	 * IDE Control/Status Register.	 */	early_write_config_dword(hose, 0, devfn, 0x40, 0x00ff0011);}static void __initsandpoint_find_bridges(void){	struct pci_controller *hose;	hose = pcibios_alloc_controller();	if (!hose)		return;	hose->first_busno = 0;	hose->last_busno = 0xff;	if (mpc10x_bridge_init(hose,			       MPC10X_MEM_MAP_B,			       MPC10X_MEM_MAP_B, MPC10X_MAPB_EUMB_BASE) == 0) {		/* Do early winbond init, then scan PCI bus */		sandpoint_setup_winbond_83553(hose);		hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);		ppc_md.pcibios_fixup = NULL;		ppc_md.pcibios_fixup_bus = NULL;		ppc_md.pci_swizzle = common_swizzle;		ppc_md.pci_map_irq = sandpoint_map_irq;	} else {		if (ppc_md.progress)			ppc_md.progress("Bridge init failed", 0x100);		printk("Host bridge init failed\n");	}	return;}#ifdef CONFIG_SERIALstatic void __initsandpoint_early_serial_map(void){	struct serial_struct serial_req;	/* Setup serial port access */	memset(&serial_req, 0, sizeof (serial_req));	serial_req.baud_base = BASE_BAUD;	serial_req.line = 0;	serial_req.port = 0;	serial_req.irq = 4;	serial_req.flags = ASYNC_BOOT_AUTOCONF;	serial_req.io_type = SERIAL_IO_MEM;	serial_req.iomem_base = (u_char *) SANDPOINT_SERIAL_0;	serial_req.iomem_reg_shift = 0;#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)	gen550_init(0, &serial_req);#endif	if (early_serial_setup(&serial_req) != 0)		printk("Early serial init of port 0 failed\n");	/* Assume early_serial_setup() doesn't modify serial_req */	serial_req.line = 1;	serial_req.port = 1;	serial_req.irq = 3;	/* XXXX */	serial_req.iomem_base = (u_char *) SANDPOINT_SERIAL_1;#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)	gen550_init(1, &serial_req);#endif	if (early_serial_setup(&serial_req) != 0)		printk("Early serial init of port 1 failed\n");}#endifstatic void __initsandpoint_setup_arch(void){	loops_per_jiffy = 100000000 / HZ;#ifdef CONFIG_BLK_DEV_INITRD	if (initrd_start)		ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);	else#endif#ifdef	CONFIG_ROOT_NFS		ROOT_DEV = to_kdev_t(0x00FF);	/* /dev/nfs pseudo device */#else		ROOT_DEV = to_kdev_t(0x0301);	/* /dev/hda1 IDE disk */#endif	/* Lookup PCI host bridges */	sandpoint_find_bridges();#ifdef CONFIG_SERIAL	sandpoint_early_serial_map();#endif#ifdef CONFIG_DUMMY_CONSOLE	conswitchp = &dummy_con;#endif	printk(KERN_INFO "Motorola SPS Sandpoint Test Platform\n");	/* DINK32 12.3 and below do not correctly enable any caches.	 * We will do this now with good known values.  Future versions	 * of DINK32 are supposed to get this correct.	 */	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_SPEC7450)		/* 745x is different.  We only want to pass along enable. */		_set_L2CR(L2CR_L2E);	else if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR)		/* All modules have 1MB of L2.  We also assume that an		 * L2 divisor of 3 will work.		 */		_set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3			  | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);#if 0	/* Untested right now. */	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR) {		/* Magic value. */		_set_L3CR(0x8f032000);	}#endif}#define	SANDPOINT_87308_CFG_ADDR		0x15c#define	SANDPOINT_87308_CFG_DATA		0x15d#define	SANDPOINT_87308_CFG_INB(addr, byte) {				\	outb((addr), SANDPOINT_87308_CFG_ADDR);				\	(byte) = inb(SANDPOINT_87308_CFG_DATA);				\}#define	SANDPOINT_87308_CFG_OUTB(addr, byte) {				\	outb((addr), SANDPOINT_87308_CFG_ADDR);				\	outb((byte), SANDPOINT_87308_CFG_DATA);				\}#define SANDPOINT_87308_SELECT_DEV(dev_num) {				\	SANDPOINT_87308_CFG_OUTB(0x07, (dev_num));			\}#define	SANDPOINT_87308_DEV_ENABLE(dev_num) {				\	SANDPOINT_87308_SELECT_DEV(dev_num);				\	SANDPOINT_87308_CFG_OUTB(0x30, 0x01);				\}/* * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip. */static void __initsandpoint_setup_natl_87308(void){	u_char reg;	/*	 * Enable all the devices on the Super I/O chip.	 */	SANDPOINT_87308_SELECT_DEV(0x00);	/* Select kbd logical device */	SANDPOINT_87308_CFG_OUTB(0xf0, 0x00);	/* Set KBC clock to 8 Mhz */	SANDPOINT_87308_DEV_ENABLE(0x00);	/* Enable keyboard */	SANDPOINT_87308_DEV_ENABLE(0x01);	/* Enable mouse */	SANDPOINT_87308_DEV_ENABLE(0x02);	/* Enable rtc */	SANDPOINT_87308_DEV_ENABLE(0x03);	/* Enable fdc (floppy) */	SANDPOINT_87308_DEV_ENABLE(0x04);	/* Enable parallel */	SANDPOINT_87308_DEV_ENABLE(0x05);	/* Enable UART 2 */	SANDPOINT_87308_CFG_OUTB(0xf0, 0x82);	/* Enable bank select regs */	SANDPOINT_87308_DEV_ENABLE(0x06);	/* Enable UART 1 */	SANDPOINT_87308_CFG_OUTB(0xf0, 0x82);	/* Enable bank select regs */	/* Set up floppy in PS/2 mode */	outb(0x09, SIO_CONFIG_RA);	reg = inb(SIO_CONFIG_RD);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?