Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2232648imm; Sun, 9 Sep 2018 19:41:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZfQiRzDS4e0NWEBffeS0hrgrhbNHXVRmD2txn1VT5jh8VUDDL1TbwuetrY0ZTLAGzk77Ns X-Received: by 2002:a63:fe02:: with SMTP id p2-v6mr20441335pgh.148.1536547282394; Sun, 09 Sep 2018 19:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536547282; cv=none; d=google.com; s=arc-20160816; b=nbl2iTbvGOKCqf0MoR+2O6yp8h9E1QAPZZb3Uc+xMiS48wqmd5x/m2XydMahEl/GFK uNOAOAnburiFbzXexkBXSOX66BMgh0/Cgu47oODvzD0JBu7m8+h9aoOp7Q9cLUKuckk0 C4PjtWqnp0dn/ADN/N//WTI8vRBN2uHlsHUsqa0Nxo9vjpYcjfg7tlMGDY+sidHjOdBA Jq2ohT6u9Tmt1doEUmx1tLy7z6CYR8U41o5kE2XOCl8aUQ270v1uwRn8XjwT3rdoRKrK eqhEFvvZLGgrnzBULzAx2r/e6KujsuD5BoUjxDo+wKZg10Qgy35if9elL6oWqFSiY2wL Lu2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=XoqN39JitX7xZtkRTukcI6J9+V8DE/e1EcuIx9Flh4Y=; b=Fu8jrRx3008u8j7yIHa+kcJ9yIRvFhugdBwxLjiMw1mCAmz+b16FPJm2UtXNPG7oo6 kyqkKhsfEGBOVoopLCNYmlTpjILPjApNXamPFgXeYQSDIC/uEGGx9fmea81v0i2YjHh/ q12uCf2I3vaj8byFxM29V6af4ubwt4nx7ecSYA7pL8QGtTZ4oRfr5dxg1bOaG/cAmLE9 xw+swJsprE5fP98/dDhWMGVOoC2IKDcAJGgcvjq2l8S4zXQZtYXCdr9HDzSWU+uZBClU 2tIAc3sTo24VGnIKWa7Lxo6Cb3iSJYyME0bjra8fm6dITyaxyY0pHlNI44CTvmO56v9S v0WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=avzo7uE1; 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 b5-v6si16595221pgd.54.2018.09.09.19.41.05; Sun, 09 Sep 2018 19:41:22 -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=avzo7uE1; 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 S1726150AbeIJHbl (ORCPT + 99 others); Mon, 10 Sep 2018 03:31:41 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45443 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbeIJHbl (ORCPT ); Mon, 10 Sep 2018 03:31:41 -0400 Received: by mail-lf1-f66.google.com with SMTP id r4-v6so16131129lff.12; Sun, 09 Sep 2018 19:39:56 -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:in-reply-to:references; bh=XoqN39JitX7xZtkRTukcI6J9+V8DE/e1EcuIx9Flh4Y=; b=avzo7uE1j7gj2PvtAGafXmxdWetQfTv9sHM9tsuLYh61cMk+fMFuSX2ZDWCYArw/Im RLvTeMEgLC0i15v5ZBTlT8yMfF13qaC436YECuAjbe0eIgYbHBkEaJq0CYt1cD9tpLik zhH+Kwt/7bo85TbefIwj5Z563fA9n8ly/PPPpH1zqg4+hN8QAMnEmIUq94IxF05lg078 /RrQATfxSHLZCOc0Zm246zuVAlqrvMZ4mt7s9rpAkJW3aNlNY+kl+lAWSUkl9KMoXsya 6w86nh5UTTJjlqS1nrL/Rq5gkljM5OHn7M4Z26YyVMbxvcnA0+2Y0iVZtz3n9aJS5LSR L2SA== 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:in-reply-to :references; bh=XoqN39JitX7xZtkRTukcI6J9+V8DE/e1EcuIx9Flh4Y=; b=nso+gayoE6tx34fKlBbK1ynuHjzWSIpQ3oZi61EAiRQ6TEPQzBKGh7lywZXU3s9v+Q Vs50unPFnwrdZlZCNre3YgOvrLwMGxYqkQymnt5Fi8kLbM/2Z9KYOConpnEk0G8KxCAN T4FFM3WXLU7F/Xl2xfu905UaIpdEMU6v9OX5RM/MpeFA76zU3z9xw59gwWY4lrI5KwYa oOwKSu+4JJpNIf1IQE0jLyGbMgL1Qt+BnPAX9fbBEBSiAU4Nng9pdASzjoWc8qfXt7Fl JRBnfKXLXp/LzyfkLmZIcrZM4u7lrCYx4siutqD7SUVITqkhyDAmsLMakp3AsPeVw4DF b3rA== X-Gm-Message-State: APzg51B4O640nAveG5birsWSQG/E3v1kSrKRyDTZoS/ywUMxwt3cT8wC mhBdqatUjZQ1aDkSaJSrGD9Mhp8oTSc= X-Received: by 2002:a19:944d:: with SMTP id w74-v6mr10386025lfd.10.1536533707266; Sun, 09 Sep 2018 15:55:07 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id v10-v6sm2401574ljg.12.2018.09.09.15.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 15:55:06 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Cc: Linus Walleij , Aaro Koskinen , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Bartlomiej Zolnierkiewicz , Janusz Krzysztofik , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table Date: Mon, 10 Sep 2018 00:56:03 +0200 Message-Id: <20180909225605.16463-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180909225605.16463-1-jmkrzyszt@gmail.com> References: <20180717231448.14958-1-jmkrzyszt@gmail.com> <20180909225605.16463-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now as Amstrad Delta board - the only user of this driver - provides GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and use the table to locate required GPIO pins. Declare static variables for storing GPIO descriptors and replace gpio_ function calls with their gpiod_ equivalents. Move GPIO lookup to the driver probe function so device initialization can be deferred instead of aborted if a GPIO pin is not yet available. Pin naming used by the driver should be followed while respective GPIO lookup table is initialized by a board init code. Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Janusz Krzysztofik --- drivers/video/fbdev/omap/lcd_ams_delta.c | 55 +++++++++++++------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/drivers/video/fbdev/omap/lcd_ams_delta.c b/drivers/video/fbdev/omap/lcd_ams_delta.c index e8c748a0dfe2..cddbd00cbf9f 100644 --- a/drivers/video/fbdev/omap/lcd_ams_delta.c +++ b/drivers/video/fbdev/omap/lcd_ams_delta.c @@ -24,11 +24,10 @@ #include #include #include +#include #include -#include #include -#include #include "omapfb.h" @@ -41,6 +40,8 @@ /* LCD class device section */ static int ams_delta_lcd; +static struct gpio_desc *gpiod_vblen; +static struct gpio_desc *gpiod_ndisp; static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) { @@ -99,41 +100,17 @@ static struct lcd_ops ams_delta_lcd_ops = { /* omapfb panel section */ -static const struct gpio _gpios[] = { - { - .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN, - .flags = GPIOF_OUT_INIT_LOW, - .label = "lcd_vblen", - }, - { - .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP, - .flags = GPIOF_OUT_INIT_LOW, - .label = "lcd_ndisp", - }, -}; - -static int ams_delta_panel_init(struct lcd_panel *panel, - struct omapfb_device *fbdev) -{ - return gpio_request_array(_gpios, ARRAY_SIZE(_gpios)); -} - -static void ams_delta_panel_cleanup(struct lcd_panel *panel) -{ - gpio_free_array(_gpios, ARRAY_SIZE(_gpios)); -} - static int ams_delta_panel_enable(struct lcd_panel *panel) { - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1); - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1); + gpiod_set_value(gpiod_ndisp, 1); + gpiod_set_value(gpiod_vblen, 1); return 0; } static void ams_delta_panel_disable(struct lcd_panel *panel) { - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0); - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0); + gpiod_set_value(gpiod_vblen, 0); + gpiod_set_value(gpiod_ndisp, 0); } static struct lcd_panel ams_delta_panel = { @@ -154,8 +131,6 @@ static struct lcd_panel ams_delta_panel = { .pcd = 0, .acb = 37, - .init = ams_delta_panel_init, - .cleanup = ams_delta_panel_cleanup, .enable = ams_delta_panel_enable, .disable = ams_delta_panel_disable, }; @@ -166,9 +141,23 @@ static struct lcd_panel ams_delta_panel = { static int ams_delta_panel_probe(struct platform_device *pdev) { struct lcd_device *lcd_device = NULL; -#ifdef CONFIG_LCD_CLASS_DEVICE int ret; + gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_vblen)) { + ret = PTR_ERR(gpiod_vblen); + dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret); + return ret; + } + + gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_ndisp)) { + ret = PTR_ERR(gpiod_ndisp); + dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret); + return ret; + } + +#ifdef CONFIG_LCD_CLASS_DEVICE lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, &ams_delta_lcd_ops); -- 2.16.4