From f3351ebd7864b83b1f5f3cdc7c8a9f9110cb562f Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 4 Jun 2008 09:31:15 +0200 Subject: add basic at91sam9260 support. Currently only second stage bootloader is supported: - No SDRAM initialisation - No UART init / baudrate change --- board/at91sam9260ek/Makefile | 2 + board/at91sam9260ek/config.h | 2 + board/at91sam9260ek/env/bin/_update | 36 +++++++++ board/at91sam9260ek/env/bin/boot | 38 +++++++++ board/at91sam9260ek/env/bin/init | 19 +++++ board/at91sam9260ek/env/bin/pcidmaloop | 14 ++++ board/at91sam9260ek/env/bin/pciloop | 13 +++ board/at91sam9260ek/env/bin/update_kernel | 8 ++ board/at91sam9260ek/env/bin/update_root | 8 ++ board/at91sam9260ek/env/config | 21 +++++ board/at91sam9260ek/init.c | 129 ++++++++++++++++++++++++++++++ board/at91sam9260ek/lowlevel_init.S | 26 ++++++ 12 files changed, 316 insertions(+) create mode 100644 board/at91sam9260ek/Makefile create mode 100644 board/at91sam9260ek/config.h create mode 100644 board/at91sam9260ek/env/bin/_update create mode 100644 board/at91sam9260ek/env/bin/boot create mode 100644 board/at91sam9260ek/env/bin/init create mode 100644 board/at91sam9260ek/env/bin/pcidmaloop create mode 100644 board/at91sam9260ek/env/bin/pciloop create mode 100644 board/at91sam9260ek/env/bin/update_kernel create mode 100644 board/at91sam9260ek/env/bin/update_root create mode 100644 board/at91sam9260ek/env/config create mode 100644 board/at91sam9260ek/init.c create mode 100644 board/at91sam9260ek/lowlevel_init.S (limited to 'board') diff --git a/board/at91sam9260ek/Makefile b/board/at91sam9260ek/Makefile new file mode 100644 index 0000000000..73ef72e210 --- /dev/null +++ b/board/at91sam9260ek/Makefile @@ -0,0 +1,2 @@ +obj-y += lowlevel_init.o +obj-y += init.o diff --git a/board/at91sam9260ek/config.h b/board/at91sam9260ek/config.h new file mode 100644 index 0000000000..38d7eef530 --- /dev/null +++ b/board/at91sam9260ek/config.h @@ -0,0 +1,2 @@ +#define CFG_MALLOC_LEN (4096 << 10) +#define CONFIG_STACKSIZE (32 * 1024) /* regular stack */ diff --git a/board/at91sam9260ek/env/bin/_update b/board/at91sam9260ek/env/bin/_update new file mode 100644 index 0000000000..fb7cbe8619 --- /dev/null +++ b/board/at91sam9260ek/env/bin/_update @@ -0,0 +1,36 @@ +#!/bin/sh + +if [ -z "$part" -o -z "$image" ]; then + echo "define \$part and \$image" + exit 1 +fi + +if [ \! -e "$part" ]; then + echo "Partition $part does not exist" + exit 1 +fi + +if [ $# = 1 ]; then + image=$1 +fi + +if [ x$ip = xdhcp ]; then + dhcp +fi + +ping $eth0.serverip +if [ $? -ne 0 ] ; then + echo "update aborted" + exit 1 +fi + +unprotect $part + +echo +echo "erasing partition $part" +erase $part + +echo +echo "flashing $image to $part" +echo +tftp $image $part diff --git a/board/at91sam9260ek/env/bin/boot b/board/at91sam9260ek/env/bin/boot new file mode 100644 index 0000000000..ed6f11a108 --- /dev/null +++ b/board/at91sam9260ek/env/bin/boot @@ -0,0 +1,38 @@ +#!/bin/sh + +. /env/config + +if [ x$1 = xflash ]; then + root=flash + kernel=flash +fi + +if [ x$1 = xnet ]; then + root=net + kernel=net +fi + +if [ x$ip = xdhcp ]; then + bootargs="$bootargs ip=dhcp" +else + bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::" +fi + +if [ x$root = xflash ]; then + bootargs="$bootargs root=$rootpart rootfstype=jffs2" +else + bootargs="$bootargs root=/dev/nfs nfsroot=192.168.23.111:$nfsroot" +fi + +bootargs="$bootargs mtdparts=physmap-flash.0:$mtdparts" + +if [ $kernel = net ]; then + if [ x$ip = xdhcp ]; then + dhcp + fi + tftp $uimage uImage + bootm uImage +else + bootm /dev/nor0.kernel +fi + diff --git a/board/at91sam9260ek/env/bin/init b/board/at91sam9260ek/env/bin/init new file mode 100644 index 0000000000..b8d8399842 --- /dev/null +++ b/board/at91sam9260ek/env/bin/init @@ -0,0 +1,19 @@ +#!/bin/sh + +PATH=/env/bin +export PATH + +. /env/config + +echo +echo -n "Hit any key to stop autoboot: " +timeout -a $autoboot_timeout +if [ $? != 0 ]; then + echo + echo "type update_kernel [] to update kernel into flash" + echo "type udate_root [] to update rootfs into flash" + echo + exit +fi + +boot \ No newline at end of file diff --git a/board/at91sam9260ek/env/bin/pcidmaloop b/board/at91sam9260ek/env/bin/pcidmaloop new file mode 100644 index 0000000000..24e76cbed7 --- /dev/null +++ b/board/at91sam9260ek/env/bin/pcidmaloop @@ -0,0 +1,14 @@ +pci stat +pci stat -c +while true; do + pci readm 32 0xA1000000 32 -s + pci readm 32 0xA2000000 256 -s + pci dmatx 2000 a2000100 128 -s + pci writem 32 0xa2000100 0x12345678 4 -s + pci readm 32 0xA3000000 256 -s + pci dmatx 2000 a3000040 128 -s + pci writem 32 0xa3000100 0x12345678 4 -s + pci readm 32 0xA4000000 16 -s + pci dmatx 2000 a4000080 4 -s + pci writem 32 0xa4000080 0x12345678 4 -s +done diff --git a/board/at91sam9260ek/env/bin/pciloop b/board/at91sam9260ek/env/bin/pciloop new file mode 100644 index 0000000000..4a804f9f31 --- /dev/null +++ b/board/at91sam9260ek/env/bin/pciloop @@ -0,0 +1,13 @@ +pci stat +pci stat -c +while true; do + pci readm 32 0xA1000000 32 -s + pci readm 32 0xA2000000 256 -s + pci writem 32 0xa2000100 0x12345678 4 -s + pci readm 32 0xA3000000 256 -s + pci writem 32 0xa3000100 0x12345678 4 -s + pci readm 32 0xA4000000 16 -s + pci writem 32 0xa4000080 0x12345678 4 -s + +# pci dmatx 2000 a3000040 128 -s +done diff --git a/board/at91sam9260ek/env/bin/update_kernel b/board/at91sam9260ek/env/bin/update_kernel new file mode 100644 index 0000000000..1ad95fc5d6 --- /dev/null +++ b/board/at91sam9260ek/env/bin/update_kernel @@ -0,0 +1,8 @@ +#!/bin/sh + +. /env/config + +image=$uimage +part=/dev/nor0.kernel + +. /env/bin/_update $1 diff --git a/board/at91sam9260ek/env/bin/update_root b/board/at91sam9260ek/env/bin/update_root new file mode 100644 index 0000000000..b757a5b922 --- /dev/null +++ b/board/at91sam9260ek/env/bin/update_root @@ -0,0 +1,8 @@ +#!/bin/sh + +. /env/config + +image=$jffs2 +part=/dev/nor0.root + +. /env/bin/_update $1 diff --git a/board/at91sam9260ek/env/config b/board/at91sam9260ek/env/config new file mode 100644 index 0000000000..9d2b0b1116 --- /dev/null +++ b/board/at91sam9260ek/env/config @@ -0,0 +1,21 @@ +#!/bin/sh + +# can be either 'net' or 'flash' +kernel=net +root=net + +# use 'dhcp' todo dhcp in uboot and in kernel +ip=dhcp + +# +# setup default ethernet address +# +eth0.serverip=192.168.23.108 +eth0.ethaddr=80:97:78:38:27:73 + +uimage=uImage-at91sam9260ek + +autoboot_timeout=3 + +nfsroot="/home/jbe/pengutronix/bsp/OSELAS.BSP-Phytec-phyCORE-i.MX27-trunk/root,v3" +bootargs="console=ttyS0,115200 rw init=/bin/sh" diff --git a/board/at91sam9260ek/init.c b/board/at91sam9260ek/init.c new file mode 100644 index 0000000000..9b5f1f90f4 --- /dev/null +++ b/board/at91sam9260ek/init.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2007 Sascha Hauer, Pengutronix + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MASK_ALE (1 << 21) /* our ALE is AD21 */ +#define MASK_CLE (1 << 22) + +static void at91sam9260ek_nand_hwcontrol(struct nand_chip *this, int cmd) +{ + ulong IO_ADDR_W = (ulong) this->IO_ADDR_W; + + IO_ADDR_W &= ~(MASK_ALE|MASK_CLE); + switch (cmd) { + case NAND_CTL_SETCLE: + IO_ADDR_W |= MASK_CLE; + break; + case NAND_CTL_SETALE: + IO_ADDR_W |= MASK_ALE; + break; + case NAND_CTL_CLRNCE: + at91_set_gpio_value(AT91_PIN_PC14, 1); + break; + case NAND_CTL_SETNCE: + at91_set_gpio_value(AT91_PIN_PC14, 0); + break; + } + this->IO_ADDR_W = (void *) IO_ADDR_W; +} + +static int at91sam9260ek_nand_ready(struct nand_chip *this) +{ + return at91_get_gpio_value(AT91_PIN_PC13); +} + +static struct nand_platform_data nand_pdata = { + .hwcontrol = at91sam9260ek_nand_hwcontrol, + .eccmode = NAND_ECC_SOFT, + .dev_ready = at91sam9260ek_nand_ready, + .chip_delay = 20, +}; + +static struct device_d nand_dev = { + .name = "nand_controller", + .map_base = 0x40000000, + .size = 0x10, + .platform_data = &nand_pdata, +}; + +static struct device_d sdram_dev = { + .name = "ram", + .id = "ram0", + + .map_base = 0x20000000, + .size = 64 * 1024 * 1024, + + .type = DEVICE_TYPE_DRAM, +}; + +static struct device_d macb_dev = { + .name = "macb", + .id = "eth0", + .map_base = AT91_BASE_EMAC, + .size = 0x1000, + .type = DEVICE_TYPE_ETHER, +}; + +static int pcm038_devices_init(void) +{ + register_device(&sdram_dev); + register_device(&nand_dev); + register_device(&macb_dev); + + armlinux_set_bootparams((void *)0x20000100); + armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK); + + return 0; +} + +device_initcall(pcm038_devices_init); + +static struct device_d pcm038_serial_device = { + .name = "atmel_serial", + .id = "cs0", + .map_base = USART3_BASE, + .size = 4096, + .type = DEVICE_TYPE_CONSOLE, +}; + +static int pcm038_console_init(void) +{ + register_device(&pcm038_serial_device); + return 0; +} + +console_initcall(pcm038_console_init); diff --git a/board/at91sam9260ek/lowlevel_init.S b/board/at91sam9260ek/lowlevel_init.S new file mode 100644 index 0000000000..4961682322 --- /dev/null +++ b/board/at91sam9260ek/lowlevel_init.S @@ -0,0 +1,26 @@ +/* + * Board specific setup info + * + * + * 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 + */ + +.globl board_init_lowlevel +board_init_lowlevel: + mov pc, lr -- cgit v1.2.3