Skip to contentSkip to conversation

arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

PATCH New Mateusz Kulikowski 4 participants 20 messages Oct 27, 2013 – Dec 9, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

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.

---
 board/calao/usb_a9263/Makefile    |  35 ++++++++
 board/calao/usb_a9263/partition.c |  25 ++++++
 board/calao/usb_a9263/usb_a9263.c | 158 ++++++++++++++++++++++++++++++++++
 boards.cfg                        |   1 +
 include/configs/usb_a9263.h       | 175 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 394 insertions(+)
 create mode 100644 board/calao/usb_a9263/Makefile
 create mode 100644 board/calao/usb_a9263/partition.c
 create mode 100644 board/calao/usb_a9263/usb_a9263.c
 create mode 100644 include/configs/usb_a9263.h
board/calao/usb_a9263/Makefile new file +35 -0
new file mode 100644
index 0000000..211752c
@@ -0,0 +1,35 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS-y += usb_a9263.o
+COBJS-$(CONFIG_HAS_DATAFLASH) += partition.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
+
+#########################################################################
board/calao/usb_a9263/partition.c new file +25 -0
new file mode 100644
index 0000000..17cbbf0
@@ -0,0 +1,25 @@
+/*
+ * (C) Copyright 2008-2009
+ * Ulf Samuelsson <[email protected]>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#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 */
+};
+
+/*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_SET, 0, "U-Boot"},
+};
board/calao/usb_a9263/usb_a9263.c new file +158 -0

158 lines not on this page · raw message

boards.cfg +1 -0
index 56af102..601482a 100644
@@ -119,6 +119,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 <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <[email protected]>
+Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <[email protected]>
 Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <[email protected]>
include/configs/usb_a9263.h new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
1.8.4.1
#1 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hi Mateusz Kulikowski,
Add Andreas in loop.

Quoted 98 lines · Mateusz Kulikowski

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.

---
  board/calao/usb_a9263/Makefile    |  35 ++++++++
  board/calao/usb_a9263/partition.c |  25 ++++++
  board/calao/usb_a9263/usb_a9263.c | 158 ++++++++++++++++++++++++++++++++++
  boards.cfg                        |   1 +
  include/configs/usb_a9263.h       | 175 ++++++++++++++++++++++++++++++++++++++
  5 files changed, 394 insertions(+)

create mode 100644 board/calao/usb_a9263/Makefile create mode 100644 board/calao/usb_a9263/partition.c create mode 100644 board/calao/usb_a9263/usb_a9263.c create mode 100644 include/configs/usb_a9263.h

board/calao/usb_a9263/Makefile new file +35 -0
new file mode 100644
index 0000000..211752c
@@ -0,0 +1,35 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS-y += usb_a9263.o
+COBJS-$(CONFIG_HAS_DATAFLASH) += partition.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
+
+#########################################################################
board/calao/usb_a9263/partition.c new file +25 -0
new file mode 100644
index 0000000..17cbbf0
@@ -0,0 +1,25 @@
+/*
+ * (C) Copyright 2008-2009
+ * Ulf Samuelsson <[email protected]>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#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 */
+};
+
+/*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_SET, 0, "U-Boot"},
+};
board/calao/usb_a9263/usb_a9263.c new file +2 -0
new file mode 100644
index 0000000..54c7671
@@ -0,0 +1,158 @@
+/*
+ * (C) Copyright 2007-2013

board/calao/usb_a9263/usb_a9263.c line 12

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/sizes.h>

No where use it (?)

board/calao/usb_a9263/usb_a9263.c line 13

Quoted 1 line
board/calao/usb_a9263/usb_a9263.c new file +1 -0
+#include <asm/arch/at91sam9263.h>

This include can be removed as you include hardware.h.

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+#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)

board/calao/usb_a9263/usb_a9263.c line 33

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+#include <net.h>
+#endif
+#include <netdev.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* ------------------------------------------------------------------------- */
+/*
+ * Miscelaneous platform dependent initialisations
+ */

I think this comment no meaning here.

Quoted 50 lines
board/calao/usb_a9263/usb_a9263.c new file +50 -0
+#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);
+
+	/* Enable NandFlash */
+	at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#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_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
+	at91_rstc_t *rstc = (at91_rstc_t *)ATMEL_BASE_RSTC;
+
+	/* Enable clock */
+	writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+

board/calao/usb_a9263/usb_a9263.c line 94

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+	/*
+	 * 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
+	 */
+	writel(1 << 25, &pio->pioc.pudr);
+	writel((1 << 25) | (1 << 26), &pio->pioe.pudr);

Use GPIO API instead of hard code.

Quoted 9 lines
board/calao/usb_a9263/usb_a9263.c new file +9 -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);
+

board/calao/usb_a9263/usb_a9263.c line 113

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+	/* 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 */
+	writel(1 << 25, &pio->pioc.puer);
+	writel((1 << 25) | (1 << 26), &pio->pioe.puer);

Ditto

board/calao/usb_a9263/usb_a9263.c line 122

Quoted 8 lines
board/calao/usb_a9263/usb_a9263.c new file +8 -0
+	at91_macb_hw_init();
+}
+#endif
+
+int board_init(void)
+{
+	/* arch number of USB-A9263-Board */
+	gd->bd->bi_arch_number = MACH_TYPE_USB_A9263;

Move to board configuration file.

Quoted 21 lines
board/calao/usb_a9263/usb_a9263.c new file +21 -0
+	/* 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 */
+	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)
+{

board/calao/usb_a9263/usb_a9263.c line 153

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+	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;
+
+	(void)bis;

No need this.

Quoted 38 lines
board/calao/usb_a9263/usb_a9263.c new file +5 -0
+#ifdef CONFIG_MACB
+	rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00);
+#endif
+	return rc;
+}
boards.cfg +1 -0
index 56af102..601482a 100644
@@ -119,6 +119,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 <[email protected]>
  Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <[email protected]>
  Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <[email protected]>
+Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <[email protected]>
  Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <[email protected]>
  Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <[email protected]>
  Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <[email protected]>
include/configs/usb_a9263.h new file +15 -0
new file mode 100644
index 0000000..1d36795
@@ -0,0 +1,175 @@
+/*
+ * (C) Copyright 2007-2013
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * 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+
+ */
+

include/configs/usb_a9263.h line 25

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -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_CALAO_USB_A9263	 1	/* Calao USB A 9263 Board       */

No where use it.

Quoted 4 lines
include/configs/usb_a9263.h new file +4 -0
+
+#define CONFIG_ARCH_CPU_INIT
+
+#define CONFIG_CMDLINE_TAG	1	/* enable passing of ATAGs      */

include/configs/usb_a9263.h line 39

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_INITRD_TAG	1
+
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+#define CONFIG_DISPLAY_CPUINFO
+
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

include/configs/usb_a9263.h line 45

Quoted 6 lines
include/configs/usb_a9263.h new file +6 -0
+
+/*
+ * Hardware drivers
+ */
+#define CONFIG_ATMEL_LEGACY
+#define CONFIG_AT91_GPIO	1

Please discard all unnecessary the "1".

include/configs/usb_a9263.h line 54

Quoted 9 lines
include/configs/usb_a9263.h new file +9 -0
+
+/* serial console */
+#define CONFIG_ATMEL_USART	1
+#define CONFIG_USART_BASE	ATMEL_BASE_DBGU
+#define CONFIG_USART_ID		ATMEL_ID_SYS
+#define CONFIG_BAUDRATE		115200
+
+/* LCD */
+#undef CONFIG_LCD

Nowhere define it, so, need need undef it.

Quoted 17 lines
include/configs/usb_a9263.h new file +17 -0
+
+#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

include/configs/usb_a9263.h line 81

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#undef CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#undef CONFIG_CMD_LOADS
+#undef CONFIG_CMD_SOURCE
+#undef CONFIG_CMD_NFS
+/*
+ * U-Boot with enabled USB stack is too big to load properly on default
+ * at91bootstrap.
+ */
+#undef CONFIG_CMD_USB

Ditto.

Quoted 22 lines
include/configs/usb_a9263.h new file +22 -0
+
+#define CONFIG_CMD_PING		1
+#define CONFIG_CMD_DHCP		1
+#define CONFIG_CMD_NAND		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_CS0	0xC0000000
+#define AT91_SPI_CLK			8000000
+#define DATAFLASH_TCSS			(0x1a << 16)
+#define DATAFLASH_TCHS			(0x1 << 24)

include/configs/usb_a9263.h line 113

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+
+/* no NOR flash */
+#define CONFIG_SYS_NO_FLASH			1
+
+/* 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
+#define CONFIG_SYS_NAND_DBW_8			1

No where use it.

Quoted 4 lines
include/configs/usb_a9263.h new file +4 -0
+/* our ALE is AD21 */
+#define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
+/* our CLE is AD22 */
+#define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)

include/configs/usb_a9263.h line 127

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIN_PD15
+#define CONFIG_SYS_NAND_READY_PIN		AT91_PIN_PA22
+#endif
+
+/* Ethernet */
+#define CONFIG_MACB				1
+#define CONFIG_RMII				1
+#define CONFIG_NET_RETRY_COUNT			20
+#define CONFIG_MACB_SEARCH_PHY			1
+#define CONFIG_ETHADDR				00:0D:00:0D:00:AB

For the MAC address, I think we should get from environment or other method, while not hard code it here.

Quoted 39 lines
include/configs/usb_a9263.h new file +38 -0
+
+/* USB */
+#ifdef CONFIG_CMD_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		0x00a00000
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME		"at91sam9263"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
+#define CONFIG_USB_STORAGE		        1
+#define CONFIG_CMD_FAT			        1
+#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	1
+#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=atmel_nand:16m(kernel)ro,120m(root1),-(root2)"\
+	"rw rootfstype=jffs2"
+
+#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

include/configs/usb_a9263.h line 175

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#define CONFIG_CMDLINE_EDITING	1
+#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

Best Regards,
Bo Shen

#2 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 4 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

On 10/28/2013 03:34, Mateusz Kulikowski wrote:

(...)

Quoted 11 lines

board/calao/usb_a9263/usb_a9263.c line 94

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+    /*
+     * 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
+     */
+    writel(1 << 25, &pio->pioc.pudr);
+    writel((1 << 25) | (1 << 26), &pio->pioe.pudr);
Quoted 1 line

Use GPIO API instead of hard code.

Should I also update (in separate patch) at91sam9263ek board (code is the same there, bad side is - I don't have that board to test)?

Quoted 4 lines

include/configs/usb_a9263.h line 39

Quoted 2 lines
include/configs/usb_a9263.h new file +2 -0
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

- I can change it, but it will not boot on "stock" board - should we force people to recompile AT91bootstrap if they want to use new U-Boot? or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?
or
- There is another way I'm not aware of (perhaps relocate U-Boot in RAM)?

Best Regards,
Mateusz Kulikowski

#3 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hello Mateusz,

Am 28.10.2013 22:30, schrieb Mateusz Kulikowski:

Quoted 10 lines

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 4 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

On 10/28/2013 03:34, Mateusz Kulikowski wrote:

(...)

[...]

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

Do you have the source code?

Quoted 2 lines

- I can change it, but it will not boot on "stock" board - should we force people to recompile AT91bootstrap if they want to use new U-Boot?

Not the preferred way ...

Quoted 3 lines

or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?

Thats the way I would prefer! We decided for the siemens at91 board ports I recently posted, see here:

[U-Boot,v1,1/3] at91: add defines for reset type
http://patchwork.ozlabs.org/patch/285365/

[U-Boot,v1,2/3] arm, at91: add Siemens board taurus (based on AT91SAM9G20)
http://patchwork.ozlabs.org/patch/285366/

[U-Boot,v1,3/3] arm, at91: add siemens corvus board
http://patchwork.ozlabs.org/patch/285367/

to start a try using spl instead of at91bootstrap. I hope to get this ASAP (serial output works :-) running and post a RFC patch. They boot from NAND but that should be no big problem to add dataflash support ...

Quoted 2 lines

or
- There is another way I'm not aware of (perhaps relocate U-Boot in RAM)?

You need always some first stage bootloader, currently this is at91bootstrap, but we should integrate this into U-Boot SPL code ...

U-Boot gets relocated in RAM, but that is later in the boot process...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#4 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hi Heiko,

Sorry for late reply.

Quoted 4 lines · Heiko Schocher
Quoted 2 lines

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

Do you have the source code?

Yes I do, it even seems to work properly after recompilation (with baremetal toolchain).

I should be able to do low-level init for this board.
Of course, first - SPL support for AT91 must be ready if I understand correctly (who will do it is different thing).

Regards,
Mateusz

#5 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Mateusz Kulikowski

Hi Mateusz Kulikowski,

Quoted 21 lines · Mateusz Kulikowski

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 4 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

On 10/28/2013 03:34, Mateusz Kulikowski wrote:

(...)

Quoted 11 lines
Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+    /*
+     * 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
+     */
+    writel(1 << 25, &pio->pioc.pudr);
+    writel((1 << 25) | (1 << 26), &pio->pioe.pudr);
Quoted 4 lines
Quoted 1 line

Use GPIO API instead of hard code.

Should I also update (in separate patch) at91sam9263ek board (code is the same there, bad side is - I don't have that board to test)?

You can use GPIO API for USB-A9263 in this patch. And send another patch to fix at91sam9263ek board (I can help test the patch for at91sam9263ek board).

Quoted 9 lines
Quoted 5 lines

include/configs/usb_a9263.h line 39

Quoted 2 lines
include/configs/usb_a9263.h new file +2 -0
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

Yes, that's true. And this is a pain for us :(
Here just a reminder for the text base.

Quoted 2 lines

- I can change it, but it will not boot on "stock" board - should we force people to recompile AT91bootstrap if they want to use new U-Boot?

(If you plan to modify the text base, you must ask for that.) For new version bootstrap, we have change this address to 0x21f00000 for boards only have 64MiB SDRAM.

Quoted 3 lines

or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?

I am working for SPL for Atmel EK boards, now focus on sama5d3xek board. After finished, I will submit then patch and go on working for other board.

Quoted 5 lines

or
- There is another way I'm not aware of (perhaps relocate U-Boot in RAM)?

Best Regards,
Mateusz Kulikowski

Best Regards,
Bo Shen

#6 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hello Bo,

Am 29.10.2013 06:24, schrieb Bo Shen:

Quoted 13 lines

Hi Mateusz Kulikowski,

Quoted 10 lines · Mateusz Kulikowski

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 4 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

On 10/28/2013 03:34, Mateusz Kulikowski wrote:

(...)

[...]

Quoted 5 lines
Quoted 3 lines

or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?

I am working for SPL for Atmel EK boards, now focus on sama5d3xek board. After finished, I will submit then patch and go on working for other board.

We just decided to go this way for the siemens boards too... (Just started, serial seems to work in spl code)

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#7 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Bo Shen

Hi,

Quoted 3 lines · Bo Shen

You can use GPIO API for USB-A9263 in this patch. And send another patch to fix at91sam9263ek board (I can help test the patch for at91sam9263ek board).

Will do it in next 2 days (unless someone will be faster).

Quoted 5 lines
Quoted 3 lines

or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?

I am working for SPL for Atmel EK boards, now focus on sama5d3xek board. After finished, I will submit then patch and go on working for other board.

Like I wrote in other mail, I should be able to do lowlevel init for this board. Just have to read/learn/play with SPL first (never used it before). But this part I prefer to do later (somewhere next month).

Regards,
Mateusz

#8 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Mateusz Kulikowski

Dear Mateusz Kulikowski,

Quoted 20 lines · Mateusz Kulikowski

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 10 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

include/configs/usb_a9263.h line 39

Quoted 2 lines · Mateusz Kulikowski
include/configs/usb_a9263.h new file +2 -0
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

Quoted 7 lines

- I can change it, but it will not boot on "stock" board - should we force people to recompile AT91bootstrap if they want to use new U-Boot? or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?
or
- There is another way I'm not aware of (perhaps relocate U-Boot in RAM)?

The crux is that in fact u-boot is relocating u-boot in any case (the most cases). It will place some stuff at the very top of the RAM (gd_t, malloc arena, stack, ...) and calculate depending on some runtime values (reserved ram, display vram, ...) where to place the resulting u-boot image. The u-boot image will be placed right after the reserved place to fill up the whole top of your RAM.
Therefore it depends on your compile time and runtime setup if there will be an overlapping between running u-boot image and resulting place when doing the relocation. It is likely to collide with the running u-boot image while relocating if it is placed just 1MiB from top of the RAM.

We decided to change at91bootstrap and u-boot for to have another load address for some boards in the past cause of real problems there. There where strange errors like running system but crashing when using a specific command.

I really recommend to leave a bit more space for u-boot runtime code to do it's relocation ad therefore use a smaller ram location. The best would be to get SPL working ASAP to have the setup of load address in just one piece of code ... A long outstanding wish of mine, but had no time to implement.

Bo and Heiko, could you both please post some RFC of your code to get this in line?

Best regards

Andreas Bie?mann

#9 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hello Andreas,

Am 29.10.2013 07:26, schrieb Andreas Bie?mann:

Quoted 42 lines

Dear Mateusz Kulikowski,

Quoted 20 lines · Mateusz Kulikowski

Hi Bo Shen,

Thanks for the check, please see below.

Quoted 10 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

include/configs/usb_a9263.h line 39

Quoted 2 lines · Mateusz Kulikowski
include/configs/usb_a9263.h new file +2 -0
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

I don't understand something here:
- this address is hardcoded in AT91bootstrap (as well as image size - 0x31000),

Quoted 7 lines

- I can change it, but it will not boot on "stock" board - should we force people to recompile AT91bootstrap if they want to use new U-Boot? or
- Should I add low-level initialization to boot U-Boot from Dataflash without AT91bootstrap (this is a bit more work)?
or
- There is another way I'm not aware of (perhaps relocate U-Boot in RAM)?

The crux is that in fact u-boot is relocating u-boot in any case (the most cases). It will place some stuff at the very top of the RAM (gd_t, malloc arena, stack, ...) and calculate depending on some runtime values (reserved ram, display vram, ...) where to place the resulting u-boot image. The u-boot image will be placed right after the reserved place to fill up the whole top of your RAM.
Therefore it depends on your compile time and runtime setup if there will be an overlapping between running u-boot image and resulting place when doing the relocation. It is likely to collide with the running u-boot image while relocating if it is placed just 1MiB from top of the RAM.

Quoted 4 lines

We decided to change at91bootstrap and u-boot for to have another load address for some boards in the past cause of real problems there. There where strange errors like running system but crashing when using a specific command.

Yep, see this on my recently posted boards too ...

Quoted 3 lines

I really recommend to leave a bit more space for u-boot runtime code to do it's relocation ad therefore use a smaller ram location. The best would be to get SPL working ASAP to have the setup of load

Full Ack.

Quoted 5 lines

address in just one piece of code ... A long outstanding wish of mine, but had no time to implement.

Bo and Heiko, could you both please post some RFC of your code to get this in line?

I just started with it, I have only serial running under SPL Code, need to write a small nand driver ... clean up ... and then I can post a RFC ... hope to do this soon ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#10 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Bo Shen

Dear Mateusz Kulikowski,

some comments additional to Bo's.

Quoted 94 lines · Bo Shen

Hi Mateusz Kulikowski,
Add Andreas in loop.

Quoted 90 lines · Mateusz Kulikowski

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.

---
  board/calao/usb_a9263/Makefile    |  35 ++++++++
  board/calao/usb_a9263/partition.c |  25 ++++++
  board/calao/usb_a9263/usb_a9263.c | 158
++++++++++++++++++++++++++++++++++
  boards.cfg                        |   1 +
  include/configs/usb_a9263.h       | 175
++++++++++++++++++++++++++++++++++++++
  5 files changed, 394 insertions(+)

create mode 100644 board/calao/usb_a9263/Makefile create mode 100644 board/calao/usb_a9263/partition.c create mode 100644 board/calao/usb_a9263/usb_a9263.c create mode 100644 include/configs/usb_a9263.h

board/calao/usb_a9263/Makefile new file +35 -0
new file mode 100644
index 0000000..211752c
@@ -0,0 +1,35 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:    GPL-2.0+
+
+include $(TOPDIR)/config.mk
+
+LIB    = $(obj)lib$(BOARD).o
+
+COBJS-y += usb_a9263.o
+COBJS-$(CONFIG_HAS_DATAFLASH) += partition.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
+
+#########################################################################
board/calao/usb_a9263/partition.c new file +4 -0
new file mode 100644
index 0000000..17cbbf0
@@ -0,0 +1,25 @@
+/*
+ * (C) Copyright 2008-2009
+ * Ulf Samuelsson <[email protected]>
+ * Thomas Petazzoni, Free Electrons,

<[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */

board/calao/usb_a9263/partition.c new file +9 -0
+#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 */

Quoted 8 lines

board/calao/usb_a9263/partition.c line 25

Quoted 8 lines
board/calao/usb_a9263/partition.c new file +8 -0
+};
+
+/*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_SET, 0, "U-Boot"},
+};

I would really like to see that removed. The dataflash thing is another part on my todo list. The common mtd code can handle these devices too (see for example at91sam9n12ek, at91sam9x5ek, ethernut5 sam5d3xek and top9000). I did some short testing on that for at91sam9263ek (at home, never sent to the list) and it worked basically. Will see if I find it this evening, clean up and post it this evening CET.

Quoted 174 lines
Quoted 17 lines
board/calao/usb_a9263/usb_a9263.c new file +5 -0
new file mode 100644
index 0000000..54c7671
@@ -0,0 +1,158 @@
+/*
+ * (C) Copyright 2007-2013
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons,

<[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */

board/calao/usb_a9263/usb_a9263.c line 12

Quoted 3 lines
board/calao/usb_a9263/usb_a9263.c new file +3 -0
+
+#include <common.h>
+#include <asm/sizes.h>

No where use it (?)

Quoted 1 line

+#include <asm/arch/at91sam9263.h>

This include can be removed as you include hardware.h.

Quoted 18 lines
board/calao/usb_a9263/usb_a9263.c new file +17 -1
+#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)
+#include <net.h>
+#endif
+#include <netdev.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
-------------------------------------------------------------------------
Quoted 4 lines

*/
+/*
+ * Miscelaneous platform dependent initialisations
+ */

I think this comment no meaning here.

Quoted 50 lines
board/calao/usb_a9263/usb_a9263.c new file +50 -0
+#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);
+
+    /* Enable NandFlash */
+    at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#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_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
+    at91_rstc_t *rstc = (at91_rstc_t *)ATMEL_BASE_RSTC;
+
+    /* Enable clock */
+    writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+

board/calao/usb_a9263/usb_a9263.c line 94

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+    /*
+     * 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
+     */
+    writel(1 << 25, &pio->pioc.pudr);
+    writel((1 << 25) | (1 << 26), &pio->pioe.pudr);

Use GPIO API instead of hard code.

Quoted 9 lines
board/calao/usb_a9263/usb_a9263.c new file +9 -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);
+

board/calao/usb_a9263/usb_a9263.c line 113

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+    /* 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 */
+    writel(1 << 25, &pio->pioc.puer);
+    writel((1 << 25) | (1 << 26), &pio->pioe.puer);

Ditto

board/calao/usb_a9263/usb_a9263.c line 122

Quoted 8 lines
board/calao/usb_a9263/usb_a9263.c new file +8 -0
+    at91_macb_hw_init();
+}
+#endif
+
+int board_init(void)
+{
+    /* arch number of USB-A9263-Board */
+    gd->bd->bi_arch_number = MACH_TYPE_USB_A9263;

Move to board configuration file.

Quoted 26 lines
board/calao/usb_a9263/usb_a9263.c new file +8 -0
+    /* 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 */

board/calao/usb_a9263/usb_a9263.c new file +17 -0
+    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;
+}
Quoted 8 lines

board/calao/usb_a9263/usb_a9263.c line 153

Quoted 6 lines
board/calao/usb_a9263/usb_a9263.c new file +6 -0
+
+int board_eth_init(bd_t *bis)
+{
+    int rc = 0;
+
+    (void)bis;

No need this.

A good way to avoid 'unused parameter' warnings is to just leave the parameter name out (i.e. use 'int board_eth_init(bd_t *)').

Quoted 76 lines
Quoted 72 lines
board/calao/usb_a9263/usb_a9263.c new file +5 -0
+#ifdef CONFIG_MACB
+    rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00);
+#endif
+    return rc;
+}
boards.cfg +0 -0
index 56af102..601482a 100644
@@ -119,6 +119,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 <[email protected]>
Active arm arm926ejs at91 calao
tny_a9260 tny_a9g20_eeprom
tny_a9260:AT91SAM9G20,SYS_USE_EEPROM
Albin Tonnerre <[email protected]>
Active arm arm926ejs at91 calao
tny_a9260 tny_a9g20_nandflash
tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH Albin Tonnerre <[email protected]>
+Active arm arm926ejs at91 calao
usb_a9263 usb_a9263_dataflash
usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH Mateusz Kulikowski <[email protected]>
Active arm arm926ejs at91 egnite
ethernut5 ethernut5
ethernut5:AT91SAM9XE
egnite GmbH <[email protected]>
Active arm arm926ejs at91 emk
top9000 top9000eval_xe
top9000:EVAL9000
Reinhard Meyer <[email protected]>
Active arm arm926ejs at91 emk
top9000 top9000su_xe
top9000:SU9000
Reinhard Meyer <[email protected]>

include/configs/usb_a9263.h new file +5 -0
new file mode 100644
index 0000000..1d36795
@@ -0,0 +1,175 @@
+/*
+ * (C) Copyright 2007-2013
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons,

<[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * 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+
+ */

include/configs/usb_a9263.h new file +11 -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_CALAO_USB_A9263     1    /* Calao USB A 9263
Quoted 1 line

Board */

No where use it.

Quoted 6 lines

include/configs/usb_a9263.h line 31

Quoted 6 lines
include/configs/usb_a9263.h new file +6 -0
+
+#define CONFIG_ARCH_CPU_INIT
+
+#define CONFIG_CMDLINE_TAG    1    /* enable passing of ATAGs      */
+#define CONFIG_SETUP_MEMORY_TAGS 1
+#define CONFIG_INITRD_TAG    1

Please do not set a value where just the 'is defined' state is tested.

Quoted 11 lines

include/configs/usb_a9263.h line 39

Quoted 8 lines
include/configs/usb_a9263.h new file +8 -0
+
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+#define CONFIG_DISPLAY_CPUINFO
+
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

As mentioned in another mail. Just one point more. It is up to you to set a correct value here. It may be ok for your setup to just leave 1MiB to top of RAM, but I doubt it really works in any case cause of the relocation. Please hack the code and print out the '__image_copy_start' and '__image_copy_end' symbol position before and after relocate_code(). Beware, arm moved to generic relocation, you have to look up common/board_[fr].c.
Also it may happen that the relocation clobbers some stuff in rel_dyn or bss sections.
If you can prove it will not collide at that position I'm fine to take it as is.

Quoted 128 lines

include/configs/usb_a9263.h line 45

Quoted 7 lines
include/configs/usb_a9263.h new file +6 -0
+
+/*
+ * Hardware drivers
+ */
+#define CONFIG_ATMEL_LEGACY
+#define CONFIG_AT91_GPIO    1

Please discard all unnecessary the "1".

include/configs/usb_a9263.h line 54

Quoted 9 lines
include/configs/usb_a9263.h new file +9 -0
+
+/* serial console */
+#define CONFIG_ATMEL_USART    1
+#define CONFIG_USART_BASE    ATMEL_BASE_DBGU
+#define CONFIG_USART_ID        ATMEL_ID_SYS
+#define CONFIG_BAUDRATE        115200
+
+/* LCD */
+#undef CONFIG_LCD

Nowhere define it, so, need need undef it.

Quoted 17 lines
include/configs/usb_a9263.h new file +17 -0
+
+#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

include/configs/usb_a9263.h line 81

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#undef CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#undef CONFIG_CMD_LOADS
+#undef CONFIG_CMD_SOURCE
+#undef CONFIG_CMD_NFS
+/*
+ * U-Boot with enabled USB stack is too big to load properly on default
+ * at91bootstrap.
+ */
+#undef CONFIG_CMD_USB

Ditto.

Quoted 22 lines
include/configs/usb_a9263.h new file +22 -0
+
+#define CONFIG_CMD_PING        1
+#define CONFIG_CMD_DHCP        1
+#define CONFIG_CMD_NAND        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_CS0    0xC0000000
+#define AT91_SPI_CLK            8000000
+#define DATAFLASH_TCSS            (0x1a << 16)
+#define DATAFLASH_TCHS            (0x1 << 24)

include/configs/usb_a9263.h line 113

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+
+/* no NOR flash */
+#define CONFIG_SYS_NO_FLASH            1
+
+/* 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
+#define CONFIG_SYS_NAND_DBW_8            1

No where use it.

Quoted 4 lines
include/configs/usb_a9263.h new file +4 -0
+/* our ALE is AD21 */
+#define CONFIG_SYS_NAND_MASK_ALE        (1 << 21)
+/* our CLE is AD22 */
+#define CONFIG_SYS_NAND_MASK_CLE        (1 << 22)

include/configs/usb_a9263.h line 127

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#define CONFIG_SYS_NAND_ENABLE_PIN        AT91_PIN_PD15
+#define CONFIG_SYS_NAND_READY_PIN        AT91_PIN_PA22
+#endif
+
+/* Ethernet */
+#define CONFIG_MACB                1
+#define CONFIG_RMII                1
+#define CONFIG_NET_RETRY_COUNT            20
+#define CONFIG_MACB_SEARCH_PHY            1
+#define CONFIG_ETHADDR                00:0D:00:0D:00:AB

For the MAC address, I think we should get from environment or other method, while not hard code it here.

Quoted 23 lines
include/configs/usb_a9263.h new file +22 -0
+
+/* USB */
+#ifdef CONFIG_CMD_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        0x00a00000
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME        "at91sam9263"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS    2
+#define CONFIG_USB_STORAGE                1
+#define CONFIG_CMD_FAT                    1
+#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    1
+#define CONFIG_SYS_MONITOR_BASE   

(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + 0x4000)

Quoted 8 lines

include/configs/usb_a9263.h line 157

Quoted 8 lines
include/configs/usb_a9263.h new file +8 -0
+#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=atmel_nand:16m(kernel)ro,120m(root1),-(root2)"\

Just a pointer ... you could use the CONFIG_CMD_MTDPARTS define. The same mtdparts provided to the kernel could be used in u-boot -> 'nboot kernel'. Some newer at91 boards use that, I personally find it quite useful.

Quoted 9 lines
Quoted 9 lines
include/configs/usb_a9263.h new file +9 -0
+    "rw rootfstype=jffs2"
+
+#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
Quoted 8 lines
Quoted 8 lines
include/configs/usb_a9263.h new file +7 -0
+#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)

Malloc is 152KiB, gd_t is smaller than 1KiB, your u-boot is smaller than 196KiB (as you mention in some comment) ... It may fit into the 1MiB gap, if there is no other runtime defined parameters changing the relocation address ...
But this is only true if you do not add more features, for example ubi(fs) which has some more runtime code and requires more than 512KiB malloc arena, about 4MiB recommended. Yust my 2?, you should really have a look for ubi(fs) when using NAND devices ...

Apart from that your patch looks good. Please address my concern about dataflash driver and Bo's comments and send a v2 for inclusion.

Best regards

Andreas Bie?mann

#11 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Dear Andreas Bie?mann,

Quoted 6 lines · Andreas Bie?mann
Quoted 6 lines
Quoted 6 lines
board/calao/usb_a9263/partition.c new file +6 -0
+
+/*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_SET, 0, "U-Boot"},
Quoted 8 lines
Quoted 1 line
Quoted 1 line

+};

I would really like to see that removed. The dataflash thing is another part on my todo list. The common mtd code can handle these devices too (see for example at91sam9n12ek, at91sam9x5ek, ethernut5 sam5d3xek and top9000). I did some short testing on that for at91sam9263ek (at home, never sent to the list) and it worked basically. Will see if I find it this evening, clean up and post it this evening CET.

What kind of Dataflash have you used?

Dataflash on Calao (at45db021b) does not have read-id command. It also has different command set than more recent version (*021d). It may be tricky to probe and operate it without modifying SPI drivers.

For now I will move partition code to "main" board file; If I figure out how to handle that Dataflash - I'll update the code. Unless I'm missing something?

Quoted 11 lines
Quoted 8 lines

board/calao/usb_a9263/usb_a9263.c line 153

Quoted 6 lines
board/calao/usb_a9263/usb_a9263.c new file +6 -0
+
+int board_eth_init(bd_t *bis)
+{
+    int rc = 0;
+
+    (void)bis;

No need this.

A good way to avoid 'unused parameter' warnings is to just leave the parameter name out (i.e. use 'int board_eth_init(bd_t *)').

AFAIK this doesn't go well with C, and will not work on default compile flags set by u-boot.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#define CONFIG_SYS_TEXT_BASE 0x23f00000

This address should be considered as u-boot is top down map, so if your system only 64MiB, there is only 1MiB left.

Quoted 11 lines

As mentioned in another mail. Just one point more. It is up to you to set a correct value here. It may be ok for your setup to just leave 1MiB to top of RAM, but I doubt it really works in any case cause of the relocation. Please hack the code and print out the '__image_copy_start' and '__image_copy_end' symbol position before and after relocate_code(). Beware, arm moved to generic relocation, you have to look up common/board_[fr].c.
Also it may happen that the relocation clobbers some stuff in rel_dyn or bss sections.
If you can prove it will not collide at that position I'm fine to take it as is.

Thanks for the tip about board_[fr] - I was not aware of it and used old boot mechanism. I'll update config file to use generic board code.

As for the memory concerns, I did little test:
- enabled debugs in board_[fr].c (they print nicely memory layout),
- Filled u-boot binary with commands/garbage to reach max size supported by AT91bootstrap (200704)
- Flashed, booted the board. Below - log (parts):
<log>
U-Boot 2013.10-00122-g509dca7-dirty (Nov 01 2013 - 20:09:46)

U-Boot code: 23F00000 -> 23F2C570  BSS: -> 23F31498
CPU: AT91SAM9263
Crystal frequency:       12 MHz
CPU clock        :      180 MHz
Master clock     :       90 MHz
DRAM:  Monitor len: 00031498
Ram size: 04000000
Ram top: 24000000

TLB table from 23ff0000 to 23ff4000
Reserving 197k for U-Boot at: 23fbe000
Reserving 152k for malloc() at: 23f98000
Reserving 84 Bytes for Board Info at: 23f97fac
Reserving 176 Bytes for Global Data at: 23f97efc

RAM Configuration:
Bank #0: 20000000
DRAM: 64 MiB
New Stack Pointer is: 23f97ed0
Relocation Offset is: 000be000
Relocating to 23fbe000, new gd at 23f97efc, sp at 23f97ed0
image_copy: 23f00000 23f2c570 <- @setup_reloc()
image_copy: 23fbe000 23fea570 <- @board_init_r()
WARNING: Caches not enabled
Now running in RAM - U-Boot at: 23fbe000
</log>

If I understand correctly, this means that we have plenty of space between start of stack, and end of non-relocated U-Boot (.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + 0x4000)

include/configs/usb_a9263.h new file +4 -0
+#define CONFIG_ENV_OFFSET        0x2000
+#define CONFIG_ENV_ADDR        (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + \
+                 CONFIG_ENV_OFFSET)
+#define CONFIG_ENV_SIZE        0x2000
Quoted 8 lines
Quoted 4 lines

include/configs/usb_a9263.h line 157

Quoted 4 lines
include/configs/usb_a9263.h new file +4 -0
+#define CONFIG_BOOTCOMMAND    "nboot 21000000 0"
+#define CONFIG_BOOTARGS        "console=ttyS0,115200 " \
+    "root=/dev/mtdblock1 " \
+    "mtdparts=atmel_nand:16m(kernel)ro,120m(root1),-(root2)"\

Just a pointer ... you could use the CONFIG_CMD_MTDPARTS define. The same mtdparts provided to the kernel could be used in u-boot -> 'nboot kernel'. Some newer at91 boards use that, I personally find it quite useful.

I'll do it after I have SPL working - it will not fit now.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
include/configs/usb_a9263.h new file +5 -0
+
+/*
+ * Size of malloc() pool
+ */
+#define CONFIG_SYS_MALLOC_LEN    ROUND(3 * CONFIG_ENV_SIZE +

128*1024, 0x1000)

Quoted 8 lines

Malloc is 152KiB, gd_t is smaller than 1KiB, your u-boot is smaller than 196KiB (as you mention in some comment) ... It may fit into the 1MiB gap, if there is no other runtime defined parameters changing the relocation address ...
But this is only true if you do not add more features, for example ubi(fs) which has some more runtime code and requires more than 512KiB malloc arena, about 4MiB recommended. Yust my 2?, you should really have a look for ubi(fs) when using NAND devices ...

It will not be possible to add more features until I get rid of AT91bootstrap.
I prefer to stick to config that may used on "stock" boards (kernel is located on separate partition, so no FS driver is needed)

Quoted 3 lines

Apart from that your patch looks good. Please address my concern about dataflash driver and Bo's comments and send a v2 for inclusion.

I will post v2 soon.

Best Regards,
Mateusz

#12 lore raw

PATCH 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Dear Mateusz Kulikowski,

Quoted 16 lines · Mateusz Kulikowski
Quoted 6 lines · Andreas Bie?mann
Quoted 6 lines
Quoted 6 lines
board/calao/usb_a9263/partition.c new file +6 -0
+
+/*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_SET, 0, "U-Boot"},
Quoted 8 lines
Quoted 1 line
Quoted 1 line

+};

I would really like to see that removed. The dataflash thing is another part on my todo list. The common mtd code can handle these devices too (see for example at91sam9n12ek, at91sam9x5ek, ethernut5 sam5d3xek and top9000). I did some short testing on that for at91sam9263ek (at home, never sent to the list) and it worked basically. Will see if I find it this evening, clean up and post it this evening CET.

Quoted 5 lines

What kind of Dataflash have you used?

Dataflash on Calao (at45db021b) does not have read-id command. It also has different command set than more recent version (*021d). It may be tricky to probe and operate it without modifying SPI drivers.

Sorry, haven't realized that. I have to check which dataflash was attached to that board.

Quoted 2 lines

For now I will move partition code to "main" board file; If I figure out how to handle that Dataflash - I'll update the code.

fine!

<snip>

Quoted 9 lines

As for the memory concerns, I did little test:
- enabled debugs in board_[fr].c (they print nicely memory layout),
- Filled u-boot binary with commands/garbage to reach max size supported by AT91bootstrap (200704)
- Flashed, booted the board. Below - log (parts):
<log>
U-Boot 2013.10-00122-g509dca7-dirty (Nov 01 2013 - 20:09:46)

U-Boot code: 23F00000 -> 23F2C570 BSS: -> 23F31498

Your code uses 23f00000 up to 23f31498, is 197.15 KiB

Quoted 7 lines
CPU: AT91SAM9263
Crystal frequency:       12 MHz
CPU clock        :      180 MHz
Master clock     :       90 MHz
DRAM:  Monitor len: 00031498
Ram size: 04000000
Ram top: 24000000
Quoted 5 lines

TLB table from 23ff0000 to 23ff4000
Reserving 197k for U-Boot at: 23fbe000
Reserving 152k for malloc() at: 23f98000
Reserving 84 Bytes for Board Info at: 23f97fac
Reserving 176 Bytes for Global Data at: 23f97efc

The relocated environment will use the top of RAM down to 23f97efc

Quoted 13 lines

RAM Configuration:
Bank #0: 20000000
DRAM: 64 MiB
New Stack Pointer is: 23f97ed0
Relocation Offset is: 000be000
Relocating to 23fbe000, new gd at 23f97efc, sp at 23f97ed0
image_copy: 23f00000 23f2c570 <- @setup_reloc()
image_copy: 23fbe000 23fea570 <- @board_init_r()
WARNING: Caches not enabled
Now running in RAM - U-Boot at: 23fbe000
</log>

Quoted 2 lines

If I understand correctly, this means that we have plenty of space between start of stack, and end of non-relocated U-Boot (.

_plenty_ of space is not true here (in my understanding), but 410 KiB will be enough ;)

<snip>

Best regards

Andreas Bie?mann

#13 lore raw

PATCH v2 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Andreas Bießmann

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.

---
 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
board/calao/usb_a9263/Makefile new file +34 -0
new file mode 100644
index 0000000..dc87684
@@ -0,0 +1,34 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# 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
+
+#########################################################################
board/calao/usb_a9263/usb_a9263.c new file +167 -0

167 lines not on this page · raw message

boards.cfg +1 -0
index 5e10125..48d6c53 100644
@@ -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 <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <[email protected]>
+Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <[email protected]>
 Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <[email protected]>
include/configs/usb_a9263.h new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
1.8.4.1
#14 lore raw

PATCH v2 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Dear Mateusz Kulikowski,

Quoted 46 lines · Mateusz Kulikowski

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.

---
 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
board/calao/usb_a9263/Makefile new file +24 -0
new file mode 100644
index 0000000..dc87684
@@ -0,0 +1,34 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# 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)

board/calao/usb_a9263/Makefile line 34

Quoted 10 lines
board/calao/usb_a9263/Makefile new file +10 -0
+	$(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.

Quoted 17 lines
board/calao/usb_a9263/usb_a9263.c new file +11 -0
new file mode 100644
index 0000000..bbc1e25
@@ -0,0 +1,167 @@
+/*
+ * (C) Copyright 2007-2013
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>

board/calao/usb_a9263/usb_a9263.c line 21

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+#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?

Quoted 47 lines
board/calao/usb_a9263/usb_a9263.c new file +47 -0
+#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);

board/calao/usb_a9263/usb_a9263.c line 78

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+
+	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?

board/calao/usb_a9263/usb_a9263.c line 81

Quoted 3 lines
board/calao/usb_a9263/usb_a9263.c new file +3 -0
+
+	/* 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.

Quoted 36 lines
board/calao/usb_a9263/usb_a9263.c new file +36 -0
+}
+#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))
+		;

board/calao/usb_a9263/usb_a9263.c line 127

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+
+	/* 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?

board/calao/usb_a9263/usb_a9263.c line 140

Quoted 13 lines
board/calao/usb_a9263/usb_a9263.c new file +13 -0
+}
+#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?

Quoted 204 lines
board/calao/usb_a9263/usb_a9263.c new file +27 -0
+	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;
+}
boards.cfg +1 -0
index 5e10125..48d6c53 100644
@@ -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 <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <[email protected]>
+Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <[email protected]>
 Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <[email protected]>
include/configs/usb_a9263.h new file +158 -0
new file mode 100644
index 0000000..6d1f43f
@@ -0,0 +1,168 @@
+/*
+ * (C) Copyright 2007-2013
+ * Stelian Pop <[email protected]>
+ * Lead Tech Design <www.leadtechdesign.com>
+ * Thomas Petazzoni, Free Electrons, <[email protected]>
+ * Mateusz Kulikowski <[email protected]>
+ *
+ * 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)

include/configs/usb_a9263.h line 168

Quoted 10 lines
include/configs/usb_a9263.h new file +10 -0
+#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

#15 lore raw

PATCH v2 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Hello Andreas,

Am 11.11.2013 12:03, schrieb Andreas Bie?mann:

Quoted 19 lines

Dear Mateusz Kulikowski,

Quoted 16 lines · Mateusz Kulikowski

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.

---
  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

[...]

Quoted 6 lines
Quoted 6 lines
board/calao/usb_a9263/usb_a9263.c new file +0 -0
new file mode 100644
index 0000000..bbc1e25
@@ -0,0 +1,167 @@

[...]

Quoted 46 lines
Quoted 33 lines
board/calao/usb_a9263/usb_a9263.c new file +33 -0
+#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))
+		;

board/calao/usb_a9263/usb_a9263.c line 127

Quoted 10 lines
board/calao/usb_a9263/usb_a9263.c new file +10 -0
+
+	/* 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.

Quoted 1 line

@Heiko will you send another patch?

I thought I wait for your GPIO update patches, and rebase my patch- serie for the siemens boards on them ...

Ok, based on the spl patches from bo shen, see

http://lists.denx.de/pipermail/u-boot/2013-November/166272.html

I can sent soon the "phy_reset" patch, if the patch passes a "MAKEALL" ;-)

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#16 lore raw

PATCH v2 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

In reply to Andreas Bießmann

Dear Andreas Bie?mann,

On 11.11.2013 12:03, Andreas Bie?mann wrote:
(...)

Quoted 4 lines

board/calao/usb_a9263/usb_a9263.c line 21

Quoted 2 lines
board/calao/usb_a9263/usb_a9263.c new file +2 -0
+#include <asm/arch/hardware.h>
+#if defined(CONFIG_MACB)

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

No problem with that.

Quoted 8 lines

board/calao/usb_a9263/usb_a9263.c line 78

Quoted 5 lines
board/calao/usb_a9263/usb_a9263.c new file +5 -0
+
+	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?

I've checked schematics - board has external pull-ups, so I can use generic GPIO.

Quoted 9 lines

board/calao/usb_a9263/usb_a9263.c line 81

Quoted 3 lines
board/calao/usb_a9263/usb_a9263.c new file +3 -0
+
+	/* 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.

Quoted 5 lines

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.

Do I understand correctly, that for all ports that I use (via generic GPIO) I should create "temporary" defines (with hardcoded gpio#)?

Perhaps I'm missing something, but I currently see no other way to get GPIO# (It will change once your RFC is included).

Of course CONFIG_ATMEL_LEGACY has to stay, as atmel_nand uses CONFIG_SYS_NAND_*_PIN and is still using old API (I guess this also needs fixing).

Quoted 8 lines

board/calao/usb_a9263/usb_a9263.c line 127

Quoted 6 lines
board/calao/usb_a9263/usb_a9263.c new file +6 -0
+	/* 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.

+1

I will also switch usb_a9263_macb_hw_init() to generic GPIO (and remove re-enabling of pull-ups as they are dropped by at91_macb_hw_init).

Quoted 6 lines

board/calao/usb_a9263/usb_a9263.c line 140

Quoted 2 lines
board/calao/usb_a9263/usb_a9263.c new file +2 -0
+#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?

I copied (see at91sam9263ek.c:256).
I've checked board schematics and this pin is floating, so for v3 I'll drop it.

Quoted 6 lines

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.

Ping :)
Do I understand correctly, that phy_reset RFC will be soon applied, then I should post v3? Or should I wait for your GPIO RFC?

In the meantime I will start playing with SPL, as u-boot image grows slowly and soon I'll be forced to cut another features just to keep it small enough.

Best Regards,
Mateusz

#17 lore raw

PATCH v2 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Dear Mateusz Kulikowski,

Quoted 1 line · Mateusz Kulikowski

On 11.11.2013 12:03, Andreas Bie?mann wrote:

<snip>

Quoted 15 lines
Quoted 9 lines

board/calao/usb_a9263/usb_a9263.c line 81

Quoted 3 lines
board/calao/usb_a9263/usb_a9263.c new file +3 -0
+
+    /* 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.

Quoted 5 lines

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.

Quoted 3 lines

Do I understand correctly, that for all ports that I use (via generic GPIO) I should create "temporary" defines
(with hardcoded gpio#)?

please use the freshly defined GPIO_PIN_Px() macros from [1].

Quoted 6 lines

Perhaps I'm missing something, but I currently see no other way to get GPIO# (It will change once your RFC is included).

Of course CONFIG_ATMEL_LEGACY has to stay, as atmel_nand uses CONFIG_SYS_NAND_*_PIN and is still using old API (I guess this also needs fixing).

The series includes change for atmel_nand [2], therefore you can remove that switch.

<snip>

Quoted 9 lines
Quoted 5 lines

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.

Ping :)
Do I understand correctly, that phy_reset RFC will be soon applied, then I should post v3?

I'll apply that patch [3] this weekend.

Quoted 1 line

Or should I wait for your GPIO RFC?

Is out now ... ;)

Best regards

Andreas Bie?mann

[1] http://patchwork.ozlabs.org/patch/295264/
[2] http://patchwork.ozlabs.org/patch/295268/
[3] http://patchwork.ozlabs.org/patch/291958/

#18 lore raw

PATCH v3 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

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.

---
Changes for v3
- Updated Makefile to a new build system
- Use generic GPIO for NAND and MAC (requires new GPIO patches)
- Use common at91 phy reset
- Dropped spi0 clock setup (pin is unused)
- Fixed PHY address as 0x0001 and dropped PHY autodetect (no need for autodetect - PHY address is bootstrapped to 1)

---
 board/calao/usb_a9263/Makefile    |  14 ++++
 board/calao/usb_a9263/usb_a9263.c | 148 +++++++++++++++++++++++++++++++++
 boards.cfg                        |   1 +
 include/configs/usb_a9263.h       | 169 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 332 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
board/calao/usb_a9263/Makefile new file +14 -0
new file mode 100644
index 0000000..8a22b3e
@@ -0,0 +1,14 @@
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop <[email protected]>
+# Lead Tech Design <www.leadtechdesign.com>
+#
+# (C) Copyright 2013
+# Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
+obj-y	+= usb_a9263.o
board/calao/usb_a9263/usb_a9263.c new file +148 -0

148 lines not on this page · raw message

boards.cfg +1 -0
index 36f0924..0f14fbb 100644
@@ -119,6 +119,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 <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_eeprom                     tny_a9260:AT91SAM9G20,SYS_USE_EEPROM                                                                                              Albin Tonnerre <[email protected]>
 Active  arm         arm926ejs      at91        calao           tny_a9260           tny_a9g20_nandflash                  tny_a9260:AT91SAM9G20,SYS_USE_NANDFLASH                                                                                           Albin Tonnerre <[email protected]>
+Active  arm         arm926ejs      at91        calao           usb_a9263           usb_a9263_dataflash                  usb_a9263:AT91SAM9263,SYS_USE_DATAFLASH                                                                                           Mateusz Kulikowski <[email protected]>
 Active  arm         arm926ejs      at91        egnite          ethernut5           ethernut5                            ethernut5:AT91SAM9XE                                                                                                              egnite GmbH <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000eval_xe                       top9000:EVAL9000                                                                                                                  Reinhard Meyer <[email protected]>
 Active  arm         arm926ejs      at91        emk             top9000             top9000su_xe                         top9000:SU9000                                                                                                                    Reinhard Meyer <[email protected]>
include/configs/usb_a9263.h new file +169 -0

169 lines not on this page · raw message

Signature · 1 line
1.8.4.1
#19 lore raw

PATCH v3 1/1 arm: at91: support for the Calao USB-A9263 board (based on AT91SAM9263)

Dear Mateusz Kulikowski,

Quoted 15 lines · Mateusz Kulikowski

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.

---
Changes for v3
- Updated Makefile to a new build system
- Use generic GPIO for NAND and MAC (requires new GPIO patches)
- Use common at91 phy reset
- Dropped spi0 clock setup (pin is unused)
- Fixed PHY address as 0x0001 and dropped PHY autodetect (no need for autodetect - PHY address is bootstrapped to 1)
---

Quoted 8 lines
board/calao/usb_a9263/Makefile    |  14 ++++
board/calao/usb_a9263/usb_a9263.c | 148 +++++++++++++++++++++++++++++++++
boards.cfg                        |   1 +
include/configs/usb_a9263.h       | 169 ++++++++++++++++++++++++++++++++++++++
4 files changed, 332 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

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann