From patchwork Sun Jan 10 12:09:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 360176 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2095446jai; Sun, 10 Jan 2021 04:11:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6CSinYRyKNKvmeikuooYMhWVP1Ji867B9pc2siJcsVsTknYk2FVGacgNLXT6Ua/EPhq8Z X-Received: by 2002:a17:902:e901:b029:dd:fa49:37f7 with SMTP id k1-20020a170902e901b02900ddfa4937f7mr10165089pld.51.1610280694442; Sun, 10 Jan 2021 04:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610280694; cv=none; d=google.com; s=arc-20160816; b=gyMPXOLwTLqGTd7gDQUfVJAk6Jkad5PtMnBlrf/cBRER2YLt91KxxSTZyj7FIEc9+n hl8gptkncQtb+yR985HPn2UO1sUBsi+mEmvdNVnmOyZjaYm4zDyCOhhnXdNwnI13X1mG krvSq8PS/UY7L97RfdcrKIF2AeS9xeLCF6ZMz3ofvgn67xhVYzPl2mcUcUkvR2riN5cw yGuT2VO5x1V8iDCGRMoCnNyj9vz7ia+St1cYK5Cc+RByCU9SzuZAQ8zRiRWkJQ8hZUf/ dGjMKZjgKPpfM9KMoHQ7gNP/YJ440VHSXc3hq+Ni6JVDv5sWcjA881fEe8YTqPGDqngw tC1A== 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=kzS5LLv84jVoA7SM1M06qm3Zi6y7NxvJamA+WIcEzBw=; b=jVyX02kZN4+KWkLxWD2Klx/w1ofMNLb/lnaRqRMe8N1uHz0T1Wf8Zef0ivE2Qd8HjK COoCwGecu+7pj54mqH90UXoOBCz7LV+qw8+vQRLIdpXokICRwyqQr35kToJZK9GmRTTx LGBLbnxs0AuouMSyAHamIv7t6ohtPWiIW2O3EhyWKH+XblGKvnlx6Iwx7aAcKBxX+Uny eXGG10VEbrrJVqv5mOPqmaFUPyWB/+xXrTBkr8WQVKNB7VuPgFnNqwQnWkLSMN4nSKRa 3PdWKPq805bhnSoKzGVTFWC+Q9nPGUUjsbuqnJF77FZsGzqBltoGe82QZP4RbQ4MAky1 L/mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="mMviX8/Q"; 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 p12si17420540pjn.160.2021.01.10.04.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jan 2021 04:11:34 -0800 (PST) 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="mMviX8/Q"; 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 AE36889F33; Sun, 10 Jan 2021 12:11:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CA1389F33 for ; Sun, 10 Jan 2021 12:11:30 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id s26so33799925lfc.8 for ; Sun, 10 Jan 2021 04:11:30 -0800 (PST) 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=qwB5BqbLAMqpioaBNvXy5eduTzHMYRCzAhFgFL4vxjw=; b=mMviX8/Qz3wgyxD+8g+2csJkoAwty4/sJZmqQjRz1y+jamI3dwOyHZYbgwO8v1QPYc n09MfAwIRP8oQx5b6VrOy4vXWSqcMvGFllV/tT9x+6m0h56PDzgti20Nqgbfr4kBEWHE 4vVnQckkcd8Zy/C38j2ilq7x/nkdm2wKyS7VMNtDxQveznYMQ0H+zmmVPsk1IBD/ntQI wER9V8QKzKG4ZoIhgxzfwsdTt1AE9BUWkbrFX/pmjin6PcRL7b3zx7Lj10ZdS5fO3kkp wZrs+ismjoDUjT4KXJ8dxY5KsyTqkz9PXhewDMiGMfyXAQJJH8LmseEMb+pXsS3i8B4g YB+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:mime-version :content-transfer-encoding; bh=qwB5BqbLAMqpioaBNvXy5eduTzHMYRCzAhFgFL4vxjw=; b=WzdsJWNHvrvqVmyvFK9Ikxisfo2DOhiXwbyEGfoaslA2qH/ATrYJHfp5lrU7w7Vvyc Jvt1yRkFzyrK0BHbC6XoiCO9rVObPbtiRXoD6PJvYcONI+lyT8TC0LDLb/sdtA8GfzYq 1kvBGnljfY0/Epe286bJkDAUPyKHawW/MWPRt/8KDU5UUbn31vwJbqwpP066dMWo9ui+ g77wwtBidCCL7sDTiNL7ZtFWZ+JtMLs6JeT9hnCXQbtaoHlrLX1GYAx1b4IlnFh3GG76 K+puxzz2b8FjtcbEYLOq7Ylj1JPUusnZODBRJcFZX5wbLY19DGBN0GJkGMt57BQGxMn6 pQmw== X-Gm-Message-State: AOAM532rLB25NJ3L+dp1//olY05zMD8ar/LDt3PzHLltx2Y0dcaSIlEt OxAsUWvAWe3xMqt1iX8S+cbo9w== X-Received: by 2002:a19:a405:: with SMTP id q5mr5667614lfc.503.1610280688854; Sun, 10 Jan 2021 04:11:28 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id b4sm2686674lfa.261.2021.01.10.04.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jan 2021 04:11:28 -0800 (PST) From: Linus Walleij To: Lee Jones , Daniel Thompson , Jingoo Han , dri-devel@lists.freedesktop.org Subject: [PATCH v8] backlight: lms283gf05: Convert to GPIO descriptors Date: Sun, 10 Jan 2021 13:09:26 +0100 Message-Id: <20210110120926.80471-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 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 v7->v8: - Rebase onto v5.11-rc1 - I wonder why this never seems to get merged...? ChangeLog v6->v7: - Rebase onto v5.10-rc1 ChangeLog v5->v6: - Rebase onto v5.9-rc1 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.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel Reviewed-by: Daniel Mack Acked-by: Mark Brown 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_ */