forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/arm/mach-pxa/mainstone.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/mach-pxa/mainstone.c
34 *
....@@ -7,12 +8,9 @@
78 * Author: Nicolas Pitre
89 * Created: Nov 05, 2002
910 * Copyright: MontaVista Software Inc.
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
1411 */
1512 #include <linux/gpio.h>
13
+#include <linux/gpio/gpio-reg.h>
1614 #include <linux/gpio/machine.h>
1715 #include <linux/init.h>
1816 #include <linux/platform_device.h>
....@@ -39,7 +37,7 @@
3937 #include <asm/mach-types.h>
4038 #include <mach/hardware.h>
4139 #include <asm/irq.h>
42
-#include <asm/sizes.h>
40
+#include <linux/sizes.h>
4341
4442 #include <asm/mach/arch.h>
4543 #include <asm/mach/map.h>
....@@ -258,7 +256,6 @@
258256 static struct platform_pwm_backlight_data mainstone_backlight_data = {
259257 .max_brightness = 1023,
260258 .dft_brightness = 1023,
261
- .enable_gpio = -1,
262259 };
263260
264261 static struct platform_device mainstone_backlight_device = {
....@@ -361,9 +358,6 @@
361358 .init = mainstone_mci_init,
362359 .setpower = mainstone_mci_setpower,
363360 .exit = mainstone_mci_exit,
364
- .gpio_card_detect = -1,
365
- .gpio_card_ro = -1,
366
- .gpio_power = -1,
367361 };
368362
369363 static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
....@@ -507,12 +501,64 @@
507501 static inline void mainstone_init_keypad(void) {}
508502 #endif
509503
504
+static int mst_pcmcia0_irqs[11] = {
505
+ [0 ... 10] = -1,
506
+ [5] = MAINSTONE_S0_CD_IRQ,
507
+ [8] = MAINSTONE_S0_STSCHG_IRQ,
508
+ [10] = MAINSTONE_S0_IRQ,
509
+};
510
+
511
+static int mst_pcmcia1_irqs[11] = {
512
+ [0 ... 10] = -1,
513
+ [5] = MAINSTONE_S1_CD_IRQ,
514
+ [8] = MAINSTONE_S1_STSCHG_IRQ,
515
+ [10] = MAINSTONE_S1_IRQ,
516
+};
517
+
518
+static struct gpiod_lookup_table mainstone_pcmcia_gpio_table = {
519
+ .dev_id = "pxa2xx-pcmcia",
520
+ .table = {
521
+ GPIO_LOOKUP("mst-pcmcia0", 0, "a0vpp", GPIO_ACTIVE_HIGH),
522
+ GPIO_LOOKUP("mst-pcmcia0", 1, "a1vpp", GPIO_ACTIVE_HIGH),
523
+ GPIO_LOOKUP("mst-pcmcia0", 2, "a0vcc", GPIO_ACTIVE_HIGH),
524
+ GPIO_LOOKUP("mst-pcmcia0", 3, "a1vcc", GPIO_ACTIVE_HIGH),
525
+ GPIO_LOOKUP("mst-pcmcia0", 4, "areset", GPIO_ACTIVE_HIGH),
526
+ GPIO_LOOKUP("mst-pcmcia0", 5, "adetect", GPIO_ACTIVE_LOW),
527
+ GPIO_LOOKUP("mst-pcmcia0", 6, "avs1", GPIO_ACTIVE_LOW),
528
+ GPIO_LOOKUP("mst-pcmcia0", 7, "avs2", GPIO_ACTIVE_LOW),
529
+ GPIO_LOOKUP("mst-pcmcia0", 8, "abvd1", GPIO_ACTIVE_HIGH),
530
+ GPIO_LOOKUP("mst-pcmcia0", 9, "abvd2", GPIO_ACTIVE_HIGH),
531
+ GPIO_LOOKUP("mst-pcmcia0", 10, "aready", GPIO_ACTIVE_HIGH),
532
+ GPIO_LOOKUP("mst-pcmcia1", 0, "b0vpp", GPIO_ACTIVE_HIGH),
533
+ GPIO_LOOKUP("mst-pcmcia1", 1, "b1vpp", GPIO_ACTIVE_HIGH),
534
+ GPIO_LOOKUP("mst-pcmcia1", 2, "b0vcc", GPIO_ACTIVE_HIGH),
535
+ GPIO_LOOKUP("mst-pcmcia1", 3, "b1vcc", GPIO_ACTIVE_HIGH),
536
+ GPIO_LOOKUP("mst-pcmcia1", 4, "breset", GPIO_ACTIVE_HIGH),
537
+ GPIO_LOOKUP("mst-pcmcia1", 5, "bdetect", GPIO_ACTIVE_LOW),
538
+ GPIO_LOOKUP("mst-pcmcia1", 6, "bvs1", GPIO_ACTIVE_LOW),
539
+ GPIO_LOOKUP("mst-pcmcia1", 7, "bvs2", GPIO_ACTIVE_LOW),
540
+ GPIO_LOOKUP("mst-pcmcia1", 8, "bbvd1", GPIO_ACTIVE_HIGH),
541
+ GPIO_LOOKUP("mst-pcmcia1", 9, "bbvd2", GPIO_ACTIVE_HIGH),
542
+ GPIO_LOOKUP("mst-pcmcia1", 10, "bready", GPIO_ACTIVE_HIGH),
543
+ { },
544
+ },
545
+};
546
+
510547 static void __init mainstone_init(void)
511548 {
512549 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
513550
514551 pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config));
515552
553
+ /* Register board control register(s) as GPIOs */
554
+ gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA0, -1, 11,
555
+ "mst-pcmcia0", MST_PCMCIA_INPUTS, 0, NULL,
556
+ NULL, mst_pcmcia0_irqs);
557
+ gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA1, -1, 11,
558
+ "mst-pcmcia1", MST_PCMCIA_INPUTS, 0, NULL,
559
+ NULL, mst_pcmcia1_irqs);
560
+ gpiod_add_lookup_table(&mainstone_pcmcia_gpio_table);
561
+
516562 pxa_set_ffuart_info(NULL);
517563 pxa_set_btuart_info(NULL);
518564 pxa_set_stuart_info(NULL);