ARM: OMAP3LOGIC: Adding SDMMC support
[linux-3.10.git] / arch / arm / mach-omap2 / board-omap3logic.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3logic.c
3  *
4  * Copyright (C) 2010 Li-Pro.Net
5  * Stephan Linz <linz@li-pro.net>
6  *
7  * Copyright (C) 2010 Logic Product Development, Inc.
8  * Peter Barada <peter.barada@logicpd.com>
9  *
10  * Modified from Beagle, EVM, and RX51
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 #include <linux/err.h>
22 #include <linux/clk.h>
23 #include <linux/io.h>
24 #include <linux/gpio.h>
25
26 #include <linux/regulator/machine.h>
27
28 #include <linux/i2c/twl.h>
29 #include <linux/mmc/host.h>
30
31 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35
36 #include "mux.h"
37 #include "hsmmc.h"
38
39 #include <plat/mux.h>
40 #include <plat/board.h>
41 #include <plat/common.h>
42 #include <plat/gpmc.h>
43 #include <plat/timer-gp.h>
44 #include <plat/sdrc.h>
45 #include <plat/control.h>
46
47 #define OMAP3LOGIC_SMSC911X_CS                  1
48
49 #define OMAP3530_LV_SOM_MMC_GPIO_CD             110
50 #define OMAP3530_LV_SOM_MMC_GPIO_WP             126
51 #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ       152
52
53 #define OMAP3_TORPEDO_MMC_GPIO_CD               127
54 #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ         129
55
56 static struct regulator_consumer_supply omap3logic_vmmc1_supply = {
57         .supply                 = "vmmc",
58 };
59
60 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
61 static struct regulator_init_data omap3logic_vmmc1 = {
62         .constraints = {
63                 .name                   = "VMMC1",
64                 .min_uV                 = 1850000,
65                 .max_uV                 = 3150000,
66                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
67                                         | REGULATOR_MODE_STANDBY,
68                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
69                                         | REGULATOR_CHANGE_MODE
70                                         | REGULATOR_CHANGE_STATUS,
71         },
72         .num_consumer_supplies  = 1,
73         .consumer_supplies      = &omap3logic_vmmc1_supply,
74 };
75
76 static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
77         .gpio_base      = OMAP_MAX_GPIO_LINES,
78         .irq_base       = TWL4030_GPIO_IRQ_BASE,
79         .irq_end        = TWL4030_GPIO_IRQ_END,
80         .use_leds       = true,
81         .pullups        = BIT(1),
82         .pulldowns      = BIT(2)  | BIT(6)  | BIT(7)  | BIT(8)
83                         | BIT(13) | BIT(15) | BIT(16) | BIT(17),
84 };
85
86 static struct twl4030_platform_data omap3logic_twldata = {
87         .irq_base       = TWL4030_IRQ_BASE,
88         .irq_end        = TWL4030_IRQ_END,
89
90         /* platform_data for children goes here */
91         .gpio           = &omap3logic_gpio_data,
92         .vmmc1          = &omap3logic_vmmc1,
93 };
94
95 static struct i2c_board_info __initdata omap3logic_i2c_boardinfo[] = {
96         {
97                 I2C_BOARD_INFO("twl4030", 0x48),
98                 .flags = I2C_CLIENT_WAKE,
99                 .irq = INT_34XX_SYS_NIRQ,
100                 .platform_data = &omap3logic_twldata,
101         },
102 };
103
104 static int __init omap3logic_i2c_init(void)
105 {
106         omap_register_i2c_bus(1, 2600, omap3logic_i2c_boardinfo,
107                                 ARRAY_SIZE(omap3logic_i2c_boardinfo));
108         return 0;
109 }
110
111 static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
112         {
113                 .name           = "external",
114                 .mmc            = 1,
115                 .caps           = MMC_CAP_4_BIT_DATA,
116                 .gpio_cd        = -EINVAL,
117                 .gpio_wp        = -EINVAL,
118         },
119         {}      /* Terminator */
120 };
121
122 static void __init board_mmc_init(void)
123 {
124         if (machine_is_omap3530_lv_som()) {
125                 /* OMAP3530 LV SOM board */
126                 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
127                 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
128                 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
129                 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
130         } else if (machine_is_omap3_torpedo()) {
131                 /* OMAP3 Torpedo board */
132                 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
133                 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
134         } else {
135                 /* unsupported board */
136                 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
137                 return;
138         }
139
140         omap2_hsmmc_init(board_mmc_info);
141         /* link regulators to MMC adapters */
142         omap3logic_vmmc1_supply.dev = board_mmc_info[0].dev;
143 }
144
145 static void __init omap3logic_init_irq(void)
146 {
147         omap2_init_common_hw(NULL, NULL);
148         omap_init_irq();
149         omap_gpio_init();
150 }
151
152 static void __init omap3logic_init(void)
153 {
154         omap3logic_i2c_init();
155         omap_serial_init();
156         board_mmc_init();
157         /* Ensure SDRC pins are mux'd for self-refresh */
158         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
159         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
160 }
161
162 MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
163         .phys_io        = 0x48000000,
164         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
165         .boot_params    = 0x80000100,
166         .map_io         = omap3_map_io,
167         .init_irq       = omap3logic_init_irq,
168         .init_machine   = omap3logic_init,
169         .timer          = &omap_timer,
170 MACHINE_END
171
172 MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
173         .phys_io        = 0x48000000,
174         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
175         .boot_params    = 0x80000100,
176         .map_io         = omap3_map_io,
177         .init_irq       = omap3logic_init_irq,
178         .init_machine   = omap3logic_init,
179         .timer          = &omap_timer,
180 MACHINE_END