ppc_4xx:netstal/common define routines used by all boards
PATCH 1/1 ppc_4xx:netstal/common define routines used by all boards
Added some routines used by all Netstal boards nm_show_print and common_misc_init_r and the very specific code to handle our SW installation procedure (set_params_for_sw_install).
--- board/netstal/common/nm_bsp.c | 131 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 116 insertions(+), 15 deletions(-)
board/netstal/common/nm_bsp.c +116 -15
@@ -20,22 +20,123 @@#include <common.h> #include <command.h> +#include <net.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" + +extern void hcu_led_set (u32 value); +extern u32 get_serial_number (void ); +extern u32 hcu_get_slot (void ); + +enum { +/* HW_GENERATION_HCU1 is no longer supported */ +HW_GENERATION_HCU2 =0x10 , +HW_GENERATION_HCU3 =0x10 , +HW_GENERATION_HCU4 =0x20 , +HW_GENERATION_HCU5 =0x30 , +HW_GENERATION_MCU =0x08 , +HW_GENERATION_MCU20 =0x0a , +HW_GENERATION_MCU25 =0x09 , +}; + + +void nm_show_print (int generation,int index,int hw_capabilities) +{ +int j; +/* reset ANSI terminal color mode */ +printf ("\x1B""[0m""Netstal Maschinen AG: " ); +if (generation ==HW_GENERATION_HCU3 ) +printf ("HCU3: index %d" , index); +else if (generation ==HW_GENERATION_HCU4 ) +printf ("HCU4: index %d" , index); +else if (generation ==HW_GENERATION_HCU5 ) +printf ("HCU5: index %d" , index); +else if (generation ==HW_GENERATION_MCU25 ) +printf ("MCU25: index %d" , index); +printf (" HW 0x%x\n" , 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@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 (); + +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 */ + { +IPaddr_t ipaddr; +char *ipstring; + + 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
Signature · 7 lines
1.5.2.5 -- Niklaus Giger Netstal Maschinen AG CH-8752 Naefels
PATCH 1/1 ppc_4xx:netstal/common define routines used by all boards
Quoted 38 lines · Niklaus Giger
Added some routines used by all Netstal boards
nm_show_printandcommon_misc_init_rand the very specific code to handle our SW installation procedure (set_params_for_sw_install).Signed-off-by Niklaus Giger <[email protected]>--- board/netstal/common/nm_bsp.c | 131++++++++++++++++++++++++++++++++++++----- 1 files changed, 116 insertions(+), 15 deletions(-)
board/netstal/common/nm_bsp.c +14
-5@@ -20,22 +20,123 @@#include <common.h> #include <command.h> +#include <net.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" + +extern void hcu_led_set (u32 value); +extern u32 get_serial_number (void ); +extern u32 hcu_get_slot (void ); + +enum { +/* HW_GENERATION_HCU1 is no longer supported */ +HW_GENERATION_HCU2 =0x10 , +HW_GENERATION_HCU3 =0x10 , +HW_GENERATION_HCU4 =0x20 ,
board/netstal/common/nm_bsp.c line 47
Quoted 10 lines
board/netstal/common/nm_bsp.c +10
-0+HW_GENERATION_HCU5 =0x30 , +HW_GENERATION_MCU =0x08 , +HW_GENERATION_MCU20 =0x0a , + HW_GENERATION_MCU25 = 0x09, +}; + + +void nm_show_print (int generation,int index,int hw_capabilities) +{ +int j;
Empty line after var declaration.
board/netstal/common/nm_bsp.c line 49
Quoted 2 lines
board/netstal/common/nm_bsp.c +2
-0+/* reset ANSI terminal color mode */ +printf ("\x1B""[0m""Netstal Maschinen AG: " );
Either use space after the function (here "print") all the time in this file or never (which is what I prefer).
Quoted 13 lines
board/netstal/common/nm_bsp.c +13
-0+if (generation ==HW_GENERATION_HCU3 ) +printf ("HCU3: index %d" , index); +else if (generation ==HW_GENERATION_HCU4 ) +printf ("HCU4: index %d" , index); +else if (generation ==HW_GENERATION_HCU5 ) +printf ("HCU5: index %d" , index); +else if (generation ==HW_GENERATION_MCU25 ) +printf ("MCU25: index %d" , index); +printf (" HW 0x%x\n" , hw_capabilities); +for (j =0 ;j <6 ; j++) { +hcu_led_set (1 << j); +udelay (200 *1000 ); + }
board/netstal/common/nm_bsp.c line 68
Quoted 10 lines
board/netstal/common/nm_bsp.c +5
-4+} + +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 ];
Newline.
Quoted 43 lines
board/netstal/common/nm_bsp.c +43
-0+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 (); + +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",
board/netstal/common/nm_bsp.c line 121
Quoted 10 lines
board/netstal/common/nm_bsp.c +10
-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 */ + {
Why do you need this "{" here? Doesn't really make sense to me.
Please fix and resubmit.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/1 ppc_4xx:netstal/common define routines used by all boards
In reply to Niklaus GigerQuoted 47 lines · In message <[email protected]> you wrote:
Added some routines used by all Netstal boards
nm_show_printandcommon_misc_init_rand the very specific code to handle our SW installation procedure (set_params_for_sw_install).Signed-off-by Niklaus Giger <[email protected]>--- board/netstal/common/nm_bsp.c | 131 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 116 insertions(+), 15 deletions(-)board/netstal/common/nm_bsp.c +24
-5@@ -20,22 +20,123 @@#include <common.h> #include <command.h> +#include <net.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" + +extern void hcu_led_set (u32 value); +extern u32 get_serial_number (void ); +extern u32 hcu_get_slot (void ); + +enum { +/* HW_GENERATION_HCU1 is no longer supported */ +HW_GENERATION_HCU2 =0x10 , +HW_GENERATION_HCU3 =0x10 , +HW_GENERATION_HCU4 =0x20 , +HW_GENERATION_HCU5 =0x30 , +HW_GENERATION_MCU =0x08 , +HW_GENERATION_MCU20 =0x0a , +HW_GENERATION_MCU25 =0x09 , +}; + + +void nm_show_print (int generation,int index,int hw_capabilities) +{ +int j;
board/netstal/common/nm_bsp.c line 57
Quoted 10 lines
board/netstal/common/nm_bsp.c +10
-0+/* reset ANSI terminal color mode */ +printf ("\x1B""[0m""Netstal Maschinen AG: " ); +if (generation ==HW_GENERATION_HCU3 ) +printf ("HCU3: index %d" , index); +else if (generation ==HW_GENERATION_HCU4 ) +printf ("HCU4: index %d" , index); +else if (generation ==HW_GENERATION_HCU5 ) +printf ("HCU5: index %d" , index); +else if (generation ==HW_GENERATION_MCU25 ) +printf ("MCU25: index %d" , index);
else ???
You probably want to do this in a loop over an array of structs matching "generation" IDs with names - will become more readable and less error prone. And eventually smaller code, too.
board/netstal/common/nm_bsp.c line 123
Quoted 6 lines
board/netstal/common/nm_bsp.c +6
-0+ } + +/* IP-Adress update */ + { +IPaddr_t ipaddr; +char *ipstring;
Please don't do this. Declare the vaiable at entry into this funtion.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A direct quote from the Boss: "We passed over a lot of good people to get the ones we hired."