[U-Boot] [PATCH] AT91: Add support for NetusG20

Reinhard Meyer u-boot at emk-elektronik.de
Tue Nov 16 13:13:50 CET 2010


Dear Claudio Mignanti,

> Add support for the NetusG20 board by Acmesystems srl.
> This board is based on AT91SAM9G20 SoC.
> 
> Signed-off-by: Claudio Mignanti <c.mignanti at gmail.com>

Please run your patch with linux/scripts/checkpatch.pl, you'll
get alot of errors (whitespace and style)...

> ---
>  MAINTAINERS                            |    5 +
>  board/acmesystems/netusg20/Makefile    |   55 ++++++++++
>  board/acmesystems/netusg20/netusg20.c  |  130 ++++++++++++++++++++++++
>  board/acmesystems/netusg20/partition.c |   39 +++++++
>  boards.cfg                             |    1 +
>  include/configs/netusg20.h             |  174 ++++++++++++++++++++++++++++++++
>  6 files changed, 404 insertions(+), 0 deletions(-)
>  create mode 100644 board/acmesystems/netusg20/Makefile
>  create mode 100644 board/acmesystems/netusg20/netusg20.c
>  create mode 100644 board/acmesystems/netusg20/partition.c
>  create mode 100644 include/configs/netusg20.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ccece74..7ce96b5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -852,6 +852,11 @@ Alex Z
>  	lart		SA1100
>  	dnp1110		SA1110
>  
> +
> +Claudio Mignanti <c.mignanti at gmail.com>
> +
> +	netusg20	ARM926EJS (AT91SAM9G20 SoC)
> +

Please sort that in alphabetically by Surname.

>  -------------------------------------------------------------------------
>  
>  Unknown / orphaned boards:

> diff --git a/board/acmesystems/netusg20/Makefile b/board/acmesystems/netusg20/Makefile
> new file mode 100644
> index 0000000..09e6695
> --- /dev/null
> +++ b/board/acmesystems/netusg20/Makefile
> @@ -0,0 +1,55 @@
> +#
> +# (C) Copyright 2003-2008
> +# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> +#
> +# (C) Copyright 2008
> +# Stelian Pop <stelian.pop at leadtechdesign.com>
> +# Lead Tech Design <www.leadtechdesign.com>
> +#
> +# 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-$(CONFIG_NETUSG20)	+= netusg20.o
> +COBJS-y	+= partition.o
> +
> +SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
> +OBJS	:= $(addprefix $(obj),$(COBJS-y))
> +SOBJS	:= $(addprefix $(obj),$(SOBJS))
> +
> +$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
> +	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
> +
> +clean:
> +	rm -f $(SOBJS) $(OBJS)
> +
> +distclean:	clean
> +	rm -f $(LIB) core *.bak $(obj).depend
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################
> diff --git a/board/acmesystems/netusg20/netusg20.c b/board/acmesystems/netusg20/netusg20.c
> new file mode 100644
> index 0000000..6bcb1f7
> --- /dev/null
> +++ b/board/acmesystems/netusg20/netusg20.c
> @@ -0,0 +1,130 @@
> +/*
> + * (C) Copyright 2007-2008
> + * Stelian Pop <stelian.pop at leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + *
> + * (C) Copyright 2010
> + * Reinhard Meyer, EMK Elektronik, reinhard.meyer at emk-elektronik.de
> + * Claudio Mignanti <c.mignanti at gmail.com>
> + *
> + * 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 <net.h>
> +#include <netdev.h>
> +#include <mmc.h>
> +#include <i2c.h>
> +#include <spi.h>
> +#include <asm/io.h>
> +#include <asm/arch/hardware.h>
> +#include <asm/arch/at91sam9260_matrix.h>
> +#include <asm/arch/at91sam9260.h>
> +#include <asm/arch/at91_common.h>
> +#include <asm/arch/at91_pmc.h>
> +#include <asm/arch/at91_rstc.h>
> +#include <asm/arch/gpio.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/* ------------------------------------------------------------------------- */
> +/*
> + * Miscellaneous platform dependent initialisations
> + */
> +#ifdef CONFIG_MACB
> +static void netus_macb_init(void)
> +{
> +	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +
> +	/* Enable EMAC clock */
> +	writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
> +
> +	/* Initialize EMAC=MACB hardware */
> +	at91_macb_hw_init();
> +}
> +
> +int board_eth_init(bd_t *bis)
> +{
> +	int rc = 0;
> +	rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC0, 0x00);
> +	return rc;
> +}
> +#else
> +/* code is more readable if #directive are around the function 
> + * and not in the middle */
> +void netus_macb_init(void) {}		/* define of dummy function */
> +int board_eth_init(bd_t *bis) { return 0;}
> +#endif

No else part here, if CONFIG_MACB is not set, and no other network interfaces
do exist, you should also not define other network related stuff. Then
board_eth_init() will not be needed.

> +
> +int board_early_init_f(void)
> +{
> +	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +
> +	/* Enable clocks for all PIOs */
> +	writel(	(1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
> +		(1 << ATMEL_ID_PIOC),
> +		&pmc->pcer);
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_GENERIC_ATMEL_MCI
> +int board_mmc_init(bd_t *bd)
> +{
> +	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +
> +	/* Enable MCI clock */
> +	writel(1 << ATMEL_ID_MCI, &pmc->pcer);
> +	at91_mci_hw_init();
> +
> +	/* This calls the atmel_mmc_init in gen_atmel_mci.c */
> +	return atmel_mci_init((void *)ATMEL_BASE_MCI);
> +
> +}
> +
> +/* return *cd = TRUE if card is NOT detected. */
> +int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> +{
> +	/* 
> +	 * This board don't support card detection.
> +	 */
> +	*cd = 0;
> +	return 0;
> +}
> +#else
> +void board_mmc_init(bd_t *bd) {}
> +#endif

Remove that function completely, if your board does not support card
detect. A weak function should kick in in mmc.c, returning the correct
value.

> +
> +int board_init (void) {
> +
> +	gd->bd->bi_arch_number = 3129; //MACH_TYPE_ACMENETUSFOXG20
> +	/* address of boot parameters */
> +	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
> +
> +	netus_macb_init();
> +	return 0;
> +}

if MACB is optional, #ifdef around the netus_macb_init()

> +
> +int dram_init(void)
> +{
> +	gd->ram_size = get_ram_size(
> +		(void *)CONFIG_SYS_SDRAM_BASE,
> +		CONFIG_SYS_SDRAM_SIZE);
> +	return 0;
> +}
> +

> diff --git a/board/acmesystems/netusg20/partition.c b/board/acmesystems/netusg20/partition.c
> new file mode 100644
> index 0000000..7d79e53
> --- /dev/null
> +++ b/board/acmesystems/netusg20/partition.c
> @@ -0,0 +1,39 @@
> +/*
> + * (C) Copyright 2008
> + * Ulf Samuelsson <ulf at atmel.com>
> + *
> + * 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_CS1, 1}
> +};
> +
> +/*define the area offsets*/
> +dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
> +	{0x00000000, 0x000041FF, FLAG_PROTECT_SET,   0, "Bootstrap"},
> +	{0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
> +	{0x00008400, 0x00041FFF, FLAG_PROTECT_SET,   0, "U-Boot"},
> +	{0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0,	"Kernel"},
> +	{0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0,	"FS"},
> +};


> diff --git a/boards.cfg b/boards.cfg
> index 648603d..97382f2 100644
> --- a/boards.cfg
> +++ b/boards.cfg
> @@ -377,6 +377,7 @@ smdk2400	arm	arm920t		-		samsung		s3c24x0
>  smdk2410	arm	arm920t		-		samsung		s3c24x0
>  voiceblue	arm	arm925t
>  omap1510inn	arm	arm925t		-		ti
> +netusg20	arm	arm926ejs	-		acmesystems	at91
>  afeb9260	arm	arm926ejs	-		-		at91
>  at91cap9adk	arm	arm926ejs	-		atmel		at91
>  davinci_dvevm	arm	arm926ejs	dvevm		davinci		davinci

I am myself insecure about how exactly to sort in stuff here, because the list
as it is is not properly sorted. Wolfgang?

> diff --git a/include/configs/netusg20.h b/include/configs/netusg20.h
> new file mode 100644
> index 0000000..051fa3a
> --- /dev/null
> +++ b/include/configs/netusg20.h
> @@ -0,0 +1,174 @@
> +/*
> + * (C) Copyright 2009-2010
> + * Reinhard Meyer, EMK Elektronik, reinhard.meyer at emk-elektronik.de
> + * Claudio Mignanti <c.mignanti at gmail.com>
> + *
> + * Configuation settings for the NetusG20 boards.
> + *
> + * 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 __CONFIG_H
> +#define __CONFIG_H
> +
> +
> +#define CONFIG_AT91SAM9G20
> +#define CONFIG_NETUSG20
> +#include <asm/hardware.h>
> +
> +#define CONFIG_SYS_TEXT_BASE	0x23f00000

Just a warning here:
I know that the original load address on Átmel systems is 1MB before end
of (expected) SDRAM.
However, with relocation this is a bit dangerous if someone reserves memory
or increases stack/bss sizes. You'll run into an overlap which is *BAD*.
I recommend changing the initial boot loader to load images to start of SDRAM.

> +
> +/* ARM asynchronous clock */
> +#define CONFIG_SYS_AT91_SLOW_CLOCK	32768
> +#define CONFIG_SYS_AT91_MAIN_CLOCK	18432000	/* 18.432 MHz */
> +#define CONFIG_SYS_HZ		1000
> +
> +/* Misc CPU related */
> +#define CONFIG_ARCH_CPU_INIT
> +#undef CONFIG_USE_IRQ			/* we don't need IRQ/FIQ stuff	*/
> +#define CONFIG_CMDLINE_TAG		/* enable passing of ATAGs	*/
> +#define CONFIG_SETUP_MEMORY_TAGS
> +#define CONFIG_INITRD_TAG
> +#define CONFIG_SKIP_LOWLEVEL_INIT
> +#define CONFIG_BOARD_EARLY_INIT_F
> +#define CONFIG_DISPLAY_CPUINFO
> +
> +/* General purpose I/O */
> +#define CONFIG_ATMEL_LEGACY		/* required until (g)pio is fixed */
> +#define CONFIG_AT91_GPIO
> +#define CONFIG_AT91_GPIO_PULLUP	1	/* keep pullups on peripheral pins */

"1" OK here. It is used numerically.

> +
> +/* Serial console */
> +#define CONFIG_ATMEL_USART
> +#define CONFIG_USART_BASE		ATMEL_BASE_DBGU
> +#define	CONFIG_USART_ID			ATMEL_ID_SYS
> +#define CONFIG_BAUDRATE			115200
> +#define CONFIG_SYS_BAUDRATE_TABLE	{115200 , 19200, 38400, 57600, 9600 }
> +#define CONFIG_BOARD_EARLY_INIT_F
> +#define CONFIG_BOOTDELAY	1

"1" OK here. It is used numerically.

> +
> +/*
> + * BOOTP options
> + */
> +#define CONFIG_BOOTP_BOOTFILESIZE	1
> +#define CONFIG_BOOTP_BOOTPATH		1
> +#define CONFIG_BOOTP_GATEWAY		1
> +#define CONFIG_BOOTP_HOSTNAME		1

Generally, with new config files, we don't want #define SOMETHING 1, if
it is only used as #ifdef SOMETHING. Please remove those "1"s all over this
file.

> +
> +/*
> + * Command line configuration.
> + */
> +#include <config_cmd_default.h>
> +#undef CONFIG_CMD_FPGA
> +#undef CONFIG_CMD_IMLS /* related to flash support, so uneeded */
> +
> +#define CONFIG_CMD_DHCP		1
> +#define CONFIG_CMD_USB		1
> +#define CONFIG_CMD_PING		1
> +
> +/* SDRAM */
> +#define CONFIG_NR_DRAM_BANKS	1
> +#define CONFIG_SYS_SDRAM_BASE	ATMEL_BASE_CS1
> +#define CONFIG_SYS_SDRAM_SIZE	0x04000000
> +
> +# define CONFIG_SYS_INIT_SP_ADDR \
> +	(ATMEL_BASE_SRAM1 + 0x1000 - GENERATED_GBL_DATA_SIZE)
> +
> +/* 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	1
> +#define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1	0xD0000000	/* CS1 */
> +#define AT91_SPI_CLK			15000000
> +
> +#define DATAFLASH_TCSS			(0x22 << 16)
> +#define DATAFLASH_TCHS			(0x1 << 24)
> +
> +/* no NAND flash on this board*/
> +#define CONFIG_SYS_NO_FLASH

That define relates to NOR and DATAFLASH (AFAIK),
but definitely not to NAND flash.

> +
> +/* Ethernet */
> +#define CONFIG_MACB				1
> +#define CONFIG_RMII				1
> +#define CONFIG_NET_MULTI		1
> +#define CONFIG_NET_RETRY_COUNT	20
> +
> +/* MMC */
> +#define CONFIG_MMC
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_GENERIC_ATMEL_MCI
> +#define CONFIG_ATMEL_MCI_PORTB

I don't know your hardware, but does not generally MMC on Slot B
conflict with SPI0 on at91sam9260 and friends?

> +
> +/* 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
> +#define CONFIG_SYS_USB_OHCI_SLOT_NAME	"at91sam9260"
> +#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		CONFIG_SYS_SDRAM_BASE
> +#define CONFIG_SYS_MEMTEST_END			0x23e00000
> +
> +/* Filesystem */
> +#define CONFIG_CMD_FAT		1
> +#define CONFIG_CMD_EXT2		1
> +#define CONFIG_CMD_MMC		1

MMC is not exactly a filesystem command...

> +
> +/* 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	"mmc init; sleep 1; " \
> +                            "fatload mmc 0 0x20000000 uImage; " \
> +                            "source 0x20000000"
> +#define CONFIG_BOOTARGS		"mem=64M console=ttyS0,115200 " \
> +                            "root=/dev/mmcblk0p1 rootwait"
> +
> +#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_STACKSIZE	(32*1024)	/* regular stack */
> +
> +#ifdef CONFIG_USE_IRQ
> +#error CONFIG_USE_IRQ not supported
> +#endif
> +
> +#endif

Best Regards,
Reinhard


More information about the U-Boot mailing list