summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2011-04-21 17:59:25 +0200
committerRobert Schwebel <r.schwebel@pengutronix.de>2011-06-24 14:25:57 +0200
commit344c9bed59fcf90d12c28ed3df9e947642046a12 (patch)
tree77d1d04da63877bade21ea2d998967e3eb8999b3
parent1ca6aa59ac2a87b9ddb3e79ee7314646974f4c94 (diff)
downloadbarebox-344c9bed59fcf90d12c28ed3df9e947642046a12.tar.gz
barebox-344c9bed59fcf90d12c28ed3df9e947642046a12.tar.xz
tuxrail: add support for busware tuxrail
Add barebox support for the Busware TuxRail board: http://www.busware.de/tiki-index.php?page=TuxRail Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
-rw-r--r--arch/arm/Makefile1
-rw-r--r--arch/arm/boards/busware-tuxrail/Makefile1
-rw-r--r--arch/arm/boards/busware-tuxrail/config.h21
-rw-r--r--arch/arm/boards/busware-tuxrail/env/bin/boot82
-rw-r--r--arch/arm/boards/busware-tuxrail/env/bin/init15
-rw-r--r--arch/arm/boards/busware-tuxrail/env/config40
-rw-r--r--arch/arm/boards/busware-tuxrail/tuxrail.c280
-rw-r--r--arch/arm/configs/tuxrail_defconfig42
-rw-r--r--arch/arm/mach-mxs/Kconfig8
9 files changed, 490 insertions, 0 deletions
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 49139a00..91186be1 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -100,6 +100,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..aa42b70c
--- /dev/null
+++ b/arch/arm/boards/busware-tuxrail/env/bin/boot
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x$1 = xdisk ]; then
+ rootfs_loc=disk
+ kernel_loc=disk
+elif [ x$1 = xnfs ]; then
+ rootfs_loc=net
+ kernel_loc=nfs
+elif [ x$1 = xtftp ]; then
+ rootfs_loc=net
+ kernel_loc=tftp
+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 [ ! -e /dev/ram0.kernelraw ]; then
+ # arm raw kernel images are usually located at sdram start + 0x8000
+ addpart /dev/ram0 8M@0x8000(kernelraw)
+fi
+
+if [ ! -e /dev/ram0.kernel ]; then
+ # Here we can safely put the kernel without risking of overwriting it
+ # while extracting
+ addpart /dev/ram0 8M@8M(kernel)
+fi
+
+if [ x$kernel_loc = xnfs ] || [ x$kernel_loc = xtftp ]; then
+ if [ x$ip = xdhcp ]; then
+ dhcp
+ fi
+ if [ $kernelimage_type = uimage ]; then
+ netload="/dev/ram0.kernel"
+ elif [ $kernelimage_type = zimage ]; then
+ netload="/dev/ram0.kernel"
+ elif [ $kernelimage_type = raw ]; then
+ netload="/dev/ram0.kernelraw"
+ elif [ $kernelimage_type = raw_lzo ]; then
+ netload="/dev/ram0.kernel"
+ else
+ echo "error: set kernelimage_type to one of 'uimage', 'zimage', 'raw' or 'raw_lzo'"
+ exit 1
+ fi
+ $kernel_loc $kernelimage $netload || exit 1
+ kdev="$netload"
+elif [ x$kernel_loc = xdisk ]; then
+ kdev="/dev/$kernel_part"
+else
+ echo "error: set kernel_loc to one of 'nfs', 'tftp'"
+ exit 1
+fi
+
+echo "booting kernel of type $kernelimage_type from $kdev"
+
+if [ x$kernelimage_type = xuimage ]; then
+ bootm $kdev
+elif [ x$kernelimage_type = xzimage ]; then
+ bootz $kdev
+elif [ x$kernelimage_type = xraw ]; then
+ if [ $kernel_loc != net ]; then
+ cp $kdev /dev/ram0.kernelraw
+ fi
+ bootu /dev/ram0.kernelraw
+elif [ x$kernelimage_type = xraw_lzo ]; then
+ unlzo $kdev /dev/ram0.kernelraw
+ bootu /dev/ram0.kernelraw
+fi
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..5e2d0f12
--- /dev/null
+++ b/arch/arm/boards/busware-tuxrail/env/config
@@ -0,0 +1,40 @@
+#!/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 'nfs', 'tftp' or 'disk'
+kernel_loc=disk
+# can be either 'net' or 'disk'
+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
+
+# What name to be used to load the kernel when 'kernel_loc=tftp'
+kernelimage=uImage.$machine
+
+# Where to get the kernel image in case of 'kernel_loc=disk'
+kernel_part=disk0.2
+
+# base kernel parameter
+bootargs="console=ttyAM0,115200 debug rw"
+
+autoboot_timeout=3
diff --git a/arch/arm/boards/busware-tuxrail/tuxrail.c b/arch/arm/boards/busware-tuxrail/tuxrail.c
new file mode 100644
index 00000000..b10cf4c3
--- /dev/null
+++ b/arch/arm/boards/busware-tuxrail/tuxrail.c
@@ -0,0 +1,280 @@
+/*
+ * (C) Copyright 2011 Juergen Beisert - Pengutronix
+ * (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.
+ *
+ */
+#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>
+#include <mach/pmic-imx23.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 */
+
+ LCD_VSYNC | GPIO_OUT | GPIO_VALUE(0), /* reset the USB LAN */
+
+ /* gpio */
+ GPMI_WRN | GPIO_IN, /* GPIO1 */ /* FIXME: datasheet says WPN */
+ 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 | PULLUP(1), /* pullup to avoid noise */
+
+ /* led */
+ PWM2_GPIO,
+
+ /* uart */
+ I2C_SDA_AUART1_RX,
+ I2C_CLK_AUART1_TX,
+
+ /* spi -> ethernet */
+ SSP1_CMD_GPIO | GPIO_OUT | GPIO_VALUE(0), /* MOSI FIXME strength? */
+ SSP1_DATA0_GPIO | GPIO_IN, /* MISO FIXME pullup? */
+ SSP1_DATA1_GPIO | GPIO_IN, /* DATA1 -> IRQ FIXME init? pullup? */
+ SSP1_DATA2_GPIO | GPIO_OUT | GPIO_VALUE(1), /* V33ENABLE FIXME init */
+ SSP1_DATA3_GPIO | GPIO_OUT | GPIO_VALUE(0), /* Slave Select */
+ SSP1_DETECT_GPIO | GPIO_OUT | GPIO_VALUE(1), /* #Reset */
+ SSP1_SCK_GPIO | GPIO_OUT | GPIO_VALUE(0), /* SCLK */
+
+ /* 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,
+
+ LCD_VSYNC | GPIO_OUT | GPIO_VALUE(1), /* release the reset to the USB LAN */
+};
+
+#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_persistent_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,
+};
+
+/*
+ * VDDIO: Voltage level to the outer world is 3.3 V
+ */
+static const struct rail_voltage tuxrail_vddio = {
+ .main_mV = 3300,
+ .guard_mV = 3300 - 175,
+ .lin_mV = 3300 - 25, /* linear regulator cannot be disabled */
+};
+
+/*
+ * VDDA: Voltage level depends on VDDIO
+ */
+static const struct rail_voltage tuxrail_vdda = {
+ .main_mV = 1800,
+ .guard_mV = 1800 - 175,
+ .lin_mV = 0, /* disable the linear regulator */
+};
+
+/*
+ * Voltage level of VDDD depends on VDDA
+ * To run the CPU core at 454 MHz VDDD must be at least at 1.55 V!
+ */
+static const struct rail_voltage tuxrail_vddd = {
+ .main_mV = 1550,
+ .guard_mV = 1550 - 175,
+ .lin_mV = 0, /* disable the linear regulator */
+};
+
+static int tuxrail_devices_init(void)
+{
+ int i, rc;
+
+ /* initialize voltages */
+ switch_to_dcdc();
+
+ setup_vddio_voltage(&tuxrail_vddio);
+ setup_vdda_voltage(&tuxrail_vdda);
+ setup_vddd_voltage(&tuxrail_vddd);
+
+ /* now we are ready to switch the clock to 454 MHz */
+ imx_set_hclk(3);
+ imx_set_armclk(455 * 1000 * 1000);
+
+ /* initialize 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);
+
+ imx_usb_phy_enable();
+ register_device(&usb_dev);
+
+ armlinux_add_dram(&sdram_dev);
+ armlinux_set_bootparams((void*)(sdram_dev.map_base + 0x100));
+ armlinux_set_architecture(MACH_TYPE_TUXRAIL);
+
+ rc = register_persistent_environment();
+ if (rc != 0)
+ printf("Cannot create the 'env0' persistent 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/configs/tuxrail_defconfig b/arch/arm/configs/tuxrail_defconfig
new file mode 100644
index 00000000..476ea229
--- /dev/null
+++ b/arch/arm/configs/tuxrail_defconfig
@@ -0,0 +1,42 @@
+CONFIG_ARCH_MXS=y
+CONFIG_MACH_TUXRAIL=y
+CONFIG_AEABI=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_TEXT_BASE=0x41000000
+CONFIG_BROKEN=y
+CONFIG_PROMPT="tuxrail:"
+CONFIG_LONGHELP=y
+CONFIG_GLOB=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_PARTITION=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/busware-tuxrail/env"
+CONFIG_DEBUG_INFO=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_MTEST=y
+CONFIG_CMD_MTEST_ALTERNATIVE=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_GPIO=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+CONFIG_NET_PING=y
+CONFIG_NET_TFTP=y
+CONFIG_NET_USB=y
+CONFIG_NET_USB_ASIX=y
+CONFIG_NET_USB_SMSC95XX=y
+# CONFIG_SPI is not set
+CONFIG_USB=y
+CONFIG_USB_EHCI=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_MXS=y
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