From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kumar Gala Date: Fri, 14 Jan 2011 05:51:12 -0600 Subject: [U-Boot] [PATCH v4] mpq101: initial support for Mercury Computer Systems MPQ101 board In-Reply-To: <101603.97416.qm@web37606.mail.mud.yahoo.com> References: <101603.97416.qm@web37606.mail.mud.yahoo.com> Message-ID: <1575B4A8-A839-4C05-AA54-B625CDAAE982@kernel.crashing.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Jan 14, 2011, at 3:10 AM, Alex Dubov wrote: > Mpq101 is a RapidIO development board in AMC form factor, featuring MPC8548 > processor, 512MB of hardwired DDR2 RAM, 128MB of hardwired NAND flash > memory, real time clock and additional serial EEPROM on i2c bus (enabled). > USB controller is available, but not presently enabled. > > Additional board information is available at: > http://www.mc.com/products/boards/ensemble_mpq101_rapidio_powerquicc_iii.aspx > > Environment is configured to precede the actual u-boot image so that it's > located at the beginning of flash erase block (made necessary by the recent > changes to the embedded environment handling). > > Signed-off-by: Alex Dubov > --- > Changes for v4: > - Replace config.mk supplied linker flags with custom linker script. > - Fix checkpatch errors. > Changes for v3: > - Use io accessor functions for all mmio accesses. > - Add configuration options for RTC and EEPROM on I2C buses. > Changes for v2: > - Remove some stale configuration code from board initialization functions. > > MAINTAINERS | 3 + > board/mercury/mpq101/Makefile | 53 +++++ > board/mercury/mpq101/law.c | 55 ++++++ > board/mercury/mpq101/mpq101.c | 140 ++++++++++++++ > board/mercury/mpq101/tlb.c | 82 ++++++++ > board/mercury/mpq101/u-boot.lds | 132 +++++++++++++ > boards.cfg | 1 + > include/configs/mpq101.h | 398 +++++++++++++++++++++++++++++++++++++++ > 8 files changed, 864 insertions(+), 0 deletions(-) > create mode 100644 board/mercury/mpq101/Makefile > create mode 100644 board/mercury/mpq101/law.c > create mode 100644 board/mercury/mpq101/mpq101.c > create mode 100644 board/mercury/mpq101/tlb.c > create mode 100644 board/mercury/mpq101/u-boot.lds > create mode 100644 include/configs/mpq101.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index d7cd09c..220c39d 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -138,6 +138,9 @@ Jon Diekema > > sbc8260 MPC8260 > > +Alex Dubov > + mpq101 MPC8548 > + > Dirk Eibach > > devconcenter PPC460EX > diff --git a/board/mercury/mpq101/Makefile b/board/mercury/mpq101/Makefile > new file mode 100644 > index 0000000..58bc1b3 > --- /dev/null > +++ b/board/mercury/mpq101/Makefile > @@ -0,0 +1,53 @@ > +# > +# Copyright 2007 Freescale Semiconductor, Inc. > +# (C) Copyright 2001-2006 > +# Wolfgang Denk, DENX Software Engineering, wd at 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 > + > +LIB = $(obj)lib$(BOARD).o > + > +COBJS-y += $(BOARD).o > +COBJS-y += law.o > +COBJS-y += tlb.o > + > +SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) > +OBJS := $(addprefix $(obj),$(COBJS-y)) > +SOBJS := $(addprefix $(obj),$(SOBJS)) > + > +$(LIB): $(obj).depend $(OBJS) $(SOBJS) > + $(call cmd_link_o_target, $(OBJS)) > + > +clean: > + rm -f $(OBJS) $(SOBJS) > + > +distclean: clean > + rm -f $(LIB) core *.bak .depend > + > +######################################################################### > + > +# defines $(obj).depend target > +include $(SRCTREE)/rules.mk > + > +sinclude $(obj).depend > + > +######################################################################### > diff --git a/board/mercury/mpq101/law.c b/board/mercury/mpq101/law.c > new file mode 100644 > index 0000000..726b5c2 > --- /dev/null > +++ b/board/mercury/mpq101/law.c > @@ -0,0 +1,55 @@ > +/* > + * Copyright 2008 Freescale Semiconductor, Inc. > + * > + * (C) Copyright 2000 > + * Wolfgang Denk, DENX Software Engineering, wd at 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 > +#include > +#include > + > +/* > + * LAW(Local Access Window) configuration: > + * > + * 0x0000_0000 0x1fff_ffff DDR SYS_SDRAM_SIZE > + * 0xc000_0000 0xdfff_ffff RapidIO 512M > + * 0xe000_0000 0xe000_ffff CCSR 1M > + * 0xf000_0000 0xffff_ffff LBC options + FLASH 256M > + * > + * Notes: > + * CCSRBAR and L2-as-SRAM don't need a configured Local Access Window. > + * If flash is 8M at default position (last 8M), no LAW needed. > + * > + * LAW 0 is reserved for boot mapping > + */ > + > +struct law_entry law_table[] = { > + SET_LAW(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_SIZE_LOG - 1, > + LAW_TRGT_IF_DDR_1), > +#ifdef CONFIG_SYS_RIO_MEM_PHYS > + SET_LAW(CONFIG_SYS_RIO_MEM_PHYS, LAW_SIZE_512M, LAW_TRGT_IF_RIO), > +#endif > + SET_LAW(CONFIG_SYS_LBC_OPTION_BASE_PHYS, LAW_SIZE_256M, > + LAW_TRGT_IF_LBC) > +}; > + > +int num_law_entries = ARRAY_SIZE(law_table); > diff --git a/board/mercury/mpq101/mpq101.c b/board/mercury/mpq101/mpq101.c > new file mode 100644 > index 0000000..8d9b518 > --- /dev/null > +++ b/board/mercury/mpq101/mpq101.c > @@ -0,0 +1,140 @@ > +/* > + * (C) Copyright 2011 Alex Dubov > + * > + * 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +unsigned long get_clock_freq(void) > +{ > + return 33000000; > +} > + > +/* > + * Initialize Local Bus > + */ > +void local_bus_init(void) > +{ > + fsl_lbc_t *lbc = LBC_BASE_ADDR; > + > + out_be32(&lbc->ltesr, 0xffffffff); /* Clear LBC error interrupts */ > + out_be32(&lbc->lteir, 0xffffffff); /* Enable LBC error interrupts */ > +} > + > +int checkboard(void) > +{ > + ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); > + ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); > + > + puts("Board: Mercury Computer Systems, Inc. MPQ-101 "); > +#ifdef CONFIG_PHYS_64BIT > + puts("(36-bit addrmap) "); > +#endif > + putc('\n'); > + > + /* > + * Initialize local bus. > + */ > + local_bus_init(); > + > + /* > + * Hack TSEC 3 and 4 IO voltages. > + */ > + out_be32(&gur->tsec34ioovcr, 0xe7e0); /* 1110 0111 1110 0xxx */ > + > + out_be32(&ecm->eedr, 0xffffffff); /* clear ecm errors */ > + out_be32(&ecm->eeer, 0xffffffff); /* enable ecm errors */ > + return 0; > +} > + > +phys_size_t initdram(int board_type) > +{ > + ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR); > + phys_size_t dram_size = 0; > + const char *p_mode = getenv("perf_mode"); > + > + puts("Initializing...."); > + > + out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS); > + out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG); > + > + out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3); > + out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0); > + > + if (p_mode && !strcmp("performance", p_mode)) { > + out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1_PERF); > + out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2_PERF); > + out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1_PERF); > + out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2_PERF); > + out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL_PERF); > + } else { > + out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1); > + out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2); > + out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1); > + out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2); > + out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL); > + } > + > + out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CTRL); > + out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_CONTROL2); > + > + asm("sync;isync"); > + udelay(500); > + > + out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL); > + asm("sync; isync"); > + udelay(500); > + > + dram_size = setup_ddr_tlbs(1ull << (CONFIG_SYS_SDRAM_SIZE_LOG - 20)); > + > + puts(" DDR: "); > + > + return get_ram_size(0, dram_size << 20); > +} > + > + > +void pci_init_board(void) > +{ > + ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); > + > + /* PCI is disabled */ > + out_be32(&gur->devdisr, in_be32(&gur->devdisr) > + | MPC85xx_DEVDISR_PCI1 > + | MPC85xx_DEVDISR_PCI2 > + | MPC85xx_DEVDISR_PCIE); > +} > diff --git a/include/configs/mpq101.h b/include/configs/mpq101.h > new file mode 100644 > index 0000000..33d6b69 > --- /dev/null > +++ b/include/configs/mpq101.h > @@ -0,0 +1,398 @@ > +/* > + * Copyright 2011 Alex Dubov > + * > + * 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 > + */ > + > +/* > + * Merury Computers MPQ101 board configuration file > + * > + */ > +#ifndef __CONFIG_H > +#define __CONFIG_H > + > +#ifdef CONFIG_36BIT > +# define CONFIG_PHYS_64BIT 1 > +#endif > + > +/* High Level Configuration Options */ > +#define CONFIG_BOOKE 1 /* BOOKE */ > +#define CONFIG_E500 1 /* BOOKE e500 family */ > +#define CONFIG_MPC85xx 1 /* MPC8540/60/55/41/48 */ > +#define CONFIG_MPC8548 1 /* MPC8548 specific */ > +#define CONFIG_MPQ101 1 /* MPQ101 board specific */ > + > +#define CONFIG_RIO 1 > +#define CONFIG_TSEC_ENET 1 /* tsec ethernet support */ > +#define CONFIG_INTERRUPTS 1 /* enable pci, srio, ddr interrupts */ > +#define CONFIG_FSL_LAW 1 /* Use common FSL init code */ > + > +/* > + * These can be toggled for performance analysis, otherwise use default. > + */ > +#define CONFIG_L2_CACHE 1 /* toggle L2 cache */ > +#define CONFIG_BTB 1 /* toggle branch predition */ > + > +#define CONFIG_PANIC_HANG 1 > + > +/* > + * Only possible on E500 Version 2 or newer cores. > + */ > +#define CONFIG_ENABLE_36BIT_PHYS 1 > + > +#ifdef CONFIG_PHYS_64BIT > +# define CONFIG_ADDR_MAP 1 > +# define CONFIG_SYS_NUM_ADDR_MAP 16 /* number of TLB1 entries */ > +#endif > + > +#ifndef __ASSEMBLY__ > +extern unsigned long get_clock_freq(void); > +#endif > + > +#define CONFIG_SYS_CLK_FREQ get_clock_freq() /* sysclk for MPC85xx */ > + > +/* You don't really need a function here for get_clock_freq() you can just: #define CONFIG_SYS_CLK_FREQ 33000000 - k