2 * board-cm-t35.c (CompuLab CM-T35 module)
4 * Copyright (C) 2009 CompuLab, Ltd.
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.
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.
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
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>
31 #include <linux/i2c/at24.h>
32 #include <linux/i2c/twl4030.h>
33 #include <linux/regulator/machine.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
39 #include <plat/board.h>
40 #include <plat/common.h>
41 #include <plat/nand.h>
42 #include <plat/gpmc.h>
45 #include <mach/hardware.h>
48 #include "sdram-micron-mt46h32m32lf-6.h"
49 #include "mmc-twl4030.h"
51 #define CM_T35_GPIO_PENDOWN 57
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
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)
62 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
63 #include <linux/smsc911x.h>
65 static 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,
72 static struct resource cm_t35_smsc911x_resources[] = {
74 .flags = IORESOURCE_MEM,
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,
83 static struct platform_device cm_t35_smsc911x_device = {
86 .num_resources = ARRAY_SIZE(cm_t35_smsc911x_resources),
87 .resource = cm_t35_smsc911x_resources,
89 .platform_data = &cm_t35_smsc911x_config,
93 static struct resource sb_t35_smsc911x_resources[] = {
95 .flags = IORESOURCE_MEM,
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,
104 static struct platform_device sb_t35_smsc911x_device = {
107 .num_resources = ARRAY_SIZE(sb_t35_smsc911x_resources),
108 .resource = sb_t35_smsc911x_resources,
110 .platform_data = &cm_t35_smsc911x_config,
114 static void __init cm_t35_init_smsc911x(struct platform_device *dev,
115 int cs, int irq_gpio)
117 unsigned long cs_mem_base;
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");
124 dev->resource[0].start = cs_mem_base + 0x0;
125 dev->resource[0].end = cs_mem_base + 0xff;
127 if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
128 (gpio_direction_input(irq_gpio) == 0)) {
129 gpio_export(irq_gpio, 0);
131 pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
135 platform_device_register(dev);
138 static void __init cm_t35_init_ethernet(void)
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);
146 static inline void __init cm_t35_init_ethernet(void) { return; }
149 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
150 #include <linux/leds.h>
152 static struct gpio_led cm_t35_leds[] = {
155 .name = "cm-t35:green",
156 .default_trigger = "heartbeat",
161 static struct gpio_led_platform_data cm_t35_led_pdata = {
162 .num_leds = ARRAY_SIZE(cm_t35_leds),
166 static struct platform_device cm_t35_led_device = {
170 .platform_data = &cm_t35_led_pdata,
174 static void __init cm_t35_init_led(void)
176 platform_device_register(&cm_t35_led_device);
179 static inline void cm_t35_init_led(void) {}
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>
187 static struct mtd_partition cm_t35_nand_partitions[] = {
190 .offset = 0, /* Offset = 0x00000 */
191 .size = 4 * NAND_BLOCK_SIZE,
192 .mask_flags = MTD_WRITEABLE
196 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
197 .size = 15 * NAND_BLOCK_SIZE,
200 .name = "uboot environment",
201 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
202 .size = 2 * NAND_BLOCK_SIZE,
206 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
207 .size = 32 * NAND_BLOCK_SIZE,
211 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
212 .size = MTDPART_SIZ_FULL,
216 static 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 */
221 .gpmc_cs_baseaddr = (void __iomem *)GPMC_CS0_BASE_ADDR,
222 .gpmc_baseaddr = (void __iomem *)OMAP34XX_GPMC_VIRT,
226 static struct resource cm_t35_nand_resource = {
227 .flags = IORESOURCE_MEM,
230 static struct platform_device cm_t35_nand_device = {
231 .name = "omap2-nand",
234 .resource = &cm_t35_nand_resource,
236 .platform_data = &cm_t35_nand_data,
240 static void __init cm_t35_init_nand(void)
242 if (platform_device_register(&cm_t35_nand_device) < 0)
243 pr_err("CM-T35: Unable to register NAND device\n");
246 static inline void cm_t35_init_nand(void) {}
249 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
250 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
251 #include <linux/spi/spi.h>
252 #include <linux/spi/ads7846.h>
254 #include <plat/mcspi.h>
256 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
258 .single_channel = 1, /* 0: slave, 1: master */
261 static int ads7846_get_pendown_state(void)
263 return !gpio_get_value(CM_T35_GPIO_PENDOWN);
266 static struct ads7846_platform_data ads7846_config = {
274 .get_pendown_state = ads7846_get_pendown_state,
278 static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
280 .modalias = "ads7846",
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,
290 static void __init cm_t35_init_ads7846(void)
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);
296 pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
300 spi_register_board_info(cm_t35_spi_board_info,
301 ARRAY_SIZE(cm_t35_spi_board_info));
304 static inline void cm_t35_init_ads7846(void) {}
307 static struct regulator_consumer_supply cm_t35_vmmc1_supply = {
311 static struct regulator_consumer_supply cm_t35_vsim_supply = {
312 .supply = "vmmc_aux",
315 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
316 static struct regulator_init_data cm_t35_vmmc1 = {
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,
326 .num_consumer_supplies = 1,
327 .consumer_supplies = &cm_t35_vmmc1_supply,
330 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
331 static struct regulator_init_data cm_t35_vsim = {
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,
341 .num_consumer_supplies = 1,
342 .consumer_supplies = &cm_t35_vsim_supply,
345 static struct twl4030_usb_data cm_t35_usb_data = {
346 .usb_mode = T2_USB_MODE_ULPI,
349 static 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),
355 static struct matrix_keymap_data cm_t35_keymap_data = {
356 .keymap = cm_t35_keymap,
357 .keymap_size = ARRAY_SIZE(cm_t35_keymap),
360 static struct twl4030_keypad_data cm_t35_kp_data = {
361 .keymap_data = &cm_t35_keymap_data,
367 static struct twl4030_hsmmc_info mmc[] = {
381 .ocr_mask = 0x00100000, /* 3.3V */
386 static 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,
392 .reset_gpio_port[0] = -EINVAL,
393 .reset_gpio_port[1] = -EINVAL,
394 .reset_gpio_port[2] = -EINVAL
397 static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
400 int wlan_rst = gpio + 2;
402 if ((gpio_request(wlan_rst, "WLAN RST") == 0) &&
403 (gpio_direction_output(wlan_rst, 1) == 0)) {
404 gpio_export(wlan_rst, 0);
407 gpio_set_value(wlan_rst, 0);
409 gpio_set_value(wlan_rst, 1);
411 pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
414 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
415 mmc[0].gpio_cd = gpio + 0;
416 twl4030_mmc_init(mmc);
418 /* link regulators to MMC adapters */
419 cm_t35_vmmc1_supply.dev = mmc[0].dev;
420 cm_t35_vsim_supply.dev = mmc[0].dev;
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;
426 usb_ehci_init(&ehci_pdata);
431 static 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,
438 static struct twl4030_platform_data cm_t35_twldata = {
439 .irq_base = TWL4030_IRQ_BASE,
440 .irq_end = TWL4030_IRQ_END,
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,
450 static struct i2c_board_info __initdata cm_t35_i2c_boardinfo[] = {
452 I2C_BOARD_INFO("tps65930", 0x48),
453 .flags = I2C_CLIENT_WAKE,
454 .irq = INT_34XX_SYS_NIRQ,
455 .platform_data = &cm_t35_twldata,
459 static void __init cm_t35_init_i2c(void)
461 omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo,
462 ARRAY_SIZE(cm_t35_i2c_boardinfo));
465 static struct omap_board_config_kernel cm_t35_config[] __initdata = {
468 static void __init cm_t35_init_irq(void)
470 omap_board_config = cm_t35_config;
471 omap_board_config_size = ARRAY_SIZE(cm_t35_config);
473 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
474 mt46h32m32lf6_sdrc_params);
479 static void __init cm_t35_map_io(void)
481 omap2_set_globals_343x();
482 omap2_map_common_io();
485 #ifdef CONFIG_OMAP_MUX
486 static struct omap_board_mux board_mux[] __initdata = {
487 { .reg_offset = OMAP_MUX_TERMINATOR },
490 #define board_mux NULL
493 static void __init cm_t35_init(void)
495 omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
499 cm_t35_init_ads7846();
500 cm_t35_init_ethernet();
505 omap_mux_init_signal("sys_nirq",
506 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
509 MACHINE_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,