sandpoint.c

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

C
743
字号
	reg = (reg & 0x3F) | 0x40;	outb(reg, SIO_CONFIG_RD);	outb(reg, SIO_CONFIG_RD);	/* Have to write twice to change! */	return;}/* * Fix IDE interrupts. */static void __initsandpoint_fix_winbond_83553(void){	/* Make all 8259 interrupt level sensitive */	outb(0xf8, 0x4d0);	outb(0xde, 0x4d1);	return;}static void __initsandpoint_init2(void){	/* Do Sandpoint board specific initialization.  */	sandpoint_fix_winbond_83553();	sandpoint_setup_natl_87308();	request_region(0x00, 0x20, "dma1");	request_region(0x20, 0x20, "pic1");	request_region(0x40, 0x20, "timer");	request_region(0x80, 0x10, "dma page reg");	request_region(0xa0, 0x20, "pic2");	request_region(0xc0, 0x20, "dma2");	return;}/* * Interrupt setup and service.  The i8259 is cascaded from EPIC IRQ0, * IRQ1-4 map to PCI slots 1-4, IDE is on EPIC 7 and 8. */static void __initsandpoint_init_IRQ(void){	int i;	OpenPIC_InitSenses = sandpoint_openpic_initsenses;	OpenPIC_NumInitSenses = sizeof (sandpoint_openpic_initsenses);	/*	 * We need to tell openpic_set_sources where things actually are.	 * mpc10x_common will setup OpenPIC_Addr at ioremap(EUMB phys base +	 * EPIC offset (0x40000));  The EPIC IRQ Register Address Map -	 * Interrupt Source Configuration Registers gives these numbers	 * as offsets starting at 0x50200, we need to adjust occordinly.	 */	/* Map serial interrupt 0 */	openpic_set_sources(0, 1, OpenPIC_Addr + 0x10200);	/* Map serial interrupts 2-5 */	openpic_set_sources(1, 4, OpenPIC_Addr + 0x10240);	/* Map serial interrupts 8-9 */	openpic_set_sources(5, 2, OpenPIC_Addr + 0x10300);	/* Skip reserved space and map i2c and DMA Ch[01] */	openpic_set_sources(7, 3, OpenPIC_Addr + 0x11020);	/* Skip reserved space and map Message Unit Interrupt (I2O) */	openpic_set_sources(10, 1, OpenPIC_Addr + 0x110C0);	openpic_init(NUM_8259_INTERRUPTS);	/* The cascade is on EPIC IRQ 0 (Linux IRQ 16). */	openpic_hookup_cascade(16, "8259 cascade to EPIC", &i8259_irq);	/*	 * openpic_init() has set up irq_desc[0-23] to be openpic	 * interrupts.  We need to set irq_desc[0-15] to be 8259 interrupts.	 * We then need to request and enable the 8259 irq.	 */	for (i = 0; i < NUM_8259_INTERRUPTS; i++)		irq_desc[i].handler = &i8259_pic;	/*	 * The EPIC allows for a read in the range of 0xFEF00000 ->	 * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.	 */	i8259_init(0xfef00000);}static u32sandpoint_irq_cannonicalize(u32 irq){	if (irq == 2)		return 9;	else		return irq;}static unsigned long __initsandpoint_find_end_of_memory(void){	bd_t *bp = (bd_t *) __res;	if (bp->bi_memsize)		return bp->bi_memsize;	/* This might be fixed in DINK32 12.4, or we'll have another	 * way to determine the correct memory size anyhow. */	/* return mpc10x_get_mem_size(MPC10X_MEM_MAP_B); */	return 32 * 1024 * 1024;}static void __initsandpoint_map_io(void){	io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);}static voidsandpoint_restart(char *cmd){	__cli();	/* Set exception prefix high - to the firmware */	_nmask_and_or_msr(0, MSR_IP);	/* Reset system via Port 92 */	outb(0x00, 0x92);	outb(0x01, 0x92);	for (;;) ;		/* Spin until reset happens */}static voidsandpoint_power_off(void){	__cli();	for (;;) ;		/* No way to shut power off with software */	/* NOTREACHED */}static voidsandpoint_halt(void){	sandpoint_power_off();	/* NOTREACHED */}static intsandpoint_show_cpuinfo(struct seq_file *m){	seq_printf(m, "vendor\t\t: Motorola SPS\n");	seq_printf(m, "machine\t\t: Sandpoint\n");	return 0;}#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)/* * IDE support. */static int sandpoint_ide_ports_known = 0;static ide_ioreg_t sandpoint_ide_regbase[MAX_HWIFS];static ide_ioreg_t sandpoint_ide_ctl_regbase[MAX_HWIFS];static ide_ioreg_t sandpoint_idedma_regbase;static voidsandpoint_ide_probe(void){	struct pci_dev *pdev = pci_find_device(PCI_VENDOR_ID_WINBOND,					       PCI_DEVICE_ID_WINBOND_82C105,					       NULL);	if (pdev) {		sandpoint_ide_regbase[0] = pdev->resource[0].start;		sandpoint_ide_regbase[1] = pdev->resource[2].start;		sandpoint_ide_ctl_regbase[0] = pdev->resource[1].start;		sandpoint_ide_ctl_regbase[1] = pdev->resource[3].start;		sandpoint_idedma_regbase = pdev->resource[4].start;	}	sandpoint_ide_ports_known = 1;	return;}/* The Sandpoint X3 allows the IDE interrupt to be directly connected * from the Windbond (PCI INTC or INTD) to the serial EPIC.  Someday * we should try this, but it was easier to use the existing 83c553 * initialization than change it to route the different interrupts :-). *	-- Dan */#if 0#define SANDPOINT_IDE_INT0	23	/* EPIC 7 */#define SANDPOINT_IDE_INT1	24	/* EPIC 8 */#else#define SANDPOINT_IDE_INT0	14	/* 8259 Test */#define SANDPOINT_IDE_INT1	15	/* 8259 Test */#endifstatic intsandpoint_ide_default_irq(ide_ioreg_t base){	if (sandpoint_ide_ports_known == 0)		sandpoint_ide_probe();	if (base == sandpoint_ide_regbase[0])		return SANDPOINT_IDE_INT0;	else if (base == sandpoint_ide_regbase[1])		return SANDPOINT_IDE_INT1;	else		return 0;}static ide_ioreg_tsandpoint_ide_default_io_base(int index){	if (sandpoint_ide_ports_known == 0)		sandpoint_ide_probe();	return sandpoint_ide_regbase[index];}static void __initsandpoint_ide_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port,			      ide_ioreg_t ctrl_port, int *irq){	ide_ioreg_t reg = data_port;	unsigned int alt_status_base;	int i;	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)		hw->io_ports[i] = reg++;	if (data_port == sandpoint_ide_regbase[0]) {		alt_status_base = sandpoint_ide_ctl_regbase[0] + 2;		hw->irq = 14;	} else if (data_port == sandpoint_ide_regbase[1]) {		alt_status_base = sandpoint_ide_ctl_regbase[1] + 2;		hw->irq = 15;	} else {		alt_status_base = 0;		hw->irq = 0;	}	if (ctrl_port)		hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;	else		hw->io_ports[IDE_CONTROL_OFFSET] = alt_status_base;	if (irq != NULL)		*irq = hw->irq;	return;}#endif/* * Set BAT 3 to map 0xf8000000 to end of physical memory space 1-to-1. */static __inline__ voidsandpoint_set_bat(void){#if 1	mb();	mtspr(DBAT1U, 0xf8000ffe);	mtspr(DBAT1L, 0xf800002a);	mb();#else	unsigned long bat3u, bat3l;	__asm__ __volatile__(" lis %0,0xf800\n	\			ori %1,%0,0x002a\n	\			ori %0,%0,0x0ffe\n	\			mtspr 0x21e,%0\n	\			mtspr 0x21f,%1\n	\			isync\n			\			sync ":"=r"(bat3u), "=r"(bat3l));#endif}TODC_ALLOC();void __initplatform_init(unsigned long r3, unsigned long r4, unsigned long r5,	      unsigned long r6, unsigned long r7){	parse_bootinfo(find_bootinfo());	/* ASSUMPTION:  If both r3 (bd_t pointer) and r6 (cmdline pointer)	 * are non-zero, then we should use the board info from the bd_t	 * structure and the cmdline pointed to by r6 instead of the	 * information from birecs, if any.  Otherwise, use the information	 * from birecs as discovered by the preceeding call to	 * parse_bootinfo().  This rule should work with both PPCBoot, which	 * uses a bd_t board info structure, and the kernel boot wrapper,	 * which uses birecs.	 */	if (r3 && r6) {		/* copy board info structure */		memcpy((void *) __res, (void *) (r3 + KERNELBASE),		       sizeof (bd_t));		/* copy command line */		*(char *) (r7 + KERNELBASE) = 0;		strcpy(cmd_line, (char *) (r6 + KERNELBASE));	}#ifdef CONFIG_BLK_DEV_INITRD	/* take care of initrd if we have one */	if (r4) {		initrd_start = r4 + KERNELBASE;		initrd_end = r5 + KERNELBASE;	}#endif				/* CONFIG_BLK_DEV_INITRD */	/* Map in board regs, etc. */	sandpoint_set_bat();	isa_io_base = MPC10X_MAPB_ISA_IO_BASE;	isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;	pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;	ISA_DMA_THRESHOLD = 0x00ffffff;	DMA_MODE_READ = 0x44;	DMA_MODE_WRITE = 0x48;	ppc_md.setup_arch = sandpoint_setup_arch;	ppc_md.show_cpuinfo = sandpoint_show_cpuinfo;	ppc_md.irq_cannonicalize = sandpoint_irq_cannonicalize;	ppc_md.init_IRQ = sandpoint_init_IRQ;	ppc_md.get_irq = openpic_get_irq;	ppc_md.init = sandpoint_init2;	ppc_md.restart = sandpoint_restart;	ppc_md.power_off = sandpoint_power_off;	ppc_md.halt = sandpoint_halt;	ppc_md.find_end_of_memory = sandpoint_find_end_of_memory;	ppc_md.setup_io_mappings = sandpoint_map_io;	TODC_INIT(TODC_TYPE_PC97307, 0x70, 0x00, 0x71, 8);	ppc_md.time_init = todc_time_init;	ppc_md.set_rtc_time = todc_set_rtc_time;	ppc_md.get_rtc_time = todc_get_rtc_time;	ppc_md.calibrate_decr = todc_calibrate_decr;	ppc_md.nvram_read_val = todc_mc146818_read_val;	ppc_md.nvram_write_val = todc_mc146818_write_val;#ifdef CONFIG_SERIAL#ifdef CONFIG_SERIAL_TEXT_DEBUG	ppc_md.progress = gen550_progress;#endif	ppc_md.early_serial_map = sandpoint_early_serial_map;#endif#ifdef CONFIG_VT	ppc_md.kbd_setkeycode = pckbd_setkeycode;	ppc_md.kbd_getkeycode = pckbd_getkeycode;	ppc_md.kbd_translate = pckbd_translate;	ppc_md.kbd_unexpected_up = pckbd_unexpected_up;	ppc_md.kbd_leds = pckbd_leds;	ppc_md.kbd_init_hw = pckbd_init_hw;#ifdef CONFIG_MAGIC_SYSRQ	ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate;	SYSRQ_KEY = 0x54;#endif#endif#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)	ppc_ide_md.default_irq = sandpoint_ide_default_irq;	ppc_ide_md.default_io_base = sandpoint_ide_default_io_base;	ppc_ide_md.ide_init_hwif = sandpoint_ide_init_hwif_ports;#endif	return;}

⌨️ 快捷键说明

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