hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arm/mach-pxa/magician.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Support for HTC Magician PDA phones:
34 * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
....@@ -6,11 +7,6 @@
67 * Copyright (c) 2006-2007 Philipp Zabel
78 *
89 * Based on hx4700.c, spitz.c and others.
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
- *
1410 */
1511
1612 #include <linux/kernel.h>
....@@ -18,6 +14,7 @@
1814 #include <linux/platform_device.h>
1915 #include <linux/delay.h>
2016 #include <linux/gpio.h>
17
+#include <linux/gpio/machine.h>
2118 #include <linux/gpio_keys.h>
2219 #include <linux/input.h>
2320 #include <linux/mfd/htc-pasic3.h>
....@@ -30,7 +27,6 @@
3027 #include <linux/regulator/fixed.h>
3128 #include <linux/regulator/gpio-regulator.h>
3229 #include <linux/regulator/machine.h>
33
-#include <linux/usb/gpio_vbus.h>
3430 #include <linux/platform_data/i2c-pxa.h>
3531
3632 #include <mach/hardware.h>
....@@ -405,7 +401,6 @@
405401 static struct platform_pwm_backlight_data backlight_data = {
406402 .max_brightness = 272,
407403 .dft_brightness = 100,
408
- .enable_gpio = -1,
409404 .init = magician_backlight_init,
410405 .notify = magician_backlight_notify,
411406 .exit = magician_backlight_exit,
....@@ -509,9 +504,20 @@
509504 .end = IRQ_MAGICIAN_VBUS,
510505 };
511506
512
-static struct gpio_vbus_mach_info gpio_vbus_info = {
513
- .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN,
514
- .gpio_vbus = EGPIO_MAGICIAN_CABLE_VBUS,
507
+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
508
+ .dev_id = "gpio-vbus",
509
+ .table = {
510
+ /*
511
+ * EGPIO on register 4 index 1, the second EGPIO chip
512
+ * starts at register 4 so this will be at index 1 on that
513
+ * chip.
514
+ */
515
+ GPIO_LOOKUP("htc-egpio-1", 1,
516
+ "vbus", GPIO_ACTIVE_HIGH),
517
+ GPIO_LOOKUP("gpio-pxa", GPIO27_MAGICIAN_USBC_PUEN,
518
+ "pullup", GPIO_ACTIVE_HIGH),
519
+ { },
520
+ },
515521 };
516522
517523 static struct platform_device gpio_vbus = {
....@@ -519,9 +525,6 @@
519525 .id = -1,
520526 .num_resources = 1,
521527 .resource = &gpio_vbus_resource,
522
- .dev = {
523
- .platform_data = &gpio_vbus_info,
524
- },
525528 };
526529
527530 /*
....@@ -644,9 +647,8 @@
644647 .consumer_supplies = bq24022_consumers,
645648 };
646649
647
-static struct gpio bq24022_gpios[] = {
648
- { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
649
-};
650
+
651
+static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW };
650652
651653 static struct gpio_regulator_state bq24022_states[] = {
652654 { .value = 100000, .gpios = (0 << 0) },
....@@ -656,12 +658,10 @@
656658 static struct gpio_regulator_config bq24022_info = {
657659 .supply_name = "bq24022",
658660
659
- .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
660
- .enable_high = 0,
661661 .enabled_at_boot = 1,
662662
663
- .gpios = bq24022_gpios,
664
- .nr_gpios = ARRAY_SIZE(bq24022_gpios),
663
+ .gflags = bq24022_gpiod_gflags,
664
+ .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags),
665665
666666 .states = bq24022_states,
667667 .nr_states = ARRAY_SIZE(bq24022_states),
....@@ -675,6 +675,17 @@
675675 .id = -1,
676676 .dev = {
677677 .platform_data = &bq24022_info,
678
+ },
679
+};
680
+
681
+static struct gpiod_lookup_table bq24022_gpiod_table = {
682
+ .dev_id = "gpio-regulator",
683
+ .table = {
684
+ GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_BQ24022_ISET2 - MAGICIAN_EGPIO_BASE,
685
+ NULL, GPIO_ACTIVE_HIGH),
686
+ GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
687
+ "enable", GPIO_ACTIVE_LOW),
688
+ { },
678689 },
679690 };
680691
....@@ -696,7 +707,6 @@
696707 static struct fixed_voltage_config vads7846 = {
697708 .supply_name = "vads7846",
698709 .microvolts = 3300000, /* probably */
699
- .gpio = -EINVAL,
700710 .startup_delay = 0,
701711 .init_data = &vads7846_regulator,
702712 };
....@@ -775,12 +785,31 @@
775785 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
776786 .init = magician_mci_init,
777787 .exit = magician_mci_exit,
778
- .gpio_card_detect = -1,
779
- .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY,
780788 .gpio_card_ro_invert = 1,
781
- .gpio_power = EGPIO_MAGICIAN_SD_POWER,
782789 };
783790
791
+/*
792
+ * Write protect on EGPIO register 5 index 4, this is on the second HTC
793
+ * EGPIO chip which starts at register 4, so we need offset 8+4=12 on that
794
+ * particular chip.
795
+ */
796
+#define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12
797
+/*
798
+ * Power on EGPIO register 2 index 0, so this is on the first HTC EGPIO chip
799
+ * starting at register 0 so we need offset 2*8+0 = 16 on that chip.
800
+ */
801
+#define EGPIO_MAGICIAN_nSD_POWER_OFFSET 16
802
+
803
+static struct gpiod_lookup_table magician_mci_gpio_table = {
804
+ .dev_id = "pxa2xx-mci.0",
805
+ .table = {
806
+ GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET,
807
+ "wp", GPIO_ACTIVE_HIGH),
808
+ GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_nSD_POWER_OFFSET,
809
+ "power", GPIO_ACTIVE_HIGH),
810
+ { },
811
+ },
812
+};
784813
785814 /*
786815 * USB OHCI
....@@ -913,7 +942,7 @@
913942 .gpio_cs = GPIO14_MAGICIAN_TSC2046_CS,
914943 };
915944
916
-static struct pxa2xx_spi_master magician_spi_info = {
945
+static struct pxa2xx_spi_controller magician_spi_info = {
917946 .num_chipselect = 1,
918947 .enable_dma = 1,
919948 };
....@@ -979,12 +1008,13 @@
9791008 i2c_register_board_info(1,
9801009 ARRAY_AND_SIZE(magician_pwr_i2c_board_info));
9811010
1011
+ gpiod_add_lookup_table(&magician_mci_gpio_table);
9821012 pxa_set_mci_info(&magician_mci_info);
9831013 pxa_set_ohci_info(&magician_ohci_info);
9841014 pxa_set_udc_info(&magician_udc_info);
9851015
9861016 /* Check LCD type we have */
987
- cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000);
1017
+ cpld = ioremap(PXA_CS3_PHYS, 0x1000);
9881018 if (cpld) {
9891019 u8 board_id = __raw_readb(cpld + 0x14);
9901020
....@@ -1007,6 +1037,8 @@
10071037 regulator_register_always_on(0, "power", pwm_backlight_supply,
10081038 ARRAY_SIZE(pwm_backlight_supply), 5000000);
10091039
1040
+ gpiod_add_lookup_table(&bq24022_gpiod_table);
1041
+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
10101042 platform_add_devices(ARRAY_AND_SIZE(devices));
10111043 }
10121044