.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/arch/arm/mach-omap1/board-ams-delta.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Board specific inits for the Amstrad E3 (codename Delta) videophone |
---|
7 | 8 | * |
---|
8 | 9 | * 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 | 10 | */ |
---|
14 | 11 | #include <linux/gpio/driver.h> |
---|
15 | 12 | #include <linux/gpio/machine.h> |
---|
| 13 | +#include <linux/gpio/consumer.h> |
---|
16 | 14 | #include <linux/gpio.h> |
---|
17 | 15 | #include <linux/kernel.h> |
---|
18 | 16 | #include <linux/init.h> |
---|
19 | 17 | #include <linux/input.h> |
---|
20 | 18 | #include <linux/interrupt.h> |
---|
21 | 19 | #include <linux/leds.h> |
---|
| 20 | +#include <linux/mtd/nand-gpio.h> |
---|
| 21 | +#include <linux/mtd/partitions.h> |
---|
22 | 22 | #include <linux/platform_device.h> |
---|
23 | 23 | #include <linux/regulator/consumer.h> |
---|
24 | 24 | #include <linux/regulator/fixed.h> |
---|
.. | .. |
---|
29 | 29 | #include <linux/io.h> |
---|
30 | 30 | #include <linux/platform_data/gpio-omap.h> |
---|
31 | 31 | |
---|
32 | | -#include <media/soc_camera.h> |
---|
33 | | - |
---|
34 | 32 | #include <asm/serial.h> |
---|
35 | 33 | #include <asm/mach-types.h> |
---|
36 | 34 | #include <asm/mach/arch.h> |
---|
37 | 35 | #include <asm/mach/map.h> |
---|
38 | 36 | |
---|
39 | | -#include <mach/board-ams-delta.h> |
---|
40 | 37 | #include <linux/platform_data/keypad-omap.h> |
---|
41 | 38 | #include <mach/mux.h> |
---|
42 | 39 | |
---|
43 | 40 | #include <mach/hardware.h> |
---|
44 | | -#include "camera.h" |
---|
45 | 41 | #include <mach/usb.h> |
---|
46 | 42 | |
---|
47 | 43 | #include "ams-delta-fiq.h" |
---|
| 44 | +#include "board-ams-delta.h" |
---|
48 | 45 | #include "iomap.h" |
---|
49 | 46 | #include "common.h" |
---|
50 | 47 | |
---|
.. | .. |
---|
167 | 164 | .pins[0] = 2, |
---|
168 | 165 | }; |
---|
169 | 166 | |
---|
170 | | -#define LATCH1_GPIO_BASE 232 |
---|
171 | 167 | #define LATCH1_NGPIO 8 |
---|
172 | 168 | |
---|
173 | 169 | static struct resource latch1_resources[] = { |
---|
.. | .. |
---|
183 | 179 | |
---|
184 | 180 | static struct bgpio_pdata latch1_pdata = { |
---|
185 | 181 | .label = LATCH1_LABEL, |
---|
186 | | - .base = LATCH1_GPIO_BASE, |
---|
| 182 | + .base = -1, |
---|
187 | 183 | .ngpio = LATCH1_NGPIO, |
---|
188 | 184 | }; |
---|
189 | 185 | |
---|
.. | .. |
---|
206 | 202 | #define LATCH1_PIN_DOCKIT1 6 |
---|
207 | 203 | #define LATCH1_PIN_DOCKIT2 7 |
---|
208 | 204 | |
---|
| 205 | +#define LATCH2_NGPIO 16 |
---|
| 206 | + |
---|
209 | 207 | static struct resource latch2_resources[] = { |
---|
210 | 208 | [0] = { |
---|
211 | 209 | .name = "dat", |
---|
212 | 210 | .start = LATCH2_PHYS, |
---|
213 | | - .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8, |
---|
| 211 | + .end = LATCH2_PHYS + (LATCH2_NGPIO - 1) / 8, |
---|
214 | 212 | .flags = IORESOURCE_MEM, |
---|
215 | 213 | }, |
---|
216 | 214 | }; |
---|
.. | .. |
---|
219 | 217 | |
---|
220 | 218 | static struct bgpio_pdata latch2_pdata = { |
---|
221 | 219 | .label = LATCH2_LABEL, |
---|
222 | | - .base = AMS_DELTA_LATCH2_GPIO_BASE, |
---|
223 | | - .ngpio = AMS_DELTA_LATCH2_NGPIO, |
---|
| 220 | + .base = -1, |
---|
| 221 | + .ngpio = LATCH2_NGPIO, |
---|
224 | 222 | }; |
---|
225 | 223 | |
---|
226 | 224 | static struct platform_device latch2_gpio_device = { |
---|
.. | .. |
---|
247 | 245 | #define LATCH2_PIN_SCARD_CMDVCC 11 |
---|
248 | 246 | #define LATCH2_PIN_MODEM_NRESET 12 |
---|
249 | 247 | #define LATCH2_PIN_MODEM_CODEC 13 |
---|
250 | | -#define LATCH2_PIN_HOOKFLASH1 14 |
---|
251 | | -#define LATCH2_PIN_HOOKFLASH2 15 |
---|
252 | | - |
---|
253 | | -static const struct gpio latch_gpios[] __initconst = { |
---|
254 | | - { |
---|
255 | | - .gpio = LATCH1_GPIO_BASE + 6, |
---|
256 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
257 | | - .label = "dockit1", |
---|
258 | | - }, |
---|
259 | | - { |
---|
260 | | - .gpio = LATCH1_GPIO_BASE + 7, |
---|
261 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
262 | | - .label = "dockit2", |
---|
263 | | - }, |
---|
264 | | - { |
---|
265 | | - .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN, |
---|
266 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
267 | | - .label = "scard_rstin", |
---|
268 | | - }, |
---|
269 | | - { |
---|
270 | | - .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC, |
---|
271 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
272 | | - .label = "scard_cmdvcc", |
---|
273 | | - }, |
---|
274 | | - { |
---|
275 | | - .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14, |
---|
276 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
277 | | - .label = "hookflash1", |
---|
278 | | - }, |
---|
279 | | - { |
---|
280 | | - .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15, |
---|
281 | | - .flags = GPIOF_OUT_INIT_LOW, |
---|
282 | | - .label = "hookflash2", |
---|
283 | | - }, |
---|
284 | | -}; |
---|
| 248 | +#define LATCH2_PIN_HANDSFREE_MUTE 14 |
---|
| 249 | +#define LATCH2_PIN_HANDSET_MUTE 15 |
---|
285 | 250 | |
---|
286 | 251 | static struct regulator_consumer_supply modem_nreset_consumers[] = { |
---|
287 | 252 | REGULATOR_SUPPLY("RESET#", "serial8250.1"), |
---|
.. | .. |
---|
300 | 265 | static struct fixed_voltage_config modem_nreset_config = { |
---|
301 | 266 | .supply_name = "modem_nreset", |
---|
302 | 267 | .microvolts = 3300000, |
---|
303 | | - .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET, |
---|
304 | 268 | .startup_delay = 25000, |
---|
305 | | - .enable_high = 1, |
---|
306 | 269 | .enabled_at_boot = 1, |
---|
307 | 270 | .init_data = &modem_nreset_data, |
---|
308 | 271 | }; |
---|
.. | .. |
---|
315 | 278 | }, |
---|
316 | 279 | }; |
---|
317 | 280 | |
---|
| 281 | +static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = { |
---|
| 282 | + .dev_id = "reg-fixed-voltage", |
---|
| 283 | + .table = { |
---|
| 284 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET, |
---|
| 285 | + NULL, GPIO_ACTIVE_HIGH), |
---|
| 286 | + { }, |
---|
| 287 | + }, |
---|
| 288 | +}; |
---|
| 289 | + |
---|
318 | 290 | struct modem_private_data { |
---|
319 | 291 | struct regulator *regulator; |
---|
320 | 292 | }; |
---|
321 | 293 | |
---|
322 | 294 | static struct modem_private_data modem_priv; |
---|
323 | 295 | |
---|
324 | | -void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) |
---|
325 | | -{ |
---|
326 | | - int bit = 0; |
---|
327 | | - u16 bitpos = 1 << bit; |
---|
| 296 | +/* |
---|
| 297 | + * Define partitions for flash device |
---|
| 298 | + */ |
---|
328 | 299 | |
---|
329 | | - for (; bit < ngpio; bit++, bitpos = bitpos << 1) { |
---|
330 | | - if (!(mask & bitpos)) |
---|
331 | | - continue; |
---|
332 | | - else |
---|
333 | | - gpio_set_value(base + bit, (value & bitpos) != 0); |
---|
334 | | - } |
---|
335 | | -} |
---|
336 | | -EXPORT_SYMBOL(ams_delta_latch_write); |
---|
| 300 | +static struct mtd_partition partition_info[] = { |
---|
| 301 | + { .name = "Kernel", |
---|
| 302 | + .offset = 0, |
---|
| 303 | + .size = 3 * SZ_1M + SZ_512K }, |
---|
| 304 | + { .name = "u-boot", |
---|
| 305 | + .offset = 3 * SZ_1M + SZ_512K, |
---|
| 306 | + .size = SZ_256K }, |
---|
| 307 | + { .name = "u-boot params", |
---|
| 308 | + .offset = 3 * SZ_1M + SZ_512K + SZ_256K, |
---|
| 309 | + .size = SZ_256K }, |
---|
| 310 | + { .name = "Amstrad LDR", |
---|
| 311 | + .offset = 4 * SZ_1M, |
---|
| 312 | + .size = SZ_256K }, |
---|
| 313 | + { .name = "File system", |
---|
| 314 | + .offset = 4 * SZ_1M + 1 * SZ_256K, |
---|
| 315 | + .size = 27 * SZ_1M }, |
---|
| 316 | + { .name = "PBL reserved", |
---|
| 317 | + .offset = 32 * SZ_1M - 3 * SZ_256K, |
---|
| 318 | + .size = 3 * SZ_256K }, |
---|
| 319 | +}; |
---|
337 | 320 | |
---|
338 | | -static struct resource ams_delta_nand_resources[] = { |
---|
339 | | - [0] = { |
---|
340 | | - .start = OMAP1_MPUIO_BASE, |
---|
341 | | - .end = OMAP1_MPUIO_BASE + |
---|
342 | | - OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1, |
---|
343 | | - .flags = IORESOURCE_MEM, |
---|
344 | | - }, |
---|
| 321 | +static struct gpio_nand_platdata nand_platdata = { |
---|
| 322 | + .parts = partition_info, |
---|
| 323 | + .num_parts = ARRAY_SIZE(partition_info), |
---|
345 | 324 | }; |
---|
346 | 325 | |
---|
347 | 326 | static struct platform_device ams_delta_nand_device = { |
---|
348 | 327 | .name = "ams-delta-nand", |
---|
349 | 328 | .id = -1, |
---|
350 | | - .num_resources = ARRAY_SIZE(ams_delta_nand_resources), |
---|
351 | | - .resource = ams_delta_nand_resources, |
---|
| 329 | + .dev = { |
---|
| 330 | + .platform_data = &nand_platdata, |
---|
| 331 | + }, |
---|
352 | 332 | }; |
---|
353 | 333 | |
---|
354 | | -#define OMAP_GPIO_LABEL "gpio-0-15" |
---|
| 334 | +#define OMAP_GPIO_LABEL "gpio-0-15" |
---|
| 335 | +#define OMAP_MPUIO_LABEL "mpuio" |
---|
355 | 336 | |
---|
356 | 337 | static struct gpiod_lookup_table ams_delta_nand_gpio_table = { |
---|
357 | 338 | .table = { |
---|
358 | 339 | GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy", |
---|
359 | 340 | 0), |
---|
360 | | - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", 0), |
---|
361 | | - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", 0), |
---|
362 | | - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", 0), |
---|
363 | | - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0), |
---|
| 341 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", |
---|
| 342 | + GPIO_ACTIVE_LOW), |
---|
| 343 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", |
---|
| 344 | + GPIO_ACTIVE_LOW), |
---|
| 345 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", |
---|
| 346 | + GPIO_ACTIVE_LOW), |
---|
| 347 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", |
---|
| 348 | + GPIO_ACTIVE_LOW), |
---|
364 | 349 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0), |
---|
365 | 350 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0), |
---|
| 351 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 0, "data", 0, 0), |
---|
| 352 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 1, "data", 1, 0), |
---|
| 353 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 2, "data", 2, 0), |
---|
| 354 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 3, "data", 3, 0), |
---|
| 355 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 4, "data", 4, 0), |
---|
| 356 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 5, "data", 5, 0), |
---|
| 357 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 6, "data", 6, 0), |
---|
| 358 | + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 7, "data", 7, 0), |
---|
366 | 359 | { }, |
---|
367 | 360 | }, |
---|
368 | 361 | }; |
---|
.. | .. |
---|
410 | 403 | }, |
---|
411 | 404 | }; |
---|
412 | 405 | |
---|
413 | | -/* |
---|
414 | | - * Dynamically allocated GPIO numbers must be obtained fromm GPIO device |
---|
415 | | - * before they can be put in the gpio_led table. Before that happens, |
---|
416 | | - * initialize the table with invalid GPIO numbers, not 0. |
---|
417 | | - */ |
---|
418 | 406 | static struct gpio_led gpio_leds[] __initdata = { |
---|
419 | 407 | [LATCH1_PIN_LED_CAMERA] = { |
---|
420 | 408 | .name = "camera", |
---|
421 | | - .gpio = -EINVAL, |
---|
422 | 409 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
423 | 410 | #ifdef CONFIG_LEDS_TRIGGERS |
---|
424 | 411 | .default_trigger = "ams_delta_camera", |
---|
.. | .. |
---|
426 | 413 | }, |
---|
427 | 414 | [LATCH1_PIN_LED_ADVERT] = { |
---|
428 | 415 | .name = "advert", |
---|
429 | | - .gpio = -EINVAL, |
---|
430 | 416 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
431 | 417 | }, |
---|
432 | 418 | [LATCH1_PIN_LED_MAIL] = { |
---|
433 | 419 | .name = "email", |
---|
434 | | - .gpio = -EINVAL, |
---|
435 | 420 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
436 | 421 | }, |
---|
437 | 422 | [LATCH1_PIN_LED_HANDSFREE] = { |
---|
438 | 423 | .name = "handsfree", |
---|
439 | | - .gpio = -EINVAL, |
---|
440 | 424 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
441 | 425 | }, |
---|
442 | 426 | [LATCH1_PIN_LED_VOICEMAIL] = { |
---|
443 | 427 | .name = "voicemail", |
---|
444 | | - .gpio = -EINVAL, |
---|
445 | 428 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
446 | 429 | }, |
---|
447 | 430 | [LATCH1_PIN_LED_VOICE] = { |
---|
448 | 431 | .name = "voice", |
---|
449 | | - .gpio = -EINVAL, |
---|
450 | 432 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
---|
451 | 433 | }, |
---|
452 | 434 | }; |
---|
.. | .. |
---|
456 | 438 | .num_leds = ARRAY_SIZE(gpio_leds), |
---|
457 | 439 | }; |
---|
458 | 440 | |
---|
459 | | -static struct i2c_board_info ams_delta_camera_board_info[] = { |
---|
460 | | - { |
---|
461 | | - I2C_BOARD_INFO("ov6650", 0x60), |
---|
| 441 | +static struct gpiod_lookup_table leds_gpio_table = { |
---|
| 442 | + .table = { |
---|
| 443 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL, |
---|
| 444 | + LATCH1_PIN_LED_CAMERA, 0), |
---|
| 445 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL, |
---|
| 446 | + LATCH1_PIN_LED_ADVERT, 0), |
---|
| 447 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL, |
---|
| 448 | + LATCH1_PIN_LED_MAIL, 0), |
---|
| 449 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL, |
---|
| 450 | + LATCH1_PIN_LED_HANDSFREE, 0), |
---|
| 451 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL, |
---|
| 452 | + LATCH1_PIN_LED_VOICEMAIL, 0), |
---|
| 453 | + GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL, |
---|
| 454 | + LATCH1_PIN_LED_VOICE, 0), |
---|
| 455 | + { }, |
---|
462 | 456 | }, |
---|
463 | 457 | }; |
---|
464 | 458 | |
---|
465 | 459 | #ifdef CONFIG_LEDS_TRIGGERS |
---|
466 | 460 | DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger); |
---|
467 | | - |
---|
468 | | -static int ams_delta_camera_power(struct device *dev, int power) |
---|
469 | | -{ |
---|
470 | | - /* |
---|
471 | | - * turn on camera LED |
---|
472 | | - */ |
---|
473 | | - if (power) |
---|
474 | | - led_trigger_event(ams_delta_camera_led_trigger, LED_FULL); |
---|
475 | | - else |
---|
476 | | - led_trigger_event(ams_delta_camera_led_trigger, LED_OFF); |
---|
477 | | - return 0; |
---|
478 | | -} |
---|
479 | | -#else |
---|
480 | | -#define ams_delta_camera_power NULL |
---|
481 | 461 | #endif |
---|
482 | | - |
---|
483 | | -static struct soc_camera_link ams_delta_iclink = { |
---|
484 | | - .bus_id = 0, /* OMAP1 SoC camera bus */ |
---|
485 | | - .i2c_adapter_id = 1, |
---|
486 | | - .board_info = &ams_delta_camera_board_info[0], |
---|
487 | | - .module_name = "ov6650", |
---|
488 | | - .power = ams_delta_camera_power, |
---|
489 | | -}; |
---|
490 | | - |
---|
491 | | -static struct platform_device ams_delta_camera_device = { |
---|
492 | | - .name = "soc-camera-pdrv", |
---|
493 | | - .id = 0, |
---|
494 | | - .dev = { |
---|
495 | | - .platform_data = &ams_delta_iclink, |
---|
496 | | - }, |
---|
497 | | -}; |
---|
498 | | - |
---|
499 | | -static struct omap1_cam_platform_data ams_delta_camera_platform_data = { |
---|
500 | | - .camexclk_khz = 12000, /* default 12MHz clock, no extra DPLL */ |
---|
501 | | - .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */ |
---|
502 | | -}; |
---|
503 | 462 | |
---|
504 | 463 | static struct platform_device ams_delta_audio_device = { |
---|
505 | 464 | .name = "ams-delta-audio", |
---|
.. | .. |
---|
512 | 471 | "hook_switch", 0), |
---|
513 | 472 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC, |
---|
514 | 473 | "modem_codec", 0), |
---|
| 474 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSFREE_MUTE, |
---|
| 475 | + "handsfree_mute", 0), |
---|
| 476 | + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSET_MUTE, |
---|
| 477 | + "handset_mute", 0), |
---|
515 | 478 | { }, |
---|
516 | 479 | }, |
---|
517 | 480 | }; |
---|
.. | .. |
---|
568 | 531 | static struct fixed_voltage_config keybrd_pwr_config = { |
---|
569 | 532 | .supply_name = "keybrd_pwr", |
---|
570 | 533 | .microvolts = 5000000, |
---|
571 | | - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, |
---|
572 | | - .enable_high = 1, |
---|
573 | 534 | .init_data = &keybrd_pwr_initdata, |
---|
574 | 535 | }; |
---|
575 | 536 | |
---|
.. | .. |
---|
593 | 554 | &latch1_gpio_device, |
---|
594 | 555 | &latch2_gpio_device, |
---|
595 | 556 | &ams_delta_kp_device, |
---|
596 | | - &ams_delta_camera_device, |
---|
597 | 557 | &ams_delta_audio_device, |
---|
598 | 558 | &ams_delta_serio_device, |
---|
599 | 559 | &ams_delta_nand_device, |
---|
.. | .. |
---|
602 | 562 | }; |
---|
603 | 563 | |
---|
604 | 564 | static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { |
---|
| 565 | + &ams_delta_nreset_gpiod_table, |
---|
605 | 566 | &ams_delta_audio_gpio_table, |
---|
606 | 567 | &keybrd_pwr_gpio_table, |
---|
607 | 568 | &ams_delta_lcd_gpio_table, |
---|
.. | .. |
---|
630 | 591 | {}, |
---|
631 | 592 | }; |
---|
632 | 593 | |
---|
| 594 | +static struct plat_serial8250_port ams_delta_modem_ports[]; |
---|
| 595 | + |
---|
| 596 | +/* |
---|
| 597 | + * Obtain MODEM IRQ GPIO descriptor using its hardware pin |
---|
| 598 | + * number and assign related IRQ number to the MODEM port. |
---|
| 599 | + * Keep the GPIO descriptor open so nobody steps in. |
---|
| 600 | + */ |
---|
| 601 | +static void __init modem_assign_irq(struct gpio_chip *chip) |
---|
| 602 | +{ |
---|
| 603 | + struct gpio_desc *gpiod; |
---|
| 604 | + |
---|
| 605 | + gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, |
---|
| 606 | + "modem_irq", GPIO_ACTIVE_HIGH, |
---|
| 607 | + GPIOD_IN); |
---|
| 608 | + if (IS_ERR(gpiod)) { |
---|
| 609 | + pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, |
---|
| 610 | + PTR_ERR(gpiod)); |
---|
| 611 | + } else { |
---|
| 612 | + ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); |
---|
| 613 | + } |
---|
| 614 | +} |
---|
| 615 | + |
---|
633 | 616 | /* |
---|
634 | 617 | * The purpose of this function is to take care of proper initialization of |
---|
635 | 618 | * devices and data structures which depend on GPIO lines provided by OMAP GPIO |
---|
.. | .. |
---|
649 | 632 | return; |
---|
650 | 633 | } |
---|
651 | 634 | |
---|
| 635 | + /* |
---|
| 636 | + * Start with FIQ initialization as it may have to request |
---|
| 637 | + * and release successfully each OMAP GPIO pin in turn. |
---|
| 638 | + */ |
---|
652 | 639 | ams_delta_init_fiq(chip, &ams_delta_serio_device); |
---|
| 640 | + |
---|
| 641 | + modem_assign_irq(chip); |
---|
| 642 | +} |
---|
| 643 | + |
---|
| 644 | +/* |
---|
| 645 | + * Initialize latch2 pins with values which are safe for dependent on-board |
---|
| 646 | + * devices or useful for their successull initialization even before GPIO |
---|
| 647 | + * driver takes control over the latch pins: |
---|
| 648 | + * - LATCH2_PIN_LCD_VBLEN = 0 |
---|
| 649 | + * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its |
---|
| 650 | + * driver takes control over it. |
---|
| 651 | + * - LATCH2_PIN_NAND_NCE = 0 |
---|
| 652 | + * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- |
---|
| 653 | + * protected before its driver takes |
---|
| 654 | + * control over it. |
---|
| 655 | + * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio |
---|
| 656 | + * driver takes control over it. |
---|
| 657 | + * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first |
---|
| 658 | + * byte of data received from attached |
---|
| 659 | + * keyboard when serio device is probed; |
---|
| 660 | + * the pin is also hogged low by the latch2 |
---|
| 661 | + * GPIO driver as soon as it is ready. |
---|
| 662 | + * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for |
---|
| 663 | + * its successful probe even before a |
---|
| 664 | + * regulator it depends on, which in turn |
---|
| 665 | + * takes control over the pin, is set up. |
---|
| 666 | + * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port |
---|
| 667 | + * to the MODEM so the CODEC is under |
---|
| 668 | + * control even if audio driver doesn't |
---|
| 669 | + * take it over. |
---|
| 670 | + */ |
---|
| 671 | +static void __init ams_delta_latch2_init(void) |
---|
| 672 | +{ |
---|
| 673 | + u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; |
---|
| 674 | + |
---|
| 675 | + __raw_writew(latch2, LATCH2_VIRT); |
---|
653 | 676 | } |
---|
654 | 677 | |
---|
655 | 678 | static void __init ams_delta_init(void) |
---|
656 | 679 | { |
---|
| 680 | + struct platform_device *leds_pdev; |
---|
| 681 | + |
---|
657 | 682 | /* mux pins for uarts */ |
---|
658 | 683 | omap_cfg_reg(UART1_TX); |
---|
659 | 684 | omap_cfg_reg(UART1_RTS); |
---|
.. | .. |
---|
673 | 698 | omap_cfg_reg(J18_1610_CAM_D7); |
---|
674 | 699 | |
---|
675 | 700 | omap_gpio_deps_init(); |
---|
| 701 | + ams_delta_latch2_init(); |
---|
676 | 702 | gpiod_add_hogs(ams_delta_gpio_hogs); |
---|
677 | 703 | |
---|
678 | 704 | omap_serial_init(); |
---|
679 | 705 | omap_register_i2c_bus(1, 100, NULL, 0); |
---|
680 | 706 | |
---|
681 | 707 | omap1_usb_init(&ams_delta_usb_config); |
---|
682 | | - omap1_set_camera_info(&ams_delta_camera_platform_data); |
---|
683 | 708 | #ifdef CONFIG_LEDS_TRIGGERS |
---|
684 | 709 | led_trigger_register_simple("ams_delta_camera", |
---|
685 | 710 | &ams_delta_camera_led_trigger); |
---|
.. | .. |
---|
715 | 740 | */ |
---|
716 | 741 | gpiod_add_lookup_tables(ams_delta_gpio_tables, |
---|
717 | 742 | ARRAY_SIZE(ams_delta_gpio_tables)); |
---|
| 743 | + |
---|
| 744 | + leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, &leds_pdata); |
---|
| 745 | + if (!IS_ERR_OR_NULL(leds_pdev)) { |
---|
| 746 | + leds_gpio_table.dev_id = dev_name(&leds_pdev->dev); |
---|
| 747 | + gpiod_add_lookup_table(&leds_gpio_table); |
---|
| 748 | + } |
---|
718 | 749 | |
---|
719 | 750 | omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); |
---|
720 | 751 | |
---|
.. | .. |
---|
752 | 783 | { |
---|
753 | 784 | .membase = IOMEM(MODEM_VIRT), |
---|
754 | 785 | .mapbase = MODEM_PHYS, |
---|
755 | | - .irq = -EINVAL, /* changed later */ |
---|
| 786 | + .irq = IRQ_NOTCONNECTED, /* changed later */ |
---|
756 | 787 | .flags = UPF_BOOT_AUTOCONF, |
---|
757 | 788 | .irqflags = IRQF_TRIGGER_RISING, |
---|
758 | 789 | .iotype = UPIO_MEM, |
---|
.. | .. |
---|
772 | 803 | }, |
---|
773 | 804 | }; |
---|
774 | 805 | |
---|
775 | | -/* |
---|
776 | | - * leds-gpio driver doesn't make use of GPIO lookup tables, |
---|
777 | | - * it has to be provided with GPIO numbers over platform data |
---|
778 | | - * if GPIO descriptor info can't be obtained from device tree. |
---|
779 | | - * We could either define GPIO lookup tables and use them on behalf |
---|
780 | | - * of the leds-gpio device, or we can use GPIO driver level methods |
---|
781 | | - * for identification of GPIO numbers as long as we don't support |
---|
782 | | - * device tree. Let's do the latter. |
---|
783 | | - */ |
---|
784 | | -static void __init ams_delta_led_init(struct gpio_chip *chip) |
---|
785 | | -{ |
---|
786 | | - struct gpio_desc *gpiod; |
---|
787 | | - int i; |
---|
788 | | - |
---|
789 | | - for (i = LATCH1_PIN_LED_CAMERA; i < LATCH1_PIN_DOCKIT1; i++) { |
---|
790 | | - gpiod = gpiochip_request_own_desc(chip, i, NULL); |
---|
791 | | - if (IS_ERR(gpiod)) { |
---|
792 | | - pr_warn("%s: %s GPIO %d request failed (%ld)\n", |
---|
793 | | - __func__, LATCH1_LABEL, i, PTR_ERR(gpiod)); |
---|
794 | | - continue; |
---|
795 | | - } |
---|
796 | | - |
---|
797 | | - /* Assign GPIO numbers to LED device. */ |
---|
798 | | - gpio_leds[i].gpio = desc_to_gpio(gpiod); |
---|
799 | | - |
---|
800 | | - gpiochip_free_own_desc(gpiod); |
---|
801 | | - } |
---|
802 | | - |
---|
803 | | - gpio_led_register_device(PLATFORM_DEVID_NONE, &leds_pdata); |
---|
804 | | -} |
---|
805 | | - |
---|
806 | | -/* |
---|
807 | | - * The purpose of this function is to take care of assignment of GPIO numbers |
---|
808 | | - * to platform devices which depend on GPIO lines provided by Amstrad Delta |
---|
809 | | - * latch1 and/or latch2 GPIO devices but don't use GPIO lookup tables. |
---|
810 | | - * The function may be called as soon as latch1/latch2 GPIO devices are |
---|
811 | | - * initilized. Since basic-mmio-gpio driver is not registered before |
---|
812 | | - * device_initcall, this may happen at erliest during device_initcall_sync. |
---|
813 | | - * Dependent devices shouldn't be registered before that, their |
---|
814 | | - * registration may be performed from within this function or later. |
---|
815 | | - */ |
---|
816 | | -static int __init ams_delta_gpio_init(void) |
---|
817 | | -{ |
---|
818 | | - struct gpio_chip *chip; |
---|
819 | | - int err; |
---|
820 | | - |
---|
821 | | - if (!machine_is_ams_delta()) |
---|
822 | | - return -ENODEV; |
---|
823 | | - |
---|
824 | | - chip = gpiochip_find(LATCH1_LABEL, gpiochip_match_by_label); |
---|
825 | | - if (!chip) |
---|
826 | | - pr_err("%s: latch1 GPIO chip not found\n", __func__); |
---|
827 | | - else |
---|
828 | | - ams_delta_led_init(chip); |
---|
829 | | - |
---|
830 | | - err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios)); |
---|
831 | | - if (err) |
---|
832 | | - pr_err("Couldn't take over latch1/latch2 GPIO pins\n"); |
---|
833 | | - |
---|
834 | | - return err; |
---|
835 | | -} |
---|
836 | | -device_initcall_sync(ams_delta_gpio_init); |
---|
837 | | - |
---|
838 | 806 | static int __init modem_nreset_init(void) |
---|
839 | 807 | { |
---|
840 | 808 | int err; |
---|
.. | .. |
---|
847 | 815 | } |
---|
848 | 816 | |
---|
849 | 817 | |
---|
| 818 | +/* |
---|
| 819 | + * This function expects MODEM IRQ number already assigned to the port. |
---|
| 820 | + * The MODEM device requires its RESET# pin kept high during probe. |
---|
| 821 | + * That requirement can be fulfilled in several ways: |
---|
| 822 | + * - with a descriptor of already functional modem_nreset regulator |
---|
| 823 | + * assigned to the MODEM private data, |
---|
| 824 | + * - with the regulator not yet controlled by modem_pm function but |
---|
| 825 | + * already enabled by default on probe, |
---|
| 826 | + * - before the modem_nreset regulator is probed, with the pin already |
---|
| 827 | + * set high explicitly. |
---|
| 828 | + * The last one is already guaranteed by ams_delta_latch2_init() called |
---|
| 829 | + * from machine_init. |
---|
| 830 | + * In order to avoid taking over ttyS0 device slot, the MODEM device |
---|
| 831 | + * should be registered after OMAP serial ports. Since those ports |
---|
| 832 | + * are registered at arch_initcall, this function can be called safely |
---|
| 833 | + * at arch_initcall_sync earliest. |
---|
| 834 | + */ |
---|
850 | 835 | static int __init ams_delta_modem_init(void) |
---|
851 | 836 | { |
---|
852 | 837 | int err; |
---|
853 | 838 | |
---|
854 | | - omap_cfg_reg(M14_1510_GPIO2); |
---|
855 | | - ams_delta_modem_ports[0].irq = |
---|
856 | | - gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); |
---|
| 839 | + if (!machine_is_ams_delta()) |
---|
| 840 | + return -ENODEV; |
---|
857 | 841 | |
---|
858 | | - err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); |
---|
859 | | - if (err) { |
---|
860 | | - pr_err("Couldn't request gpio pin for modem\n"); |
---|
861 | | - return err; |
---|
862 | | - } |
---|
863 | | - gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); |
---|
| 842 | + omap_cfg_reg(M14_1510_GPIO2); |
---|
864 | 843 | |
---|
865 | 844 | /* Initialize the modem_nreset regulator consumer before use */ |
---|
866 | 845 | modem_priv.regulator = ERR_PTR(-ENODEV); |
---|
867 | 846 | |
---|
868 | | - ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, |
---|
869 | | - AMS_DELTA_LATCH2_MODEM_CODEC); |
---|
870 | | - |
---|
871 | 847 | err = platform_device_register(&ams_delta_modem_device); |
---|
872 | | - if (err) |
---|
873 | | - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); |
---|
874 | 848 | |
---|
875 | 849 | return err; |
---|
876 | 850 | } |
---|
| 851 | +arch_initcall_sync(ams_delta_modem_init); |
---|
877 | 852 | |
---|
878 | 853 | static int __init late_init(void) |
---|
879 | 854 | { |
---|
880 | 855 | int err; |
---|
881 | 856 | |
---|
882 | 857 | err = modem_nreset_init(); |
---|
883 | | - if (err) |
---|
884 | | - return err; |
---|
885 | | - |
---|
886 | | - err = ams_delta_modem_init(); |
---|
887 | 858 | if (err) |
---|
888 | 859 | return err; |
---|
889 | 860 | |
---|
.. | .. |
---|
901 | 872 | |
---|
902 | 873 | unregister: |
---|
903 | 874 | platform_device_unregister(&ams_delta_modem_device); |
---|
904 | | - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); |
---|
905 | 875 | return err; |
---|
906 | 876 | } |
---|
907 | 877 | |
---|