* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
2008-01-16 17:39 [U-Boot-Users] [PATCH] ppc_4xx resubmit: Netstal HCU5 board: added various fixes and POST Niklaus Giger
@ 2008-01-16 17:39 ` Niklaus Giger
2008-01-17 7:18 ` Stefan Roese
2008-01-17 13:36 ` Stefan Roese
0 siblings, 2 replies; 6+ messages in thread
From: Niklaus Giger @ 2008-01-16 17:39 UTC (permalink / raw)
To: u-boot
Added some routines used by all Netstal boards:
- nm_bsp.c: - nm_show_print and
- common_misc_init_r
- set_params_for_sw_install. Bery specific code to handle our SW
installation procedure
- fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
to handle sdram initialization.
- nm.h: Common header
Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
---
board/netstal/common/fixed_sdram.c | 107 +++++++++++++++++++++++++++++
board/netstal/common/nm.h | 40 +++++++++++
board/netstal/common/nm_bsp.c | 131 +++++++++++++++++++++++++++++++-----
3 files changed, 262 insertions(+), 16 deletions(-)
create mode 100644 board/netstal/common/fixed_sdram.c
create mode 100644 board/netstal/common/nm.h
diff --git a/board/netstal/common/fixed_sdram.c b/board/netstal/common/fixed_sdram.c
new file mode 100644
index 0000000..f6e4b5a
--- /dev/null
+++ b/board/netstal/common/fixed_sdram.c
@@ -0,0 +1,107 @@
+/*
+ *(C) Copyright 2005-2008 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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 <ppc4xx.h>
+#include <asm/processor.h>
+#include "nm.h"
+
+#if defined(DEBUG)
+void show_sdram_registers(void)
+{
+ u32 value;
+
+ printf ("SDRAM Controller Registers --\n");
+ mfsdram(mem_mcopt1, value);
+ printf (" SDRAM0_CFG : 0x%08x\n", value);
+ mfsdram(mem_status, value);
+ printf (" SDRAM0_STATUS: 0x%08x\n", value);
+ mfsdram(mem_mb0cf, value);
+ printf (" SDRAM0_B0CR : 0x%08x\n", value);
+ mfsdram(mem_mb1cf, value);
+ printf (" SDRAM0_B1CR : 0x%08x\n", value);
+ mfsdram(mem_sdtr1, value);
+ printf (" SDRAM0_TR : 0x%08x\n", value);
+ mfsdram(mem_rtr, value);
+ printf (" SDRAM0_RTR : 0x%08x\n", value);
+}
+#endif
+
+long int fixed_hcu4_sdram (unsigned int dram_size)
+{
+#ifdef DEBUG
+ printf (__FUNCTION__);
+#endif
+ /* disable memory controller */
+ mtdcr (memcfga, mem_mcopt1);
+ mtdcr (memcfgd, 0x00000000);
+
+ udelay (500);
+
+ /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
+ mtdcr (memcfga, mem_besra);
+ mtdcr (memcfgd, 0xffffffff);
+
+ /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
+ mtdcr (memcfga, mem_besrb);
+ mtdcr (memcfgd, 0xffffffff);
+
+ /* Clear SDRAM0_ECCCFG (disable ECC) */
+ mtdcr (memcfga, mem_ecccf);
+ mtdcr (memcfgd, 0x00000000);
+
+ /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
+ mtdcr (memcfga, mem_eccerr);
+ mtdcr (memcfgd, 0xffffffff);
+
+ /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
+ */
+ mtdcr (memcfga, mem_sdtr1);
+ mtdcr (memcfgd, 0x008a4015);
+
+ /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
+ */
+ mtdcr (memcfga, mem_mb0cf);
+ if(dram_size == 32*1024*1024) { mtdcr (memcfgd, 0x00062001); }
+ if(dram_size == 64*1024*1024) { mtdcr (memcfgd, 0x00084001); }
+ if(dram_size == 128*1024*1024) { mtdcr (memcfgd, 0x000A4001); }
+
+ /* refresh timer = 0x400 */
+ mtdcr (memcfga, mem_rtr);
+ if(dram_size == 32*1024*1024) { mtdcr (memcfgd, 0x07F00000); }
+ if(dram_size == 64*1024*1024) { mtdcr (memcfgd, 0x04100000); }
+ if(dram_size == 128*1024*1024) { mtdcr (memcfgd, 0x04100000); }
+
+ /* Power management idle timer set to the default. */
+ mtdcr (memcfga, mem_pmit);
+ mtdcr (memcfgd, 0x07c00000);
+
+ udelay (500);
+
+ /* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */
+ mtdcr (memcfga, mem_mcopt1);
+ mtdcr (memcfgd, 0x90800000);
+
+#ifdef DEBUG
+ printf ("%s: done\n", __FUNCTION__);
+#endif
+ return dram_size;
+}
+
diff --git a/board/netstal/common/nm.h b/board/netstal/common/nm.h
new file mode 100644
index 0000000..7e59390
--- /dev/null
+++ b/board/netstal/common/nm.h
@@ -0,0 +1,40 @@
+/*
+ *(C) Copyright 2005-2007 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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
+ */
+
+extern void hcu_led_set(u32 value);
+extern u32 get_serial_number(void);
+extern u32 hcu_get_slot(void);
+extern int board_with_pci(void);
+extern void nm_show_print(int generation, int index, int hw_capabilities);
+extern void set_params_for_sw_install(int install_requested, char *board_name );
+extern void common_misc_init_r(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,
+};
+
+
diff --git a/board/netstal/common/nm_bsp.c b/board/netstal/common/nm_bsp.c
index a9de45e..c756ecd 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 at netstal.com)
*
* This source code is free software; you can redistribute it
@@ -20,22 +20,121 @@
#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 )
+{
+ 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)
{
- 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;
+ 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
--
1.5.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
2008-01-16 17:39 ` [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards Niklaus Giger
@ 2008-01-17 7:18 ` Stefan Roese
2008-01-17 13:36 ` Stefan Roese
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2008-01-17 7:18 UTC (permalink / raw)
To: u-boot
On Wednesday 16 January 2008, Niklaus Giger wrote:
> Added some routines used by all Netstal boards:
> - nm_bsp.c: - nm_show_print and
> - common_misc_init_r
> - set_params_for_sw_install. Bery specific code to handle our SW
> installation procedure
> - fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
> to handle sdram initialization.
> - nm.h: Common header
Please find some comments below.
> Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
> ---
> board/netstal/common/fixed_sdram.c | 107 +++++++++++++++++++++++++++++
> board/netstal/common/nm.h | 40 +++++++++++
> board/netstal/common/nm_bsp.c | 131 +++++++++++++++++++++++++++++++-----
> 3 files changed, 262 insertions(+), 16 deletions(-)
> create mode 100644 board/netstal/common/fixed_sdram.c
> create mode 100644 board/netstal/common/nm.h
>
> diff --git a/board/netstal/common/fixed_sdram.c b/board/netstal/common/fixed_sdram.c
> new file mode 100644
> index 0000000..f6e4b5a
> --- /dev/null
> +++ b/board/netstal/common/fixed_sdram.c
> @@ -0,0 +1,107 @@
> +/*
> + *(C) Copyright 2005-2008 Netstal Maschinen AG
> + * Niklaus Giger (Niklaus.Giger at netstal.com)
> + *
> + * This source code is free software; you can redistribute it
> + * and/or modify it in source code form 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 <ppc4xx.h>
> +#include <asm/processor.h>
> +#include "nm.h"
> +
> +#if defined(DEBUG)
> +void show_sdram_registers(void)
> +{
> + u32 value;
> +
> + printf ("SDRAM Controller Registers --\n");
> + mfsdram(mem_mcopt1, value);
You are mixing two programming styles here. func () and func(). Please
only use one style in one source file.
> + printf (" SDRAM0_CFG : 0x%08x\n", value);
> + mfsdram(mem_status, value);
> + printf (" SDRAM0_STATUS: 0x%08x\n", value);
> + mfsdram(mem_mb0cf, value);
> + printf (" SDRAM0_B0CR : 0x%08x\n", value);
> + mfsdram(mem_mb1cf, value);
> + printf (" SDRAM0_B1CR : 0x%08x\n", value);
> + mfsdram(mem_sdtr1, value);
> + printf (" SDRAM0_TR : 0x%08x\n", value);
> + mfsdram(mem_rtr, value);
> + printf (" SDRAM0_RTR : 0x%08x\n", value);
> +}
> +#endif
> +
> +long int fixed_hcu4_sdram (unsigned int dram_size)
> +{
> +#ifdef DEBUG
> + printf (__FUNCTION__);
> +#endif
debug(__FUNCTION__);
> + /* disable memory controller */
> + mtdcr (memcfga, mem_mcopt1);
> + mtdcr (memcfgd, 0x00000000);
mtsdram(mem_mcopt1, 0x00000000);
> + udelay (500);
> +
> + /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
> + mtdcr (memcfga, mem_besra);
> + mtdcr (memcfgd, 0xffffffff);
Please use the mtsdram/mfsdram everywhere in this file.
> + /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
> + mtdcr (memcfga, mem_besrb);
> + mtdcr (memcfgd, 0xffffffff);
> +
> + /* Clear SDRAM0_ECCCFG (disable ECC) */
> + mtdcr (memcfga, mem_ecccf);
> + mtdcr (memcfgd, 0x00000000);
> +
> + /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
> + mtdcr (memcfga, mem_eccerr);
> + mtdcr (memcfgd, 0xffffffff);
> +
> + /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
> + */
> + mtdcr (memcfga, mem_sdtr1);
> + mtdcr (memcfgd, 0x008a4015);
> +
> + /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
> + */
> + mtdcr (memcfga, mem_mb0cf);
> + if(dram_size == 32*1024*1024) { mtdcr (memcfgd, 0x00062001); }
> + if(dram_size == 64*1024*1024) { mtdcr (memcfgd, 0x00084001); }
> + if(dram_size == 128*1024*1024) { mtdcr (memcfgd, 0x000A4001); }
Multiple problems in this one. Why not:
switch (dram_size >> 20) {
case 32:
mtsdram(mem_mb0cf, 0x00062001);
break;
case 64:
mtsdram(mem_mb0cf, 0x00084001);
break;
case 128:
mtsdram(mem_mb0cf, 0x000A4001);
break;
default:
printf("Some error here...\n");
}
> + /* refresh timer = 0x400 */
> + mtdcr (memcfga, mem_rtr);
> + if(dram_size == 32*1024*1024) { mtdcr (memcfgd, 0x07F00000); }
> + if(dram_size == 64*1024*1024) { mtdcr (memcfgd, 0x04100000); }
> + if(dram_size == 128*1024*1024) { mtdcr (memcfgd, 0x04100000); }
Again.
> + /* Power management idle timer set to the default. */
> + mtdcr (memcfga, mem_pmit);
> + mtdcr (memcfgd, 0x07c00000);
> +
> + udelay (500);
> +
> + /* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */
> + mtdcr (memcfga, mem_mcopt1);
> + mtdcr (memcfgd, 0x90800000);
> +
> +#ifdef DEBUG
> + printf ("%s: done\n", __FUNCTION__);
> +#endif
> + return dram_size;
> +}
> +
> diff --git a/board/netstal/common/nm.h b/board/netstal/common/nm.h
> new file mode 100644
> index 0000000..7e59390
> --- /dev/null
> +++ b/board/netstal/common/nm.h
> @@ -0,0 +1,40 @@
> +/*
> + *(C) Copyright 2005-2007 Netstal Maschinen AG
> + * Niklaus Giger (Niklaus.Giger at netstal.com)
> + *
> + * This source code is free software; you can redistribute it
> + * and/or modify it in source code form 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
> + */
> +
> +extern void hcu_led_set(u32 value);
> +extern u32 get_serial_number(void);
> +extern u32 hcu_get_slot(void);
> +extern int board_with_pci(void);
> +extern void nm_show_print(int generation, int index, int hw_capabilities);
> +extern void set_params_for_sw_install(int install_requested, char *board_name );
> +extern void common_misc_init_r(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,
> +};
> +
> +
> diff --git a/board/netstal/common/nm_bsp.c b/board/netstal/common/nm_bsp.c
> index a9de45e..c756ecd 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 at netstal.com)
> *
> * This source code is free software; you can redistribute it
> @@ -20,22 +20,121 @@
>
> #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] =
> +{
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;
char *generationName = 0;
> +
> + /* reset ANSI terminal color mode */
> + printf("\x1B""[0m""Netstal Maschinen AG: ");
> + for (j=0; j < (sizeof(generations)/sizeof(generations[0])); j++)
> + {
for (j=0; j < (sizeof(generations)/sizeof(generations[0])); j++) {
or even:
for (j=0; j < ARRAY_SIZE(generations); j++) {
> + if (generations[j].id == generation)
> + {
if (generations[j].id == generation) {
Please fix and re-submit.
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
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
@ 2008-01-17 8:59 Niklaus Giger
2008-01-17 9:07 ` Stefan Roese
0 siblings, 1 reply; 6+ messages in thread
From: Niklaus Giger @ 2008-01-17 8:59 UTC (permalink / raw)
To: u-boot
Added some routines used by all Netstal boards:
- nm_bsp.c: - nm_show_print and
- common_misc_init_r
- set_params_for_sw_install. Bery specific code to handle our SW
installation procedure
- fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
to handle sdram initialization.
- nm.h: Common header
Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
---
board/netstal/common/fixed_sdram.c | 106 +++++++++++++++++++++++++++++
board/netstal/common/nm.h | 40 +++++++++++
board/netstal/common/nm_bsp.c | 128 +++++++++++++++++++++++++++++++-----
3 files changed, 258 insertions(+), 16 deletions(-)
create mode 100644 board/netstal/common/fixed_sdram.c
create mode 100644 board/netstal/common/nm.h
diff --git a/board/netstal/common/fixed_sdram.c b/board/netstal/common/fixed_sdram.c
new file mode 100644
index 0000000..65b297f
--- /dev/null
+++ b/board/netstal/common/fixed_sdram.c
@@ -0,0 +1,106 @@
+/*
+ *(C) Copyright 2005-2008 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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 <ppc4xx.h>
+#include <asm/processor.h>
+#include "nm.h"
+
+#if defined(DEBUG)
+void show_sdram_registers(void)
+{
+ u32 value;
+
+ printf("SDRAM Controller Registers --\n");
+ mfsdram(mem_mcopt1, value);
+ printf(" SDRAM0_CFG : 0x%08x\n", value);
+ mfsdram(mem_status, value);
+ printf(" SDRAM0_STATUS: 0x%08x\n", value);
+ mfsdram(mem_mb0cf, value);
+ printf(" SDRAM0_B0CR : 0x%08x\n", value);
+ mfsdram(mem_mb1cf, value);
+ printf(" SDRAM0_B1CR : 0x%08x\n", value);
+ mfsdram(mem_sdtr1, value);
+ printf(" SDRAM0_TR : 0x%08x\n", value);
+ mfsdram(mem_rtr, value);
+ printf(" SDRAM0_RTR : 0x%08x\n", value);
+}
+#endif
+
+long int fixed_hcu4_sdram (unsigned int dram_size)
+{
+#ifdef DEBUG
+ printf(__FUNCTION__);
+#endif
+ /* disable memory controller */
+ mtsdram(mem_mcopt1, 0x00000000);
+
+ udelay (500);
+
+ /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
+ mtsdram(mem_besra, 0xffffffff);
+
+ /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
+ mtsdram(mem_besrb, 0xffffffff);
+
+ /* Clear SDRAM0_ECCCFG (disable ECC) */
+ mtsdram(mem_ecccf, 0x00000000);
+
+ /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
+ mtsdram(mem_eccerr, 0xffffffff);
+
+ /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
+ */
+ mtsdram(mem_sdtr1, 0x008a4015);
+
+ /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
+ * and refresh timer
+ */
+ switch (dram_size >> 20) {
+ case 32:
+ mtsdram(mem_mb0cf, 0x00062001);
+ mtsdram(mem_rtr, 0x07F00000);
+ break;
+ case 64:
+ mtsdram(mem_mb0cf, 0x00084001);
+ mtsdram(mem_rtr, 0x04100000);
+ break;
+ case 128:
+ mtsdram(mem_mb0cf, 0x000A4001);
+ mtsdram(mem_rtr, 0x04100000);
+ break;
+ default:
+ printf("Some error here...\n");
+ }
+
+ /* Power management idle timer set to the default. */
+ mtsdram(mem_pmit, 0x07c00000);
+
+ udelay (500);
+
+ /* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */
+ mtsdram(mem_mcopt1, 0x90800000);
+
+#ifdef DEBUG
+ printf("%s: done\n", __FUNCTION__);
+#endif
+ return dram_size;
+}
+
diff --git a/board/netstal/common/nm.h b/board/netstal/common/nm.h
new file mode 100644
index 0000000..7e59390
--- /dev/null
+++ b/board/netstal/common/nm.h
@@ -0,0 +1,40 @@
+/*
+ *(C) Copyright 2005-2007 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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
+ */
+
+extern void hcu_led_set(u32 value);
+extern u32 get_serial_number(void);
+extern u32 hcu_get_slot(void);
+extern int board_with_pci(void);
+extern void nm_show_print(int generation, int index, int hw_capabilities);
+extern void set_params_for_sw_install(int install_requested, char *board_name );
+extern void common_misc_init_r(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,
+};
+
+
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 at 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@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
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
2008-01-17 8:59 [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards Niklaus Giger
@ 2008-01-17 9:07 ` Stefan Roese
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2008-01-17 9:07 UTC (permalink / raw)
To: u-boot
On Thursday 17 January 2008, Niklaus Giger wrote:
> Added some routines used by all Netstal boards:
> - nm_bsp.c: - nm_show_print and
> - common_misc_init_r
> - set_params_for_sw_install. Bery specific code to handle our SW
> installation procedure
> - fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
> to handle sdram initialization.
> - nm.h: Common header
Please see below.
> Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
> ---
> board/netstal/common/fixed_sdram.c | 106 +++++++++++++++++++++++++++++
> board/netstal/common/nm.h | 40 +++++++++++
> board/netstal/common/nm_bsp.c | 128
> +++++++++++++++++++++++++++++++----- 3 files changed, 258 insertions(+), 16
> deletions(-)
> create mode 100644 board/netstal/common/fixed_sdram.c
> create mode 100644 board/netstal/common/nm.h
>
> diff --git a/board/netstal/common/fixed_sdram.c
> b/board/netstal/common/fixed_sdram.c new file mode 100644
> index 0000000..65b297f
> --- /dev/null
> +++ b/board/netstal/common/fixed_sdram.c
> @@ -0,0 +1,106 @@
> +/*
> + *(C) Copyright 2005-2008 Netstal Maschinen AG
> + * Niklaus Giger (Niklaus.Giger at netstal.com)
> + *
> + * This source code is free software; you can redistribute it
> + * and/or modify it in source code form 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 <ppc4xx.h>
> +#include <asm/processor.h>
> +#include "nm.h"
> +
> +#if defined(DEBUG)
> +void show_sdram_registers(void)
> +{
> + u32 value;
> +
> + printf("SDRAM Controller Registers --\n");
> + mfsdram(mem_mcopt1, value);
> + printf(" SDRAM0_CFG : 0x%08x\n", value);
> + mfsdram(mem_status, value);
> + printf(" SDRAM0_STATUS: 0x%08x\n", value);
> + mfsdram(mem_mb0cf, value);
> + printf(" SDRAM0_B0CR : 0x%08x\n", value);
> + mfsdram(mem_mb1cf, value);
> + printf(" SDRAM0_B1CR : 0x%08x\n", value);
> + mfsdram(mem_sdtr1, value);
> + printf(" SDRAM0_TR : 0x%08x\n", value);
> + mfsdram(mem_rtr, value);
> + printf(" SDRAM0_RTR : 0x%08x\n", value);
> +}
> +#endif
> +
> +long int fixed_hcu4_sdram (unsigned int dram_size)
> +{
> +#ifdef DEBUG
> + printf(__FUNCTION__);
> +#endif
> + /* disable memory controller */
> + mtsdram(mem_mcopt1, 0x00000000);
> +
> + udelay (500);
> +
> + /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
> + mtsdram(mem_besra, 0xffffffff);
> +
> + /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
> + mtsdram(mem_besrb, 0xffffffff);
> +
> + /* Clear SDRAM0_ECCCFG (disable ECC) */
> + mtsdram(mem_ecccf, 0x00000000);
> +
> + /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
> + mtsdram(mem_eccerr, 0xffffffff);
> +
> + /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
> + */
> + mtsdram(mem_sdtr1, 0x008a4015);
> +
> + /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
> + * and refresh timer
> + */
> + switch (dram_size >> 20) {
> + case 32:
> + mtsdram(mem_mb0cf, 0x00062001);
> + mtsdram(mem_rtr, 0x07F00000);
> + break;
> + case 64:
> + mtsdram(mem_mb0cf, 0x00084001);
> + mtsdram(mem_rtr, 0x04100000);
> + break;
> + case 128:
> + mtsdram(mem_mb0cf, 0x000A4001);
> + mtsdram(mem_rtr, 0x04100000);
> + break;
> + default:
> + printf("Some error here...\n");
Heh. This was just an example that you should fill with a reasonable error
message. :)
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
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
@ 2008-01-17 11:53 Niklaus Giger
0 siblings, 0 replies; 6+ messages in thread
From: Niklaus Giger @ 2008-01-17 11:53 UTC (permalink / raw)
To: u-boot
Added some routines used by all Netstal boards:
- nm_bsp.c: - nm_show_print and
- common_misc_init_r
- set_params_for_sw_install. Very specific code to handle our SW
installation procedure
- fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
to handle sdram initialization.
- nm.h: Common header
Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
---
board/netstal/common/fixed_sdram.c | 106 +++++++++++++++++++++++++++++
board/netstal/common/nm.h | 40 +++++++++++
board/netstal/common/nm_bsp.c | 128 +++++++++++++++++++++++++++++++-----
3 files changed, 258 insertions(+), 16 deletions(-)
create mode 100644 board/netstal/common/fixed_sdram.c
create mode 100644 board/netstal/common/nm.h
diff --git a/board/netstal/common/fixed_sdram.c b/board/netstal/common/fixed_sdram.c
new file mode 100644
index 0000000..467c6ab
--- /dev/null
+++ b/board/netstal/common/fixed_sdram.c
@@ -0,0 +1,106 @@
+/*
+ *(C) Copyright 2005-2008 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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 <ppc4xx.h>
+#include <asm/processor.h>
+#include "nm.h"
+
+#if defined(DEBUG)
+void show_sdram_registers(void)
+{
+ u32 value;
+
+ printf("SDRAM Controller Registers --\n");
+ mfsdram(mem_mcopt1, value);
+ printf(" SDRAM0_CFG : 0x%08x\n", value);
+ mfsdram(mem_status, value);
+ printf(" SDRAM0_STATUS: 0x%08x\n", value);
+ mfsdram(mem_mb0cf, value);
+ printf(" SDRAM0_B0CR : 0x%08x\n", value);
+ mfsdram(mem_mb1cf, value);
+ printf(" SDRAM0_B1CR : 0x%08x\n", value);
+ mfsdram(mem_sdtr1, value);
+ printf(" SDRAM0_TR : 0x%08x\n", value);
+ mfsdram(mem_rtr, value);
+ printf(" SDRAM0_RTR : 0x%08x\n", value);
+}
+#endif
+
+long int fixed_hcu4_sdram (unsigned int dram_size)
+{
+#ifdef DEBUG
+ printf(__FUNCTION__);
+#endif
+ /* disable memory controller */
+ mtsdram(mem_mcopt1, 0x00000000);
+
+ udelay (500);
+
+ /* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
+ mtsdram(mem_besra, 0xffffffff);
+
+ /* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
+ mtsdram(mem_besrb, 0xffffffff);
+
+ /* Clear SDRAM0_ECCCFG (disable ECC) */
+ mtsdram(mem_ecccf, 0x00000000);
+
+ /* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
+ mtsdram(mem_eccerr, 0xffffffff);
+
+ /* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
+ */
+ mtsdram(mem_sdtr1, 0x008a4015);
+
+ /* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
+ * and refresh timer
+ */
+ switch (dram_size >> 20) {
+ case 32:
+ mtsdram(mem_mb0cf, 0x00062001);
+ mtsdram(mem_rtr, 0x07F00000);
+ break;
+ case 64:
+ mtsdram(mem_mb0cf, 0x00084001);
+ mtsdram(mem_rtr, 0x04100000);
+ break;
+ case 128:
+ mtsdram(mem_mb0cf, 0x000A4001);
+ mtsdram(mem_rtr, 0x04100000);
+ break;
+ default:
+ printf("Invalid memory size of %d MB given\n", dram_size >> 20);
+ }
+
+ /* Power management idle timer set to the default. */
+ mtsdram(mem_pmit, 0x07c00000);
+
+ udelay (500);
+
+ /* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */
+ mtsdram(mem_mcopt1, 0x90800000);
+
+#ifdef DEBUG
+ printf("%s: done\n", __FUNCTION__);
+#endif
+ return dram_size;
+}
+
diff --git a/board/netstal/common/nm.h b/board/netstal/common/nm.h
new file mode 100644
index 0000000..7e59390
--- /dev/null
+++ b/board/netstal/common/nm.h
@@ -0,0 +1,40 @@
+/*
+ *(C) Copyright 2005-2007 Netstal Maschinen AG
+ * Niklaus Giger (Niklaus.Giger at netstal.com)
+ *
+ * This source code is free software; you can redistribute it
+ * and/or modify it in source code form 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
+ */
+
+extern void hcu_led_set(u32 value);
+extern u32 get_serial_number(void);
+extern u32 hcu_get_slot(void);
+extern int board_with_pci(void);
+extern void nm_show_print(int generation, int index, int hw_capabilities);
+extern void set_params_for_sw_install(int install_requested, char *board_name );
+extern void common_misc_init_r(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,
+};
+
+
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 at 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@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
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards
2008-01-16 17:39 ` [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards Niklaus Giger
2008-01-17 7:18 ` Stefan Roese
@ 2008-01-17 13:36 ` Stefan Roese
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2008-01-17 13:36 UTC (permalink / raw)
To: u-boot
On Wednesday 16 January 2008, Niklaus Giger wrote:
> Added some routines used by all Netstal boards:
> - nm_bsp.c: - nm_show_print and
> - common_misc_init_r
> - set_params_for_sw_install. Bery specific code to handle our SW
> installation procedure
> - fixed_sdram.c: Common routines for HCU4 (and upcoming) MCU25 boards
> to handle sdram initialization.
> - nm.h: Common header
>
> Signed-off-by: Niklaus Giger <niklaus.giger@netstal.com>
Applied, 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
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-01-17 13:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17 8:59 [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards Niklaus Giger
2008-01-17 9:07 ` Stefan Roese
-- strict thread matches above, loose matches on Subject: below --
2008-01-17 11:53 Niklaus Giger
2008-01-16 17:39 [U-Boot-Users] [PATCH] ppc_4xx resubmit: Netstal HCU5 board: added various fixes and POST Niklaus Giger
2008-01-16 17:39 ` [U-Boot-Users] [PATCH] ppc_4xx resubmit: netstal/common define routines used by all boards Niklaus Giger
2008-01-17 7:18 ` Stefan Roese
2008-01-17 13:36 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox