OMAP4: Sync up omap4430 defconfig
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-omap2 / board-cm-t35.c
CommitLineData
2886d128
MR
1/*
2 * board-cm-t35.c (CompuLab CM-T35 module)
3 *
4 * Copyright (C) 2009 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/platform_device.h>
26#include <linux/input.h>
27#include <linux/input/matrix_keypad.h>
28#include <linux/delay.h>
29#include <linux/gpio.h>
30
31#include <linux/i2c/at24.h>
32#include <linux/i2c/twl4030.h>
33#include <linux/regulator/machine.h>
34
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38
39#include <plat/board.h>
40#include <plat/common.h>
2886d128
MR
41#include <plat/nand.h>
42#include <plat/gpmc.h>
43#include <plat/usb.h>
44
45#include <mach/hardware.h>
46
ca5742bd 47#include "mux.h"
2886d128
MR
48#include "sdram-micron-mt46h32m32lf-6.h"
49#include "mmc-twl4030.h"
50
51#define CM_T35_GPIO_PENDOWN 57
52
53#define CM_T35_SMSC911X_CS 5
54#define CM_T35_SMSC911X_GPIO 163
55#define SB_T35_SMSC911X_CS 4
56#define SB_T35_SMSC911X_GPIO 65
57
58#define NAND_BLOCK_SIZE SZ_128K
59#define GPMC_CS0_BASE 0x60
60#define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
61
62#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
63#include <linux/smsc911x.h>
64
65static struct smsc911x_platform_config cm_t35_smsc911x_config = {
66 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
67 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
68 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
69 .phy_interface = PHY_INTERFACE_MODE_MII,
70};
71
72static struct resource cm_t35_smsc911x_resources[] = {
73 {
74 .flags = IORESOURCE_MEM,
75 },
76 {
77 .start = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
78 .end = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
79 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
80 },
81};
82
83static struct platform_device cm_t35_smsc911x_device = {
84 .name = "smsc911x",
85 .id = 0,
86 .num_resources = ARRAY_SIZE(cm_t35_smsc911x_resources),
87 .resource = cm_t35_smsc911x_resources,
88 .dev = {
89 .platform_data = &cm_t35_smsc911x_config,
90 },
91};
92
93static struct resource sb_t35_smsc911x_resources[] = {
94 {
95 .flags = IORESOURCE_MEM,
96 },
97 {
98 .start = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
99 .end = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
100 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
101 },
102};
103
104static struct platform_device sb_t35_smsc911x_device = {
105 .name = "smsc911x",
106 .id = 1,
107 .num_resources = ARRAY_SIZE(sb_t35_smsc911x_resources),
108 .resource = sb_t35_smsc911x_resources,
109 .dev = {
110 .platform_data = &cm_t35_smsc911x_config,
111 },
112};
113
114static void __init cm_t35_init_smsc911x(struct platform_device *dev,
115 int cs, int irq_gpio)
116{
117 unsigned long cs_mem_base;
118
119 if (gpmc_cs_request(cs, SZ_16M, &cs_mem_base) < 0) {
120 pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
121 return;
122 }
123
124 dev->resource[0].start = cs_mem_base + 0x0;
125 dev->resource[0].end = cs_mem_base + 0xff;
126
127 if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
128 (gpio_direction_input(irq_gpio) == 0)) {
129 gpio_export(irq_gpio, 0);
130 } else {
131 pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
132 return;
133 }
134
135 platform_device_register(dev);
136}
137
138static void __init cm_t35_init_ethernet(void)
139{
140 cm_t35_init_smsc911x(&cm_t35_smsc911x_device,
141 CM_T35_SMSC911X_CS, CM_T35_SMSC911X_GPIO);
142 cm_t35_init_smsc911x(&sb_t35_smsc911x_device,
143 SB_T35_SMSC911X_CS, SB_T35_SMSC911X_GPIO);
144}
145#else
146static inline void __init cm_t35_init_ethernet(void) { return; }
147#endif
148
149#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
150#include <linux/leds.h>
151
152static struct gpio_led cm_t35_leds[] = {
153 [0] = {
154 .gpio = 186,
155 .name = "cm-t35:green",
156 .default_trigger = "heartbeat",
157 .active_low = 0,
158 },
159};
160
161static struct gpio_led_platform_data cm_t35_led_pdata = {
162 .num_leds = ARRAY_SIZE(cm_t35_leds),
163 .leds = cm_t35_leds,
164};
165
166static struct platform_device cm_t35_led_device = {
167 .name = "leds-gpio",
168 .id = -1,
169 .dev = {
170 .platform_data = &cm_t35_led_pdata,
171 },
172};
173
174static void __init cm_t35_init_led(void)
175{
176 platform_device_register(&cm_t35_led_device);
177}
178#else
179static inline void cm_t35_init_led(void) {}
180#endif
181
182#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
183#include <linux/mtd/mtd.h>
184#include <linux/mtd/nand.h>
185#include <linux/mtd/partitions.h>
186
187static struct mtd_partition cm_t35_nand_partitions[] = {
188 {
189 .name = "xloader",
190 .offset = 0, /* Offset = 0x00000 */
191 .size = 4 * NAND_BLOCK_SIZE,
192 .mask_flags = MTD_WRITEABLE
193 },
194 {
195 .name = "uboot",
196 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
197 .size = 15 * NAND_BLOCK_SIZE,
198 },
199 {
200 .name = "uboot environment",
201 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
202 .size = 2 * NAND_BLOCK_SIZE,
203 },
204 {
205 .name = "linux",
206 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
207 .size = 32 * NAND_BLOCK_SIZE,
208 },
209 {
210 .name = "rootfs",
211 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
212 .size = MTDPART_SIZ_FULL,
213 },
214};
215
216static struct omap_nand_platform_data cm_t35_nand_data = {
217 .parts = cm_t35_nand_partitions,
218 .nr_parts = ARRAY_SIZE(cm_t35_nand_partitions),
219 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
220 .cs = 0,
221 .gpmc_cs_baseaddr = (void __iomem *)GPMC_CS0_BASE_ADDR,
222 .gpmc_baseaddr = (void __iomem *)OMAP34XX_GPMC_VIRT,
223
224};
225
226static struct resource cm_t35_nand_resource = {
227 .flags = IORESOURCE_MEM,
228};
229
230static struct platform_device cm_t35_nand_device = {
231 .name = "omap2-nand",
232 .id = -1,
233 .num_resources = 1,
234 .resource = &cm_t35_nand_resource,
235 .dev = {
236 .platform_data = &cm_t35_nand_data,
237 },
238};
239
240static void __init cm_t35_init_nand(void)
241{
242 if (platform_device_register(&cm_t35_nand_device) < 0)
243 pr_err("CM-T35: Unable to register NAND device\n");
244}
245#else
246static inline void cm_t35_init_nand(void) {}
247#endif
248
249#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
250 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
251#include <linux/spi/spi.h>
252#include <linux/spi/ads7846.h>
253
254#include <plat/mcspi.h>
255
256static struct omap2_mcspi_device_config ads7846_mcspi_config = {
257 .turbo_mode = 0,
258 .single_channel = 1, /* 0: slave, 1: master */
259};
260
261static int ads7846_get_pendown_state(void)
262{
263 return !gpio_get_value(CM_T35_GPIO_PENDOWN);
264}
265
266static struct ads7846_platform_data ads7846_config = {
267 .x_max = 0x0fff,
268 .y_max = 0x0fff,
269 .x_plate_ohms = 180,
270 .pressure_max = 255,
271 .debounce_max = 10,
272 .debounce_tol = 3,
273 .debounce_rep = 1,
274 .get_pendown_state = ads7846_get_pendown_state,
275 .keep_vref_on = 1,
276};
277
278static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
279 {
280 .modalias = "ads7846",
281 .bus_num = 1,
282 .chip_select = 0,
283 .max_speed_hz = 1500000,
284 .controller_data = &ads7846_mcspi_config,
285 .irq = OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN),
286 .platform_data = &ads7846_config,
287 },
288};
289
290static void __init cm_t35_init_ads7846(void)
291{
292 if ((gpio_request(CM_T35_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
293 (gpio_direction_input(CM_T35_GPIO_PENDOWN) == 0)) {
294 gpio_export(CM_T35_GPIO_PENDOWN, 0);
295 } else {
296 pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
297 return;
298 }
299
300 spi_register_board_info(cm_t35_spi_board_info,
301 ARRAY_SIZE(cm_t35_spi_board_info));
302}
303#else
304static inline void cm_t35_init_ads7846(void) {}
305#endif
306
307static struct regulator_consumer_supply cm_t35_vmmc1_supply = {
308 .supply = "vmmc",
309};
310
311static struct regulator_consumer_supply cm_t35_vsim_supply = {
312 .supply = "vmmc_aux",
313};
314
315/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
316static struct regulator_init_data cm_t35_vmmc1 = {
317 .constraints = {
318 .min_uV = 1850000,
319 .max_uV = 3150000,
320 .valid_modes_mask = REGULATOR_MODE_NORMAL
321 | REGULATOR_MODE_STANDBY,
322 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
323 | REGULATOR_CHANGE_MODE
324 | REGULATOR_CHANGE_STATUS,
325 },
326 .num_consumer_supplies = 1,
327 .consumer_supplies = &cm_t35_vmmc1_supply,
328};
329
330/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
331static struct regulator_init_data cm_t35_vsim = {
332 .constraints = {
333 .min_uV = 1800000,
334 .max_uV = 3000000,
335 .valid_modes_mask = REGULATOR_MODE_NORMAL
336 | REGULATOR_MODE_STANDBY,
337 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
338 | REGULATOR_CHANGE_MODE
339 | REGULATOR_CHANGE_STATUS,
340 },
341 .num_consumer_supplies = 1,
342 .consumer_supplies = &cm_t35_vsim_supply,
343};
344
345static struct twl4030_usb_data cm_t35_usb_data = {
346 .usb_mode = T2_USB_MODE_ULPI,
347};
348
349static int cm_t35_keymap[] = {
350 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT),
351 KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN),
352 KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D),
353};
354
355static struct matrix_keymap_data cm_t35_keymap_data = {
356 .keymap = cm_t35_keymap,
357 .keymap_size = ARRAY_SIZE(cm_t35_keymap),
358};
359
360static struct twl4030_keypad_data cm_t35_kp_data = {
361 .keymap_data = &cm_t35_keymap_data,
362 .rows = 3,
363 .cols = 3,
364 .rep = 1,
365};
366
367static struct twl4030_hsmmc_info mmc[] = {
368 {
369 .mmc = 1,
370 .wires = 4,
371 .gpio_cd = -EINVAL,
372 .gpio_wp = -EINVAL,
373
374 },
375 {
376 .mmc = 2,
377 .wires = 4,
378 .transceiver = 1,
379 .gpio_cd = -EINVAL,
380 .gpio_wp = -EINVAL,
381 .ocr_mask = 0x00100000, /* 3.3V */
382 },
383 {} /* Terminator */
384};
385
386static struct ehci_hcd_omap_platform_data ehci_pdata = {
387 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
388 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
389 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
390
391 .phy_reset = true,
392 .reset_gpio_port[0] = -EINVAL,
393 .reset_gpio_port[1] = -EINVAL,
394 .reset_gpio_port[2] = -EINVAL
395};
396
397static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
398 unsigned ngpio)
399{
400 int wlan_rst = gpio + 2;
401
402 if ((gpio_request(wlan_rst, "WLAN RST") == 0) &&
403 (gpio_direction_output(wlan_rst, 1) == 0)) {
404 gpio_export(wlan_rst, 0);
405
406 udelay(10);
407 gpio_set_value(wlan_rst, 0);
408 udelay(10);
409 gpio_set_value(wlan_rst, 1);
410 } else {
411 pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
412 }
413
414 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
415 mmc[0].gpio_cd = gpio + 0;
416 twl4030_mmc_init(mmc);
417
418 /* link regulators to MMC adapters */
419 cm_t35_vmmc1_supply.dev = mmc[0].dev;
420 cm_t35_vsim_supply.dev = mmc[0].dev;
421
422 /* setup USB with proper PHY reset GPIOs */
423 ehci_pdata.reset_gpio_port[0] = gpio + 6;
424 ehci_pdata.reset_gpio_port[1] = gpio + 7;
425
426 usb_ehci_init(&ehci_pdata);
427
428 return 0;
429}
430
431static struct twl4030_gpio_platform_data cm_t35_gpio_data = {
432 .gpio_base = OMAP_MAX_GPIO_LINES,
433 .irq_base = TWL4030_GPIO_IRQ_BASE,
434 .irq_end = TWL4030_GPIO_IRQ_END,
435 .setup = cm_t35_twl_gpio_setup,
436};
437
438static struct twl4030_platform_data cm_t35_twldata = {
439 .irq_base = TWL4030_IRQ_BASE,
440 .irq_end = TWL4030_IRQ_END,
441
442 /* platform_data for children goes here */
443 .keypad = &cm_t35_kp_data,
444 .usb = &cm_t35_usb_data,
445 .gpio = &cm_t35_gpio_data,
446 .vmmc1 = &cm_t35_vmmc1,
447 .vsim = &cm_t35_vsim,
448};
449
450static struct i2c_board_info __initdata cm_t35_i2c_boardinfo[] = {
451 {
452 I2C_BOARD_INFO("tps65930", 0x48),
453 .flags = I2C_CLIENT_WAKE,
454 .irq = INT_34XX_SYS_NIRQ,
455 .platform_data = &cm_t35_twldata,
456 },
457};
458
459static void __init cm_t35_init_i2c(void)
460{
461 omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo,
462 ARRAY_SIZE(cm_t35_i2c_boardinfo));
463}
464
465static struct omap_board_config_kernel cm_t35_config[] __initdata = {
466};
467
468static void __init cm_t35_init_irq(void)
469{
470 omap_board_config = cm_t35_config;
471 omap_board_config_size = ARRAY_SIZE(cm_t35_config);
472
473 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
474 mt46h32m32lf6_sdrc_params);
475 omap_init_irq();
476 omap_gpio_init();
477}
478
479static void __init cm_t35_map_io(void)
480{
481 omap2_set_globals_343x();
482 omap2_map_common_io();
483}
484
ca5742bd
TL
485#ifdef CONFIG_OMAP_MUX
486static struct omap_board_mux board_mux[] __initdata = {
487 { .reg_offset = OMAP_MUX_TERMINATOR },
488};
489#else
490#define board_mux NULL
491#endif
492
2886d128
MR
493static void __init cm_t35_init(void)
494{
ca5742bd 495 omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
2886d128
MR
496 omap_serial_init();
497 cm_t35_init_i2c();
498 cm_t35_init_nand();
499 cm_t35_init_ads7846();
500 cm_t35_init_ethernet();
501 cm_t35_init_led();
502
503 usb_musb_init();
504
4896e394
TL
505 omap_mux_init_signal("sys_nirq",
506 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
2886d128
MR
507}
508
509MACHINE_START(CM_T35, "Compulab CM-T35")
510 .phys_io = 0x48000000,
511 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
512 .boot_params = 0x80000100,
513 .map_io = cm_t35_map_io,
514 .init_irq = cm_t35_init_irq,
515 .init_machine = cm_t35_init,
516 .timer = &omap_timer,
517MACHINE_END