summaryrefslogtreecommitdiff
path: root/board/netstal/common/nm_bsp.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-01-23 14:19:45 +0100
committerWolfgang Denk <wd@denx.de>2008-01-23 14:19:45 +0100
commit8f00731818f0f0deaca899bde56de98d3d95c0b6 (patch)
treec20b13ba953ec3a0af0564ee7f79d151e6ff934a /board/netstal/common/nm_bsp.c
parented3afca32e1b28e441bc9f4b804edac47686554e (diff)
parent9cfff9e9d4d9dbb9bb428cea3fa2cda3b3e593ad (diff)
downloadu-boot-imx-8f00731818f0f0deaca899bde56de98d3d95c0b6.zip
u-boot-imx-8f00731818f0f0deaca899bde56de98d3d95c0b6.tar.gz
u-boot-imx-8f00731818f0f0deaca899bde56de98d3d95c0b6.tar.bz2
Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
Diffstat (limited to 'board/netstal/common/nm_bsp.c')
-rw-r--r--board/netstal/common/nm_bsp.c128
1 files changed, 112 insertions, 16 deletions
diff --git a/board/netstal/common/nm_bsp.c b/board/netstal/common/nm_bsp.c
index a9de45e..b50b4af 100644
--- a/board/netstal/common/nm_bsp.c
+++ b/board/netstal/common/nm_bsp.c
@@ -1,5 +1,5 @@
/*
- *(C) Copyright 2005-2007 Netstal Maschinen AG
+ *(C) Copyright 2005-2008 Netstal Maschinen AG
* Niklaus Giger (Niklaus.Giger@netstal.com)
*
* This source code is free software; you can redistribute it
@@ -20,22 +20,118 @@
#include <common.h>
#include <command.h>
+#include <net.h>
+#include "nm.h"
-#ifdef CONFIG_CMD_BSP
-/*
- * Command nm_bsp: Netstal Maschinen BSP specific command
- */
-int nm_bsp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+DECLARE_GLOBAL_DATA_PTR;
+
+#define DEFAULT_ETH_ADDR "ethaddr"
+
+typedef struct {u8 id; char *name;} generation_info;
+
+generation_info generations[7] = {
+ {HW_GENERATION_HCU2, "HCU2"},
+ {HW_GENERATION_HCU3, "HCU3"},
+ {HW_GENERATION_HCU4, "HCU4"},
+ {HW_GENERATION_HCU5, "HCU5"},
+ {HW_GENERATION_MCU, "MCU"},
+ {HW_GENERATION_MCU20, "MCU20"},
+ {HW_GENERATION_MCU25, "MCU25"},
+};
+
+void nm_show_print(int generation, int index, int hw_capabilities)
+{
+ int j;
+ char *generationName=0;
+
+ /* reset ANSI terminal color mode */
+ printf("\x1B""[0m""Netstal Maschinen AG: ");
+ for (j=0; j < (sizeof(generations)/sizeof(generations[0])); j++) {
+ if (generations[j].id == generation) {
+ generationName = generations[j].name;
+ break;
+ }
+ }
+ printf("%s: index %d HW 0x%x\n", generationName, index, hw_capabilities);
+ for (j = 0;j < 6; j++) {
+ hcu_led_set(1 << j);
+ udelay(200 * 1000);
+ }
+}
+
+void set_params_for_sw_install(int install_requested, char *board_name )
{
- printf("%s: flag %d, argc %d, argv[0] %s\n", __FUNCTION__,
- flag, argc, argv[0]);
- printf("Netstal Maschinen BSP specific command. None at the moment.\n");
- return 0;
+ if (install_requested) {
+ char string[128];
+
+ printf("\n\n%s SW-Installation: %d patching boot parameters\n",
+ board_name, install_requested);
+ setenv("bootdelay", "0");
+ setenv("loadaddr", "0x01000000");
+ setenv("serverip", "172.25.1.1");
+ setenv("bootcmd", "run install");
+ sprintf(string, "tftp ${loadaddr} admin/sw_on_hd; "
+ "tftp ${loadaddr} installer/%s_sw_inst; "
+ "run boot_sw_inst", board_name);
+ setenv("install", string);
+ sprintf(string, "setenv bootargs emac(0,0)c:%s/%s_sw_inst "
+ "e=${ipaddr} h=${serverip} f=0x1000; "
+ "bootvx ${loadaddr}\0",
+ board_name, board_name);
+ setenv("boot_sw_inst", string);
+ }
+}
+
+void common_misc_init_r(void)
+{
+ char *s = getenv(DEFAULT_ETH_ADDR);
+ char *e;
+ int i;
+ u32 serial = get_serial_number();
+ IPaddr_t ipaddr;
+ char *ipstring;
+
+ for (i = 0; i < 6; ++i) {
+ gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
+ if (s)
+ s = (*e) ? e + 1 : e;
+ }
+
+ if (gd->bd->bi_enetaddr[3] == 0 &&
+ gd->bd->bi_enetaddr[4] == 0 &&
+ gd->bd->bi_enetaddr[5] == 0) {
+ char ethaddr[22];
+
+ /* Must be in sync with CONFIG_ETHADDR */
+ gd->bd->bi_enetaddr[0] = 0x00;
+ gd->bd->bi_enetaddr[1] = 0x60;
+ gd->bd->bi_enetaddr[2] = 0x13;
+ gd->bd->bi_enetaddr[3] = (serial >> 16) & 0xff;
+ gd->bd->bi_enetaddr[4] = (serial >> 8) & 0xff;
+ gd->bd->bi_enetaddr[5] = hcu_get_slot();
+ sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X\0",
+ gd->bd->bi_enetaddr[0], gd->bd->bi_enetaddr[1],
+ gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3],
+ gd->bd->bi_enetaddr[4], gd->bd->bi_enetaddr[5]) ;
+ printf("%s: Setting eth %s serial 0x%x\n", __FUNCTION__,
+ ethaddr, serial);
+ setenv(DEFAULT_ETH_ADDR, ethaddr);
+ }
+
+ /* IP-Adress update */
+ ipstring = getenv("ipaddr");
+ if (ipstring == 0)
+ ipaddr = string_to_ip("172.25.1.99");
+ else
+ ipaddr = string_to_ip(ipstring);
+ if ((ipaddr & 0xff) != (32 + hcu_get_slot())) {
+ char tmp[22];
+
+ ipaddr = (ipaddr & 0xffffff00) + 32 + hcu_get_slot();
+ ip_to_string (ipaddr, tmp);
+ printf("%s: enforce %s\n", __FUNCTION__, tmp);
+ setenv("ipaddr", tmp);
+ saveenv();
+ }
}
-U_BOOT_CMD(
- nm_bsp, 1, 1, nm_bsp,
- "nm_bsp - Netstal Maschinen BSP specific command. \n",
- "Help for Netstal Maschinen BSP specific command.\n"
- );
-#endif