diff options
Diffstat (limited to 'board')
-rw-r--r-- | board/digsy_mtc/Makefile | 2 | ||||
-rw-r--r-- | board/digsy_mtc/cmd_mtc.c | 350 | ||||
-rw-r--r-- | board/digsy_mtc/cmd_mtc.h | 60 | ||||
-rw-r--r-- | board/digsy_mtc/digsy_mtc.c | 12 | ||||
-rw-r--r-- | board/freescale/common/sys_eeprom.c | 6 | ||||
-rw-r--r-- | board/freescale/mpc8360emds/mpc8360emds.c | 4 | ||||
-rw-r--r-- | board/freescale/mpc8360erdk/mpc8360erdk.c | 4 | ||||
-rw-r--r-- | board/freescale/mpc837xemds/mpc837xemds.c | 4 | ||||
-rw-r--r-- | board/freescale/mpc837xerdb/mpc837xerdb.c | 4 | ||||
-rw-r--r-- | board/freescale/p2020ds/p2020ds.c | 3 | ||||
-rw-r--r-- | board/keymile/kmeter1/kmeter1.c | 4 | ||||
-rw-r--r-- | board/mpc8540eval/mpc8540eval.c | 33 | ||||
-rw-r--r-- | board/sbc8560/sbc8560.c | 33 | ||||
-rw-r--r-- | board/xes/xpedite5170/Makefile | 52 | ||||
-rw-r--r-- | board/xes/xpedite5170/config.mk | 32 | ||||
-rw-r--r-- | board/xes/xpedite5170/ddr.c | 168 | ||||
-rw-r--r-- | board/xes/xpedite5170/law.c | 52 | ||||
-rw-r--r-- | board/xes/xpedite5170/u-boot.lds | 132 | ||||
-rw-r--r-- | board/xes/xpedite5170/xpedite5170.c | 111 |
19 files changed, 988 insertions, 78 deletions
diff --git a/board/digsy_mtc/Makefile b/board/digsy_mtc/Makefile index 7d659e5..0bededc 100644 --- a/board/digsy_mtc/Makefile +++ b/board/digsy_mtc/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).a -COBJS := $(BOARD).o +COBJS := $(BOARD).o cmd_mtc.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/digsy_mtc/cmd_mtc.c b/board/digsy_mtc/cmd_mtc.c new file mode 100644 index 0000000..9e377cd --- /dev/null +++ b/board/digsy_mtc/cmd_mtc.c @@ -0,0 +1,350 @@ +/* + * (C) Copyright 2009 + * Werner Pfister <Pfister_Werner@intercontrol.de> + * + * (C) Copyright 2009 Semihalf, Grzegorz Bernacki + * + * 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 <common.h> +#include <command.h> +#include <mpc5xxx.h> +#include "spi.h" +#include "cmd_mtc.h" + +DECLARE_GLOBAL_DATA_PTR; + +static const char *led_names[] = { + "diag", + "can1", + "can2", + "can3", + "can4", + "usbpwr", + "usbbusy", + "user1", + "user2", + "" +}; + +static void mtc_calculate_checksum(tx_msp_cmd *packet) +{ + int i; + uchar *buff; + + buff = (uchar *) packet; + + for (i = 0; i < 6; i++) + packet->cks += buff[i]; +} + +static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + int i; + + if (argc < 2) { + cmd_usage(cmdtp); + return -1; + } + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_SET_LED; + + pcmd.cmd_val0 = 0xff; + for (i = 0; strlen(led_names[i]) != 0; i++) { + if (strncmp(argv[1], led_names[i], strlen(led_names[i])) == 0) { + pcmd.cmd_val0 = i; + break; + } + } + + if (pcmd.cmd_val0 == 0xff) { + printf("Usage:\n%s\n", cmdtp->help); + return -1; + } + + if (argc >= 3) { + if (strncmp(argv[2], "red", 3) == 0) + pcmd.cmd_val1 = 1; + else if (strncmp(argv[2], "green", 5) == 0) + pcmd.cmd_val1 = 2; + else if (strncmp(argv[2], "orange", 6) == 0) + pcmd.cmd_val1 = 3; + else + pcmd.cmd_val1 = 0; + } + + if (argc >= 4) + pcmd.cmd_val2 = simple_strtol(argv[3], NULL, 10); + else + pcmd.cmd_val2 = 0; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + return err; +} + +static int do_mtc_key(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_GET_VIM; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + if (!err) { + /* function returns '0' if key is pressed */ + err = (prx.input & 0x80) ? 0 : 1; + } + + return err; +} + +static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + uchar channel_mask = 0; + + if (argc < 3) { + cmd_usage(cmdtp); + return -1; + } + + if (strncmp(argv[1], "on", 2) == 0) + channel_mask |= 1; + if (strncmp(argv[2], "on", 2) == 0) + channel_mask |= 2; + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_GET_VIM; + pcmd.user_out = channel_mask; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + return err; +} + +static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + uchar channel_num = 0; + + if (argc < 2) { + cmd_usage(cmdtp); + return -1; + } + + channel_num = simple_strtol(argv[1], NULL, 10); + if ((channel_num != 1) && (channel_num != 2)) { + printf("mtc digin: invalid parameter - must be '1' or '2'\n"); + return -1; + } + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_GET_VIM; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + if (!err) { + /* function returns '0' when digin is on */ + err = (prx.input & channel_num) ? 0 : 1; + } + + return err; +} + +static int do_mtc_appreg(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err; + char buf[5]; + + /* read appreg */ + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_WD_PARA; + pcmd.cmd_val0 = 5; /* max. Count */ + pcmd.cmd_val1 = 5; /* max. Time */ + pcmd.cmd_val2 = 0; /* =0 means read appreg */ + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + if (!err) { + sprintf(buf, "%d", prx.ack2); + setenv("appreg", buf); + } + + return err; +} + +static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + tx_msp_cmd pcmd; + rx_msp_cmd prx; + int err = 0; + + memset(&pcmd, 0, sizeof(pcmd)); + memset(&prx, 0, sizeof(prx)); + + pcmd.cmd = CMD_FW_VERSION; + + mtc_calculate_checksum(&pcmd); + err = spi_xfer(NULL, MTC_TRANSFER_SIZE, &pcmd, &prx, + SPI_XFER_BEGIN | SPI_XFER_END); + + if (!err) { + printf("FW V%d.%d.%d / HW %d\n", + prx.ack0, prx.ack1, prx.ack3, prx.ack2); + } + + return err; +} + +static int do_mtc_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +cmd_tbl_t cmd_mtc_sub[] = { + U_BOOT_CMD_MKENT(led, 3, 1, do_mtc_led, + "set state of leds", + "[ledname] [state] [blink]\n" + " - lednames: diag can1 can2 can3 can4 usbpwr usbbusy user1 user2\n" + " - state: off red green orange\n" + " - blink: blink interval in 100ms steps (1 - 10; 0 = static)\n"), + U_BOOT_CMD_MKENT(key, 0, 1, do_mtc_key, + "returns state of user key\n", ""), + U_BOOT_CMD_MKENT(version, 0, 1, do_mtc_version, + "returns firmware version of supervisor uC\n", ""), + U_BOOT_CMD_MKENT(appreg, 0, 1, do_mtc_appreg, + "reads appreg value and stores in environment variable 'appreg'\n", ""), + U_BOOT_CMD_MKENT(digin, 1, 1, do_mtc_digin, + "returns state of digital input", + "<channel_num> - get state of digital input (1 or 2)\n"), + U_BOOT_CMD_MKENT(digout, 2, 1, do_mtc_digout, + "sets digital outputs", + "<on|off> <on|off>- set state of digital output 1 and 2\n"), + U_BOOT_CMD_MKENT(help, 4, 1, do_mtc_help, "get help", + "[command] - get help for command\n"), +}; + +static int do_mtc_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + extern int _do_help(cmd_tbl_t *cmd_start, int cmd_items, + cmd_tbl_t *cmdtp, int flag, + int argc, char *argv[]); +#ifdef CONFIG_SYS_LONGHELP + puts("mtc "); +#endif + return _do_help(&cmd_mtc_sub[0], + ARRAY_SIZE(cmd_mtc_sub), cmdtp, flag, argc, argv); +} + +/* Relocate the command table function pointers when running in RAM */ +int mtc_cmd_init_r(void) +{ + cmd_tbl_t *cmdtp; + + for (cmdtp = &cmd_mtc_sub[0]; cmdtp != + &cmd_mtc_sub[ARRAY_SIZE(cmd_mtc_sub)]; cmdtp++) { + ulong addr; + + addr = (ulong)(cmdtp->cmd) + gd->reloc_off; + cmdtp->cmd = + (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; + + addr = (ulong)(cmdtp->name) + gd->reloc_off; + cmdtp->name = (char *)addr; + + if (cmdtp->usage) { + addr = (ulong)(cmdtp->usage) + gd->reloc_off; + cmdtp->usage = (char *)addr; + } +#ifdef CONFIG_SYS_LONGHELP + if (cmdtp->help) { + addr = (ulong)(cmdtp->help) + gd->reloc_off; + cmdtp->help = (char *)addr; + } +#endif + } + return 0; +} + +int cmd_mtc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + cmd_tbl_t *c; + int err = 0; + + c = find_cmd_tbl(argv[1], &cmd_mtc_sub[0], ARRAY_SIZE(cmd_mtc_sub)); + if (c) { + argc--; + argv++; + return c->cmd(c, flag, argc, argv); + } else { + /* Unrecognized command */ + cmd_usage(cmdtp); + return 1; + } + + return err; +} + +U_BOOT_CMD(mtc, 5, 1, cmd_mtc, + "mtc - special commands for digsyMTC\n", + "[subcommand] [args...]\n" + "Subcommands list:\n" + "led [ledname] [state] [blink] - set state of leds\n" + " [ledname]: diag can1 can2 can3 can4 usbpwr usbbusy user1 user2\n" + " [state]: off red green orange\n" + " [blink]: blink interval in 100ms steps (1 - 10; 0 = static)\n" + "key - returns state of user key\n" + "version - returns firmware version of supervisor uC\n" + "appreg - reads appreg value and stores in environment variable" + " 'appreg'\n" + "digin [channel] - returns state of digital input (1 or 2)\n" + "digout <on|off> <on|off> - sets state of two digital outputs\n" + "help [subcommand] - get help for subcommand\n"); + diff --git a/board/digsy_mtc/cmd_mtc.h b/board/digsy_mtc/cmd_mtc.h new file mode 100644 index 0000000..db3aeed --- /dev/null +++ b/board/digsy_mtc/cmd_mtc.h @@ -0,0 +1,60 @@ +/* + * (C) Copyright 2009 + * Werner Pfister <Pfister_Werner@intercontrol.de> + * + * (C) Copyright 2009 Semihalf, Grzegorz Bernacki + * + * 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 + */ + +#ifndef CMD_MTC_H +#define CMD_MTC_H + +#define CMD_WD_PARA 0x02 +#define CMD_FW_VERSION 0x10 +#define CMD_GET_VIM 0x30 +#define CMD_SET_LED 0x40 + +typedef struct { + u8 cmd; + u8 sys_in; + u8 cmd_val0; + u8 cmd_val1; + u8 cmd_val2; + u8 user_out; + u8 cks; + u8 dummy1; + u8 dummy2; +} tx_msp_cmd; + +typedef struct { + u8 input; + u8 state; + u8 ack2; + u8 ack3; + u8 ack0; + u8 ack1; + u8 ack; + u8 dummy; + u8 cks; +} rx_msp_cmd; + +#define MTC_TRANSFER_SIZE (sizeof(tx_msp_cmd) * 8) + +#endif diff --git a/board/digsy_mtc/digsy_mtc.c b/board/digsy_mtc/digsy_mtc.c index 83d5864..9d77e54 100644 --- a/board/digsy_mtc/digsy_mtc.c +++ b/board/digsy_mtc/digsy_mtc.c @@ -186,6 +186,9 @@ int checkboard(void) int board_early_init_r(void) { +#ifdef CONFIG_MPC52XX_SPI + struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt*)MPC5XXX_GPT; +#endif /* * Now, when we are in RAM, enable flash write access for detection * process. Note that CS_BOOT cannot be cleared when executing in @@ -202,6 +205,13 @@ int board_early_init_r(void) /* Low level USB init, required for proper kernel operation */ usb_cpu_init(); #endif +#ifdef CONFIG_MPC52XX_SPI + /* GPT 6 Output Enable */ + out_be32(&gpt[6].emsr, 0x00000034); + /* GPT 7 Output Enable */ + out_be32(&gpt[7].emsr, 0x00000034); +#endif + return (0); } @@ -230,6 +240,7 @@ void board_get_enetaddr (uchar * enet) int misc_init_r(void) { + extern int mtc_cmd_init_r (void); uchar enetaddr[6]; if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { @@ -237,6 +248,7 @@ int misc_init_r(void) eth_setenv_enetaddr("ethaddr", enetaddr); } + mtc_cmd_init_r(); return 0; } diff --git a/board/freescale/common/sys_eeprom.c b/board/freescale/common/sys_eeprom.c index ae5304a..3e1e332 100644 --- a/board/freescale/common/sys_eeprom.c +++ b/board/freescale/common/sys_eeprom.c @@ -78,12 +78,14 @@ static int has_been_read = 0; #ifdef CONFIG_SYS_I2C_EEPROM_NXID /* Is this a valid NXID EEPROM? */ -#define is_valid (*((u32 *)e.id) == (('N' << 24) | ('X' << 16) | ('I' << 8) | 'D')) +#define is_valid ((e.id[0] == 'N') || (e.id[1] == 'X') || \ + (e.id[2] == 'I') || (e.id[3] == 'D')) #endif #ifdef CONFIG_SYS_I2C_EEPROM_CCID /* Is this a valid CCID EEPROM? */ -#define is_valid (*((u32 *)e.id) == (('C' << 24) | ('C' << 16) | ('I' << 8) | 'D')) +#define is_valid ((e.id[0] == 'C') || (e.id[1] == 'C') || \ + (e.id[2] == 'I') || (e.id[3] == 'D')) #endif /** diff --git a/board/freescale/mpc8360emds/mpc8360emds.c b/board/freescale/mpc8360emds/mpc8360emds.c index 85c0120..dc4dbd3 100644 --- a/board/freescale/mpc8360emds/mpc8360emds.c +++ b/board/freescale/mpc8360emds/mpc8360emds.c @@ -116,7 +116,7 @@ int board_early_init_r(void) return 0; } -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) extern void ddr_enable_ecc(unsigned int dram_size); #endif int fixed_sdram(void); @@ -138,7 +138,7 @@ phys_size_t initdram(int board_type) msize = fixed_sdram(); #endif -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) /* * Initialize DDR ECC byte */ diff --git a/board/freescale/mpc8360erdk/mpc8360erdk.c b/board/freescale/mpc8360erdk/mpc8360erdk.c index af3b8ce..3771878 100644 --- a/board/freescale/mpc8360erdk/mpc8360erdk.c +++ b/board/freescale/mpc8360erdk/mpc8360erdk.c @@ -268,7 +268,7 @@ int fixed_sdram(void) phys_size_t initdram(int board_type) { -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) extern void ddr_enable_ecc(unsigned int dram_size); #endif volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; @@ -281,7 +281,7 @@ phys_size_t initdram(int board_type) im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR; msize = fixed_sdram(); -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) /* * Initialize DDR ECC byte */ diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c index 062d762..8506892 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -199,7 +199,7 @@ int board_early_init_r(void) return 0; } -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) extern void ddr_enable_ecc(unsigned int dram_size); #endif int fixed_sdram(void); @@ -218,7 +218,7 @@ phys_size_t initdram(int board_type) msize = fixed_sdram(); #endif -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) /* Initialize DDR ECC byte */ ddr_enable_ecc(msize * 1024 * 1024); #endif diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c index 318a3dc..a4a1927 100644 --- a/board/freescale/mpc837xerdb/mpc837xerdb.c +++ b/board/freescale/mpc837xerdb/mpc837xerdb.c @@ -59,7 +59,7 @@ testdram(void) } #endif -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) void ddr_enable_ecc(unsigned int dram_size); #endif int fixed_sdram(void); @@ -78,7 +78,7 @@ phys_size_t initdram(int board_type) msize = fixed_sdram(); #endif -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) /* Initialize DDR ECC byte */ ddr_enable_ecc(msize * 1024 * 1024); #endif diff --git a/board/freescale/p2020ds/p2020ds.c b/board/freescale/p2020ds/p2020ds.c index 6b72d61..293e5a4 100644 --- a/board/freescale/p2020ds/p2020ds.c +++ b/board/freescale/p2020ds/p2020ds.c @@ -36,6 +36,7 @@ #include <tsec.h> #include <asm/fsl_law.h> #include <asm/mp.h> +#include <netdev.h> #include "../common/pixis.h" #include "../common/sgmii_riser.h" @@ -594,7 +595,7 @@ int board_eth_init(bd_t *bis) tsec_eth_init(bis, tsec_info, num); - return 0; + return pci_eth_init(bis); } #endif diff --git a/board/keymile/kmeter1/kmeter1.c b/board/keymile/kmeter1/kmeter1.c index 660d87b..3d1b941 100644 --- a/board/keymile/kmeter1/kmeter1.c +++ b/board/keymile/kmeter1/kmeter1.c @@ -153,7 +153,7 @@ int fixed_sdram(void) phys_size_t initdram (int board_type) { -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) extern void ddr_enable_ecc (unsigned int dram_size); #endif volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; @@ -166,7 +166,7 @@ phys_size_t initdram (int board_type) im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR; msize = fixed_sdram (); -#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC) +#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) /* * Initialize DDR ECC byte */ diff --git a/board/mpc8540eval/mpc8540eval.c b/board/mpc8540eval/mpc8540eval.c index 72a1ad3..7c27233 100644 --- a/board/mpc8540eval/mpc8540eval.c +++ b/board/mpc8540eval/mpc8540eval.c @@ -137,40 +137,9 @@ phys_size_t initdram (int board_type) { /* Initialize all of memory for ECC, then * enable errors */ - uint *p = 0; - uint i = 0; volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR); - dma_init(); - for (*p = 0; p < (uint *)(8 * 1024); p++) { - if (((unsigned int)p & 0x1f) == 0) { dcbz(p); } - *p = (unsigned int)0xdeadbeef; - if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); } - } - - /* 8K */ - dma_xfer((uint *)0x2000,0x2000,(uint *)0); - /* 16K */ - dma_xfer((uint *)0x4000,0x4000,(uint *)0); - /* 32K */ - dma_xfer((uint *)0x8000,0x8000,(uint *)0); - /* 64K */ - dma_xfer((uint *)0x10000,0x10000,(uint *)0); - /* 128k */ - dma_xfer((uint *)0x20000,0x20000,(uint *)0); - /* 256k */ - dma_xfer((uint *)0x40000,0x40000,(uint *)0); - /* 512k */ - dma_xfer((uint *)0x80000,0x80000,(uint *)0); - /* 1M */ - dma_xfer((uint *)0x100000,0x100000,(uint *)0); - /* 2M */ - dma_xfer((uint *)0x200000,0x200000,(uint *)0); - /* 4M */ - dma_xfer((uint *)0x400000,0x400000,(uint *)0); - for (i = 1; i < dram_size / 0x800000; i++) { - dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0); - } + dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size); /* Enable errors for ECC */ ddr->err_disable = 0x00000000; diff --git a/board/sbc8560/sbc8560.c b/board/sbc8560/sbc8560.c index 7f032c8..c40b5e3 100644 --- a/board/sbc8560/sbc8560.c +++ b/board/sbc8560/sbc8560.c @@ -338,40 +338,9 @@ phys_size_t initdram (int board_type) { /* Initialize all of memory for ECC, then * enable errors */ - uint *p = 0; - uint i = 0; volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR); - dma_init(); - for (*p = 0; p < (uint *)(8 * 1024); p++) { - if (((unsigned int)p & 0x1f) == 0) { dcbz(p); } - *p = (unsigned int)0xdeadbeef; - if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); } - } - /* 8K */ - dma_xfer((uint *)0x2000,0x2000,(uint *)0); - /* 16K */ - dma_xfer((uint *)0x4000,0x4000,(uint *)0); - /* 32K */ - dma_xfer((uint *)0x8000,0x8000,(uint *)0); - /* 64K */ - dma_xfer((uint *)0x10000,0x10000,(uint *)0); - /* 128k */ - dma_xfer((uint *)0x20000,0x20000,(uint *)0); - /* 256k */ - dma_xfer((uint *)0x40000,0x40000,(uint *)0); - /* 512k */ - dma_xfer((uint *)0x80000,0x80000,(uint *)0); - /* 1M */ - dma_xfer((uint *)0x100000,0x100000,(uint *)0); - /* 2M */ - dma_xfer((uint *)0x200000,0x200000,(uint *)0); - /* 4M */ - dma_xfer((uint *)0x400000,0x400000,(uint *)0); - - for (i = 1; i < dram_size / 0x800000; i++) { - dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0); - } + dma_meminit(CONFIG_MEM_INIT_VALUE, dram_size); /* Enable errors for ECC */ ddr->err_disable = 0x00000000; diff --git a/board/xes/xpedite5170/Makefile b/board/xes/xpedite5170/Makefile new file mode 100644 index 0000000..fea6686 --- /dev/null +++ b/board/xes/xpedite5170/Makefile @@ -0,0 +1,52 @@ +# +# (C) Copyright 2001 +# 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 +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)lib$(BOARD).a + +COBJS-y += $(BOARD).o +COBJS-y += ddr.o +COBJS-y += law.o + +SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS-y)) +SOBJS := $(addprefix $(obj),$(SOBJS-y)) + +$(LIB): $(obj).depend $(OBJS) $(SOBJS) + $(AR) $(ARFLAGS) $@ $(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/xes/xpedite5170/config.mk b/board/xes/xpedite5170/config.mk new file mode 100644 index 0000000..c3df6d5 --- /dev/null +++ b/board/xes/xpedite5170/config.mk @@ -0,0 +1,32 @@ +# +# Copyright 2009 Extreme Engineering Solutions, Inc. +# Copyright 2007-2008 Freescale Semiconductor, Inc. +# +# 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 +# + +# +# XPedite5170 +# +TEXT_BASE = 0xfff00000 + +PLATFORM_RELFLAGS += -mrelocatable + +PLATFORM_CPPFLAGS += -DCONFIG_MPC86xx=1 +PLATFORM_CPPFLAGS += -DCONFIG_MPC8641=1 -maltivec -mabi=altivec -msoft-float diff --git a/board/xes/xpedite5170/ddr.c b/board/xes/xpedite5170/ddr.c new file mode 100644 index 0000000..1d57d09 --- /dev/null +++ b/board/xes/xpedite5170/ddr.c @@ -0,0 +1,168 @@ +/* + * Copyright 2009 Extreme Engineering Solutions, Inc. + * Copyright 2007-2008 Freescale Semiconductor, Inc. + * + * 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 <common.h> +#include <i2c.h> +#include <asm/fsl_ddr_sdram.h> +#include <asm/fsl_ddr_dimm_params.h> + +static void get_spd(ddr2_spd_eeprom_t *spd, unsigned char i2c_address) +{ + i2c_read(i2c_address, SPD_EEPROM_OFFSET, 2, (uchar *)spd, + sizeof(ddr2_spd_eeprom_t)); +} + +unsigned int fsl_ddr_get_mem_data_rate(void) +{ + return get_bus_freq(0); +} + +void fsl_ddr_get_spd(ddr2_spd_eeprom_t *ctrl_dimms_spd, + unsigned int ctrl_num) +{ + unsigned int i; + unsigned int i2c_address = 0; + + for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) { + if (ctrl_num == 0) { + i2c_address = SPD_EEPROM_ADDRESS1; +#ifdef SPD_EEPROM_ADDRESS2 + } else if (ctrl_num == 1) { + i2c_address = SPD_EEPROM_ADDRESS2; +#endif + } else { + /* An inalid ctrl number was give, use default SPD */ + printf("ERROR: invalid DDR ctrl: %d\n", ctrl_num); + i2c_address = SPD_EEPROM_ADDRESS1; + } + + get_spd(&(ctrl_dimms_spd[i]), i2c_address); + } +} + +/* + * There are four board-specific SDRAM timing parameters which must be + * calculated based on the particular PCB artwork. These are: + * 1.) CPO (Read Capture Delay) + * - TIMING_CFG_2 register + * Source: Calculation based on board trace lengths and + * chip-specific internal delays. + * 2.) WR_DATA_DELAY (Write Command to Data Strobe Delay) + * - TIMING_CFG_2 register + * Source: Calculation based on board trace lengths. + * Unless clock and DQ lanes are very different + * lengths (>2"), this should be set to the nominal value + * of 1/2 clock delay. + * 3.) CLK_ADJUST (Clock and Addr/Cmd alignment control) + * - DDR_SDRAM_CLK_CNTL register + * Source: Signal Integrity Simulations + * 4.) 2T Timing on Addr/Ctl + * - TIMING_CFG_2 register + * Source: Signal Integrity Simulations + * Usually only needed with heavy load/very high speed (>DDR2-800) + * + * PCB routing on the XPedite5170 is nearly identical to the XPedite5370 + * so we use the XPedite5370 settings as a basis for the XPedite5170. + */ + +typedef struct board_memctl_options { + uint16_t datarate_mhz_low; + uint16_t datarate_mhz_high; + uint8_t clk_adjust; + uint8_t cpo_override; + uint8_t write_data_delay; +} board_memctl_options_t; + +static struct board_memctl_options bopts_ctrl[][2] = { + { + /* Controller 0 */ + { + /* DDR2 600/667 */ + .datarate_mhz_low = 500, + .datarate_mhz_high = 750, + .clk_adjust = 5, + .cpo_override = 8, + .write_data_delay = 2, + }, + { + /* DDR2 800 */ + .datarate_mhz_low = 750, + .datarate_mhz_high = 850, + .clk_adjust = 5, + .cpo_override = 9, + .write_data_delay = 2, + }, + }, + { + /* Controller 1 */ + { + /* DDR2 600/667 */ + .datarate_mhz_low = 500, + .datarate_mhz_high = 750, + .clk_adjust = 5, + .cpo_override = 7, + .write_data_delay = 2, + }, + { + /* DDR2 800 */ + .datarate_mhz_low = 750, + .datarate_mhz_high = 850, + .clk_adjust = 5, + .cpo_override = 8, + .write_data_delay = 2, + }, + }, +}; + +void fsl_ddr_board_options(memctl_options_t *popts, + dimm_params_t *pdimm, + unsigned int ctrl_num) +{ + struct board_memctl_options *bopts = bopts_ctrl[ctrl_num]; + sys_info_t sysinfo; + int i; + unsigned int datarate; + + get_sys_info(&sysinfo); + datarate = fsl_ddr_get_mem_data_rate() / 1000000; + + for (i = 0; i < ARRAY_SIZE(bopts_ctrl[ctrl_num]); i++) { + if ((bopts[i].datarate_mhz_low <= datarate) && + (bopts[i].datarate_mhz_high >= datarate)) { + debug("controller %d:\n", ctrl_num); + debug(" clk_adjust = %d\n", bopts[i].clk_adjust); + debug(" cpo = %d\n", bopts[i].cpo_override); + debug(" write_data_delay = %d\n", + bopts[i].write_data_delay); + popts->clk_adjust = bopts[i].clk_adjust; + popts->cpo_override = bopts[i].cpo_override; + popts->write_data_delay = bopts[i].write_data_delay; + } + } + + /* + * Factors to consider for half-strength driver enable: + * - number of DIMMs installed + */ + popts->half_strength_driver_enable = 0; +} diff --git a/board/xes/xpedite5170/law.c b/board/xes/xpedite5170/law.c new file mode 100644 index 0000000..0b7d9ef --- /dev/null +++ b/board/xes/xpedite5170/law.c @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Freescale Semiconductor, Inc. + * + * (C) Copyright 2000 + * 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 + */ + +#include <common.h> +#include <asm/fsl_law.h> +#include <asm/mmu.h> + +/* + * Notes: + * CCSRBAR don't need a configured Local Access Window. + * If flash is 8M at default position (last 8M), no LAW needed. + */ + +struct law_entry law_table[] = { + SET_LAW(CONFIG_SYS_FLASH_BASE2, LAW_SIZE_256M, LAW_TRGT_IF_LBC), +#ifdef CONFIG_SYS_NAND_BASE + /* NAND LAW covers 2 NAND flashes */ + SET_LAW(CONFIG_SYS_NAND_BASE, LAW_SIZE_512K, LAW_TRGT_IF_LBC), +#endif +#ifdef CONFIG_SYS_PCIE1_MEM_PHYS + SET_LAW(CONFIG_SYS_PCIE1_MEM_PHYS, LAW_SIZE_1G, LAW_TRGT_IF_PCIE_1), + SET_LAW(CONFIG_SYS_PCIE1_IO_PHYS, LAW_SIZE_8M, LAW_TRGT_IF_PCIE_1), +#endif +#ifdef CONFIG_SYS_PCIE2_MEM_PHYS + SET_LAW(CONFIG_SYS_PCIE2_MEM_PHYS, LAW_SIZE_256M, LAW_TRGT_IF_PCIE_2), + SET_LAW(CONFIG_SYS_PCIE2_IO_PHYS, LAW_SIZE_8M, LAW_TRGT_IF_PCIE_2), +#endif +}; + +int num_law_entries = ARRAY_SIZE(law_table); diff --git a/board/xes/xpedite5170/u-boot.lds b/board/xes/xpedite5170/u-boot.lds new file mode 100644 index 0000000..b71a7d6 --- /dev/null +++ b/board/xes/xpedite5170/u-boot.lds @@ -0,0 +1,132 @@ +/* + * Copyright 2006, 2007 Freescale Semiconductor, Inc. + * + * 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: */ + .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 : + { + cpu/mpc86xx/start.o (.text) + cpu/mpc86xx/traps.o (.text) + cpu/mpc86xx/interrupts.o (.text) + cpu/mpc86xx/cpu_init.o (.text) + cpu/mpc86xx/cpu.o (.text) + cpu/mpc86xx/speed.o (.text) + common/dlmalloc.o (.text) + lib_generic/crc32.o (.text) + lib_ppc/extable.o (.text) + lib_generic/zlib.o (.text) + *(.text) + *(.got1) + } + _etext = .; + PROVIDE (etext = .); + .rodata : + { + *(.eh_frame) + *(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/board/xes/xpedite5170/xpedite5170.c b/board/xes/xpedite5170/xpedite5170.c new file mode 100644 index 0000000..f4231a9 --- /dev/null +++ b/board/xes/xpedite5170/xpedite5170.c @@ -0,0 +1,111 @@ +/* + * Copyright 2009 Extreme Engineering Solutions, Inc. + * + * 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 <common.h> +#include <asm/processor.h> +#include <asm/mmu.h> +#include <asm/io.h> +#include <fdt_support.h> +#include <pca953x.h> + +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_PCI) +extern void ft_board_pci_setup(void *blob, bd_t *bd); +#endif + +int checkboard(void) +{ + char *s; + + printf("Board: X-ES %s 3U VPX SBC\n", CONFIG_SYS_BOARD_NAME); + printf(" "); + s = getenv("board_rev"); + if (s) + printf("Rev %s, ", s); + s = getenv("serial#"); + if (s) + printf("Serial# %s, ", s); + s = getenv("board_cfg"); + if (s) + printf("Cfg %s", s); + printf("\n"); + + return 0; +} +/* + * Print out which flash was booted from and if booting from the 2nd flash, + * swap flash chip selects to maintain consistent flash numbering/addresses. + */ +static void flash_cs_fixup(void) +{ + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + ccsr_lbc_t *lbc = &immap->im_lbc; + int flash_sel; + + /* + * Print boot dev and swap flash flash chip selects if booted from 2nd + * flash. Swapping chip selects presents user with a common memory + * map regardless of which flash was booted from. + */ + flash_sel = !((pca953x_get_val(CONFIG_SYS_I2C_PCA953X_ADDR0) & + CONFIG_SYS_PCA953X_C0_FLASH_PASS_CS)); + printf("FLASH: Executed from FLASH%d\n", flash_sel ? 2 : 1); + + if (flash_sel) { + out_be32(&lbc->br0, CONFIG_SYS_BR1_PRELIM); + out_be32(&lbc->or0, CONFIG_SYS_OR1_PRELIM); + + out_be32(&lbc->br1, CONFIG_SYS_BR0_PRELIM); + out_be32(&lbc->or1, CONFIG_SYS_OR0_PRELIM); + } +} + +int board_early_init_r(void) +{ + /* Initialize PCA9557 devices */ + pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0); + pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0); + pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0); + pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0); + + flash_cs_fixup(); + + return 0; +} + +#if defined(CONFIG_OF_BOARD_SETUP) +void ft_board_setup(void *blob, bd_t *bd) +{ +#ifdef CONFIG_PCI + ft_board_pci_setup(blob, bd); +#endif + ft_cpu_setup(blob, bd); +} +#endif + +#ifdef CONFIG_MP +extern void cpu_mp_lmb_reserve(struct lmb *lmb); + +void board_lmb_reserve(struct lmb *lmb) +{ + cpu_mp_lmb_reserve(lmb); +} +#endif |