Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4979799imm; Fri, 18 May 2018 14:10:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7gKG2We10lXC9XBYBVaXX8r9mbSuWuy+/e+jCvxKTy9Lsk7tzvmfAyExbQP0dPcYcTdjL X-Received: by 2002:a17:902:28ab:: with SMTP id f40-v6mr11166380plb.208.1526677846557; Fri, 18 May 2018 14:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526677846; cv=none; d=google.com; s=arc-20160816; b=X4YfC8qmRTsGk+OkMukiXKFA+dCSRcB8z8xvnmry3daf8wHIEZi/bn6uF32cvgzaRQ bctPRgZJZ6I2rBLIXffqX0aGvBzWbEeLslOR7i9kf4PZd51qo96XFnk2o8qRnnMvoslv hkpnBGXYI61nsbjVE1B/H16iFnwEIH/ClX8gcgLhKKGldtrkIsFBfnCrVBiXdOdSNKjz VV+PGFNa8ijN6RxZKMA/qgIZWnXEspwKF1bqcuSlqSM+5v9XReMabKmLJH66+0on81cR DPD/MBt2QgvMsjUWj2MKFtrjellnUcXGOn2DAYlYOqYARbZ6Ofpxp5IGa7BB94mNP+cW KyxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RFoxl4dusv56+Xviz0kHodBnY7F4hDuCrJOHClJlU9Y=; b=yVRp4uxEWxZsfJTzCIH+FkblsmiATNliGa9WD/iSI7x6nxDhj4iCTpGqyxItQ09xPW ew7OrjHXW8f9Zt8TF04tYvgAE7Kz2254utisiyVDw4ci0fmuxyw440meSWxjME/eTjbb SqPy42sA3KKq8u4CjvhLEcVoCElLMNErF71gwy5r3Xy3q/0ah5UMPIPDU5stF+zeCRnX eFXbXH7eJ2FignEDIFGBVEekznc0spz5yBoAdu+F1cZzUC4CXen5iHyXhUJNnPf1l/EI JH/k7VP+7zfmrtOAgmqUBelVdEWKFVWHv6HFM6QU3o83RVNTNRv6EHSSrLW4i0w5UUYG 2YYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CK6O2IN2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10-v6si6475078pge.245.2018.05.18.14.10.32; Fri, 18 May 2018 14:10:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CK6O2IN2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752112AbeERVKE (ORCPT + 99 others); Fri, 18 May 2018 17:10:04 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34045 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbeERVKB (ORCPT ); Fri, 18 May 2018 17:10:01 -0400 Received: by mail-lf0-f68.google.com with SMTP id x145-v6so3862849lff.1; Fri, 18 May 2018 14:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RFoxl4dusv56+Xviz0kHodBnY7F4hDuCrJOHClJlU9Y=; b=CK6O2IN2gVtgJEAZT5hcRmiCSxFKrW92/outOHi/kKY/XE43EWT4U8od8HWXCNTuzf P2fWBBaIwfNQIuklynjOVc6g23utIJhBJn0uJf8JeP+e8ls4+T7KlrjtvRIcR4garGPf HbnwPVYU7XUYmE8J7/ce3oJrVYaQWjEq3GeCPhRb9DQCNWasJy8C/ugn/RmEmJk7F4Bm 6Z2ejbTeJnbHnXTMBhLCm6NwfZKbxLybTLB1fQTu06cNSo8uOYIbuO5xz+7M7d/3oe4u +CypUaZ8Is574Oma7nMhzJFtsYY3tstcfZjWIvxJloKZpbUMZsLZbfIdNOOg8k+Ylqiy sQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RFoxl4dusv56+Xviz0kHodBnY7F4hDuCrJOHClJlU9Y=; b=uG0aRAN0caiEnGhNYyxv+zlZxT8LBgLhWTU/0Q+SUJFJTaU/9MkSsPpLpbnZdvTAy8 sNQLw4rwxOqUVDGnsDU53nPTOMurgdtlB6z38meQNEd7xiRfG9dmPHM6Tqi5/bm+m4Lf sMt8QGtNLsZ0qtWCU4cXWNOHCie1se1rsd2i6YwXoCsRppQOw9DHyYzicQ/hc52TSFUg DgMyJTgG0/KOX4/WF3Nxz+43ivP2bJNTM1d1HsF9LLYY8NithXuo9urH2XbsY5kgPFPE y/Dl6PqLYNLE0XX7G22YGOkmjjjW719r3NM5f0t1zK72ruLW36DyqDmWRrIfpX+dOsPg +4mg== X-Gm-Message-State: ALKqPwfCL6BRKNcF0e7I9/EAUCuigbHkF0bAVZxXLg7SCD6Ih5D1+f8E 7BPWS5BSWzpZTSz4Npwk7cI= X-Received: by 2002:a2e:9248:: with SMTP id v8-v6mr6916423ljg.133.1526677799054; Fri, 18 May 2018 14:09:59 -0700 (PDT) Received: from localhost.localdomain (apn-31-0-34-132.dynamic.gprs.plus.pl. [31.0.34.132]) by smtp.gmail.com with ESMTPSA id 23-v6sm2057026lfw.64.2018.05.18.14.09.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 14:09:58 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren , Dmitry Torokhov , Boris Brezillon , Tomi Valkeinen , Mark Brown Cc: Aaro Koskinen , Richard Weinberger , Peter Ujfalusi , Jarkko Nikula , Liam Girdwood , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, Janusz Krzysztofik Subject: [PATCH 1/6] ARM: OMAP1: ams-delta: add GPIO lookup tables Date: Fri, 18 May 2018 23:09:49 +0200 Message-Id: <20180518210954.29044-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Scope of the change is limited to GPIO pins used by board specific device drivers which will be updated by follow-up patches of the series. Those are some OMAP GPIO (gpio-0-15) and most of Amstrad Delta latch2 GPIO bank pins. Remaining pins of those banks, as well as Amstrad Delta latch1 pins, will be addressed later. Assign a label ("latch2") to the bank, enumerate its pins and put that information, together with OMAP GPIO bank pins, in GPIO lookup tables. Assign lookup tables to devices as soon as those devices are registered and their names can be obtained. A step froward in: - removal of hard-coded GPIO numbers from drivers, - removal of board mach includes from drivers, - switching to dynamically assigned GPIO numbers. Created and compile tested agains linux-4.17-rc3 Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 52e8e53ca154..4b78e73f8bf7 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ #include +#include #include #include #include @@ -202,7 +203,10 @@ static struct resource latch2_resources[] = { }, }; +#define LATCH2_LABEL "latch2" + static struct bgpio_pdata latch2_pdata = { + .label = LATCH2_LABEL, .base = AMS_DELTA_LATCH2_GPIO_BASE, .ngpio = AMS_DELTA_LATCH2_NGPIO, }; @@ -217,6 +221,23 @@ static struct platform_device latch2_gpio_device = { }, }; +#define LATCH2_PIN_LCD_VBLEN 0 +#define LATCH2_PIN_LCD_NDISP 1 +#define LATCH2_PIN_NAND_NCE 2 +#define LATCH2_PIN_NAND_NRE 3 +#define LATCH2_PIN_NAND_NWP 4 +#define LATCH2_PIN_NAND_NWE 5 +#define LATCH2_PIN_NAND_ALE 6 +#define LATCH2_PIN_NAND_CLE 7 +#define LATCH2_PIN_KEYBRD_PWR 8 +#define LATCH2_PIN_KEYBRD_DATAOUT 9 +#define LATCH2_PIN_SCARD_RSTIN 10 +#define LATCH2_PIN_SCARD_CMDVCC 11 +#define LATCH2_PIN_MODEM_NRESET 12 +#define LATCH2_PIN_MODEM_CODEC 13 +#define LATCH2_PIN_HOOKFLASH1 14 +#define LATCH2_PIN_HOOKFLASH2 15 + static const struct gpio latch_gpios[] __initconst = { { .gpio = LATCH1_GPIO_BASE + 6, @@ -323,6 +344,22 @@ static struct platform_device ams_delta_nand_device = { .resource = ams_delta_nand_resources, }; +#define OMAP_GPIO_LABEL "gpio-0-15" + +static struct gpiod_lookup_table ams_delta_nand_gpio_table = { + .table = { + GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy", + 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0), + { }, + }, +}; + static struct resource ams_delta_kp_resources[] = { [0] = { .start = INT_KEYBOARD, @@ -358,6 +395,14 @@ static struct platform_device ams_delta_lcd_device = { .id = -1, }; +static struct gpiod_lookup_table ams_delta_lcd_gpio_table = { + .table = { + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp", 0), + { }, + }, +}; + static const struct gpio_led gpio_leds[] __initconst = { { .name = "camera", @@ -449,11 +494,35 @@ static struct platform_device ams_delta_audio_device = { .id = -1, }; +static struct gpiod_lookup_table ams_delta_audio_gpio_table = { + .table = { + GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH, + "hook_switch", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC, + "modem_codec", 0), + { }, + }, +}; + static struct platform_device cx20442_codec_device = { .name = "cx20442-codec", .id = -1, }; +static struct gpiod_lookup_table ams_delta_serio_gpio_table = { + .table = { + GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_DATA, + "data", 0), + GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_CLK, + "clock", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, + "power", 0), + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, + "dataout", 0), + { }, + }, +}; + static struct platform_device *ams_delta_devices[] __initdata = { &latch1_gpio_device, &latch2_gpio_device, @@ -468,6 +537,16 @@ static struct platform_device *late_devices[] __initdata = { &cx20442_codec_device, }; +static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { + &ams_delta_audio_gpio_table, + &ams_delta_serio_gpio_table, +}; + +static struct gpiod_lookup_table *late_gpio_tables[] __initdata = { + &ams_delta_lcd_gpio_table, + &ams_delta_nand_gpio_table, +}; + static void __init ams_delta_init(void) { /* mux pins for uarts */ @@ -500,6 +579,20 @@ static void __init ams_delta_init(void) gpio_led_register_device(-1, &leds_pdata); platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); + /* + * As soon as devices have been registered, assign their dev_names + * to respective GPIO lookup tables before they are added. + */ + ams_delta_audio_gpio_table.dev_id = + dev_name(&ams_delta_audio_device.dev); + /* + * No device name is assigned to GPIO lookup table for serio device + * as long as serio driver is not converted to platform device driver. + */ + + gpiod_add_lookup_tables(ams_delta_gpio_tables, + ARRAY_SIZE(ams_delta_gpio_tables)); + ams_delta_init_fiq(); omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); @@ -570,6 +663,15 @@ static int __init late_init(void) platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); + /* + * As soon as devices have been registered, assign their dev_names + * to respective GPIO lookup tables before they are added. + */ + ams_delta_lcd_gpio_table.dev_id = dev_name(&ams_delta_lcd_device.dev); + ams_delta_nand_gpio_table.dev_id = dev_name(&ams_delta_nand_device.dev); + + gpiod_add_lookup_tables(late_gpio_tables, ARRAY_SIZE(late_gpio_tables)); + err = platform_device_register(&modem_nreset_device); if (err) { pr_err("Couldn't register the modem regulator device\n"); -- 2.16.1