diff options
Diffstat (limited to 'roms/u-boot-sam460ex/board/ACube/Sam460ex')
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/Makefile | 74 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/Sam460ex.c | 994 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/config.mk | 45 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/init.S | 89 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/init_cn.S | 140 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/init_radeon.c | 290 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot-nand.lds | 135 | ||||
-rw-r--r-- | roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot.lds | 110 |
8 files changed, 1877 insertions, 0 deletions
diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/Makefile b/roms/u-boot-sam460ex/board/ACube/Sam460ex/Makefile new file mode 100644 index 000000000..a7c0040fd --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/Makefile @@ -0,0 +1,74 @@ +# +# (C) Copyright 2008 +# Stefan Roese, DENX Software Engineering, sr@denx.de. +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +CFLAGS += -I../menu -I../common -I. + +LIB = $(obj)lib$(BOARD).a + +EMUDIR = ../bios_emulator/scitech/src/x86emu/ +EMUOBJ = $(EMUDIR)decode.o $(EMUDIR)ops2.o $(EMUDIR)fpu.o $(EMUDIR)prim_ops.o \ + $(EMUDIR)ops.o $(EMUDIR)sys.o $(EMUDIR)debug.o + +MENUDIR = ../menu/ +MENUOBJ = $(MENUDIR)bios_menu.o $(MENUDIR)bootselect_menu.o $(MENUDIR)list.o \ + $(MENUDIR)cmd_menu.o $(MENUDIR)label_items.o $(MENUDIR)creation.o \ + $(MENUDIR)func_items.o $(MENUDIR)layout.o \ + $(MENUDIR)menu.o $(MENUDIR)popup_items.o \ + $(MENUDIR)string_edit.o $(MENUDIR)string_items.o + +COMMONDIR = ../common/ +COMMONOBJ = $(COMMONDIR)vesa.o $(COMMONDIR)vesa_video.o \ + $(COMMONDIR)cmd_boota.o $(COMMONDIR)misc_utils.o $(COMMONDIR)sys_dep.o \ + $(COMMONDIR)sam_ide.o $(COMMONDIR)init_sm502.o $(COMMONDIR)sm502.o + +COBJS-y := $(BOARD).o init_radeon.o $(COMMONOBJ) $(EMUOBJ) $(MENUOBJ) \ + ../bios_emulator/x86interface.o \ + ../bios_emulator/bios.o ../bios_emulator/glue.o \ + +#COBJS-$(CONFIG_CMD_CHIP_CONFIG) += chip_config.o +SOBJS := init.o + +COBJS := $(COBJS-y) +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) +SOBJS := $(addprefix $(obj),$(SOBJS)) + +$(LIB): $(OBJS) $(SOBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS) + +clean: + rm -f $(SOBJS) $(OBJS) + +distclean: clean + rm -f $(LIB) core *.bak $(obj).depend + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/Sam460ex.c b/roms/u-boot-sam460ex/board/ACube/Sam460ex/Sam460ex.c new file mode 100644 index 000000000..4d5b953c0 --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/Sam460ex.c @@ -0,0 +1,994 @@ +/* + * (C) Copyright 2009-2011 + * Max Tretene, ACube Systems Srl. mtretene@acube-systems.com. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <ppc440.h> +#include <libfdt.h> +#include <fdt_support.h> +#include <i2c.h> +#include <asm/processor.h> +#include <asm/io.h> +#include <asm/mmu.h> +#include <asm/4xx_pcie.h> +#include <asm/gpio.h> +#include <asm/errno.h> +#include <sm501.h> +#include "../common/vesa.h" + +#undef DEBUG + +#ifdef DEBUG +#define PRINTF(fmt,args...) printf (fmt ,##args) +#else +#define PRINTF(fmt,args...) +#endif + +#define SAMLOGO +#ifdef SAMLOGO +#include "../common/logo_acube.h" +#else +#define LOGO_WIDTH 176 +#define LOGO_HEIGHT 48 +unsigned char logo_acube[LOGO_WIDTH * LOGO_HEIGHT] = { 0 }; +#endif + +#ifndef CONFIG_SYS_NO_FLASH +extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ +#endif + +DECLARE_GLOBAL_DATA_PTR; + +#define BOARD_CANYONLANDS_PCIE 1 +#define BOARD_CANYONLANDS_SATA 2 + +extern int onbus; +extern int console_col; /* cursor col */ +extern int console_row; /* cursor row */ + +extern u32 *fb_base_phys_sm502; +extern unsigned char SM502INIT; +extern pci_dev_t dev_sm502; +extern struct FrameBufferInfo *fbi; + +unsigned char SM502 = 0; +struct pci_controller *ppc460_hose = NULL; + +/* + * Override the default functions in cpu/ppc4xx/44x_spd_ddr2.c with + * board specific values. + */ + +u32 ddr_wrdtr(u32 default_val) { + return (SDRAM_WRDTR_LLWP_1_CYC | SDRAM_WRDTR_WTR_180_DEG_ADV | 0x823); +} + +u32 ddr_clktr(u32 default_val) { + return (SDRAM_CLKTR_CLKP_90_DEG_ADV); +} + +static int pvr_460ex(void) +{ + u32 pvr = get_pvr(); + + if ((pvr == PVR_460EX_RA) || (pvr == PVR_460EX_SE_RA) || + (pvr == PVR_460EX_RB)) + return 1; + + return 0; +} + +int board_early_init_f(void) +{ + u32 sdr0_cust0; + + /* + * Setup the interrupt controller polarities, triggers, etc. + */ + + // Sam460ex IRQ MAP: + // IRQ0 = ETH_INT + // IRQ1 = FPGA_INT + // IRQ2 = PCI_INT (PCIA, PCIB, PCIC, PCIB) + // IRQ3 = FPGA_INT2 + // IRQ11 = RTC_INT + // IRQ12 = SM502_INT + + mtdcr(UIC0SR, 0xffffffff); /* clear all */ + mtdcr(UIC0ER, 0x00000000); /* disable all */ + mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */ + mtdcr(UIC0PR, 0xffffffff); /* per ref-board manual */ + mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */ + mtdcr(UIC0VR, 0x00000000); /* 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, 0xefffffff); /* IRQ2 neg */ + mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */ + mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */ + mtdcr(UIC1SR, 0xffffffff); /* clear all */ + + mtdcr(UIC2SR, 0xffffffff); /* clear all */ + mtdcr(UIC2ER, 0x00000000); /* disable all */ + mtdcr(UIC2CR, 0x00000000); /* all non-critical */ + mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */ + mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */ + mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */ + mtdcr(UIC2SR, 0xffffffff); /* clear all */ + + mtdcr(UIC3SR, 0xffffffff); /* clear all */ + mtdcr(UIC3ER, 0x00000000); /* disable all */ + mtdcr(UIC3CR, 0x00000000); /* all non-critical */ + mtdcr(UIC3PR, 0xffefffff); /* IRQ12 neg */ + mtdcr(UIC3TR, 0x00000000); /* per ref-board manual */ + mtdcr(UIC3VR, 0x00000000); /* int31 highest, base=0x000 */ + mtdcr(UIC3SR, 0xffffffff); /* clear all */ + + /* SDR Setting - enable NDFC */ + mfsdr(SDR0_CUST0, sdr0_cust0); + sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL | + SDR0_CUST0_NDFC_ENABLE | + SDR0_CUST0_NDFC_BW_8_BIT | + SDR0_CUST0_NDFC_ARE_MASK | + SDR0_CUST0_NDFC_BAC_ENCODE(3) | + (0x80000000 >> (28 + CONFIG_SYS_NAND_CS)); + mtsdr(SDR0_CUST0, sdr0_cust0); + + /* + * Configure PFC (Pin Function Control) registers + * Enable GPIO 49-63 + * UART0: 8 pins + */ + mtsdr(SDR0_PFC0, 0x00007fff); + mtsdr(SDR0_PFC1, 0x00000000); + + /* Enable PCI host functionality in SDR0_PCI0 */ + mtsdr(SDR0_PCI0, 0xa0000000); + + mtsdr(SDR0_SRST1, 0); /* Pull AHB out of reset default=1 */ + + /* Setup PLB4-AHB bridge based on the system address map */ + mtdcr(AHB_TOP, 0x8000004B); + mtdcr(AHB_BOT, 0x8000004B); + + return 0; +} + +static void canyonlands_sata_init(int board_type) +{ + u32 reg; + + if (board_type == BOARD_CANYONLANDS_SATA) { + /* Put SATA in reset */ + SDR_WRITE(SDR0_SRST1, 0x00020001); + + /* Set the phy for SATA, not PCI-E port 0 */ + reg = SDR_READ(PESDR0_PHY_CTL_RST); + SDR_WRITE(PESDR0_PHY_CTL_RST, (reg & 0xeffffffc) | 0x00000001); + reg = SDR_READ(PESDR0_L0CLK); + SDR_WRITE(PESDR0_L0CLK, (reg & 0xfffffff8) | 0x00000007); + SDR_WRITE(PESDR0_L0CDRCTL, 0x00003111); + SDR_WRITE(PESDR0_L0DRV, 0x00000104); + + /* Bring SATA out of reset */ + SDR_WRITE(SDR0_SRST1, 0x00000000); + } +} + +int checkboard(void) +{ + char s[64] = { 0 }; + + gd->board_type = BOARD_CANYONLANDS_PCIE; + getenv_r("serdes",s,64); + + if (strcmp(s,"sata2") == 0) + gd->board_type = BOARD_CANYONLANDS_SATA; + + puts("Board: Sam460ex, PCIe 4x + "); + + switch (gd->board_type) { + case BOARD_CANYONLANDS_PCIE: + puts("PCIe 1x\n"); + break; + + case BOARD_CANYONLANDS_SATA: + puts("SATA-2\n"); + break; + } + + canyonlands_sata_init(gd->board_type); + + return (0); +} + +/************************************************************************* + * 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 ) +{ + ppc460_hose = hose; + + return 1; +} +#endif /* defined(CONFIG_PCI) */ + +#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) +void pci_master_init(struct pci_controller *hose) +{ + /*--------------------------------------------------------------------------+ + | PowerPC440 PCI Master configuration. + | Map PLB/processor addresses to PCI memory space. + | PLB address 0xA0000000-0xCFFFFFFF ==> PCI address 0x80000000-0xCFFFFFFF + | Use byte reversed out routines to handle endianess. + | Make this region non-prefetchable. + +--------------------------------------------------------------------------*/ + out32r(PCIL0_POM0SA, 0 ); /* disable */ + out32r(PCIL0_POM1SA, 0 ); /* disable */ + out32r(PCIL0_POM2SA, 0 ); /* disable */ + + out32r(PCIL0_POM0LAL, CONFIG_SYS_PCI_MEMBASE); /* PMM0 Local Address */ + out32r(PCIL0_POM0LAH, 0x0000000c); /* PMM0 Local Address */ + out32r(PCIL0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE); /* PMM0 PCI Low Address */ + out32r(PCIL0_POM0PCIAH, 0x00000000); /* PMM0 PCI High Address */ + out32r(PCIL0_POM0SA, ~(0x10000000 - 1) | 1); /* 256MB + enable region */ + + out32r(PCIL0_POM1LAL, CONFIG_SYS_PCI_MEMBASE2); /* PMM0 Local Address */ + out32r(PCIL0_POM1LAH, 0x0000000c); /* PMM0 Local Address */ + out32r(PCIL0_POM1PCIAL, CONFIG_SYS_PCI_MEMBASE2); /* PMM0 PCI Low Address */ + out32r(PCIL0_POM1PCIAH, 0x00000000); /* PMM0 PCI High Address */ + out32r(PCIL0_POM1SA, ~(0x10000000 - 1) | 1); /* 256MB + enable region */ + + out_le16((void *)PCIL0_CMD, in16r(PCIL0_CMD) | PCI_COMMAND_MASTER); +} +#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */ + +#if defined(CONFIG_PCI) +int board_pcie_first(void) +{ + /* + * Canyonlands with SATA enabled has only one PCIe slot + * (2nd one). + */ + if (gd->board_type == BOARD_CANYONLANDS_SATA) + return 1; + + return 0; +} +#endif /* CONFIG_PCI */ + +int board_early_init_r (void) +{ + /* + * Clear potential errors resulting from auto-calibration. + * If not done, then we could get an interrupt later on when + * exceptions are enabled. + */ + + set_mcsr(get_mcsr()); + + return 0; +} + +int misc_init_r(void) +{ + u32 sdr0_srst1 = 0; + u32 eth_cfg; + u8 val; + + /* + * Set EMAC mode/configuration (GMII, SGMII, RGMII...). + * This is board specific, so let's do it here. + */ + mfsdr(SDR0_ETH_CFG, eth_cfg); + /* disable SGMII mode */ + eth_cfg &= ~(SDR0_ETH_CFG_SGMII2_ENABLE | + SDR0_ETH_CFG_SGMII1_ENABLE | + SDR0_ETH_CFG_SGMII0_ENABLE); + /* Set the for 2 RGMII mode */ + /* GMC0 EMAC4_0, GMC0 EMAC4_1, RGMII Bridge 0 */ + eth_cfg &= ~SDR0_ETH_CFG_GMC0_BRIDGE_SEL; + if (pvr_460ex()) + eth_cfg |= SDR0_ETH_CFG_GMC1_BRIDGE_SEL; + else + eth_cfg &= ~SDR0_ETH_CFG_GMC1_BRIDGE_SEL; + mtsdr(SDR0_ETH_CFG, eth_cfg); + + /* + * The AHB Bridge core is held in reset after power-on or reset + * so enable it now + */ + mfsdr(SDR0_SRST1, sdr0_srst1); + sdr0_srst1 &= ~SDR0_SRST1_AHB; + mtsdr(SDR0_SRST1, sdr0_srst1); + + /* + * RTC/M41T62: + * Disable square wave output: Batterie will be drained + * quickly, when this output is not disabled + */ + val = i2c_reg_read(CONFIG_SYS_I2C_RTC_ADDR, 0xa); + val &= ~0x40; + i2c_reg_write(CONFIG_SYS_I2C_RTC_ADDR, 0xa, val); + + return 0; +} + +#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) +void ft_board_setup(void *blob, bd_t *bd) +{ + u32 val[4]; + int rc; + + ft_cpu_setup(blob, bd); + + /* Fixup NOR mapping */ + val[0] = 0; /* chip select number */ + val[1] = 0; /* always 0 */ + val[2] = CONFIG_SYS_FLASH_BASE_PHYS_L; /* we fixed up this address */ + val[3] = gd->bd->bi_flashsize; + rc = fdt_find_and_setprop(blob, "/plb/opb/ebc", "ranges", + val, sizeof(val), 1); + if (rc) { + printf("Unable to update property NOR mapping, err=%s\n", + fdt_strerror(rc)); + } + + if (gd->board_type == BOARD_CANYONLANDS_SATA) { + /* + * When SATA is selected we need to disable the first PCIe + * node in the device tree, so that Linux doesn't initialize + * it. + */ + rc = fdt_find_and_setprop(blob, "/plb/pciex@d00000000", "status", + "disabled", sizeof("disabled"), 1); + if (rc) { + printf("Unable to update property status in PCIe node, err=%s\n", + fdt_strerror(rc)); + } + } + + if (gd->board_type == BOARD_CANYONLANDS_PCIE) { + /* + * When PCIe is selected we need to disable the SATA + * node in the device tree, so that Linux doesn't initialize + * it. + */ + rc = fdt_find_and_setprop(blob, "/plb/sata@bffd1000", "status", + "disabled", sizeof("disabled"), 1); + if (rc) { + printf("Unable to update property status in PCIe node, err=%s\n", + fdt_strerror(rc)); + } + } +} +#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ + +void pciauto_setup_device_mem(struct pci_controller *hose, + pci_dev_t dev, int bars_num, + struct pci_region *mem, + struct pci_region *prefetch, + struct pci_region *io, + pci_size_t bar_size_lower, + pci_size_t bar_size_upper) +{ + unsigned int bar_response, bar_back; + pci_addr_t bar_value; + pci_size_t bar_size; + struct pci_region *bar_res; + int bar, bar_nr = 0; + int found_mem64 = 0; + + for (bar = PCI_BASE_ADDRESS_0; bar < PCI_BASE_ADDRESS_0 + (bars_num*4); bar += 4) { + /* Tickle the BAR and get the response */ + pci_hose_read_config_dword(hose, dev, bar, &bar_back); + pci_hose_write_config_dword(hose, dev, bar, 0xffffffff); + pci_hose_read_config_dword(hose, dev, bar, &bar_response); + pci_hose_write_config_dword(hose, dev, bar, bar_back); + + /* If BAR is not implemented go to the next BAR */ + if (!bar_response) + continue; + + found_mem64 = 0; + + /* Check the BAR type and set our address mask */ + if ( ! (bar_response & PCI_BASE_ADDRESS_SPACE)) { + if ( (bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == + PCI_BASE_ADDRESS_MEM_TYPE_64) { + u32 bar_response_upper; + u64 bar64; + pci_hose_write_config_dword(hose, dev, bar+4, 0xffffffff); + pci_hose_read_config_dword(hose, dev, bar+4, &bar_response_upper); + + bar64 = ((u64)bar_response_upper << 32) | bar_response; + + bar_size = ~(bar64 & PCI_BASE_ADDRESS_MEM_MASK) + 1; + found_mem64 = 1; + } else { + bar_size = (u32)(~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1); + } + if (prefetch && (bar_response & PCI_BASE_ADDRESS_MEM_PREFETCH)) + bar_res = prefetch; + else + bar_res = mem; + + PRINTF("PCI Autoconfig: BAR %d, Mem, size=0x%llx, ", bar_nr, (u64)bar_size); + + if ((bar_size >= bar_size_lower) && (bar_size <= bar_size_upper)) { + if (pciauto_region_allocate(bar_res, bar_size, &bar_value) == 0) { + /* Write it out and update our limit */ + pci_hose_write_config_dword(hose, dev, bar, (u32)bar_value); + PRINTF(" BAR written value=0x%8x, ", (u32)bar_value); + + if (found_mem64) { + bar += 4; +#ifdef CONFIG_SYS_PCI_64BIT + pci_hose_write_config_dword(hose, dev, bar, (u32)(bar_value>>32)); +#else + /* + * If we are a 64-bit decoder then increment to the + * upper 32 bits of the bar and force it to locate + * in the lower 4GB of memory. + */ + pci_hose_write_config_dword(hose, dev, bar, 0x00000000); +#endif + } + } + } + } + + PRINTF("\n"); + + bar_nr++; + } +} + +void fix_pci_bars(void) +{ + struct pci_controller *hose = ppc460_hose; + unsigned int found_multi=0,problem=0,sec_func=0; + unsigned short vendor, device, class; + unsigned char header_type; + pci_dev_t dev; + u32 bar0; + + PRINTF("fix_pci_bars ++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for (dev = PCI_BDF(0,0,0); + dev < PCI_BDF(0,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); + dev += PCI_BDF(0,0,1)) { + + if (pci_skip_dev(hose, dev)) + continue; + + if (PCI_FUNC(dev) && !found_multi) + continue; + + pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type); + + pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor); + + if (vendor != 0xffff && vendor != 0x0000) { + + if (!PCI_FUNC(dev)) + found_multi = header_type & 0x80; + + pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class); + + PRINTF("PCI Scan: Found Bus %d, Device %d, Function %d - %x\n", + PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), class ); + + if (((PCI_BUS(dev)==0) && (PCI_DEV(dev)==4) && (PCI_FUNC(dev)==0)) && + ((class==0x300) || (class==0x380))) problem +=1; + + if (((PCI_BUS(dev)==0) && (PCI_DEV(dev)==4) && (PCI_FUNC(dev)==1)) && + ((class==0x300) || (class==0x380))) sec_func =1; + + if ((PCI_BUS(dev)==0) && (PCI_DEV(dev)==6) && (PCI_FUNC(dev)==0)) { + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); + bar0 = bar0 & 0xfffff000; + PRINTF("BAR0 = %8x\n",bar0); + + if ((bar0 == 0) || (bar0 >= 0x9c000000)) problem +=1; + } + } + } + + PRINTF("problem = %d\n",problem); + + if (problem >= 2) { + + pciauto_config_init(hose); + + /* setup MEM SPACE for PCI gfx card (big BARs) */ + dev = PCI_BDF(0,4,0); + pciauto_setup_device_mem(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io, 0x00100000, 0xFFFFFFFF); + + if (sec_func) { + dev = PCI_BDF(0,4,1); + pciauto_setup_device_mem(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io, 0x00100000, 0xFFFFFFFF); + } + + /* setup MEM SPACE for the onboard gfx card */ + dev = PCI_BDF(0,6,0); + pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io); + + /* setup MEM SPACE for PCI gfx card (small BARs) */ + dev = PCI_BDF(0,4,0); + pciauto_setup_device_mem(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io, 0x0, 0x000FFFFF); + + if (sec_func) { + dev = PCI_BDF(0,4,1); + pciauto_setup_device_mem(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io, 0x0, 0x000FFFFF); + } + } +} + +extern struct pci_controller pcie_hose[CONFIG_SYS_PCIE_NR_PORTS]; + +void assign_pci_irq (void) +{ + u8 ii, class, pin; + int BusNum, Device, Function; + unsigned char HeaderType; + unsigned short VendorID; + pci_dev_t dev; + + // On Board fixed PCI devices ------------------------- + + // Silicon Motion SM502 + if ((dev = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0)) >= 0) + { + // video IRQ connected to UIC3-20 ----------------- + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 116); + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); + } + + // Optional PCI devices on PCI Slots 33/66 Mhz -------- + + for (BusNum = 0; BusNum <= ppc460_hose->last_busno; BusNum++) + { + for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) + { + HeaderType = 0; + + for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) + { + if (Function && !(HeaderType & 0x80)) + break; + + dev = PCI_BDF(BusNum, Device, Function); + + if (dev != -1) + { + pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID); + if ((VendorID == 0xFFFF) || (VendorID == 0x0000)) + continue; + + if (!Function) + pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType); + + if ((BusNum == 0) && (Device == 0x06)) continue; + + pci_read_config_byte(dev, PCI_CLASS_CODE, &class); + + //if (class != PCI_BASE_CLASS_BRIDGE) + { + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + + if (pin > 0) + { + // all pci IRQ on external slot are connected to UIC1-0 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 32); + } + + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); + } + } + } + } + } + + // PCI-Express bus ---------------------------------------------- + + struct pci_controller *hose; + + for (ii = 0; ii < CONFIG_SYS_PCIE_NR_PORTS; ii++) + { + hose = &pcie_hose[ii]; + + if (hose) + { + if (hose->last_busno > hose->first_busno) + { + // there is card in the PCIE slot + // assume no bridge presents + + dev = PCI_BDF(hose->last_busno,0,0); + + if (dev != -1) + { + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + + if (pin > 0) + { + // PCIE 1x slot is connected to UIC3-0 + // PCIE 4x slot is connected to UIC3-6 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0x60 + ii*0x6); + } + } + } + } + } +} + +/* +void show_tlb(void) +{ + int i; + unsigned long tlb_word0_value; + unsigned long tlb_word1_value; + unsigned long tlb_word2_value; + + for (i=0; i<PPC4XX_TLB_SIZE; i++) + { + tlb_word0_value = mftlb1(i); + tlb_word1_value = mftlb2(i); + tlb_word2_value = mftlb3(i); + + printf("TLB %i, %08x %08x %08x\n",i,tlb_word0_value,tlb_word1_value,tlb_word2_value); + + if ((tlb_word0_value & TLB_WORD0_V_MASK) == TLB_WORD0_V_DISABLE) + break; + } +} +*/ +/* +void show_pcie_info(void) +{ + volatile void *mbase = NULL; + + mbase = (u32 *)CONFIG_SYS_PCIE0_XCFGBASE; + + printf("0:PEGPL_OMR1BA=%08x.%08x MSK=%08x.%08x\n", + mfdcr(DCRN_PEGPL_OMR1BAH(PCIE0)), + mfdcr(DCRN_PEGPL_OMR1BAL(PCIE0)), + mfdcr(DCRN_PEGPL_OMR1MSKH(PCIE0)), + mfdcr(DCRN_PEGPL_OMR1MSKL(PCIE0))); + + printf("0:PECFG_POM0LA=%08x.%08x\n", in_le32(mbase + PECFG_POM0LAH), + in_le32(mbase + PECFG_POM0LAL)); + + printf("0:PECFG_POM2LA=%08x.%08x\n", in_le32(mbase + PECFG_POM2LAH), + in_le32(mbase + PECFG_POM2LAL)); + + mbase = (u32 *)CONFIG_SYS_PCIE1_XCFGBASE; + + // pci-express bar0 + printf("1:PEGPL_OMR1BA=%08x.%08x MSK=%08x.%08x\n", + mfdcr(DCRN_PEGPL_OMR1BAH(PCIE1)), + mfdcr(DCRN_PEGPL_OMR1BAL(PCIE1)), + mfdcr(DCRN_PEGPL_OMR1MSKH(PCIE1)), + mfdcr(DCRN_PEGPL_OMR1MSKL(PCIE1))); + + printf("1:PECFG_POM0LA=%08x.%08x\n", in_le32(mbase + PECFG_POM0LAH), + in_le32(mbase + PECFG_POM0LAL)); + + printf("1:PECFG_POM2LA=%08x.%08x\n", in_le32(mbase + PECFG_POM2LAH), + in_le32(mbase + PECFG_POM2LAL)); + +} +*/ + +int last_stage_init (void) +{ + uchar buf; + int jj, ret = 0; + u16 fpga_val = 0; + + u32 val = mfspr(SPRN_MMUCR); + val = 0x00010000; + mtspr(SPRN_MMUCR,val); + + do_fpga(); + + // Red Led OFF ---------------------------------------- + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E); + fpga_val &= ~0x0002; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + + // fix possible menuboot_cmd misconfiguration --------- + char *s = getenv("menuboot_cmd"); + if ((!s) || + ((s) && (strlen(s) < 3)) || + ((s) && (strcmp(s,"noboot") == 0))) + { + setenv("menuboot_cmd","boota"); + saveenv(); + } + + fix_pci_bars(); + assign_pci_irq(); + + // cache on ------------------------------------------- + change_tlb(0, 256*1024*1024, 0); + + // SM502 Graphic card on PCI -------------------------- +#ifdef CONFIG_VIDEO_SM502 + init_sm502(); +#endif + + // x86 Graphic card on PCI ---------------------------- + ret = init_radeon(ppc460_hose); + + // active gfx card ------------------------------------ + SM502 = 0; // default VGA card + +#ifdef CONFIG_VIDEO_SM502 + s = getenv("video_activate"); + if ((strcmp(s, "sm502") == 0) && (SM502INIT)) SM502 = 1; + else if ((SM502INIT) && (ret == 0)) SM502 = 1; +#endif + + if (SM502 && SM502INIT) + { +#ifdef CONFIG_VIDEO_SM502 + fbi = (struct FrameBufferInfo *)(malloc(sizeof(struct FrameBufferInfo))); + if (fbi) + { + fbi->BaseAddress = fb_base_phys_sm502; + fbi->XSize = board_get_width(); + fbi->YSize = board_get_height(); + fbi->BitsPerPixel = 8; + fbi->Modulo = board_get_width(); + + onbus = 0; + drv_video_init(); + } +#endif + } + else if (ret > 0) + { + if (SM502INIT) + { + // shutdown onboard gfx card + unsigned short cmd; + + pci_read_config_word(dev_sm502, PCI_COMMAND, &cmd); + cmd &= ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY); + pci_write_config_word(dev_sm502, PCI_COMMAND, cmd); + } + } + + // custom silent mode --------------------------------- + int hush = 0; + s = getenv("hush"); + if (s) hush = atoi(s); + if (hush) { + s = getenv("stdout"); + if ((s) && (strncmp(s,"vga",3) == 0)) + gd->flags |= GD_FLG_SILENT; + } + +#ifdef SAMLOGO + // Welcome Screen ------------------------------------- + if (fbi) + { + unsigned int xx, yy, xoff = 0, yoff = 0; + + if (gd->flags & GD_FLG_SILENT) { + xoff = (fbi->XSize-LOGO_WIDTH) / 2; + yoff = (fbi->YSize-LOGO_HEIGHT) / 9; + } + else puts("\n\n\n\n"); + + for (xx = 0; xx < LOGO_WIDTH; xx++) + { + for (yy = 0; yy < LOGO_HEIGHT; yy++) + { + buf = logo_acube[xx + (LOGO_HEIGHT-yy-1)*LOGO_WIDTH]; + *((char *)(fbi->BaseAddress + (xx+xoff) + (yy+yoff)*fbi->XSize*(fbi->BitsPerPixel/8))) = buf; + } + } + } +#endif + + puts("Config: PCIe 4x + "); + + if (gd->board_type == BOARD_CANYONLANDS_PCIE) + puts("PCIe 1x\n"); + else + puts("SATA-2\n"); + + // cache off ------------------------------------------ + change_tlb(0, 256*1024*1024, TLB_WORD2_I_ENABLE); + + // Yellow LED OFF ------------------------------------- + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E); + fpga_val &= ~0x0004; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + + // Catweasel keyboard --------------------------------- + //ret = catw_kb_init(); + + // cleanup last 8 bytes of the RTC registers bank ----- + + char arr[8] = { 0 }; + i2c_write(0x68, 0x08, 1, &arr, 8); + + // USB Init ------------------------------------------- + + uint32_t cmd; + + SDR_WRITE(SDR0_SRST1, 0x00000008); + + //gpio_config(19, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1); + gpio_config(16, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1); + wait_ms(200); + + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x30); + fpga_val |= 0x0004; //0x0014; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x30, fpga_val); + wait_ms(200); + + SDR_WRITE(SDR0_SRST1, 0); + + cmd = in_le32(CONFIG_SYS_AHB_BASE | 0xd0410); + cmd |= 1 << 1; + out_le32(CONFIG_SYS_AHB_BASE | 0xd0410, cmd); + wait_ms(10); + + cmd = in_le32(CONFIG_SYS_AHB_BASE | 0xd0454); + cmd |= 1 << 12; + out_le32(CONFIG_SYS_AHB_BASE | 0xd0454, cmd); + wait_ms(10); + + cmd = in_le32(CONFIG_SYS_AHB_BASE | 0xd0410); + cmd |= 1 << 1; + out_le32(CONFIG_SYS_AHB_BASE | 0xd0410, cmd); + wait_ms(10); + + out_le32((void *)CONFIG_SYS_AHB_BASE + 0xd0048,0xff000001); + + s = getenv("usb_delay"); + if (s) { + ret = atoi(s) * 10; + if (ret <= 0) ret = 0; + if (ret > 2000) ret = 2000; + for (jj=0;jj<ret;jj++) udelay(10000); + } + + if (gd->flags & GD_FLG_SILENT) { + gd->flags &= ~GD_FLG_SILENT; + console_row = 29; + console_col = 28; + puts("Init USB... "); + gd->flags |= GD_FLG_SILENT; + } + + ret = usb_init(); + +#ifdef CONFIG_USB_STORAGE + // try to recognize storage devices immediately ------- + if (ret >= 0) + { + usb_event_poll(); + s = getenv("scan_usb_storage"); + if (s) usb_stor_scan(1); + } +#endif + + // Init SATA controller ------------------------------- + if (gd->flags & GD_FLG_SILENT) { + gd->flags &= ~GD_FLG_SILENT; + puts("Done - Init SATA... "); + gd->flags |= GD_FLG_SILENT; + } + + ide_controllers_init(); + + // Ambra LED OFF -------------------------------------- + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E); + fpga_val &= ~0x0008; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + + if (gd->flags & GD_FLG_SILENT) { + gd->flags &= ~GD_FLG_SILENT; + puts("Done\n"); + gd->flags |= GD_FLG_SILENT; + } + + //show_pcie_info(); + + //show_tlb(); + + return 0; +} + +void do_fpga(void) +{ + u8 tmp,dd,mm,yy,rv; + u16 fpga_val; + + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2a); + tmp = fpga_val & 0xff; + mm = (tmp/16)*10 + (tmp%16); + tmp = (fpga_val >> 8) & 0xff; + dd = (tmp/16)*10 + (tmp%16); + + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2c); + tmp = fpga_val & 0xff; + rv = (tmp/16)*10 + (tmp%16); + tmp = (fpga_val >> 8) & 0xff;; + yy = (tmp/16)*10 + (tmp%16); + + printf("FPGA: Revision %02d (20%2d-%02d-%02d)\n",rv,yy,mm,dd); +} + +void do_shutdown(void) +{ + u16 fpga_val; + + fpga_val = 0x000f; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + wait_ms(300); + fpga_val = 0x0000; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + wait_ms(300); + fpga_val = 0x000f; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + wait_ms(300); + + fpga_val = 0x0010; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + + while(1); // never return +} + +void board_reset(void) +{ + u16 fpga_val; + fpga_val = in_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E); + fpga_val |= 0x0010; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); + wait_ms(25); + fpga_val &= ~0x0010; + out_be16((void *)CONFIG_SYS_FPGA_BASE + 0x2E, fpga_val); +} + +U_BOOT_CMD( fpga, 1, 0, do_fpga, + "show FPGA firmware revision", + "show FPGA firmware revision"); + +U_BOOT_CMD( shutdown, 1, 0, do_shutdown, + "switch machine off", + "switch machine off"); diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/config.mk b/roms/u-boot-sam460ex/board/ACube/Sam460ex/config.mk new file mode 100644 index 000000000..2e72fcf3b --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/config.mk @@ -0,0 +1,45 @@ +# +# (C) Copyright 2008 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# ACube Systems Sam460EX Board +# + +sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp + +ifndef TEXT_BASE +TEXT_BASE = 0xFFF80000 +endif + +X86EMU = -I../bios_emulator/scitech/include -I../bios_emulator/scitech/src/x86emu + +# -fgnu89-inline requires gcc 4.2 (it can be omitted in previous versions) +PLATFORM_CPPFLAGS += -DCONFIG_440=1 $(X86EMU) -Dprintk=printf -fgnu89-inline + + +ifeq ($(debug),1) +PLATFORM_CPPFLAGS += -DDEBUG +endif + +ifeq ($(dbcr),1) +PLATFORM_CPPFLAGS += -DCONFIG_SYS_INIT_DBCR=0x8cff0000 +endif diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/init.S b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init.S new file mode 100644 index 000000000..15eaac08f --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init.S @@ -0,0 +1,89 @@ +/* + * (C) Copyright 2008 + * Stefan Roese, DENX Software Engineering, sr@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <ppc_asm.tmpl> +#include <config.h> +#include <asm/mmu.h> + +/************************************************************************** + * TLB TABLE + * + * This table is used by the cpu boot code to setup the initial tlb + * entries. Rather than make broad assumptions in the cpu source tree, + * this table lets each board set things up however they like. + * + * Pointer to the table is returned in r1 + * + *************************************************************************/ + .section .bootpg,"ax" + .globl tlbtab + +tlbtab: + tlbtab_start + + /* + * BOOT_CS (FLASH) must be first. Before relocation SA_I can be off to + * use the speed up boot process. It is patched after relocation to + * enable SA_I + */ + tlbentry(CONFIG_SYS_BOOT_BASE_ADDR, SZ_256M, CONFIG_SYS_BOOT_BASE_ADDR, 4, AC_R|AC_W|AC_X|SA_G) /* TLB 0 */ + + /* + * TLB entries for SDRAM are not needed on this platform. + * They are dynamically generated in the SPD DDR(2) detection + * routine. + */ + +#ifdef CONFIG_SYS_INIT_RAM_DCACHE + /* TLB-entry for init-ram in dcache (SA_I must be turned off!) */ + tlbentry(CONFIG_SYS_INIT_RAM_ADDR, SZ_4K, CONFIG_SYS_INIT_RAM_ADDR, 0, AC_R|AC_W|AC_X|SA_G) +#endif + + tlbentry(CONFIG_SYS_PCI_BASE, SZ_256M, 0x00000000, 0xC, AC_R|AC_W|SA_G|SA_I) + + tlbentry(CONFIG_SYS_PCI_MEMBASE, SZ_256M, CONFIG_SYS_PCI_MEMBASE, 0xC, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCI_MEMBASE + 0x10000000, SZ_256M, CONFIG_SYS_PCI_MEMBASE + 0x10000000, 0xC, AC_R|AC_W|SA_G|SA_I) + + tlbentry(CONFIG_SYS_PCIE_MEMBASE , SZ_256M, CONFIG_SYS_PCIE_MEMBASE , 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE_MEMBASE + 0x10000000, SZ_256M, CONFIG_SYS_PCIE_MEMBASE + 0x10000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE_MEMBASE + 0x20000000, SZ_256M, CONFIG_SYS_PCIE_MEMBASE + 0x20000000, 0xD, AC_R|AC_W|SA_G|SA_I) + //tlbentry(CONFIG_SYS_PCIE_MEMBASE + 0x30000000, SZ_256M, CONFIG_SYS_PCIE_MEMBASE + 0x30000000, 0xD, AC_R|AC_W|SA_G|SA_I) + + tlbentry(CONFIG_SYS_PCIE0_CFGBASE, SZ_16M, 0x00000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE1_CFGBASE, SZ_16M, 0x20000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE0_XCFGBASE, SZ_1K, 0x10000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE1_XCFGBASE, SZ_1K, 0x30000000, 0xD, AC_R|AC_W|SA_G|SA_I) + + /* PCIe UTL register */ + tlbentry(CONFIG_SYS_PCIE_BASE, SZ_16K, 0x08010000, 0xC, AC_R|AC_W|SA_G|SA_I) + + /* TLB-entry for OCM */ + tlbentry(CONFIG_SYS_OCM_BASE, SZ_1M, 0x00000000, 4, AC_RWX | SA_I) + + /* TLB-entry for Local Configuration registers => peripherals */ + tlbentry(CONFIG_SYS_LOCAL_CONF_REGS, SZ_16M, CONFIG_SYS_LOCAL_CONF_REGS, 4, AC_R|AC_W|AC_X|SA_G|SA_I) + + /* AHB: Internal USB Peripherals (USB, SATA) */ + tlbentry(CONFIG_SYS_AHB_BASE, SZ_1M, 0xbff00000, 4, AC_R|AC_W|AC_X|SA_G|SA_I) + + tlbtab_end diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_cn.S b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_cn.S new file mode 100644 index 000000000..0b667968a --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_cn.S @@ -0,0 +1,140 @@ +/* + * (C) Copyright 2008 + * Stefan Roese, DENX Software Engineering, sr@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <ppc_asm.tmpl> +#include <config.h> +#include <asm-ppc/mmu.h> + +/************************************************************************** + * TLB TABLE + * + * This table is used by the cpu boot code to setup the initial tlb + * entries. Rather than make broad assumptions in the cpu source tree, + * this table lets each board set things up however they like. + * + * Pointer to the table is returned in r1 + * + *************************************************************************/ + .section .bootpg,"ax" + .globl tlbtab + +tlbtab: + tlbtab_start + + /* + * BOOT_CS (FLASH) must be first. Before relocation SA_I can be off to + * use the speed up boot process. It is patched after relocation to + * enable SA_I + */ +#ifndef CONFIG_NAND_SPL + tlbentry(CONFIG_SYS_BOOT_BASE_ADDR, SZ_16M, CONFIG_SYS_BOOT_BASE_ADDR, 4, AC_R|AC_W|AC_X|SA_G) /* TLB 0 */ +#else + tlbentry(CONFIG_SYS_NAND_BOOT_SPL_SRC, SZ_4K, CONFIG_SYS_NAND_BOOT_SPL_SRC, 4, AC_R|AC_W|AC_X|SA_G) + tlbentry(CONFIG_SYS_SDRAM_BASE, SZ_256M, CONFIG_SYS_SDRAM_BASE, 0, AC_R|AC_W|AC_X|SA_G|SA_I) + tlbentry(256 << 20, SZ_256M, 256 << 20, 0, AC_R|AC_W|AC_X|SA_G|SA_I) +#endif + + /* + * TLB entries for SDRAM are not needed on this platform. + * They are dynamically generated in the SPD DDR(2) detection + * routine. + */ + +#ifdef CONFIG_SYS_INIT_RAM_DCACHE + /* TLB-entry for init-ram in dcache (SA_I must be turned off!) */ + tlbentry(CONFIG_SYS_INIT_RAM_ADDR, SZ_4K, CONFIG_SYS_INIT_RAM_ADDR, 0, AC_R|AC_W|AC_X|SA_G) +#endif + + tlbentry(CONFIG_SYS_PCI_BASE, SZ_256M, 0x00000000, 0xC, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCI_MEMBASE, SZ_256M, 0x20000000, 0xC, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE_MEMBASE, SZ_256M, 0xB0000000, 0xD, AC_R|AC_W|SA_G|SA_I) + + tlbentry(CONFIG_SYS_PCIE0_CFGBASE, SZ_16M, 0x00000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE1_CFGBASE, SZ_16M, 0x20000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE0_XCFGBASE, SZ_1K, 0x10000000, 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_PCIE1_XCFGBASE, SZ_1K, 0x30000000, 0xD, AC_R|AC_W|SA_G|SA_I) + + /* PCIe UTL register */ + tlbentry(CONFIG_SYS_PCIE_BASE, SZ_16K, 0x08010000, 0xC, AC_R|AC_W|SA_G|SA_I) + +#if !defined(CONFIG_ARCHES) + /* TLB-entry for NAND */ + tlbentry(CONFIG_SYS_NAND_ADDR, SZ_16M, CONFIG_SYS_NAND_ADDR, 4, AC_R|AC_W|AC_X|SA_G|SA_I) + + /* TLB-entry for CPLD */ + tlbentry(CONFIG_SYS_BCSR_BASE, SZ_1K, CONFIG_SYS_BCSR_BASE, 4, AC_R|AC_W|SA_G|SA_I) +#else + /* TLB-entry for FPGA */ + tlbentry(CONFIG_SYS_FPGA_BASE, SZ_16M, CONFIG_SYS_FPGA_BASE, 4, AC_R|AC_W|SA_G|SA_I) +#endif + + /* TLB-entry for OCM */ + tlbentry(CONFIG_SYS_OCM_BASE, SZ_1M, 0x00000000, 4, AC_R|AC_W|AC_X|SA_I) + + /* TLB-entry for Local Configuration registers => peripherals */ + tlbentry(CONFIG_SYS_LOCAL_CONF_REGS, SZ_16M, CONFIG_SYS_LOCAL_CONF_REGS, 4, AC_R|AC_W|AC_X|SA_G|SA_I) + + /* AHB: Internal USB Peripherals (USB, SATA) */ + tlbentry(CONFIG_SYS_AHB_BASE, SZ_1M, 0xbff00000, 4, AC_R|AC_W|AC_X|SA_G|SA_I) + +#if defined(CONFIG_RAPIDIO) + /* TLB-entries for RapidIO (SRIO) */ + tlbentry(CONFIG_SYS_SRGPL0_REG_BAR, SZ_16M, CONFIG_SYS_SRGPL0_REG_BAR, + 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_SRGPL0_CFG_BAR, SZ_16M, CONFIG_SYS_SRGPL0_CFG_BAR, + 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_SRGPL0_MNT_BAR, SZ_16M, CONFIG_SYS_SRGPL0_MNT_BAR, + 0xD, AC_R|AC_W|SA_G|SA_I) + tlbentry(CONFIG_SYS_I2ODMA_BASE, SZ_1K, 0x00100000, + 0x4, AC_R|AC_W|SA_G|SA_I) +#endif + + tlbtab_end + +#if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) + /* + * For NAND booting the first TLB has to be reconfigured to full size + * and with caching disabled after running from RAM! + */ +#define TLB00 TLB0(CONFIG_SYS_BOOT_BASE_ADDR, SZ_256M) +#define TLB01 TLB1(CONFIG_SYS_BOOT_BASE_ADDR, 1) +#define TLB02 TLB2(AC_R|AC_W|AC_X|SA_G|SA_I) + + .globl reconfig_tlb0 +reconfig_tlb0: + sync + isync + addi r4,r0,0x0000 /* TLB entry #0 */ + lis r5,TLB00@h + ori r5,r5,TLB00@l + tlbwe r5,r4,0x0000 /* Save it out */ + lis r5,TLB01@h + ori r5,r5,TLB01@l + tlbwe r5,r4,0x0001 /* Save it out */ + lis r5,TLB02@h + ori r5,r5,TLB02@l + tlbwe r5,r4,0x0002 /* Save it out */ + sync + isync + blr +#endif diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_radeon.c b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_radeon.c new file mode 100644 index 000000000..88b25a0cd --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/init_radeon.c @@ -0,0 +1,290 @@ +/* + * (C) Copyright 2009-2011 + * Max Tretene, ACube Systems Srl. mtretene@acube-systems.com. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <pci.h> +#include <sm501.h> +#include <video_fb.h> +#include "../common/vesa.h" + +DECLARE_GLOBAL_DATA_PTR; + +#undef DEBUG + +#ifdef DEBUG +#define PRINTF(fmt,args...) printf (fmt ,##args) +#else +#define PRINTF(fmt,args...) +#endif + +extern int execute_bios(pci_dev_t gr_dev, void *); + +u32 fb_base_phys = 0; +u32 mmio_base_phys = 0; +u32 io_base_phys = 0; + +int onbus = -1; + +struct FrameBufferInfo *fbi = NULL; + +pci_dev_t pci_find_radeon(struct pci_controller *ppc460_hose) +{ + struct pci_controller * hose; + u16 vendor; + u8 header_type; + pci_dev_t bdf; + int bus, found_multi = 0; + + static struct pci_device_id id; + + id.vendor = PCI_VENDOR_ID_ATI; + + for (hose = ppc460_hose; hose; hose = hose->next) + { + for (bus = 0; bus <= hose->last_busno; bus++) + { + PRINTF("pci_find_radeon %d\n",bus); + + for (bdf = PCI_BDF(bus,0,0); + bdf < PCI_BDF(bus+1,0,0); + bdf += PCI_BDF(0,0,1)) + { + if (!PCI_FUNC(bdf)) { + pci_read_config_byte(bdf, + PCI_HEADER_TYPE, + &header_type); + + found_multi = header_type & 0x80; + } else { + if (!found_multi) + continue; + } + + pci_read_config_word(bdf, + PCI_VENDOR_ID, + &vendor); + + if (vendor == id.vendor) + { + onbus = bus; + return bdf; + } + } + } + } + + return (-1); +} + +int init_radeon(struct pci_controller *hose) +{ + int jj; + unsigned char agp_control; + unsigned short cmd, devcmd; + pci_dev_t dev = ~0; + pci_dev_t bridge = ~0; + + puts("VGA: "); + + dev = pci_find_radeon(hose); + + if (dev != -1) + { + PRINTF("RADEON found on %02x:%02x:%02x\n", + PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev)); + + // ---------------------------------------------------------- + + PRINTF("Shutting down graphics card at %x.%x.%x\n", + PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev)); + + // Graphics card... + pci_read_config_word(dev, PCI_COMMAND, &cmd); + + devcmd = cmd; + cmd &= ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY); + + pci_write_config_word(dev, PCI_COMMAND, cmd); + PRINTF(" CMD register now %X\n", cmd); + + // ---------------------------------------------------------- + + //bridge = pci_find_bridge_for_bus(hose, PCI_BUS(dev)); + + bridge = PCI_BDF(0,0,0); + PRINTF("Behind bridge (%d) at %02x:%02x:%02x\n", bridge, + PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge)); + + pci_read_config_byte(bridge, 0x3E, &agp_control); + agp_control |= 0x18; + pci_write_config_byte(bridge, 0x3E, agp_control); + + // ---------------------------------------------------------- + + PRINTF("Re-enabling %x.%x.%x\n", + PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev)); + + pci_write_config_word(dev, + PCI_COMMAND, devcmd | PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + + // ---------------------------------------------------------- + +#ifdef DEBUG2 + PRINTF("\nCard Summary\n------------\n"); + { + int bar, found_mem64; + unsigned int bar_response; + unsigned int io, mem; + pci_addr_t bar_value; + pci_size_t bar_size; + + for (bar = PCI_BASE_ADDRESS_0; bar < PCI_BASE_ADDRESS_5; bar += 4) { + pci_write_config_dword (dev, bar, 0xffffffff); + pci_read_config_dword (dev, bar, &bar_response); + + if (!bar_response) + continue; + + found_mem64 = 0; + io = 0; + mem = 0; + + /* Check the BAR type and set our address mask */ + if (bar_response & PCI_BASE_ADDRESS_SPACE) { + bar_size = ~(bar_response & PCI_BASE_ADDRESS_IO_MASK) + 1; + /* round up region base address to a multiple of size */ + io = 1; //((io - 1) | (bar_size - 1)) + 1; + //bar_value = io; + /* compute new region base address */ + //io = io + bar_size; + } else { + if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == + PCI_BASE_ADDRESS_MEM_TYPE_64) { + u32 bar_response_upper; + u64 bar64; + pci_write_config_dword(dev, bar+4, 0xffffffff); + pci_read_config_dword(dev, bar+4, &bar_response_upper); + + bar64 = ((u64)bar_response_upper << 32) | bar_response; + + bar_size = ~(bar64 & PCI_BASE_ADDRESS_MEM_MASK) + 1; + found_mem64 = 1; + } else { + bar_size = (u32)(~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1); + } + + /* round up region base address to multiple of size */ + mem = 1; //((mem - 1) | (bar_size - 1)) + 1; + //bar_value = mem; + /* compute new region base address */ + //mem = mem + bar_size; + } + + u32 low, high; + low = bar_size & 0xffffffff; + if (found_mem64) high = (bar_size >> 32) & 0xffffffff; + else high = 0; + + PRINTF("bar_size = %08x%08x, io = %x, mem = %x mem64 = %x\n", high, low, io, mem, found_mem64); + + if (found_mem64) bar += 4; + } + } +#endif + + pci_read_config_dword(dev, PCI_BASE_ADDRESS_2, &mmio_base_phys); + mmio_base_phys &= ~0x0F; + PRINTF("mmio_base_phys = %08x\n",mmio_base_phys); + + /* here we assume that a Radeon is on bus 0 (PCI) */ + /* and a RadeonHD is on bus 1 or higher (PCI or PCI-E) */ + + if (onbus == 0) + pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &io_base_phys); + else + pci_read_config_dword(dev, PCI_BASE_ADDRESS_4, &io_base_phys); + + io_base_phys &= ~0x0F; + PRINTF("io_base = %08x\n",io_base_phys); + + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &fb_base_phys); + fb_base_phys &= ~0x0F; + PRINTF("fb_base = %08x\n",fb_base_phys); + + PRINTF("executing bios onbus=%d\n",onbus); + + if (execute_bios(dev, TEXT_BASE)) + { + puts("1\n"); + + u32 *tmp = fb_base_phys; + + jj = (640 * 480) / 4; + while (jj--) + *tmp++ = 0; + + puts("VESA: "); + + // 257 = 640 x 480 - 8 bit + // 259 = 800 x 600 - 8 bit + fbi = set_vesa_mode(257); + + if (fbi) + { + puts("OK\n"); + + // fixme: there is a problem with some radeon cards + // the fbi structure isn't filled with the required + // information, here we fill it in such case + + PRINTF("%08x %d %d %d %d\n",fbi->BaseAddress, + fbi->XSize, + fbi->YSize, + fbi->BitsPerPixel, + fbi->Modulo); + + if (fbi->BaseAddress != fb_base_phys) + { + fbi->BaseAddress = fb_base_phys; + fbi->XSize = 640; + fbi->YSize = 480; + fbi->BitsPerPixel = 8; + fbi->Modulo = 640; + + PRINTF("%08x %d %d %d %d\n",fbi->BaseAddress, + fbi->XSize, + fbi->YSize, + fbi->BitsPerPixel, + fbi->Modulo); + } + + drv_video_init(); + } + else + puts("ERROR\n"); + + return 1; + } + else puts("ERROR EXECUTING BIOS\n"); + } + else puts("NO CARDS\n"); + + return 0; +} diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot-nand.lds b/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot-nand.lds new file mode 100644 index 000000000..d18c53615 --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot-nand.lds @@ -0,0 +1,135 @@ +/* + * (C) Copyright 2008 + * Stefan Roese, DENX Software Engineering, sr@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +OUTPUT_ARCH(powerpc) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) } + .rela.text : { *(.rela.text) } + .rel.data : { *(.rel.data) } + .rela.data : { *(.rela.data) } + .rel.rodata : { *(.rel.rodata) } + .rela.rodata : { *(.rela.rodata) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } + .plt : { *(.plt) } + .text : + { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */ + + cpu/ppc4xx/start.o (.text) + + /* Align to next NAND block */ + . = ALIGN(0x20000); + common/env_embedded.o (.ppcenv) + /* Keep some space here for redundant env and potential bad env blocks */ + . = ALIGN(0x80000); + + *(.text) + *(.fixup) + *(.got1) + } + _etext = .; + PROVIDE (etext = .); + .rodata : + { + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) + } + .fini : { *(.fini) } =0 + .ctors : { *(.ctors) } + .dtors : { *(.dtors) } + + /* Read-write section, merged into data segment: */ + . = (. + 0x00FF) & 0xFFFFFF00; + _erotext = .; + PROVIDE (erotext = .); + .reloc : + { + *(.got) + _GOT2_TABLE_ = .; + *(.got2) + _FIXUP_TABLE_ = .; + *(.fixup) + } + __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2; + __fixup_entries = (. - _FIXUP_TABLE_)>>2; + + .data : + { + *(.data) + *(.data1) + *(.sdata) + *(.sdata2) + *(.dynamic) + CONSTRUCTORS + } + _edata = .; + PROVIDE (edata = .); + + . = .; + __u_boot_cmd_start = .; + .u_boot_cmd : { *(.u_boot_cmd) } + __u_boot_cmd_end = .; + + + . = .; + __start___ex_table = .; + __ex_table : { *(__ex_table) } + __stop___ex_table = .; + + . = ALIGN(256); + __init_begin = .; + .text.init : { *(.text.init) } + .data.init : { *(.data.init) } + . = ALIGN(256); + __init_end = .; + + __bss_start = .; + .bss (NOLOAD) : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + . = ALIGN(4); + } + + _end = . ; + PROVIDE (end = .); +} diff --git a/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot.lds b/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot.lds new file mode 100644 index 000000000..580eefe11 --- /dev/null +++ b/roms/u-boot-sam460ex/board/ACube/Sam460ex/u-boot.lds @@ -0,0 +1,110 @@ +/* + * (C) Copyright 2008 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +OUTPUT_ARCH(powerpc) +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + .resetvec 0xFFFFFFFC : + { + *(.resetvec) + } = 0xffff + + .bootpg 0xFFFFF000 : + { + arch/powerpc/cpu/ppc4xx/start.o (.text) + } = 0xffff + + /* Read-only sections, merged into text segment: */ + . = + SIZEOF_HEADERS; + .text : + { + /* WARNING - the following is hand-optimized to fit within */ + /* the sector layout of our flash chips! XXX FIXME XXX */ + + arch/powerpc/cpu/ppc4xx/start.o (.text) + + *(.text*) + } + _etext = .; + PROVIDE (etext = .); + .rodata : + { + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) + } + + /* Read-write section, merged into data segment: */ + . = (. + 0x00FF) & 0xFFFFFF00; + _erotext = .; + PROVIDE (erotext = .); + .reloc : + { + KEEP(*(.got)) + _GOT2_TABLE_ = .; + KEEP(*(.got2)) + _FIXUP_TABLE_ = .; + KEEP(*(.fixup)) + } + __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2; + __fixup_entries = (. - _FIXUP_TABLE_)>>2; + + .data : + { + *(.data*)
+ *(.sdata*) + } + _edata = .; + PROVIDE (edata = .); + + . = .; + __u_boot_cmd_start = .; + .u_boot_cmd : { *(.u_boot_cmd) } + __u_boot_cmd_end = .; + + + . = .; + __start___ex_table = .; + __ex_table : { *(__ex_table) } + __stop___ex_table = .; + + . = ALIGN(256); + __init_begin = .; + .text.init : { *(.text.init) } + .data.init : { *(.data.init) } + . = ALIGN(256); + __init_end = .; + + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + . = ALIGN(4); + } + + _end = . ; + PROVIDE (end = .); +} |