From patchwork Thu Jun 25 23:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 191752 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp1715765ecs; Thu, 25 Jun 2020 16:22:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCWPjMcX9pjUBN8RLam1KMQuaR7NaD0bAoO9VMvkEwE6PsfNavKv9WCcgZEc7FAdvVJIBN X-Received: by 2002:a17:90a:ac0f:: with SMTP id o15mr372161pjq.105.1593127372631; Thu, 25 Jun 2020 16:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593127372; cv=none; d=google.com; s=arc-20160816; b=UbMrOJ/cU8HhMuwVV0DiUxAk0Jq4xxH8W3Xv9Fa9Lq/YfaZ3qFGNyUo+uYakALiBTq nTyuJHrXVFoPWrRPvC4uRN9tC0XUFMiSse8TDnZKqmRjbDuiqNJH9s6GMEu6TpaonYGb NSOoh6TuKYjGnX4IY8COf4j4RsIdaSMQGOmLv7/VOWqzZla6qQTZPcI+acmPfZo7iean WhuP0IkrQ61xlLKBzgBczb25iRa4WHu7fyLnEDsKZ4IN80J60LnanhYhU+GEH01XTK0L X6ZBCcRetosNOFWap2Cu8Lu+RUkOSTl/z0boJhUi75fzWVlJ5DWcPUFaH/3W7SFJlfRU Tc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=31HTaDukwPskntJn42Aq+pDzhs1SGVNzS3C/UuIPAbs=; b=o2a2naGG7vJLhmVd+w5FkAVxb8/HUMwIj8zneeAi80OxgezYLugdG0XXOQ05ZjWF8E ihQ2Wl2LLYZogl7DN2ZG2/yGCi4teA3eNxy/W+T9Er4pGkeZrRYkS0h0gx62vvUVNyHU 6JDVu59I5n+0l/9DvGb3fgm9Jy71GIc1Wf1QoztbpsFXJgens5PoqZBeBawYSQ1t+i/z nR2XXBEXEExKdss9CYIvoTte4OKyzv2u2Ycaw043UNPIeMEkozdTpSys6Hcv6M3lCI0c 6qnbbShP17PKYZ73SUfVF94x0rCJIB2F0oPJd+QXYekW6Hxubl5WhyYXHK8iIX4Zq0PE Wa1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="ffdP/+cB"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id v17si15033472pgo.388.2020.06.25.16.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 16:22:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="ffdP/+cB"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 436E56E375; Thu, 25 Jun 2020 23:22:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by gabe.freedesktop.org (Postfix) with ESMTPS id F28326E375 for ; Thu, 25 Jun 2020 23:22:46 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id u25so4162973lfm.1 for ; Thu, 25 Jun 2020 16:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tr5qRrIpaLHqwbCI73R/8nLDwutFHOOPxOya0UymHGM=; b=ffdP/+cBZWymdXaarp7OKl6i5AkMYNiPogXfk/e2W6mWu87NWP3eGjnxfpBjrr+QMk UTyH2KVlNJ+PYG2eDusMT4vtAjIJOtVGvrbUTQxbrpRNg63GSiZpbNqlmp78uTmg1oa1 jfK800usFfaXeozQrnktaguFMr0ncDAW1aZt4ktYuX2AbI3NhkBfhL36lvYHlI1pc62J hkx2XQfC98kOJpS/3nk9yEhTTEy2ovrMhR/7aPzVMerCsg9S7Udyp2eZym9cEqbggryd ZckUVhYXuy4vBjM+918Ly3FZkke0UpQdnv26lm4pLHz8X0m2enB0rJy+MDuycRiUPuRe kQCw== 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:mime-version :content-transfer-encoding; bh=tr5qRrIpaLHqwbCI73R/8nLDwutFHOOPxOya0UymHGM=; b=GJUdOGW3vahjHRDsYQiae7ie9EiyHxETbguwOeyW4b0y9Y9L+ZpPoHXtZ35zBEMF3i 1AyAdjfsY9+dEd5+zpNErMIYdws8kQeawgqk0nXukR5UT9hZ+9+SmX6xTyFlACEYyDNt 32xbMWDHDV4jMT7s0OHhN4ozWCk46qbB+HAbY14VgkPaH89jaSJKJCDkZMJ3YQA1wDTt U+vNFiW5GNtgMh4hBYJ/3YfEQhhtPFbrfVl0mTa4UFrH7hNka4rhZYGWpqD8SFsNa87d CBxw70UxeCKrpy72N9Te0NAFexYL6BY29D5dN91eJDcpUzZfQfnw0zo2Gok137NxPpLX 7Fjw== X-Gm-Message-State: AOAM532JeqX/FGWnaxchU41WZ6A5iprbeVw2JuygjgExuL+6W43542x+ E+kFtRQsXdYHs++VFxAUBskMTA== X-Received: by 2002:a19:7f55:: with SMTP id a82mr236235lfd.112.1593127365276; Thu, 25 Jun 2020 16:22:45 -0700 (PDT) Received: from genomnajs.lan (c-d63ee155.152980-0-69706f6e6c79.bbcust.telenor.se. [85.225.62.214]) by smtp.gmail.com with ESMTPSA id v12sm4894672lfp.12.2020.06.25.16.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 16:22:44 -0700 (PDT) From: Linus Walleij To: Lee Jones , Daniel Thompson , Jingoo Han , dri-devel@lists.freedesktop.org Subject: [PATCH v5] backlight: lms283gf05: Convert to GPIO descriptors Date: Fri, 26 Jun 2020 01:22:40 +0200 Message-Id: <20200625232240.281737-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Robert Jarzmik , Haojian Zhuang , Daniel Mack Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This converts the lms283gf05 backlight driver to use GPIO descriptors and switches the single PXA Palm Z2 device over to defining these. Since the platform data was only used to convey GPIO information we can delete the platform data header. Notice that we define the proper active low semantics in the board file GPIO descriptor table (active low) and assert the reset line by bringing it to "1" (asserted). Cc: Marek Vasut Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Reviewed-by: Daniel Thompson Signed-off-by: Linus Walleij --- ChangeLog v4->v5: - Rebase on v5.8-rc1 - Collected Daniel's Reviewed-by tag. ChangeLog v3->v4: - Check IS_ERR() on the returned GPIO descriptor. - Unconditionally set consumer name since the API tolerates NULL. ChangeLog v2->v3: - Fix a use-before-allocated bug discovered by compile tests. - Remove unused ret variable as autobuilders complained. ChangeLog v1->v2: - Bring up the GPIO de-asserted in probe() Marek: I saw this was written by you, are you regularly testing the Z2 device? --- arch/arm/mach-pxa/z2.c | 12 +++++--- drivers/video/backlight/lms283gf05.c | 43 +++++++++++----------------- include/linux/spi/lms283gf05.h | 16 ----------- 3 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 include/linux/spi/lms283gf05.h -- 2.25.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c index 21fd76bb09cd..89eb5243c85f 100644 --- a/arch/arm/mach-pxa/z2.c +++ b/arch/arm/mach-pxa/z2.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -578,8 +577,13 @@ static struct pxa2xx_spi_chip lms283_chip_info = { .gpio_cs = GPIO88_ZIPITZ2_LCD_CS, }; -static const struct lms283gf05_pdata lms283_pdata = { - .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET, +static struct gpiod_lookup_table lms283_gpio_table = { + .dev_id = "spi2.0", /* SPI bus 2 chip select 0 */ + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET, + "reset", GPIO_ACTIVE_LOW), + { }, + }, }; static struct spi_board_info spi_board_info[] __initdata = { @@ -595,7 +599,6 @@ static struct spi_board_info spi_board_info[] __initdata = { { .modalias = "lms283gf05", .controller_data = &lms283_chip_info, - .platform_data = &lms283_pdata, .max_speed_hz = 400000, .bus_num = 2, .chip_select = 0, @@ -615,6 +618,7 @@ static void __init z2_spi_init(void) { pxa2xx_set_spi_info(1, &pxa_ssp1_master_info); pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); + gpiod_add_lookup_table(&lms283_gpio_table); spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); } #else diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index 0e45685bcc1c..36856962ed83 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c @@ -9,16 +9,16 @@ #include #include #include -#include +#include #include #include -#include #include struct lms283gf05_state { struct spi_device *spi; struct lcd_device *ld; + struct gpio_desc *reset; }; struct lms283gf05_seq { @@ -90,13 +90,13 @@ static const struct lms283gf05_seq disp_pdwnseq[] = { }; -static void lms283gf05_reset(unsigned long gpio, bool inverted) +static void lms283gf05_reset(struct gpio_desc *gpiod) { - gpio_set_value(gpio, !inverted); + gpiod_set_value(gpiod, 0); /* De-asserted */ mdelay(100); - gpio_set_value(gpio, inverted); + gpiod_set_value(gpiod, 1); /* Asserted */ mdelay(20); - gpio_set_value(gpio, !inverted); + gpiod_set_value(gpiod, 0); /* De-asserted */ mdelay(20); } @@ -125,18 +125,15 @@ static int lms283gf05_power_set(struct lcd_device *ld, int power) { struct lms283gf05_state *st = lcd_get_data(ld); struct spi_device *spi = st->spi; - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); if (power <= FB_BLANK_NORMAL) { - if (pdata) - lms283gf05_reset(pdata->reset_gpio, - pdata->reset_inverted); + if (st->reset) + lms283gf05_reset(st->reset); lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); } else { lms283gf05_toggle(spi, disp_pdwnseq, ARRAY_SIZE(disp_pdwnseq)); - if (pdata) - gpio_set_value(pdata->reset_gpio, - pdata->reset_inverted); + if (st->reset) + gpiod_set_value(st->reset, 1); /* Asserted */ } return 0; @@ -150,24 +147,18 @@ static struct lcd_ops lms_ops = { static int lms283gf05_probe(struct spi_device *spi) { struct lms283gf05_state *st; - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); struct lcd_device *ld; - int ret = 0; - - if (pdata != NULL) { - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, - GPIOF_DIR_OUT | (!pdata->reset_inverted ? - GPIOF_INIT_HIGH : GPIOF_INIT_LOW), - "LMS283GF05 RESET"); - if (ret) - return ret; - } st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), GFP_KERNEL); if (st == NULL) return -ENOMEM; + st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(st->reset)) + return PTR_ERR(st->reset); + gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET"); + ld = devm_lcd_device_register(&spi->dev, "lms283gf05", &spi->dev, st, &lms_ops); if (IS_ERR(ld)) @@ -179,8 +170,8 @@ static int lms283gf05_probe(struct spi_device *spi) spi_set_drvdata(spi, st); /* kick in the LCD */ - if (pdata) - lms283gf05_reset(pdata->reset_gpio, pdata->reset_inverted); + if (st->reset) + lms283gf05_reset(st->reset); lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); return 0; diff --git a/include/linux/spi/lms283gf05.h b/include/linux/spi/lms283gf05.h deleted file mode 100644 index f237b2d062e9..000000000000 --- a/include/linux/spi/lms283gf05.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * lms283gf05.h - Platform glue for Samsung LMS283GF05 LCD - * - * Copyright (C) 2009 Marek Vasut -*/ - -#ifndef _INCLUDE_LINUX_SPI_LMS283GF05_H_ -#define _INCLUDE_LINUX_SPI_LMS283GF05_H_ - -struct lms283gf05_pdata { - unsigned long reset_gpio; - bool reset_inverted; -}; - -#endif /* _INCLUDE_LINUX_SPI_LMS283GF05_H_ */