Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1772761rdb; Thu, 7 Dec 2023 08:23:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs+27KTb8IBTMj7NggBwT85V49N7kGombTW9vJPxdEdOauxc/rODkLtoKcraiEIeB0fZwT X-Received: by 2002:a05:6a20:8f28:b0:188:444e:2b6c with SMTP id b40-20020a056a208f2800b00188444e2b6cmr3833692pzk.49.1701966215243; Thu, 07 Dec 2023 08:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701966215; cv=none; d=google.com; s=arc-20160816; b=Ekn8pbIiwllGQA5poE+TidQz+qhOSIURXnUIptNXfX40WFQ0Wgljw3f+KC1+FKnFw7 mRlGqGLrittW/92UYX97DnfPWHkG2Ym6M9bC9HyriL7fsnD/UjUCzmfbbsNsdiQWtuTN gfsLqJ7xtsKFuUkG0HWAIMMIC0bh498hiCdGL2Ej1ckfIV8yX3VkBPJAlA4YkiAAjPGU eKkj2c1rxE5u0evNXW8AVmgCG1mFszw1acjqePI20/LLCUE1hKZc08t/DmpW2+onFOSQ ljc6CiKu4vo2C5FuE97k63YFGVs5lHJ4xzyxZLSgKtUIqS/Yz+HBqp7tZLw2FbYyx9YU /qdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ubr4+ErEzlhujSsC6C8Ea0ksG6mRaqsNZIPdogmybMI=; fh=QNK77n7HB5IyP0raIxeDSUyUx2MtY40UZVuFeGUZS2M=; b=DgWu+sGT3+4mnnMUqU1OZyOwdnAB9z6Fs3rYoHGkdktM01Xk9pORBhAoJtxdIrv4RF 21OO0Dbyt3+KfCJSStEq+hUznCZPWotA6hYJeHw48qx2gJCANBSIoYMztaVvHzHJrqC4 HnX1RpcIWPNmzhrTnK+22cjQYSQ4pmKp447gQF2eRoY+o/MacoAF5zH0dePlrYIsy+L5 oU61KvHKAMq9FIlVwpm+GH0qyvV3YR7eOyRXuFyFF5oyJt7OOGltx9tJQMd5og1i0EI2 NBJxgW3iJvSNxp0EYWezwGjAOFMzdyShCG1TACMtWFEHyf7ZQ2vJuoBGDqCSog7Ny6qM fyLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a6U9kvS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kr12-20020a056a004b4c00b006cec77b95a3si202370pfb.279.2023.12.07.08.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 08:23:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a6U9kvS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E933F80BCF4A; Thu, 7 Dec 2023 08:23:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232616AbjLGQXQ (ORCPT + 99 others); Thu, 7 Dec 2023 11:23:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbjLGQXP (ORCPT ); Thu, 7 Dec 2023 11:23:15 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3730B2; Thu, 7 Dec 2023 08:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701966201; x=1733502201; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=8+BxMMeY/Dw2CxqFJw7s1TVTKBcrVitZzQXCsmGEH6Y=; b=a6U9kvS4uAO0MrJcUy/gNVpI0EcDt5XXao9SYfqimmxt515fzarnqiCb 5IiuSnj6Ts2T6DBPOr/HGGOC73ghkkKkW0EE4mCykpbwlRnncq/kHsnB6 K3T8U7VK/jbAF5+uxWRAC0eT0OSdDhdB2vqXHrRGOmsoG1rcKCZV0Kuij fI2O5dlNpwUVjGZa/bWhKjDP0P92iSb5PGE9J6hB9IRA63ojNTj9AJr5G 5OOr5cMppqCqJ3p9/CZI5viD/b7KwQh0c+qjzo9qaFpmxIQ05zQsNmFV+ qPDcgZw3D1hXkfKQL5N0799w5GYqyHO2isbJN9taX0VZa4HNWy2SiWDaD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="397049190" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="397049190" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 08:23:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="765154385" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="765154385" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2023 08:23:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 783B6591; Thu, 7 Dec 2023 18:15:25 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Daniel Thompson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Lee Jones , Jingoo Han , Helge Deller Subject: [PATCH v2 1/1] backlight: hx8357: Convert to agnostic GPIO API Date: Thu, 7 Dec 2023 18:14:32 +0200 Message-ID: <20231207161513.3195509-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 07 Dec 2023 08:23:32 -0800 (PST) The of_gpio.h is going to be removed. In preparation of that convert the driver to the agnostic API. Reviewed-by: Daniel Thompson Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines with legacy bindings") Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- v2: collected tags (Linus, Daniel), added Fixes tag (Linus) drivers/gpio/gpiolib-of.c | 4 +- drivers/video/backlight/hx8357.c | 74 ++++++++++---------------------- 2 files changed, 24 insertions(+), 54 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 402f7d99b0c1..e7770eedd146 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -184,7 +184,7 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np, const char *propname; bool active_high; } gpios[] = { -#if !IS_ENABLED(CONFIG_LCD_HX8357) +#if IS_ENABLED(CONFIG_LCD_HX8357) /* * Himax LCD controllers used incorrectly named * "gpios-reset" property and also specified wrong @@ -478,7 +478,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, */ const char *compatible; } gpios[] = { -#if !IS_ENABLED(CONFIG_LCD_HX8357) +#if IS_ENABLED(CONFIG_LCD_HX8357) /* Himax LCD controllers used "gpios-reset" */ { "reset", "gpios-reset", "himax,hx8357" }, { "reset", "gpios-reset", "himax,hx8369" }, diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index f76d2469d490..d7298376cf74 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -6,11 +6,11 @@ */ #include +#include #include #include #include #include -#include #include #define HX8357_NUM_IM_PINS 3 @@ -83,11 +83,10 @@ #define HX8369_SET_GAMMA_CURVE_RELATED 0xe0 struct hx8357_data { - unsigned im_pins[HX8357_NUM_IM_PINS]; - unsigned reset; + struct gpio_descs *im_pins; + struct gpio_desc *reset; struct spi_device *spi; int state; - bool use_im_pins; }; static u8 hx8357_seq_power[] = { @@ -321,11 +320,11 @@ static void hx8357_lcd_reset(struct lcd_device *lcdev) struct hx8357_data *lcd = lcd_get_data(lcdev); /* Reset the screen */ - gpio_set_value(lcd->reset, 1); + gpiod_set_value(lcd->reset, 0); usleep_range(10000, 12000); - gpio_set_value(lcd->reset, 0); + gpiod_set_value(lcd->reset, 1); usleep_range(10000, 12000); - gpio_set_value(lcd->reset, 1); + gpiod_set_value(lcd->reset, 0); /* The controller needs 120ms to recover from reset */ msleep(120); @@ -340,10 +339,10 @@ static int hx8357_lcd_init(struct lcd_device *lcdev) * Set the interface selection pins to SPI mode, with three * wires */ - if (lcd->use_im_pins) { - gpio_set_value_cansleep(lcd->im_pins[0], 1); - gpio_set_value_cansleep(lcd->im_pins[1], 0); - gpio_set_value_cansleep(lcd->im_pins[2], 1); + if (lcd->im_pins) { + gpiod_set_value_cansleep(lcd->im_pins->desc[0], 1); + gpiod_set_value_cansleep(lcd->im_pins->desc[1], 0); + gpiod_set_value_cansleep(lcd->im_pins->desc[2], 1); } ret = hx8357_spi_write_array(lcdev, hx8357_seq_power, @@ -580,6 +579,7 @@ MODULE_DEVICE_TABLE(of, hx8357_dt_ids); static int hx8357_probe(struct spi_device *spi) { + struct device *dev = &spi->dev; struct lcd_device *lcdev; struct hx8357_data *lcd; const struct of_device_id *match; @@ -601,49 +601,19 @@ static int hx8357_probe(struct spi_device *spi) if (!match || !match->data) return -EINVAL; - lcd->reset = of_get_named_gpio(spi->dev.of_node, "gpios-reset", 0); - if (!gpio_is_valid(lcd->reset)) { - dev_err(&spi->dev, "Missing dt property: gpios-reset\n"); - return -EINVAL; - } + lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(lcd->reset)) + return dev_err_probe(dev, PTR_ERR(lcd->reset), "failed to request reset GPIO\n"); + gpiod_set_consumer_name(lcd->reset, "hx8357-reset"); - ret = devm_gpio_request_one(&spi->dev, lcd->reset, - GPIOF_OUT_INIT_HIGH, - "hx8357-reset"); - if (ret) { - dev_err(&spi->dev, - "failed to request gpio %d: %d\n", - lcd->reset, ret); - return -EINVAL; - } + lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW); + if (IS_ERR(lcd->im_pins)) + return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n"); + if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS) + return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n"); - if (of_property_present(spi->dev.of_node, "im-gpios")) { - lcd->use_im_pins = 1; - - for (i = 0; i < HX8357_NUM_IM_PINS; i++) { - lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node, - "im-gpios", i); - if (lcd->im_pins[i] == -EPROBE_DEFER) { - dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n"); - return -EPROBE_DEFER; - } - if (!gpio_is_valid(lcd->im_pins[i])) { - dev_err(&spi->dev, "Missing dt property: im-gpios\n"); - return -EINVAL; - } - - ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i], - GPIOF_OUT_INIT_LOW, - "im_pins"); - if (ret) { - dev_err(&spi->dev, "failed to request gpio %d: %d\n", - lcd->im_pins[i], ret); - return -EINVAL; - } - } - } else { - lcd->use_im_pins = 0; - } + for (i = 0; i < HX8357_NUM_IM_PINS; i++) + gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, &hx8357_ops); -- 2.43.0.rc1.1.gbec44491f096