Re: [U-Boot] [PATCH 2/5] [PATCH 2/5] Add support for the armadeus APF27 board

2012-07-07 Thread Stefano Babic
On 28/06/2012 22:36, Philippe Reynes wrote:
 Signed-off-by: Philippe Reynes trem...@yahoo.fr
 Signed-off-by: Eric Jarrige eric.jarr...@armadeus.org
 Signed-off-by: Nicolas Colombain nicolas.colomb...@armadeus.com
 ---

Hi Philippe,



 + rm -f $(SOBJS) $(OBJS)
 +
 +distclean:   clean
 + rm -f $(LIB) core *.bak $(obj).depend

clean / distclean are not needed, drop these rules

 +#include common.h
 +#include crc.h
 +#include jffs2/jffs2.h
 +#include nand.h
 +#include netdev.h
 +#include asm/io.h
 +#include asm/arch/imx-regs.h
 +#include asm/errno.h
 +
 +DECLARE_GLOBAL_DATA_PTR;
 +
 +u32 get_board_rev(void)
 +{
 + struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 +
 + return readl(iim-bank[1].fuse_regs[8]);

For my understanding: who does store the version number in the fuses ?
The board's manufacturer ?

 +int get_num_ram_bank(void)
 +{
 + struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 + int nr_dram_banks = 1;
 +
 + if ((get_board_rev()  0)  (CONFIG_NR_DRAM_BANKS  1))
 + nr_dram_banks += readl(iim-bank[1].fuse_regs[9])  0x01;

It seems to me there are some hidden important information in the fuses.
Maybe can you document them adding a map of the relevant fuses for this
board ?

 + /* Unlock whole flash but U-Boot */
 + s = getenv(env_offset);
 + offset = CONFIG_ENV_OFFSET;
 + if ((s != NULL)  (0 != strcmp(s, 0)))
 + offset = simple_strtoul(s, NULL, 16);
 +
 + if (nand_unlock(nand_info[0], offset, nand_info[0].size - offset))
 + printf(NAND flash lock/unlocked failed\n);

Why is it needed ?

 +void
 +show_boot_progress(int status)
 +{
 +#ifdef CONFIG_SHOW_BOOT_PROGRESS
 +#endif
 + return;
 +}

This is quite dead code..

 +#if defined(CONFIG_FEC_MXC)
 + struct eth_device *dev;
 + uchar eth_addr[6];
 +
 + rc = fecmxc_initialize(bis);
 +
 + if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 + dev = eth_get_dev_by_index(0);
 + if (dev) {
 + eth_setenv_enetaddr(STR_ENV_ETHADDR, dev-enetaddr);
 + } else {
 + printf(FEC APF27: Couldn't get eth device\n);
 + rc = -1;
 + }

It is not clear to me why you have your special way to set up the MAC
address instead of rely on the already working code. The FEC is already
initialized for i.MX27 by general SOC code, see imx27lite.

 +
 +void enable_caches(void)
 +{
 +#ifndef CONFIG_SYS_DCACHE_OFF
 + /* Enable D-cache. I-cache is already enabled in start.S */
 + dcache_enable();
 +#endif

This is SOC-related, and not board related. It belongs to the SOC code.

 diff --git a/board/armadeus/apf27/config.mk b/board/armadeus/apf27/config.mk
 new file mode 100644
 index 000..9713e69
 --- /dev/null
 +++ b/board/armadeus/apf27/config.mk
 @@ -0,0 +1,38 @@
 +#
 +# (C) Copyright 2003
 +# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 +# (C) Copyright 2012
 +# Eric Jarrige eric.jarr...@armadeus.org
 +#
 +# 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
 +#
 +
 +#
 +# This config file is used for compilation of armadeus sources
 +#
 +# You might change location of U-Boot in memory by setting right TEXT_BASE.
 +# This allows for example having one copy located at the end of ram and 
 stored
 +# in flash device and later on while developing use other location to test
 +# the code in RAM device only.
 +#
 +
 +ifndef TEXT_BASE
 +TEXT_BASE = 0xAFF0
 +endif

config.mk is obsolete and must not be added for new boards. TEXT_BASE
must be set in the configuration file, see CONFIG_SYS_TEXT_BASE.

 diff --git a/board/armadeus/apf27/lowlevel_init.S 
 b/board/armadeus/apf27/lowlevel_init.S
 +
 diff --git a/boards.cfg b/boards.cfg
 index a723f67..d77ce77 100644
 --- a/boards.cfg
 +++ b/boards.cfg
 @@ -69,6 +69,7 @@ integratorcp_cm926ejsarm arm926ejs   
 integrator  armltd
  aspenite arm arm926ejs   -   
 Marvellarmada100
  gplugd   arm arm926ejs   -   
 Marvellarmada100
  afeb9260 arm arm926ejs   -   -   
at91
 +apf27 

[U-Boot] [PATCH 2/5] [PATCH 2/5] Add support for the armadeus APF27 board

2012-06-28 Thread Philippe Reynes
Signed-off-by: Philippe Reynes trem...@yahoo.fr
Signed-off-by: Eric Jarrige eric.jarr...@armadeus.org
Signed-off-by: Nicolas Colombain nicolas.colomb...@armadeus.com
---
 board/armadeus/apf27/Makefile|   52 ++
 board/armadeus/apf27/apf27.c |  310 ++
 board/armadeus/apf27/config.mk   |   38 
 board/armadeus/apf27/lowlevel_init.S |  275 ++
 boards.cfg   |1 +
 5 files changed, 676 insertions(+), 0 deletions(-)
 create mode 100644 board/armadeus/apf27/Makefile
 create mode 100644 board/armadeus/apf27/apf27.c
 create mode 100644 board/armadeus/apf27/config.mk
 create mode 100644 board/armadeus/apf27/lowlevel_init.S

diff --git a/board/armadeus/apf27/Makefile b/board/armadeus/apf27/Makefile
new file mode 100644
index 000..fe6ba5c
--- /dev/null
+++ b/board/armadeus/apf27/Makefile
@@ -0,0 +1,52 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+# (C) Copyright 2012
+# Eric Jarrige eric.jarr...@armadeus.org
+#
+# 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).o
+
+COBJS  := apf27.o
+SOBJS  := lowlevel_init.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+clean:
+   rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/armadeus/apf27/apf27.c b/board/armadeus/apf27/apf27.c
new file mode 100644
index 000..75be2c1
--- /dev/null
+++ b/board/armadeus/apf27/apf27.c
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ * Copyright (C) 2008-2012 Eric Jarrige eric.jarr...@armadeus.org
+ *
+ * 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 crc.h
+#include jffs2/jffs2.h
+#include nand.h
+#include netdev.h
+#include asm/io.h
+#include asm/arch/imx-regs.h
+#include asm/errno.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+u32 get_board_rev(void)
+{
+   struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
+
+   return readl(iim-bank[1].fuse_regs[8]);
+}
+
+int get_num_ram_bank(void)
+{
+   struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
+   int nr_dram_banks = 1;
+
+   if ((get_board_rev()  0)  (CONFIG_NR_DRAM_BANKS  1))
+   nr_dram_banks += readl(iim-bank[1].fuse_regs[9])  0x01;
+   else
+   nr_dram_banks = CONFIG_NR_DRAM_POPULATED;
+
+   return nr_dram_banks;
+}
+
+static void apf27_gpio_init(void)
+{
+   struct gpio_regs *regs = (struct gpio_regs *)IMX_GPIO_BASE;
+
+   /* PORT A */
+   writel(CONFIG_SYS_DR_A_VAL,regs-port[PORTA].dr);
+   writel(CONFIG_SYS_OCR1_A_VAL,  regs-port[PORTA].ocr1);
+   writel(CONFIG_SYS_OCR2_A_VAL,  regs-port[PORTA].ocr2);
+   writel(CONFIG_SYS_ICFA1_A_VAL, regs-port[PORTA].iconfa1);
+   writel(CONFIG_SYS_ICFA2_A_VAL, regs-port[PORTA].iconfa2);
+   writel(CONFIG_SYS_ICFB1_A_VAL, regs-port[PORTA].iconfb1);
+   writel(CONFIG_SYS_ICFB2_A_VAL, regs-port[PORTA].iconfb2);
+   writel(CONFIG_SYS_ICR1_A_VAL,  regs-port[PORTA].icr1);
+   writel(CONFIG_SYS_ICR2_A_VAL,  regs-port[PORTA].icr2);
+