Niklaus Giger | e8397fc7 | 2007-07-27 11:38:26 +0200 | [diff] [blame] | 1 | /* |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 2 | *(C) Copyright 2005-2008 Netstal Maschinen AG |
Niklaus Giger | e8397fc7 | 2007-07-27 11:38:26 +0200 | [diff] [blame] | 3 | * Niklaus Giger (Niklaus.Giger@netstal.com) |
| 4 | * |
| 5 | * This source code is free software; you can redistribute it |
| 6 | * and/or modify it in source code form under the terms of the GNU |
| 7 | * General Public License as published by the Free Software |
| 8 | * Foundation; either version 2 of the License, or (at your option) |
| 9 | * any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 19 | */ |
| 20 | |
| 21 | #include <common.h> |
| 22 | #include <command.h> |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 23 | #include <net.h> |
| 24 | #include "nm.h" |
Niklaus Giger | e8397fc7 | 2007-07-27 11:38:26 +0200 | [diff] [blame] | 25 | |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
| 28 | #define DEFAULT_ETH_ADDR "ethaddr" |
| 29 | |
| 30 | typedef struct {u8 id; char *name;} generation_info; |
| 31 | |
Niklaus Giger | 7497312 | 2008-02-05 11:31:28 +0100 | [diff] [blame] | 32 | generation_info generations[6] = { |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 33 | {HW_GENERATION_HCU3, "HCU3"}, |
| 34 | {HW_GENERATION_HCU4, "HCU4"}, |
| 35 | {HW_GENERATION_HCU5, "HCU5"}, |
| 36 | {HW_GENERATION_MCU, "MCU"}, |
| 37 | {HW_GENERATION_MCU20, "MCU20"}, |
| 38 | {HW_GENERATION_MCU25, "MCU25"}, |
| 39 | }; |
| 40 | |
| 41 | void nm_show_print(int generation, int index, int hw_capabilities) |
Niklaus Giger | e8397fc7 | 2007-07-27 11:38:26 +0200 | [diff] [blame] | 42 | { |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 43 | int j; |
| 44 | char *generationName=0; |
| 45 | |
| 46 | /* reset ANSI terminal color mode */ |
| 47 | printf("\x1B""[0m""Netstal Maschinen AG: "); |
| 48 | for (j=0; j < (sizeof(generations)/sizeof(generations[0])); j++) { |
| 49 | if (generations[j].id == generation) { |
| 50 | generationName = generations[j].name; |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | printf("%s: index %d HW 0x%x\n", generationName, index, hw_capabilities); |
| 55 | for (j = 0;j < 6; j++) { |
| 56 | hcu_led_set(1 << j); |
| 57 | udelay(200 * 1000); |
| 58 | } |
Niklaus Giger | e8397fc7 | 2007-07-27 11:38:26 +0200 | [diff] [blame] | 59 | } |
| 60 | |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 61 | void set_params_for_sw_install(int install_requested, char *board_name ) |
| 62 | { |
| 63 | if (install_requested) { |
| 64 | char string[128]; |
| 65 | |
| 66 | printf("\n\n%s SW-Installation: %d patching boot parameters\n", |
| 67 | board_name, install_requested); |
| 68 | setenv("bootdelay", "0"); |
| 69 | setenv("loadaddr", "0x01000000"); |
| 70 | setenv("serverip", "172.25.1.1"); |
| 71 | setenv("bootcmd", "run install"); |
| 72 | sprintf(string, "tftp ${loadaddr} admin/sw_on_hd; " |
| 73 | "tftp ${loadaddr} installer/%s_sw_inst; " |
| 74 | "run boot_sw_inst", board_name); |
| 75 | setenv("install", string); |
| 76 | sprintf(string, "setenv bootargs emac(0,0)c:%s/%s_sw_inst " |
| 77 | "e=${ipaddr} h=${serverip} f=0x1000; " |
Wolfgang Denk | 9b55a25 | 2008-07-11 01:16:00 +0200 | [diff] [blame] | 78 | "bootvx ${loadaddr}%c", |
| 79 | board_name, board_name, 0); |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 80 | setenv("boot_sw_inst", string); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | void common_misc_init_r(void) |
| 85 | { |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 86 | IPaddr_t ipaddr; |
| 87 | char *ipstring; |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 88 | uchar ethaddr[6]; |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 89 | |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 90 | if (!eth_getenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr)) { |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 91 | /* Must be in sync with CONFIG_ETHADDR */ |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 92 | u32 serial = get_serial_number(); |
| 93 | ethaddr[0] = 0x00; |
| 94 | ethaddr[1] = 0x60; |
| 95 | ethaddr[2] = 0x13; |
| 96 | ethaddr[3] = (serial >> 16) & 0xff; |
| 97 | ethaddr[4] = (serial >> 8) & 0xff; |
| 98 | ethaddr[5] = hcu_get_slot(); |
| 99 | eth_setenv_enetaddr(DEFAULT_ETH_ADDR, ethaddr); |
Niklaus Giger | 69b0634 | 2008-01-17 12:53:56 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* IP-Adress update */ |
| 103 | ipstring = getenv("ipaddr"); |
| 104 | if (ipstring == 0) |
| 105 | ipaddr = string_to_ip("172.25.1.99"); |
| 106 | else |
| 107 | ipaddr = string_to_ip(ipstring); |
| 108 | if ((ipaddr & 0xff) != (32 + hcu_get_slot())) { |
| 109 | char tmp[22]; |
| 110 | |
| 111 | ipaddr = (ipaddr & 0xffffff00) + 32 + hcu_get_slot(); |
| 112 | ip_to_string (ipaddr, tmp); |
| 113 | printf("%s: enforce %s\n", __FUNCTION__, tmp); |
| 114 | setenv("ipaddr", tmp); |
| 115 | saveenv(); |
| 116 | } |
| 117 | } |