Re: [U-Boot] [PATCH v2 3/4] arm, at91: add Siemens board taurus and axm

2013-11-04 Thread Andreas Bießmann
On 11/04/2013 07:40 AM, Heiko Schocher wrote:
 enable support for the siemens AT91SAM9G20 based boards taurus
 and axm.
 
 Signed-off-by: Roger Meier r.me...@siemens.com
 Reviewed-by: Heiko Schocher h...@denx.de
 Cc: Andreas Bießmann andreas.de...@googlemail.com
 Cc: Bo Shen voice.s...@atmel.com
 
 ---
 - changes for v2:
   - add comments from bo shen
 - use gpio api
 - remove unneccessary comment
 - use at91_wait_for_reset()
 - remove unneccessary code in board file
 - Coding Style cleanup (tabs and unneccessary 1 after config define
   removed)
 - add commit message
   - add comments from Andreas Bießmann andreas.de...@googlemail.com:
 - detect sdram size on startup without read dram setting
 - get rid of MACH_TYPE definition in config file
 ---
  board/siemens/taurus/Makefile |  38 +
  board/siemens/taurus/taurus.c | 186 
 ++
  boards.cfg|   2 +
  include/configs/taurus.h  | 159 
  4 files changed, 385 insertions(+)
  create mode 100644 board/siemens/taurus/Makefile
  create mode 100644 board/siemens/taurus/taurus.c
  create mode 100644 include/configs/taurus.h
 
 diff --git a/board/siemens/taurus/Makefile b/board/siemens/taurus/Makefile
 new file mode 100644
 index 000..9c288b7
 --- /dev/null
 +++ b/board/siemens/taurus/Makefile
 @@ -0,0 +1,38 @@
 +#
 +# Makefile for Siemens TAURUS (AT91SAM9G20) based board
 +# (C) Copyright 2013 Siemens AG
 +#
 +# Based on:
 +# U-Boot file: board/atmel/at91sam9260ek/Makefile
 +#
 +# (C) Copyright 2003-2008
 +# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 +#
 +# (C) Copyright 2008
 +# Stelian Pop stel...@popies.net
 +# Lead Tech Design www.leadtechdesign.com
 +#
 +# SPDX-License-Identifier:   GPL-2.0+
 +#
 +
 +include $(TOPDIR)/config.mk
 +
 +LIB  = $(obj)lib$(BOARD).o
 +
 +COBJS-y  += taurus.o
 +
 +SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
 +OBJS := $(addprefix $(obj),$(COBJS-y))
 +SOBJS:= $(addprefix $(obj),$(SOBJS))
 +
 +$(LIB):  $(obj).depend $(OBJS) $(SOBJS)
 + $(call cmd_link_o_target, $(OBJS) $(SOBJS))
 +
 +#
 +
 +# defines $(obj).depend target
 +include $(SRCTREE)/rules.mk
 +
 +sinclude $(obj).depend
 +
 +#
 diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
 new file mode 100644
 index 000..66d55d6
 --- /dev/null
 +++ b/board/siemens/taurus/taurus.c
 @@ -0,0 +1,186 @@
 +/*
 + * Board functions for Siemens TAURUS (AT91SAM9G20) based boards
 + * (C) Copyright Siemens AG
 + *
 + * Based on:
 + * U-Boot file: board/atmel/at91sam9260ek/at91sam9260ek.c
 + *
 + * (C) Copyright 2007-2008
 + * Stelian Pop stel...@popies.net
 + * Lead Tech Design www.leadtechdesign.com
 + *
 + * SPDX-License-Identifier:  GPL-2.0+
 + */
 +
 +#include common.h
 +#include asm/io.h
 +#include asm/arch/at91sam9260_matrix.h
 +#include asm/arch/at91sam9_smc.h
 +#include asm/arch/at91_common.h
 +#include asm/arch/at91_pmc.h
 +#include asm/arch/at91_rstc.h
 +#include asm/arch/gpio.h
 +#include asm/arch/at91sam9_sdramc.h
 +#include atmel_mci.h
 +
 +#if defined(CONFIG_RESET_PHY_R)  defined(CONFIG_MACB)

minor complaint: I think we can include net.h unconditionally here.

 +# include net.h
 +#endif
 +#include netdev.h
 +
 +DECLARE_GLOBAL_DATA_PTR;
 +
 +#ifdef CONFIG_CMD_NAND
 +static void taurus_nand_hw_init(void)
 +{
 + struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
 + struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
 + unsigned long csa;
 +
 + /* Assign CS3 to NAND/SmartMedia Interface */
 + csa = readl(matrix-ebicsa);
 + csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
 + writel(csa, matrix-ebicsa);
 +
 + /* Configure SMC CS3 for NAND/SmartMedia */
 + writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
 +AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
 +smc-cs[3].setup);
 + writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
 +AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(3),
 +smc-cs[3].pulse);
 + writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
 +smc-cs[3].cycle);
 + writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
 +AT91_SMC_MODE_EXNW_DISABLE |
 +AT91_SMC_MODE_DBW_8 |
 +AT91_SMC_MODE_TDF_CYCLE(3),
 +smc-cs[3].mode);
 +
 + /* Configure RDY/BSY */
 + at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
 +
 + /* Enable NandFlash */
 + at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 +}
 +#endif
 +
 +#ifdef CONFIG_MACB
 +static void taurus_macb_hw_init(void)
 +{
 + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 + struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
 + unsigned long erstl;
 +
 + /* 

Re: [U-Boot] [PATCH v2 3/4] arm, at91: add Siemens board taurus and axm

2013-11-04 Thread Heiko Schocher

Hello Andreas,

Am 04.11.2013 09:43, schrieb Andreas Bießmann:

On 11/04/2013 07:40 AM, Heiko Schocher wrote:

enable support for the siemens AT91SAM9G20 based boards taurus
and axm.

Signed-off-by: Roger Meierr.me...@siemens.com
Reviewed-by: Heiko Schocherh...@denx.de
Cc: Andreas Bießmannandreas.de...@googlemail.com
Cc: Bo Shenvoice.s...@atmel.com

---
- changes for v2:
   - add comments from bo shen
 - use gpio api
 - remove unneccessary comment
 - use at91_wait_for_reset()
 - remove unneccessary code in board file
 - Coding Style cleanup (tabs and unneccessary 1 after config define
   removed)
 - add commit message
   - add comments from Andreas Bießmannandreas.de...@googlemail.com:
 - detect sdram size on startup without read dram setting
 - get rid of MACH_TYPE definition in config file
---
  board/siemens/taurus/Makefile |  38 +
  board/siemens/taurus/taurus.c | 186 ++
  boards.cfg|   2 +
  include/configs/taurus.h  | 159 
  4 files changed, 385 insertions(+)
  create mode 100644 board/siemens/taurus/Makefile
  create mode 100644 board/siemens/taurus/taurus.c
  create mode 100644 include/configs/taurus.h

diff --git a/board/siemens/taurus/Makefile b/board/siemens/taurus/Makefile
new file mode 100644
index 000..9c288b7
--- /dev/null
+++ b/board/siemens/taurus/Makefile

[...]

diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
new file mode 100644
index 000..66d55d6
--- /dev/null
+++ b/board/siemens/taurus/taurus.c
@@ -0,0 +1,186 @@
+/*
+ * Board functions for Siemens TAURUS (AT91SAM9G20) based boards
+ * (C) Copyright Siemens AG
+ *
+ * Based on:
+ * U-Boot file: board/atmel/at91sam9260ek/at91sam9260ek.c
+ *
+ * (C) Copyright 2007-2008
+ * Stelian Popstel...@popies.net
+ * Lead Tech Designwww.leadtechdesign.com
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#includecommon.h
+#includeasm/io.h
+#includeasm/arch/at91sam9260_matrix.h
+#includeasm/arch/at91sam9_smc.h
+#includeasm/arch/at91_common.h
+#includeasm/arch/at91_pmc.h
+#includeasm/arch/at91_rstc.h
+#includeasm/arch/gpio.h
+#includeasm/arch/at91sam9_sdramc.h
+#includeatmel_mci.h
+
+#if defined(CONFIG_RESET_PHY_R)  defined(CONFIG_MACB)


minor complaint: I think we can include net.h unconditionally here.


removed.


+# includenet.h
+#endif
+#includenetdev.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_CMD_NAND
+static void taurus_nand_hw_init(void)
+{
+   struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+   struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
+   unsigned long csa;
+
+   /* Assign CS3 to NAND/SmartMedia Interface */
+   csa = readl(matrix-ebicsa);
+   csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
+   writel(csa,matrix-ebicsa);
+
+   /* Configure SMC CS3 for NAND/SmartMedia */
+   writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
+  AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
+   smc-cs[3].setup);
+   writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
+  AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(3),
+   smc-cs[3].pulse);
+   writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
+   smc-cs[3].cycle);
+   writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+  AT91_SMC_MODE_EXNW_DISABLE |
+  AT91_SMC_MODE_DBW_8 |
+  AT91_SMC_MODE_TDF_CYCLE(3),
+   smc-cs[3].mode);
+
+   /* Configure RDY/BSY */
+   at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+
+   /* Enable NandFlash */
+   at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#endif
+
+#ifdef CONFIG_MACB
+static void taurus_macb_hw_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
+   unsigned long erstl;
+
+   /* Enable EMAC clock */
+   writel(1  ATMEL_ID_EMAC0,pmc-pcer);


Is it required to enable the MACB clock before PHY reset? It will be
done later on in at91_macb_hw_init() in any case.


Hmm.. this is done in more at91 boards ... Hmm.. seems we should
look, if we can make this function common? If I see this correct,
only the pin setup is board specific, or?


+
+   /*
+* Disable pull-up on:
+*  RXDV (PA17) =  PHY normal mode (not Test mode)
+*  ERX0 (PA14) =  PHY ADDR0
+*  ERX1 (PA15) =  PHY ADDR1
+*  ERX2 (PA25) =  PHY ADDR2
+*  ERX3 (PA26) =  PHY ADDR3
+*  ECRS (PA28) =  PHY ADDR4  =  PHYADDR = 0x0
+*
+* PHY has internal pull-down
+*/
+   at91_set_pio_pullup(AT91_PIO_PORTA, 14, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTA, 15, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTA, 17, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTA, 25, 0);
+   at91_set_pio_pullup(AT91_PIO_PORTA, 26, 

Re: [U-Boot] [PATCH v2 3/4] arm, at91: add Siemens board taurus and axm

2013-11-04 Thread Andreas Bießmann
Hello Heiko,

On 11/04/2013 10:09 AM, Heiko Schocher wrote:
 Am 04.11.2013 09:43, schrieb Andreas Bießmann:
 On 11/04/2013 07:40 AM, Heiko Schocher wrote:

snip

 +#ifdef CONFIG_MACB
 +static void taurus_macb_hw_init(void)
 +{
 +struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 +struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
 +unsigned long erstl;
 +
 +/* Enable EMAC clock */
 +writel(1  ATMEL_ID_EMAC0,pmc-pcer);

 Is it required to enable the MACB clock before PHY reset? It will be
 done later on in at91_macb_hw_init() in any case.
 
 Hmm.. this is done in more at91 boards ... Hmm.. seems we should
 look, if we can make this function common? If I see this correct,
 only the pin setup is board specific, or?

That's true.

How could we provide the gpio setup to a common function then?

I think we should go with some at91_phy_reset() which should preferably
run before enabling the (e)macb (would that be true for
CONFIG_RESET_PHY_R?).
I haven't checked it but think it would be Ok to enable the (e)macb
peripheral clock when enabling the peripheral. Therefore the 'Enable
EMAC clock' above could be removed. _All_ at91_macb_hw_init() should
therefore enable the peripheral clock ... unfortunately some do not at
the moment.

snip

 +/* USB */
 +#if defined(CONFIG_BOARD_TAURUS)
 +#define CONFIG_USB_ATMEL
 +#define CONFIG_USB_OHCI_NEW
 +#define CONFIG_SYS_USB_OHCI_CPU_INIT
 +#define CONFIG_SYS_USB_OHCI_REGS_BASE0x0050
 +#define CONFIG_SYS_USB_OHCI_SLOT_NAMEat91sam9260
 +#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS2LEGA

 What does '2LEGA' mean here?
 
 Hups... This should be:
 
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS2
 
 Hmm... I do not find this in my patch file I send with git-sendmail
 
 Also in the mailarchive:
 http://lists.denx.de/pipermail/u-boot/2013-November/166040.html
 
 I could not find 2LEGA ...
 
 But in Patchwork, there is a 2LEGA ...
 
 http://patchwork.ozlabs.org/patch/288117/

I can't find it in the patch ...

 
 It seems, thats something introduced from you?

Yea, maybe some cursor jump around in MUA while writing 'ATMEL_LEGACY'.
Sorry for the trouble.

Best regards

Andreas Bießmann
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/4] arm, at91: add Siemens board taurus and axm

2013-11-03 Thread Heiko Schocher
enable support for the siemens AT91SAM9G20 based boards taurus
and axm.

Signed-off-by: Roger Meier r.me...@siemens.com
Reviewed-by: Heiko Schocher h...@denx.de
Cc: Andreas Bießmann andreas.de...@googlemail.com
Cc: Bo Shen voice.s...@atmel.com

---
- changes for v2:
  - add comments from bo shen
- use gpio api
- remove unneccessary comment
- use at91_wait_for_reset()
- remove unneccessary code in board file
- Coding Style cleanup (tabs and unneccessary 1 after config define
  removed)
- add commit message
  - add comments from Andreas Bießmann andreas.de...@googlemail.com:
- detect sdram size on startup without read dram setting
- get rid of MACH_TYPE definition in config file
---
 board/siemens/taurus/Makefile |  38 +
 board/siemens/taurus/taurus.c | 186 ++
 boards.cfg|   2 +
 include/configs/taurus.h  | 159 
 4 files changed, 385 insertions(+)
 create mode 100644 board/siemens/taurus/Makefile
 create mode 100644 board/siemens/taurus/taurus.c
 create mode 100644 include/configs/taurus.h

diff --git a/board/siemens/taurus/Makefile b/board/siemens/taurus/Makefile
new file mode 100644
index 000..9c288b7
--- /dev/null
+++ b/board/siemens/taurus/Makefile
@@ -0,0 +1,38 @@
+#
+# Makefile for Siemens TAURUS (AT91SAM9G20) based board
+# (C) Copyright 2013 Siemens AG
+#
+# Based on:
+# U-Boot file: board/atmel/at91sam9260ek/Makefile
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop stel...@popies.net
+# Lead Tech Design www.leadtechdesign.com
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS-y+= taurus.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS-y))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
new file mode 100644
index 000..66d55d6
--- /dev/null
+++ b/board/siemens/taurus/taurus.c
@@ -0,0 +1,186 @@
+/*
+ * Board functions for Siemens TAURUS (AT91SAM9G20) based boards
+ * (C) Copyright Siemens AG
+ *
+ * Based on:
+ * U-Boot file: board/atmel/at91sam9260ek/at91sam9260ek.c
+ *
+ * (C) Copyright 2007-2008
+ * Stelian Pop stel...@popies.net
+ * Lead Tech Design www.leadtechdesign.com
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include common.h
+#include asm/io.h
+#include asm/arch/at91sam9260_matrix.h
+#include asm/arch/at91sam9_smc.h
+#include asm/arch/at91_common.h
+#include asm/arch/at91_pmc.h
+#include asm/arch/at91_rstc.h
+#include asm/arch/gpio.h
+#include asm/arch/at91sam9_sdramc.h
+#include atmel_mci.h
+
+#if defined(CONFIG_RESET_PHY_R)  defined(CONFIG_MACB)
+# include net.h
+#endif
+#include netdev.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_CMD_NAND
+static void taurus_nand_hw_init(void)
+{
+   struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+   struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
+   unsigned long csa;
+
+   /* Assign CS3 to NAND/SmartMedia Interface */
+   csa = readl(matrix-ebicsa);
+   csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
+   writel(csa, matrix-ebicsa);
+
+   /* Configure SMC CS3 for NAND/SmartMedia */
+   writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
+  AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
+  smc-cs[3].setup);
+   writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
+  AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(3),
+  smc-cs[3].pulse);
+   writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
+  smc-cs[3].cycle);
+   writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+  AT91_SMC_MODE_EXNW_DISABLE |
+  AT91_SMC_MODE_DBW_8 |
+  AT91_SMC_MODE_TDF_CYCLE(3),
+  smc-cs[3].mode);
+
+   /* Configure RDY/BSY */
+   at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+
+   /* Enable NandFlash */
+   at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#endif
+
+#ifdef CONFIG_MACB
+static void taurus_macb_hw_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
+   unsigned long erstl;
+
+   /* Enable EMAC clock */
+   writel(1  ATMEL_ID_EMAC0, pmc-pcer);
+
+   /*
+* Disable pull-up on:
+*  RXDV (PA17) = PHY normal mode (not Test mode)
+*  ERX0 (PA14) = PHY