forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/arm/mach-pxa/hx4700.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Support for HP iPAQ hx4700 PDAs.
34 *
....@@ -7,11 +8,6 @@
78 * Copyright (c) 2004 Hewlett-Packard Company.
89 * Copyright (c) 2005 SDG Systems, LLC
910 * Copyright (c) 2006 Anton Vorontsov <cbou@mail.ru>
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.
14
- *
1511 */
1612
1713 #include <linux/kernel.h>
....@@ -19,6 +15,7 @@
1915 #include <linux/platform_device.h>
2016 #include <linux/delay.h>
2117 #include <linux/fb.h>
18
+#include <linux/gpio/machine.h>
2219 #include <linux/gpio.h>
2320 #include <linux/gpio_keys.h>
2421 #include <linux/input.h>
....@@ -37,7 +34,6 @@
3734 #include <linux/spi/ads7846.h>
3835 #include <linux/spi/spi.h>
3936 #include <linux/spi/pxa2xx_spi.h>
40
-#include <linux/usb/gpio_vbus.h>
4137 #include <linux/platform_data/i2c-pxa.h>
4238
4339 #include <mach/hardware.h>
....@@ -560,7 +556,6 @@
560556 static struct platform_pwm_backlight_data backlight_data = {
561557 .max_brightness = 200,
562558 .dft_brightness = 100,
563
- .enable_gpio = -1,
564559 };
565560
566561 static struct platform_device backlight = {
....@@ -581,18 +576,24 @@
581576 * USB "Transceiver"
582577 */
583578
584
-static struct gpio_vbus_mach_info gpio_vbus_info = {
585
- .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
586
- .gpio_vbus = GPIOD14_nUSBC_DETECT,
587
- .gpio_vbus_inverted = 1,
579
+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
580
+ .dev_id = "gpio-vbus",
581
+ .table = {
582
+ /* This GPIO is on ASIC3 */
583
+ GPIO_LOOKUP("asic3",
584
+ /* Convert to a local offset on the ASIC3 */
585
+ GPIOD14_nUSBC_DETECT - HX4700_ASIC3_GPIO_BASE,
586
+ "vbus", GPIO_ACTIVE_LOW),
587
+ /* This one is on the primary SOC GPIO */
588
+ GPIO_LOOKUP("gpio-pxa", GPIO76_HX4700_USBC_PUEN,
589
+ "pullup", GPIO_ACTIVE_HIGH),
590
+ { },
591
+ },
588592 };
589593
590594 static struct platform_device gpio_vbus = {
591595 .name = "gpio-vbus",
592596 .id = -1,
593
- .dev = {
594
- .platform_data = &gpio_vbus_info,
595
- },
596597 };
597598
598599 static struct pxa2xx_udc_mach_info hx4700_udc_info;
....@@ -629,7 +630,7 @@
629630 },
630631 };
631632
632
-static struct pxa2xx_spi_master pxa_ssp2_master_info = {
633
+static struct pxa2xx_spi_controller pxa_ssp2_master_info = {
633634 .num_chipselect = 1,
634635 .enable_dma = 1,
635636 };
....@@ -702,9 +703,7 @@
702703 .consumer_supplies = bq24022_consumers,
703704 };
704705
705
-static struct gpio bq24022_gpios[] = {
706
- { GPIO96_HX4700_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
707
-};
706
+static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW };
708707
709708 static struct gpio_regulator_state bq24022_states[] = {
710709 { .value = 100000, .gpios = (0 << 0) },
....@@ -714,12 +713,10 @@
714713 static struct gpio_regulator_config bq24022_info = {
715714 .supply_name = "bq24022",
716715
717
- .enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN,
718
- .enable_high = 0,
719716 .enabled_at_boot = 0,
720717
721
- .gpios = bq24022_gpios,
722
- .nr_gpios = ARRAY_SIZE(bq24022_gpios),
718
+ .gflags = bq24022_gpiod_gflags,
719
+ .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags),
723720
724721 .states = bq24022_states,
725722 .nr_states = ARRAY_SIZE(bq24022_states),
....@@ -733,6 +730,17 @@
733730 .id = -1,
734731 .dev = {
735732 .platform_data = &bq24022_info,
733
+ },
734
+};
735
+
736
+static struct gpiod_lookup_table bq24022_gpiod_table = {
737
+ .dev_id = "gpio-regulator",
738
+ .table = {
739
+ GPIO_LOOKUP("gpio-pxa", GPIO96_HX4700_BQ24022_ISET2,
740
+ NULL, GPIO_ACTIVE_HIGH),
741
+ GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN,
742
+ "enable", GPIO_ACTIVE_LOW),
743
+ { },
736744 },
737745 };
738746
....@@ -878,6 +886,8 @@
878886 pxa_set_btuart_info(NULL);
879887 pxa_set_stuart_info(NULL);
880888
889
+ gpiod_add_lookup_table(&bq24022_gpiod_table);
890
+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
881891 platform_add_devices(devices, ARRAY_SIZE(devices));
882892 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
883893