forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/arm/mach-pxa/tosa.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Support for Sharp SL-C6000x PDAs
34 * Model: (Tosa)
....@@ -5,11 +6,6 @@
56 * Copyright (c) 2005 Dirk Opfer
67 *
78 * Based on code written by Sharp/Lineo for 2.4 kernels
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
12
- *
139 */
1410
1511 #include <linux/clkdev.h>
....@@ -31,12 +27,12 @@
3127 #include <linux/gpio_keys.h>
3228 #include <linux/input.h>
3329 #include <linux/gpio.h>
30
+#include <linux/gpio/machine.h>
3431 #include <linux/power/gpio-charger.h>
3532 #include <linux/spi/spi.h>
3633 #include <linux/spi/pxa2xx_spi.h>
3734 #include <linux/input/matrix_keypad.h>
3835 #include <linux/platform_data/i2c-pxa.h>
39
-#include <linux/usb/gpio_vbus.h>
4036 #include <linux/reboot.h>
4137 #include <linux/memblock.h>
4238
....@@ -243,18 +239,20 @@
243239 /*
244240 * USB Device Controller
245241 */
246
-static struct gpio_vbus_mach_info tosa_udc_info = {
247
- .gpio_pullup = TOSA_GPIO_USB_PULLUP,
248
- .gpio_vbus = TOSA_GPIO_USB_IN,
249
- .gpio_vbus_inverted = 1,
242
+static struct gpiod_lookup_table tosa_udc_gpiod_table = {
243
+ .dev_id = "gpio-vbus",
244
+ .table = {
245
+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_USB_IN,
246
+ "vbus", GPIO_ACTIVE_LOW),
247
+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_USB_PULLUP,
248
+ "pullup", GPIO_ACTIVE_HIGH),
249
+ { },
250
+ },
250251 };
251252
252253 static struct platform_device tosa_gpio_vbus = {
253254 .name = "gpio-vbus",
254255 .id = -1,
255
- .dev = {
256
- .platform_data = &tosa_udc_info,
257
- },
258256 };
259257
260258 /*
....@@ -291,9 +289,19 @@
291289 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
292290 .init = tosa_mci_init,
293291 .exit = tosa_mci_exit,
294
- .gpio_card_detect = TOSA_GPIO_nSD_DETECT,
295
- .gpio_card_ro = TOSA_GPIO_SD_WP,
296
- .gpio_power = TOSA_GPIO_PWR_ON,
292
+};
293
+
294
+static struct gpiod_lookup_table tosa_mci_gpio_table = {
295
+ .dev_id = "pxa2xx-mci.0",
296
+ .table = {
297
+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_nSD_DETECT,
298
+ "cd", GPIO_ACTIVE_LOW),
299
+ GPIO_LOOKUP("sharp-scoop.0", TOSA_GPIO_SD_WP - TOSA_SCOOP_GPIO_BASE,
300
+ "wp", GPIO_ACTIVE_LOW),
301
+ GPIO_LOOKUP("sharp-scoop.0", TOSA_GPIO_PWR_ON - TOSA_SCOOP_GPIO_BASE,
302
+ "power", GPIO_ACTIVE_HIGH),
303
+ { },
304
+ },
297305 };
298306
299307 /*
....@@ -361,6 +369,15 @@
361369 /*
362370 * Tosa AC IN
363371 */
372
+static struct gpiod_lookup_table tosa_power_gpiod_table = {
373
+ .dev_id = "gpio-charger",
374
+ .table = {
375
+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_AC_IN,
376
+ NULL, GPIO_ACTIVE_LOW),
377
+ { },
378
+ },
379
+};
380
+
364381 static char *tosa_ac_supplied_to[] = {
365382 "main-battery",
366383 "backup-battery",
....@@ -370,8 +387,6 @@
370387 static struct gpio_charger_platform_data tosa_power_data = {
371388 .name = "charger",
372389 .type = POWER_SUPPLY_TYPE_MAINS,
373
- .gpio = TOSA_GPIO_AC_IN,
374
- .gpio_active_low = 1,
375390 .supplied_to = tosa_ac_supplied_to,
376391 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
377392 };
....@@ -802,8 +817,28 @@
802817 .dev.platform_data = &tosa_bt_data,
803818 };
804819
805
-static struct pxa2xx_spi_master pxa_ssp_master_info = {
820
+static struct pxa2xx_spi_controller pxa_ssp_master_info = {
806821 .num_chipselect = 1,
822
+};
823
+
824
+static struct gpiod_lookup_table tosa_lcd_gpio_table = {
825
+ .dev_id = "spi2.0",
826
+ .table = {
827
+ GPIO_LOOKUP("tc6393xb",
828
+ TOSA_GPIO_TG_ON - TOSA_TC6393XB_GPIO_BASE,
829
+ "tg #pwr", GPIO_ACTIVE_HIGH),
830
+ { },
831
+ },
832
+};
833
+
834
+static struct gpiod_lookup_table tosa_lcd_bl_gpio_table = {
835
+ .dev_id = "i2c-tosa-bl",
836
+ .table = {
837
+ GPIO_LOOKUP("tc6393xb",
838
+ TOSA_GPIO_BL_C20MA - TOSA_TC6393XB_GPIO_BASE,
839
+ "backlight", GPIO_ACTIVE_HIGH),
840
+ { },
841
+ },
807842 };
808843
809844 static struct spi_board_info spi_board_info[] __initdata = {
....@@ -908,6 +943,7 @@
908943 /* enable batt_fault */
909944 PMCR = 0x01;
910945
946
+ gpiod_add_lookup_table(&tosa_mci_gpio_table);
911947 pxa_set_mci_info(&tosa_mci_platform_data);
912948 pxa_set_ficp_info(&tosa_ficp_platform_data);
913949 pxa_set_i2c_info(NULL);
....@@ -915,10 +951,14 @@
915951 platform_scoop_config = &tosa_pcmcia_config;
916952
917953 pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
954
+ gpiod_add_lookup_table(&tosa_lcd_gpio_table);
955
+ gpiod_add_lookup_table(&tosa_lcd_bl_gpio_table);
918956 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
919957
920958 clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
921959
960
+ gpiod_add_lookup_table(&tosa_udc_gpiod_table);
961
+ gpiod_add_lookup_table(&tosa_power_gpiod_table);
922962 platform_add_devices(devices, ARRAY_SIZE(devices));
923963 }
924964