[U-Boot] [PATCH] Support for Embedtronics/MRFSA board.

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Aug 29 22:15:23 CEST 2009


On 20:22 Sat 29 Aug     , Sami Kantoluoto wrote:
> 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
> 
> Signed-off-by: Sami Kantoluoto <sami.kantoluoto at embedtronics.fi>
> ---
>  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
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
> 
> index 0000000..bfc7bad
> --- /dev/null
> +++ b/board/embedtronics/mrfsa/ks8995ma.h
> @@ -0,0 +1,255 @@
> +/*
> + * (C) Copyright 2009
> + * Sami Kantoluoto <sami.kantoluoto at embedtronics.fi>
> + * 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	_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
> diff --git a/board/embedtronics/mrfsa/mrfsa.c b/board/embedtronics/mrfsa/mrfsa.c
> new file mode 100644
> index 0000000..6420c4b
> --- /dev/null
> +++ b/board/embedtronics/mrfsa/mrfsa.c
> @@ -0,0 +1,481 @@
> +/*
> + * (C) Copyright 2007-2008
> + * Stelian Pop <stelian.pop at leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + *
> + * (C) Copyright 2009
> + * Sami Kantoluoto <sami.kantoluoto at embedtronics.fi>
> + * 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>
please
#include <asm/arch/at91sam9_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
> + */
> +
as already point please use at91 generic hw init and atmel_spi driver
> +
> +#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);
> +	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
> +
> +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
> +
> +	/* 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?
> +
> +#ifdef	CONFIG_ATMEL_MCI
> +	mrfsa_mci_hw_init ();
> +#endif
> +
> +	mrfsa_spi_hw_init ();
> +
> +#ifdef CONFIG_MACB
> +	mrfsa_macb_hw_init ();
> +#endif
> +
> +	return 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?
> +}
> +

> +
> +#ifdef CONFIG_RESET_PHY_R
please create a phy driver
> +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;
> +	}
> +
> +	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
> +	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
> +	/*printf("%s: reg=%02x, value=%02x, ret=%d\n", __FUNCTION__, reg, *value, ret); */
please use debug
> +	return ret;
> +}
> +
> diff --git a/board/embedtronics/mrfsa/partition.c b/board/embedtronics/mrfsa/partition.c
> new file mode 100644
> index 0000000..1f88f1b
> --- /dev/null
> +++ b/board/embedtronics/mrfsa/partition.c
> @@ -0,0 +1,44 @@
> +/*
> + * (C) Copyright 2008
> + * Ulf Samuelsson <ulf at atmel.com>
> + *
> + * (C) Copyright 2009
> + * Sami Kantoluoto <sami.kantoluoto at embedtronics.fi>
> + * 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}
> +};
> +
> +/*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
> diff --git a/board/embedtronics/mrfsa/watchdog.c b/board/embedtronics/mrfsa/watchdog.c
> new file mode 100644
> index 0000000..95f5ac3
> --- /dev/null
> +++ b/board/embedtronics/mrfsa/watchdog.c
> @@ -0,0 +1,62 @@
> +/*
> + * (C) Copyright 2009
> + * Sami Kantoluoto <sami.kantoluoto at embedtronics.fi>
> + * 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);
> +}
> +
> +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?
> +
> +#endif /* CONFIG_HW_WATCHDOG */
> diff --git a/common/console.c b/common/console.c
> index 867c12c..fb6e409 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -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?

>  #ifdef CONFIG_DISABLE_CONSOLE
>  	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
>  		return 0;
> diff --git a/cpu/arm926ejs/at91/timer.c b/cpu/arm926ejs/at91/timer.c
> index 811bb3c..03fce54 100644
> --- a/cpu/arm926ejs/at91/timer.c
> +++ b/cpu/arm926ejs/at91/timer.c
> @@ -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?
>  	if (now >= lastinc)	/* normal mode (non roll) */
>  		/* move stamp forward with absolut diff ticks */
>  		timestamp += (now - lastinc);
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index c184353..9e2e771 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -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 */
better to switch to the phylib to handle your switch as a phy driver
>  

Best Regards,
J.


More information about the U-Boot mailing list