omap: mux: Add new style init functions to omap3 board-*.c files
[deliverable/linux.git] / arch / arm / mach-omap2 / board-igep0020.c
1 /*
2 * Copyright (C) 2009 Integration Software and Electronic Engineering.
3 *
4 * Modified from mach-omap2/board-generic.c
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/err.h>
16 #include <linux/clk.h>
17 #include <linux/io.h>
18 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
20
21 #include <linux/regulator/machine.h>
22 #include <linux/i2c/twl4030.h>
23
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26
27 #include <plat/board.h>
28 #include <plat/common.h>
29 #include <plat/gpmc.h>
30 #include <plat/mux.h>
31 #include <plat/usb.h>
32
33 #include "mux.h"
34 #include "mmc-twl4030.h"
35
36 #define IGEP2_SMSC911X_CS 5
37 #define IGEP2_SMSC911X_GPIO 176
38 #define IGEP2_GPIO_USBH_NRESET 24
39 #define IGEP2_GPIO_LED0_RED 26
40 #define IGEP2_GPIO_LED0_GREEN 27
41 #define IGEP2_GPIO_LED1_RED 28
42
43 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
44
45 #include <linux/smsc911x.h>
46
47 static struct smsc911x_platform_config igep2_smsc911x_config = {
48 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
49 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
50 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
51 .phy_interface = PHY_INTERFACE_MODE_MII,
52 };
53
54 static struct resource igep2_smsc911x_resources[] = {
55 {
56 .flags = IORESOURCE_MEM,
57 },
58 {
59 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
60 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
61 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
62 },
63 };
64
65 static struct platform_device igep2_smsc911x_device = {
66 .name = "smsc911x",
67 .id = 0,
68 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
69 .resource = igep2_smsc911x_resources,
70 .dev = {
71 .platform_data = &igep2_smsc911x_config,
72 },
73 };
74
75 static inline void __init igep2_init_smsc911x(void)
76 {
77 unsigned long cs_mem_base;
78
79 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
80 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
81 gpmc_cs_free(IGEP2_SMSC911X_CS);
82 return;
83 }
84
85 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
86 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
87
88 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
89 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
90 gpio_export(IGEP2_SMSC911X_GPIO, 0);
91 } else {
92 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
93 return;
94 }
95
96 platform_device_register(&igep2_smsc911x_device);
97 }
98
99 #else
100 static inline void __init igep2_init_smsc911x(void) { }
101 #endif
102
103 static struct omap_board_config_kernel igep2_config[] __initdata = {
104 };
105
106 static struct regulator_consumer_supply igep2_vmmc1_supply = {
107 .supply = "vmmc",
108 };
109
110 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
111 static struct regulator_init_data igep2_vmmc1 = {
112 .constraints = {
113 .min_uV = 1850000,
114 .max_uV = 3150000,
115 .valid_modes_mask = REGULATOR_MODE_NORMAL
116 | REGULATOR_MODE_STANDBY,
117 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
118 | REGULATOR_CHANGE_MODE
119 | REGULATOR_CHANGE_STATUS,
120 },
121 .num_consumer_supplies = 1,
122 .consumer_supplies = &igep2_vmmc1_supply,
123 };
124
125 static struct twl4030_hsmmc_info mmc[] = {
126 {
127 .mmc = 1,
128 .wires = 4,
129 .gpio_cd = -EINVAL,
130 .gpio_wp = -EINVAL,
131 },
132 {
133 .mmc = 2,
134 .wires = 4,
135 .gpio_cd = -EINVAL,
136 .gpio_wp = -EINVAL,
137 },
138 {} /* Terminator */
139 };
140
141 static int igep2_twl_gpio_setup(struct device *dev,
142 unsigned gpio, unsigned ngpio)
143 {
144 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
145 mmc[0].gpio_cd = gpio + 0;
146 twl4030_mmc_init(mmc);
147
148 /* link regulators to MMC adapters ... we "know" the
149 * regulators will be set up only *after* we return.
150 */
151 igep2_vmmc1_supply.dev = mmc[0].dev;
152
153 return 0;
154 };
155
156 static struct twl4030_gpio_platform_data igep2_gpio_data = {
157 .gpio_base = OMAP_MAX_GPIO_LINES,
158 .irq_base = TWL4030_GPIO_IRQ_BASE,
159 .irq_end = TWL4030_GPIO_IRQ_END,
160 .use_leds = false,
161 .setup = igep2_twl_gpio_setup,
162 };
163
164 static struct twl4030_usb_data igep2_usb_data = {
165 .usb_mode = T2_USB_MODE_ULPI,
166 };
167
168 static void __init igep2_init_irq(void)
169 {
170 omap_board_config = igep2_config;
171 omap_board_config_size = ARRAY_SIZE(igep2_config);
172 omap2_init_common_hw(NULL, NULL);
173 omap_init_irq();
174 omap_gpio_init();
175 }
176
177 static struct twl4030_platform_data igep2_twldata = {
178 .irq_base = TWL4030_IRQ_BASE,
179 .irq_end = TWL4030_IRQ_END,
180
181 /* platform_data for children goes here */
182 .usb = &igep2_usb_data,
183 .gpio = &igep2_gpio_data,
184 .vmmc1 = &igep2_vmmc1,
185
186 };
187
188 static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
189 {
190 I2C_BOARD_INFO("twl4030", 0x48),
191 .flags = I2C_CLIENT_WAKE,
192 .irq = INT_34XX_SYS_NIRQ,
193 .platform_data = &igep2_twldata,
194 },
195 };
196
197 static int __init igep2_i2c_init(void)
198 {
199 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
200 ARRAY_SIZE(igep2_i2c_boardinfo));
201 /* Bus 3 is attached to the DVI port where devices like the pico DLP
202 * projector don't work reliably with 400kHz */
203 omap_register_i2c_bus(3, 100, NULL, 0);
204 return 0;
205 }
206
207 #ifdef CONFIG_OMAP_MUX
208 static struct omap_board_mux board_mux[] __initdata = {
209 { .reg_offset = OMAP_MUX_TERMINATOR },
210 };
211 #else
212 #define board_mux NULL
213 #endif
214
215 static void __init igep2_init(void)
216 {
217 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
218 igep2_i2c_init();
219 omap_serial_init();
220 usb_musb_init();
221
222 igep2_init_smsc911x();
223
224 /* GPIO userspace leds */
225 if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
226 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
227 gpio_export(IGEP2_GPIO_LED0_RED, 0);
228 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
229 } else
230 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
231
232 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
233 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
234 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
235 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
236 } else
237 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
238
239 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
240 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
241 gpio_export(IGEP2_GPIO_LED1_RED, 0);
242 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
243 } else
244 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
245 }
246
247 static void __init igep2_map_io(void)
248 {
249 omap2_set_globals_343x();
250 omap2_map_common_io();
251 }
252
253 MACHINE_START(IGEP0020, "IGEP v2 board")
254 .phys_io = 0x48000000,
255 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
256 .boot_params = 0x80000100,
257 .map_io = igep2_map_io,
258 .init_irq = igep2_init_irq,
259 .init_machine = igep2_init,
260 .timer = &omap_timer,
261 MACHINE_END
This page took 0.038256 seconds and 5 git commands to generate.