[U-Boot] [PATCH v4 1/2] Add support for Eukrea CPU9260 SBC

Jean-Christophe PLAGNIOL-VILLARD
2009-07-23T22:16:17Z

On 23:45 Sat 18 Jul , Eric Benard wrote:
> CPUAT91 is built around Atmel's AT91SAM9260 and has up to 64MB of NOR
> flash, up to 128MB of SDRAM, up to 2GB of NAND and includes a 10/100
> Ethernet PHY in RMII mode.
>
> v4 : do the commit before generating/sending the patch ;-)
> v3 : fix Makefile (run mkconfig after config.h configuration)
>
> Signed-off-by: Eric Benard <eric@eukrea.com>
> ---
> MAINTAINERS | 4 +
> MAKEALL | 1 +
> Makefile | 13 ++
> board/eukrea/cpu9260/Makefile | 59 +++++++
> board/eukrea/cpu9260/config.mk | 1 +
> board/eukrea/cpu9260/cpu9260.c | 211 +++++++++++++++++++++++
> board/eukrea/cpu9260/cpu9260_led.c | 46 +++++
> include/configs/cpu9260.h | 335 ++++++++++++++++++++++++++++++++++++
> 8 files changed, 670 insertions(+), 0 deletions(-)
> create mode 100644 board/eukrea/cpu9260/Makefile
> create mode 100644 board/eukrea/cpu9260/config.mk
> create mode 100644 board/eukrea/cpu9260/cpu9260.c
> create mode 100644 board/eukrea/cpu9260/cpu9260_led.c
> create mode 100644 include/configs/cpu9260.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 575a7ec..b8d701a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -515,6 +515,10 @@ Dirk Behme <dirk.behme@gmail.com>
>
> omap3_beagle ARM CORTEX-A8 (OMAP3530 SoC)
>
> +Eric Benard <eric@eukrea.com>
> +
> + cpu9260 ARM926EJS (AT91SAM9260 SoC)
> +
> Rishi Bhattacharya <rishi@ti.com>
>
> omap5912osk ARM926EJS
> diff --git a/MAKEALL b/MAKEALL
> index 020ff73..bdc80fa 100755
> --- a/MAKEALL
> +++ b/MAKEALL
> @@ -592,6 +592,7 @@ LIST_at91=" \
> at91sam9m10g45ek \
> at91sam9rlek \
> cmc_pu2 \
> + cpu9260 \
> csb637 \
> kb9202 \
> meesc \
> diff --git a/Makefile b/Makefile
> index 090e645..8c4178f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2813,6 +2813,19 @@ at91sam9rlek_config : unconfig
> fi;
> @$(MKCONFIG) -a at91sam9rlek arm arm926ejs at91sam9rlek atmel at91
>
> +cpu9260_64m_config \
> +cpu9260_config : unconfig
> + @if [ "$(findstring _64m,$@)" ] ; then \
> + echo "#define CONFIG_SYS_SDRC_CR_VAL CONFIG_SYS_SDRC_CR_VAL_64MB" \
> + >>$(obj)include/config.h ; \
> + $(XECHO) "... CPU9260 with 64MB SDRAM" ; \
> + else \
> + echo "#define CONFIG_SYS_SDRC_CR_VAL CONFIG_SYS_SDRC_CR_VAL_128MB" \
> + >>$(obj)include/config.h ; \
> + $(XECHO) "... CPU9260 with 128MB SDRAM" ; \
> + fi;
> + @$(MKCONFIG) -a cpu9260 arm arm926ejs cpu9260 eukrea at91
> +
> meesc_config : unconfig
> @$(MKCONFIG) $(@:_config=) arm arm926ejs meesc esd at91
>
> diff --git a/board/eukrea/cpu9260/Makefile b/board/eukrea/cpu9260/Makefile
> new file mode 100644
> index 0000000..5b1acdc
> --- /dev/null
> +++ b/board/eukrea/cpu9260/Makefile
> @@ -0,0 +1,59 @@
> +#
> +# (C) Copyright 2003-2008
> +# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> +#
> +# (C) Copyright 2008
> +# Stelian Pop <stelian.pop@leadtechdesign.com>
> +# Lead Tech Design <www.leadtechdesign.com>
> +# Ilko Iliev <www.ronetix.at>
> +#
> +# (C) Copyright 2009
> +# Eric Benard <eric@eukrea.com>
> +#
> +# See file CREDITS for list of people who contributed to this
> +# project.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation; either version 2 of
> +# the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> +# MA 02111-1307 USA
> +#
> +
> +include $(TOPDIR)/config.mk
> +
> +LIB = $(obj)lib$(BOARD).a
> +
> +COBJS-y += $(BOARD).o
> +COBJS-y += $(BOARD)_led.o
please keep the same way as all other at91sam
COBJS-y += led.o

> +
> +SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
> +OBJS := $(addprefix $(obj),$(COBJS-y) $(SOBJS))
> +SOBJS := $(addprefix $(obj),$(SOBJS))
> +
> +$(LIB): $(obj).depend $(OBJS) $(SOBJS)
> + $(AR) $(ARFLAGS) $@ $(OBJS)
> +
> +clean:
> + rm -f $(SOBJS) $(OBJS)
> +
> +distclean: clean
> + rm -f $(LIB) core *.bak $(obj).depend
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################
> diff --git a/board/eukrea/cpu9260/config.mk b/board/eukrea/cpu9260/config.mk
> new file mode 100644
> index 0000000..9ce161e
> --- /dev/null
> +++ b/board/eukrea/cpu9260/config.mk
> @@ -0,0 +1 @@
> +TEXT_BASE = 0x21f00000
> diff --git a/board/eukrea/cpu9260/cpu9260.c b/board/eukrea/cpu9260/cpu9260.c
> new file mode 100644
> index 0000000..84707b6
> --- /dev/null
> +++ b/board/eukrea/cpu9260/cpu9260.c
> @@ -0,0 +1,211 @@
> +/*
> + * (C) Copyright 2007-2008
> + * Stelian Pop <stelian.pop@leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + * Ilko Iliev <www.ronetix.at>
> + *
> + * (C) Copyright 2009
> + * Eric Benard <eric@eukrea.com>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <asm/sizes.h>
> +#include <asm/arch/at91sam9260.h>
> +#include <asm/arch/at91sam9260_matrix.h>
please
#include <asm/arch/at91sam9_matrix.h>
> +#include <asm/arch/at91sam9_smc.h>
> +#include <asm/arch/at91_common.h>
> +#include <asm/arch/at91_pmc.h>
> +#include <asm/arch/at91_rstc.h>
> +#include <asm/arch/gpio.h>
> +#include <asm/arch/io.h>
> +#include <asm/arch/clk.h>
> +#include <asm/arch/hardware.h>
> +#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
> +#include <net.h>
> +#endif
> +#include <netdev.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +/* ------------------------------------------------------------------------- */
> +/*
> + * Miscelaneous platform dependent initialisations
> + */
> +
> +#ifdef CONFIG_CMD_NAND
> +static void cpu9260_nand_hw_init(void)
> +{
> + unsigned long csa;
> +
> + /* Enable CS3 */
> + csa = at91_sys_read(AT91_MATRIX_EBICSA);
> + at91_sys_write(AT91_MATRIX_EBICSA,
> + csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
> +
> + /* Configure SMC CS3 for NAND/SmartMedia */
> + at91_sys_write(AT91_SMC_SETUP(3),
> + AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0) |
> + AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
> + at91_sys_write(AT91_SMC_PULSE(3),
> + AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) |
> + AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
> + at91_sys_write(AT91_SMC_CYCLE(3),
> + AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
> + at91_sys_write(AT91_SMC_MODE(3),
> + AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
> + AT91_SMC_EXNWMODE_DISABLE |
> + AT91_SMC_DBW_8 |
> + AT91_SMC_TDF_(2));
> +
> + at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOC);
> +
> + /* 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 cpu9260_macb_hw_init(void)
> +{
> + unsigned long rstc;
> +
> + /* Enable clock */
> + at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC);
> +
> + /*
> + * Disable pull-up on:
> + * RXDV (PA17) => PHY normal mode (not Test mode)
> + * ERX0 (PA14) => PHY ADDR0
> + * ERX1 (PA15) => PHY ADDR1
> + * ERX2 (PA25) => PHY ADDR2
> + * ERX3 (PA26) => PHY ADDR3
> + * ECRS (PA28) => PHY ADDR4 => PHYADDR = 0x0
> + *
> + * PHY has internal pull-down
> + */
> + writel(pin_to_mask(AT91_PIN_PA14) |
> + pin_to_mask(AT91_PIN_PA15) |
> + pin_to_mask(AT91_PIN_PA17) |
> + pin_to_mask(AT91_PIN_PA25) |
> + pin_to_mask(AT91_PIN_PA26) |
> + pin_to_mask(AT91_PIN_PA28),
> + pin_to_controller(AT91_PIN_PA0) + PIO_PUDR);
> +
> + rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
> +
> + /* Need to reset PHY -> 500ms reset */
> + at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
> + AT91_RSTC_ERSTL & (0x0D << 8) |
> + AT91_RSTC_URSTEN);
> +
> + at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST);
> +
> + /* Wait for end hardware reset */
> + while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL));
> +
> + /* Restore NRST value */
> + at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
> + (rstc) |
> + AT91_RSTC_URSTEN);
> +
> + /* Re-enable pull-up */
> + writel(pin_to_mask(AT91_PIN_PA14) |
> + pin_to_mask(AT91_PIN_PA15) |
> + pin_to_mask(AT91_PIN_PA17) |
> + pin_to_mask(AT91_PIN_PA25) |
> + pin_to_mask(AT91_PIN_PA26) |
> + pin_to_mask(AT91_PIN_PA28),
> + pin_to_controller(AT91_PIN_PA0) + PIO_PUER);
> +
> + at91_macb_hw_init();
> +}
> +#endif
> +
> +int board_init(void)
> +{
> + /* Enable Ctrlc */
> + console_init_f();
> +
> + /* arch number of CPUAT9260-Board */
> + gd->bd->bi_arch_number = MACH_TYPE_CPUAT9260;
> +
> + /* adress of boot parameters */
> + gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
> +
> + at91_serial_hw_init();
> +#ifdef CONFIG_CMD_NAND
> + cpu9260_nand_hw_init();
> +#endif
> +#ifdef CONFIG_MACB
> + cpu9260_macb_hw_init();
> +#endif
> +
> + return 0;
> +}
> +
> +int dram_init(void)
> +{
> + gd->bd->bi_dram[0].start = PHYS_SDRAM;
> + gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
> + return 0;
> +}
> +
> +#ifdef CONFIG_RESET_PHY_R
> +void reset_phy(void)
> +{
> +#ifdef CONFIG_MACB
> + /*
> + * Initialize ethernet HW addr prior to starting Linux,
> + * needed for nfsroot
> + */
> + eth_init(gd->bd);
> +#endif
> +}
> +#endif
> +
> +int board_eth_init(bd_t *bis)
> +{
> + int rc = 0;
> +#ifdef CONFIG_MACB
> + rc = macb_eth_initialize(0, (void *)AT91SAM9260_BASE_EMAC, 0x1F);
> +#endif
> + return rc;
> +}
> +
> +#ifdef CONFIG_DISPLAY_CPUINFO
> +int checkboard(void)
> +{
> + char buf[32];
> +
> + printf("Board : Eukrea Electromatique CPU9260\n");
> + printf("Crystal frequency: %8s MHz\n",
> + strmhz(buf, get_main_clk_rate()));
> + printf("CPU clock : %8s MHz\n",
> + strmhz(buf, get_cpu_clk_rate()));
> + printf("Master clock : %8s MHz\n",
> + strmhz(buf, get_mck_clk_rate()));
> + printf("\n");
it can not work CONFIG_DISPLAY_CPUINFO is for print_cpuinfo callback
when I tell you use CONFIG_DISPLAY_CPUINFO
it's because we already implement this printf in
cpu/arm926ejs/at91/cpu.c
so please update
> + return 0;
> +}
> +#endif
> diff --git a/board/eukrea/cpu9260/cpu9260_led.c b/board/eukrea/cpu9260/cpu9260_led.c
> new file mode 100644
> index 0000000..33942c7
> --- /dev/null
> +++ b/board/eukrea/cpu9260/cpu9260_led.c
> @@ -0,0 +1,46 @@
> +/*
> + * (C) Copyright 2007-2008
> + * Stelian Pop <stelian.pop@leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + * Ilko Iliev <www.ronetix.at>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <asm/arch/at91sam9260.h>
> +#include <asm/arch/at91_pmc.h>
> +#include <asm/arch/gpio.h>
> +#include <asm/arch/io.h>
> +
> +void coloured_LED_init(void)
> +{
> + /* Enable clock */
> + at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOC);
> +
> + at91_set_gpio_output(CONFIG_RED_LED, 1);
> + at91_set_gpio_output(CONFIG_GREEN_LED, 1);
> + at91_set_gpio_output(CONFIG_YELLOW_LED, 1);
> + at91_set_gpio_output(CONFIG_BLUE_LED, 1);
> +
> + at91_set_gpio_value(CONFIG_RED_LED, 1);
> + at91_set_gpio_value(CONFIG_GREEN_LED, 1);
> + at91_set_gpio_value(CONFIG_YELLOW_LED, 1);
> + at91_set_gpio_value(CONFIG_BLUE_LED, 0);
> +}
> diff --git a/include/configs/cpu9260.h b/include/configs/cpu9260.h
> new file mode 100644
> index 0000000..1342754
> --- /dev/null
> +++ b/include/configs/cpu9260.h
> @@ -0,0 +1,335 @@
> +/*
> + * (C) Copyright 2007-2008
> + * Stelian Pop <stelian.pop@leadtechdesign.com>
> + * Lead Tech Design <www.leadtechdesign.com>
> + * Ilko Iliev <www.ronetix.at>
> + *
> + * (C) Copyright 2009
> + * Eric Benard <eric@eukrea.com>
> + *
> + * Configuration settings for the Eukrea CPU9260 board.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +
> +#define CONFIG_DISPLAY_CPUINFO 1
> +
> +#define CPU9260_CRYSTAL 18432000
please use
AT91_MAIN_CLOCK or you will let U-Boot detect it for the clock
api

Best Regards,
J.