.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Support for HTC Magician PDA phones: |
---|
3 | 4 | * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110 |
---|
.. | .. |
---|
6 | 7 | * Copyright (c) 2006-2007 Philipp Zabel |
---|
7 | 8 | * |
---|
8 | 9 | * 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 | | - * |
---|
14 | 10 | */ |
---|
15 | 11 | |
---|
16 | 12 | #include <linux/kernel.h> |
---|
.. | .. |
---|
18 | 14 | #include <linux/platform_device.h> |
---|
19 | 15 | #include <linux/delay.h> |
---|
20 | 16 | #include <linux/gpio.h> |
---|
| 17 | +#include <linux/gpio/machine.h> |
---|
21 | 18 | #include <linux/gpio_keys.h> |
---|
22 | 19 | #include <linux/input.h> |
---|
23 | 20 | #include <linux/mfd/htc-pasic3.h> |
---|
.. | .. |
---|
30 | 27 | #include <linux/regulator/fixed.h> |
---|
31 | 28 | #include <linux/regulator/gpio-regulator.h> |
---|
32 | 29 | #include <linux/regulator/machine.h> |
---|
33 | | -#include <linux/usb/gpio_vbus.h> |
---|
34 | 30 | #include <linux/platform_data/i2c-pxa.h> |
---|
35 | 31 | |
---|
36 | 32 | #include <mach/hardware.h> |
---|
.. | .. |
---|
405 | 401 | static struct platform_pwm_backlight_data backlight_data = { |
---|
406 | 402 | .max_brightness = 272, |
---|
407 | 403 | .dft_brightness = 100, |
---|
408 | | - .enable_gpio = -1, |
---|
409 | 404 | .init = magician_backlight_init, |
---|
410 | 405 | .notify = magician_backlight_notify, |
---|
411 | 406 | .exit = magician_backlight_exit, |
---|
.. | .. |
---|
509 | 504 | .end = IRQ_MAGICIAN_VBUS, |
---|
510 | 505 | }; |
---|
511 | 506 | |
---|
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 | + }, |
---|
515 | 521 | }; |
---|
516 | 522 | |
---|
517 | 523 | static struct platform_device gpio_vbus = { |
---|
.. | .. |
---|
519 | 525 | .id = -1, |
---|
520 | 526 | .num_resources = 1, |
---|
521 | 527 | .resource = &gpio_vbus_resource, |
---|
522 | | - .dev = { |
---|
523 | | - .platform_data = &gpio_vbus_info, |
---|
524 | | - }, |
---|
525 | 528 | }; |
---|
526 | 529 | |
---|
527 | 530 | /* |
---|
.. | .. |
---|
644 | 647 | .consumer_supplies = bq24022_consumers, |
---|
645 | 648 | }; |
---|
646 | 649 | |
---|
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 }; |
---|
650 | 652 | |
---|
651 | 653 | static struct gpio_regulator_state bq24022_states[] = { |
---|
652 | 654 | { .value = 100000, .gpios = (0 << 0) }, |
---|
.. | .. |
---|
656 | 658 | static struct gpio_regulator_config bq24022_info = { |
---|
657 | 659 | .supply_name = "bq24022", |
---|
658 | 660 | |
---|
659 | | - .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, |
---|
660 | | - .enable_high = 0, |
---|
661 | 661 | .enabled_at_boot = 1, |
---|
662 | 662 | |
---|
663 | | - .gpios = bq24022_gpios, |
---|
664 | | - .nr_gpios = ARRAY_SIZE(bq24022_gpios), |
---|
| 663 | + .gflags = bq24022_gpiod_gflags, |
---|
| 664 | + .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags), |
---|
665 | 665 | |
---|
666 | 666 | .states = bq24022_states, |
---|
667 | 667 | .nr_states = ARRAY_SIZE(bq24022_states), |
---|
.. | .. |
---|
675 | 675 | .id = -1, |
---|
676 | 676 | .dev = { |
---|
677 | 677 | .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 | + { }, |
---|
678 | 689 | }, |
---|
679 | 690 | }; |
---|
680 | 691 | |
---|
.. | .. |
---|
696 | 707 | static struct fixed_voltage_config vads7846 = { |
---|
697 | 708 | .supply_name = "vads7846", |
---|
698 | 709 | .microvolts = 3300000, /* probably */ |
---|
699 | | - .gpio = -EINVAL, |
---|
700 | 710 | .startup_delay = 0, |
---|
701 | 711 | .init_data = &vads7846_regulator, |
---|
702 | 712 | }; |
---|
.. | .. |
---|
775 | 785 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
---|
776 | 786 | .init = magician_mci_init, |
---|
777 | 787 | .exit = magician_mci_exit, |
---|
778 | | - .gpio_card_detect = -1, |
---|
779 | | - .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY, |
---|
780 | 788 | .gpio_card_ro_invert = 1, |
---|
781 | | - .gpio_power = EGPIO_MAGICIAN_SD_POWER, |
---|
782 | 789 | }; |
---|
783 | 790 | |
---|
| 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 | +}; |
---|
784 | 813 | |
---|
785 | 814 | /* |
---|
786 | 815 | * USB OHCI |
---|
.. | .. |
---|
913 | 942 | .gpio_cs = GPIO14_MAGICIAN_TSC2046_CS, |
---|
914 | 943 | }; |
---|
915 | 944 | |
---|
916 | | -static struct pxa2xx_spi_master magician_spi_info = { |
---|
| 945 | +static struct pxa2xx_spi_controller magician_spi_info = { |
---|
917 | 946 | .num_chipselect = 1, |
---|
918 | 947 | .enable_dma = 1, |
---|
919 | 948 | }; |
---|
.. | .. |
---|
979 | 1008 | i2c_register_board_info(1, |
---|
980 | 1009 | ARRAY_AND_SIZE(magician_pwr_i2c_board_info)); |
---|
981 | 1010 | |
---|
| 1011 | + gpiod_add_lookup_table(&magician_mci_gpio_table); |
---|
982 | 1012 | pxa_set_mci_info(&magician_mci_info); |
---|
983 | 1013 | pxa_set_ohci_info(&magician_ohci_info); |
---|
984 | 1014 | pxa_set_udc_info(&magician_udc_info); |
---|
985 | 1015 | |
---|
986 | 1016 | /* Check LCD type we have */ |
---|
987 | | - cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); |
---|
| 1017 | + cpld = ioremap(PXA_CS3_PHYS, 0x1000); |
---|
988 | 1018 | if (cpld) { |
---|
989 | 1019 | u8 board_id = __raw_readb(cpld + 0x14); |
---|
990 | 1020 | |
---|
.. | .. |
---|
1007 | 1037 | regulator_register_always_on(0, "power", pwm_backlight_supply, |
---|
1008 | 1038 | ARRAY_SIZE(pwm_backlight_supply), 5000000); |
---|
1009 | 1039 | |
---|
| 1040 | + gpiod_add_lookup_table(&bq24022_gpiod_table); |
---|
| 1041 | + gpiod_add_lookup_table(&gpio_vbus_gpiod_table); |
---|
1010 | 1042 | platform_add_devices(ARRAY_AND_SIZE(devices)); |
---|
1011 | 1043 | } |
---|
1012 | 1044 | |
---|