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/delay.h>
28 #include <linux/gpio.h>
30 #include <linux/i2c/at24.h>
31 #include <linux/i2c/twl4030.h>
32 #include <linux/regulator/machine.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <plat/board.h>
39 #include <plat/common.h>
41 #include <plat/nand.h>
42 #include <plat/keypad.h>
43 #include <plat/gpmc.h>
46 #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
56 #define NAND_BLOCK_SIZE SZ_128K
57 #define GPMC_CS0_BASE 0x60
58 #define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
60 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
61 #include <linux/smsc911x.h>
63 static struct resource cm_t35_smsc911x_resources
[] = {
65 .name
= "smsc911x-memory",
66 .flags
= IORESOURCE_MEM
,
69 .start
= OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO
),
70 .end
= OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO
),
71 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
75 static struct smsc911x_platform_config cm_t35_smsc911x_config
= {
76 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
77 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
78 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
79 .phy_interface
= PHY_INTERFACE_MODE_MII
,
82 static struct platform_device cm_t35_smsc911x_device
= {
85 .num_resources
= ARRAY_SIZE(cm_t35_smsc911x_resources
),
86 .resource
= cm_t35_smsc911x_resources
,
88 .platform_data
= &cm_t35_smsc911x_config
,
92 static void __init
cm_t35_init_smsc911x(void)
94 unsigned long cs_mem_base
;
96 if (gpmc_cs_request(CM_T35_SMSC911X_CS
, SZ_16M
, &cs_mem_base
) < 0) {
97 pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
101 cm_t35_smsc911x_resources
[0].start
= cs_mem_base
+ 0x0;
102 cm_t35_smsc911x_resources
[0].end
= cs_mem_base
+ 0xff;
104 if ((gpio_request(CM_T35_SMSC911X_GPIO
, "CM ETH IRQ") == 0) &&
105 (gpio_direction_input(CM_T35_SMSC911X_GPIO
) == 0)) {
106 gpio_export(CM_T35_SMSC911X_GPIO
, 0);
108 pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
112 platform_device_register(&cm_t35_smsc911x_device
);
115 static inline void __init
cm_t35_init_smsc911x(void) { return; }
118 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
119 #include <linux/leds.h>
121 static struct gpio_led cm_t35_leds
[] = {
124 .name
= "cm-t35:green",
125 .default_trigger
= "heartbeat",
130 static struct gpio_led_platform_data cm_t35_led_pdata
= {
131 .num_leds
= ARRAY_SIZE(cm_t35_leds
),
135 static struct platform_device cm_t35_led_device
= {
139 .platform_data
= &cm_t35_led_pdata
,
143 static void __init
cm_t35_init_led(void)
145 platform_device_register(&cm_t35_led_device
);
148 static inline void cm_t35_init_led(void) {}
151 #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
152 #include <linux/mtd/mtd.h>
153 #include <linux/mtd/nand.h>
154 #include <linux/mtd/partitions.h>
156 static struct mtd_partition cm_t35_nand_partitions
[] = {
159 .offset
= 0, /* Offset = 0x00000 */
160 .size
= 4 * NAND_BLOCK_SIZE
,
161 .mask_flags
= MTD_WRITEABLE
165 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x80000 */
166 .size
= 15 * NAND_BLOCK_SIZE
,
169 .name
= "uboot environment",
170 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x260000 */
171 .size
= 2 * NAND_BLOCK_SIZE
,
175 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x280000 */
176 .size
= 32 * NAND_BLOCK_SIZE
,
180 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x680000 */
181 .size
= MTDPART_SIZ_FULL
,
185 static struct omap_nand_platform_data cm_t35_nand_data
= {
186 .parts
= cm_t35_nand_partitions
,
187 .nr_parts
= ARRAY_SIZE(cm_t35_nand_partitions
),
188 .dma_channel
= -1, /* disable DMA in OMAP NAND driver */
190 .gpmc_cs_baseaddr
= (void __iomem
*)GPMC_CS0_BASE_ADDR
,
191 .gpmc_baseaddr
= (void __iomem
*)OMAP34XX_GPMC_VIRT
,
195 static struct resource cm_t35_nand_resource
= {
196 .flags
= IORESOURCE_MEM
,
199 static struct platform_device cm_t35_nand_device
= {
200 .name
= "omap2-nand",
203 .resource
= &cm_t35_nand_resource
,
205 .platform_data
= &cm_t35_nand_data
,
209 static void __init
cm_t35_init_nand(void)
211 if (platform_device_register(&cm_t35_nand_device
) < 0)
212 pr_err("CM-T35: Unable to register NAND device\n");
215 static inline void cm_t35_init_nand(void) {}
218 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
219 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
220 #include <linux/spi/spi.h>
221 #include <linux/spi/ads7846.h>
223 #include <plat/mcspi.h>
225 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
227 .single_channel
= 1, /* 0: slave, 1: master */
230 static int ads7846_get_pendown_state(void)
232 return !gpio_get_value(CM_T35_GPIO_PENDOWN
);
235 static struct ads7846_platform_data ads7846_config
= {
243 .get_pendown_state
= ads7846_get_pendown_state
,
247 static struct spi_board_info cm_t35_spi_board_info
[] __initdata
= {
249 .modalias
= "ads7846",
252 .max_speed_hz
= 1500000,
253 .controller_data
= &ads7846_mcspi_config
,
254 .irq
= OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN
),
255 .platform_data
= &ads7846_config
,
259 static void __init
cm_t35_init_ads7846(void)
261 if ((gpio_request(CM_T35_GPIO_PENDOWN
, "ADS7846_PENDOWN") == 0) &&
262 (gpio_direction_input(CM_T35_GPIO_PENDOWN
) == 0)) {
263 gpio_export(CM_T35_GPIO_PENDOWN
, 0);
265 pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
269 spi_register_board_info(cm_t35_spi_board_info
,
270 ARRAY_SIZE(cm_t35_spi_board_info
));
273 static inline void cm_t35_init_ads7846(void) {}
276 static struct regulator_consumer_supply cm_t35_vmmc1_supply
= {
280 static struct regulator_consumer_supply cm_t35_vsim_supply
= {
281 .supply
= "vmmc_aux",
284 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
285 static struct regulator_init_data cm_t35_vmmc1
= {
289 .valid_modes_mask
= REGULATOR_MODE_NORMAL
290 | REGULATOR_MODE_STANDBY
,
291 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
292 | REGULATOR_CHANGE_MODE
293 | REGULATOR_CHANGE_STATUS
,
295 .num_consumer_supplies
= 1,
296 .consumer_supplies
= &cm_t35_vmmc1_supply
,
299 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
300 static struct regulator_init_data cm_t35_vsim
= {
304 .valid_modes_mask
= REGULATOR_MODE_NORMAL
305 | REGULATOR_MODE_STANDBY
,
306 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
307 | REGULATOR_CHANGE_MODE
308 | REGULATOR_CHANGE_STATUS
,
310 .num_consumer_supplies
= 1,
311 .consumer_supplies
= &cm_t35_vsim_supply
,
314 static struct twl4030_usb_data cm_t35_usb_data
= {
315 .usb_mode
= T2_USB_MODE_ULPI
,
318 static int cm_t35_keymap
[] = {
319 KEY(0, 0, KEY_A
), KEY(0, 1, KEY_B
), KEY(0, 2, KEY_LEFT
),
320 KEY(1, 0, KEY_UP
), KEY(1, 1, KEY_ENTER
), KEY(1, 2, KEY_DOWN
),
321 KEY(2, 0, KEY_RIGHT
), KEY(2, 1, KEY_C
), KEY(2, 2, KEY_D
),
324 static struct matrix_keymap_data cm_t35_keymap_data
= {
325 .keymap
= cm_t35_keymap
,
326 .keymap_size
= ARRAY_SIZE(cm_t35_keymap
),
329 static struct twl4030_keypad_data cm_t35_kp_data
= {
330 .keymap_data
= &cm_t35_keymap_data
,
336 static struct twl4030_hsmmc_info mmc
[] = {
350 .ocr_mask
= 0x00100000, /* 3.3V */
355 static struct ehci_hcd_omap_platform_data ehci_pdata
= {
356 .port_mode
[0] = EHCI_HCD_OMAP_MODE_PHY
,
357 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
358 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
361 .reset_gpio_port
[0] = -EINVAL
,
362 .reset_gpio_port
[1] = -EINVAL
,
363 .reset_gpio_port
[2] = -EINVAL
366 static int cm_t35_twl_gpio_setup(struct device
*dev
, unsigned gpio
,
369 int wlan_rst
= gpio
+ 2;
371 if ((gpio_request(wlan_rst
, "WLAN RST") == 0) &&
372 (gpio_direction_output(wlan_rst
, 1) == 0)) {
373 gpio_export(wlan_rst
, 0);
376 gpio_set_value(wlan_rst
, 0);
378 gpio_set_value(wlan_rst
, 1);
380 pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
383 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
384 mmc
[0].gpio_cd
= gpio
+ 0;
385 twl4030_mmc_init(mmc
);
387 /* link regulators to MMC adapters */
388 cm_t35_vmmc1_supply
.dev
= mmc
[0].dev
;
389 cm_t35_vsim_supply
.dev
= mmc
[0].dev
;
391 /* setup USB with proper PHY reset GPIOs */
392 ehci_pdata
.reset_gpio_port
[0] = gpio
+ 6;
393 ehci_pdata
.reset_gpio_port
[1] = gpio
+ 7;
395 usb_ehci_init(&ehci_pdata
);
400 static struct twl4030_gpio_platform_data cm_t35_gpio_data
= {
401 .gpio_base
= OMAP_MAX_GPIO_LINES
,
402 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
403 .irq_end
= TWL4030_GPIO_IRQ_END
,
404 .setup
= cm_t35_twl_gpio_setup
,
407 static struct twl4030_platform_data cm_t35_twldata
= {
408 .irq_base
= TWL4030_IRQ_BASE
,
409 .irq_end
= TWL4030_IRQ_END
,
411 /* platform_data for children goes here */
412 .keypad
= &cm_t35_kp_data
,
413 .usb
= &cm_t35_usb_data
,
414 .gpio
= &cm_t35_gpio_data
,
415 .vmmc1
= &cm_t35_vmmc1
,
416 .vsim
= &cm_t35_vsim
,
419 static struct i2c_board_info __initdata cm_t35_i2c_boardinfo
[] = {
421 I2C_BOARD_INFO("tps65930", 0x48),
422 .flags
= I2C_CLIENT_WAKE
,
423 .irq
= INT_34XX_SYS_NIRQ
,
424 .platform_data
= &cm_t35_twldata
,
428 static void __init
cm_t35_init_i2c(void)
430 omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo
,
431 ARRAY_SIZE(cm_t35_i2c_boardinfo
));
434 static struct omap_board_config_kernel cm_t35_config
[] __initdata
= {
437 static void __init
cm_t35_init_irq(void)
439 omap_board_config
= cm_t35_config
;
440 omap_board_config_size
= ARRAY_SIZE(cm_t35_config
);
442 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
,
443 mt46h32m32lf6_sdrc_params
);
448 static void __init
cm_t35_map_io(void)
450 omap2_set_globals_343x();
451 omap2_map_common_io();
454 static void __init
cm_t35_init(void)
459 cm_t35_init_ads7846();
460 cm_t35_init_smsc911x();
465 omap_cfg_reg(AF26_34XX_SYS_NIRQ
);
468 MACHINE_START(CM_T35
, "Compulab CM-T35")
469 .phys_io
= 0x48000000,
470 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
471 .boot_params
= 0x80000100,
472 .map_io
= cm_t35_map_io
,
473 .init_irq
= cm_t35_init_irq
,
474 .init_machine
= cm_t35_init
,
475 .timer
= &omap_timer
,