From patchwork Fri May 18 21:09:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10412199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDCD860230 for ; Fri, 18 May 2018 21:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC26D28AB7 for ; Fri, 18 May 2018 21:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0EBB28AF1; Fri, 18 May 2018 21:11:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2667828AB7 for ; Fri, 18 May 2018 21:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752020AbeERVKC (ORCPT ); Fri, 18 May 2018 17:10:02 -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-Google-Smtp-Source: AB8JxZoDO8l3+yNRv8iqnstxFMus3A891SucT5Ok5+rhjFqpyksqAZze9P0sad0zEGhd+krtepIaTg== 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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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");