forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/arm/mach-pxa/palmtc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/mach-pxa/palmtc.c
34 *
....@@ -8,10 +9,6 @@
89 * Based on work of:
910 * Petr Blaha <p3t3@centrum.cz>
1011 * Chetan S. Kumar <shivakumar.chetan@gmail.com>
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License version 2 as
14
- * published by the Free Software Foundation.
1512 */
1613
1714 #include <linux/platform_device.h>
....@@ -20,13 +17,12 @@
2017 #include <linux/input.h>
2118 #include <linux/pwm.h>
2219 #include <linux/pwm_backlight.h>
23
-#include <linux/gpio.h>
20
+#include <linux/gpio/machine.h>
2421 #include <linux/input/matrix_keypad.h>
2522 #include <linux/ucb1400.h>
2623 #include <linux/power_supply.h>
2724 #include <linux/gpio_keys.h>
2825 #include <linux/mtd/physmap.h>
29
-#include <linux/usb/gpio_vbus.h>
3026
3127 #include <asm/mach-types.h>
3228 #include <asm/mach/arch.h>
....@@ -120,14 +116,25 @@
120116 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
121117 static struct pxamci_platform_data palmtc_mci_platform_data = {
122118 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
123
- .gpio_power = GPIO_NR_PALMTC_SD_POWER,
124
- .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY,
125
- .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N,
126119 .detect_delay_ms = 200,
120
+};
121
+
122
+static struct gpiod_lookup_table palmtc_mci_gpio_table = {
123
+ .dev_id = "pxa2xx-mci.0",
124
+ .table = {
125
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N,
126
+ "cd", GPIO_ACTIVE_LOW),
127
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY,
128
+ "wp", GPIO_ACTIVE_LOW),
129
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER,
130
+ "power", GPIO_ACTIVE_HIGH),
131
+ { },
132
+ },
127133 };
128134
129135 static void __init palmtc_mmc_init(void)
130136 {
137
+ gpiod_add_lookup_table(&palmtc_mci_gpio_table);
131138 pxa_set_mci_info(&palmtc_mci_platform_data);
132139 }
133140 #else
....@@ -167,6 +174,15 @@
167174 * Backlight
168175 ******************************************************************************/
169176 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
177
+
178
+static struct gpiod_lookup_table palmtc_pwm_bl_gpio_table = {
179
+ .dev_id = "pwm-backlight.0",
180
+ .table = {
181
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_BL_POWER,
182
+ "enable", GPIO_ACTIVE_HIGH),
183
+ },
184
+};
185
+
170186 static struct pwm_lookup palmtc_pwm_lookup[] = {
171187 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
172188 PWM_POLARITY_NORMAL),
....@@ -175,7 +191,6 @@
175191 static struct platform_pwm_backlight_data palmtc_backlight_data = {
176192 .max_brightness = PALMTC_MAX_INTENSITY,
177193 .dft_brightness = PALMTC_MAX_INTENSITY,
178
- .enable_gpio = GPIO_NR_PALMTC_BL_POWER,
179194 };
180195
181196 static struct platform_device palmtc_backlight = {
....@@ -188,6 +203,7 @@
188203
189204 static void __init palmtc_pwm_init(void)
190205 {
206
+ gpiod_add_lookup_table(&palmtc_pwm_bl_gpio_table);
191207 pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
192208 platform_device_register(&palmtc_backlight);
193209 }
....@@ -311,22 +327,25 @@
311327 * UDC
312328 ******************************************************************************/
313329 #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
314
-static struct gpio_vbus_mach_info palmtc_udc_info = {
315
- .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
316
- .gpio_vbus_inverted = 1,
317
- .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
330
+static struct gpiod_lookup_table palmtc_udc_gpiod_table = {
331
+ .dev_id = "gpio-vbus",
332
+ .table = {
333
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_DETECT_N,
334
+ "vbus", GPIO_ACTIVE_LOW),
335
+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_POWER,
336
+ "pullup", GPIO_ACTIVE_HIGH),
337
+ { },
338
+ },
318339 };
319340
320341 static struct platform_device palmtc_gpio_vbus = {
321342 .name = "gpio-vbus",
322343 .id = -1,
323
- .dev = {
324
- .platform_data = &palmtc_udc_info,
325
- },
326344 };
327345
328346 static void __init palmtc_udc_init(void)
329347 {
348
+ gpiod_add_lookup_table(&palmtc_udc_gpiod_table);
330349 platform_device_register(&palmtc_gpio_vbus);
331350 };
332351 #else