2 * board-cm-t35.c (CompuLab CM-T35 module)
4 * Copyright (C) 2009 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
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>
42 #include <plat/nand.h>
43 #include <plat/gpmc.h>
46 #include <mach/hardware.h>
49 #include "sdram-micron-mt46h32m32lf-6.h"
50 #include "mmc-twl4030.h"
52 #define CM_T35_GPIO_PENDOWN 57
54 #define CM_T35_SMSC911X_CS 5
55 #define CM_T35_SMSC911X_GPIO 163
56 #define SB_T35_SMSC911X_CS 4
57 #define SB_T35_SMSC911X_GPIO 65
59 #define NAND_BLOCK_SIZE SZ_128K
60 #define GPMC_CS0_BASE 0x60
61 #define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
63 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
64 #include <linux/smsc911x.h>
66 static struct smsc911x_platform_config cm_t35_smsc911x_config = {
67 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
68 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
69 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
70 .phy_interface = PHY_INTERFACE_MODE_MII,
73 static struct resource cm_t35_smsc911x_resources[] = {
75 .flags = IORESOURCE_MEM,
78 .start = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
79 .end = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
80 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
84 static struct platform_device cm_t35_smsc911x_device = {
87 .num_resources = ARRAY_SIZE(cm_t35_smsc911x_resources),
88 .resource = cm_t35_smsc911x_resources,
90 .platform_data = &cm_t35_smsc911x_config,
94 static struct resource sb_t35_smsc911x_resources[] = {
96 .flags = IORESOURCE_MEM,
99 .start = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
100 .end = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
101 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
105 static struct platform_device sb_t35_smsc911x_device = {
108 .num_resources = ARRAY_SIZE(sb_t35_smsc911x_resources),
109 .resource = sb_t35_smsc911x_resources,
111 .platform_data = &cm_t35_smsc911x_config,
115 static void __init cm_t35_init_smsc911x(struct platform_device *dev,
116 int cs, int irq_gpio)
118 unsigned long cs_mem_base;
120 if (gpmc_cs_request(cs, SZ_16M, &cs_mem_base) < 0) {
121 pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
125 dev->resource[0].start = cs_mem_base + 0x0;
126 dev->resource[0].end = cs_mem_base + 0xff;
128 if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
129 (gpio_direction_input(irq_gpio) == 0)) {
130 gpio_export(irq_gpio, 0);
132 pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
136 platform_device_register(dev);
139 static void __init cm_t35_init_ethernet(void)
141 cm_t35_init_smsc911x(&cm_t35_smsc911x_device,
142 CM_T35_SMSC911X_CS, CM_T35_SMSC911X_GPIO);
143 cm_t35_init_smsc911x(&sb_t35_smsc911x_device,
144 SB_T35_SMSC911X_CS, SB_T35_SMSC911X_GPIO);
147 static inline void __init cm_t35_init_ethernet(void) { return; }
150 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
151 #include <linux/leds.h>
153 static struct gpio_led cm_t35_leds[] = {
156 .name = "cm-t35:green",
157 .default_trigger = "heartbeat",
162 static struct gpio_led_platform_data cm_t35_led_pdata = {
163 .num_leds = ARRAY_SIZE(cm_t35_leds),
167 static struct platform_device cm_t35_led_device = {
171 .platform_data = &cm_t35_led_pdata,
175 static void __init cm_t35_init_led(void)
177 platform_device_register(&cm_t35_led_device);
180 static inline void cm_t35_init_led(void) {}
183 #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
184 #include <linux/mtd/mtd.h>
185 #include <linux/mtd/nand.h>
186 #include <linux/mtd/partitions.h>
188 static struct mtd_partition cm_t35_nand_partitions[] = {
191 .offset = 0, /* Offset = 0x00000 */
192 .size = 4 * NAND_BLOCK_SIZE,
193 .mask_flags = MTD_WRITEABLE
197 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
198 .size = 15 * NAND_BLOCK_SIZE,
201 .name = "uboot environment",
202 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
203 .size = 2 * NAND_BLOCK_SIZE,
207 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
208 .size = 32 * NAND_BLOCK_SIZE,
212 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
213 .size = MTDPART_SIZ_FULL,
217 static struct omap_nand_platform_data cm_t35_nand_data = {
218 .parts = cm_t35_nand_partitions,
219 .nr_parts = ARRAY_SIZE(cm_t35_nand_partitions),
220 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
222 .gpmc_cs_baseaddr = (void __iomem *)GPMC_CS0_BASE_ADDR,
223 .gpmc_baseaddr = (void __iomem *)OMAP34XX_GPMC_VIRT,
227 static struct resource cm_t35_nand_resource = {
228 .flags = IORESOURCE_MEM,
231 static struct platform_device cm_t35_nand_device = {
232 .name = "omap2-nand",
235 .resource = &cm_t35_nand_resource,
237 .platform_data = &cm_t35_nand_data,
241 static void __init cm_t35_init_nand(void)
243 if (platform_device_register(&cm_t35_nand_device) < 0)
244 pr_err("CM-T35: Unable to register NAND device\n");
247 static inline void cm_t35_init_nand(void) {}
250 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
251 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
252 #include <linux/spi/spi.h>
253 #include <linux/spi/ads7846.h>
255 #include <plat/mcspi.h>
257 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
259 .single_channel = 1, /* 0: slave, 1: master */
262 static int ads7846_get_pendown_state(void)
264 return !gpio_get_value(CM_T35_GPIO_PENDOWN);
267 static struct ads7846_platform_data ads7846_config = {
275 .get_pendown_state = ads7846_get_pendown_state,
279 static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
281 .modalias = "ads7846",
284 .max_speed_hz = 1500000,
285 .controller_data = &ads7846_mcspi_config,
286 .irq = OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN),
287 .platform_data = &ads7846_config,
291 static void __init cm_t35_init_ads7846(void)
293 if ((gpio_request(CM_T35_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
294 (gpio_direction_input(CM_T35_GPIO_PENDOWN) == 0)) {
295 gpio_export(CM_T35_GPIO_PENDOWN, 0);
297 pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
301 spi_register_board_info(cm_t35_spi_board_info,
302 ARRAY_SIZE(cm_t35_spi_board_info));
305 static inline void cm_t35_init_ads7846(void) {}
308 static struct regulator_consumer_supply cm_t35_vmmc1_supply = {
312 static struct regulator_consumer_supply cm_t35_vsim_supply = {
313 .supply = "vmmc_aux",
316 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
317 static struct regulator_init_data cm_t35_vmmc1 = {
321 .valid_modes_mask = REGULATOR_MODE_NORMAL
322 | REGULATOR_MODE_STANDBY,
323 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
324 | REGULATOR_CHANGE_MODE
325 | REGULATOR_CHANGE_STATUS,
327 .num_consumer_supplies = 1,
328 .consumer_supplies = &cm_t35_vmmc1_supply,
331 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
332 static struct regulator_init_data cm_t35_vsim = {
336 .valid_modes_mask = REGULATOR_MODE_NORMAL
337 | REGULATOR_MODE_STANDBY,
338 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
339 | REGULATOR_CHANGE_MODE
340 | REGULATOR_CHANGE_STATUS,
342 .num_consumer_supplies = 1,
343 .consumer_supplies = &cm_t35_vsim_supply,
346 static struct twl4030_usb_data cm_t35_usb_data = {
347 .usb_mode = T2_USB_MODE_ULPI,
350 static int cm_t35_keymap[] = {
351 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT),
352 KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN),
353 KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D),
356 static struct matrix_keymap_data cm_t35_keymap_data = {
357 .keymap = cm_t35_keymap,
358 .keymap_size = ARRAY_SIZE(cm_t35_keymap),
361 static struct twl4030_keypad_data cm_t35_kp_data = {
362 .keymap_data = &cm_t35_keymap_data,
368 static struct twl4030_hsmmc_info mmc[] = {
382 .ocr_mask = 0x00100000, /* 3.3V */
387 static struct ehci_hcd_omap_platform_data ehci_pdata = {
388 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
389 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
390 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
393 .reset_gpio_port[0] = -EINVAL,
394 .reset_gpio_port[1] = -EINVAL,
395 .reset_gpio_port[2] = -EINVAL
398 static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
401 int wlan_rst = gpio + 2;
403 if ((gpio_request(wlan_rst, "WLAN RST") == 0) &&
404 (gpio_direction_output(wlan_rst, 1) == 0)) {
405 gpio_export(wlan_rst, 0);
408 gpio_set_value(wlan_rst, 0);
410 gpio_set_value(wlan_rst, 1);
412 pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
415 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
416 mmc[0].gpio_cd = gpio + 0;
417 twl4030_mmc_init(mmc);
419 /* link regulators to MMC adapters */
420 cm_t35_vmmc1_supply.dev = mmc[0].dev;
421 cm_t35_vsim_supply.dev = mmc[0].dev;
423 /* setup USB with proper PHY reset GPIOs */
424 ehci_pdata.reset_gpio_port[0] = gpio + 6;
425 ehci_pdata.reset_gpio_port[1] = gpio + 7;
427 usb_ehci_init(&ehci_pdata);
432 static struct twl4030_gpio_platform_data cm_t35_gpio_data = {
433 .gpio_base = OMAP_MAX_GPIO_LINES,
434 .irq_base = TWL4030_GPIO_IRQ_BASE,
435 .irq_end = TWL4030_GPIO_IRQ_END,
436 .setup = cm_t35_twl_gpio_setup,
439 static struct twl4030_platform_data cm_t35_twldata = {
440 .irq_base = TWL4030_IRQ_BASE,
441 .irq_end = TWL4030_IRQ_END,
443 /* platform_data for children goes here */
444 .keypad = &cm_t35_kp_data,
445 .usb = &cm_t35_usb_data,
446 .gpio = &cm_t35_gpio_data,
447 .vmmc1 = &cm_t35_vmmc1,
448 .vsim = &cm_t35_vsim,
451 static struct i2c_board_info __initdata cm_t35_i2c_boardinfo[] = {
453 I2C_BOARD_INFO("tps65930", 0x48),
454 .flags = I2C_CLIENT_WAKE,
455 .irq = INT_34XX_SYS_NIRQ,
456 .platform_data = &cm_t35_twldata,
460 static void __init cm_t35_init_i2c(void)
462 omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo,
463 ARRAY_SIZE(cm_t35_i2c_boardinfo));
466 static struct omap_board_config_kernel cm_t35_config[] __initdata = {
469 static void __init cm_t35_init_irq(void)
471 omap_board_config = cm_t35_config;
472 omap_board_config_size = ARRAY_SIZE(cm_t35_config);
474 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
475 mt46h32m32lf6_sdrc_params);
480 static void __init cm_t35_map_io(void)
482 omap2_set_globals_343x();
483 omap2_map_common_io();
486 #ifdef CONFIG_OMAP_MUX
487 static struct omap_board_mux board_mux[] __initdata = {
488 { .reg_offset = OMAP_MUX_TERMINATOR },
491 #define board_mux NULL
494 static void __init cm_t35_init(void)
496 omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
500 cm_t35_init_ads7846();
501 cm_t35_init_ethernet();
506 omap_mux_init_signal("sys_nirq",
507 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
510 MACHINE_START(CM_T35, "Compulab CM-T35")
511 .phys_io = 0x48000000,
512 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
513 .boot_params = 0x80000100,
514 .map_io = cm_t35_map_io,
515 .init_irq = cm_t35_init_irq,
516 .init_machine = cm_t35_init,
517 .timer = &omap_timer,