2010-10-24 18:53:13 +00:00
|
|
|
/*
|
2009-03-26 12:16:36 +00:00
|
|
|
* 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 <common.h>
|
|
|
|
#include <net.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <environment.h>
|
2009-10-22 12:21:25 +00:00
|
|
|
#include <mach/imx-regs.h>
|
2009-03-26 12:16:36 +00:00
|
|
|
#include <fec.h>
|
2009-10-22 12:21:25 +00:00
|
|
|
#include <mach/gpio.h>
|
2009-03-26 12:16:36 +00:00
|
|
|
#include <asm/armlinux.h>
|
2010-09-16 08:28:38 +00:00
|
|
|
#include <generated/mach-types.h>
|
2009-03-26 12:16:36 +00:00
|
|
|
#include <partition.h>
|
|
|
|
#include <fs.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <nand.h>
|
|
|
|
#include <spi/spi.h>
|
|
|
|
#include <asm/io.h>
|
2009-10-22 12:21:25 +00:00
|
|
|
#include <mach/imx-nand.h>
|
|
|
|
#include <mach/imx-pll.h>
|
2009-06-25 14:21:10 +00:00
|
|
|
#include <gpio.h>
|
2009-09-09 09:31:30 +00:00
|
|
|
#include <asm/mmu.h>
|
2009-09-09 09:32:05 +00:00
|
|
|
#include <usb/isp1504.h>
|
2010-06-16 12:30:07 +00:00
|
|
|
#include <mach/iomux-mx27.h>
|
2010-10-24 18:53:13 +00:00
|
|
|
#include <mach/devices-imx27.h>
|
2009-03-26 12:16:36 +00:00
|
|
|
|
|
|
|
static struct fec_platform_data fec_info = {
|
|
|
|
.xcv_type = MII100,
|
|
|
|
.phy_addr = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct imx_nand_platform_data nand_info = {
|
|
|
|
.width = 1,
|
|
|
|
.hw_ecc = 1,
|
2010-10-21 07:11:54 +00:00
|
|
|
.flash_bbt = 1,
|
2009-03-26 12:16:36 +00:00
|
|
|
};
|
|
|
|
|
2009-09-09 09:32:05 +00:00
|
|
|
#ifdef CONFIG_USB
|
2011-01-14 19:02:12 +00:00
|
|
|
static void pca100_usb_register(void)
|
2009-09-09 09:32:05 +00:00
|
|
|
{
|
|
|
|
mdelay(10);
|
|
|
|
|
2009-10-09 09:56:21 +00:00
|
|
|
gpio_direction_output(GPIO_PORTB + 24, 0);
|
2011-01-14 19:02:12 +00:00
|
|
|
gpio_direction_output(GPIO_PORTB + 23, 0);
|
2009-09-09 09:32:05 +00:00
|
|
|
|
|
|
|
mdelay(10);
|
|
|
|
|
2011-01-14 19:02:12 +00:00
|
|
|
isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x170), 1);
|
2011-07-23 00:08:15 +00:00
|
|
|
add_generic_usb_ehci_device(-1, IMX_OTG_BASE, NULL);
|
2009-09-09 09:32:05 +00:00
|
|
|
isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x570), 1);
|
2011-07-23 00:08:15 +00:00
|
|
|
add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
|
2009-09-09 09:32:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-07-29 09:43:48 +00:00
|
|
|
static int pca100_mem_init(void)
|
2009-09-09 09:31:30 +00:00
|
|
|
{
|
2011-07-29 09:43:48 +00:00
|
|
|
arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mem_initcall(pca100_mem_init);
|
2009-09-09 09:31:30 +00:00
|
|
|
|
2011-01-14 19:02:12 +00:00
|
|
|
static void pca100_usb_init(void)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = readl(IMX_OTG_BASE + 0x600);
|
|
|
|
reg &= ~((3 << 21) | 1);
|
|
|
|
reg |= (1 << 5) | (1 << 16) | (1 << 19) | (1 << 11) | (1 << 20);
|
|
|
|
writel(reg, IMX_OTG_BASE + 0x600);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* switch usbotg and usbh2 to ulpi mode. Do this *before*
|
|
|
|
* the iomux setup to prevent funny hardware bugs from
|
|
|
|
* triggering. Also, do this even when USB support is
|
|
|
|
* disabled to give Linux USB support a good start.
|
|
|
|
*/
|
|
|
|
reg = readl(IMX_OTG_BASE + 0x584);
|
|
|
|
reg &= ~(3 << 30);
|
|
|
|
reg |= 2 << 30;
|
|
|
|
writel(reg, IMX_OTG_BASE + 0x584);
|
|
|
|
|
|
|
|
reg = readl(IMX_OTG_BASE + 0x184);
|
|
|
|
reg &= ~(3 << 30);
|
|
|
|
reg |= 2 << 30;
|
|
|
|
writel(reg, IMX_OTG_BASE + 0x184);
|
|
|
|
|
|
|
|
/* disable the usb phys */
|
|
|
|
imx_gpio_mode((GPIO_PORTB | 23) | GPIO_GPIO | GPIO_IN);
|
|
|
|
gpio_direction_output(GPIO_PORTB + 23, 1);
|
|
|
|
imx_gpio_mode((GPIO_PORTB | 24) | GPIO_GPIO | GPIO_IN);
|
|
|
|
gpio_direction_output(GPIO_PORTB + 24, 1);
|
|
|
|
}
|
|
|
|
|
2009-03-26 12:16:36 +00:00
|
|
|
static int pca100_devices_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
2009-06-10 15:30:16 +00:00
|
|
|
struct device_d *nand;
|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_AF_USBH2_DATA4,
|
|
|
|
PD20_AF_USBH2_DATA3,
|
|
|
|
PD21_AF_USBH2_DATA6,
|
|
|
|
PD22_AF_USBH2_DATA0,
|
|
|
|
PD23_AF_USBH2_DATA2,
|
|
|
|
PD24_AF_USBH2_DATA1,
|
|
|
|
PD26_AF_USBH2_DATA5,
|
2010-10-08 16:30:58 +00:00
|
|
|
/* SDHC */
|
|
|
|
PB4_PF_SD2_D0,
|
|
|
|
PB5_PF_SD2_D1,
|
|
|
|
PB6_PF_SD2_D2,
|
|
|
|
PB7_PF_SD2_D3,
|
|
|
|
PB8_PF_SD2_CMD,
|
|
|
|
PB9_PF_SD2_CLK,
|
2011-01-14 19:02:12 +00:00
|
|
|
PC7_PF_USBOTG_DATA5,
|
|
|
|
PC8_PF_USBOTG_DATA6,
|
|
|
|
PC9_PF_USBOTG_DATA0,
|
|
|
|
PC10_PF_USBOTG_DATA2,
|
|
|
|
PC11_PF_USBOTG_DATA1,
|
|
|
|
PC12_PF_USBOTG_DATA4,
|
|
|
|
PC13_PF_USBOTG_DATA3,
|
|
|
|
PE0_PF_USBOTG_NXT,
|
|
|
|
PE1_PF_USBOTG_STP,
|
|
|
|
PE2_PF_USBOTG_DIR,
|
|
|
|
PE24_PF_USBOTG_CLK,
|
|
|
|
PE25_PF_USBOTG_DATA7,
|
2009-03-26 12:16:36 +00:00
|
|
|
};
|
|
|
|
|
2010-10-08 16:30:58 +00:00
|
|
|
PCCR0 |= PCCR0_SDHC2_EN;
|
|
|
|
|
2011-01-14 19:02:12 +00:00
|
|
|
pca100_usb_init();
|
2009-06-25 14:21:10 +00:00
|
|
|
|
2009-09-09 09:32:05 +00:00
|
|
|
/* initizalize gpios */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(mode); i++)
|
|
|
|
imx_gpio_mode(mode[i]);
|
|
|
|
|
2010-10-24 18:53:13 +00:00
|
|
|
imx27_add_nand(&nand_info);
|
|
|
|
imx27_add_fec(&fec_info);
|
|
|
|
imx27_add_mmc0(NULL);
|
2009-03-26 12:16:36 +00:00
|
|
|
|
|
|
|
PCCR1 |= PCCR1_PERCLK2_EN;
|
|
|
|
|
2009-09-09 09:32:05 +00:00
|
|
|
#ifdef CONFIG_USB
|
2011-01-14 19:02:12 +00:00
|
|
|
pca100_usb_register();
|
2009-09-09 09:32:05 +00:00
|
|
|
#endif
|
|
|
|
|
2009-06-11 10:51:26 +00:00
|
|
|
nand = get_device_by_name("nand0");
|
2009-06-10 15:30:16 +00:00
|
|
|
devfs_add_partition("nand0", 0x00000, 0x40000, PARTITION_FIXED, "self_raw");
|
|
|
|
dev_add_bb_dev("self_raw", "self0");
|
2009-03-26 12:16:36 +00:00
|
|
|
|
2009-06-10 15:30:16 +00:00
|
|
|
devfs_add_partition("nand0", 0x40000, 0x20000, PARTITION_FIXED, "env_raw");
|
|
|
|
dev_add_bb_dev("env_raw", "env0");
|
2009-03-26 12:16:36 +00:00
|
|
|
|
|
|
|
armlinux_set_bootparams((void *)0xa0000100);
|
|
|
|
armlinux_set_architecture(2149);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(pca100_devices_init);
|
|
|
|
|
|
|
|
static int pca100_console_init(void)
|
|
|
|
{
|
2011-07-28 07:14:50 +00:00
|
|
|
imx27_add_uart0();
|
2009-03-26 12:16:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
console_initcall(pca100_console_init);
|
|
|
|
|
|
|
|
#ifdef CONFIG_NAND_IMX_BOOT
|
|
|
|
void __bare_init nand_boot(void)
|
|
|
|
{
|
2009-10-23 11:43:36 +00:00
|
|
|
imx_nand_load_image((void *)TEXT_BASE, 256 * 1024);
|
2009-03-26 12:16:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|