| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 | /* * Copyright (C) 2009 Integration Software and Electronic Engineering. * * Modified from mach-omap2/board-generic.c * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/kernel.h>#include <linux/init.h>#include <linux/platform_device.h>#include <linux/delay.h>#include <linux/err.h>#include <linux/clk.h>#include <linux/io.h>#include <linux/gpio.h>#include <linux/interrupt.h>#include <linux/input.h>#include <linux/regulator/machine.h>#include <linux/regulator/fixed.h>#include <linux/i2c/twl.h>#include <linux/mmc/host.h>#include <linux/mtd/nand.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <video/omapdss.h>#include <video/omap-panel-tfp410.h>#include <linux/platform_data/mtd-onenand-omap2.h>#include "common.h"#include "gpmc.h"#include "mux.h"#include "hsmmc.h"#include "sdram-numonyx-m65kxxxxam.h"#include "common-board-devices.h"#include "board-flash.h"#include "control.h"#include "gpmc-onenand.h"#define IGEP2_SMSC911X_CS       5#define IGEP2_SMSC911X_GPIO     176#define IGEP2_GPIO_USBH_NRESET  24#define IGEP2_GPIO_LED0_GREEN   26#define IGEP2_GPIO_LED0_RED     27#define IGEP2_GPIO_LED1_RED     28#define IGEP2_GPIO_DVI_PUP      170#define IGEP2_RB_GPIO_WIFI_NPD     94#define IGEP2_RB_GPIO_WIFI_NRESET  95#define IGEP2_RB_GPIO_BT_NRESET    137#define IGEP2_RC_GPIO_WIFI_NPD     138#define IGEP2_RC_GPIO_WIFI_NRESET  139#define IGEP2_RC_GPIO_BT_NRESET    137#define IGEP3_GPIO_LED0_GREEN	54#define IGEP3_GPIO_LED0_RED	53#define IGEP3_GPIO_LED1_RED	16#define IGEP3_GPIO_USBH_NRESET  183#define IGEP_SYSBOOT_MASK           0x1f#define IGEP_SYSBOOT_NAND           0x0f#define IGEP_SYSBOOT_ONENAND        0x10/* * IGEP2 Hardware Revision Table * *  -------------------------------------------------------------------------- * | Id. | Hw Rev.            | HW0 (28) | WIFI_NPD | WIFI_NRESET | BT_NRESET | *  -------------------------------------------------------------------------- * |  0  | B                  |   high   |  gpio94  |   gpio95    |     -     | * |  0  | B/C (B-compatible) |   high   |  gpio94  |   gpio95    |  gpio137  | * |  1  | C                  |   low    |  gpio138 |   gpio139   |  gpio137  | *  -------------------------------------------------------------------------- */#define IGEP2_BOARD_HWREV_B	0#define IGEP2_BOARD_HWREV_C	1#define IGEP3_BOARD_HWREV	2static u8 hwrev;static void __init igep2_get_revision(void){	u8 ret;	if (machine_is_igep0030()) {		hwrev = IGEP3_BOARD_HWREV;		return;	}	omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT);	if (gpio_request_one(IGEP2_GPIO_LED1_RED, GPIOF_IN, "GPIO_HW0_REV")) {		pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");		pr_err("IGEP2: Unknown Hardware Revision\n");		return;	}	ret = gpio_get_value(IGEP2_GPIO_LED1_RED);	if (ret == 0) {		pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");		hwrev = IGEP2_BOARD_HWREV_C;	} else if (ret ==  1) {		pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");		hwrev = IGEP2_BOARD_HWREV_B;	} else {		pr_err("IGEP2: Unknown Hardware Revision\n");		hwrev = -1;	}	gpio_free(IGEP2_GPIO_LED1_RED);}#if defined(CONFIG_MTD_ONENAND_OMAP2) ||		\	defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) ||	\	defined(CONFIG_MTD_NAND_OMAP2) ||		\	defined(CONFIG_MTD_NAND_OMAP2_MODULE)#define ONENAND_MAP             0x20000000/* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY ) * Since the device is equipped with two DataRAMs, and two-plane NAND * Flash memory array, these two component enables simultaneous program * of 4KiB. Plane1 has only even blocks such as block0, block2, block4 * while Plane2 has only odd blocks such as block1, block3, block5. * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048) */static struct mtd_partition igep_flash_partitions[] = {	{		.name           = "X-Loader",		.offset         = 0,		.size           = 2 * (64*(2*2048))	},	{		.name           = "U-Boot",		.offset         = MTDPART_OFS_APPEND,		.size           = 6 * (64*(2*2048)),	},	{		.name           = "Environment",		.offset         = MTDPART_OFS_APPEND,		.size           = 2 * (64*(2*2048)),	},	{		.name           = "Kernel",		.offset         = MTDPART_OFS_APPEND,		.size           = 12 * (64*(2*2048)),	},	{		.name           = "File System",		.offset         = MTDPART_OFS_APPEND,		.size           = MTDPART_SIZ_FULL,	},};static inline u32 igep_get_sysboot_value(void){	return omap_ctrl_readl(OMAP343X_CONTROL_STATUS) & IGEP_SYSBOOT_MASK;}static void __init igep_flash_init(void){	u32 mux;	mux = igep_get_sysboot_value();	if (mux == IGEP_SYSBOOT_NAND) {		pr_info("IGEP: initializing NAND memory device\n");		board_nand_init(igep_flash_partitions,				ARRAY_SIZE(igep_flash_partitions),				0, NAND_BUSWIDTH_16, nand_default_timings);	} else if (mux == IGEP_SYSBOOT_ONENAND) {		pr_info("IGEP: initializing OneNAND memory device\n");		board_onenand_init(igep_flash_partitions,				   ARRAY_SIZE(igep_flash_partitions), 0);	} else {		pr_err("IGEP: Flash: unsupported sysboot sequence found\n");	}}#elsestatic void __init igep_flash_init(void) {}#endif#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)#include <linux/smsc911x.h>#include "gpmc-smsc911x.h"static struct omap_smsc911x_platform_data smsc911x_cfg = {	.cs             = IGEP2_SMSC911X_CS,	.gpio_irq       = IGEP2_SMSC911X_GPIO,	.gpio_reset     = -EINVAL,	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,};static inline void __init igep2_init_smsc911x(void){	gpmc_smsc911x_init(&smsc911x_cfg);}#elsestatic inline void __init igep2_init_smsc911x(void) { }#endifstatic struct regulator_consumer_supply igep_vmmc1_supply[] = {	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),};/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */static struct regulator_init_data igep_vmmc1 = {	.constraints = {		.min_uV			= 1850000,		.max_uV			= 3150000,		.valid_modes_mask	= REGULATOR_MODE_NORMAL					| REGULATOR_MODE_STANDBY,		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE					| REGULATOR_CHANGE_MODE					| REGULATOR_CHANGE_STATUS,	},	.num_consumer_supplies  = ARRAY_SIZE(igep_vmmc1_supply),	.consumer_supplies      = igep_vmmc1_supply,};static struct regulator_consumer_supply igep_vio_supply[] = {	REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),};static struct regulator_init_data igep_vio = {	.constraints = {		.min_uV			= 1800000,		.max_uV			= 1800000,		.apply_uV		= 1,		.valid_modes_mask	= REGULATOR_MODE_NORMAL					| REGULATOR_MODE_STANDBY,		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE					| REGULATOR_CHANGE_MODE					| REGULATOR_CHANGE_STATUS,	},	.num_consumer_supplies  = ARRAY_SIZE(igep_vio_supply),	.consumer_supplies      = igep_vio_supply,};static struct regulator_consumer_supply igep_vmmc2_supply[] = {	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),};static struct regulator_init_data igep_vmmc2 = {	.constraints		= {		.valid_modes_mask	= REGULATOR_MODE_NORMAL,		.always_on		= 1,	},	.num_consumer_supplies	= ARRAY_SIZE(igep_vmmc2_supply),	.consumer_supplies	= igep_vmmc2_supply,};static struct fixed_voltage_config igep_vwlan = {	.supply_name		= "vwlan",	.microvolts		= 3300000,	.gpio			= -EINVAL,	.enabled_at_boot	= 1,	.init_data		= &igep_vmmc2,};static struct platform_device igep_vwlan_device = {	.name		= "reg-fixed-voltage",	.id		= 0,	.dev = {		.platform_data	= &igep_vwlan,	},};static struct omap2_hsmmc_info mmc[] = {	{		.mmc		= 1,		.caps		= MMC_CAP_4_BIT_DATA,		.gpio_cd	= -EINVAL,		.gpio_wp	= -EINVAL,		.deferred	= true,	},#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)	{		.mmc		= 2,		.caps		= MMC_CAP_4_BIT_DATA,		.gpio_cd	= -EINVAL,		.gpio_wp	= -EINVAL,	},#endif	{}      /* Terminator */};#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)#include <linux/leds.h>static struct gpio_led igep_gpio_leds[] = {	[0] = {		.name			= "gpio-led:red:d0",		.default_trigger	= "default-off"	},	[1] = {		.name			= "gpio-led:green:d0",		.default_trigger	= "default-off",	},	[2] = {		.name			= "gpio-led:red:d1",		.default_trigger	= "default-off",	},	[3] = {		.name			= "gpio-led:green:d1",		.default_trigger	= "heartbeat",		.gpio			= -EINVAL, /* gets replaced */		.active_low		= 1,	},};static struct gpio_led_platform_data igep_led_pdata = {	.leds           = igep_gpio_leds,	.num_leds       = ARRAY_SIZE(igep_gpio_leds),};static struct platform_device igep_led_device = {	 .name   = "leds-gpio",	 .id     = -1,	 .dev    = {		 .platform_data  =  &igep_led_pdata,	},};static void __init igep_leds_init(void){	if (machine_is_igep0020()) {		igep_gpio_leds[0].gpio = IGEP2_GPIO_LED0_RED;		igep_gpio_leds[1].gpio = IGEP2_GPIO_LED0_GREEN;		igep_gpio_leds[2].gpio = IGEP2_GPIO_LED1_RED;	} else {		igep_gpio_leds[0].gpio = IGEP3_GPIO_LED0_RED;		igep_gpio_leds[1].gpio = IGEP3_GPIO_LED0_GREEN;		igep_gpio_leds[2].gpio = IGEP3_GPIO_LED1_RED;	}	platform_device_register(&igep_led_device);}#elsestatic struct gpio igep_gpio_leds[] __initdata = {	{ -EINVAL,	GPIOF_OUT_INIT_LOW, "gpio-led:red:d0"   },	{ -EINVAL,	GPIOF_OUT_INIT_LOW, "gpio-led:green:d0" },	{ -EINVAL,	GPIOF_OUT_INIT_LOW, "gpio-led:red:d1"   },};static inline void igep_leds_init(void){	int i;	if (machine_is_igep0020()) {		igep_gpio_leds[0].gpio = IGEP2_GPIO_LED0_RED;		igep_gpio_leds[1].gpio = IGEP2_GPIO_LED0_GREEN;		igep_gpio_leds[2].gpio = IGEP2_GPIO_LED1_RED;	} else {		igep_gpio_leds[0].gpio = IGEP3_GPIO_LED0_RED;		igep_gpio_leds[1].gpio = IGEP3_GPIO_LED0_GREEN;		igep_gpio_leds[2].gpio = IGEP3_GPIO_LED1_RED;
 |