[U-Boot] [PATCH 2/3] Add support for Bluewater Systems Snapper 9260 and 9G20 modules

Reinhard Meyer u-boot at emk-elektronik.de
Tue Jan 25 05:43:16 CET 2011


Dear Ryan Mallon,
> Signed-off-by: Ryan Mallon<ryan at bluewatersys.com>
> ---
>   board/bluewater/snapper9260/Makefile      |   55 +++++++++
>   board/bluewater/snapper9260/config.mk     |    1 +

See comment in your patch 0/3.

>   board/bluewater/snapper9260/snapper9260.c |  177 +++++++++++++++++++++++++++++
>   3 files changed, 233 insertions(+), 0 deletions(-)
>   create mode 100644 board/bluewater/snapper9260/Makefile
>   create mode 100644 board/bluewater/snapper9260/config.mk
>   create mode 100644 board/bluewater/snapper9260/snapper9260.c
>
> diff --git a/board/bluewater/snapper9260/Makefile b/board/bluewater/snapper9260/Makefile
> new file mode 100644
> index 0000000..20d2406
> --- /dev/null
> +++ b/board/bluewater/snapper9260/Makefile
> @@ -0,0 +1,55 @@
> +#
> +# (C) Copyright 2003-2008
> +# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
> +#
> +# (C) Copyright 2011 Bluewater Systems
> +#
> +# 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).o
> +
> +COBJS-y	+= snapper9260.o
> +
> +SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
> +OBJS	:= $(addprefix $(obj),$(COBJS-y))
> +SOBJS	:= $(addprefix $(obj),$(SOBJS))
> +
> +$(LIB): $(OBJS) $(SOBJS)
> +	$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)

This is old code. Libraries are not built anymore.
Has this even been built on current top of tree u-boot?

> +
> +clean:
> +	rm -f $(SOBJS) $(OBJS)
> +
> +distclean: clean
> +	rm -f $(LIB) core *.bak .depend
> +
> +.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
> +	$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c)>  $@
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################
> diff --git a/board/bluewater/snapper9260/config.mk b/board/bluewater/snapper9260/config.mk
> new file mode 100644
> index 0000000..e554a45
> --- /dev/null
> +++ b/board/bluewater/snapper9260/config.mk
> @@ -0,0 +1 @@
> +CONFIG_SYS_TEXT_BASE = 0x23f00000
> diff --git a/board/bluewater/snapper9260/snapper9260.c b/board/bluewater/snapper9260/snapper9260.c
> new file mode 100644
> index 0000000..04cb0a8
> --- /dev/null
> +++ b/board/bluewater/snapper9260/snapper9260.c
> @@ -0,0 +1,177 @@
> +/*
> + * Bluewater Systems Snapper 9260/9G20 modules
> + *
> + * (C) Copyright 2011 Bluewater Systems
> + *   Author: Andre Renaud<andre at bluewatersys.com>
> + *   Author: Ryan Mallon<ryan at bluewatersys.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include<common.h>
> +#include<asm/sizes.h>
> +#include<asm/arch/at91sam9260.h>
> +#include<asm/arch/at91sam9260_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/at91_pio.h>
> +#include<asm/arch/clk.h>
> +#include<asm/arch/gpio.h>
> +#include<asm/arch/io.h>
> +#include<asm/arch/hardware.h>
> +#include<net.h>
> +#include<netdev.h>
> +
> +#include<i2c.h>
> +#include<pca953x.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +

> +/* The mach-type is the same for both Snapper 9260 and 9G20 */
> +#define SNAPPER9260_MACH_TYPE	1987

Nope. This is not acceptable. ARM mach types are exclusively defined in
mach-types.h. Its already there:
#define MACH_TYPE_SNAPPER_9260         1987

> +
> +#define IO_EXP_ETH_RESET	(0<<  1)
> +#define IO_EXP_ETH_POWER	(1<<  1)
> +
> +static void macb_hw_init(void)
> +{
> +	unsigned long rstc;
> +
> +	/* Enable clock */
> +	at91_sys_write(AT91_PMC_PCER, 1<<  AT91SAM9260_ID_EMAC);
> +
> +	/* Disable pull-ups to prevent PHY going into test mode */
> +	writel(pin_to_mask(AT91_PIN_PA14) |
> +	       pin_to_mask(AT91_PIN_PA15) |
> +	       pin_to_mask(AT91_PIN_PA18),
> +	       pin_to_controller(AT91_PIN_PA0) + PIO_PUDR);
> +
> +	/* Power down ethernet */
> +	pca953x_set_dir(0x28, IO_EXP_ETH_POWER, PCA953X_DIR_OUT);
> +	pca953x_set_val(0x28, IO_EXP_ETH_POWER, 1);
> +
> +	/* Hold ethernet in reset */
> +	pca953x_set_dir(0x28, IO_EXP_ETH_RESET, PCA953X_DIR_OUT);
> +	pca953x_set_val(0x28, IO_EXP_ETH_RESET, 0);
> +
> +	/* Enable ethernet power */
> +	pca953x_set_val(0x28, IO_EXP_ETH_POWER, 0);
> +
> +	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, (rstc | AT91_RSTC_KEY |
> +				      AT91_RSTC_URSTEN));
> +
> +	/* Bring the ethernet out of reset */
> +	pca953x_set_val(0x28, IO_EXP_ETH_RESET, 1);
> +
> +	/* The phy internal reset take 21ms */
> +	udelay(21 * 1000);
> +
> +	/* Re-enable pull-up */
> +	writel(pin_to_mask(AT91_PIN_PA14) |
> +	       pin_to_mask(AT91_PIN_PA15) |
> +	       pin_to_mask(AT91_PIN_PA18),
> +	       pin_to_controller(AT91_PIN_PA0) + PIO_PUER);
> +
> +	at91_macb_hw_init();
> +}
> +
> +static void 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_(2) | AT91_SMC_NCS_WRSETUP_(0) |
> +		       AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
> +	at91_sys_write(AT91_SMC_PULSE(3),
> +		       AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(4) |
> +		       AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(4));
> +	at91_sys_write(AT91_SMC_CYCLE(3),
> +		       AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
> +	at91_sys_write(AT91_SMC_MODE(3),
> +		       AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
> +		       AT91_SMC_EXNWMODE_DISABLE |
> +		       AT91_SMC_DBW_8 |
> +		       AT91_SMC_TDF_(3));
> +
> +	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);
> +}
> +
> +int board_init(void)
> +{
> +	/* Enable Ctrl-c */
> +	console_init_f();
> +
> +	gd->bd->bi_arch_number = SNAPPER9260_MACH_TYPE;
> +
> +	/* Address of boot parameters */
> +	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
> +
> +	/* Enable PIO clocks */
> +	at91_sys_write(AT91_PMC_PCER, 1<<  AT91SAM9260_ID_PIOA);
> +	at91_sys_write(AT91_PMC_PCER, 1<<  AT91SAM9260_ID_PIOB);
> +	at91_sys_write(AT91_PMC_PCER, 1<<  AT91SAM9260_ID_PIOC);
> +
> +	/* Initalise i2c (for IO expander) */
> +	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
> +
> +	at91_serial_hw_init();
> +	nand_hw_init();
> +	macb_hw_init();
> +
> +	return 0;
> +}
> +
> +int board_eth_init(bd_t *bis)
> +{
> +	return macb_eth_initialize(0, (void *)AT91SAM9260_BASE_EMAC, 0x1f);
> +}
> +
> +int dram_init(void)
> +{
> +	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;

This is not advisable. Use
	gd->ram_size = get_ram_size(
		(void *)CONFIG_SYS_SDRAM_BASE,
		CONFIG_SYS_SDRAM_SIZE);
instead.

> +	return 0;
> +}
> +
> +void reset_phy(void)
> +{
> +}

This is all based on older (legacy) at91 hardware access. It would be better if
you based it on the reworked at91 code at
git://git.denx.de/u-boot-atmel.git rework101229 branch.
For templates see the at91sam9260ek port there.

Best Regards,
Reinhard


More information about the U-Boot mailing list