[U-Boot] [PATCH v2] arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Andreas Bießmann andreas.devel at googlemail.com
Mon Nov 11 12:03:56 CET 2013


Dear Mateusz Kulikowski,

On 11/02/2013 12:19 AM, Mateusz Kulikowski wrote:
> Add support for USB-A9263 board manufactured by Calao Systems
> (http://www.calao-systems.com/).
> Code is based on old U-Boot sources (2010.09) released by Calao and
> existing AT92SAM9263-EK code.
> 
> Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski at gmail.com>
> ---
>  board/calao/usb_a9263/Makefile    |  34 ++++++++
>  board/calao/usb_a9263/usb_a9263.c | 167 +++++++++++++++++++++++++++++++++++++
>  boards.cfg                        |   1 +
>  include/configs/usb_a9263.h       | 168 ++++++++++++++++++++++++++++++++++++++
>  4 files changed, 370 insertions(+)
>  create mode 100644 board/calao/usb_a9263/Makefile
>  create mode 100644 board/calao/usb_a9263/usb_a9263.c
>  create mode 100644 include/configs/usb_a9263.h
> 
> diff --git a/board/calao/usb_a9263/Makefile b/board/calao/usb_a9263/Makefile
> new file mode 100644
> index 0000000..dc87684
> --- /dev/null
> +++ b/board/calao/usb_a9263/Makefile
> @@ -0,0 +1,34 @@
> +#
> +# (C) Copyright 2003-2008
> +# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> +#
> +# (C) Copyright 2008
> +# Stelian Pop <stelian at popies.net>
> +# Lead Tech Design <www.leadtechdesign.com>
> +#
> +# (C) Copyright 2013
> +# Mateusz Kulikowski <mateusz.kulikowski at gmail.com>
> +#
> +# SPDX-License-Identifier:	GPL-2.0+
> +
> +include $(TOPDIR)/config.mk
> +
> +LIB	= $(obj)lib$(BOARD).o
> +
> +COBJS-y += usb_a9263.o
> +
> +SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
> +OBJS	:= $(addprefix $(obj),$(COBJS-y))
> +SOBJS	:= $(addprefix $(obj),$(SOBJS))
> +
> +$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
> +	$(call cmd_link_o_target, $(OBJS) $(SOBJS))
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################

please adopt all Makefiles to latest KBuild changes in u-boot/master.

> diff --git a/board/calao/usb_a9263/usb_a9263.c b/board/calao/usb_a9263/usb_a9263.c
> new file mode 100644
> index 0000000..bbc1e25
> --- /dev/null
> +++ b/board/calao/usb_a9263/usb_a9263.c
> @@ -0,0 +1,167 @@
> +/*
> + * (C) Copyright 2007-2013
> + * Stelian Pop <stelian.pop at leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + * Thomas Petazzoni, Free Electrons, <thomas.petazzoni at free-electrons.com>
> + * Mateusz Kulikowski <mateusz.kulikowski at gmail.com>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <asm/arch/at91sam9_smc.h>
> +#include <asm/arch/at91_common.h>
> +#include <asm/arch/at91_pmc.h>
> +#include <asm/arch/at91_rstc.h>
> +#include <asm/arch/at91_matrix.h>
> +#include <asm/arch/at91_pio.h>
> +#include <asm/arch/clk.h>
> +#include <asm/arch/gpio.h>
> +#include <asm/arch/hardware.h>
> +#if defined(CONFIG_MACB)

I think we can include the headers unconditionally, or is there a problem?

> +#include <net.h>
> +#endif
> +#include <netdev.h>
> +#if defined(CONFIG_HAS_DATAFLASH)
> +#include <dataflash.h>
> +#endif
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#ifdef CONFIG_HAS_DATAFLASH
> +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 */
> +};
> +
> +/*define the area offsets*/
> +dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
> +	{0x00000000, 0x00001FFF, FLAG_PROTECT_SET, 0, "Bootstrap"},
> +	{0x00002000, 0x00003FFF, FLAG_PROTECT_CLEAR, 0, "Environment"},
> +	{0x00004000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "U-Boot"},
> +};
> +#endif
> +
> +#ifdef CONFIG_CMD_NAND
> +static void usb_a9263_nand_hw_init(void)
> +{
> +	unsigned long csa;
> +	at91_smc_t *smc = (at91_smc_t *)ATMEL_BASE_SMC0;
> +	at91_matrix_t *matrix = (at91_matrix_t *)ATMEL_BASE_MATRIX;
> +	at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> +
> +	/* Enable CS3 */
> +	csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A;
> +	writel(csa, &matrix->csa[0]);
> +
> +	/* Configure SMC CS3 for NAND/SmartMedia */
> +	writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
> +	       AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
> +	       &smc->cs[3].setup);
> +
> +	writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
> +	       AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
> +	       &smc->cs[3].pulse);
> +
> +	writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
> +	       &smc->cs[3].cycle);
> +
> +	writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
> +	       AT91_SMC_MODE_EXNW_DISABLE |
> +	       AT91_SMC_MODE_DBW_8 |
> +	       AT91_SMC_MODE_TDF_CYCLE(2), &smc->cs[3].mode);
> +
> +	writel(1 << ATMEL_ID_PIOA | 1 << ATMEL_ID_PIOCDE, &pmc->pcer);
> +
> +	/* Configure RDY/BSY */
> +	at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);

Could you please use the generic GPIO API here? Is it Ok for you to not
mux the pullup for the ready pin?

> +
> +	/* Enable NandFlash */
> +	at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);

Here you could really use the gpio_direction_output(). I sent out an RFC
lately to define new GPIO_PIN_Px() macros. As long as that RFC is not
reworked and included I think it is Ok to use the CONFIG_ATMEL_LEGACY
defines.
Please switch to the generic GPIO API for defining GPIO direction and
switching GPIO, even on AT91. On the long run we will remove the
redundant at91_pio API, at least regarding plane GPIO functionality.
Therefore it would be good to use that API now, even if it costs some
function calls currently.

> +}
> +#endif
> +
> +#ifdef CONFIG_MACB
> +static void usb_a9263_macb_hw_init(void)
> +{
> +	unsigned long erstl;
> +	at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> +	at91_rstc_t *rstc = (at91_rstc_t *)ATMEL_BASE_RSTC;
> +
> +	/* Enable clock */
> +	writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
> +
> +	/*
> +	 * Disable pull-up on:
> +	 *  RXDV (PC25) => PHY normal mode (not Test mode)
> +	 *  ERX0 (PE25) => PHY ADDR0
> +	 *  ERX1 (PE26) => PHY ADDR1 => PHYADDR = 0x0
> +	 *
> +	 * PHY has internal pull-down
> +	 */
> +	at91_set_pio_pullup(AT91_PIO_PORTC, 25, 0);
> +	at91_set_pio_pullup(AT91_PIO_PORTE, 25, 0);
> +	at91_set_pio_pullup(AT91_PIO_PORTE, 26, 0);
> +
> +	erstl = readl(&rstc->mr) & AT91_RSTC_MR_ERSTL_MASK;
> +
> +	/* Need to reset PHY -> 500ms reset */
> +	writel(AT91_RSTC_KEY | AT91_RSTC_MR_ERSTL(0x0D) |
> +	       AT91_RSTC_MR_URSTEN, &rstc->mr);
> +
> +	writel(AT91_RSTC_KEY | AT91_RSTC_CR_EXTRST, &rstc->cr);
> +
> +	/* Wait for end hardware reset */
> +	while (!(readl(&rstc->sr) & AT91_RSTC_SR_NRSTL))
> +		;
> +
> +	/* Restore NRST value */
> +	writel(AT91_RSTC_KEY | erstl | AT91_RSTC_MR_URSTEN, &rstc->mr);
> +
> +	/* Re-enable pull-up */
> +	at91_set_pio_pullup(AT91_PIO_PORTC, 25, 1);
> +	at91_set_pio_pullup(AT91_PIO_PORTE, 25, 1);
> +	at91_set_pio_pullup(AT91_PIO_PORTE, 26, 1);
> +
> +	at91_macb_hw_init();

Heiko proposed a solution for unifying macb reset sequence.

@Heiko will you send another patch?

> +}
> +#endif
> +
> +int board_init(void)
> +{
> +	/* adress of boot parameters */
> +	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
> +
> +#ifdef CONFIG_CMD_NAND
> +	usb_a9263_nand_hw_init();
> +#endif
> +#ifdef CONFIG_HAS_DATAFLASH
> +	at91_set_pio_output(AT91_PIO_PORTE, 20, 1);	/* select spi0 clock */

Here we could also use the generic GPIO API. Beside that, did you really
copy the at91sam9263 here? IOW, do you really have a slot for MMC/DF
here and therefore require to switch the clock?

> +	at91_spi0_hw_init(1 << 0);
> +#endif
> +#ifdef CONFIG_MACB
> +	usb_a9263_macb_hw_init();
> +#endif
> +#ifdef CONFIG_USB_OHCI_NEW
> +	at91_uhp_hw_init();
> +#endif
> +	return 0;
> +}
> +
> +int dram_init(void)
> +{
> +	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
> +				    CONFIG_SYS_SDRAM_SIZE);
> +	return 0;
> +}
> +
> +int board_eth_init(bd_t *bis)
> +{
> +	int rc = 0;
> +
> +#ifdef CONFIG_MACB
> +	rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00);
> +#endif
> +	return rc;
> +}
> diff --git a/boards.cfg b/boards.cfg
> index 5e10125..48d6c53 100644
> --- a/boards.cfg
> +++ b/boards.cfg
> @@ -120,6 +120,7 @@ Active  arm         arm926ejs      at91        calao           tny_a9260
>  Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9260_nandflash                  tny_a9260:AT91SAM9260,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <albin.tonnerre at free-electrons.com>
>  Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <albin.tonnerre at free-electrons.com>
>  Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <albin.tonnerre at free-electrons.com>
> +Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <mateusz.kulikowski at gmail.com>
>  Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <info at egnite.de>
>  Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <reinhard.meyer at emk-elektronik.de>
>  Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <reinhard.meyer at emk-elektronik.de>
> diff --git a/include/configs/usb_a9263.h b/include/configs/usb_a9263.h
> new file mode 100644
> index 0000000..6d1f43f
> --- /dev/null
> +++ b/include/configs/usb_a9263.h
> @@ -0,0 +1,168 @@
> +/*
> + * (C) Copyright 2007-2013
> + * Stelian Pop <stelian.pop at leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + * Thomas Petazzoni, Free Electrons, <thomas.petazzoni at free-electrons.com>
> + * Mateusz Kulikowski <mateusz.kulikowski at gmail.com>
> + *
> + * Settings for Calao USB-A9263 board
> + *
> + * U-Boot image has to be less than 200704 bytes, otherwise at91bootstrap
> + * installed on board will not be able to load it properly.
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +#include <asm/hardware.h>
> +
> +/* ARM asynchronous clock */
> +#define CONFIG_SYS_AT91_MAIN_CLOCK	12000000	/* 12 MHz crystal */
> +#define CONFIG_SYS_AT91_SLOW_CLOCK	32768
> +#define CONFIG_SYS_HZ			1000
> +
> +#define CONFIG_MACH_TYPE		MACH_TYPE_USB_A9263
> +
> +#define CONFIG_ARCH_CPU_INIT
> +
> +#define CONFIG_CMDLINE_TAG	/* enable passing of ATAGs      */
> +#define CONFIG_SETUP_MEMORY_TAGS
> +#define CONFIG_INITRD_TAG
> +
> +#define CONFIG_SKIP_LOWLEVEL_INIT
> +
> +#define CONFIG_DISPLAY_CPUINFO
> +
> +#define CONFIG_OF_LIBFDT
> +#define CONFIG_SYS_GENERIC_BOARD
> +#define CONFIG_SYS_TEXT_BASE 0x23f00000
> +
> +/*
> + * Hardware drivers
> + */
> +#define CONFIG_ATMEL_LEGACY
> +#define CONFIG_AT91_GPIO
> +
> +/* 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_BOOTDELAY 3
> +
> +/*
> + * BOOTP options
> + */
> +#define CONFIG_BOOTP_BOOTFILESIZE
> +#define CONFIG_BOOTP_BOOTPATH
> +#define CONFIG_BOOTP_GATEWAY
> +#define CONFIG_BOOTP_HOSTNAME
> +
> +/*
> + * 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
> +#undef CONFIG_CMD_NFS
> +
> +#define CONFIG_CMD_PING
> +#define CONFIG_CMD_DHCP
> +#define CONFIG_CMD_NAND
> +
> +/* 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
> +#define CONFIG_SYS_SPI_WRITE_TOUT		(5*CONFIG_SYS_HZ)
> +#define CONFIG_SYS_MAX_DATAFLASH_BANKS		1
> +#define CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0	0xC0000000
> +#define AT91_SPI_CLK			8000000
> +#define DATAFLASH_TCSS			(0x1a << 16)
> +#define DATAFLASH_TCHS			(0x1 << 24)
> +
> +/* no NOR flash */
> +#define CONFIG_SYS_NO_FLASH
> +
> +/* NAND flash */
> +#ifdef CONFIG_CMD_NAND
> +#define CONFIG_NAND_ATMEL
> +#define CONFIG_SYS_MAX_NAND_DEVICE		1
> +#define CONFIG_SYS_NAND_BASE			ATMEL_BASE_CS3
> +/* our ALE is AD21 */
> +#define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
> +/* our CLE is AD22 */
> +#define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)
> +#define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIN_PD15
> +#define CONFIG_SYS_NAND_READY_PIN		AT91_PIN_PA22
> +#endif
> +
> +#define MTDPARTS_DEFAULT "mtdparts=atmel_nand:16m(kernel)ro,120m(root1),-(root2)"
> +
> +/* Ethernet */
> +#define CONFIG_MACB
> +#define CONFIG_RMII
> +#define CONFIG_NET_RETRY_COUNT			20
> +#define CONFIG_MACB_SEARCH_PHY
> +
> +/* USB */
> +#ifdef CONFIG_CMD_USB
> +#define CONFIG_USB_ATMEL
> +#define CONFIG_USB_OHCI_NEW
> +#define CONFIG_DOS_PARTITION
> +#define CONFIG_SYS_USB_OHCI_CPU_INIT
> +#define CONFIG_SYS_USB_OHCI_REGS_BASE		0x00a00000
> +#define CONFIG_SYS_USB_OHCI_SLOT_NAME		"at91sam9263"
> +#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
> +#define CONFIG_USB_STORAGE
> +#define CONFIG_CMD_FAT
> +#endif
> +
> +#define CONFIG_SYS_LOAD_ADDR			0x22000000
> +
> +#define CONFIG_SYS_MEMTEST_START		CONFIG_SYS_SDRAM_BASE
> +#define CONFIG_SYS_MEMTEST_END			0x23e00000
> +
> +/* bootstrap + u-boot + env in dataflash on CS0 */
> +#define CONFIG_ENV_IS_IN_DATAFLASH
> +#define CONFIG_SYS_MONITOR_BASE	(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + 0x4000)
> +#define CONFIG_ENV_OFFSET		0x2000
> +#define CONFIG_ENV_ADDR		(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + \
> +				 CONFIG_ENV_OFFSET)
> +#define CONFIG_ENV_SIZE		0x2000
> +#define CONFIG_BOOTCOMMAND	"nboot 21000000 0"
> +#define CONFIG_BOOTARGS		"console=ttyS0,115200 " \
> +	"root=/dev/mtdblock1 " \
> +	"mtdparts=" MTDPARTS_DEFAULT " " \
> +	"rw rootfstype=jffs2"
> +#define CONFIG_EXTRA_ENV_SETTINGS \
> +	"mtdparts=" MTDPARTS_DEFAULT "\0" \
> +
> +#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_CMDLINE_EDITING
> +#define CONFIG_AUTO_COMPLETE
> +#define CONFIG_SYS_HUSH_PARSER
> +
> +/*
> + * Size of malloc() pool
> + */
> +#define CONFIG_SYS_MALLOC_LEN	ROUND(3 * CONFIG_ENV_SIZE + 128*1024, 0x1000)
> +
> +#endif
> 

Beside these minor complaints there is nothing to stop inclusion for
2014.01. Please stay tuned and do not send v3 immediately cause of the
ongoing change for GPIO API and consolidation of macb reset.
I think another ping from your side in about two weeks would be Ok, if
you haven't seen changes in the two mentioned points on the list.

Best regards

Andreas Bießmann


More information about the U-Boot mailing list