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

📄 tsi108_init.c

📁 U-boot源码 ARM7启动代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef DISABLE_PBM	/*	 * For IBM processors we have to set Address-Only commands generated	 * by PBM that are different from ones set after reset.	 */	temp = get_cpu_type ();	if ((CPU_750FX == temp) || (CPU_750GX == temp))		out32 (CFG_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_MCMD,			0x00009955);#endif	/* DISABLE_PBM */#ifdef CONFIG_PCI	/*	 * Initialize PCI/X block	 */	/* Map PCI/X Configuration Space (16MB @ 0x0_FE000000) */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET +		PCI_PFAB_BAR0_UPPER, 0);	__asm__ __volatile__ ("sync");	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_BAR0,		0xFB000001);	__asm__ __volatile__ ("sync");	/* Set Bus Number for the attached PCI/X bus (we will use 0 for NB) */	temp =	in32(CFG_TSI108_CSR_BASE +		TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT);	temp &= ~0xFF00;	/* Clear the BUS_NUM field */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT,		temp);	/* Map PCI/X IO Space (64KB @ 0x0_FD000000) takes one 16MB LUT entry */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO_UPPER,		0);	__asm__ __volatile__ ("sync");	/* This register is on the PCI side to interpret the address it receives	 * and maps it as a IO address.	 */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO,		0xFA000001);	__asm__ __volatile__ ("sync");	/*	 * Map PCI/X Memory Space	 *	 * Transactions directed from OCM to PCI Memory Space are directed	 * from PB to PCI	 * unchanged (as defined by PB_OCN_BAR1,2 and LUT settings).	 * If address remapping is required the corresponding PCI_PFAB_MEM32	 * and PCI_PFAB_PFMx register groups have to be configured.	 *	 * Map the path from the PCI/X bus into the system memory	 *	 * The memory mapped window assotiated with PCI P2O_BAR2 provides	 * access to the system memory without address remapping.	 * All system memory is opened for accesses initiated by PCI/X bus	 * masters.	 *	 * Initialize LUT associated with PCI P2O_BAR2	 *	 * set pointer to LUT associated with PCI P2O_BAR2	 */	reg_ptr =		(ulong *) (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x500);#ifdef DISABLE_PBM	/* In case when PBM is disabled (no HW supported cache snoopng on PB)	 * P2O_BAR2 is directly mapped into the system memory without address	 * translation.	 */	reg_val = 0x00000004;	/* SDRAM port + NO Addr_Translation */	for (i = 0; i < 32; i++) {		*reg_ptr++ = reg_val;	/* P2O_BAR2_LUTx */		*reg_ptr++ = 0;		/* P2O_BAR2_LUT_UPPERx */	}	/* value for PCI BAR2 (size = 512MB, Enabled, No Addr. Translation) */	reg_val = 0x00007500;#else	reg_val = 0x00000002;	/* Destination port = PBM */	for (i = 0; i < 32; i++) {		*reg_ptr++ = reg_val;	/* P2O_BAR2_LUTx *//* P2O_BAR2_LUT_UPPERx : Set data swapping mode for PBM (byte swapping) */		*reg_ptr++ = 0x40000000;/* offset = 16MB, address translation is enabled to allow byte swapping */		reg_val += 0x01000000;	}/* value for PCI BAR2 (size = 512MB, Enabled, Address Translation Enabled) */	reg_val = 0x00007100;#endif	__asm__ __volatile__ ("eieio");	__asm__ __volatile__ ("sync");	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES,		reg_val);	__asm__ __volatile__ ("sync");	/* Set 64-bit PCI bus address for system memory	 * ( 0 is the best choice for easy mapping)	 */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2,		0x00000000);	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2_UPPER,		0x00000000);	__asm__ __volatile__ ("sync");#ifndef DISABLE_PBM	/*	 *  The memory mapped window assotiated with PCI P2O_BAR3 provides	 *  access to the system memory using SDRAM OCN port and address	 *  translation. This is alternative way to access SDRAM from PCI	 *  required for Tsi108 emulation testing.	 *  All system memory is opened for accesses initiated by	 *  PCI/X bus masters.	 *	 *  Initialize LUT associated with PCI P2O_BAR3	 *	 *  set pointer to LUT associated with PCI P2O_BAR3	 */	reg_ptr =		(ulong *) (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x600);	reg_val = 0x00000004;	/* Destination port = SDC */	for (i = 0; i < 32; i++) {		*reg_ptr++ = reg_val;	/* P2O_BAR3_LUTx *//* P2O_BAR3_LUT_UPPERx : Set data swapping mode for PBM (byte swapping) */		*reg_ptr++ = 0;/* offset = 16MB, address translation is enabled to allow byte swapping */		reg_val += 0x01000000;	}	__asm__ __volatile__ ("eieio");	__asm__ __volatile__ ("sync");	/* Configure PCI P2O_BAR3 (size = 512MB, Enabled) */	reg_val =		in32(CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET +		 PCI_P2O_PAGE_SIZES);	reg_val &= ~0x00FF;	reg_val |= 0x0071;	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES,		reg_val);	__asm__ __volatile__ ("sync");	/* Set 64-bit base PCI bus address for window (0x20000000) */	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3_UPPER,		0x00000000);	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3,		0x20000000);	__asm__ __volatile__ ("sync");#endif	/* !DISABLE_PBM */#ifdef ENABLE_PCI_CSR_BAR	/* open if required access to Tsi108 CSRs from the PCI/X bus */	/* enable BAR0 on the PCI/X bus */	reg_val = in32(CFG_TSI108_CSR_BASE +		TSI108_PCI_REG_OFFSET + PCI_MISC_CSR);	reg_val |= 0x02;	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_MISC_CSR,		reg_val);	__asm__ __volatile__ ("sync");	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0_UPPER,		0x00000000);	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0,		CFG_TSI108_CSR_BASE);	__asm__ __volatile__ ("sync");#endif	/*	 * Finally enable PCI/X Bus Master and Memory Space access	 */	reg_val = in32(CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR);	reg_val |= 0x06;	out32 (CFG_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR, reg_val);	__asm__ __volatile__ ("sync");#endif	/* CONFIG_PCI */	/*	 * Initialize MPIC outputs (interrupt pins):	 * Interrupt routing on the Grendel Emul. Board:	 * PB_INT[0] -> INT (CPU0)	 * PB_INT[1] -> INT (CPU1)	 * PB_INT[2] -> MCP (CPU0)	 * PB_INT[3] -> MCP (CPU1)	 * Set interrupt controller outputs as Level_Sensitive/Active_Low	 */	out32 (CFG_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(0), 0x02);	out32 (CFG_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(1), 0x02);	out32 (CFG_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(2), 0x02);	out32 (CFG_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(3), 0x02);	__asm__ __volatile__ ("sync");	/*	 * Ensure that Machine Check exception is enabled	 * We need it to support PCI Bus probing (configuration reads)	 */	reg_val = mfmsr ();	mtmsr(reg_val | MSR_ME);	return 0;}/* * Needed to print out L2 cache info * used in the misc_init_r function */unsigned long get_l2cr (void){	unsigned long l2controlreg;	asm volatile ("mfspr %0, 1017":"=r" (l2controlreg):);	return l2controlreg;}/* * misc_init_r() * * various things to do after relocation * */int misc_init_r (void){#ifdef CFG_CLK_SPREAD	/* Initialize Spread-Spectrum Clock generation */	ulong i;	/* Ensure that Spread-Spectrum is disabled */	out32 (CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, 0);	out32 (CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0, 0);	/* Initialize PLL1: CG_PCI_CLK , internal OCN_CLK	 * Uses pre-calculated value for Fout = 800 MHz, Fs = 30 kHz, D = 0.5%	 */	out32 (CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0,		0x002e0044);	/* D = 0.25% */	out32 (CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL1,		0x00000039);	/* BWADJ */	/* Initialize PLL0: CG_PB_CLKO  */	/* Detect PB clock freq. */	i = in32(CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PWRUP_STATUS);	i = (i >> 16) & 0x07;	/* Get PB PLL multiplier */	out32 (CFG_TSI108_CSR_BASE +		TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, pll0_config[i].ctrl0);	out32 (CFG_TSI108_CSR_BASE +		TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL1, pll0_config[i].ctrl1);	/* Wait and set SSEN for both PLL0 and 1 */	udelay (1000);	out32 (CFG_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0,		0x802e0044);	/* D=0.25% */	out32 (CFG_TSI108_CSR_BASE +		TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0,	 	0x80000000 | pll0_config[i].ctrl0);#endif	/* CFG_CLK_SPREAD */#ifdef CFG_L2	l2cache_enable ();#endif	printf ("BUS:   %d MHz\n", gd->bus_clk / 1000000);	printf ("MEM:   %d MHz\n", gd->mem_clk / 1000000);	/*	 * All the information needed to print the cache details is avaiblable	 * at this point i.e. above call to l2cache_enable is the very last	 * thing done with regards to enabling diabling the cache.	 * So this seems like a good place to print all this information	 */	printf ("CACHE: ");	switch (get_cpu_type()) {	case CPU_7447A:		printf ("L1 Instruction cache - 32KB 8-way");		(get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		printf ("L1 Data cache - 32KB 8-way");		(get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		printf ("Unified L2 cache - 512KB 8-way");		(get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		printf ("\n");		break;	case CPU_7448:		printf ("L1 Instruction cache - 32KB 8-way");		(get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		printf ("L1 Data cache - 32KB 8-way");		(get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		printf ("Unified L2 cache - 1MB 8-way");		(get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") :			printf (" DISABLED\n");		break;	default:		break;	}	return 0;}

⌨️ 快捷键说明

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