Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'omap-for-v4.20/omap1-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/soc

A series of omap1 gpio changes for ams-delta

Janusz Krzysztofik has cleaned up ams-delta gpio usage along with
generic gpio framework improvments. This series contains the omap1
specific clean-up for ams-delta modem and unused gpios.

Note that this conflicts with the gpio-omap changes queued into
an immutable gpio branch ib-omap for the gpio-omap.h header file.
The merge resolution is to drop the IS_BUILTIN(CONFIG_GPIO_OMAP)
section and keep the #endif tagged for __ASSEMBLER__.

* tag 'omap-for-v4.20/omap1-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
ARM: OMAP1: ams-delta: Don't request unused GPIOs
ARM: OMAP1: ams-delta-fiq: Use <linux/platform_data/gpio-omap.h>
ARM: OMAP1: ams-delta: register MODEM device earlier
ARM: OMAP1: ams-delta: initialize latch2 pins to safe values
ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+96 -88
+3 -9
arch/arm/mach-omap1/ams-delta-fiq-handler.S
··· 15 15 16 16 #include <linux/linkage.h> 17 17 #include <linux/platform_data/ams-delta-fiq.h> 18 + #include <linux/platform_data/gpio-omap.h> 18 19 19 20 #include <asm/assembler.h> 20 21 #include <mach/board-ams-delta.h> ··· 25 24 #include "soc.h" 26 25 27 26 /* 28 - * GPIO related definitions, copied from arch/arm/plat-omap/gpio.c. 29 - * Unfortunately, those were not placed in a separate header file. 27 + * OMAP1510 GPIO related symbol copied from arch/arm/mach-omap1/gpio15xx.c. 28 + * Unfortunately, it was not placed in a separate header file. 30 29 */ 31 30 #define OMAP1510_GPIO_BASE 0xFFFCE000 32 - #define OMAP1510_GPIO_DATA_INPUT 0x00 33 - #define OMAP1510_GPIO_DATA_OUTPUT 0x04 34 - #define OMAP1510_GPIO_DIR_CONTROL 0x08 35 - #define OMAP1510_GPIO_INT_CONTROL 0x0c 36 - #define OMAP1510_GPIO_INT_MASK 0x10 37 - #define OMAP1510_GPIO_INT_STATUS 0x14 38 - #define OMAP1510_GPIO_PIN_CONTROL 0x18 39 31 40 32 /* GPIO register bitmasks */ 41 33 #define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA)
+89 -72
arch/arm/mach-omap1/board-ams-delta.c
··· 250 250 #define LATCH2_PIN_HOOKFLASH1 14 251 251 #define LATCH2_PIN_HOOKFLASH2 15 252 252 253 - static const struct gpio latch_gpios[] __initconst = { 254 - { 255 - .gpio = LATCH1_GPIO_BASE + 6, 256 - .flags = GPIOF_OUT_INIT_LOW, 257 - .label = "dockit1", 258 - }, 259 - { 260 - .gpio = LATCH1_GPIO_BASE + 7, 261 - .flags = GPIOF_OUT_INIT_LOW, 262 - .label = "dockit2", 263 - }, 264 - { 265 - .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN, 266 - .flags = GPIOF_OUT_INIT_LOW, 267 - .label = "scard_rstin", 268 - }, 269 - { 270 - .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC, 271 - .flags = GPIOF_OUT_INIT_LOW, 272 - .label = "scard_cmdvcc", 273 - }, 274 - { 275 - .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14, 276 - .flags = GPIOF_OUT_INIT_LOW, 277 - .label = "hookflash1", 278 - }, 279 - { 280 - .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15, 281 - .flags = GPIOF_OUT_INIT_LOW, 282 - .label = "hookflash2", 283 - }, 284 - }; 285 - 286 253 static struct regulator_consumer_supply modem_nreset_consumers[] = { 287 254 REGULATOR_SUPPLY("RESET#", "serial8250.1"), 288 255 REGULATOR_SUPPLY("POR", "cx20442-codec"), ··· 287 320 }; 288 321 289 322 static struct modem_private_data modem_priv; 290 - 291 - void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) 292 - { 293 - int bit = 0; 294 - u16 bitpos = 1 << bit; 295 - 296 - for (; bit < ngpio; bit++, bitpos = bitpos << 1) { 297 - if (!(mask & bitpos)) 298 - continue; 299 - else 300 - gpio_set_value(base + bit, (value & bitpos) != 0); 301 - } 302 - } 303 - EXPORT_SYMBOL(ams_delta_latch_write); 304 323 305 324 static struct resource ams_delta_nand_resources[] = { 306 325 [0] = { ··· 583 630 {}, 584 631 }; 585 632 633 + static struct plat_serial8250_port ams_delta_modem_ports[]; 634 + 635 + /* 636 + * Obtain MODEM IRQ GPIO descriptor using its hardware pin 637 + * number and assign related IRQ number to the MODEM port. 638 + * Keep the GPIO descriptor open so nobody steps in. 639 + */ 640 + static void __init modem_assign_irq(struct gpio_chip *chip) 641 + { 642 + struct gpio_desc *gpiod; 643 + 644 + gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, 645 + "modem_irq"); 646 + if (IS_ERR(gpiod)) { 647 + pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, 648 + PTR_ERR(gpiod)); 649 + } else { 650 + gpiod_direction_input(gpiod); 651 + ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); 652 + } 653 + } 654 + 586 655 /* 587 656 * The purpose of this function is to take care of proper initialization of 588 657 * devices and data structures which depend on GPIO lines provided by OMAP GPIO ··· 624 649 return; 625 650 } 626 651 652 + /* 653 + * Start with FIQ initialization as it may have to request 654 + * and release successfully each OMAP GPIO pin in turn. 655 + */ 627 656 ams_delta_init_fiq(chip, &ams_delta_serio_device); 657 + 658 + modem_assign_irq(chip); 659 + } 660 + 661 + /* 662 + * Initialize latch2 pins with values which are safe for dependent on-board 663 + * devices or useful for their successull initialization even before GPIO 664 + * driver takes control over the latch pins: 665 + * - LATCH2_PIN_LCD_VBLEN = 0 666 + * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its 667 + * driver takes control over it. 668 + * - LATCH2_PIN_NAND_NCE = 0 669 + * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- 670 + * protected before its driver takes 671 + * control over it. 672 + * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio 673 + * driver takes control over it. 674 + * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first 675 + * byte of data received from attached 676 + * keyboard when serio device is probed; 677 + * the pin is also hogged low by the latch2 678 + * GPIO driver as soon as it is ready. 679 + * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for 680 + * its successful probe even before a 681 + * regulator it depends on, which in turn 682 + * takes control over the pin, is set up. 683 + * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port 684 + * to the MODEM so the CODEC is under 685 + * control even if audio driver doesn't 686 + * take it over. 687 + */ 688 + static void __init ams_delta_latch2_init(void) 689 + { 690 + u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; 691 + 692 + __raw_writew(latch2, LATCH2_VIRT); 628 693 } 629 694 630 695 static void __init ams_delta_init(void) ··· 688 673 omap_cfg_reg(J18_1610_CAM_D7); 689 674 690 675 omap_gpio_deps_init(); 676 + ams_delta_latch2_init(); 691 677 gpiod_add_hogs(ams_delta_gpio_hogs); 692 678 693 679 omap_serial_init(); ··· 829 813 static int __init ams_delta_gpio_init(void) 830 814 { 831 815 struct gpio_chip *chip; 832 - int err; 833 816 834 817 if (!machine_is_ams_delta()) 835 818 return -ENODEV; ··· 839 824 else 840 825 ams_delta_led_init(chip); 841 826 842 - err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios)); 843 - if (err) 844 - pr_err("Couldn't take over latch1/latch2 GPIO pins\n"); 845 - 846 - return err; 827 + return 0; 847 828 } 848 829 device_initcall_sync(ams_delta_gpio_init); 849 830 ··· 855 844 } 856 845 857 846 847 + /* 848 + * This function expects MODEM IRQ number already assigned to the port 849 + * and fails if it's not. 850 + * The MODEM device requires its RESET# pin kept high during probe. 851 + * That requirement can be fulfilled in several ways: 852 + * - with a descriptor of already functional modem_nreset regulator 853 + * assigned to the MODEM private data, 854 + * - with the regulator not yet controlled by modem_pm function but 855 + * already enabled by default on probe, 856 + * - before the modem_nreset regulator is probed, with the pin already 857 + * set high explicitly. 858 + * The last one is already guaranteed by ams_delta_latch2_init() called 859 + * from machine_init. 860 + * In order to avoid taking over ttyS0 device slot, the MODEM device 861 + * should be registered after OMAP serial ports. Since those ports 862 + * are registered at arch_initcall, this function can be called safely 863 + * at arch_initcall_sync earliest. 864 + */ 858 865 static int __init ams_delta_modem_init(void) 859 866 { 860 867 int err; 861 868 862 - omap_cfg_reg(M14_1510_GPIO2); 863 - ams_delta_modem_ports[0].irq = 864 - gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 869 + if (!machine_is_ams_delta()) 870 + return -ENODEV; 865 871 866 - err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); 867 - if (err) { 868 - pr_err("Couldn't request gpio pin for modem\n"); 869 - return err; 870 - } 871 - gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 872 + if (ams_delta_modem_ports[0].irq < 0) 873 + return ams_delta_modem_ports[0].irq; 874 + 875 + omap_cfg_reg(M14_1510_GPIO2); 872 876 873 877 /* Initialize the modem_nreset regulator consumer before use */ 874 878 modem_priv.regulator = ERR_PTR(-ENODEV); 875 879 876 - ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 877 - AMS_DELTA_LATCH2_MODEM_CODEC); 878 - 879 880 err = platform_device_register(&ams_delta_modem_device); 880 - if (err) 881 - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 882 881 883 882 return err; 884 883 } 884 + arch_initcall_sync(ams_delta_modem_init); 885 885 886 886 static int __init late_init(void) 887 887 { 888 888 int err; 889 889 890 890 err = modem_nreset_init(); 891 - if (err) 892 - return err; 893 - 894 - err = ams_delta_modem_init(); 895 891 if (err) 896 892 return err; 897 893 ··· 916 898 917 899 unregister: 918 900 platform_device_unregister(&ams_delta_modem_device); 919 - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 920 901 return err; 921 902 } 922 903
-7
arch/arm/mach-omap1/include/mach/board-ams-delta.h
··· 59 59 #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN 60 60 #define AMS_DELTA_LATCH2_NGPIO 16 61 61 62 - #ifndef __ASSEMBLY__ 63 - void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value); 64 - #define ams_delta_latch2_write(mask, value) \ 65 - ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \ 66 - AMS_DELTA_LATCH2_NGPIO, (mask), (value)) 67 - #endif 68 - 69 62 #endif /* CONFIG_MACH_AMS_DELTA */ 70 63 71 64 #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */
+4
include/linux/platform_data/gpio-omap.h
··· 24 24 #ifndef __ASM_ARCH_OMAP_GPIO_H 25 25 #define __ASM_ARCH_OMAP_GPIO_H 26 26 27 + #ifndef __ASSEMBLER__ 27 28 #include <linux/io.h> 28 29 #include <linux/platform_device.h> 30 + #endif 29 31 30 32 #define OMAP1_MPUIO_BASE 0xfffb5000 31 33 ··· 159 157 #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr)) 160 158 #define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES) 161 159 160 + #ifndef __ASSEMBLER__ 162 161 struct omap_gpio_reg_offs { 163 162 u16 revision; 164 163 u16 direction; ··· 218 215 { 219 216 } 220 217 #endif 218 + #endif /* __ASSEMBLER__ */ 221 219 222 220 #endif