forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/mach-omap1/board-ams-delta.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/mach-omap1/board-ams-delta.c
34 *
....@@ -6,19 +7,18 @@
67 * Board specific inits for the Amstrad E3 (codename Delta) videophone
78 *
89 * 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.
1310 */
1411 #include <linux/gpio/driver.h>
1512 #include <linux/gpio/machine.h>
13
+#include <linux/gpio/consumer.h>
1614 #include <linux/gpio.h>
1715 #include <linux/kernel.h>
1816 #include <linux/init.h>
1917 #include <linux/input.h>
2018 #include <linux/interrupt.h>
2119 #include <linux/leds.h>
20
+#include <linux/mtd/nand-gpio.h>
21
+#include <linux/mtd/partitions.h>
2222 #include <linux/platform_device.h>
2323 #include <linux/regulator/consumer.h>
2424 #include <linux/regulator/fixed.h>
....@@ -29,22 +29,19 @@
2929 #include <linux/io.h>
3030 #include <linux/platform_data/gpio-omap.h>
3131
32
-#include <media/soc_camera.h>
33
-
3432 #include <asm/serial.h>
3533 #include <asm/mach-types.h>
3634 #include <asm/mach/arch.h>
3735 #include <asm/mach/map.h>
3836
39
-#include <mach/board-ams-delta.h>
4037 #include <linux/platform_data/keypad-omap.h>
4138 #include <mach/mux.h>
4239
4340 #include <mach/hardware.h>
44
-#include "camera.h"
4541 #include <mach/usb.h>
4642
4743 #include "ams-delta-fiq.h"
44
+#include "board-ams-delta.h"
4845 #include "iomap.h"
4946 #include "common.h"
5047
....@@ -167,7 +164,6 @@
167164 .pins[0] = 2,
168165 };
169166
170
-#define LATCH1_GPIO_BASE 232
171167 #define LATCH1_NGPIO 8
172168
173169 static struct resource latch1_resources[] = {
....@@ -183,7 +179,7 @@
183179
184180 static struct bgpio_pdata latch1_pdata = {
185181 .label = LATCH1_LABEL,
186
- .base = LATCH1_GPIO_BASE,
182
+ .base = -1,
187183 .ngpio = LATCH1_NGPIO,
188184 };
189185
....@@ -206,11 +202,13 @@
206202 #define LATCH1_PIN_DOCKIT1 6
207203 #define LATCH1_PIN_DOCKIT2 7
208204
205
+#define LATCH2_NGPIO 16
206
+
209207 static struct resource latch2_resources[] = {
210208 [0] = {
211209 .name = "dat",
212210 .start = LATCH2_PHYS,
213
- .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
211
+ .end = LATCH2_PHYS + (LATCH2_NGPIO - 1) / 8,
214212 .flags = IORESOURCE_MEM,
215213 },
216214 };
....@@ -219,8 +217,8 @@
219217
220218 static struct bgpio_pdata latch2_pdata = {
221219 .label = LATCH2_LABEL,
222
- .base = AMS_DELTA_LATCH2_GPIO_BASE,
223
- .ngpio = AMS_DELTA_LATCH2_NGPIO,
220
+ .base = -1,
221
+ .ngpio = LATCH2_NGPIO,
224222 };
225223
226224 static struct platform_device latch2_gpio_device = {
....@@ -247,41 +245,8 @@
247245 #define LATCH2_PIN_SCARD_CMDVCC 11
248246 #define LATCH2_PIN_MODEM_NRESET 12
249247 #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
285250
286251 static struct regulator_consumer_supply modem_nreset_consumers[] = {
287252 REGULATOR_SUPPLY("RESET#", "serial8250.1"),
....@@ -300,9 +265,7 @@
300265 static struct fixed_voltage_config modem_nreset_config = {
301266 .supply_name = "modem_nreset",
302267 .microvolts = 3300000,
303
- .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
304268 .startup_delay = 25000,
305
- .enable_high = 1,
306269 .enabled_at_boot = 1,
307270 .init_data = &modem_nreset_data,
308271 };
....@@ -315,54 +278,84 @@
315278 },
316279 };
317280
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
+
318290 struct modem_private_data {
319291 struct regulator *regulator;
320292 };
321293
322294 static struct modem_private_data modem_priv;
323295
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
+ */
328299
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
+};
337320
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),
345324 };
346325
347326 static struct platform_device ams_delta_nand_device = {
348327 .name = "ams-delta-nand",
349328 .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
+ },
352332 };
353333
354
-#define OMAP_GPIO_LABEL "gpio-0-15"
334
+#define OMAP_GPIO_LABEL "gpio-0-15"
335
+#define OMAP_MPUIO_LABEL "mpuio"
355336
356337 static struct gpiod_lookup_table ams_delta_nand_gpio_table = {
357338 .table = {
358339 GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",
359340 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),
364349 GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0),
365350 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),
366359 { },
367360 },
368361 };
....@@ -410,15 +403,9 @@
410403 },
411404 };
412405
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
- */
418406 static struct gpio_led gpio_leds[] __initdata = {
419407 [LATCH1_PIN_LED_CAMERA] = {
420408 .name = "camera",
421
- .gpio = -EINVAL,
422409 .default_state = LEDS_GPIO_DEFSTATE_OFF,
423410 #ifdef CONFIG_LEDS_TRIGGERS
424411 .default_trigger = "ams_delta_camera",
....@@ -426,27 +413,22 @@
426413 },
427414 [LATCH1_PIN_LED_ADVERT] = {
428415 .name = "advert",
429
- .gpio = -EINVAL,
430416 .default_state = LEDS_GPIO_DEFSTATE_OFF,
431417 },
432418 [LATCH1_PIN_LED_MAIL] = {
433419 .name = "email",
434
- .gpio = -EINVAL,
435420 .default_state = LEDS_GPIO_DEFSTATE_OFF,
436421 },
437422 [LATCH1_PIN_LED_HANDSFREE] = {
438423 .name = "handsfree",
439
- .gpio = -EINVAL,
440424 .default_state = LEDS_GPIO_DEFSTATE_OFF,
441425 },
442426 [LATCH1_PIN_LED_VOICEMAIL] = {
443427 .name = "voicemail",
444
- .gpio = -EINVAL,
445428 .default_state = LEDS_GPIO_DEFSTATE_OFF,
446429 },
447430 [LATCH1_PIN_LED_VOICE] = {
448431 .name = "voice",
449
- .gpio = -EINVAL,
450432 .default_state = LEDS_GPIO_DEFSTATE_OFF,
451433 },
452434 };
....@@ -456,50 +438,27 @@
456438 .num_leds = ARRAY_SIZE(gpio_leds),
457439 };
458440
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
+ { },
462456 },
463457 };
464458
465459 #ifdef CONFIG_LEDS_TRIGGERS
466460 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
481461 #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
-};
503462
504463 static struct platform_device ams_delta_audio_device = {
505464 .name = "ams-delta-audio",
....@@ -512,6 +471,10 @@
512471 "hook_switch", 0),
513472 GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC,
514473 "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),
515478 { },
516479 },
517480 };
....@@ -568,8 +531,6 @@
568531 static struct fixed_voltage_config keybrd_pwr_config = {
569532 .supply_name = "keybrd_pwr",
570533 .microvolts = 5000000,
571
- .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
572
- .enable_high = 1,
573534 .init_data = &keybrd_pwr_initdata,
574535 };
575536
....@@ -593,7 +554,6 @@
593554 &latch1_gpio_device,
594555 &latch2_gpio_device,
595556 &ams_delta_kp_device,
596
- &ams_delta_camera_device,
597557 &ams_delta_audio_device,
598558 &ams_delta_serio_device,
599559 &ams_delta_nand_device,
....@@ -602,6 +562,7 @@
602562 };
603563
604564 static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
565
+ &ams_delta_nreset_gpiod_table,
605566 &ams_delta_audio_gpio_table,
606567 &keybrd_pwr_gpio_table,
607568 &ams_delta_lcd_gpio_table,
....@@ -630,6 +591,28 @@
630591 {},
631592 };
632593
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
+
633616 /*
634617 * The purpose of this function is to take care of proper initialization of
635618 * devices and data structures which depend on GPIO lines provided by OMAP GPIO
....@@ -649,11 +632,53 @@
649632 return;
650633 }
651634
635
+ /*
636
+ * Start with FIQ initialization as it may have to request
637
+ * and release successfully each OMAP GPIO pin in turn.
638
+ */
652639 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);
653676 }
654677
655678 static void __init ams_delta_init(void)
656679 {
680
+ struct platform_device *leds_pdev;
681
+
657682 /* mux pins for uarts */
658683 omap_cfg_reg(UART1_TX);
659684 omap_cfg_reg(UART1_RTS);
....@@ -673,13 +698,13 @@
673698 omap_cfg_reg(J18_1610_CAM_D7);
674699
675700 omap_gpio_deps_init();
701
+ ams_delta_latch2_init();
676702 gpiod_add_hogs(ams_delta_gpio_hogs);
677703
678704 omap_serial_init();
679705 omap_register_i2c_bus(1, 100, NULL, 0);
680706
681707 omap1_usb_init(&ams_delta_usb_config);
682
- omap1_set_camera_info(&ams_delta_camera_platform_data);
683708 #ifdef CONFIG_LEDS_TRIGGERS
684709 led_trigger_register_simple("ams_delta_camera",
685710 &ams_delta_camera_led_trigger);
....@@ -715,6 +740,12 @@
715740 */
716741 gpiod_add_lookup_tables(ams_delta_gpio_tables,
717742 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
+ }
718749
719750 omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
720751
....@@ -752,7 +783,7 @@
752783 {
753784 .membase = IOMEM(MODEM_VIRT),
754785 .mapbase = MODEM_PHYS,
755
- .irq = -EINVAL, /* changed later */
786
+ .irq = IRQ_NOTCONNECTED, /* changed later */
756787 .flags = UPF_BOOT_AUTOCONF,
757788 .irqflags = IRQF_TRIGGER_RISING,
758789 .iotype = UPIO_MEM,
....@@ -772,69 +803,6 @@
772803 },
773804 };
774805
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
-
838806 static int __init modem_nreset_init(void)
839807 {
840808 int err;
....@@ -847,43 +815,46 @@
847815 }
848816
849817
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
+ */
850835 static int __init ams_delta_modem_init(void)
851836 {
852837 int err;
853838
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;
857841
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);
864843
865844 /* Initialize the modem_nreset regulator consumer before use */
866845 modem_priv.regulator = ERR_PTR(-ENODEV);
867846
868
- ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
869
- AMS_DELTA_LATCH2_MODEM_CODEC);
870
-
871847 err = platform_device_register(&ams_delta_modem_device);
872
- if (err)
873
- gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
874848
875849 return err;
876850 }
851
+arch_initcall_sync(ams_delta_modem_init);
877852
878853 static int __init late_init(void)
879854 {
880855 int err;
881856
882857 err = modem_nreset_init();
883
- if (err)
884
- return err;
885
-
886
- err = ams_delta_modem_init();
887858 if (err)
888859 return err;
889860
....@@ -901,7 +872,6 @@
901872
902873 unregister:
903874 platform_device_unregister(&ams_delta_modem_device);
904
- gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
905875 return err;
906876 }
907877