| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Support for Sharp SL-C6000x PDAs |
|---|
| 3 | 4 | * Model: (Tosa) |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (c) 2005 Dirk Opfer |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * 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 | | - * |
|---|
| 13 | 9 | */ |
|---|
| 14 | 10 | |
|---|
| 15 | 11 | #include <linux/clkdev.h> |
|---|
| .. | .. |
|---|
| 31 | 27 | #include <linux/gpio_keys.h> |
|---|
| 32 | 28 | #include <linux/input.h> |
|---|
| 33 | 29 | #include <linux/gpio.h> |
|---|
| 30 | +#include <linux/gpio/machine.h> |
|---|
| 34 | 31 | #include <linux/power/gpio-charger.h> |
|---|
| 35 | 32 | #include <linux/spi/spi.h> |
|---|
| 36 | 33 | #include <linux/spi/pxa2xx_spi.h> |
|---|
| 37 | 34 | #include <linux/input/matrix_keypad.h> |
|---|
| 38 | 35 | #include <linux/platform_data/i2c-pxa.h> |
|---|
| 39 | | -#include <linux/usb/gpio_vbus.h> |
|---|
| 40 | 36 | #include <linux/reboot.h> |
|---|
| 41 | 37 | #include <linux/memblock.h> |
|---|
| 42 | 38 | |
|---|
| .. | .. |
|---|
| 243 | 239 | /* |
|---|
| 244 | 240 | * USB Device Controller |
|---|
| 245 | 241 | */ |
|---|
| 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 | + }, |
|---|
| 250 | 251 | }; |
|---|
| 251 | 252 | |
|---|
| 252 | 253 | static struct platform_device tosa_gpio_vbus = { |
|---|
| 253 | 254 | .name = "gpio-vbus", |
|---|
| 254 | 255 | .id = -1, |
|---|
| 255 | | - .dev = { |
|---|
| 256 | | - .platform_data = &tosa_udc_info, |
|---|
| 257 | | - }, |
|---|
| 258 | 256 | }; |
|---|
| 259 | 257 | |
|---|
| 260 | 258 | /* |
|---|
| .. | .. |
|---|
| 291 | 289 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
|---|
| 292 | 290 | .init = tosa_mci_init, |
|---|
| 293 | 291 | .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 | + }, |
|---|
| 297 | 305 | }; |
|---|
| 298 | 306 | |
|---|
| 299 | 307 | /* |
|---|
| .. | .. |
|---|
| 361 | 369 | /* |
|---|
| 362 | 370 | * Tosa AC IN |
|---|
| 363 | 371 | */ |
|---|
| 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 | + |
|---|
| 364 | 381 | static char *tosa_ac_supplied_to[] = { |
|---|
| 365 | 382 | "main-battery", |
|---|
| 366 | 383 | "backup-battery", |
|---|
| .. | .. |
|---|
| 370 | 387 | static struct gpio_charger_platform_data tosa_power_data = { |
|---|
| 371 | 388 | .name = "charger", |
|---|
| 372 | 389 | .type = POWER_SUPPLY_TYPE_MAINS, |
|---|
| 373 | | - .gpio = TOSA_GPIO_AC_IN, |
|---|
| 374 | | - .gpio_active_low = 1, |
|---|
| 375 | 390 | .supplied_to = tosa_ac_supplied_to, |
|---|
| 376 | 391 | .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to), |
|---|
| 377 | 392 | }; |
|---|
| .. | .. |
|---|
| 802 | 817 | .dev.platform_data = &tosa_bt_data, |
|---|
| 803 | 818 | }; |
|---|
| 804 | 819 | |
|---|
| 805 | | -static struct pxa2xx_spi_master pxa_ssp_master_info = { |
|---|
| 820 | +static struct pxa2xx_spi_controller pxa_ssp_master_info = { |
|---|
| 806 | 821 | .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 | + }, |
|---|
| 807 | 842 | }; |
|---|
| 808 | 843 | |
|---|
| 809 | 844 | static struct spi_board_info spi_board_info[] __initdata = { |
|---|
| .. | .. |
|---|
| 908 | 943 | /* enable batt_fault */ |
|---|
| 909 | 944 | PMCR = 0x01; |
|---|
| 910 | 945 | |
|---|
| 946 | + gpiod_add_lookup_table(&tosa_mci_gpio_table); |
|---|
| 911 | 947 | pxa_set_mci_info(&tosa_mci_platform_data); |
|---|
| 912 | 948 | pxa_set_ficp_info(&tosa_ficp_platform_data); |
|---|
| 913 | 949 | pxa_set_i2c_info(NULL); |
|---|
| .. | .. |
|---|
| 915 | 951 | platform_scoop_config = &tosa_pcmcia_config; |
|---|
| 916 | 952 | |
|---|
| 917 | 953 | 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); |
|---|
| 918 | 956 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); |
|---|
| 919 | 957 | |
|---|
| 920 | 958 | clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL); |
|---|
| 921 | 959 | |
|---|
| 960 | + gpiod_add_lookup_table(&tosa_udc_gpiod_table); |
|---|
| 961 | + gpiod_add_lookup_table(&tosa_power_gpiod_table); |
|---|
| 922 | 962 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
|---|
| 923 | 963 | } |
|---|
| 924 | 964 | |
|---|