| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 | /* * linux/arch/arm/mach-omap2/board-omap3beagle.c * * Copyright (C) 2008 Texas Instruments * * Modified from mach-omap2/board-3430sdp.c * * Initial code: Syed Mohammed Khasim * * 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/leds.h>#include <linux/gpio.h>#include <linux/input.h>#include <linux/gpio_keys.h>#include <linux/opp.h>#include <linux/cpu.h>#include <linux/mtd/mtd.h>#include <linux/mtd/partitions.h>#include <linux/mtd/nand.h>#include <linux/mmc/host.h>#include <linux/regulator/machine.h>#include <linux/i2c/twl.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <asm/mach/map.h>#include <asm/mach/flash.h>#include <video/omapdss.h>#include <video/omap-panel-tfp410.h>#include <linux/platform_data/mtd-nand-omap2.h>#include "common.h"#include "omap_device.h"#include "gpmc.h"#include "soc.h"#include "mux.h"#include "hsmmc.h"#include "pm.h"#include "board-flash.h"#include "common-board-devices.h"#define	NAND_CS	0/* * OMAP3 Beagle revision * Run time detection of Beagle revision is done by reading GPIO. * GPIO ID - *	AXBX	= GPIO173, GPIO172, GPIO171: 1 1 1 *	C1_3	= GPIO173, GPIO172, GPIO171: 1 1 0 *	C4	= GPIO173, GPIO172, GPIO171: 1 0 1 *	XMA/XMB = GPIO173, GPIO172, GPIO171: 0 0 0 *	XMC = GPIO173, GPIO172, GPIO171: 0 1 0 */enum {	OMAP3BEAGLE_BOARD_UNKN = 0,	OMAP3BEAGLE_BOARD_AXBX,	OMAP3BEAGLE_BOARD_C1_3,	OMAP3BEAGLE_BOARD_C4,	OMAP3BEAGLE_BOARD_XM,	OMAP3BEAGLE_BOARD_XMC,};static u8 omap3_beagle_version;/* * Board-specific configuration * Defaults to BeagleBoard-xMC */static struct {	int mmc1_gpio_wp;	int usb_pwr_level;	int dvi_pd_gpio;	int usr_button_gpio;	int mmc_caps;} beagle_config = {	.mmc1_gpio_wp = -EINVAL,	.usb_pwr_level = GPIOF_OUT_INIT_LOW,	.dvi_pd_gpio = -EINVAL,	.usr_button_gpio = 4,	.mmc_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,};static struct gpio omap3_beagle_rev_gpios[] __initdata = {	{ 171, GPIOF_IN, "rev_id_0"    },	{ 172, GPIOF_IN, "rev_id_1" },	{ 173, GPIOF_IN, "rev_id_2"    },};static void __init omap3_beagle_init_rev(void){	int ret;	u16 beagle_rev = 0;	omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);	omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);	omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);	ret = gpio_request_array(omap3_beagle_rev_gpios,				 ARRAY_SIZE(omap3_beagle_rev_gpios));	if (ret < 0) {		printk(KERN_ERR "Unable to get revision detection GPIO pins\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;		return;	}	beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)			| (gpio_get_value(173) << 2);	gpio_free_array(omap3_beagle_rev_gpios,			ARRAY_SIZE(omap3_beagle_rev_gpios));	switch (beagle_rev) {	case 7:		printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;		beagle_config.mmc1_gpio_wp = 29;		beagle_config.dvi_pd_gpio = 170;		beagle_config.usr_button_gpio = 7;		break;	case 6:		printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;		beagle_config.mmc1_gpio_wp = 23;		beagle_config.dvi_pd_gpio = 170;		beagle_config.usr_button_gpio = 7;		break;	case 5:		printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;		beagle_config.mmc1_gpio_wp = 23;		beagle_config.dvi_pd_gpio = 170;		beagle_config.usr_button_gpio = 7;		break;	case 0:		printk(KERN_INFO "OMAP3 Beagle Rev: xM Ax/Bx\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;		beagle_config.usb_pwr_level = GPIOF_OUT_INIT_HIGH;		beagle_config.mmc_caps &= ~MMC_CAP_8_BIT_DATA;		break;	case 2:		printk(KERN_INFO "OMAP3 Beagle Rev: xM C\n");		omap3_beagle_version = OMAP3BEAGLE_BOARD_XMC;		beagle_config.mmc_caps &= ~MMC_CAP_8_BIT_DATA;		break;	default:		printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);		omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;	}}static struct mtd_partition omap3beagle_nand_partitions[] = {	/* All the partition sizes are listed in terms of NAND block size */	{		.name		= "X-Loader",		.offset		= 0,		.size		= 4 * NAND_BLOCK_SIZE,		.mask_flags	= MTD_WRITEABLE,	/* force read-only */	},	{		.name		= "U-Boot",		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x80000 */		.size		= 15 * NAND_BLOCK_SIZE,		.mask_flags	= MTD_WRITEABLE,	/* force read-only */	},	{		.name		= "U-Boot Env",		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x260000 */		.size		= 1 * NAND_BLOCK_SIZE,	},	{		.name		= "Kernel",		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x280000 */		.size		= 32 * NAND_BLOCK_SIZE,	},	{		.name		= "File System",		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x680000 */		.size		= MTDPART_SIZ_FULL,	},};/* DSS */static struct tfp410_platform_data dvi_panel = {	.i2c_bus_num = 3,	.power_down_gpio = -1,};static struct omap_dss_device beagle_dvi_device = {	.type = OMAP_DISPLAY_TYPE_DPI,	.name = "dvi",	.driver_name = "tfp410",	.data = &dvi_panel,	.phy.dpi.data_lines = 24,};static struct omap_dss_device beagle_tv_device = {	.name = "tv",	.driver_name = "venc",	.type = OMAP_DISPLAY_TYPE_VENC,	.phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,};static struct omap_dss_device *beagle_dss_devices[] = {	&beagle_dvi_device,	&beagle_tv_device,};static struct omap_dss_board_info beagle_dss_data = {	.num_devices = ARRAY_SIZE(beagle_dss_devices),	.devices = beagle_dss_devices,	.default_device = &beagle_dvi_device,};#include "sdram-micron-mt46h32m32lf-6.h"static struct omap2_hsmmc_info mmc[] = {	{		.mmc		= 1,		.caps		= MMC_CAP_4_BIT_DATA,		.gpio_wp	= -EINVAL,		.deferred	= true,	},	{}	/* Terminator */};static struct regulator_consumer_supply beagle_vmmc1_supply[] = {	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),};static struct regulator_consumer_supply beagle_vsim_supply[] = {	REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),};static struct gpio_led gpio_leds[];static int beagle_twl_gpio_setup(struct device *dev,		unsigned gpio, unsigned ngpio){	int r;	mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp;	/* gpio + 0 is "mmc0_cd" (input/IRQ) */	mmc[0].gpio_cd = gpio + 0;	omap_hsmmc_late_init(mmc);	/*	 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active	 * high / others active low)	 * DVI reset GPIO is different between beagle revisions	 */	/* Valid for all -xM revisions */	if (cpu_is_omap3630()) {		/*		 * gpio + 1 on Xm controls the TFP410's enable line (active low)		 * gpio + 2 control varies depending on the board rev as below:		 * P7/P8 revisions(prototype): Camera EN		 * A2+ revisions (production): LDO (DVI, serial, led blocks)		 */		r = gpio_request_one(gpio + 1, GPIOF_OUT_INIT_LOW,				     "nDVI_PWR_EN");		if (r)			pr_err("%s: unable to configure nDVI_PWR_EN\n",				__func__);		beagle_config.dvi_pd_gpio = gpio + 2;	} else {		/*		 * REVISIT: need ehci-omap hooks for external VBUS		 * power switch and overcurrent detect		 */		if (gpio_request_one(gpio + 1, GPIOF_IN, "EHCI_nOC"))			pr_err("%s: unable to configure EHCI_nOC\n", __func__);	}	dvi_panel.power_down_gpio = beagle_config.dvi_pd_gpio;	gpio_request_one(gpio + TWL4030_GPIO_MAX, beagle_config.usb_pwr_level,			"nEN_USB_PWR");	/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */	gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;	return 0;}static struct twl4030_gpio_platform_data beagle_gpio_data = {	.use_leds	= true,	.pullups	= BIT(1),	.pulldowns	= BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)				| BIT(15) | BIT(16) | BIT(17),	.setup		= beagle_twl_gpio_setup,};/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */static struct regulator_init_data beagle_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(beagle_vmmc1_supply),	.consumer_supplies	= beagle_vmmc1_supply,};/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */static struct regulator_init_data beagle_vsim = {	.constraints = {		.min_uV			= 1800000,		.max_uV			= 3000000,		.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(beagle_vsim_supply),	.consumer_supplies	= beagle_vsim_supply,};static struct twl4030_platform_data beagle_twldata = {	/* platform_data for children goes here */	.gpio		= &beagle_gpio_data,	.vmmc1		= &beagle_vmmc1,	.vsim		= &beagle_vsim,};static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {       {               I2C_BOARD_INFO("eeprom", 0x50),       },};static int __init omap3_beagle_i2c_init(void){	omap3_pmic_get_config(&beagle_twldata,			TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC |			TWL_COMMON_PDATA_AUDIO,			TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);	beagle_twldata.vpll2->constraints.name = "VDVI";	omap3_pmic_init("twl4030", &beagle_twldata);	/* Bus 3 is attached to the DVI port where devices like the pico DLP	 * projector don't work reliably with 400kHz */	omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));	return 0;}static struct gpio_led gpio_leds[] = {	{		.name			= "beagleboard::usr0",		.default_trigger	= "heartbeat",		.gpio			= 150,	},	{		.name			= "beagleboard::usr1",		.default_trigger	= "mmc0",		.gpio			= 149,	},	{		.name			= "beagleboard::pmu_stat",		.gpio			= -EINVAL,	/* gets replaced */
 |