diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-06-18 13:51:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-07-11 09:53:16 +0200 |
commit | 1ee484f3829e3f69d43fa46aa210a12ffc610908 (patch) | |
tree | 4fb466ee1660fa7268611777a0228561ab68c902 /arch/arm/boards/tqma6x | |
parent | 24bd4d0d6fc61eb434b1cd785d349e01c7d6c1a3 (diff) | |
download | barebox-1ee484f3829e3f69d43fa46aa210a12ffc610908.tar.gz barebox-1ee484f3829e3f69d43fa46aa210a12ffc610908.tar.xz |
ARM: i.MX6: TQ tqma6x initial board support
The TQ tqma6x comes in two different variants. One i.MX6s based
tqma6s and a i.MX6q based tqma6q.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards/tqma6x')
-rw-r--r-- | arch/arm/boards/tqma6x/Makefile | 5 | ||||
-rw-r--r-- | arch/arm/boards/tqma6x/board.c | 154 | ||||
-rw-r--r-- | arch/arm/boards/tqma6x/flash-header-tqma6dl.imxcfg | 99 | ||||
-rw-r--r-- | arch/arm/boards/tqma6x/flash-header-tqma6q.imxcfg | 104 | ||||
-rw-r--r-- | arch/arm/boards/tqma6x/lowlevel.c | 88 |
5 files changed, 450 insertions, 0 deletions
diff --git a/arch/arm/boards/tqma6x/Makefile b/arch/arm/boards/tqma6x/Makefile new file mode 100644 index 0000000000..f250e5977c --- /dev/null +++ b/arch/arm/boards/tqma6x/Makefile @@ -0,0 +1,5 @@ +obj-y += board.o +obj-y += flash-header-tqma6q.dcd.o flash-header-tqma6dl.dcd.o +extra-y += flash-header-tqma6q.dcd.S flash-header-tqma6dl.dcd.S +extra-y += flash-header-tqma6q.dcd flash-header-tqma6dl.dcd +lwl-y += lowlevel.o diff --git a/arch/arm/boards/tqma6x/board.c b/arch/arm/boards/tqma6x/board.c new file mode 100644 index 0000000000..9e81a1d11d --- /dev/null +++ b/arch/arm/boards/tqma6x/board.c @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2013 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. + * + */ + +#include <generated/mach-types.h> +#include <environment.h> +#include <bootsource.h> +#include <partition.h> +#include <common.h> +#include <envfs.h> +#include <sizes.h> +#include <init.h> +#include <gpio.h> +#include <fec.h> + +#include <linux/micrel_phy.h> +#include <mfd/stmpe-i2c.h> + +#include <asm/armlinux.h> +#include <asm/io.h> + +#include <mach/devices-imx6.h> +#include <mach/imx6-regs.h> +#include <mach/iomux-mx6.h> +#include <mach/imx6-mmdc.h> +#include <mach/generic.h> +#include <mach/imx6.h> +#include <mach/bbu.h> + +#define RQ7_GPIO_ENET_PHYADD2 IMX_GPIO_NR(6, 30) +#define RQ7_GPIO_ENET_MODE0 IMX_GPIO_NR(6, 25) +#define RQ7_GPIO_ENET_MODE1 IMX_GPIO_NR(6, 27) +#define RQ7_GPIO_ENET_MODE2 IMX_GPIO_NR(6, 28) +#define RQ7_GPIO_ENET_MODE3 IMX_GPIO_NR(6, 29) +#define RQ7_GPIO_ENET_EN_CLK125 IMX_GPIO_NR(6, 24) + +static iomux_v3_cfg_t tqma6x_pads_gpio[] = { + MX6Q_PAD_RGMII_RXC__GPIO_6_30, + MX6Q_PAD_RGMII_RD0__GPIO_6_25, + MX6Q_PAD_RGMII_RD1__GPIO_6_27, + MX6Q_PAD_RGMII_RD2__GPIO_6_28, + MX6Q_PAD_RGMII_RD3__GPIO_6_29, + MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24, +}; + +static void mmd_write_reg(struct phy_device *dev, int device, int reg, int val) +{ + phy_write(dev, 0x0d, device); + phy_write(dev, 0x0e, reg); + phy_write(dev, 0x0d, (1 << 14) | device); + phy_write(dev, 0x0e, val); +} + +static int ksz9031rn_phy_fixup(struct phy_device *dev) +{ + /* + * min rx data delay, max rx/tx clock delay, + * min rx/tx control delay + */ + mmd_write_reg(dev, 2, 4, 0); + mmd_write_reg(dev, 2, 5, 0); + mmd_write_reg(dev, 2, 8, 0x003ff); + + return 0; +} + +static int tqma6x_enet_init(void) +{ + if (!of_machine_is_compatible("tq,mba6x")) + return 0; + + mxc_iomux_v3_setup_multiple_pads(tqma6x_pads_gpio, ARRAY_SIZE(tqma6x_pads_gpio)); + gpio_direction_output(RQ7_GPIO_ENET_PHYADD2, 0); + gpio_direction_output(RQ7_GPIO_ENET_MODE0, 1); + gpio_direction_output(RQ7_GPIO_ENET_MODE1, 1); + gpio_direction_output(RQ7_GPIO_ENET_MODE2, 1); + gpio_direction_output(RQ7_GPIO_ENET_MODE3, 1); + gpio_direction_output(RQ7_GPIO_ENET_EN_CLK125, 1); + + gpio_direction_output(25, 0); + mdelay(50); + + gpio_direction_output(25, 1); + mdelay(50); + + phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK, + ksz9031rn_phy_fixup); + + return 0; +} +fs_initcall(tqma6x_enet_init); + +extern char flash_header_tqma6dl_start[]; +extern char flash_header_tqma6dl_end[]; + +extern char flash_header_tqma6q_start[]; +extern char flash_header_tqma6q_end[]; + +static int tqma6x_env_init(void) +{ + void *flash_header_start; + void *flash_header_end; + + if (of_machine_is_compatible("tq,tqma6s")) { + flash_header_start = (void *)flash_header_tqma6dl_start; + flash_header_end = (void *)flash_header_tqma6dl_end; + } else if (of_machine_is_compatible("tq,tqma6q")) { + flash_header_start = (void *)flash_header_tqma6q_start; + flash_header_end = (void *)flash_header_tqma6q_end; + } else { + return 0; + } + + devfs_add_partition("m25p0", 0, SZ_512K, DEVFS_PARTITION_FIXED, "m25p0.barebox"); + + imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox", + BBU_HANDLER_FLAG_DEFAULT, (void *)flash_header_start, + flash_header_end - flash_header_start, 0); + imx6_bbu_internal_mmc_register_handler("emmc", "/dev/mmc2.boot0", + 0, (void *)flash_header_start, flash_header_end - flash_header_start, 0); + + device_detect_by_name("mmc2"); + + default_environment_path = "/dev/mmc2.boot1"; + + return 0; +} +late_initcall(tqma6x_env_init); + +static int tqma6x_core_init(void) +{ + if (!of_machine_is_compatible("tq,mba6x")) + return 0; + + imx6_init_lowlevel(); + + return 0; +} +postcore_initcall(tqma6x_core_init); diff --git a/arch/arm/boards/tqma6x/flash-header-tqma6dl.imxcfg b/arch/arm/boards/tqma6x/flash-header-tqma6dl.imxcfg new file mode 100644 index 0000000000..614b7a3da0 --- /dev/null +++ b/arch/arm/boards/tqma6x/flash-header-tqma6dl.imxcfg @@ -0,0 +1,99 @@ +soc imx6 +loadaddr 0x20000000 +dcdofs 0x400 +wm 32 0x020e04bc 0x00000030 +wm 32 0x020e04c0 0x00000030 +wm 32 0x020e04c4 0x00000030 +wm 32 0x020e04c8 0x00000030 +wm 32 0x020e04cc 0x00000030 +wm 32 0x020e04d0 0x00000030 +wm 32 0x020e04d4 0x00000030 +wm 32 0x020e04d8 0x00000030 +wm 32 0x020e0764 0x00000030 +wm 32 0x020e0770 0x00000030 +wm 32 0x020e0778 0x00000030 +wm 32 0x020e077c 0x00000030 +wm 32 0x020e0780 0x00000030 +wm 32 0x020e0784 0x00000030 +wm 32 0x020e078c 0x00000030 +wm 32 0x020e0748 0x00000030 +wm 32 0x020e074c 0x00000030 +wm 32 0x020e076c 0x00000030 +wm 32 0x020e0470 0x00020030 +wm 32 0x020e0474 0x00020030 +wm 32 0x020e0478 0x00020030 +wm 32 0x020e047c 0x00020030 +wm 32 0x020e0480 0x00020030 +wm 32 0x020e0484 0x00020030 +wm 32 0x020e0488 0x00020030 +wm 32 0x020e048c 0x00020030 +wm 32 0x020e0464 0x00020030 +wm 32 0x020e0490 0x00020030 +wm 32 0x020e04ac 0x00020030 +wm 32 0x020e04b0 0x00020030 +wm 32 0x020e0494 0x000e0030 +wm 32 0x020e04a4 0x00003000 +wm 32 0x020e04a8 0x00003000 +wm 32 0x020e04b4 0x00003030 +wm 32 0x020e04b8 0x00003030 +wm 32 0x020e0750 0x00020000 +wm 32 0x020e0760 0x00020000 +wm 32 0x020e0754 0x00000000 +wm 32 0x020e04a0 0x00000000 +wm 32 0x020e0774 0x000C0000 +wm 32 0x021b081c 0x33333333 +wm 32 0x021b0820 0x33333333 +wm 32 0x021b0824 0x33333333 +wm 32 0x021b0828 0x33333333 +wm 32 0x021b481c 0x33333333 +wm 32 0x021b4820 0x33333333 +wm 32 0x021b4824 0x33333333 +wm 32 0x021b4828 0x33333333 +wm 32 0x021b0018 0x00081740 +wm 32 0x021b001c 0x00008000 +wm 32 0x021b0004 0x0002002D +wm 32 0x021b000c 0x40435323 +wm 32 0x021b0010 0xB66E8D63 +wm 32 0x021b0014 0x01FF00DB +wm 32 0x021b002c 0x000026D2 +wm 32 0x021b0030 0x00431023 +wm 32 0x021b0008 0x00333030 +wm 32 0x021b0004 0x0002556D +wm 32 0x021b0040 0x00000017 +wm 32 0x021b0000 0x83190000 +wm 32 0x021b001c 0x04008032 +wm 32 0x021b001c 0x00008033 +wm 32 0x021b001c 0x00048031 +wm 32 0x021b001c 0x13208030 +wm 32 0x021b001c 0x04008040 +wm 32 0x021b0800 0xA1390003 +wm 32 0x021b4800 0xA1390003 +wm 32 0x021b0020 0x00005800 +wm 32 0x021b0818 0x00022227 +wm 32 0x021b4818 0x00022227 +wm 32 0x021b083c 0x42350231 +wm 32 0x021b483c 0x42350231 +wm 32 0x021b0840 0x021A0218 +wm 32 0x021b4840 0x021A0218 +wm 32 0x021b0848 0x4B4B4E49 +wm 32 0x021b4848 0x4B4B4E49 +wm 32 0x021b0850 0x3F3F3035 +wm 32 0x021b4850 0x3F3F3035 +wm 32 0x021b080c 0x0040003C +wm 32 0x021b0810 0x0032003E +wm 32 0x021b480c 0x0040003C +wm 32 0x021b4810 0x0032003E +wm 32 0x021b08b8 0x00000800 +wm 32 0x021b48b8 0x00000800 +wm 32 0x021b001c 0x00000000 +wm 32 0x021b0404 0x00011006 +wm 32 0x020C4068 0x00C03F3F +wm 32 0x020C406c 0x0030FC03 +wm 32 0x020C4070 0x0FFFC000 +wm 32 0x020C4074 0x3FF00000 +wm 32 0x020C4078 0x00FFF300 +wm 32 0x020C407c 0x0F0000C3 +wm 32 0x020C4080 0x000003FF +wm 32 0x020e0010 0xF00000CF +wm 32 0x020e0018 0x007F007F +wm 32 0x020e001c 0x007F007F diff --git a/arch/arm/boards/tqma6x/flash-header-tqma6q.imxcfg b/arch/arm/boards/tqma6x/flash-header-tqma6q.imxcfg new file mode 100644 index 0000000000..4319776645 --- /dev/null +++ b/arch/arm/boards/tqma6x/flash-header-tqma6q.imxcfg @@ -0,0 +1,104 @@ +soc imx6 +loadaddr 0x20000000 +dcdofs 0x400 + +wm 32 0x020e05a8 0x00000030 +wm 32 0x020e05b0 0x00000030 +wm 32 0x020e0524 0x00000030 +wm 32 0x020e051c 0x00000030 +wm 32 0x020e0518 0x00000030 +wm 32 0x020e050c 0x00000030 +wm 32 0x020e05b8 0x00000030 +wm 32 0x020e05c0 0x00000030 +wm 32 0x020e05ac 0x00020030 +wm 32 0x020e05b4 0x00020030 +wm 32 0x020e0528 0x00020030 +wm 32 0x020e0520 0x00020030 +wm 32 0x020e0514 0x00020030 +wm 32 0x020e0510 0x00020030 +wm 32 0x020e05bc 0x00020030 +wm 32 0x020e05c4 0x00020030 +wm 32 0x020e056c 0x00020030 +wm 32 0x020e0578 0x00020030 +wm 32 0x020e0588 0x00020030 +wm 32 0x020e0594 0x00020030 +wm 32 0x020e057c 0x00020030 +wm 32 0x020e0590 0x00003000 +wm 32 0x020e0598 0x00003000 +wm 32 0x020e058c 0x00000000 +wm 32 0x020e059c 0x00003030 +wm 32 0x020e05a0 0x00003030 +wm 32 0x020e0784 0x00000030 +wm 32 0x020e0788 0x00000030 +wm 32 0x020e0794 0x00000030 +wm 32 0x020e079c 0x00000030 +wm 32 0x020e07a0 0x00000030 +wm 32 0x020e07a4 0x00000030 +wm 32 0x020e07a8 0x00000030 +wm 32 0x020e0748 0x00000030 +wm 32 0x020e074c 0x00000030 +wm 32 0x020e0750 0x00020000 +wm 32 0x020e0758 0x00000000 +wm 32 0x020e0774 0x00020000 +wm 32 0x020e078c 0x00000030 +wm 32 0x020e0798 0x000c0000 +wm 32 0x021b081c 0x33333333 +wm 32 0x021b0820 0x33333333 +wm 32 0x021b0824 0x33333333 +wm 32 0x021b0828 0x33333333 +wm 32 0x021b481c 0x33333333 +wm 32 0x021b4820 0x33333333 +wm 32 0x021b4824 0x33333333 +wm 32 0x021b4828 0x33333333 +wm 32 0x021b0018 0x00081740 +wm 32 0x021b001c 0x00008000 +wm 32 0x021b000c 0x555a7974 +wm 32 0x021b0010 0xdb538f64 +wm 32 0x021b0014 0x01ff00db +wm 32 0x021b002c 0x000026d2 +wm 32 0x021b0030 0x005a1023 +wm 32 0x021b0008 0x09444040 +wm 32 0x021b0004 0x00025576 +wm 32 0x021b0040 0x00000027 +wm 32 0x021b0000 0x831a0000 +wm 32 0x021b001c 0x04088032 +wm 32 0x021b001c 0x0408803a +wm 32 0x021b001c 0x00008033 +wm 32 0x021b001c 0x0000803b +wm 32 0x021b001c 0x00428031 +wm 32 0x021b001c 0x00428039 +wm 32 0x021b001c 0x19308030 +wm 32 0x021b001c 0x19308038 +wm 32 0x021b001c 0x04008040 +wm 32 0x021b001c 0x04008048 +wm 32 0x021b0800 0xa1380003 +wm 32 0x021b4800 0xa1380003 +wm 32 0x021b0020 0x00005800 +wm 32 0x021b0818 0x00022227 +wm 32 0x021b4818 0x00022227 +wm 32 0x021b083c 0x434b0350 +wm 32 0x021b0840 0x034c0359 +wm 32 0x021b483c 0x434b0350 +wm 32 0x021b4840 0x03650348 +wm 32 0x021b0848 0x4436383b +wm 32 0x021b4848 0x39393341 +wm 32 0x021b0850 0x35373933 +wm 32 0x021b4850 0x48254a36 +wm 32 0x021b080c 0x001f001f +wm 32 0x021b0810 0x001f001f +wm 32 0x021b480c 0x00440044 +wm 32 0x021b4810 0x00440044 +wm 32 0x021b08b8 0x00000800 +wm 32 0x021b48b8 0x00000800 +wm 32 0x021b001c 0x00000000 +wm 32 0x021b0404 0x00011006 +wm 32 0x020c4068 0x00c03f3f +wm 32 0x020c406c 0x0030fc03 +wm 32 0x020c4070 0x0fffc000 +wm 32 0x020c4074 0x3ff00000 +wm 32 0x020c4078 0x00fff300 +wm 32 0x020c407c 0x0f0000c3 +wm 32 0x020c4080 0x000003ff +wm 32 0x020e0010 0xf00000cf +wm 32 0x020e0018 0x007f007f +wm 32 0x020e001c 0x007f007f diff --git a/arch/arm/boards/tqma6x/lowlevel.c b/arch/arm/boards/tqma6x/lowlevel.c new file mode 100644 index 0000000000..8c8684123a --- /dev/null +++ b/arch/arm/boards/tqma6x/lowlevel.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2013 Sascha Hauer <s.hauer@pengutronix.de> + * + * 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 <debug_ll.h> +#include <common.h> +#include <sizes.h> +#include <io.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <asm/sections.h> +#include <asm/cache.h> +#include <asm/mmu.h> +#include <mach/imx6-mmdc.h> +#include <mach/imx6.h> + +static inline void setup_uart(void) +{ + /* Enable UART for lowlevel debugging purposes */ + writel(0x00000000, 0x021e8080); + writel(0x00004027, 0x021e8084); + writel(0x00000704, 0x021e8088); + writel(0x00000a81, 0x021e8090); + writel(0x0000002b, 0x021e809c); + writel(0x00013880, 0x021e80b0); + writel(0x0000047f, 0x021e80a4); + writel(0x0000c34f, 0x021e80a8); + writel(0x00000001, 0x021e8080); +} + +extern char __dtb_imx6q_mba6x_start[]; +extern char __dtb_imx6dl_mba6x_start[]; + +ENTRY_FUNCTION(start_imx6q_mba6x)(void) +{ + uint32_t fdt; + + __barebox_arm_head(); + + arm_cpu_lowlevel_init(); + + arm_setup_stack(0x00920000 - 8); + + if (IS_ENABLED(CONFIG_DEBUG_LL)) { + writel(0x2, 0x020e0338); + setup_uart(); + PUTC_LL('a'); + } + + arm_early_mmu_cache_invalidate(); + + fdt = (uint32_t)__dtb_imx6q_mba6x_start - get_runtime_offset(); + + barebox_arm_entry(0x10000000, SZ_1G, fdt); +} + +ENTRY_FUNCTION(start_imx6dl_mba6x)(void) +{ + uint32_t fdt; + + __barebox_arm_head(); + + arm_cpu_lowlevel_init(); + + arm_setup_stack(0x00920000 - 8); + + if (IS_ENABLED(CONFIG_DEBUG_LL)) { + writel(0x2, 0x020e035c); + setup_uart(); + PUTC_LL('a'); + } + + arm_early_mmu_cache_invalidate(); + + fdt = (uint32_t)__dtb_imx6dl_mba6x_start - get_runtime_offset(); + + barebox_arm_entry(0x10000000, SZ_512M, fdt); +} |