⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prep_setup.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * ppc_cs4232_dma and ppc_cs4232_dma2 are used in include/asm/dma.h * to distinguish sound dma-channels from others. This is because * blocksize on 16 bit dma-channels 5,6,7 is 128k, but * the cs4232.c uses 64k like on 8 bit dma-channels 0,1,2,3 */static void __init prep_init_sound(void){	PPC_DEVICE *audiodevice = NULL;	/*	 * Get the needed resource informations from residual data.	 *	 */	if (have_residual_data)		audiodevice = residual_find_device(~0, NULL,				MultimediaController, AudioController, -1, 0);	if (audiodevice != NULL) {		PnP_TAG_PACKET *pkt;		pkt = PnP_find_packet((unsigned char *)&res->DevicePnPHeap[audiodevice->AllocatedOffset],				S5_Packet, 0);		if (pkt != NULL)			ppc_cs4232_dma = masktoint(pkt->S5_Pack.DMAMask);		pkt = PnP_find_packet((unsigned char*)&res->DevicePnPHeap[audiodevice->AllocatedOffset],				S5_Packet, 1);		if (pkt != NULL)			ppc_cs4232_dma2 = masktoint(pkt->S5_Pack.DMAMask);	}	/*	 * These are the PReP specs' defaults for the cs4231.  We use these	 * as fallback incase we don't have residual data.	 * At least the IBM Thinkpad 850 with IDE DMA Channels at 6 and 7	 * will use the other values.	 */	if (audiodevice == NULL) {		switch (_prep_type) {		case _PREP_IBM:			ppc_cs4232_dma = 1;			ppc_cs4232_dma2 = -1;			break;		default:			ppc_cs4232_dma = 6;			ppc_cs4232_dma2 = 7;		}	}	/*	 * Find a way to push these informations to the cs4232 driver	 * Give it out with printk, when not in cmd_line?	 * Append it to  cmd_line and saved_command_line?	 * Format is cs4232=io,irq,dma,dma2	 */}#endif /* CONFIG_SOUND_CS4232 *//* * Fill out screen_info according to the residual data. This allows us to use * at least vesafb. */static void __initprep_init_vesa(void){#if     (defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA16_MODULE) || \	 defined(CONFIG_FB_VESA))	PPC_DEVICE *vgadev = NULL;	if (have_residual_data)		vgadev = residual_find_device(~0, NULL, DisplayController,							SVGAController, -1, 0);	if (vgadev != NULL) {		PnP_TAG_PACKET *pkt;		pkt = PnP_find_large_vendor_packet(				(unsigned char *)&res->DevicePnPHeap[vgadev->AllocatedOffset],				0x04, 0); /* 0x04 = Display Tag */		if (pkt != NULL) {			unsigned char *ptr = (unsigned char *)pkt;			if (ptr[4]) {				/* graphics mode */				screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB;				screen_info.lfb_depth = ptr[4] * 8;				screen_info.lfb_width = swab16(*(short *)(ptr+6));				screen_info.lfb_height = swab16(*(short *)(ptr+8));				screen_info.lfb_linelength = swab16(*(short *)(ptr+10));				screen_info.lfb_base = swab32(*(long *)(ptr+12));				screen_info.lfb_size = swab32(*(long *)(ptr+20)) / 65536;			}		}	}#endif}/* * Set DBAT 2 to access 0x80000000 so early progress messages will work */static __inline__ voidprep_set_bat(void){	/* wait for all outstanding memory access to complete */	mb();	/* setup DBATs */	mtspr(SPRN_DBAT2U, 0x80001ffe);	mtspr(SPRN_DBAT2L, 0x8000002a);	/* wait for updates */	mb();}/* * IBM 3-digit status LED */static unsigned int ibm_statusled_base;static voidibm_statusled_progress(char *s, unsigned short hex);static intibm_statusled_panic(struct notifier_block *dummy1, unsigned long dummy2,		    void * dummy3){	ibm_statusled_progress(NULL, 0x505); /* SOS */	return NOTIFY_DONE;}static struct notifier_block ibm_statusled_block = {	ibm_statusled_panic,	NULL,	INT_MAX /* try to do it first */};static voidibm_statusled_progress(char *s, unsigned short hex){	static int notifier_installed;	/*	 * Progress uses 4 digits and we have only 3.  So, we map 0xffff to	 * 0xfff for display switch off.  Out of range values are mapped to	 * 0xeff, as I'm told 0xf00 and above are reserved for hardware codes.	 * Install the panic notifier when the display is first switched off.	 */	if (hex == 0xffff) {		hex = 0xfff;		if (!notifier_installed) {			++notifier_installed;			notifier_chain_register(&panic_notifier_list,						&ibm_statusled_block);		}	}	else		if (hex > 0xfff)			hex = 0xeff;	mb();	outw(hex, ibm_statusled_base);}static void __initibm_statusled_init(void){	/*	 * The IBM 3-digit LED display is specified in the residual data	 * as an operator panel device, type "System Status LED".  Find	 * that device and determine its address.  We validate all the	 * other parameters on the off-chance another, similar device	 * exists.	 */	if (have_residual_data) {		PPC_DEVICE *led;		PnP_TAG_PACKET *pkt;		led = residual_find_device(~0, NULL, SystemPeripheral,					   OperatorPanel, SystemStatusLED, 0);		if (!led)			return;		pkt = PnP_find_packet((unsigned char *)		       &res->DevicePnPHeap[led->AllocatedOffset], S8_Packet, 0);		if (!pkt)			return;		if (pkt->S8_Pack.IOInfo != ISAAddr16bit)			return;		if (*(unsigned short *)pkt->S8_Pack.RangeMin !=		    *(unsigned short *)pkt->S8_Pack.RangeMax)			return;		if (pkt->S8_Pack.IOAlign != 2)			return;		if (pkt->S8_Pack.IONum != 2)			return;		ibm_statusled_base = ld_le16((unsigned short *)					     (pkt->S8_Pack.RangeMin));		ppc_md.progress = ibm_statusled_progress;	}}static void __initprep_setup_arch(void){	unsigned char reg;	int is_ide=0;	/* init to some ~sane value until calibrate_delay() runs */	loops_per_jiffy = 50000000;	/* Lookup PCI host bridges */	prep_find_bridges();	/* Set up floppy in PS/2 mode */	outb(0x09, SIO_CONFIG_RA);	reg = inb(SIO_CONFIG_RD);	reg = (reg & 0x3F) | 0x40;	outb(reg, SIO_CONFIG_RD);	outb(reg, SIO_CONFIG_RD);	/* Have to write twice to change! */	switch ( _prep_type )	{	case _PREP_IBM:		reg = inb(PREP_IBM_PLANAR);		printk(KERN_INFO "IBM planar ID: %02x", reg);		switch (reg) {			case PREP_IBM_SANDALFOOT:				prep_gen_enable_l2();				setup_ibm_pci = prep_sandalfoot_setup_pci;				ppc_md.power_off = prep_sig750_poweroff;				ppc_md.show_cpuinfo = prep_sandalfoot_cpuinfo;				break;			case PREP_IBM_THINKPAD:				prep_gen_enable_l2();				setup_ibm_pci = prep_thinkpad_setup_pci;				ppc_md.power_off = prep_carrera_poweroff;				ppc_md.show_cpuinfo = prep_thinkpad_cpuinfo;				break;			default:				if (have_residual_data) {					prep_gen_enable_l2();					setup_ibm_pci = prep_residual_setup_pci;					ppc_md.power_off = prep_halt;					ppc_md.show_cpuinfo = prep_gen_cpuinfo;					break;				}				else					printk(" - unknown! Assuming Carolina");					/* fall through */			case PREP_IBM_CAROLINA_IDE_0:			case PREP_IBM_CAROLINA_IDE_1:			case PREP_IBM_CAROLINA_IDE_2:			case PREP_IBM_CAROLINA_IDE_3:				is_ide = 1;			case PREP_IBM_CAROLINA_SCSI_0:			case PREP_IBM_CAROLINA_SCSI_1:			case PREP_IBM_CAROLINA_SCSI_2:			case PREP_IBM_CAROLINA_SCSI_3:				prep_carolina_enable_l2();				setup_ibm_pci = prep_carolina_setup_pci;				ppc_md.power_off = prep_sig750_poweroff;				ppc_md.show_cpuinfo = prep_carolina_cpuinfo;				break;			case PREP_IBM_TIGER1_133:			case PREP_IBM_TIGER1_166:			case PREP_IBM_TIGER1_180:			case PREP_IBM_TIGER1_xxx:			case PREP_IBM_TIGER1_333:				prep_carolina_enable_l2();				setup_ibm_pci = prep_tiger1_setup_pci;				ppc_md.power_off = prep_sig750_poweroff;				ppc_md.show_cpuinfo = prep_tiger1_cpuinfo;				break;		}		printk("\n");		/* default root device */		if (is_ide)			ROOT_DEV = MKDEV(IDE0_MAJOR, 3);		else			ROOT_DEV = MKDEV(SCSI_DISK0_MAJOR, 3);		break;	case _PREP_Motorola:		prep_gen_enable_l2();		ppc_md.power_off = prep_halt;		ppc_md.show_cpuinfo = prep_mot_cpuinfo;#ifdef CONFIG_BLK_DEV_INITRD		if (initrd_start)			ROOT_DEV = Root_RAM0;		else#endif#ifdef CONFIG_ROOT_NFS			ROOT_DEV = Root_NFS;#else			ROOT_DEV = Root_SDA2;#endif		break;	}	/* Read in NVRAM data */	init_prep_nvram();	/* if no bootargs, look in NVRAM */	if ( cmd_line[0] == '\0' ) {		char *bootargs;		 bootargs = prep_nvram_get_var("bootargs");		 if (bootargs != NULL) {			 strcpy(cmd_line, bootargs);			 /* again.. */			 strcpy(saved_command_line, cmd_line);		}	}#ifdef CONFIG_SOUND_CS4232	prep_init_sound();#endif /* CONFIG_SOUND_CS4232 */	prep_init_vesa();	switch (_prep_type) {	case _PREP_Motorola:		raven_init();		break;	case _PREP_IBM:		ibm_prep_init();		break;	}#ifdef CONFIG_VGA_CONSOLE	/* vgacon.c needs to know where we mapped IO memory in io_block_mapping() */	vgacon_remap_base = 0xf0000000;	conswitchp = &vga_con;#endif}/* * First, see if we can get this information from the residual data. * This is important on some IBM PReP systems.  If we cannot, we let the * TODC code handle doing this. */static void __initprep_calibrate_decr(void){	if (have_residual_data) {		unsigned long freq, divisor = 4;		if ( res->VitalProductData.ProcessorBusHz ) {			freq = res->VitalProductData.ProcessorBusHz;			printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",					(freq/divisor)/1000000,					(freq/divisor)%1000000);			tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);			tb_ticks_per_jiffy = freq / HZ / divisor;		}	}	else		todc_calibrate_decr();}static void __initprep_init_IRQ(void){	int i;	unsigned int pci_viddid, pci_did;	if (OpenPIC_Addr != NULL) {		openpic_init(NUM_8259_INTERRUPTS);		/* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */		openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",				       i8259_irq);	}	if (have_residual_data) {		i8259_init(residual_isapic_addr(), 0);		return;	}	/* If we have a Raven PCI bridge or a Hawk PCI bridge / Memory	 * controller, we poll (as they have a different int-ack address). */	early_read_config_dword(NULL, 0, 0, PCI_VENDOR_ID, &pci_viddid);	pci_did = (pci_viddid & 0xffff0000) >> 16;	if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_MOTOROLA)			&& ((pci_did == PCI_DEVICE_ID_MOTOROLA_RAVEN)				|| (pci_did == PCI_DEVICE_ID_MOTOROLA_HAWK)))		i8259_init(0, 0);	else		/* PCI interrupt ack address given in section 6.1.8 of the		 * PReP specification. */		i8259_init(MPC10X_MAPA_PCI_INTACK_ADDR, 0);}#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)/* * IDE stuff. */static intprep_ide_default_irq(unsigned long base){	switch (base) {		case 0x1f0: return 13;		case 0x170: return 13;		case 0x1e8: return 11;		case 0x168: return 10;		case 0xfff0: return 14;		/* MCP(N)750 ide0 */		case 0xffe0: return 15;		/* MCP(N)750 ide1 */		default: return 0;	}}static unsigned longprep_ide_default_io_base(int index){	switch (index) {		case 0: return 0x1f0;		case 1: return 0x170;		case 2: return 0x1e8;		case 3: return 0x168;		default:			return 0;	}}#endif#ifdef CONFIG_SMP/* PReP (MTX) support */static int __initsmp_prep_probe(void){	extern int mot_multi;	if (mot_multi) {		openpic_request_IPIs();		smp_hw_index[1] = 1;		return 2;	}	return 1;}static void __initsmp_prep_kick_cpu(int nr){	*(unsigned long *)KERNELBASE = nr;	asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");	printk("CPU1 released, waiting\n");}static void __initsmp_prep_setup_cpu(int cpu_nr){	if (OpenPIC_Addr)		do_openpic_setup_cpu();}static struct smp_ops_t prep_smp_ops = {	smp_openpic_message_pass,	smp_prep_probe,	smp_prep_kick_cpu,	smp_prep_setup_cpu,	.give_timebase = smp_generic_give_timebase,	.take_timebase = smp_generic_take_timebase,};#endif /* CONFIG_SMP *//* * Setup the bat mappings we're going to load that cover * the io areas.  RAM was mapped by mapin_ram(). * -- Cort */static void __initprep_map_io(void){	io_block_mapping(0x80000000, PREP_ISA_IO_BASE, 0x10000000, _PAGE_IO);	io_block_mapping(0xf0000000, PREP_ISA_MEM_BASE, 0x08000000, _PAGE_IO);}static int __initprep_request_io(void){	if (_machine == _MACH_prep) {#ifdef CONFIG_NVRAM		request_region(PREP_NVRAM_AS0, 0x8, "nvram");#endif		request_region(0x00,0x20,"dma1");		request_region(0x40,0x20,"timer");		request_region(0x80,0x10,"dma page reg");		request_region(0xc0,0x20,"dma2");	}	return 0;}device_initcall(prep_request_io);void __initprep_init(unsigned long r3, unsigned long r4, unsigned long r5,		unsigned long r6, unsigned long r7){#ifdef CONFIG_PREP_RESIDUAL	/* make a copy of residual data */	if ( r3 ) {		memcpy((void *)res,(void *)(r3+KERNELBASE),			 sizeof(RESIDUAL));	}#endif	isa_io_base = PREP_ISA_IO_BASE;	isa_mem_base = PREP_ISA_MEM_BASE;	pci_dram_offset = PREP_PCI_DRAM_OFFSET;	ISA_DMA_THRESHOLD = 0x00ffffff;	DMA_MODE_READ = 0x44;	DMA_MODE_WRITE = 0x48;	ppc_do_canonicalize_irqs = 1;	/* figure out what kind of prep workstation we are */	if (have_residual_data) {		if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) )			_prep_type = _PREP_IBM;		else			_prep_type = _PREP_Motorola;	}	else {		/* assume motorola if no residual (netboot?) */		_prep_type = _PREP_Motorola;	}#ifdef CONFIG_PREP_RESIDUAL	/* Switch off all residual data processing if the user requests it */	if (strstr(cmd_line, "noresidual") != NULL)			res = NULL;#endif	/* Initialise progress early to get maximum benefit */	prep_set_bat();	ibm_statusled_init();	ppc_md.setup_arch     = prep_setup_arch;	ppc_md.show_percpuinfo = prep_show_percpuinfo;	ppc_md.show_cpuinfo   = NULL; /* set in prep_setup_arch() */	ppc_md.init_IRQ       = prep_init_IRQ;	/* this gets changed later on if we have an OpenPIC -- Cort */	ppc_md.get_irq        = i8259_irq;	ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;	ppc_md.restart        = prep_restart;	ppc_md.power_off      = NULL; /* set in prep_setup_arch() */	ppc_md.halt           = prep_halt;	ppc_md.nvram_read_val = prep_nvram_read_val;	ppc_md.nvram_write_val = prep_nvram_write_val;	ppc_md.time_init      = todc_time_init;	if (_prep_type == _PREP_IBM) {		ppc_md.rtc_read_val = todc_mc146818_read_val;		ppc_md.rtc_write_val = todc_mc146818_write_val;		TODC_INIT(TODC_TYPE_MC146818, RTC_PORT(0), NULL, RTC_PORT(1),				8);	} else {		TODC_INIT(TODC_TYPE_MK48T59, PREP_NVRAM_AS0, PREP_NVRAM_AS1,				PREP_NVRAM_DATA, 8);	}	ppc_md.calibrate_decr = prep_calibrate_decr;	ppc_md.set_rtc_time   = todc_set_rtc_time;	ppc_md.get_rtc_time   = todc_get_rtc_time;	ppc_md.setup_io_mappings = prep_map_io;#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)	ppc_ide_md.default_irq = prep_ide_default_irq;	ppc_ide_md.default_io_base = prep_ide_default_io_base;#endif#ifdef CONFIG_SMP	smp_ops			 = &prep_smp_ops;#endif /* CONFIG_SMP */}

⌨️ 快捷键说明

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