Skip to contentSkip to conversation

Add support for hammerhead AVR32 board

PATCH New Alex 5 participants 7 messages Mar 14, 2008 – Apr 6, 2008

lore
Share & tools
lore

Alex

author
#0 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

Hi

This patch adds support for our new AVR32 based board.

It is against the latest u-boot-avr32.git.

As suggested I removed 'flash.c'.
And as Ben Warren suggested I named my network initialization 'board_eth_initialize( ... )'. Like this I don't need to ifdef the call to this function, right?

Alex

u-boot-avr32/board/miromico/hammerhead/config.mk +3 -0
diff -Nur old/u-boot-avr32/board/miromico/hammerhead/config.mk new/u-boot-avr32/board/miromico/hammerhead/config.mk
@@ -0,0 +1,3 @@
+TEXT_BASE		= 0x00000000
+PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
+PLATFORM_LDFLAGS	+= --gc-sections
u-boot-avr32/board/miromico/hammerhead/eth.c +37 -0
diff -Nur old/u-boot-avr32/board/miromico/hammerhead/eth.c new/u-boot-avr32/board/miromico/hammerhead/eth.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Miromico AG
+ *
+ * Ethernet initialization for the Miromico Hammerhead AVR32 board
+ *
+ * Mostly copied form Atmel ATNGW100 sources
+ *
+ * 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 <common.h>
+
+#include <asm/arch/memory-map.h>
+
+extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
+
+#ifdef CONFIG_CMD_NET
+void board_eth_initialize(bd_t *bi)
+{
+	macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
+}
+#endif
u-boot-avr32/board/miromico/hammerhead/hammerhead.c +79 -0

79 lines not on this page · raw message

u-boot-avr32/board/miromico/hammerhead/Makefile +40 -0
diff -Nur old/u-boot-avr32/board/miromico/hammerhead/Makefile new/u-boot-avr32/board/miromico/hammerhead/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2008 Miromico AG
+#
+# 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).a
+
+COBJS	:= $(BOARD).o eth.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+$(LIB): $(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
u-boot-avr32/board/miromico/hammerhead/u-boot.lds +80 -0

80 lines not on this page · raw message

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +11 -0
diff -Nur old/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c new/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c
@@ -142,3 +142,14 @@
  	gpio_select_periph_A(GPIO_PIN_PA15, 0);	/* DATA3 */
  }
  #endif
+
+#ifdef CONFIG_HAMMERHEAD
+/*
+ * Hammerhead board uses GCLK3 (Periph A on PB29) as 25MHz clock output
+ * for ethernet PHY.
+ */
+void gpio_enable_gclk3(void)
+{
+        gpio_select_periph_A(GPIO_PIN_PB29, 0); /* GCLK3         */
+}
+#endif
u-boot-avr32/cpu/at32ap/cpu.c +14 -0
diff -Nur old/u-boot-avr32/cpu/at32ap/cpu.c new/u-boot-avr32/cpu/at32ap/cpu.c
@@ -81,6 +81,16 @@
  #endif
  }
 
+#ifdef CONFIG_HAMMERHEAD
+static void gclk_init(void)
+{
+  /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */
+
+  /* Enable GCLK3 with no input divider, from OSC0 (crystal) */
+  sm_writel( PM_GCCTRL3, SM_BIT(CEN) );
+}
+#endif
+
  int cpu_init(void)
  {
  	extern void _evba(void);
@@ -105,6 +115,10 @@
  	     p += CFG_ICACHE_LINESZ)
  		asm volatile("cache %0, 0x02" : "=m"(*p) :: "memory");
 
+#ifdef CONFIG_HAMMERHEAD
+	gclk_init();
+#endif
+
  	return 0;
  }
 
u-boot-avr32/cpu/at32ap/sm.h +10 -1
diff -Nur old/u-boot-avr32/cpu/at32ap/sm.h new/u-boot-avr32/cpu/at32ap/sm.h
@@ -21,7 +21,16 @@
  #define SM_PM_IMR				0x0048
  #define SM_PM_ISR				0x004c
  #define SM_PM_ICR				0x0050
-#define SM_PM_GCCTRL				0x0060
+
+#define SM_PM_GCCTRL0				0x0060
+#define SM_PM_GCCTRL1				0x0064
+#define SM_PM_GCCTRL2				0x0068
+#define SM_PM_GCCTRL3				0x006c
+#define SM_PM_GCCTRL4				0x0070
+#define SM_PM_GCCTRL5				0x0074
+#define SM_PM_GCCTRL6				0x0078
+#define SM_PM_GCCTRL7				0x007c
+
  #define SM_RTC_CTRL				0x0080
  #define SM_RTC_VAL				0x0084
  #define SM_RTC_TOP				0x0088
u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h +4 -0
diff -Nur old/u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h new/u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h
@@ -217,4 +217,8 @@
  void gpio_enable_mmci(void);
  #endif
 
+#ifdef CONFIG_HAMMERHEAD
+void gpio_enable_gclk3(void);
+#endif
+
  #endif /* __ASM_AVR32_ARCH_GPIO_H__ */
u-boot-avr32/include/configs/hammerhead.h +177 -0

177 lines not on this page · raw message

u-boot-avr32/MAKEALL +1 -0
diff -Nur old/u-boot-avr32/MAKEALL new/u-boot-avr32/MAKEALL
@@ -676,6 +676,7 @@
  	atstk1003	\
  	atstk1004	\
  	atngw100	\
+	hammerhead     \
  "
 
  #########################################################################
u-boot-avr32/Makefile +3 -0
diff -Nur old/u-boot-avr32/Makefile new/u-boot-avr32/Makefile
@@ -2813,6 +2813,9 @@
  atngw100_config	:	unconfig
  	@$(MKCONFIG) $(@:_config=) avr32 at32ap atngw100 atmel at32ap700x
 
+hammerhead_config       :       unconfig
+	@$(MKCONFIG) $(@:_config=) avr32 at32ap hammerhead miromico at32ap700x
+
  #########################################################################
  #########################################################################
  #########################################################################
u-boot-avr32/net/eth.c +3 -0
diff -Nur old/u-boot-avr32/net/eth.c new/u-boot-avr32/net/eth.c
@@ -64,6 +64,7 @@
  extern int mcffec_initialize(bd_t*);
  extern int mcdmafec_initialize(bd_t*);
  extern int at91cap9_eth_initialize(bd_t *);
+extern int board_eth_initialize(bd_t *);
 
  #ifdef CONFIG_API
  extern void (*push_packet)(volatile void *, int);
@@ -288,6 +289,8 @@
  	at91cap9_eth_initialize(bis);
  #endif
 
+	board_eth_initialize(bis);
+
  	if (!eth_devices) {
  		puts ("No ethernet found.\n");
  		show_boot_progress (-64);
#1 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

Quoted 2 lines · In message <[email protected]> you wrote:

This patch adds support for our new AVR32 based board.

...

Quoted 6 lines

diff -Nur old/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c new/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +0 -0
@@ -142,3 +142,14 @@
  	gpio_select_periph_A(GPIO_PIN_PA15, 0);	/* DATA3 */
  }

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c line 153

Quoted 10 lines
u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +9 -0
  #endif
+
+#ifdef CONFIG_HAMMERHEAD
+/*
+ * Hammerhead board uses GCLK3 (Periph A on PB29) as 25MHz clock output
+ * for ethernet PHY.
+ */
+void gpio_enable_gclk3(void)
+{
+        gpio_select_periph_A(GPIO_PIN_PB29, 0); /* GCLK3         */

^^^^^^^^^^

Indentation not by TAB.

Quoted 11 lines
u-boot-avr32/net/eth.c +1 -0
@@ -64,6 +64,7 @@
  extern int mcffec_initialize(bd_t*);
  extern int mcdmafec_initialize(bd_t*);
  extern int at91cap9_eth_initialize(bd_t *);
+extern int board_eth_initialize(bd_t *);
 
  #ifdef CONFIG_API
  extern void (*push_packet)(volatile void *, int);

u-boot-avr32/net/eth.c line 293

Quoted 5 lines
u-boot-avr32/net/eth.c +2 -0
@@ -288,6 +289,8 @@
  	at91cap9_eth_initialize(bis);
  #endif
 
+	board_eth_initialize(bis);
+

Hm... did you really check if other boards still build? Did you run the MAKEALL script?

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
Quote from a recent meeting:   "We are going to continue having these
meetings everyday until I find out why no work is getting done."
author
#2 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

Hi

Sorry, as you might have guessed I did not run MAKEALL to check my patch :-( Worse, It would have broken existing code... Sorry again.

I try to avoid such things in future.

I corrected the patch. I tried to run MAKEALL, but it fails, as I don't have all those cross-compilers installed. Am I missing something? Do I need to install them, or what is the correct procedure?

So instead of MAKEALL I compiled a few targets by hand.

Alex

u-boot-avr32/board/miromico/hammerhead/eth.c +37 -0
diff -Naur old/u-boot-avr32/board/miromico/hammerhead/eth.c new/u-boot-avr32/board/miromico/hammerhead/eth.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Miromico AG
+ *
+ * Ethernet initialization for the Miromico Hammerhead AVR32 board
+ *
+ * Mostly copied form Atmel ATNGW100 sources
+ *
+ * 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 <common.h>
+
+#include <asm/arch/memory-map.h>
+
+extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
+
+#ifdef CONFIG_CMD_NET
+void board_eth_initialize(bd_t *bi)
+{
+	macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
+}
+#endif
u-boot-avr32/board/miromico/hammerhead/hammerhead.c +79 -0

79 lines not on this page · raw message

u-boot-avr32/board/miromico/hammerhead/Makefile +40 -0
diff -Naur old/u-boot-avr32/board/miromico/hammerhead/Makefile new/u-boot-avr32/board/miromico/hammerhead/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2008 Miromico AG
+#
+# 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).a
+
+COBJS	:= $(BOARD).o eth.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+$(LIB): $(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
u-boot-avr32/board/miromico/hammerhead/u-boot.lds +80 -0

80 lines not on this page · raw message

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +11 -0
diff -Naur old/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c new/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c
@@ -142,3 +142,14 @@
  	gpio_select_periph_A(GPIO_PIN_PA15, 0);	/* DATA3 */
  }
  #endif
+
+#ifdef CONFIG_HAMMERHEAD
+/*
+ * Hammerhead board uses GCLK3 (Periph A on PB29) as 25MHz clock output
+ * for ethernet PHY.
+ */
+void gpio_enable_gclk3(void)
+{
+  gpio_select_periph_A(GPIO_PIN_PB29, 0); /* GCLK3         */
+}
+#endif
u-boot-avr32/cpu/at32ap/cpu.c +14 -0
diff -Naur old/u-boot-avr32/cpu/at32ap/cpu.c new/u-boot-avr32/cpu/at32ap/cpu.c
@@ -81,6 +81,16 @@
  #endif
  }
 
+#ifdef CONFIG_HAMMERHEAD
+static void gclk_init(void)
+{
+  /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */
+
+  /* Enable GCLK3 with no input divider, from OSC0 (crystal) */
+  sm_writel( PM_GCCTRL3, SM_BIT(CEN) );
+}
+#endif
+
  int cpu_init(void)
  {
  	extern void _evba(void);
@@ -105,6 +115,10 @@
  	     p += CFG_ICACHE_LINESZ)
  		asm volatile("cache %0, 0x02" : "=m"(*p) :: "memory");
 
+#ifdef CONFIG_HAMMERHEAD
+	gclk_init();
+#endif
+
  	return 0;
  }
 
u-boot-avr32/cpu/at32ap/sm.h +10 -1
diff -Naur old/u-boot-avr32/cpu/at32ap/sm.h new/u-boot-avr32/cpu/at32ap/sm.h
@@ -21,7 +21,16 @@
  #define SM_PM_IMR				0x0048
  #define SM_PM_ISR				0x004c
  #define SM_PM_ICR				0x0050
-#define SM_PM_GCCTRL				0x0060
+
+#define SM_PM_GCCTRL0				0x0060
+#define SM_PM_GCCTRL1				0x0064
+#define SM_PM_GCCTRL2				0x0068
+#define SM_PM_GCCTRL3				0x006c
+#define SM_PM_GCCTRL4				0x0070
+#define SM_PM_GCCTRL5				0x0074
+#define SM_PM_GCCTRL6				0x0078
+#define SM_PM_GCCTRL7				0x007c
+
  #define SM_RTC_CTRL				0x0080
  #define SM_RTC_VAL				0x0084
  #define SM_RTC_TOP				0x0088
u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h +4 -0
diff -Naur old/u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h new/u-boot-avr32/include/asm-avr32/arch-at32ap700x/gpio.h
@@ -217,4 +217,8 @@
  void gpio_enable_mmci(void);
  #endif
 
+#ifdef CONFIG_HAMMERHEAD
+void gpio_enable_gclk3(void);
+#endif
+
  #endif /* __ASM_AVR32_ARCH_GPIO_H__ */
u-boot-avr32/include/configs/hammerhead.h +177 -0

177 lines not on this page · raw message

u-boot-avr32/MAKEALL +1 -0
diff -Naur old/u-boot-avr32/MAKEALL new/u-boot-avr32/MAKEALL
@@ -676,6 +676,7 @@
  	atstk1003	\
  	atstk1004	\
  	atngw100	\
+	hammerhead      \
  "
 
  #########################################################################
u-boot-avr32/Makefile +3 -0
diff -Naur old/u-boot-avr32/Makefile new/u-boot-avr32/Makefile
@@ -2813,6 +2813,9 @@
  atngw100_config	:	unconfig
  	@$(MKCONFIG) $(@:_config=) avr32 at32ap atngw100 atmel at32ap700x
 
+hammerhead_config       :       unconfig
+	@$(MKCONFIG) $(@:_config=) avr32 at32ap hammerhead miromico at32ap700x
+
  #########################################################################
  #########################################################################
  #########################################################################
u-boot-avr32/net/eth.c +4 -0
diff -Naur old/u-boot-avr32/net/eth.c new/u-boot-avr32/net/eth.c
@@ -64,6 +64,7 @@
  extern int mcffec_initialize(bd_t*);
  extern int mcdmafec_initialize(bd_t*);
  extern int at91cap9_eth_initialize(bd_t *);
+extern int board_eth_initialize(bd_t *);
 
  #ifdef CONFIG_API
  extern void (*push_packet)(volatile void *, int);
@@ -287,6 +288,9 @@
  #if defined(CONFIG_AT91CAP9)
  	at91cap9_eth_initialize(bis);
  #endif
+#if defined(CONFIG_HAMMERHEAD)
+	board_eth_initialize(bis);
+#endif
 
  	if (!eth_devices) {
  		puts ("No ethernet found.\n");
#3 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

Quoted 41 lines · Alex

Hi

Sorry, as you might have guessed I did not run MAKEALL to check my patch :-( Worse, It would have broken existing code... Sorry again.

I try to avoid such things in future.

I corrected the patch. I tried to run MAKEALL, but it fails, as I don't have all those cross-compilers installed. Am I missing something? Do I need to install them, or what is the correct procedure?

So instead of MAKEALL I compiled a few targets by hand.

Alex

diff -Naur old/u-boot-avr32/board/miromico/hammerhead/eth.c new/u-boot-avr32/board/miromico/hammerhead/eth.c

u-boot-avr32/board/miromico/hammerhead/eth.c +22 -0
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Miromico AG
+ *
+ * Ethernet initialization for the Miromico Hammerhead AVR32 board
+ *
+ * Mostly copied form Atmel ATNGW100 sources
+ *
+ * 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

u-boot-avr32/board/miromico/hammerhead/eth.c line 32

Quoted 10 lines
u-boot-avr32/board/miromico/hammerhead/eth.c +10 -0
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+
+#include <asm/arch/memory-map.h>
+
+extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
+
+#ifdef CONFIG_CMD_NET

Please move this to the Makefile

Quoted 13 lines
u-boot-avr32/board/miromico/hammerhead/eth.c +5 -0
+void board_eth_initialize(bd_t *bi)
+{
+	macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
+}
+#endif

diff -Naur old/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c new/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +1 -0
@@ -142,3 +142,14 @@
  	gpio_select_periph_A(GPIO_PIN_PA15, 0);	/* DATA3 */
  }
  #endif
+

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c line 155

Quoted 10 lines
u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +10 -0
+#ifdef CONFIG_HAMMERHEAD
+/*
+ * Hammerhead board uses GCLK3 (Periph A on PB29) as 25MHz clock output
+ * for ethernet PHY.
+ */
+void gpio_enable_gclk3(void)
+{
+  gpio_select_periph_A(GPIO_PIN_PB29, 0); /* GCLK3         */
+}
+#endif

I'll prefer a weak function

u-boot-avr32/cpu/at32ap/cpu.c line 85

Quoted 9 lines

diff -Naur old/u-boot-avr32/cpu/at32ap/cpu.c new/u-boot-avr32/cpu/at32ap/cpu.c

u-boot-avr32/cpu/at32ap/cpu.c +2 -0
@@ -81,6 +81,16 @@
  #endif
  }
 
+#ifdef CONFIG_HAMMERHEAD
+static void gclk_init(void)

same I'll prefer a weak function

u-boot-avr32/cpu/at32ap/cpu.c line 93

Quoted 8 lines
u-boot-avr32/cpu/at32ap/cpu.c +8 -0
+{
+  /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */
+
+  /* Enable GCLK3 with no input divider, from OSC0 (crystal) */
+  sm_writel( PM_GCCTRL3, SM_BIT(CEN) );
+}
+#endif
+

Best Regards,
J.

#4 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

In reply to Alex

Hi Alex,

Please see below for some (delayed) review comments.

Quoted 2 lines · On Mon, 17 Mar 2008 11:31:42 +0100 Alex <[email protected]> wrote:

I corrected the patch. I tried to run MAKEALL, but it fails, as I don't have all those cross-compilers installed. Am I missing something? Do I need to install them, or what is the correct procedure?

You can run MAKEALL for one particular architecture by doing

CROSS_COMPILE=<target>- ./MAKEALL <arch>

where <arch> can be a major architecture (e.g. ppc, arm, etc.) or a subarchitecture/platform (e.g. 4xx, ARM9, etc.)

u-boot-avr32/board/miromico/hammerhead/eth.c

Quoted 5 lines

diff -Naur old/u-boot-avr32/board/miromico/hammerhead/eth.c new/u-boot-avr32/board/miromico/hammerhead/eth.c

u-boot-avr32/board/miromico/hammerhead/eth.c +1 -0
 
+extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);

Hrm...we should really move this to a separate header, but let's wait until the current discussions reach some sort of conclusion.

u-boot-avr32/board/miromico/hammerhead/hammerhead.c line 66

Quoted 12 lines
u-boot-avr32/board/miromico/hammerhead/eth.c +6 -0
+#ifdef CONFIG_CMD_NET
+void board_eth_initialize(bd_t *bi)
+{
+	macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
+}
+#endif

diff -Naur old/u-boot-avr32/board/miromico/hammerhead/hammerhead.c new/u-boot-avr32/board/miromico/hammerhead/hammerhead.c

u-boot-avr32/board/miromico/hammerhead/hammerhead.c +2 -0
 
+	/* Select GCLK3 peripheral function. We'll need it as clock output
+     * for ethernet PHY. */

There's a bit of whitespace damage here and there, as others have pointed out.

u-boot-avr32/board/miromico/hammerhead/hammerhead.c line 79

Quoted 4 lines
u-boot-avr32/board/miromico/hammerhead/hammerhead.c +4 -0
+void board_init_info(void)
+{
+	gd->bd->bi_phy_id[0] = 0x01;
+}

We should probably get rid of this function. Don't worry about it for now though.

u-boot-avr32/board/miromico/hammerhead/u-boot.lds line 42

Quoted 11 lines

diff -Naur old/u-boot-avr32/board/miromico/hammerhead/u-boot.lds new/u-boot-avr32/board/miromico/hammerhead/u-boot.lds

u-boot-avr32/board/miromico/hammerhead/u-boot.lds +7 -0
 
+	. = ALIGN(32);
+	__flashprog_start = .;
+	.flashprog : {
+		*(.flashprog)
+	}
+	. = ALIGN(32);
+	__flashprog_end = .;

I don't think this block is needed since you're using the CFI flash driver. It should probably be culled from the ATNGW100 linker script too.

Quoted 8 lines

diff -Naur old/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c new/u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +1 -0
@@ -142,3 +142,14 @@
  	gpio_select_periph_A(GPIO_PIN_PA15, 0);	/* DATA3 */
  }
  #endif
+

u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c line 155

Quoted 10 lines
u-boot-avr32/cpu/at32ap/at32ap700x/gpio.c +10 -0
+#ifdef CONFIG_HAMMERHEAD
+/*
+ * Hammerhead board uses GCLK3 (Periph A on PB29) as 25MHz clock output
+ * for ethernet PHY.
+ */
+void gpio_enable_gclk3(void)
+{
+  gpio_select_periph_A(GPIO_PIN_PB29, 0); /* GCLK3         */
+}
+#endif

Please drop the #ifdef. --gc-sections will take care of it.

Quoted 6 lines

diff -Naur old/u-boot-avr32/cpu/at32ap/cpu.c new/u-boot-avr32/cpu/at32ap/cpu.c

u-boot-avr32/cpu/at32ap/cpu.c +0 -0
@@ -81,6 +81,16 @@
  #endif
  }

u-boot-avr32/cpu/at32ap/cpu.c line 92

Quoted 10 lines
u-boot-avr32/cpu/at32ap/cpu.c +9 -0
 
+#ifdef CONFIG_HAMMERHEAD
+static void gclk_init(void)
+{
+  /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */
+
+  /* Enable GCLK3 with no input divider, from OSC0 (crystal) */
+  sm_writel( PM_GCCTRL3, SM_BIT(CEN) );
+}
+#endif

Hmm...could you turn it into something more generic, like

void gclk_enable(unsigned int id)

and call it from the board code? Then you could get rid of the #ifdefs and let --gc-sections remove it if it turns out to be unused.

u-boot-avr32/cpu/at32ap/cpu.c line 116

Quoted 3 lines
u-boot-avr32/cpu/at32ap/cpu.c +0 -0
@@ -105,6 +115,10 @@
  	     p += CFG_ICACHE_LINESZ)
  		asm volatile("cache %0, 0x02" : "=m"(*p) :: "memory");

Hmm...another piece of code we can get rid of. This is unrelated to your patch though.

u-boot-avr32/cpu/at32ap/cpu.c line 120

Quoted 3 lines
u-boot-avr32/cpu/at32ap/cpu.c +3 -0
+#ifdef CONFIG_HAMMERHEAD
+	gclk_init();
+#endif

Please remove this if you follow my suggestion above.

Quoted 7 lines

diff -Naur old/u-boot-avr32/cpu/at32ap/sm.h new/u-boot-avr32/cpu/at32ap/sm.h

u-boot-avr32/cpu/at32ap/sm.h +0 -0
@@ -21,7 +21,16 @@
  #define SM_PM_IMR				0x0048
  #define SM_PM_ISR				0x004c
  #define SM_PM_ICR				0x0050

u-boot-avr32/cpu/at32ap/sm.h line 32

Quoted 10 lines
u-boot-avr32/cpu/at32ap/sm.h +9 -1
-#define SM_PM_GCCTRL				0x0060
+
+#define SM_PM_GCCTRL0				0x0060
+#define SM_PM_GCCTRL1				0x0064
+#define SM_PM_GCCTRL2				0x0068
+#define SM_PM_GCCTRL3				0x006c
+#define SM_PM_GCCTRL4				0x0070
+#define SM_PM_GCCTRL5				0x0074
+#define SM_PM_GCCTRL6				0x0078
+#define SM_PM_GCCTRL7				0x007c

Why not

#define SM_PM_GCCTRL(x) (0x0060 + 4 * (x))

perhaps as a separate patch?

Quoted 12 lines

diff -Naur old/u-boot-avr32/net/eth.c new/u-boot-avr32/net/eth.c

u-boot-avr32/net/eth.c +1 -0
@@ -64,6 +64,7 @@
  extern int mcffec_initialize(bd_t*);
  extern int mcdmafec_initialize(bd_t*);
  extern int at91cap9_eth_initialize(bd_t *);
+extern int board_eth_initialize(bd_t *);
 
  #ifdef CONFIG_API
  extern void (*push_packet)(volatile void *, int);

u-boot-avr32/net/eth.c line 293

Quoted 6 lines
u-boot-avr32/net/eth.c +3 -0
@@ -287,6 +288,9 @@
  #if defined(CONFIG_AT91CAP9)
  	at91cap9_eth_initialize(bis);
  #endif
+#if defined(CONFIG_HAMMERHEAD)
+	board_eth_initialize(bis);
+#endif

We probably want something more generic-sounding like CONFIG_HAS_BOARD_ETH_INITIALIZE so that boards can migrate over to the new API one by one. But I'll leave it to Ben to decide how to do this.

Haavard

#5 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

In reply to Alex

Hi Alex,

Quoted 47 lines · Alex

Hi

Sorry, as you might have guessed I did not run MAKEALL to check my patch :-( Worse, It would have broken existing code... Sorry again.

I try to avoid such things in future.

I corrected the patch. I tried to run MAKEALL, but it fails, as I don't have all those cross-compilers installed. Am I missing something? Do I need to install them, or what is the correct procedure?

So instead of MAKEALL I compiled a few targets by hand.

Alex

diff -Naur old/u-boot-avr32/board/miromico/hammerhead/eth.c new/u-boot-avr32/board/miromico/hammerhead/eth.c

u-boot-avr32/board/miromico/hammerhead/eth.c +27 -0
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Miromico AG
+ *
+ * Ethernet initialization for the Miromico Hammerhead AVR32 board
+ *
+ * Mostly copied form Atmel ATNGW100 sources
+ *
+ * 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 <common.h>
+

u-boot-avr32/board/miromico/hammerhead/eth.c line 37

Quoted 10 lines
u-boot-avr32/board/miromico/hammerhead/eth.c +10 -0
+#include <asm/arch/memory-map.h>
+
+extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
+
+#ifdef CONFIG_CMD_NET
+void board_eth_initialize(bd_t *bi)
+{
+	macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
+}
+#endif

I don't know the overall status of this patch set, but if you change the name of this function to board_eth_init(bd_t *bi), you won't need to touch /net/eth.c. Sorry for the churn...
<snip>

Quoted 14 lines

diff -Naur old/u-boot-avr32/net/eth.c new/u-boot-avr32/net/eth.c

u-boot-avr32/net/eth.c +1 -0
@@ -64,6 +64,7 @@
  extern int mcffec_initialize(bd_t*);
  extern int mcdmafec_initialize(bd_t*);
  extern int at91cap9_eth_initialize(bd_t *);
+extern int board_eth_initialize(bd_t *);
 
  #ifdef CONFIG_API
  extern void (*push_packet)(volatile void *, int);

u-boot-avr32/net/eth.c line 296

Quoted 9 lines
u-boot-avr32/net/eth.c +3 -0
@@ -287,6 +288,9 @@
  #if defined(CONFIG_AT91CAP9)
  	at91cap9_eth_initialize(bis);
  #endif
+#if defined(CONFIG_HAMMERHEAD)
+	board_eth_initialize(bis);
+#endif
 
  	if (!eth_devices) {
  		puts ("No ethernet found.\n");

I have a patch that will be submitted tomorrow that puts a call to board_eth_init() here, so you don't need to. If this is already in the AVR32 repo no big deal.

regards,
Ben

#6 lore raw

PATCH 1/1 Add support for hammerhead AVR32 board

Quoted 3 lines · On Sun, 30 Mar 2008 19:41:52 -0400 Ben Warren <[email protected]> wrote:

I have a patch that will be submitted tomorrow that puts a call to board_eth_init() here, so you don't need to. If this is already in the AVR32 repo no big deal.

FWIW, it's not in the AVR32 repo yet. I think the patch needs another spin to address the comments that came up.

That said, I'm totally out of sync with most mailing lists right now, so if a newer version was posted without me in the Cc list, I haven't noticed it yet.

Haavard