diff options
author | Robert Schwebel <r.schwebel@pengutronix.de> | 2011-04-21 17:59:25 +0200 |
---|---|---|
committer | Robert Schwebel <r.schwebel@pengutronix.de> | 2011-04-26 11:01:22 +0200 |
commit | 565d45319f428ac55f8634f7781ee7d29b80d235 (patch) | |
tree | 2df110f759271b008ffcc6e4ee3d119388defa0d | |
parent | 349f147835a39f317098f96d173ecefd3827b42a (diff) | |
download | barebox-565d45319f428ac55f8634f7781ee7d29b80d235.tar.gz barebox-565d45319f428ac55f8634f7781ee7d29b80d235.tar.xz |
WIP: tuxrail: add support for Busware TuxRail
Work in progress, so no Signed-off-by: yet.
-rw-r--r-- | arch/arm/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/config.h | 21 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/env/bin/boot | 38 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/env/bin/init | 15 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/env/config | 36 | ||||
-rw-r--r-- | arch/arm/boards/busware-tuxrail/tuxrail.c | 248 | ||||
-rw-r--r-- | arch/arm/mach-mxs/Kconfig | 8 |
8 files changed, 368 insertions, 0 deletions
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 21d6157f..fbb95d5d 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -99,6 +99,7 @@ board-$(CONFIG_MACH_SCB9328) := scb9328 board-$(CONFIG_MACH_NESO) := guf-neso board-$(CONFIG_MACH_MX23EVK) := freescale-mx23-evk board-$(CONFIG_MACH_CHUMBY) := chumby_falconwing +board-$(CONFIG_MACH_TUXRAIL) := busware-tuxrail board-$(CONFIG_MACH_TX28) := karo-tx28 board-$(CONFIG_MACH_FREESCALE_MX51_PDK) := freescale-mx51-pdk board-$(CONFIG_MACH_GUF_CUPID) := guf-cupid diff --git a/arch/arm/boards/busware-tuxrail/Makefile b/arch/arm/boards/busware-tuxrail/Makefile new file mode 100644 index 00000000..fbbc3879 --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/Makefile @@ -0,0 +1 @@ +obj-y = tuxrail.o diff --git a/arch/arm/boards/busware-tuxrail/config.h b/arch/arm/boards/busware-tuxrail/config.h new file mode 100644 index 00000000..87d9e2f4 --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/config.h @@ -0,0 +1,21 @@ +/* + * 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_ + +#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/busware-tuxrail/env/bin/boot b/arch/arm/boards/busware-tuxrail/env/bin/boot new file mode 100644 index 00000000..981a387a --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/env/bin/boot @@ -0,0 +1,38 @@ +#!/bin/sh + +. /env/config + +if [ x$1 = xdisk ]; then + rootfs_loc=disk + kernel_loc=disk +elif [ x$1 = xnet ]; then + rootfs_loc=net + kernel_loc=net +fi + +if [ x$ip = xdhcp ]; then + bootargs="$bootargs ip=dhcp" +elif [ x$ip = xnone ]; then + bootargs="$bootargs ip=none" +else + bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask:::" +fi + +if [ x$rootfs_loc = xdisk ]; then + bootargs="$bootargs noinitrd rootfstype=$rootfs_type root=/dev/$rootfs_part" +elif [ x$rootfs_loc = xnet ]; then + bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd" +elif [ x$rootfs_loc = xinitrd ]; then + bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init" +fi + +if [ x$kernelimage_type = xuimage ]; then + bootm /dev/$kernel_part +elif [ x$kernelimage_type = xzimage ]; then + bootz /dev/$kernel_part +else + echo "Booting failed. Correct setup of 'kernelimage_type'?" + exit +fi + +echo "Booting failed. Correct setup of 'kernel_part'?" diff --git a/arch/arm/boards/busware-tuxrail/env/bin/init b/arch/arm/boards/busware-tuxrail/env/bin/init new file mode 100644 index 00000000..3ed68f76 --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/env/bin/init @@ -0,0 +1,15 @@ +#!/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 + exit +fi + +boot diff --git a/arch/arm/boards/busware-tuxrail/env/config b/arch/arm/boards/busware-tuxrail/env/config new file mode 100644 index 00000000..c9d35ba9 --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/env/config @@ -0,0 +1,36 @@ +#!/bin/sh + +machine=tuxrail + +# use 'dhcp' to do dhcp in barebox and in kernel +# use 'none' if you want to skip kernel ip autoconfiguration +ip=none + +# or set your networking parameters here (if a USB network adapter is attached) +#eth0.ipaddr=a.b.c.d +#eth0.netmask=a.b.c.d +#eth0.gateway=a.b.c.d +#eth0.serverip=a.b.c.d + +# can be either 'net' or 'disk' +kernel_loc=disk +# can be either 'net', or 'disk' or 'initrd' +rootfs_loc=disk + +# can be any regular filesystem like ext2, ext3, reiserfs in case of 'rootfs_loc=disk' +rootfs_type=ext2 +# Where is the rootfs in case of 'rootfs_loc=disk' +rootfs_part=mmcblk0p4 + +# Where is the rootfs in case of 'rootfs_loc=net' +nfsroot=FIXME + +# The image type of the kernel. Can be uimage, zimage +kernelimage_type=uimage +# Where to get the kernel image in case of 'kernel_loc=disk' +kernel_part=disk0.2 + +# base kernel parameter +bootargs="console=ttyAM0,115200 debug ro lcd_panel=lms350 ssp1=mmc line=1 sysrq_always_enabled rotary=1" + +autoboot_timeout=2 diff --git a/arch/arm/boards/busware-tuxrail/tuxrail.c b/arch/arm/boards/busware-tuxrail/tuxrail.c new file mode 100644 index 00000000..666f5818 --- /dev/null +++ b/arch/arm/boards/busware-tuxrail/tuxrail.c @@ -0,0 +1,248 @@ +/* + * (C) Copyright 2011 Robert Schwebel - Pengutronix + * + * Based on Chumby Falconwing Code, (C) 2010 Juergen Beisert + * + * 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 <init.h> +#include <gpio.h> +#include <environment.h> +#include <errno.h> +#include <mci.h> +#include <sizes.h> +#include <usb/ehci.h> +#include <asm/armlinux.h> +#include <asm/io.h> +#include <asm/mmu.h> +#include <generated/mach-types.h> +#include <mach/imx-regs.h> +#include <mach/clock.h> +#include <mach/mci.h> +#include <mach/usb.h> + +static struct memory_platform_data ram_pdata = { + .name = "ram0", + .flags = DEVFS_RDWR, +}; + +static struct device_d sdram_dev = { + .id = -1, + .name = "mem", + .map_base = IMX_MEMORY_BASE, + .size = 64 * 1024 * 1024, + .platform_data = &ram_pdata, +}; + +static struct mxs_mci_platform_data mci_pdata = { + .caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz, + .voltages = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3 V fixed */ +}; + +static struct device_d mci_dev = { + .name = "mxs_mci", + .map_base = IMX_SSP2_BASE, + .platform_data = &mci_pdata, +}; + +static const uint32_t pad_setup[] = { + + /* sdram: not required as already done by bootlets */ + + /* gpio */ +// GPMI_WPN | GPIO_IN, /* GPIO1 */ /* FIXME does not exist? */ + GPMI_RDN_GPIO | GPIO_IN, /* GPIO2 */ + GPMI_ALE_GPIO | GPIO_IN, /* GPIO3 */ + LCD_D4_GPIO | GPIO_IN, /* GPIO4 */ + LCD_D6_GPIO | GPIO_IN, /* GPIO5 */ + LCD_RESET_GPIO | GPIO_IN, /* GPIO6 */ + GPMI_D04_GPIO | GPIO_IN, /* GPIO7 */ + GPMI_D06_GPIO | GPIO_IN, /* GPIO8 */ + + /* i2c */ + LCD_ENABE_I2C_CLK, + LCD_HSYNC_I2C_SD, + + /* sd card interface */ + GPMI_D00_SSP2_D0 | PULLUP(1), + GPMI_D01_SSP2_D1 | PULLUP(1), + GPMI_D02_SSP2_D2 | PULLUP(1), + GPMI_D03_SSP2_D3 | PULLUP(1), + GPMI_RDY1_SSP2_CMD | PULLUP(1), + GPMI_WRN_SSP2_SCK, + GPMI_RDY0_SSP2_DETECT | PULLUP(1), /* nc */ + + /* debug port */ + PWM1_DUART_TX | STRENGTH(S4MA), /* strength is TBD */ + PWM0_DUART_RX | STRENGTH(S4MA), /* strength is TBD */ + + /* led */ + PWM2_GPIO, + + /* uart */ + I2C_SDA_AUART1_RX, + I2C_CLK_AUART1_TX, + + /* spi -> ethernet */ + /* FIXME */ + + /* unused, without external pullups/downs */ + LCD_CS_GPIO | GPIO_IN | PULLUP(1), + LCD_D7_GPIO | GPIO_IN | PULLUP(1), + LCD_DOTCLOCK_GPIO | GPIO_IN | PULLUP(1), + LCD_VSYNC_GPIO | GPIO_IN | PULLUP(1), + LCD_WR_GPIO | GPIO_IN | PULLUP(1), + GPMI_CLE_GPIO | GPIO_IN | PULLUP(1), + GPMI_CE0N_GPIO | GPIO_IN | PULLUP(1), + GPMI_CE1N_GPIO | GPIO_IN | PULLUP(1), + GPMI_D05_GPIO | GPIO_IN | PULLUP(1), + GPMI_D07_GPIO | GPIO_IN | PULLUP(1), + + /* unused, with external pullups/downs */ + LCD_D0_GPIO | GPIO_IN, + LCD_D1_GPIO | GPIO_IN, + LCD_D2_GPIO | GPIO_IN, + LCD_D3_GPIO | GPIO_IN, + LCD_D5_GPIO | GPIO_IN, + LCD_RS_GPIO | GPIO_IN, +}; + +#ifdef CONFIG_MMU +static int tuxrail_mmu_init(void) +{ + mmu_init(); + + arm_create_section(0x40000000, 0x40000000, 64, PMD_SECT_DEF_CACHED); + arm_create_section(0x50000000, 0x40000000, 64, PMD_SECT_DEF_UNCACHED); + + setup_dma_coherent(0x10000000); + + mmu_enable(); + + return 0; +} +postcore_initcall(tuxrail_mmu_init); +#endif + +/** + * Try to register an environment storage on the attached MCI card + * @return 0 on success + * + * We rely on the existence of a usable SD card, already attached to + * our system, to get something like a persistent memory for our environment. + * If this SD card is also the boot media, we can use the second partition + * for our environment purpose (if present!). + */ +static int register_persistant_environment(void) +{ + struct cdev *cdev; + + /* there is only one SD card socket: disk0 */ + cdev = cdev_by_name("disk0"); + if (cdev == NULL) { + pr_err("No SD card preset\n"); + return -ENODEV; + } + + /* SD card is present, search for a partition */ + cdev = cdev_by_name("disk0.1"); + if (cdev == NULL) { + pr_err("No second partition available\n"); + pr_info("Please create at least a second partition with" + " 256 kiB...512 kiB in size (your choice)\n"); + return -ENODEV; + } + + /* use the full partition as our persistent environment storage */ + return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); +} + +static struct ehci_platform_data tuxrail_usb_pdata = { + .flags = EHCI_HAS_TT, + .hccr_offset = 0x100, + .hcor_offset = 0x140, +}; + +static struct device_d usb_dev = { + .name = "ehci", + .id = -1, + .map_base = IMX_USB_BASE, + .size = 0x200, + .platform_data = &tuxrail_usb_pdata, +}; + +#define GPIO_USB_HUB_RESET 29 +#define GPIO_USB_HUB_POWER 26 + +static void tuxrail_init_usb(void) +{ + /* power USB hub */ + gpio_direction_output(GPIO_USB_HUB_POWER, 1); + mdelay(1); + /* bring USB hub out of reset */ + gpio_direction_output(GPIO_USB_HUB_RESET, 1); + + imx_usb_phy_enable(); + register_device(&usb_dev); +} + +static int tuxrail_devices_init(void) +{ + int i, rc; + + /* initizalize gpios */ + for (i = 0; i < ARRAY_SIZE(pad_setup); i++) + imx_gpio_mode(pad_setup[i]); + + register_device(&sdram_dev); + + /* enable IOCLK to run at the PLL frequency */ + imx_set_ioclk(480*1000*1000); + + /* run the SSP unit clock at 100 MHz */ + imx_set_sspclk(0, 100*1000*1000, 1); + + register_device(&mci_dev); + + tuxrail_init_usb(); + + armlinux_add_dram(&sdram_dev); + armlinux_set_bootparams((void*)(sdram_dev.map_base + 0x100)); + armlinux_set_architecture(MACH_TYPE_TUXRAIL); + + rc = register_persistant_environment(); + if (rc != 0) + printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); + + return 0; +} + +device_initcall(tuxrail_devices_init); + +static struct device_d tuxrail_serial_device = { + .name = "stm_serial", + .map_base = IMX_DBGUART_BASE, + .size = 8192, +}; + +static int tuxrail_console_init(void) +{ + return register_device(&tuxrail_serial_device); +} + +console_initcall(tuxrail_console_init); + diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig index f9cefaf9..652cd6a7 100644 --- a/arch/arm/mach-mxs/Kconfig +++ b/arch/arm/mach-mxs/Kconfig @@ -4,12 +4,14 @@ config ARCH_TEXT_BASE hex default 0x41000000 if MACH_MX23EVK default 0x42000000 if MACH_CHUMBY + default 0x42000000 if MACH_TUXRAIL default 0x47000000 if MACH_TX28 config BOARDINFO default "Freescale i.MX23-EVK" if MACH_MX23EVK default "Chumby Falconwing" if MACH_CHUMBY default "Karo TX28" if MACH_TX28 + default "Busware TuxRail" if MACH_TUXRAIL comment "Freescale i.MX System-on-Chip" @@ -44,6 +46,12 @@ config MACH_CHUMBY Say Y here if you are using the "chumby one" aka falconwing from Chumby Industries +config MACH_TUXRAIL + bool "TuxRail" + select HAVE_MMU + help + Say Y here if you are using the Busware TuxRail board. + endchoice endif |