From patchwork Tue Dec 3 13:09:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11271247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2671921 for ; Tue, 3 Dec 2019 13:09:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B94A2068E for ; Tue, 3 Dec 2019 13:09:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B94A2068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 871A76E513; Tue, 3 Dec 2019 13:09:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE7506E50E for ; Tue, 3 Dec 2019 13:09:21 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id m6so3767518ljc.1 for ; Tue, 03 Dec 2019 05:09:21 -0800 (PST) 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=4UEsXQl3I/T+z770nwn4lhgtMw/PAlF7NFfwFxnxhdI=; b=M8fawm4z+/11VIRVXM10A++sHnWbKfIkZnmqu57w/tkTDrIDyvJwdggyaYKXkI62SJ vnESKINgF8i0qQrMrhfy9K8QONs56Ome33b0wi6GEI6nV37Jb41dJqpKyci+H/SrZ9+c dZWtJgvQsTc21M2F1tKckDLID0EBqmol+d4S/Ncu0GdzDZ3eVoW6HZ6STJqyQIK0J60Y S5ZLe4jYWgLXjpFV0BmucHLg7oXS/g+WL/U+XF1c2zm65wSKwNsCWncoTXBCJQ5YHsD2 KzrT5VtMeQGIj3KMYI7/UB6HtoUYsX6+gjxHC2lQLK3YZtmO8qMrJO51Dl7DMD1Mp3rm XnxQ== X-Gm-Message-State: APjAAAXXwDYwcAuFug4ozj8gVIfE3s7kpzrRUKZAS7Lgh3FzXrBna+xw 1r++EBypqs0RQuDOCkn6zF6YNJ8x2EM= X-Google-Smtp-Source: APXvYqyE8bvn/4nxbTp2IzkuXev0B626VRgW8HBr3BcVrnwalF9TVnvlTRTVtQ+yRAn39dTihi+AQQ== X-Received: by 2002:a2e:85d5:: with SMTP id h21mr2515391ljj.243.1575378559953; Tue, 03 Dec 2019 05:09:19 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s22sm1344688ljm.41.2019.12.03.05.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 05:09:18 -0800 (PST) From: Linus Walleij To: dri-devel@lists.freedesktop.org, Maarten Lankhorst , Maxime Ripard , Sean Paul Subject: [PATCH] drm/tilcdc: Switch to using GPIO descriptors Date: Tue, 3 Dec 2019 14:09:16 +0100 Message-Id: <20191203130916.155779-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Mailman-Original-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=4UEsXQl3I/T+z770nwn4lhgtMw/PAlF7NFfwFxnxhdI=; b=J6+nzx7Liq6IkE2ZbYv9iUn6DDeNpvUfozrfr15HUHXmbq90IDh1BO0EgBG0+CCwLu sD0B+Rdq6AcqNxWVMibtCf1cFinsGwEofsyVGx+DgG4qAqXhy4Q/78XoJalr6884ADHb HGFn/8qrVrXA7FHavmw0heG9YpcSDT32SBqrUhYQhx19OO72p+DVt17Ar7wq/RowfQzz BFAhttnz2BLXMPa8qdlp3pgOufM+IQB6TsMhO7fWxhRCAXMc6woWk2C6oFQYH5WsIuKj lqC82sbD7neLMb8H64IWa/tCoueus+MQxZl49kqQi12uL1FVn/bcMILg+kCAM/OJZLd7 ancA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen , Jyri Sarha , linux-arm-kernel@lists.infradead.org, David Lechner Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The TI LCDC picks a GPIO line from the device tree to use for DPMS power on/off. We can switch this to use a GPIO descriptor pretty easily. Make sure to request the GPIO "as is" so that the DPMS state that we start (boot) in is preserved. Cc: Jyri Sarha Cc: Tomi Valkeinen Cc: David Lechner Signed-off-by: Linus Walleij Reviewed-by: David Lechner --- drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 30 ++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c index 530edb3b51cc..41cd9a7c4316 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c @@ -4,9 +4,8 @@ * Author: Rob Clark */ -#include +#include #include -#include #include #include @@ -21,7 +20,7 @@ struct tfp410_module { struct tilcdc_module base; struct i2c_adapter *i2c; - int gpio; + struct gpio_desc *power_gpiod; }; #define to_tfp410_module(x) container_of(x, struct tfp410_module, base) @@ -58,10 +57,10 @@ static void tfp410_encoder_dpms(struct drm_encoder *encoder, int mode) if (mode == DRM_MODE_DPMS_ON) { DBG("Power on"); - gpio_direction_output(tfp410_encoder->mod->gpio, 1); + gpiod_direction_output(tfp410_encoder->mod->power_gpiod, 1); } else { DBG("Power off"); - gpio_direction_output(tfp410_encoder->mod->gpio, 0); + gpiod_direction_output(tfp410_encoder->mod->power_gpiod, 0); } tfp410_encoder->dpms = mode; @@ -318,17 +317,17 @@ static int tfp410_probe(struct platform_device *pdev) of_node_put(i2c_node); - tfp410_mod->gpio = of_get_named_gpio_flags(node, "powerdn-gpio", - 0, NULL); - if (tfp410_mod->gpio < 0) { - dev_warn(&pdev->dev, "No power down GPIO\n"); - } else { - ret = gpio_request(tfp410_mod->gpio, "DVI_PDn"); - if (ret) { - dev_err(&pdev->dev, "could not get DVI_PDn gpio\n"); - goto fail_adapter; - } + tfp410_mod->power_gpiod = devm_gpiod_get_optional(&pdev->dev, + "powerdn", + GPIOD_ASIS); + if (IS_ERR(tfp410_mod->power_gpiod)) { + dev_err(&pdev->dev, "could not get DVI_PDn gpio\n"); + goto fail_adapter; } + if (!tfp410_mod->power_gpiod) + dev_warn(&pdev->dev, "No power down GPIO\n"); + else + gpiod_set_consumer_name(tfp410_mod->power_gpiod, "DVI_PDn"); return 0; @@ -346,7 +345,6 @@ static int tfp410_remove(struct platform_device *pdev) struct tfp410_module *tfp410_mod = to_tfp410_module(mod); i2c_put_adapter(tfp410_mod->i2c); - gpio_free(tfp410_mod->gpio); tilcdc_module_cleanup(mod);