| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * linux/arch/arm/mach-omap2/board-omap3touchbook.c | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 2009 Always Innovating | 
 | 5 |  * | 
 | 6 |  * Modified from mach-omap2/board-omap3beagleboard.c | 
 | 7 |  * | 
 | 8 |  * Initial code: Grégoire Gentil, Tim Yamin | 
 | 9 |  * | 
 | 10 |  * This program is free software; you can redistribute it and/or modify | 
 | 11 |  * it under the terms of the GNU General Public License version 2 as | 
 | 12 |  * published by the Free Software Foundation. | 
 | 13 |  */ | 
 | 14 |  | 
 | 15 | #include <linux/kernel.h> | 
 | 16 | #include <linux/init.h> | 
 | 17 | #include <linux/platform_device.h> | 
 | 18 | #include <linux/delay.h> | 
 | 19 | #include <linux/err.h> | 
 | 20 | #include <linux/clk.h> | 
 | 21 | #include <linux/io.h> | 
 | 22 | #include <linux/leds.h> | 
 | 23 | #include <linux/gpio.h> | 
 | 24 | #include <linux/input.h> | 
 | 25 | #include <linux/gpio_keys.h> | 
 | 26 |  | 
 | 27 | #include <linux/mtd/mtd.h> | 
 | 28 | #include <linux/mtd/partitions.h> | 
 | 29 | #include <linux/mtd/nand.h> | 
| Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 30 | #include <linux/mmc/host.h> | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 31 |  | 
 | 32 | #include <plat/mcspi.h> | 
 | 33 | #include <linux/spi/spi.h> | 
 | 34 |  | 
 | 35 | #include <linux/spi/ads7846.h> | 
 | 36 |  | 
 | 37 | #include <linux/regulator/machine.h> | 
| Balaji T K | ebeb53e | 2009-12-15 20:09:02 +0530 | [diff] [blame] | 38 | #include <linux/i2c/twl.h> | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 39 |  | 
 | 40 | #include <mach/hardware.h> | 
 | 41 | #include <asm/mach-types.h> | 
 | 42 | #include <asm/mach/arch.h> | 
 | 43 | #include <asm/mach/map.h> | 
 | 44 | #include <asm/mach/flash.h> | 
 | 45 |  | 
 | 46 | #include <plat/board.h> | 
 | 47 | #include <plat/common.h> | 
 | 48 | #include <plat/gpmc.h> | 
 | 49 | #include <plat/nand.h> | 
 | 50 | #include <plat/usb.h> | 
 | 51 | #include <plat/timer-gp.h> | 
 | 52 |  | 
 | 53 | #include "mux.h" | 
| Adrian Hunter | d02a900 | 2010-02-15 10:03:34 -0800 | [diff] [blame] | 54 | #include "hsmmc.h" | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 55 |  | 
 | 56 | #include <asm/setup.h> | 
 | 57 |  | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 58 | #define NAND_BLOCK_SIZE		SZ_128K | 
 | 59 |  | 
 | 60 | #define OMAP3_AC_GPIO		136 | 
 | 61 | #define OMAP3_TS_GPIO		162 | 
 | 62 | #define TB_BL_PWM_TIMER		9 | 
 | 63 | #define TB_KILL_POWER_GPIO	168 | 
 | 64 |  | 
 | 65 | unsigned long touchbook_revision; | 
 | 66 |  | 
 | 67 | static struct mtd_partition omap3touchbook_nand_partitions[] = { | 
 | 68 | 	/* All the partition sizes are listed in terms of NAND block size */ | 
 | 69 | 	{ | 
 | 70 | 		.name		= "X-Loader", | 
 | 71 | 		.offset		= 0, | 
 | 72 | 		.size		= 4 * NAND_BLOCK_SIZE, | 
 | 73 | 		.mask_flags	= MTD_WRITEABLE,	/* force read-only */ | 
 | 74 | 	}, | 
 | 75 | 	{ | 
 | 76 | 		.name		= "U-Boot", | 
 | 77 | 		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x80000 */ | 
 | 78 | 		.size		= 15 * NAND_BLOCK_SIZE, | 
 | 79 | 		.mask_flags	= MTD_WRITEABLE,	/* force read-only */ | 
 | 80 | 	}, | 
 | 81 | 	{ | 
 | 82 | 		.name		= "U-Boot Env", | 
 | 83 | 		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x260000 */ | 
 | 84 | 		.size		= 1 * NAND_BLOCK_SIZE, | 
 | 85 | 	}, | 
 | 86 | 	{ | 
 | 87 | 		.name		= "Kernel", | 
 | 88 | 		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x280000 */ | 
 | 89 | 		.size		= 32 * NAND_BLOCK_SIZE, | 
 | 90 | 	}, | 
 | 91 | 	{ | 
 | 92 | 		.name		= "File System", | 
 | 93 | 		.offset		= MTDPART_OFS_APPEND,	/* Offset = 0x680000 */ | 
 | 94 | 		.size		= MTDPART_SIZ_FULL, | 
 | 95 | 	}, | 
 | 96 | }; | 
 | 97 |  | 
 | 98 | static struct omap_nand_platform_data omap3touchbook_nand_data = { | 
 | 99 | 	.options	= NAND_BUSWIDTH_16, | 
 | 100 | 	.parts		= omap3touchbook_nand_partitions, | 
 | 101 | 	.nr_parts	= ARRAY_SIZE(omap3touchbook_nand_partitions), | 
 | 102 | 	.dma_channel	= -1,		/* disable DMA in OMAP NAND driver */ | 
 | 103 | 	.nand_setup	= NULL, | 
 | 104 | 	.dev_ready	= NULL, | 
 | 105 | }; | 
 | 106 |  | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 107 | #include "sdram-micron-mt46h32m32lf-6.h" | 
 | 108 |  | 
| Adrian Hunter | 68ff042 | 2010-02-15 10:03:34 -0800 | [diff] [blame] | 109 | static struct omap2_hsmmc_info mmc[] = { | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 110 | 	{ | 
 | 111 | 		.mmc		= 1, | 
| Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 112 | 		.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 113 | 		.gpio_wp	= 29, | 
 | 114 | 	}, | 
 | 115 | 	{}	/* Terminator */ | 
 | 116 | }; | 
 | 117 |  | 
 | 118 | static struct platform_device omap3_touchbook_lcd_device = { | 
 | 119 | 	.name		= "omap3touchbook_lcd", | 
 | 120 | 	.id		= -1, | 
 | 121 | }; | 
 | 122 |  | 
 | 123 | static struct omap_lcd_config omap3_touchbook_lcd_config __initdata = { | 
 | 124 | 	.ctrl_name	= "internal", | 
 | 125 | }; | 
 | 126 |  | 
 | 127 | static struct regulator_consumer_supply touchbook_vmmc1_supply = { | 
 | 128 | 	.supply			= "vmmc", | 
 | 129 | }; | 
 | 130 |  | 
 | 131 | static struct regulator_consumer_supply touchbook_vsim_supply = { | 
 | 132 | 	.supply			= "vmmc_aux", | 
 | 133 | }; | 
 | 134 |  | 
 | 135 | static struct gpio_led gpio_leds[]; | 
 | 136 |  | 
 | 137 | static int touchbook_twl_gpio_setup(struct device *dev, | 
 | 138 | 		unsigned gpio, unsigned ngpio) | 
 | 139 | { | 
 | 140 | 	if (system_rev >= 0x20 && system_rev <= 0x34301000) { | 
 | 141 | 		omap_mux_init_gpio(23, OMAP_PIN_INPUT); | 
 | 142 | 		mmc[0].gpio_wp = 23; | 
 | 143 | 	} else { | 
 | 144 | 		omap_mux_init_gpio(29, OMAP_PIN_INPUT); | 
 | 145 | 	} | 
 | 146 | 	/* gpio + 0 is "mmc0_cd" (input/IRQ) */ | 
 | 147 | 	mmc[0].gpio_cd = gpio + 0; | 
| Adrian Hunter | 68ff042 | 2010-02-15 10:03:34 -0800 | [diff] [blame] | 148 | 	omap2_hsmmc_init(mmc); | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 149 |  | 
 | 150 | 	/* link regulators to MMC adapters */ | 
 | 151 | 	touchbook_vmmc1_supply.dev = mmc[0].dev; | 
 | 152 | 	touchbook_vsim_supply.dev = mmc[0].dev; | 
 | 153 |  | 
 | 154 | 	/* REVISIT: need ehci-omap hooks for external VBUS | 
 | 155 | 	 * power switch and overcurrent detect | 
 | 156 | 	 */ | 
 | 157 |  | 
 | 158 | 	gpio_request(gpio + 1, "EHCI_nOC"); | 
 | 159 | 	gpio_direction_input(gpio + 1); | 
 | 160 |  | 
 | 161 | 	/* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */ | 
 | 162 | 	gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR"); | 
 | 163 | 	gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0); | 
 | 164 |  | 
 | 165 | 	/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ | 
 | 166 | 	gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; | 
 | 167 |  | 
 | 168 | 	return 0; | 
 | 169 | } | 
 | 170 |  | 
 | 171 | static struct twl4030_gpio_platform_data touchbook_gpio_data = { | 
 | 172 | 	.gpio_base	= OMAP_MAX_GPIO_LINES, | 
 | 173 | 	.irq_base	= TWL4030_GPIO_IRQ_BASE, | 
 | 174 | 	.irq_end	= TWL4030_GPIO_IRQ_END, | 
 | 175 | 	.use_leds	= true, | 
 | 176 | 	.pullups	= BIT(1), | 
 | 177 | 	.pulldowns	= BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13) | 
 | 178 | 				| BIT(15) | BIT(16) | BIT(17), | 
 | 179 | 	.setup		= touchbook_twl_gpio_setup, | 
 | 180 | }; | 
 | 181 |  | 
 | 182 | static struct regulator_consumer_supply touchbook_vdac_supply = { | 
 | 183 | 	.supply		= "vdac", | 
 | 184 | 	.dev		= &omap3_touchbook_lcd_device.dev, | 
 | 185 | }; | 
 | 186 |  | 
 | 187 | static struct regulator_consumer_supply touchbook_vdvi_supply = { | 
 | 188 | 	.supply		= "vdvi", | 
 | 189 | 	.dev		= &omap3_touchbook_lcd_device.dev, | 
 | 190 | }; | 
 | 191 |  | 
 | 192 | /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ | 
 | 193 | static struct regulator_init_data touchbook_vmmc1 = { | 
 | 194 | 	.constraints = { | 
 | 195 | 		.min_uV			= 1850000, | 
 | 196 | 		.max_uV			= 3150000, | 
 | 197 | 		.valid_modes_mask	= REGULATOR_MODE_NORMAL | 
 | 198 | 					| REGULATOR_MODE_STANDBY, | 
 | 199 | 		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE | 
 | 200 | 					| REGULATOR_CHANGE_MODE | 
 | 201 | 					| REGULATOR_CHANGE_STATUS, | 
 | 202 | 	}, | 
 | 203 | 	.num_consumer_supplies	= 1, | 
 | 204 | 	.consumer_supplies	= &touchbook_vmmc1_supply, | 
 | 205 | }; | 
 | 206 |  | 
 | 207 | /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */ | 
 | 208 | static struct regulator_init_data touchbook_vsim = { | 
 | 209 | 	.constraints = { | 
 | 210 | 		.min_uV			= 1800000, | 
 | 211 | 		.max_uV			= 3000000, | 
 | 212 | 		.valid_modes_mask	= REGULATOR_MODE_NORMAL | 
 | 213 | 					| REGULATOR_MODE_STANDBY, | 
 | 214 | 		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE | 
 | 215 | 					| REGULATOR_CHANGE_MODE | 
 | 216 | 					| REGULATOR_CHANGE_STATUS, | 
 | 217 | 	}, | 
 | 218 | 	.num_consumer_supplies	= 1, | 
 | 219 | 	.consumer_supplies	= &touchbook_vsim_supply, | 
 | 220 | }; | 
 | 221 |  | 
 | 222 | /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */ | 
 | 223 | static struct regulator_init_data touchbook_vdac = { | 
 | 224 | 	.constraints = { | 
 | 225 | 		.min_uV			= 1800000, | 
 | 226 | 		.max_uV			= 1800000, | 
 | 227 | 		.valid_modes_mask	= REGULATOR_MODE_NORMAL | 
 | 228 | 					| REGULATOR_MODE_STANDBY, | 
 | 229 | 		.valid_ops_mask		= REGULATOR_CHANGE_MODE | 
 | 230 | 					| REGULATOR_CHANGE_STATUS, | 
 | 231 | 	}, | 
 | 232 | 	.num_consumer_supplies	= 1, | 
 | 233 | 	.consumer_supplies	= &touchbook_vdac_supply, | 
 | 234 | }; | 
 | 235 |  | 
 | 236 | /* VPLL2 for digital video outputs */ | 
 | 237 | static struct regulator_init_data touchbook_vpll2 = { | 
 | 238 | 	.constraints = { | 
 | 239 | 		.name			= "VDVI", | 
 | 240 | 		.min_uV			= 1800000, | 
 | 241 | 		.max_uV			= 1800000, | 
 | 242 | 		.valid_modes_mask	= REGULATOR_MODE_NORMAL | 
 | 243 | 					| REGULATOR_MODE_STANDBY, | 
 | 244 | 		.valid_ops_mask		= REGULATOR_CHANGE_MODE | 
 | 245 | 					| REGULATOR_CHANGE_STATUS, | 
 | 246 | 	}, | 
 | 247 | 	.num_consumer_supplies	= 1, | 
 | 248 | 	.consumer_supplies	= &touchbook_vdvi_supply, | 
 | 249 | }; | 
 | 250 |  | 
 | 251 | static struct twl4030_usb_data touchbook_usb_data = { | 
 | 252 | 	.usb_mode	= T2_USB_MODE_ULPI, | 
 | 253 | }; | 
 | 254 |  | 
 | 255 | static struct twl4030_codec_audio_data touchbook_audio_data = { | 
 | 256 | 	.audio_mclk = 26000000, | 
 | 257 | }; | 
 | 258 |  | 
 | 259 | static struct twl4030_codec_data touchbook_codec_data = { | 
 | 260 | 	.audio_mclk = 26000000, | 
 | 261 | 	.audio = &touchbook_audio_data, | 
 | 262 | }; | 
 | 263 |  | 
 | 264 | static struct twl4030_platform_data touchbook_twldata = { | 
 | 265 | 	.irq_base	= TWL4030_IRQ_BASE, | 
 | 266 | 	.irq_end	= TWL4030_IRQ_END, | 
 | 267 |  | 
 | 268 | 	/* platform_data for children goes here */ | 
 | 269 | 	.usb		= &touchbook_usb_data, | 
 | 270 | 	.gpio		= &touchbook_gpio_data, | 
 | 271 | 	.codec		= &touchbook_codec_data, | 
 | 272 | 	.vmmc1		= &touchbook_vmmc1, | 
 | 273 | 	.vsim		= &touchbook_vsim, | 
 | 274 | 	.vdac		= &touchbook_vdac, | 
 | 275 | 	.vpll2		= &touchbook_vpll2, | 
 | 276 | }; | 
 | 277 |  | 
 | 278 | static struct i2c_board_info __initdata touchbook_i2c_boardinfo[] = { | 
 | 279 | 	{ | 
 | 280 | 		I2C_BOARD_INFO("twl4030", 0x48), | 
 | 281 | 		.flags = I2C_CLIENT_WAKE, | 
 | 282 | 		.irq = INT_34XX_SYS_NIRQ, | 
 | 283 | 		.platform_data = &touchbook_twldata, | 
 | 284 | 	}, | 
 | 285 | }; | 
 | 286 |  | 
 | 287 | static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = { | 
 | 288 | 	{ | 
 | 289 | 		I2C_BOARD_INFO("bq27200", 0x55), | 
 | 290 | 	}, | 
 | 291 | }; | 
 | 292 |  | 
 | 293 | static int __init omap3_touchbook_i2c_init(void) | 
 | 294 | { | 
 | 295 | 	/* Standard TouchBook bus */ | 
 | 296 | 	omap_register_i2c_bus(1, 2600, touchbook_i2c_boardinfo, | 
 | 297 | 			ARRAY_SIZE(touchbook_i2c_boardinfo)); | 
 | 298 |  | 
 | 299 | 	/* Additional TouchBook bus */ | 
 | 300 | 	omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo, | 
 | 301 | 			ARRAY_SIZE(touchBook_i2c_boardinfo)); | 
 | 302 |  | 
 | 303 | 	return 0; | 
 | 304 | } | 
 | 305 |  | 
 | 306 | static void __init omap3_ads7846_init(void) | 
 | 307 | { | 
 | 308 | 	if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) { | 
 | 309 | 		printk(KERN_ERR "Failed to request GPIO %d for " | 
 | 310 | 				"ads7846 pen down IRQ\n", OMAP3_TS_GPIO); | 
 | 311 | 		return; | 
 | 312 | 	} | 
 | 313 |  | 
 | 314 | 	gpio_direction_input(OMAP3_TS_GPIO); | 
| Felipe Balbi | 48feb33 | 2010-05-26 14:42:24 -0700 | [diff] [blame] | 315 | 	gpio_set_debounce(OMAP3_TS_GPIO, 310); | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 316 | } | 
 | 317 |  | 
 | 318 | static struct ads7846_platform_data ads7846_config = { | 
 | 319 | 	.x_min			= 100, | 
 | 320 | 	.y_min			= 265, | 
 | 321 | 	.x_max			= 3950, | 
 | 322 | 	.y_max			= 3750, | 
 | 323 | 	.x_plate_ohms		= 40, | 
 | 324 | 	.pressure_max		= 255, | 
 | 325 | 	.debounce_max		= 10, | 
 | 326 | 	.debounce_tol		= 5, | 
 | 327 | 	.debounce_rep		= 1, | 
 | 328 | 	.gpio_pendown		= OMAP3_TS_GPIO, | 
 | 329 | 	.keep_vref_on		= 1, | 
 | 330 | }; | 
 | 331 |  | 
 | 332 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { | 
 | 333 | 	.turbo_mode	= 0, | 
 | 334 | 	.single_channel	= 1,	/* 0: slave, 1: master */ | 
 | 335 | }; | 
 | 336 |  | 
 | 337 | static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = { | 
 | 338 | 	{ | 
 | 339 | 		.modalias		= "ads7846", | 
 | 340 | 		.bus_num		= 4, | 
 | 341 | 		.chip_select		= 0, | 
 | 342 | 		.max_speed_hz		= 1500000, | 
 | 343 | 		.controller_data	= &ads7846_mcspi_config, | 
 | 344 | 		.irq			= OMAP_GPIO_IRQ(OMAP3_TS_GPIO), | 
 | 345 | 		.platform_data		= &ads7846_config, | 
 | 346 | 	} | 
 | 347 | }; | 
 | 348 |  | 
 | 349 | static struct gpio_led gpio_leds[] = { | 
 | 350 | 	{ | 
 | 351 | 		.name			= "touchbook::usr0", | 
 | 352 | 		.default_trigger	= "heartbeat", | 
 | 353 | 		.gpio			= 150, | 
 | 354 | 	}, | 
 | 355 | 	{ | 
 | 356 | 		.name			= "touchbook::usr1", | 
 | 357 | 		.default_trigger	= "mmc0", | 
 | 358 | 		.gpio			= 149, | 
 | 359 | 	}, | 
 | 360 | 	{ | 
 | 361 | 		.name			= "touchbook::pmu_stat", | 
 | 362 | 		.gpio			= -EINVAL,	/* gets replaced */ | 
 | 363 | 		.active_low		= true, | 
 | 364 | 	}, | 
 | 365 | }; | 
 | 366 |  | 
 | 367 | static struct gpio_led_platform_data gpio_led_info = { | 
 | 368 | 	.leds		= gpio_leds, | 
 | 369 | 	.num_leds	= ARRAY_SIZE(gpio_leds), | 
 | 370 | }; | 
 | 371 |  | 
 | 372 | static struct platform_device leds_gpio = { | 
 | 373 | 	.name	= "leds-gpio", | 
 | 374 | 	.id	= -1, | 
 | 375 | 	.dev	= { | 
 | 376 | 		.platform_data	= &gpio_led_info, | 
 | 377 | 	}, | 
 | 378 | }; | 
 | 379 |  | 
 | 380 | static struct gpio_keys_button gpio_buttons[] = { | 
 | 381 | 	{ | 
 | 382 | 		.code			= BTN_EXTRA, | 
 | 383 | 		.gpio			= 7, | 
 | 384 | 		.desc			= "user", | 
 | 385 | 		.wakeup			= 1, | 
 | 386 | 	}, | 
 | 387 | 	{ | 
 | 388 | 		.code			= KEY_POWER, | 
 | 389 | 		.gpio			= 183, | 
 | 390 | 		.desc			= "power", | 
 | 391 | 		.wakeup			= 1, | 
 | 392 | 	}, | 
 | 393 | }; | 
 | 394 |  | 
 | 395 | static struct gpio_keys_platform_data gpio_key_info = { | 
 | 396 | 	.buttons	= gpio_buttons, | 
 | 397 | 	.nbuttons	= ARRAY_SIZE(gpio_buttons), | 
 | 398 | }; | 
 | 399 |  | 
 | 400 | static struct platform_device keys_gpio = { | 
 | 401 | 	.name	= "gpio-keys", | 
 | 402 | 	.id	= -1, | 
 | 403 | 	.dev	= { | 
 | 404 | 		.platform_data	= &gpio_key_info, | 
 | 405 | 	}, | 
 | 406 | }; | 
 | 407 |  | 
 | 408 | static struct omap_board_config_kernel omap3_touchbook_config[] __initdata = { | 
 | 409 | 	{ OMAP_TAG_LCD,		&omap3_touchbook_lcd_config }, | 
 | 410 | }; | 
 | 411 |  | 
 | 412 | #ifdef CONFIG_OMAP_MUX | 
 | 413 | static struct omap_board_mux board_mux[] __initdata = { | 
 | 414 | 	{ .reg_offset = OMAP_MUX_TERMINATOR }, | 
 | 415 | }; | 
 | 416 | #else | 
 | 417 | #define board_mux	NULL | 
 | 418 | #endif | 
 | 419 |  | 
 | 420 | static void __init omap3_touchbook_init_irq(void) | 
 | 421 | { | 
 | 422 | 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); | 
 | 423 | 	omap_board_config = omap3_touchbook_config; | 
 | 424 | 	omap_board_config_size = ARRAY_SIZE(omap3_touchbook_config); | 
 | 425 | 	omap2_init_common_hw(mt46h32m32lf6_sdrc_params, | 
 | 426 | 			     mt46h32m32lf6_sdrc_params); | 
 | 427 | 	omap_init_irq(); | 
 | 428 | #ifdef CONFIG_OMAP_32K_TIMER | 
 | 429 | 	omap2_gp_clockevent_set_gptimer(12); | 
 | 430 | #endif | 
 | 431 | 	omap_gpio_init(); | 
 | 432 | } | 
 | 433 |  | 
 | 434 | static struct platform_device *omap3_touchbook_devices[] __initdata = { | 
 | 435 | 	&omap3_touchbook_lcd_device, | 
 | 436 | 	&leds_gpio, | 
 | 437 | 	&keys_gpio, | 
 | 438 | }; | 
 | 439 |  | 
 | 440 | static void __init omap3touchbook_flash_init(void) | 
 | 441 | { | 
 | 442 | 	u8 cs = 0; | 
 | 443 | 	u8 nandcs = GPMC_CS_NUM + 1; | 
 | 444 |  | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 445 | 	/* find out the chip-select on which NAND exists */ | 
 | 446 | 	while (cs < GPMC_CS_NUM) { | 
 | 447 | 		u32 ret = 0; | 
 | 448 | 		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | 
 | 449 |  | 
 | 450 | 		if ((ret & 0xC00) == 0x800) { | 
 | 451 | 			printk(KERN_INFO "Found NAND on CS%d\n", cs); | 
 | 452 | 			if (nandcs > GPMC_CS_NUM) | 
 | 453 | 				nandcs = cs; | 
 | 454 | 		} | 
 | 455 | 		cs++; | 
 | 456 | 	} | 
 | 457 |  | 
 | 458 | 	if (nandcs > GPMC_CS_NUM) { | 
 | 459 | 		printk(KERN_INFO "NAND: Unable to find configuration " | 
 | 460 | 				 "in GPMC\n "); | 
 | 461 | 		return; | 
 | 462 | 	} | 
 | 463 |  | 
 | 464 | 	if (nandcs < GPMC_CS_NUM) { | 
 | 465 | 		omap3touchbook_nand_data.cs = nandcs; | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 466 |  | 
 | 467 | 		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs); | 
| Sukumar Ghorai | f450d86 | 2010-07-09 09:14:46 +0000 | [diff] [blame] | 468 | 		if (gpmc_nand_init(&omap3touchbook_nand_data) < 0) | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 469 | 			printk(KERN_ERR "Unable to register NAND device\n"); | 
 | 470 | 	} | 
 | 471 | } | 
 | 472 |  | 
| Felipe Balbi | 6f69a18 | 2010-03-04 09:45:53 +0200 | [diff] [blame] | 473 | static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 474 |  | 
 | 475 | 	.port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, | 
 | 476 | 	.port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, | 
 | 477 | 	.port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, | 
 | 478 |  | 
 | 479 | 	.phy_reset  = true, | 
 | 480 | 	.reset_gpio_port[0]  = -EINVAL, | 
 | 481 | 	.reset_gpio_port[1]  = 147, | 
 | 482 | 	.reset_gpio_port[2]  = -EINVAL | 
 | 483 | }; | 
 | 484 |  | 
 | 485 | static void omap3_touchbook_poweroff(void) | 
 | 486 | { | 
 | 487 | 	int r; | 
 | 488 |  | 
 | 489 | 	r = gpio_request(TB_KILL_POWER_GPIO, "DVI reset"); | 
 | 490 | 	if (r < 0) { | 
 | 491 | 		printk(KERN_ERR "Unable to get kill power GPIO\n"); | 
 | 492 | 		return; | 
 | 493 | 	} | 
 | 494 |  | 
 | 495 | 	gpio_direction_output(TB_KILL_POWER_GPIO, 0); | 
 | 496 | } | 
 | 497 |  | 
| Tony Lindgren | d2197e1 | 2010-03-09 14:59:48 -0800 | [diff] [blame] | 498 | static int __init early_touchbook_revision(char *p) | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 499 | { | 
| Tony Lindgren | d2197e1 | 2010-03-09 14:59:48 -0800 | [diff] [blame] | 500 | 	if (!p) | 
 | 501 | 		return 0; | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 502 |  | 
| Tony Lindgren | d2197e1 | 2010-03-09 14:59:48 -0800 | [diff] [blame] | 503 | 	return strict_strtoul(p, 10, &touchbook_revision); | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 504 | } | 
| Tony Lindgren | d2197e1 | 2010-03-09 14:59:48 -0800 | [diff] [blame] | 505 | early_param("tbr", early_touchbook_revision); | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 506 |  | 
| Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 507 | static struct omap_musb_board_data musb_board_data = { | 
 | 508 | 	.interface_type		= MUSB_INTERFACE_ULPI, | 
 | 509 | 	.mode			= MUSB_OTG, | 
 | 510 | 	.power			= 100, | 
 | 511 | }; | 
 | 512 |  | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 513 | static void __init omap3_touchbook_init(void) | 
 | 514 | { | 
 | 515 | 	pm_power_off = omap3_touchbook_poweroff; | 
 | 516 |  | 
 | 517 | 	omap3_touchbook_i2c_init(); | 
 | 518 | 	platform_add_devices(omap3_touchbook_devices, | 
 | 519 | 			ARRAY_SIZE(omap3_touchbook_devices)); | 
 | 520 | 	omap_serial_init(); | 
 | 521 |  | 
 | 522 | 	omap_mux_init_gpio(170, OMAP_PIN_INPUT); | 
 | 523 | 	gpio_request(176, "DVI_nPD"); | 
 | 524 | 	/* REVISIT leave DVI powered down until it's needed ... */ | 
 | 525 | 	gpio_direction_output(176, true); | 
 | 526 |  | 
 | 527 | 	/* Touchscreen and accelerometer */ | 
 | 528 | 	spi_register_board_info(omap3_ads7846_spi_board_info, | 
 | 529 | 				ARRAY_SIZE(omap3_ads7846_spi_board_info)); | 
 | 530 | 	omap3_ads7846_init(); | 
| Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 531 | 	usb_musb_init(&musb_board_data); | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 532 | 	usb_ehci_init(&ehci_pdata); | 
 | 533 | 	omap3touchbook_flash_init(); | 
 | 534 |  | 
 | 535 | 	/* Ensure SDRC pins are mux'd for self-refresh */ | 
 | 536 | 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); | 
 | 537 | 	omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); | 
 | 538 | } | 
 | 539 |  | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 540 | MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board") | 
 | 541 | 	/* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */ | 
 | 542 | 	.phys_io	= 0x48000000, | 
 | 543 | 	.io_pg_offst	= ((0xd8000000) >> 18) & 0xfffc, | 
 | 544 | 	.boot_params	= 0x80000100, | 
| Mike Rapoport | 869fef4 | 2010-08-04 14:43:18 +0300 | [diff] [blame] | 545 | 	.map_io		= omap3_map_io, | 
| Russell King | 71ee7da | 2010-05-23 10:18:16 +0100 | [diff] [blame] | 546 | 	.reserve	= omap_reserve, | 
| Gregoire Gentil | 7a079ca | 2009-12-11 16:16:34 -0800 | [diff] [blame] | 547 | 	.init_irq	= omap3_touchbook_init_irq, | 
 | 548 | 	.init_machine	= omap3_touchbook_init, | 
 | 549 | 	.timer		= &omap_timer, | 
 | 550 | MACHINE_END |