Skip to contentSkip to conversation

Support for Embedtronics/MRFSA board.

PATCH New Sami Kantoluoto 3 participants 6 messages Aug 29, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

Adds support for Embedtronics Oy's MRFSA board. Board features AT91SAM9G20 controller, 64 MB of SDRAM, two 64 Mbit data flashses (AT45DB321), SD card slot, GSM modem, GPS receiver, ZigBee (CC2420), USB host ports, USB device port, two RS232 and one RS422/RS485 port, two opto isolated inputs, two relays and bunch of leds.

This patch supports booting (e.g. Linux kernel) from following media/interface:

- dataflash
- ethernet
- debug serial port
- SD/MMC

---
 Makefile                             |   13 +
 board/embedtronics/mrfsa/Makefile    |   60 +++++
 board/embedtronics/mrfsa/config.mk   |    1 +
 board/embedtronics/mrfsa/iopins.h    |   36 +++
 board/embedtronics/mrfsa/ks8995ma.h  |  255 ++++++++++++++++++
 board/embedtronics/mrfsa/mrfsa.c     |  481 ++++++++++++++++++++++++++++++++++
 board/embedtronics/mrfsa/partition.c |   44 +++
 board/embedtronics/mrfsa/watchdog.c  |   62 +++++
 common/console.c                     |    6 +
 cpu/arm926ejs/at91/timer.c           |    7 +-
 drivers/net/macb.c                   |    4 +
 include/asm-arm/mach-types.h         |   13 +
 include/configs/mrfsa.h              |  197 ++++++++++++++
 lib_arm/bootm.c                      |   13 +
 14 files changed, 1191 insertions(+), 1 deletions(-)
 create mode 100644 board/embedtronics/mrfsa/Makefile
 create mode 100644 board/embedtronics/mrfsa/config.mk
 create mode 100644 board/embedtronics/mrfsa/iopins.h
 create mode 100644 board/embedtronics/mrfsa/ks8995ma.h
 create mode 100644 board/embedtronics/mrfsa/mrfsa.c
 create mode 100644 board/embedtronics/mrfsa/partition.c
 create mode 100644 board/embedtronics/mrfsa/watchdog.c
 create mode 100644 include/configs/mrfsa.h
Makefile +13 -0
index 02393b6..b66421c 100644
@@ -2751,6 +2751,19 @@ at91sam9g20ek_config	:	unconfig
 	fi;
 	@$(MKCONFIG) -a at91sam9260ek arm arm926ejs at91sam9260ek atmel at91
 
+mrfsa_dataflash_cs0_config \
+mrfsa_dataflash_cs1_config \
+mrfsa_config		:	unconfig
+	@mkdir -p $(obj)include
+	@if [ "$(findstring dataflash_cs1,$@)" ] ; then \
+		echo "#define CONFIG_SYS_USE_DATAFLASH_CS1 1"   >>$(obj)include/config.h ; \
+		$(XECHO) "... with environment variable in SPI DATAFLASH CS0" ; \
+	else \
+		echo "#define CONFIG_SYS_USE_DATAFLASH_CS0 1"	>>$(obj)include/config.h ; \
+		$(XECHO) "... with environment variable in SPI DATAFLASH CS0" ; \
+	fi;
+	@$(MKCONFIG) -a mrfsa arm arm926ejs mrfsa embedtronics at91
+
 at91sam9xeek_nandflash_config \
 at91sam9xeek_dataflash_cs0_config \
 at91sam9xeek_dataflash_cs1_config \
board/embedtronics/mrfsa/Makefile new file +60 -0

60 lines not on this page · raw message

board/embedtronics/mrfsa/config.mk new file +1 -0
new file mode 100644
index 0000000..ff2cfd1
@@ -0,0 +1 @@
+TEXT_BASE = 0x23f00000
board/embedtronics/mrfsa/iopins.h new file +36 -0
new file mode 100644
index 0000000..e7824dd
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * 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
+ */
+
+#ifndef	_mrfsa_iopins_h
+#define	_mrfsa_iopins_h
+
+/* some output pins: */
+#define	PIN_SPI0_CSZB	AT91_PIN_PB31	/* ZigBee slave select */
+#define	PIN_SPI0_CSETH	AT91_PIN_PB30	/* ethernet switch slave select */
+#define	PIN_SPI0_CSSR	AT91_PIN_PB17	/* shift register slave select */
+#define	PIN_RESET_OUT	AT91_PIN_PC14	/* resets switch, active low */
+#define	PIN_NICEDOG	AT91_PIN_PC4	/* wathcdog pin, must be pulsed
+					 * periodically */
+
+#endif /* !_mrfsa_iopins_h */
board/embedtronics/mrfsa/ks8995ma.h new file +255 -0

255 lines not on this page · raw message

board/embedtronics/mrfsa/mrfsa.c new file +481 -0

481 lines not on this page · raw message

board/embedtronics/mrfsa/partition.c new file +44 -0

44 lines not on this page · raw message

board/embedtronics/mrfsa/watchdog.c new file +62 -0

62 lines not on this page · raw message

common/console.c +6 -0
index 867c12c..fb6e409 100644
@@ -311,6 +311,12 @@ int getc(void)
 
 int tstc(void)
 {
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
cpu/arm926ejs/at91/timer.c +6 -1
index 811bb3c..03fce54 100644
@@ -83,7 +83,12 @@ int timer_init(void)
 unsigned long long get_ticks(void)
 {
 	ulong now = READ_TIMER;
-
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif
 	if (now >= lastinc)	/* normal mode (non roll) */
 		/* move stamp forward with absolut diff ticks */
 		timestamp += (now - lastinc);
drivers/net/macb.c +4 -0
index c184353..9e2e771 100644
@@ -291,6 +291,7 @@ static int macb_recv(struct eth_device *netdev)
 	return 0;
 }
 
+#ifndef	CONFIG_NO_PHY
 static void macb_phy_reset(struct macb_device *macb)
 {
 	struct eth_device *netdev = &macb->netdev;
@@ -403,6 +404,7 @@ static int macb_phy_init(struct macb_device *macb)
 		return 1;
 	}
 }
+#endif	/* CONFIG_NO_PHY */
 
 static int macb_init(struct eth_device *netdev, bd_t *bd)
 {
@@ -463,8 +465,10 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 #endif
 #endif /* CONFIG_RMII */
 
+#ifndef	CONFIG_NO_PHY
 	if (!macb_phy_init(macb))
 		return -1;
+#endif	/* CONFIG_NO_PHY */
 
 	/* Enable TX and RX */
 	macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE));
include/asm-arm/mach-types.h +13 -0
index 5293d67..316c05e 100644
@@ -2241,6 +2241,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_OMAP3_WL_FF          2258
 #define MACH_TYPE_SIMCOM               2259
 #define MACH_TYPE_MCWEBIO              2260
+#define	MACH_TYPE_MRFSA		       2295
 
 #ifdef CONFIG_ARCH_EBSA110
 # ifdef machine_arch_type
@@ -28990,6 +28991,18 @@ extern unsigned int __machine_arch_type;
 # define machine_is_mcwebio()	(0)
 #endif
 
+#ifdef	CONFIG_MACH_MRFSA
+# ifdef machine_arch_type
+#  undef machine_arch_type
+#  define machine_arch_type	__machine_arch_type
+# else
+#  define machine_arch_type	MACH_TYPE_MRFSA
+# endif
+# define machine_is_mrfsa()	(machine_arch_type == MACH_TYPE_MRFSA)
+#else
+# define machine_is_mrfsa()	(0)
+#endif
+
 /*
  * These have not yet been registered
  */
include/configs/mrfsa.h new file +197 -0

197 lines not on this page · raw message

lib_arm/bootm.c +13 -0
index 128b7e3..e882d9b 100644
@@ -27,6 +27,11 @@
 #include <u-boot/zlib.h>
 #include <asm/byteorder.h>
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#include <watchdog.h>
+#endif
+
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
@@ -123,8 +128,16 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	}
 #endif
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
+
 	cleanup_before_linux ();
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
+
 	theKernel (0, machid, bd->bi_boot_params);
 	/* does not return */
 
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

Hi Sami,

Please note that I'm not an u-boot custodian, so what follows is by no means authoritative.
However, I do have some comments about your code:

Quoted 82 lines · Sami Kantoluoto
board/embedtronics/mrfsa/mrfsa.c new file +76 -0
new file mode 100644
index 0000000..6420c4b
@@ -0,0 +1,481 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * 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/at91_common.h>
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91sam9260_matrix.h>
+#include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_wdt.h>
+#include <asm/arch/at91_rstc.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_spi.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+#if defined(CONFIG_RESET_PHY_R) || defined(CONFIG_MACB)
+#include <net.h>
+#include <netdev.h>
+#endif
+
+#include "ks8995ma.h"
+#include "iopins.h"
+
+#ifndef	CONFIG_NO_VLANS
+#define	CONFIG_NO_VLANS	1
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* ------------------------------------------------------------------------- */
+/*
+ * Miscelaneous platform dependent initialisations
+ */
+
+static void mrfsa_serial_hw_init (void)
+{
+#ifdef CONFIG_USART0
+	at91_set_A_periph (AT91_PIN_PB4, 1);	/* TXD0 */
+	at91_set_A_periph (AT91_PIN_PB5, 0);	/* RXD0 */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91_ID_US0);
+#endif
+
+#ifdef CONFIG_USART1
+	at91_set_A_periph (AT91_PIN_PB6, 1);	/* TXD1 */
+	at91_set_A_periph (AT91_PIN_PB7, 0);	/* RXD1 */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91_ID_US1);
+#endif
+
+#ifdef CONFIG_USART2
+	at91_set_A_periph (AT91_PIN_PB8, 1);	/* TXD2 */

board/embedtronics/mrfsa/mrfsa.c line 86

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+	at91_set_A_periph (AT91_PIN_PB9, 0);	/* RXD2 */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91_ID_US2);
+#endif
+
+#ifdef CONFIG_USART3		/* DBGU */
+	at91_set_A_periph (AT91_PIN_PB14, 0);	/* DRXD */
+	at91_set_A_periph (AT91_PIN_PB15, 1);	/* DTXD */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91_ID_SYS);
+#endif
+}

There's already an at91_serial_hw_init() function which exactly performs that, why don't you use it?

Quoted 8 lines
board/embedtronics/mrfsa/mrfsa.c new file +8 -0
+static void mrfsa_spi_hw_init (void)
+{
+	unsigned long mode;
+
+	/* Enable clock for SPI */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91SAM9260_ID_SPI0);
+
+	at91_set_A_periph (AT91_PIN_PA3, 1);	/* SPI0_NPCS0 */

board/embedtronics/mrfsa/mrfsa.c line 105

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+	at91_set_B_periph (AT91_PIN_PC11, 1);	/* SPI0_NPCS1 */
+	at91_set_gpio_output (PIN_SPI0_CSETH, 1);	/* CSETH */
+	at91_set_gpio_output (PIN_SPI0_CSSR, 1);	/* CSSR */
+	at91_set_gpio_output (PIN_SPI0_CSZB, 1);	/* CSZB */
+
+	at91_set_A_periph (AT91_PIN_PA0, 0);	/* SPI0_MISO */
+	at91_set_A_periph (AT91_PIN_PA1, 0);	/* SPI0_MOSI */
+	at91_set_A_periph (AT91_PIN_PA2, 0);	/* SPI0_SPCK */
+}
+

Same here. at91_spi0_hw_init() seems to do a large part of that, you should consider using it

Quoted 41 lines
board/embedtronics/mrfsa/mrfsa.c new file +41 -0
+static int spi_transfer (unsigned csr, unsigned cspin, const void *src,
+			 void *dst, int len)
+{
+	unsigned long mode;
+	unsigned int timeout;
+
+	/* make sure SPI is not clocking data */
+	writel (AT91_SPI_TXTDIS + AT91_SPI_RXTDIS,
+		AT91_BASE_SPI + AT91_SPI_PTCR);
+
+	/* select slave parameters */
+	mode = readl (AT91_BASE_SPI + AT91_SPI_MR);
+	mode &= 0xfff0ffff;
+	writel (mode | (((0xf & ~(1 << csr)) << 16) & AT91_SPI_PCS),
+		AT91_BASE_SPI + AT91_SPI_MR);
+
+	/* Initialize the Transmit and Receive Pointer */
+	writel ((unsigned int)dst, AT91_BASE_SPI + AT91_SPI_RPR);
+	writel ((unsigned int)src, AT91_BASE_SPI + AT91_SPI_TPR);
+
+	/* Initialize the Transmit and Receive Counters */
+	writel (len, AT91_BASE_SPI + AT91_SPI_RCR);
+	writel (len, AT91_BASE_SPI + AT91_SPI_TCR);
+
+	/* arm simple, non interrupt dependent timer */
+	reset_timer_masked ();
+	timeout = 0;
+
+	/* select slave */
+	at91_set_gpio_value (cspin, 0);
+
+	/* transmit data */
+	writel (AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR);
+	while (!(readl (AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) &&
+	       ((timeout = get_timer_masked ()) < CONFIG_SYS_SPI_WRITE_TOUT)) ;
+	writel (AT91_SPI_TXTDIS + AT91_SPI_RXTDIS,
+		AT91_BASE_SPI + AT91_SPI_PTCR);
+
+	/* deselect slave */
+	at91_set_gpio_value (cspin, 1);
+

board/embedtronics/mrfsa/mrfsa.c line 156

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+	/* return error on failure */
+	if (timeout >= CONFIG_SYS_SPI_WRITE_TOUT) {
+		printf ("Error Timeout\n\r");
+		return -1;
+	}
+
+	/* success! */
+	return 0;
+}
+

Why do you need this one ? drivers/spi/atmel_spi.c should provide you with the spi_xfer function, which likely does what you want. All you need is

#define CONFIG_ATMEL_SPI in your board config.h

board/embedtronics/mrfsa/mrfsa.c line 273

Quoted 6 lines
board/embedtronics/mrfsa/mrfsa.c new file +6 -0
+int dram_init (void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM;
+	gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
+	return 0;
+}

You should use get_ram_size() here, as it will help detecting is your RAM is somehow damaged.

Quoted 26 lines
board/embedtronics/mrfsa/mrfsa.c new file +1 -0
+#endif /* CONFIG_HW_WATCHDOG */
common/console.c +6 -0
index 867c12c..fb6e409 100644
@@ -311,6 +311,12 @@ int getc(void)
 
 int tstc(void)
 {
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
cpu/arm926ejs/at91/timer.c +0 -0
index 811bb3c..03fce54 100644
@@ -83,7 +83,12 @@ int timer_init(void)
 unsigned long long get_ticks(void)
 {
 	ulong now = READ_TIMER;

cpu/arm926ejs/at91/timer.c int timer_init(void) · line 94

Quoted 10 lines
cpu/arm926ejs/at91/timer.c +6 -1
-
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif
 	if (now >= lastinc)	/* normal mode (non roll) */
 		/* move stamp forward with absolut diff ticks */
 		timestamp += (now - lastinc);

You should provide a rationale for making such a change. So far this seems to have worked for everyone, so your change is unlikely to be accepted unless you justify why this is needed.

Quoted 21 lines
drivers/net/macb.c +2 -0
index c184353..9e2e771 100644
@@ -291,6 +291,7 @@ static int macb_recv(struct eth_device *netdev)
 	return 0;
 }
 
+#ifndef	CONFIG_NO_PHY
 static void macb_phy_reset(struct macb_device *macb)
 {
 	struct eth_device *netdev = &macb->netdev;
@@ -403,6 +404,7 @@ static int macb_phy_init(struct macb_device *macb)
 		return 1;
 	}
 }
+#endif	/* CONFIG_NO_PHY */
 
 static int macb_init(struct eth_device *netdev, bd_t *bd)
 {

drivers/net/macb.c static int macb_init(struct eth_device *netdev, bd_t *bd) · line 474

Quoted 10 lines
drivers/net/macb.c +2 -0
@@ -463,8 +465,10 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 #endif
 #endif /* CONFIG_RMII */
 
+#ifndef	CONFIG_NO_PHY
 	if (!macb_phy_init(macb))
 		return -1;
+#endif	/* CONFIG_NO_PHY */
 
 	/* Enable TX and RX */
 	macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE));

Same here. You should explain what problems you're trying to fix.

Quoted 28 lines
include/configs/mrfsa.h new file +22 -0
new file mode 100644
index 0000000..83ad18b
@@ -0,0 +1,197 @@
+/*
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * Configuation settings for the MRFSA board.
+ *
+ * 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

include/configs/mrfsa.h line 32

Quoted 10 lines
include/configs/mrfsa.h new file +10 -0
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/* ARM asynchronous clock */
+#define AT91_MAIN_CLOCK		20000000	/* 20.000 MHz crystal */
+#define AT91C_MASTER_CLOCK	133333333	/* peripheral clock */

AT91C_MASTER_CLOCK is not needed

include/configs/mrfsa.h line 37

Quoted 5 lines
include/configs/mrfsa.h new file +5 -0
+#define CONFIG_SYS_HZ		1000
+
+#define CONFIG_ARM926EJS	1	/* This is an ARM926EJS Core    */
+
+#define AT91_CPU_NAME		"AT91SAM9G20"

Neither is AT91_CPU_NAME

Quoted 69 lines
include/configs/mrfsa.h new file +69 -0
+#define CONFIG_AT91SAM9G20	1	/* It's an Atmel AT91SAM9G20 SoC */
+
+#define CONFIG_ARCH_CPU_INIT
+#undef CONFIG_USE_IRQ		/* we don't need IRQ/FIQ stuff  */
+
+#define CONFIG_CMDLINE_TAG	1	/* enable passing of ATAGs      */
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_INITRD_TAG	1
+
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SKIP_RELOCATE_UBOOT
+
+/*
+ * Hardware drivers
+ */
+#define CONFIG_ATMEL_USART	1
+#undef CONFIG_USART0
+#undef CONFIG_USART1
+#undef CONFIG_USART2
+#define CONFIG_USART3		1	/* USART 3 is DBGU */
+
+/* LED */
+#undef	CONFIG_AT91_LED
+
+#define CONFIG_BOOTDELAY	3
+
+/*
+ * BOOTP options
+ */
+#define CONFIG_BOOTP_BOOTFILESIZE	1
+#define CONFIG_BOOTP_BOOTPATH		1
+#define CONFIG_BOOTP_GATEWAY		1
+#define CONFIG_BOOTP_HOSTNAME		1
+
+/*
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+#undef CONFIG_CMD_BDI
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#undef CONFIG_CMD_LOADS
+#undef CONFIG_CMD_SOURCE
+
+#define	CONFIG_CMD_MMC		1
+#define CONFIG_CMD_PING		1
+#define CONFIG_CMD_DHCP		1
+#define CONFIG_CMD_USB		1
+#define	CONFIG_CMD_FAT		1
+#define	CONFIG_CMD_EXT2			1
+
+#define	CONFIG_MMC		1
+#define	CONFIG_ATMEL_MCI	1
+
+#define	CONFIG_DOS_PARTITION		1	/* support DOS partition table */
+
+/* SDRAM */
+#define CONFIG_NR_DRAM_BANKS		1
+#define PHYS_SDRAM			0x20000000
+#define PHYS_SDRAM_SIZE			0x04000000	/* 64 megs */
+
+/* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
+#define CONFIG_HAS_DATAFLASH		1
+#define CONFIG_SYS_SPI_WRITE_TOUT		(5*CONFIG_SYS_HZ)
+#define CONFIG_SYS_MAX_DATAFLASH_BANKS		2
+#define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0	0xC0000000	/* CS0 */
+#define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1	0xD0000000	/* CS1 */

include/configs/mrfsa.h line 116

Quoted 10 lines
include/configs/mrfsa.h new file +10 -0
+#define AT91_SPI_CLK			15000000
+
+#define DATAFLASH_TCSS			(0x22 << 16)
+#define DATAFLASH_TCHS			(0x1 << 24)
+
+/* NAND flash - no nand flash on this board */
+#ifdef CONFIG_CMD_NAND
+#error No NAND FLASH
+#endif
+#define	CONFIG_SYS_NO_NAND			1

There's no such thing as CONFIG_SYS_NO_NAND

Quoted 68 lines
include/configs/mrfsa.h new file +68 -0
+/* NOR flash - no real flash on this board */
+#define CONFIG_SYS_NO_FLASH			1
+
+/* Ethernet */
+#define CONFIG_MACB			1
+#define	CONFIG_NO_PHY			1
+#undef	CONFIG_RMII
+#define	CONFIG_NET_MULTI		1
+#define CONFIG_NET_RETRY_COUNT		20
+#define CONFIG_RESET_PHY_R		1
+
+/* USB */
+#define CONFIG_USB_ATMEL
+#define CONFIG_USB_OHCI_NEW		1
+#define CONFIG_DOS_PARTITION		1
+#define CONFIG_SYS_USB_OHCI_CPU_INIT		1
+#define CONFIG_SYS_USB_OHCI_REGS_BASE		0x00500000	/* AT91SAM9260_UHP_BASE */
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME		"at91sam9g20"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
+#define CONFIG_USB_STORAGE		1
+
+#define CONFIG_SYS_LOAD_ADDR			0x22000000	/* load address */
+
+#define CONFIG_SYS_MEMTEST_START		PHYS_SDRAM
+#define CONFIG_SYS_MEMTEST_END			0x23e00000
+
+#ifdef CONFIG_SYS_USE_DATAFLASH_CS0
+
+/* bootstrap + u-boot + env + linux in dataflash on CS0 */
+#define CONFIG_ENV_IS_IN_DATAFLASH	1
+#define CONFIG_SYS_MONITOR_BASE	(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + 0x8400)
+#define CONFIG_ENV_OFFSET		0x4200
+#define CONFIG_ENV_ADDR		(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET)
+#define CONFIG_ENV_SIZE		0x4200
+#define CONFIG_BOOTCOMMAND	"cp.b 0xC0042000 0x22000000 0x210000; bootm"
+#define CONFIG_BOOTARGS		"console=ttyS0,115200 "			\
+				"root=/dev/mmcblk0p1 rootwait rw"
+
+#elif CONFIG_SYS_USE_DATAFLASH_CS1
+
+/* bootstrap + u-boot + env + linux in dataflash on CS1 */
+#define CONFIG_ENV_IS_IN_DATAFLASH	1
+#define CONFIG_SYS_MONITOR_BASE	(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1 + 0x8400)
+#define CONFIG_ENV_OFFSET		0x4200
+#define CONFIG_ENV_ADDR		(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1 + CONFIG_ENV_OFFSET)
+#define CONFIG_ENV_SIZE		0x4200
+#define CONFIG_BOOTCOMMAND	"cp.b 0xD0042000 0x22000000 0x210000; bootm"
+#define CONFIG_BOOTARGS		"console=ttyS0,115200 "			\
+				"root=/dev/mmcblk0p1 rootwait rw"
+
+#endif
+
+#define CONFIG_BAUDRATE		115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{115200 , 19200, 38400, 57600, 9600 }
+
+#define CONFIG_SYS_PROMPT		"U-Boot> "
+#define CONFIG_SYS_CBSIZE		256
+#define CONFIG_SYS_MAXARGS		16
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_LONGHELP		1
+#define CONFIG_CMDLINE_EDITING	1
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_SYS_MALLOC_LEN		ROUND(3 * CONFIG_ENV_SIZE + 128*1024, 0x1000)
+#define CONFIG_SYS_GBL_DATA_SIZE	128	/* 128 bytes for initial data */
+

include/configs/mrfsa.h line 195

Quoted 10 lines
include/configs/mrfsa.h new file +10 -0
+#define CONFIG_STACKSIZE	(32*1024)	/* regular stack */
+
+#ifdef CONFIG_USE_IRQ
+#error CONFIG_USE_IRQ not supported
+#endif
+
+#define	CONFIG_HW_WATCHDOG		1	/* we've hardware watchdog */
+
+#define	BOARD_LATE_INIT			1
+#define	MMCI_BASE			AT91SAM9260_BASE_MCI

As per my previous email, this really should be done at some common level. Defining this - especially on boards which have only 1 controller - in every config file is nothing but duplication

Quoted 23 lines
include/configs/mrfsa.h new file +1 -0
+#endif
lib_arm/bootm.c +7 -0
index 128b7e3..e882d9b 100644
@@ -27,6 +27,11 @@
 #include <u-boot/zlib.h>
 #include <asm/byteorder.h>
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#include <watchdog.h>
+#endif
+
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
@@ -123,8 +128,16 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	}
 #endif
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();

lib_arm/bootm.c int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) · line 142

Quoted 10 lines
lib_arm/bootm.c +6 -0
+#endif
+
 	cleanup_before_linux ();
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
+
 	theKernel (0, machid, bd->bi_boot_params);
 	/* does not return */

You might want to provide a rationale for this change, too.

Regards,

Signature · 4 lines
Albin Tonnerre, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

Quoted 5 lines · Albin Tonnerre

Hi Sami,

Please note that I'm not an u-boot custodian, so what follows is by no means authoritative.
However, I do have some comments about your code:

agreed with all comments

Best Regards,
J.

#3 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

In reply to Sami Kantoluoto
Quoted 31 lines · Sami Kantoluoto

Adds support for Embedtronics Oy's MRFSA board. Board features AT91SAM9G20 controller, 64 MB of SDRAM, two 64 Mbit data flashses (AT45DB321), SD card slot, GSM modem, GPS receiver, ZigBee (CC2420), USB host ports, USB device port, two RS232 and one RS422/RS485 port, two opto isolated inputs, two relays and bunch of leds.

This patch supports booting (e.g. Linux kernel) from following media/interface:

- dataflash
- ethernet
- debug serial port
- SD/MMC

---
 Makefile                             |   13 +
 board/embedtronics/mrfsa/Makefile    |   60 +++++
 board/embedtronics/mrfsa/config.mk   |    1 +
 board/embedtronics/mrfsa/iopins.h    |   36 +++
 board/embedtronics/mrfsa/ks8995ma.h  |  255 ++++++++++++++++++
 board/embedtronics/mrfsa/mrfsa.c     |  481 ++++++++++++++++++++++++++++++++++
 board/embedtronics/mrfsa/partition.c |   44 +++
 board/embedtronics/mrfsa/watchdog.c  |   62 +++++
 common/console.c                     |    6 +
 cpu/arm926ejs/at91/timer.c           |    7 +-
 drivers/net/macb.c                   |    4 +
 include/asm-arm/mach-types.h         |   13 +
 include/configs/mrfsa.h              |  197 ++++++++++++++
 lib_arm/bootm.c                      |   13 +
 14 files changed, 1191 insertions(+), 1 deletions(-)
Quoted 8 lines
 create mode 100644 board/embedtronics/mrfsa/Makefile
 create mode 100644 board/embedtronics/mrfsa/config.mk
 create mode 100644 board/embedtronics/mrfsa/iopins.h
 create mode 100644 board/embedtronics/mrfsa/ks8995ma.h
 create mode 100644 board/embedtronics/mrfsa/mrfsa.c
 create mode 100644 board/embedtronics/mrfsa/partition.c
 create mode 100644 board/embedtronics/mrfsa/watchdog.c
 create mode 100644 include/configs/mrfsa.h

first please split this patch in ortogonal changeset as
1) patch for macb
2) patch for your switch
3) patch for the watchdog
4) patch for your board
please put the the sync request of the mach-types.h about your board after the ---
I'll handle it myself before apply your board

Quoted 28 lines

index 0000000..bfc7bad

board/embedtronics/mrfsa/ks8995ma.h new file +23 -0
@@ -0,0 +1,255 @@
+/*
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * 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
+ */

board/embedtronics/mrfsa/ks8995ma.h line 33

Quoted 10 lines
board/embedtronics/mrfsa/ks8995ma.h new file +10 -0
+
+#ifndef	_dev_spi_ks8995ma_h_
+#define	_dev_spi_ks8995ma_h_	1
+
+#define	KS_OK		0
+#define	KS_ERROR	-1
+
+#define	KS_RD_DATA	0x03
+#define	KS_WR_DATA	0x02
+

please be awre that I've start to work on the adding of a phylib
http://git.denx.de/?p=u-boot/u-boot-arm.git;a=shortlog;h=refs/heads/phylib

which will simplify phy and switch support so please take a look on it

Quoted 28 lines
board/embedtronics/mrfsa/mrfsa.c new file +22 -0
new file mode 100644
index 0000000..6420c4b
@@ -0,0 +1,481 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * 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.
+ *

board/embedtronics/mrfsa/mrfsa.c line 32

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+ * 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/at91_common.h>
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91sam9260_matrix.h>

please
#include <asm/arch/at91sam9_matrix.h>

Quoted 18 lines
board/embedtronics/mrfsa/mrfsa.c new file +18 -0
+#include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_wdt.h>
+#include <asm/arch/at91_rstc.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_spi.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+#if defined(CONFIG_RESET_PHY_R) || defined(CONFIG_MACB)
+#include <net.h>
+#include <netdev.h>
+#endif
+
+#include "ks8995ma.h"
+#include "iopins.h"
+
+#ifndef	CONFIG_NO_VLANS

board/embedtronics/mrfsa/mrfsa.c line 60

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+#define	CONFIG_NO_VLANS	1
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* ------------------------------------------------------------------------- */
+/*
+ * Miscelaneous platform dependent initialisations
+ */
+

as already point please use at91 generic hw init and atmel_spi driver

Quoted 6 lines
board/embedtronics/mrfsa/mrfsa.c new file +6 -0
+
+#ifdef	CONFIG_ATMEL_MCI
+static void mrfsa_mci_hw_init (void)
+{
+	/* Enable clock */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI);

board/embedtronics/mrfsa/mrfsa.c line 221

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+
+	/* configure I/O */
+	at91_set_A_periph (AT91_PIN_PA6, 1);
+	at91_set_A_periph (AT91_PIN_PA7, 1);
+	at91_set_A_periph (AT91_PIN_PA8, 1);
+	at91_set_A_periph (AT91_PIN_PA9, 1);
+	at91_set_A_periph (AT91_PIN_PA10, 1);
+	at91_set_A_periph (AT91_PIN_PA11, 1);
+}
+#endif	/* CONFIG_ATMEL_MCI */

the one must move to cpu/arm926ejs/at91/soc_devices please add it at the time of the mci support for all socs

board/embedtronics/mrfsa/mrfsa.c line 230

Quoted 9 lines
board/embedtronics/mrfsa/mrfsa.c new file +9 -0
+
+void mrfsa_wdt_init (void);
+
+int board_init (void)
+{
+	at91_set_gpio_output (PIN_RESET_OUT, 1);	/* reset output */
+
+	/* Enable Ctrlc */
+	console_init_f ();

no-need please remove

board/embedtronics/mrfsa/mrfsa.c line 241

Quoted 11 lines
board/embedtronics/mrfsa/mrfsa.c new file +11 -0
+
+	/* arch number of MRFSA-Board */
+	gd->bd->bi_arch_number = MACH_TYPE_MRFSA;
+	/* address of boot parameters */
+	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+
+	mrfsa_serial_hw_init ();
+
+#ifdef CONFIG_HW_WATCHDOG
+	mrfsa_wdt_init ();
+#endif

why?

Quoted 14 lines
board/embedtronics/mrfsa/mrfsa.c new file +14 -0
+
+#ifdef	CONFIG_ATMEL_MCI
+	mrfsa_mci_hw_init ();
+#endif
+
+	mrfsa_spi_hw_init ();
+
+#ifdef CONFIG_MACB
+	mrfsa_macb_hw_init ();
+#endif
+
+	return 0;
+}
+

board/embedtronics/mrfsa/mrfsa.c line 265

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+int board_late_init (void)
+{
+	/* prepare CSR(3) for shift registers */
+	writel (AT91_SPI_NCPHA
+		| AT91_SPI_BITS_8
+		| ((AT91C_MASTER_CLOCK / 10000000) << 8),
+		AT91_BASE_SPI + AT91_SPI_CSR (3));
+
+	/* set shift registers */
+	shreg_wr(0xfe, 0x30);

why?

board/embedtronics/mrfsa/mrfsa.c line 275

Quoted 5 lines
board/embedtronics/mrfsa/mrfsa.c new file +4 -0
+}
+
 
+
+#ifdef CONFIG_RESET_PHY_R

please create a phy driver

Quoted 12 lines
board/embedtronics/mrfsa/mrfsa.c new file +12 -0
+static unsigned int ks_cmd (unsigned rdwr, unsigned reg, unsigned value,
+			    unsigned *retvalue)
+{
+	unsigned char cmd[4] = { rdwr, reg, value }, rsp[4];
+	int ret;
+
+	ret = spi_transfer (2, PIN_SPI0_CSETH, cmd, rsp, 4);
+
+	if (ret != 0) {
+		return KS_ERROR;
+	}
+

board/embedtronics/mrfsa/mrfsa.c line 297

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+	if (retvalue) {
+		*retvalue = rsp[2];
+	}
+
+	return KS_OK;
+}
+
+static unsigned int ks_write_reg (unsigned reg, unsigned value)
+{
+	/*printf("%s: reg=%02x, value=%02x\n", __FUNCTION__, reg, value); */

please use debug

board/embedtronics/mrfsa/mrfsa.c line 303

Quoted 6 lines
board/embedtronics/mrfsa/mrfsa.c new file +6 -0
+	return ks_cmd (KS_WR_DATA, reg, value, 0);
+}
+
+static unsigned int ks_read_reg (unsigned reg, unsigned *value)
+{
+	int ret = ks_cmd (KS_RD_DATA, reg, 0, value);

please add an empty line

board/embedtronics/mrfsa/mrfsa.c line 304

Quoted 1 line
board/embedtronics/mrfsa/mrfsa.c new file +1 -0
+	/*printf("%s: reg=%02x, value=%02x, ret=%d\n", __FUNCTION__, reg, *value, ret); */

please use debug

Quoted 43 lines
board/embedtronics/mrfsa/mrfsa.c new file +3 -0
+	return ret;
+}
+
board/embedtronics/mrfsa/partition.c new file +34 -0
new file mode 100644
index 0000000..1f88f1b
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2008
+ * Ulf Samuelsson <[email protected]>
+ *
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtronics Oy <www.embedtronics.fi>
+ *
+ * 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 <config.h>
+#include <asm/hardware.h>
+#include <dataflash.h>
+
+AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = {
+	{CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0},	/* Logical adress, CS */
+	{CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1, 1}

board/embedtronics/mrfsa/partition.c line 44

Quoted 10 lines
board/embedtronics/mrfsa/partition.c new file +10 -0
+};
+
+/*define the area offsets*/
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+	{0x00000000, 0x000041FF, FLAG_PROTECT_CLEAR /*SET*/, 0, "Bootstrap"},
+	{0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
+	{0x00008400, 0x00041FFF, FLAG_PROTECT_CLEAR /*SET*/, 0, "U-Boot"},
+	{0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"},
+	{0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
+};

NACK the DATAFLASH driver is deprecated please use spi flash framework

Quoted 56 lines
board/embedtronics/mrfsa/watchdog.c new file +50 -0
new file mode 100644
index 0000000..95f5ac3
@@ -0,0 +1,62 @@
+/*
+ * (C) Copyright 2009
+ * Sami Kantoluoto <[email protected]>
+ * Embedtroncs Oy <www.embedtronics.fi>
+ *
+ * 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
+ */
+
+/*
+ * MRFSA board level hardware watchdog.
+ */
+#include <common.h>
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_wdt.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+#ifdef CONFIG_HW_WATCHDOG
+#include <watchdog.h>
+#include "iopins.h"
+
+static void at91_wdt_reset (void)
+{
+	at91_sys_write (AT91_WDT + AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+}
+
+void hw_watchdog_reset (void)
+{
+	at91_set_gpio_value (PIN_NICEDOG, 1);
+	at91_wdt_reset ();
+	at91_set_gpio_value (PIN_NICEDOG, 0);
+}
+

board/embedtronics/mrfsa/watchdog.c line 60

Quoted 10 lines
board/embedtronics/mrfsa/watchdog.c new file +10 -0
+void mrfsa_wdt_init (void)
+{
+	at91_wdt_reset ();
+	at91_sys_write (AT91_WDT + AT91_WDT_MR,
+			AT91_WDT_WDD | AT91_WDT_WDV | AT91_WDT_WDRSTEN |
+			AT91_WDT_WDRPROC | AT91_WDT_WDDBGHLT);
+	at91_set_gpio_output (PIN_NICEDOG, 0);
+
+	hw_watchdog_reset ();
+}

why don't you use the generic watch dog driver?

Quoted 7 lines
board/embedtronics/mrfsa/watchdog.c new file +2 -0
+
+#endif /* CONFIG_HW_WATCHDOG */
common/console.c +0 -0
index 867c12c..fb6e409 100644

common/console.c int getc(void) · line 319

Quoted 9 lines
common/console.c +6 -0
@@ -311,6 +311,12 @@ int getc(void)
 
 int tstc(void)
 {
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif

why?

Quoted 8 lines
common/console.c +0 -0
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
cpu/arm926ejs/at91/timer.c +0 -0
index 811bb3c..03fce54 100644

cpu/arm926ejs/at91/timer.c int timer_init(void) · line 91

Quoted 10 lines
cpu/arm926ejs/at91/timer.c +6 -1
@@ -83,7 +83,12 @@ int timer_init(void)
 unsigned long long get_ticks(void)
 {
 	ulong now = READ_TIMER;
-
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif

why?

Quoted 16 lines
cpu/arm926ejs/at91/timer.c +0 -0
 	if (now >= lastinc)	/* normal mode (non roll) */
 		/* move stamp forward with absolut diff ticks */
 		timestamp += (now - lastinc);
drivers/net/macb.c +1 -0
index c184353..9e2e771 100644
@@ -291,6 +291,7 @@ static int macb_recv(struct eth_device *netdev)
 	return 0;
 }
 
+#ifndef	CONFIG_NO_PHY
 static void macb_phy_reset(struct macb_device *macb)
 {
 	struct eth_device *netdev = &macb->netdev;

drivers/net/macb.c static int macb_phy_init(struct macb_device *macb) · line 407

Quoted 4 lines
drivers/net/macb.c +1 -0
@@ -403,6 +404,7 @@ static int macb_phy_init(struct macb_device *macb)
 		return 1;
 	}
 }
+#endif	/* CONFIG_NO_PHY */

better to switch to the phylib to handle your switch as a phy driver

Quoted 1 line

Best Regards,
J.

#4 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Sami Kantoluoto

Adds support for Embedtronics Oy's MRFSA board. Board features

[snip]

Quoted 24 lines
Quoted 16 lines
---
 Makefile                             |   13 +
 board/embedtronics/mrfsa/Makefile    |   60 +++++
 board/embedtronics/mrfsa/config.mk   |    1 +
 board/embedtronics/mrfsa/iopins.h    |   36 +++
 board/embedtronics/mrfsa/ks8995ma.h  |  255 ++++++++++++++++++
 board/embedtronics/mrfsa/mrfsa.c     |  481 ++++++++++++++++++++++++++++++++++
 board/embedtronics/mrfsa/partition.c |   44 +++
 board/embedtronics/mrfsa/watchdog.c  |   62 +++++
 common/console.c                     |    6 +
 cpu/arm926ejs/at91/timer.c           |    7 +-
 drivers/net/macb.c                   |    4 +
 include/asm-arm/mach-types.h         |   13 +
 include/configs/mrfsa.h              |  197 ++++++++++++++
 lib_arm/bootm.c                      |   13 +
 14 files changed, 1191 insertions(+), 1 deletions(-)
Quoted 8 lines
 create mode 100644 board/embedtronics/mrfsa/Makefile
 create mode 100644 board/embedtronics/mrfsa/config.mk
 create mode 100644 board/embedtronics/mrfsa/iopins.h
 create mode 100644 board/embedtronics/mrfsa/ks8995ma.h
 create mode 100644 board/embedtronics/mrfsa/mrfsa.c
 create mode 100644 board/embedtronics/mrfsa/partition.c
 create mode 100644 board/embedtronics/mrfsa/watchdog.c
 create mode 100644 include/configs/mrfsa.h
Quoted 9 lines

first please split this patch in ortogonal changeset as
1) patch for macb
2) patch for your switch
3) patch for the watchdog
4) patch for your board
please put the the sync request of the mach-types.h about your board after the ---
I'll handle it myself before apply your board

Ok.

----------------------------------------------------

Quoted 5 lines
Quoted 1 line

+++ b/board/embedtronics/mrfsa/ks8995ma.h

please be awre that I've start to work on the adding of a phylib
http://git.denx.de/?p=u-boot/u-boot-arm.git;a=shortlog;h=refs/heads/phylib

which will simplify phy and switch support so please take a look on it

I'll check that out.

----------------------------------------------------

Quoted 9 lines
Quoted 9 lines
board/embedtronics/mrfsa/mrfsa.c new file +9 -0
+#ifdef	CONFIG_ATMEL_MCI
+static void mrfsa_mci_hw_init (void)
+{
+	/* Enable clock */
+	at91_sys_write (AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI);
+
+	/* configure I/O */
+	at91_set_A_periph (AT91_PIN_PA6, 1);
+	at91_set_A_periph (AT91_PIN_PA7, 1);
Quoted 8 lines

board/embedtronics/mrfsa/mrfsa.c line 221

Quoted 6 lines
board/embedtronics/mrfsa/mrfsa.c new file +6 -0
+	at91_set_A_periph (AT91_PIN_PA8, 1);
+	at91_set_A_periph (AT91_PIN_PA9, 1);
+	at91_set_A_periph (AT91_PIN_PA10, 1);
+	at91_set_A_periph (AT91_PIN_PA11, 1);
+}
+#endif	/* CONFIG_ATMEL_MCI */

the one must move to cpu/arm926ejs/at91/soc_devices please add it at the time of the mci support for all socs

Ok.. Is this acceptable interface:

void at91_mci0_hw_init (unsigned mcda_bits, unsigned mcdb_bits);

mcda_bits tells the bus width (0 = not used, 1 = one bit, 4 = four bits) of slot A and mcdb_bits for slot B. This is needed because at91_mci_hw_init() needs to know which I/O pins to configure.

Quoted 5 lines
Quoted 5 lines
board/embedtronics/mrfsa/mrfsa.c new file +5 -0
+
+void mrfsa_wdt_init (void);
+
+int board_init (void)
+{

[snip]

Quoted 4 lines

board/embedtronics/mrfsa/mrfsa.c line 241

Quoted 3 lines
board/embedtronics/mrfsa/mrfsa.c new file +3 -0
+#ifdef CONFIG_HW_WATCHDOG
+	mrfsa_wdt_init ();
+#endif

why?

Just to make sure the hardware (external to CPU) watchdog doesn't reset us.

Quoted 11 lines

board/embedtronics/mrfsa/mrfsa.c line 265

Quoted 10 lines
board/embedtronics/mrfsa/mrfsa.c new file +10 -0
+int board_late_init (void)
+{
+	/* prepare CSR(3) for shift registers */
+	writel (AT91_SPI_NCPHA
+		| AT91_SPI_BITS_8
+		| ((AT91C_MASTER_CLOCK / 10000000) << 8),
+		AT91_BASE_SPI + AT91_SPI_CSR (3));
+
+	/* set shift registers */
+	shreg_wr(0xfe, 0x30);

why?

To configure state of leds and outputs behind the shift register. I'll add some comments (and modify to use the present spi interface).

Quoted 6 lines

board/embedtronics/mrfsa/mrfsa.c line 275

Quoted 5 lines
board/embedtronics/mrfsa/mrfsa.c new file +4 -0
+}
+
 
+
+#ifdef CONFIG_RESET_PHY_R

please create a phy driver

Ok.

Quoted 1 line
Quoted 1 line
board/embedtronics/mrfsa/partition.c +0 -0

[snip]

Quoted 5 lines

board/embedtronics/mrfsa/partition.c

Quoted 4 lines
board/embedtronics/mrfsa/partition.c +4 -0
+AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = {
+	{CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0},	/* Logical adress,

CS */

Quoted 12 lines

board/embedtronics/mrfsa/partition.c line 44

Quoted 11 lines
board/embedtronics/mrfsa/partition.c +11 -0
+	{CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1, 1}
+};
+
+/*define the area offsets*/
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+	{0x00000000, 0x000041FF, FLAG_PROTECT_CLEAR /*SET*/, 0, "Bootstrap"},
+	{0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
+	{0x00008400, 0x00041FFF, FLAG_PROTECT_CLEAR /*SET*/, 0, "U-Boot"},
+	{0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"},
+	{0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
+};

NACK the DATAFLASH driver is deprecated please use spi flash framework

Ok.

Quoted 6 lines

board/embedtronics/mrfsa/watchdog.c line 27

Quoted 5 lines
board/embedtronics/mrfsa/watchdog.c +4 -0
+
+/*
+ * MRFSA board level hardware watchdog.
+ */

why don't you use the generic watch dog driver?

We've external watchdog chip (CAT1023 or so) because Atmel had/has bug in boot code that disabled the internal watchdog..

Quoted 6 lines
Quoted 6 lines
common/console.c +0 -0
index 867c12c..fb6e409 100644
@@ -311,6 +311,12 @@ int getc(void)
 
Quoted 9 lines

common/console.c int getc(void) · line 319

Quoted 8 lines
common/console.c +6 -0
 int tstc(void)
 {
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif

why?

Well, the CAT1023 (watchdog chip) requires to be signaled quite often and at least older version of U-boot (used v1.3.4 originally) did not meet that requirement (at least under boot delay and maybe some other cases).

Quoted 11 lines
Quoted 11 lines
common/console.c +0 -0
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
cpu/arm926ejs/at91/timer.c +0 -0
index 811bb3c..03fce54 100644
@@ -83,7 +83,12 @@ int timer_init(void)
 unsigned long long get_ticks(void)
 {
 	ulong now = READ_TIMER;
Quoted 8 lines

cpu/arm926ejs/at91/timer.c int timer_init(void) · line 91

Quoted 7 lines
cpu/arm926ejs/at91/timer.c +6 -1
-
+#ifdef  CONFIG_HW_WATCHDOG
+	hw_watchdog_reset();
+#endif
+#ifdef  CONFIG_WATCHDOG
+	watchdog_reset();
+#endif

why?

Quite the same reason as above.. Can't remember the exact case anymore but some loops (that used timeouts but did not use tstc() directly or indrectly) were too long for watchdog.

Quoted 2 lines

Best Regards,
J.

Thank you for comments. I'll fix things and post a new patch..

      -sk
#5 lore raw

PATCH 1/1 Support for Embedtronics/MRFSA board.

In reply to Sami Kantoluoto
Quoted 31 lines · Sami Kantoluoto

Adds support for Embedtronics Oy's MRFSA board. Board features AT91SAM9G20 controller, 64 MB of SDRAM, two 64 Mbit data flashses (AT45DB321), SD card slot, GSM modem, GPS receiver, ZigBee (CC2420), USB host ports, USB device port, two RS232 and one RS422/RS485 port, two opto isolated inputs, two relays and bunch of leds.

This patch supports booting (e.g. Linux kernel) from following media/interface:

- dataflash
- ethernet
- debug serial port
- SD/MMC

---
 Makefile                             |   13 +
 board/embedtronics/mrfsa/Makefile    |   60 +++++
 board/embedtronics/mrfsa/config.mk   |    1 +
 board/embedtronics/mrfsa/iopins.h    |   36 +++
 board/embedtronics/mrfsa/ks8995ma.h  |  255 ++++++++++++++++++
 board/embedtronics/mrfsa/mrfsa.c     |  481 ++++++++++++++++++++++++++++++++++
 board/embedtronics/mrfsa/partition.c |   44 +++
 board/embedtronics/mrfsa/watchdog.c  |   62 +++++
 common/console.c                     |    6 +
 cpu/arm926ejs/at91/timer.c           |    7 +-
 drivers/net/macb.c                   |    4 +
 include/asm-arm/mach-types.h         |   13 +
 include/configs/mrfsa.h              |  197 ++++++++++++++
 lib_arm/bootm.c                      |   13 +
 14 files changed, 1191 insertions(+), 1 deletions(-)
Quoted 8 lines
 create mode 100644 board/embedtronics/mrfsa/Makefile
 create mode 100644 board/embedtronics/mrfsa/config.mk
 create mode 100644 board/embedtronics/mrfsa/iopins.h
 create mode 100644 board/embedtronics/mrfsa/ks8995ma.h
 create mode 100644 board/embedtronics/mrfsa/mrfsa.c
 create mode 100644 board/embedtronics/mrfsa/partition.c
 create mode 100644 board/embedtronics/mrfsa/watchdog.c
 create mode 100644 include/configs/mrfsa.h

I forgot it in my previous email, but you should also add an entry for your board in MAINTAINERS, as well as in MAKEALL.

Regards,

Signature · 4 lines
Albin Tonnerre, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com