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: 180723 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1479148ile; Tue, 3 Dec 2019 05:09:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwS2ad7zLWervbu88So3n4eedgO5uodxVUx0mpUXMVR3kjXnVtgY4nhNzI9HDlYfcm2ScW5 X-Received: by 2002:a17:902:aa97:: with SMTP id d23mr4639274plr.337.1575378565567; Tue, 03 Dec 2019 05:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575378565; cv=none; d=google.com; s=arc-20160816; b=aUhJX2sdM8ExbVKO/zTaP1iI37qXM4Tt6NLpijpyEsbtjULQHg9imaOUfo7IXaoBTl R31rcIg5QJr5FS4sSAC08tOV9XEWduYcILnV7PCq0uoOpaLlMx5l7Cn/k7TCUse1g0vi dLDLcHJHpaQ3S4nIEyJnF7fXiXcpkw01P3rvOuBd8ary1vqkxxF7po9Fgzv/a8Xq0n+p DiwFv5/QdjWkntVXb5F60h0C4C2PEvKHkqLol7BgTrOx8kbZhcoS3+54IZwM0V4Elw7u /x+gQ5IK9UPufh0o0Nm/V61PFr86+v7gIj8dmsDIOADYSWlpvmhVM/oTCmeTgYl9SMW4 csUA== 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 :delivered-to; bh=cPcrovcKzFJYatIEnlBkz1XGIc/2+CSlaA/60BzByuA=; b=TimdeRw5h8r4NHaZGguXWYsahSW1cSf6hYIoycAAbHmpTJv6HqnUI3tA4nplmlV2d2 3lg2WjftLpesICSU7AvDgzZL5VM97Cnd9QcQSOHXyyuxEGpN3hW4/asIJHP5Km7x+SRe LPRBqU9NEdhaNZHldA9AMll68J/2IUP//3ogmnEEG99YZRNyWbBY/scAo4CCtaZL65qh tlol72wFP5a82c6rfblIKoqFJACQ/1Li9O0BZrLZUgfMQh1jhZAr3D+55RL4YWtSl0eH bqBEtIspatHuEg8UagDrfDKwn7Dp6K6WyhQW4k2SpPxaxieNz/fhYlwZUOKjzzcLY6bT K5QA== ARC-Authentication-Results: i=1; mx.google.com; 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 e22si2124651pjt.44.2019.12.03.05.09.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2019 05:09:25 -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; 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 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-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);