Commit | Line | Data |
---|---|---|
9b6553cd TL |
1 | /* |
2 | * linux/arch/arm/mach-omap1/board-ams-delta.c | |
3 | * | |
4 | * Modified from board-generic.c | |
5 | * | |
6 | * Board specific inits for the Amstrad E3 (codename Delta) videophone | |
7 | * | |
8 | * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 as | |
12 | * published by the Free Software Foundation. | |
13 | */ | |
937eb4bb | 14 | #include <linux/basic_mmio_gpio.h> |
2f8163ba | 15 | #include <linux/gpio.h> |
9b6553cd TL |
16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | |
325d50b6 | 18 | #include <linux/input.h> |
eff443df | 19 | #include <linux/interrupt.h> |
243e76b4 | 20 | #include <linux/leds.h> |
ac2885df | 21 | #include <linux/mutex.h> |
9b6553cd | 22 | #include <linux/platform_device.h> |
ac2885df JK |
23 | #include <linux/regulator/consumer.h> |
24 | #include <linux/regulator/fixed.h> | |
25 | #include <linux/regulator/machine.h> | |
eff443df | 26 | #include <linux/serial_8250.h> |
dc28094b | 27 | #include <linux/export.h> |
9b6553cd | 28 | |
8452e9ef JK |
29 | #include <media/soc_camera.h> |
30 | ||
eff443df | 31 | #include <asm/serial.h> |
a09e64fb | 32 | #include <mach/hardware.h> |
9b6553cd TL |
33 | #include <asm/mach-types.h> |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/map.h> | |
36 | ||
7489ffce | 37 | #include <plat/io.h> |
ce491cf8 | 38 | #include <plat/board-ams-delta.h> |
ce491cf8 TL |
39 | #include <plat/keypad.h> |
40 | #include <plat/mux.h> | |
41 | #include <plat/usb.h> | |
42 | #include <plat/board.h> | |
4e65331c | 43 | #include "common.h" |
8452e9ef | 44 | #include <mach/camera.h> |
9b6553cd | 45 | |
e6f740f5 JK |
46 | #include <mach/ams-delta-fiq.h> |
47 | ||
da1f026b | 48 | static const unsigned int ams_delta_keymap[] = { |
a524626b | 49 | KEY(0, 0, KEY_F1), /* Advert */ |
325d50b6 | 50 | |
da1f026b JK |
51 | KEY(0, 3, KEY_COFFEE), /* Games */ |
52 | KEY(0, 2, KEY_QUESTION), /* Directory */ | |
53 | KEY(2, 3, KEY_CONNECT), /* Internet */ | |
54 | KEY(1, 2, KEY_SHOP), /* Services */ | |
a524626b | 55 | KEY(1, 1, KEY_PHONE), /* VoiceMail */ |
325d50b6 | 56 | |
da1f026b | 57 | KEY(0, 1, KEY_DELETE), /* Delete */ |
a524626b | 58 | KEY(2, 2, KEY_PLAY), /* Play */ |
da1f026b JK |
59 | KEY(1, 0, KEY_PAGEUP), /* Up */ |
60 | KEY(1, 3, KEY_PAGEDOWN), /* Down */ | |
61 | KEY(2, 0, KEY_EMAIL), /* ReadEmail */ | |
62 | KEY(2, 1, KEY_STOP), /* Stop */ | |
325d50b6 JM |
63 | |
64 | /* Numeric keypad portion */ | |
da1f026b JK |
65 | KEY(0, 7, KEY_KP1), |
66 | KEY(0, 6, KEY_KP2), | |
67 | KEY(0, 5, KEY_KP3), | |
68 | KEY(1, 7, KEY_KP4), | |
69 | KEY(1, 6, KEY_KP5), | |
70 | KEY(1, 5, KEY_KP6), | |
71 | KEY(2, 7, KEY_KP7), | |
72 | KEY(2, 6, KEY_KP8), | |
73 | KEY(2, 5, KEY_KP9), | |
74 | KEY(3, 6, KEY_KP0), | |
75 | KEY(3, 7, KEY_KPASTERISK), | |
76 | KEY(3, 5, KEY_KPDOT), /* # key */ | |
77 | KEY(7, 2, KEY_NUMLOCK), /* Mute */ | |
78 | KEY(7, 1, KEY_KPMINUS), /* Recall */ | |
79 | KEY(6, 1, KEY_KPPLUS), /* Redial */ | |
80 | KEY(7, 6, KEY_KPSLASH), /* Handsfree */ | |
81 | KEY(6, 0, KEY_ENTER), /* Video */ | |
82 | ||
83 | KEY(7, 4, KEY_CAMERA), /* Photo */ | |
84 | ||
85 | KEY(0, 4, KEY_F2), /* Home */ | |
86 | KEY(1, 4, KEY_F3), /* Office */ | |
87 | KEY(2, 4, KEY_F4), /* Mobile */ | |
a524626b | 88 | KEY(7, 7, KEY_F5), /* SMS */ |
da1f026b | 89 | KEY(7, 5, KEY_F6), /* Email */ |
325d50b6 JM |
90 | |
91 | /* QWERTY portion of keypad */ | |
da1f026b | 92 | KEY(3, 4, KEY_Q), |
325d50b6 | 93 | KEY(3, 3, KEY_W), |
da1f026b JK |
94 | KEY(3, 2, KEY_E), |
95 | KEY(3, 1, KEY_R), | |
96 | KEY(3, 0, KEY_T), | |
97 | KEY(4, 7, KEY_Y), | |
98 | KEY(4, 6, KEY_U), | |
99 | KEY(4, 5, KEY_I), | |
325d50b6 | 100 | KEY(4, 4, KEY_O), |
da1f026b | 101 | KEY(4, 3, KEY_P), |
325d50b6 | 102 | |
da1f026b JK |
103 | KEY(4, 2, KEY_A), |
104 | KEY(4, 1, KEY_S), | |
105 | KEY(4, 0, KEY_D), | |
106 | KEY(5, 7, KEY_F), | |
107 | KEY(5, 6, KEY_G), | |
325d50b6 | 108 | KEY(5, 5, KEY_H), |
da1f026b JK |
109 | KEY(5, 4, KEY_J), |
110 | KEY(5, 3, KEY_K), | |
111 | KEY(5, 2, KEY_L), | |
325d50b6 | 112 | |
da1f026b JK |
113 | KEY(5, 1, KEY_Z), |
114 | KEY(5, 0, KEY_X), | |
115 | KEY(6, 7, KEY_C), | |
325d50b6 | 116 | KEY(6, 6, KEY_V), |
da1f026b JK |
117 | KEY(6, 5, KEY_B), |
118 | KEY(6, 4, KEY_N), | |
119 | KEY(6, 3, KEY_M), | |
120 | KEY(6, 2, KEY_SPACE), | |
325d50b6 | 121 | |
da1f026b JK |
122 | KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */ |
123 | KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ | |
325d50b6 JM |
124 | }; |
125 | ||
937eb4bb JK |
126 | #define LATCH1_PHYS 0x01000000 |
127 | #define LATCH1_VIRT 0xEA000000 | |
128 | #define MODEM_PHYS 0x04000000 | |
129 | #define MODEM_VIRT 0xEB000000 | |
130 | #define LATCH2_PHYS 0x08000000 | |
131 | #define LATCH2_VIRT 0xEC000000 | |
9b6553cd | 132 | |
9b6553cd | 133 | static struct map_desc ams_delta_io_desc[] __initdata = { |
6e2d4107 | 134 | /* AMS_DELTA_LATCH1 */ |
9b6553cd | 135 | { |
937eb4bb JK |
136 | .virtual = LATCH1_VIRT, |
137 | .pfn = __phys_to_pfn(LATCH1_PHYS), | |
9b6553cd TL |
138 | .length = 0x01000000, |
139 | .type = MT_DEVICE | |
140 | }, | |
6e2d4107 | 141 | /* AMS_DELTA_LATCH2 */ |
9b6553cd | 142 | { |
937eb4bb JK |
143 | .virtual = LATCH2_VIRT, |
144 | .pfn = __phys_to_pfn(LATCH2_PHYS), | |
9b6553cd TL |
145 | .length = 0x01000000, |
146 | .type = MT_DEVICE | |
147 | }, | |
6e2d4107 | 148 | /* AMS_DELTA_MODEM */ |
9b6553cd | 149 | { |
937eb4bb JK |
150 | .virtual = MODEM_VIRT, |
151 | .pfn = __phys_to_pfn(MODEM_PHYS), | |
9b6553cd TL |
152 | .length = 0x01000000, |
153 | .type = MT_DEVICE | |
154 | } | |
155 | }; | |
156 | ||
da564a05 | 157 | static struct omap_lcd_config ams_delta_lcd_config __initdata = { |
a524626b TL |
158 | .ctrl_name = "internal", |
159 | }; | |
160 | ||
dc0caefd | 161 | static struct omap_usb_config ams_delta_usb_config = { |
07116152 JM |
162 | .register_host = 1, |
163 | .hmc_mode = 16, | |
164 | .pins[0] = 2, | |
165 | }; | |
166 | ||
a7e2a89a | 167 | static struct omap_board_config_kernel ams_delta_config[] __initdata = { |
a524626b | 168 | { OMAP_TAG_LCD, &ams_delta_lcd_config }, |
9b6553cd TL |
169 | }; |
170 | ||
5ca6180f JK |
171 | #define LATCH1_GPIO_BASE 232 |
172 | #define LATCH1_NGPIO 8 | |
173 | ||
da564a05 | 174 | static struct resource latch1_resources[] = { |
937eb4bb JK |
175 | [0] = { |
176 | .name = "dat", | |
177 | .start = LATCH1_PHYS, | |
5ca6180f | 178 | .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8, |
937eb4bb JK |
179 | .flags = IORESOURCE_MEM, |
180 | }, | |
181 | }; | |
182 | ||
da564a05 | 183 | static struct bgpio_pdata latch1_pdata = { |
5ca6180f JK |
184 | .base = LATCH1_GPIO_BASE, |
185 | .ngpio = LATCH1_NGPIO, | |
937eb4bb JK |
186 | }; |
187 | ||
188 | static struct platform_device latch1_gpio_device = { | |
189 | .name = "basic-mmio-gpio", | |
190 | .id = 0, | |
191 | .resource = latch1_resources, | |
192 | .num_resources = ARRAY_SIZE(latch1_resources), | |
193 | .dev = { | |
194 | .platform_data = &latch1_pdata, | |
195 | }, | |
196 | }; | |
197 | ||
da564a05 | 198 | static struct resource latch2_resources[] = { |
937eb4bb JK |
199 | [0] = { |
200 | .name = "dat", | |
201 | .start = LATCH2_PHYS, | |
202 | .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8, | |
203 | .flags = IORESOURCE_MEM, | |
204 | }, | |
205 | }; | |
206 | ||
da564a05 | 207 | static struct bgpio_pdata latch2_pdata = { |
937eb4bb JK |
208 | .base = AMS_DELTA_LATCH2_GPIO_BASE, |
209 | .ngpio = AMS_DELTA_LATCH2_NGPIO, | |
210 | }; | |
211 | ||
212 | static struct platform_device latch2_gpio_device = { | |
213 | .name = "basic-mmio-gpio", | |
214 | .id = 1, | |
215 | .resource = latch2_resources, | |
216 | .num_resources = ARRAY_SIZE(latch2_resources), | |
217 | .dev = { | |
218 | .platform_data = &latch2_pdata, | |
219 | }, | |
220 | }; | |
221 | ||
da564a05 | 222 | static const struct gpio latch_gpios[] __initconst = { |
937eb4bb | 223 | { |
5ca6180f | 224 | .gpio = LATCH1_GPIO_BASE + 6, |
937eb4bb JK |
225 | .flags = GPIOF_OUT_INIT_LOW, |
226 | .label = "dockit1", | |
227 | }, | |
228 | { | |
5ca6180f | 229 | .gpio = LATCH1_GPIO_BASE + 7, |
937eb4bb JK |
230 | .flags = GPIOF_OUT_INIT_LOW, |
231 | .label = "dockit2", | |
232 | }, | |
937eb4bb JK |
233 | { |
234 | .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN, | |
235 | .flags = GPIOF_OUT_INIT_LOW, | |
236 | .label = "scard_rstin", | |
237 | }, | |
238 | { | |
239 | .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC, | |
240 | .flags = GPIOF_OUT_INIT_LOW, | |
241 | .label = "scard_cmdvcc", | |
242 | }, | |
937eb4bb JK |
243 | { |
244 | .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC, | |
245 | .flags = GPIOF_OUT_INIT_LOW, | |
246 | .label = "modem_codec", | |
247 | }, | |
248 | { | |
249 | .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14, | |
250 | .flags = GPIOF_OUT_INIT_LOW, | |
251 | .label = "hookflash1", | |
252 | }, | |
253 | { | |
254 | .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15, | |
255 | .flags = GPIOF_OUT_INIT_LOW, | |
256 | .label = "hookflash2", | |
257 | }, | |
258 | }; | |
259 | ||
ac2885df JK |
260 | static struct regulator_consumer_supply modem_nreset_consumers[] = { |
261 | REGULATOR_SUPPLY("RESET#", "serial8250.1"), | |
262 | REGULATOR_SUPPLY("POR", "cx20442-codec"), | |
263 | }; | |
264 | ||
265 | static struct regulator_init_data modem_nreset_data = { | |
266 | .constraints = { | |
267 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, | |
268 | .boot_on = 1, | |
269 | }, | |
270 | .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers), | |
271 | .consumer_supplies = modem_nreset_consumers, | |
272 | }; | |
273 | ||
274 | static struct fixed_voltage_config modem_nreset_config = { | |
275 | .supply_name = "modem_nreset", | |
276 | .microvolts = 3300000, | |
277 | .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET, | |
278 | .startup_delay = 25000, | |
279 | .enable_high = 1, | |
280 | .enabled_at_boot = 1, | |
281 | .init_data = &modem_nreset_data, | |
282 | }; | |
283 | ||
284 | static struct platform_device modem_nreset_device = { | |
285 | .name = "reg-fixed-voltage", | |
286 | .id = -1, | |
287 | .dev = { | |
288 | .platform_data = &modem_nreset_config, | |
289 | }, | |
290 | }; | |
291 | ||
292 | struct modem_private_data { | |
293 | struct regulator *regulator; | |
294 | struct { | |
295 | struct mutex lock; | |
296 | bool enabled; | |
297 | } consumer; | |
298 | }; | |
299 | ||
300 | static int regulator_toggle(struct modem_private_data *priv, bool enable) | |
301 | { | |
302 | int err = 0; | |
303 | ||
304 | mutex_lock(&priv->consumer.lock); | |
305 | if (IS_ERR(priv->regulator)) { | |
306 | err = PTR_ERR(priv->regulator); | |
307 | } else if (enable) { | |
308 | if (!priv->consumer.enabled) { | |
309 | err = regulator_enable(priv->regulator); | |
310 | priv->consumer.enabled = true; | |
311 | } | |
312 | } else { | |
313 | if (priv->consumer.enabled) { | |
314 | err = regulator_disable(priv->regulator); | |
315 | priv->consumer.enabled = false; | |
316 | } | |
317 | } | |
318 | mutex_unlock(&priv->consumer.lock); | |
319 | ||
320 | return err; | |
321 | } | |
322 | ||
323 | static struct modem_private_data modem_priv; | |
324 | ||
937eb4bb JK |
325 | void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) |
326 | { | |
327 | int bit = 0; | |
328 | u16 bitpos = 1 << bit; | |
329 | ||
330 | for (; bit < ngpio; bit++, bitpos = bitpos << 1) { | |
331 | if (!(mask & bitpos)) | |
332 | continue; | |
ac2885df JK |
333 | else if (base + bit == AMS_DELTA_GPIO_PIN_MODEM_NRESET) |
334 | regulator_toggle(&modem_priv, (value & bitpos) != 0); | |
335 | else | |
336 | gpio_set_value(base + bit, (value & bitpos) != 0); | |
937eb4bb JK |
337 | } |
338 | } | |
339 | EXPORT_SYMBOL(ams_delta_latch_write); | |
340 | ||
eaca491f JK |
341 | static struct resource ams_delta_nand_resources[] = { |
342 | [0] = { | |
343 | .start = OMAP1_MPUIO_BASE, | |
344 | .end = OMAP1_MPUIO_BASE + | |
345 | OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1, | |
346 | .flags = IORESOURCE_MEM, | |
347 | }, | |
348 | }; | |
349 | ||
7e95d1f1 JK |
350 | static struct platform_device ams_delta_nand_device = { |
351 | .name = "ams-delta-nand", | |
eaca491f JK |
352 | .id = -1, |
353 | .num_resources = ARRAY_SIZE(ams_delta_nand_resources), | |
354 | .resource = ams_delta_nand_resources, | |
7e95d1f1 JK |
355 | }; |
356 | ||
325d50b6 JM |
357 | static struct resource ams_delta_kp_resources[] = { |
358 | [0] = { | |
359 | .start = INT_KEYBOARD, | |
360 | .end = INT_KEYBOARD, | |
361 | .flags = IORESOURCE_IRQ, | |
362 | }, | |
363 | }; | |
364 | ||
da1f026b JK |
365 | static const struct matrix_keymap_data ams_delta_keymap_data = { |
366 | .keymap = ams_delta_keymap, | |
367 | .keymap_size = ARRAY_SIZE(ams_delta_keymap), | |
368 | }; | |
369 | ||
dc0caefd | 370 | static struct omap_kp_platform_data ams_delta_kp_data = { |
325d50b6 JM |
371 | .rows = 8, |
372 | .cols = 8, | |
da1f026b | 373 | .keymap_data = &ams_delta_keymap_data, |
325d50b6 JM |
374 | .delay = 9, |
375 | }; | |
376 | ||
07ad6ab3 | 377 | static struct platform_device ams_delta_kp_device = { |
325d50b6 JM |
378 | .name = "omap-keypad", |
379 | .id = -1, | |
380 | .dev = { | |
381 | .platform_data = &ams_delta_kp_data, | |
382 | }, | |
383 | .num_resources = ARRAY_SIZE(ams_delta_kp_resources), | |
384 | .resource = ams_delta_kp_resources, | |
385 | }; | |
386 | ||
07ad6ab3 | 387 | static struct platform_device ams_delta_lcd_device = { |
a524626b TL |
388 | .name = "lcd_ams_delta", |
389 | .id = -1, | |
390 | }; | |
391 | ||
da564a05 | 392 | static const struct gpio_led gpio_leds[] __initconst = { |
5ca6180f JK |
393 | { |
394 | .name = "camera", | |
395 | .gpio = LATCH1_GPIO_BASE + 0, | |
396 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
397 | #ifdef CONFIG_LEDS_TRIGGERS | |
398 | .default_trigger = "ams_delta_camera", | |
399 | #endif | |
400 | }, | |
401 | { | |
402 | .name = "advert", | |
403 | .gpio = LATCH1_GPIO_BASE + 1, | |
404 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
405 | }, | |
406 | { | |
407 | .name = "email", | |
408 | .gpio = LATCH1_GPIO_BASE + 2, | |
409 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
410 | }, | |
411 | { | |
412 | .name = "handsfree", | |
413 | .gpio = LATCH1_GPIO_BASE + 3, | |
414 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
415 | }, | |
416 | { | |
417 | .name = "voicemail", | |
418 | .gpio = LATCH1_GPIO_BASE + 4, | |
419 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
420 | }, | |
421 | { | |
422 | .name = "voice", | |
423 | .gpio = LATCH1_GPIO_BASE + 5, | |
424 | .default_state = LEDS_GPIO_DEFSTATE_OFF, | |
425 | }, | |
426 | }; | |
427 | ||
da564a05 | 428 | static const struct gpio_led_platform_data leds_pdata __initconst = { |
5ca6180f JK |
429 | .leds = gpio_leds, |
430 | .num_leds = ARRAY_SIZE(gpio_leds), | |
9becde79 JM |
431 | }; |
432 | ||
8452e9ef JK |
433 | static struct i2c_board_info ams_delta_camera_board_info[] = { |
434 | { | |
435 | I2C_BOARD_INFO("ov6650", 0x60), | |
436 | }, | |
437 | }; | |
438 | ||
243e76b4 JK |
439 | #ifdef CONFIG_LEDS_TRIGGERS |
440 | DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger); | |
441 | ||
442 | static int ams_delta_camera_power(struct device *dev, int power) | |
443 | { | |
444 | /* | |
445 | * turn on camera LED | |
446 | */ | |
447 | if (power) | |
448 | led_trigger_event(ams_delta_camera_led_trigger, LED_FULL); | |
449 | else | |
450 | led_trigger_event(ams_delta_camera_led_trigger, LED_OFF); | |
451 | return 0; | |
452 | } | |
453 | #else | |
454 | #define ams_delta_camera_power NULL | |
455 | #endif | |
456 | ||
a7e2a89a | 457 | static struct soc_camera_link ams_delta_iclink = { |
8452e9ef JK |
458 | .bus_id = 0, /* OMAP1 SoC camera bus */ |
459 | .i2c_adapter_id = 1, | |
460 | .board_info = &ams_delta_camera_board_info[0], | |
461 | .module_name = "ov6650", | |
243e76b4 | 462 | .power = ams_delta_camera_power, |
8452e9ef JK |
463 | }; |
464 | ||
07ad6ab3 | 465 | static struct platform_device ams_delta_camera_device = { |
8452e9ef JK |
466 | .name = "soc-camera-pdrv", |
467 | .id = 0, | |
468 | .dev = { | |
469 | .platform_data = &ams_delta_iclink, | |
470 | }, | |
471 | }; | |
472 | ||
473 | static struct omap1_cam_platform_data ams_delta_camera_platform_data = { | |
474 | .camexclk_khz = 12000, /* default 12MHz clock, no extra DPLL */ | |
475 | .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */ | |
476 | }; | |
477 | ||
9becde79 | 478 | static struct platform_device *ams_delta_devices[] __initdata = { |
937eb4bb JK |
479 | &latch1_gpio_device, |
480 | &latch2_gpio_device, | |
325d50b6 | 481 | &ams_delta_kp_device, |
8452e9ef | 482 | &ams_delta_camera_device, |
9becde79 JM |
483 | }; |
484 | ||
da564a05 | 485 | static struct platform_device *late_devices[] __initdata = { |
f7519d8c | 486 | &ams_delta_nand_device, |
a524626b | 487 | &ams_delta_lcd_device, |
9becde79 JM |
488 | }; |
489 | ||
9b6553cd TL |
490 | static void __init ams_delta_init(void) |
491 | { | |
c33da3a8 JK |
492 | /* mux pins for uarts */ |
493 | omap_cfg_reg(UART1_TX); | |
494 | omap_cfg_reg(UART1_RTS); | |
495 | ||
8452e9ef JK |
496 | /* parallel camera interface */ |
497 | omap_cfg_reg(H19_1610_CAM_EXCLK); | |
498 | omap_cfg_reg(J15_1610_CAM_LCLK); | |
499 | omap_cfg_reg(L18_1610_CAM_VS); | |
500 | omap_cfg_reg(L15_1610_CAM_HS); | |
501 | omap_cfg_reg(L19_1610_CAM_D0); | |
502 | omap_cfg_reg(K14_1610_CAM_D1); | |
503 | omap_cfg_reg(K15_1610_CAM_D2); | |
504 | omap_cfg_reg(K19_1610_CAM_D3); | |
505 | omap_cfg_reg(K18_1610_CAM_D4); | |
506 | omap_cfg_reg(J14_1610_CAM_D5); | |
507 | omap_cfg_reg(J19_1610_CAM_D6); | |
508 | omap_cfg_reg(J18_1610_CAM_D7); | |
509 | ||
9b6553cd TL |
510 | omap_board_config = ams_delta_config; |
511 | omap_board_config_size = ARRAY_SIZE(ams_delta_config); | |
512 | omap_serial_init(); | |
1ed16a86 | 513 | omap_register_i2c_bus(1, 100, NULL, 0); |
9b6553cd | 514 | |
dd0cdd88 | 515 | omap1_usb_init(&ams_delta_usb_config); |
8452e9ef | 516 | omap1_set_camera_info(&ams_delta_camera_platform_data); |
243e76b4 JK |
517 | #ifdef CONFIG_LEDS_TRIGGERS |
518 | led_trigger_register_simple("ams_delta_camera", | |
519 | &ams_delta_camera_led_trigger); | |
520 | #endif | |
5ca6180f | 521 | gpio_led_register_device(-1, &leds_pdata); |
9becde79 | 522 | platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); |
b3dba0b8 | 523 | |
e6f740f5 | 524 | ams_delta_init_fiq(); |
e6f740f5 | 525 | |
b3dba0b8 | 526 | omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); |
9b6553cd TL |
527 | } |
528 | ||
aabf3173 JK |
529 | static void modem_pm(struct uart_port *port, unsigned int state, unsigned old) |
530 | { | |
531 | struct modem_private_data *priv = port->private_data; | |
532 | ||
533 | if (state == old) | |
534 | return; | |
535 | ||
536 | regulator_toggle(priv, state == 0); | |
537 | } | |
538 | ||
eff443df JK |
539 | static struct plat_serial8250_port ams_delta_modem_ports[] = { |
540 | { | |
937eb4bb JK |
541 | .membase = IOMEM(MODEM_VIRT), |
542 | .mapbase = MODEM_PHYS, | |
eff443df JK |
543 | .irq = -EINVAL, /* changed later */ |
544 | .flags = UPF_BOOT_AUTOCONF, | |
545 | .irqflags = IRQF_TRIGGER_RISING, | |
546 | .iotype = UPIO_MEM, | |
547 | .regshift = 1, | |
548 | .uartclk = BASE_BAUD * 16, | |
aabf3173 JK |
549 | .pm = modem_pm, |
550 | .private_data = &modem_priv, | |
eff443df JK |
551 | }, |
552 | { }, | |
553 | }; | |
554 | ||
555 | static struct platform_device ams_delta_modem_device = { | |
556 | .name = "serial8250", | |
557 | .id = PLAT8250_DEV_PLATFORM1, | |
558 | .dev = { | |
559 | .platform_data = ams_delta_modem_ports, | |
560 | }, | |
561 | }; | |
562 | ||
f7519d8c | 563 | static int __init late_init(void) |
eff443df | 564 | { |
4cb2dc67 JK |
565 | int err; |
566 | ||
7f9187c2 TL |
567 | if (!machine_is_ams_delta()) |
568 | return -ENODEV; | |
569 | ||
937eb4bb JK |
570 | err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios)); |
571 | if (err) { | |
572 | pr_err("Couldn't take over latch1/latch2 GPIO pins\n"); | |
573 | return err; | |
574 | } | |
f7519d8c JK |
575 | |
576 | platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); | |
577 | ||
ac2885df JK |
578 | err = platform_device_register(&modem_nreset_device); |
579 | if (err) { | |
580 | pr_err("Couldn't register the modem regulator device\n"); | |
581 | return err; | |
582 | } | |
583 | ||
eff443df | 584 | omap_cfg_reg(M14_1510_GPIO2); |
4cb2dc67 JK |
585 | ams_delta_modem_ports[0].irq = |
586 | gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | |
587 | ||
588 | err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); | |
589 | if (err) { | |
590 | pr_err("Couldn't request gpio pin for modem\n"); | |
591 | return err; | |
592 | } | |
593 | gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | |
eff443df | 594 | |
ac2885df JK |
595 | /* Initialize the modem_nreset regulator consumer before use */ |
596 | mutex_init(&modem_priv.consumer.lock); | |
597 | modem_priv.regulator = ERR_PTR(-ENODEV); | |
598 | ||
aabf3173 JK |
599 | ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, |
600 | AMS_DELTA_LATCH2_MODEM_CODEC); | |
eff443df | 601 | |
f7519d8c JK |
602 | err = platform_device_register(&ams_delta_modem_device); |
603 | if (err) | |
604 | goto gpio_free; | |
ac2885df JK |
605 | |
606 | /* | |
607 | * Once the modem device is registered, the modem_nreset | |
608 | * regulator can be requested on behalf of that device. | |
aabf3173 JK |
609 | * In addition to the modem .pm callback, that regulator |
610 | * is still used via the ams_delta_latch_write() wrapper | |
611 | * by the ASoC driver until updated. | |
ac2885df JK |
612 | */ |
613 | modem_priv.regulator = regulator_get(&ams_delta_modem_device.dev, | |
614 | "RESET#"); | |
615 | if (IS_ERR(modem_priv.regulator)) { | |
616 | err = PTR_ERR(modem_priv.regulator); | |
617 | goto unregister; | |
618 | } | |
f7519d8c JK |
619 | return 0; |
620 | ||
ac2885df JK |
621 | unregister: |
622 | platform_device_unregister(&ams_delta_modem_device); | |
f7519d8c JK |
623 | gpio_free: |
624 | gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | |
625 | return err; | |
eff443df | 626 | } |
f7519d8c | 627 | late_initcall(late_init); |
eff443df | 628 | |
5bb01a99 TL |
629 | static void __init ams_delta_map_io(void) |
630 | { | |
631 | omap15xx_map_io(); | |
632 | iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); | |
633 | } | |
634 | ||
9b6553cd TL |
635 | MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)") |
636 | /* Maintainer: Jonathan McDowell <noodles@earth.li> */ | |
246e389d | 637 | .atag_offset = 0x100, |
5bb01a99 | 638 | .map_io = ams_delta_map_io, |
7b88e62f | 639 | .init_early = omap1_init_early, |
71ee7dad | 640 | .reserve = omap_reserve, |
7b88e62f | 641 | .init_irq = omap1_init_irq, |
9b6553cd | 642 | .init_machine = ams_delta_init, |
e74984e4 | 643 | .timer = &omap1_timer, |
baa95883 | 644 | .restart = omap1_restart, |
9b6553cd | 645 | MACHINE_END |