📄 bamboo.c
字号:
mtdcr(uic0cr, 0x00000009); /* ATI & UIC1 crit are critical */ mtdcr(uic0pr, 0xfffffe13); /* per ref-board manual */ mtdcr(uic0tr, 0x01c00008); /* per ref-board manual */ mtdcr(uic0vr, 0x00000001); /* int31 highest, base=0x000 */ mtdcr(uic0sr, 0xffffffff); /* clear all */ mtdcr(uic1sr, 0xffffffff); /* clear all */ mtdcr(uic1er, 0x00000000); /* disable all */ mtdcr(uic1cr, 0x00000000); /* all non-critical */ mtdcr(uic1pr, 0xffffe0ff); /* per ref-board manual */ mtdcr(uic1tr, 0x00ffc000); /* per ref-board manual */ mtdcr(uic1vr, 0x00000001); /* int31 highest, base=0x000 */ mtdcr(uic1sr, 0xffffffff); /* clear all */ /*-------------------------------------------------------------------- * Setup the GPIO pins *-------------------------------------------------------------------*/ out32(GPIO0_OSRL, 0x00000400); out32(GPIO0_OSRH, 0x00000000); out32(GPIO0_TSRL, 0x00000400); out32(GPIO0_TSRH, 0x00000000); out32(GPIO0_ISR1L, 0x00000000); out32(GPIO0_ISR1H, 0x00000000); out32(GPIO0_ISR2L, 0x00000000); out32(GPIO0_ISR2H, 0x00000000); out32(GPIO0_ISR3L, 0x00000000); out32(GPIO0_ISR3H, 0x00000000); out32(GPIO1_OSRL, 0x0C380000); out32(GPIO1_OSRH, 0x00000000); out32(GPIO1_TSRL, 0x0C380000); out32(GPIO1_TSRH, 0x00000000); out32(GPIO1_ISR1L, 0x0FC30000); out32(GPIO1_ISR1H, 0x00000000); out32(GPIO1_ISR2L, 0x0C010000); out32(GPIO1_ISR2H, 0x00000000); out32(GPIO1_ISR3L, 0x01400000); out32(GPIO1_ISR3H, 0x00000000); configure_ppc440ep_pins(); return 0;}int checkboard(void){ char *s = getenv("serial#"); printf("Board: Bamboo - AMCC PPC440EP Evaluation Board"); if (s != NULL) { puts(", serial# "); puts(s); } putc('\n'); return (0);}long int initdram (int board_type){#if !(defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)) long dram_size; dram_size = spd_sdram(); return dram_size;#else return CFG_MBYTES_SDRAM << 20;#endif}#if defined(CFG_DRAM_TEST)int testdram(void){ unsigned long *mem = (unsigned long *)0; const unsigned long kend = (1024 / sizeof(unsigned long)); unsigned long k, n, *p32, ctr; const unsigned long bend = CFG_MBYTES_SDRAM * 1024 * 1024; mtmsr(0); for (k = 0; k < CFG_MBYTES_SDRAM*1024; ++k, mem += (1024 / sizeof(unsigned long))) { if ((k & 1023) == 0) { printf("%3d MB\r", k / 1024); } memset(mem, 0xaaaaaaaa, 1024); for (n = 0; n < kend; ++n) { if (mem[n] != 0xaaaaaaaa) { printf("SDRAM test fails at: %08x\n", (uint) & mem[n]); return 1; } } memset(mem, 0x55555555, 1024); for (n = 0; n < kend; ++n) { if (mem[n] != 0x55555555) { printf("SDRAM test fails at: %08x\n", (uint) & mem[n]); return 1; } } } /* * Perform a sequence test to ensure that all * memory locations are uniquely addressable */ ctr = 0; p32 = 0; while ((unsigned long)p32 != bend) { if (0 == ((unsigned long)p32 & ((1<<20)-1))) printf("Writing %3d MB\r", (unsigned long)p32 >> 20); *p32++ = ctr++; } ctr = 0; p32 = 0; while ((unsigned long)p32 != bend) { if (0 == ((unsigned long)p32 & ((1<<20)-1))) printf("Verifying %3d MB\r", (unsigned long)p32 >> 20); if (*p32 != ctr) { printf("SDRAM test fails at: %08x\n", p32); return 1; } ctr++; p32++; } printf("SDRAM test passes\n"); return 0;}#endif/************************************************************************* * pci_pre_init * * This routine is called just prior to registering the hose and gives * the board the opportunity to check things. Returning a value of zero * indicates that things are bad & PCI initialization should be aborted. * * Different boards may wish to customize the pci controller structure * (add regions, override default access routines, etc) or perform * certain pre-initialization actions. * ************************************************************************/#if defined(CONFIG_PCI)int pci_pre_init(struct pci_controller *hose){ unsigned long addr; /*-------------------------------------------------------------------------+ | Set priority for all PLB3 devices to 0. | Set PLB3 arbiter to fair mode. +-------------------------------------------------------------------------*/ mfsdr(sdr_amp1, addr); mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00); addr = mfdcr(plb3_acr); mtdcr(plb3_acr, addr | 0x80000000); /*-------------------------------------------------------------------------+ | Set priority for all PLB4 devices to 0. +-------------------------------------------------------------------------*/ mfsdr(sdr_amp0, addr); mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00); addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */ mtdcr(plb4_acr, addr); /*-------------------------------------------------------------------------+ | Set Nebula PLB4 arbiter to fair mode. +-------------------------------------------------------------------------*/ /* Segment0 */ addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair; addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled; addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep; addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep; mtdcr(plb0_acr, addr); /* Segment1 */ addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair; addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled; addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep; addr = (addr & ~plb1_acr_wrp_mask) | plb1_acr_wrp_2deep; mtdcr(plb1_acr, addr); return 1;}#endif /* defined(CONFIG_PCI) *//************************************************************************* * pci_target_init * * The bootstrap configuration provides default settings for the pci * inbound map (PIM). But the bootstrap config choices are limited and * may not be sufficient for a given board. * ************************************************************************/#if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)void pci_target_init(struct pci_controller *hose){ /*--------------------------------------------------------------------------+ * Set up Direct MMIO registers *--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------+ | PowerPC440 EP PCI Master configuration. | Map one 1Gig range of PLB/processor addresses to PCI memory space. | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF | Use byte reversed out routines to handle endianess. | Make this region non-prefetchable. +--------------------------------------------------------------------------*/ out32r(PCIX0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */ out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */ out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE); /* PMM0 PCI Low Address */ out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */ out32r(PCIX0_PMM0MA, 0xE0000001); /* 512M + No prefetching, and enable region */ out32r(PCIX0_PMM1MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */ out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */ out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2); /* PMM0 PCI Low Address */ out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */ out32r(PCIX0_PMM1MA, 0xE0000001); /* 512M + No prefetching, and enable region */ out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */ out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */ out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */ out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */ /*--------------------------------------------------------------------------+ * Set up Configuration registers *--------------------------------------------------------------------------*/ /* Program the board's subsystem id/vendor id */ pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID, CFG_PCI_SUBSYS_VENDORID); pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID); /* Configure command register as bus master */ pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER); /* 240nS PCI clock */ pci_write_config_word(0, PCI_LATENCY_TIMER, 1); /* No error reporting */ pci_write_config_word(0, PCI_ERREN, 0); pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);}#endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) *//************************************************************************* * pci_master_init * ************************************************************************/#if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)void pci_master_init(struct pci_controller *hose){ unsigned short temp_short; /*--------------------------------------------------------------------------+ | Write the PowerPC440 EP PCI Configuration regs. | Enable PowerPC440 EP to be a master on the PCI bus (PMM). | Enable PowerPC440 EP to act as a PCI memory target (PTM). +--------------------------------------------------------------------------*/ pci_read_config_word(0, PCI_COMMAND, &temp_short); pci_write_config_word(0, PCI_COMMAND, temp_short | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);}#endif /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) *//************************************************************************* * is_pci_host * * This routine is called to determine if a pci scan should be * performed. With various hardware environments (especially cPCI and * PPMC) it's insufficient to depend on the state of the arbiter enable * bit in the strap register, or generic host/adapter assumptions. * * Rather than hard-code a bad assumption in the general 440 code, the * 440 pci code requires the board to decide at runtime. * * Return 0 for adapter mode, non-zero for host (monarch) mode. * * ************************************************************************/#if defined(CONFIG_PCI)int is_pci_host(struct pci_controller *hose){ /* Bamboo is always configured as host. */ return (1);}#endif /* defined(CONFIG_PCI) *//*----------------------------------------------------------------------------+ | is_powerpc440ep_pass1. +----------------------------------------------------------------------------*/int is_powerpc440ep_pass1(void){ unsigned long pvr; pvr = get_pvr(); if (pvr == PVR_POWERPC_440EP_PASS1) return TRUE; else if (pvr == PVR_POWERPC_440EP_PASS2) return FALSE; else { printf("brdutil error 3\n"); for (;;) ; } return(FALSE);}/*----------------------------------------------------------------------------+ | is_nand_selected. +----------------------------------------------------------------------------*/int is_nand_selected(void){#ifdef CONFIG_BAMBOO_NAND return TRUE;#else return FALSE;#endif}/*----------------------------------------------------------------------------+ | config_on_ebc_cs4_is_small_flash => from EPLD +----------------------------------------------------------------------------*/unsigned char config_on_ebc_cs4_is_small_flash(void){ /* Not implemented yet => returns constant value */ return TRUE;}/*----------------------------------------------------------------------------+ | Ext_bus_cntlr_init. | Initialize the external bus controller +----------------------------------------------------------------------------*/void ext_bus_cntlr_init(void){ unsigned long sdr0_pstrp0, sdr0_sdstp1; unsigned long bootstrap_settings, boot_selection, ebc_boot_size; int computed_boot_device = BOOT_DEVICE_UNKNOWN; unsigned long ebc0_cs0_bnap_value = 0, ebc0_cs0_bncr_value = 0; unsigned long ebc0_cs1_bnap_value = 0, ebc0_cs1_bncr_value = 0; unsigned long ebc0_cs2_bnap_value = 0, ebc0_cs2_bncr_value = 0; unsigned long ebc0_cs3_bnap_value = 0, ebc0_cs3_bncr_value = 0; unsigned long ebc0_cs4_bnap_value = 0, ebc0_cs4_bncr_value = 0; /*-------------------------------------------------------------------------+ | | PART 1 : Initialize EBC Bank 5 | ============================== | Bank5 is always associated to the NVRAM/EPLD. | It has to be initialized prior to other banks settings computation since | some board registers values may be needed | +-------------------------------------------------------------------------*/ /* NVRAM - FPGA */ mtebc(pb5ap, EBC0_BNAP_NVRAM_FPGA); mtebc(pb5cr, EBC0_BNCR_NVRAM_FPGA_CS5); /*-------------------------------------------------------------------------+ | | PART 2 : Determine which boot device was selected | ========================================= | | Read Pin Strap Register in PPC440EP | In case of boot from IIC, read Serial Device Strap Register1 | | Result can either be : | - Boot from EBC 8bits => SMALL FLASH | - Boot from EBC 16bits => Large Flash or SRAM | - Boot from NAND Flash | - Boot from PCI | +-------------------------------------------------------------------------*/ /* Read Pin Strap Register in PPC440EP */ mfsdr(sdr_pstrp0, sdr0_pstrp0); bootstrap_settings = sdr0_pstrp0 & SDR0_PSTRP0_BOOTSTRAP_MASK; /*-------------------------------------------------------------------------+ | PPC440EP Pass1 +-------------------------------------------------------------------------*/ if (is_powerpc440ep_pass1() == TRUE) { switch(bootstrap_settings) { case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -