Merge branch 'for-rmk/perf' into for-rmk/virt/kvm/core
[deliverable/linux.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-2012 Logic Product Development, Inc.
8 * Peter Barada <peter.barada@logicpd.com>
9 * Ashwin BIhari <ashwin.bihari@logicpd.com>
10 *
11 * Modified from Beagle, EVM, and RX51
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
24 #include <linux/io.h>
25 #include <linux/gpio.h>
26
27 #include <linux/regulator/fixed.h>
28 #include <linux/regulator/machine.h>
29
30 #include <linux/i2c/twl.h>
31 #include <linux/mmc/host.h>
32
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
36
37 #include "common.h"
38 #include "mux.h"
39 #include "hsmmc.h"
40 #include "control.h"
41 #include "common-board-devices.h"
42 #include "gpmc.h"
43 #include "gpmc-smsc911x.h"
44
45 #define OMAP3LOGIC_SMSC911X_CS 1
46
47 #define OMAP3530_LV_SOM_MMC_GPIO_CD 110
48 #define OMAP3530_LV_SOM_MMC_GPIO_WP 126
49 #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
50
51 #define OMAP3_TORPEDO_MMC_GPIO_CD 127
52 #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
53
54 static struct regulator_consumer_supply omap3logic_vmmc1_supply[] = {
55 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
56 };
57
58 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
59 static struct regulator_init_data omap3logic_vmmc1 = {
60 .constraints = {
61 .name = "VMMC1",
62 .min_uV = 1850000,
63 .max_uV = 3150000,
64 .valid_modes_mask = REGULATOR_MODE_NORMAL
65 | REGULATOR_MODE_STANDBY,
66 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
67 | REGULATOR_CHANGE_MODE
68 | REGULATOR_CHANGE_STATUS,
69 },
70 .num_consumer_supplies = ARRAY_SIZE(omap3logic_vmmc1_supply),
71 .consumer_supplies = omap3logic_vmmc1_supply,
72 };
73
74 static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
75 .use_leds = true,
76 .pullups = BIT(1),
77 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
78 | BIT(13) | BIT(15) | BIT(16) | BIT(17),
79 };
80
81 static struct twl4030_usb_data omap3logic_usb_data = {
82 .usb_mode = T2_USB_MODE_ULPI,
83 };
84
85
86 static struct twl4030_platform_data omap3logic_twldata = {
87 /* platform_data for children goes here */
88 .gpio = &omap3logic_gpio_data,
89 .vmmc1 = &omap3logic_vmmc1,
90 .usb = &omap3logic_usb_data,
91 };
92
93 static int __init omap3logic_i2c_init(void)
94 {
95 omap3_pmic_init("twl4030", &omap3logic_twldata);
96 return 0;
97 }
98
99 static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
100 {
101 .name = "external",
102 .mmc = 1,
103 .caps = MMC_CAP_4_BIT_DATA,
104 .gpio_cd = -EINVAL,
105 .gpio_wp = -EINVAL,
106 },
107 {} /* Terminator */
108 };
109
110 static void __init board_mmc_init(void)
111 {
112 if (machine_is_omap3530_lv_som()) {
113 /* OMAP3530 LV SOM board */
114 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
115 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
116 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
117 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
118 } else if (machine_is_omap3_torpedo()) {
119 /* OMAP3 Torpedo board */
120 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
121 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
122 } else {
123 /* unsupported board */
124 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
125 return;
126 }
127
128 omap_hsmmc_init(board_mmc_info);
129 }
130
131 static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
132 .cs = OMAP3LOGIC_SMSC911X_CS,
133 .gpio_irq = -EINVAL,
134 .gpio_reset = -EINVAL,
135 };
136
137 /* TODO/FIXME (comment by Peter Barada, LogicPD):
138 * Fix the PBIAS voltage for Torpedo MMC1 pins that
139 * are used for other needs (IRQs, etc). */
140 static void omap3torpedo_fix_pbias_voltage(void)
141 {
142 u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
143 u32 reg;
144
145 if (machine_is_omap3_torpedo())
146 {
147 /* Set the bias for the pin */
148 reg = omap_ctrl_readl(control_pbias_offset);
149
150 reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
151 omap_ctrl_writel(reg, control_pbias_offset);
152
153 /* 100ms delay required for PBIAS configuration */
154 msleep(100);
155
156 reg |= OMAP343X_PBIASLITEVMODE1;
157 reg |= OMAP343X_PBIASLITEPWRDNZ1;
158 omap_ctrl_writel(reg | 0x300, control_pbias_offset);
159 }
160 }
161
162 static inline void __init board_smsc911x_init(void)
163 {
164 if (machine_is_omap3530_lv_som()) {
165 /* OMAP3530 LV SOM board */
166 board_smsc911x_data.gpio_irq =
167 OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
168 omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
169 } else if (machine_is_omap3_torpedo()) {
170 /* OMAP3 Torpedo board */
171 board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
172 omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
173 } else {
174 /* unsupported board */
175 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
176 return;
177 }
178
179 gpmc_smsc911x_init(&board_smsc911x_data);
180 }
181
182 #ifdef CONFIG_OMAP_MUX
183 static struct omap_board_mux board_mux[] __initdata = {
184 /* mUSB */
185 OMAP3_MUX(HSUSB0_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
186 OMAP3_MUX(HSUSB0_STP, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
187 OMAP3_MUX(HSUSB0_DIR, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
188 OMAP3_MUX(HSUSB0_NXT, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
189 OMAP3_MUX(HSUSB0_DATA0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
190 OMAP3_MUX(HSUSB0_DATA1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
191 OMAP3_MUX(HSUSB0_DATA2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
192 OMAP3_MUX(HSUSB0_DATA3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
193 OMAP3_MUX(HSUSB0_DATA4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
194 OMAP3_MUX(HSUSB0_DATA5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
195 OMAP3_MUX(HSUSB0_DATA6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
196 OMAP3_MUX(HSUSB0_DATA7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
197
198 { .reg_offset = OMAP_MUX_TERMINATOR },
199 };
200 #endif
201
202 static struct regulator_consumer_supply dummy_supplies[] = {
203 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
204 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
205 };
206
207 static void __init omap3logic_init(void)
208 {
209 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
210 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
211 omap3torpedo_fix_pbias_voltage();
212 omap3logic_i2c_init();
213 omap_serial_init();
214 omap_sdrc_init(NULL, NULL);
215 board_mmc_init();
216 board_smsc911x_init();
217
218 usb_musb_init(NULL);
219
220 /* Ensure SDRC pins are mux'd for self-refresh */
221 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
222 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
223 }
224
225 MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
226 .atag_offset = 0x100,
227 .reserve = omap_reserve,
228 .map_io = omap3_map_io,
229 .init_early = omap35xx_init_early,
230 .init_irq = omap3_init_irq,
231 .handle_irq = omap3_intc_handle_irq,
232 .init_machine = omap3logic_init,
233 .init_late = omap35xx_init_late,
234 .timer = &omap3_timer,
235 .restart = omap3xxx_restart,
236 MACHINE_END
237
238 MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
239 .atag_offset = 0x100,
240 .reserve = omap_reserve,
241 .map_io = omap3_map_io,
242 .init_early = omap35xx_init_early,
243 .init_irq = omap3_init_irq,
244 .handle_irq = omap3_intc_handle_irq,
245 .init_machine = omap3logic_init,
246 .init_late = omap35xx_init_late,
247 .timer = &omap3_timer,
248 .restart = omap3xxx_restart,
249 MACHINE_END
This page took 0.064884 seconds and 5 git commands to generate.