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