From patchwork Wed Jun 5 08:46:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10976483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35D9B92A for ; Wed, 5 Jun 2019 08:46:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265EA28834 for ; Wed, 5 Jun 2019 08:46:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A92528847; Wed, 5 Jun 2019 08:46:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB26828834 for ; Wed, 5 Jun 2019 08:46:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEA0889688; Wed, 5 Jun 2019 08:46:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C81589688 for ; Wed, 5 Jun 2019 08:46:49 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id n4so13315542wrw.13 for ; Wed, 05 Jun 2019 01:46:49 -0700 (PDT) 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=o+eHts3UorKo8UYBcN1QT/Tt6PpNCT4+hc66JFubl48=; b=TdSK1kvWbkVqGluEwcBsd1u+GVxKNPPmysbrXg+6Fjnu1croWDJ7wofQIKQfRD01r1 pjLbHkQ9n3XgeJgSNCtoOjrk3oN+7yEezD5dQmQUfNQ5RiRHlm//Wea8L0T3OYFaaQDj fq8ki1DmnWQpZsrptLmqUOPXT5COpdbgaCgSjVTXbHTNSZ55TQwYuKjgrZcokcC1AVl/ oE1Uwn+r6R+KMsI5prlfpgS6kn90rvTEzukVxLytYLeIrGOvrt37eLBkHVyVbH07o4Tl vUa8eES7YVhMlorSMY+zKT8p3C+4UVSbhuJUyOpMF6wMBKN8D3ClbCaWzWrqEIbi/Yi4 rPhg== X-Gm-Message-State: APjAAAX2QrEnRfKROh3RZ1mtcOPWw0BnapPBBSnJG1kaavhpBw2yCQfe p8B/Vg95XVzut8yhOWCa0MQ= X-Google-Smtp-Source: APXvYqycG0HDgoAoJqeHklo3PcpK3qTnFMLP01TwiuVnRWc2Io0ZA3jpwM4Y+7jf85/fmTMxsgiZkw== X-Received: by 2002:adf:e4d2:: with SMTP id v18mr9582368wrm.189.1559724407982; Wed, 05 Jun 2019 01:46:47 -0700 (PDT) Received: from localhost (p2E5BEF36.dip0.t-ipconnect.de. [46.91.239.54]) by smtp.gmail.com with ESMTPSA id d10sm24075929wrh.91.2019.06.05.01.46.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 05 Jun 2019 01:46:47 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH] drm/tegra: Use GPIO descriptor API Date: Wed, 5 Jun 2019 10:46:46 +0200 Message-Id: <20190605084646.12340-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o+eHts3UorKo8UYBcN1QT/Tt6PpNCT4+hc66JFubl48=; b=PSfMaFlRm23bCSXA8pty1uWOdSxy4ziR22dDSPjO+GvFeP1udfidk+tJjzFrzgyqcZ qTYHeePbiPsPQ5lQXKwlUsJGpAni7o32ymym0OXwlXnQZy9CaMApEjFb1GQ2GjJci1tx +Hnw++3td8TnYsnmwLwKibdULSrWguTmfmnp9wWEVf095wPND3Vpu0SpZCqSKR4baBof LfULpwoXHIKrtVQv+aBoX5pC5BlDlewSIshSKSSTHNaNtFd8KMVjBhlAoB5Z4xxBRq1q dfKuj7uvKf0Q4jaMcg2y50VnpEa+id5foc1Hau2guzKzofS0US/aeC4PCHu1v0NhEtmI yOFg== 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: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding The legacy GPIO API has long been deprecated. Move the driver over to the descriptor-based API, which allows us to get rid of some boilerplate while at it. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/drm.h | 3 +- drivers/gpu/drm/tegra/output.c | 52 +++++++++++++--------------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 70154c253d45..488f36f00bd8 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -127,8 +127,7 @@ struct tegra_output { const struct edid *edid; struct cec_notifier *cec; unsigned int hpd_irq; - int hpd_gpio; - enum of_gpio_flags hpd_gpio_flags; + struct gpio_desc *hpd_gpio; struct drm_encoder encoder; struct drm_connector connector; diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index 9c2b9dad55c3..e4d242ca27b8 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -53,18 +53,11 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force) struct tegra_output *output = connector_to_output(connector); enum drm_connector_status status = connector_status_unknown; - if (gpio_is_valid(output->hpd_gpio)) { - if (output->hpd_gpio_flags & OF_GPIO_ACTIVE_LOW) { - if (gpio_get_value(output->hpd_gpio) != 0) - status = connector_status_disconnected; - else - status = connector_status_connected; - } else { - if (gpio_get_value(output->hpd_gpio) == 0) - status = connector_status_disconnected; - else - status = connector_status_connected; - } + if (output->hpd_gpio) { + if (gpiod_get_value(output->hpd_gpio) == 0) + status = connector_status_disconnected; + else + status = connector_status_connected; } else { if (!output->panel) status = connector_status_disconnected; @@ -102,6 +95,7 @@ static irqreturn_t hpd_irq(int irq, void *data) int tegra_output_probe(struct tegra_output *output) { struct device_node *ddc, *panel; + unsigned long flags; int err, size; if (!output->of_node) @@ -130,23 +124,18 @@ int tegra_output_probe(struct tegra_output *output) of_node_put(ddc); } - output->hpd_gpio = of_get_named_gpio_flags(output->of_node, - "nvidia,hpd-gpio", 0, - &output->hpd_gpio_flags); - if (gpio_is_valid(output->hpd_gpio)) { - unsigned long flags; + output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev, + output->of_node, + "nvidia,hpd-gpio", 0, + GPIOD_IN, + "HDMI hotplug detect"); + if (IS_ERR(output->hpd_gpio)) + return PTR_ERR(output->hpd_gpio); - err = gpio_request_one(output->hpd_gpio, GPIOF_DIR_IN, - "HDMI hotplug detect"); + if (output->hpd_gpio) { + err = gpiod_to_irq(output->hpd_gpio); if (err < 0) { - dev_err(output->dev, "gpio_request_one(): %d\n", err); - return err; - } - - err = gpio_to_irq(output->hpd_gpio); - if (err < 0) { - dev_err(output->dev, "gpio_to_irq(): %d\n", err); - gpio_free(output->hpd_gpio); + dev_err(output->dev, "gpiod_to_irq(): %d\n", err); return err; } @@ -160,7 +149,6 @@ int tegra_output_probe(struct tegra_output *output) if (err < 0) { dev_err(output->dev, "failed to request IRQ#%u: %d\n", output->hpd_irq, err); - gpio_free(output->hpd_gpio); return err; } @@ -186,10 +174,8 @@ void tegra_output_remove(struct tegra_output *output) if (output->cec) cec_notifier_put(output->cec); - if (gpio_is_valid(output->hpd_gpio)) { + if (output->hpd_gpio) free_irq(output->hpd_irq, output); - gpio_free(output->hpd_gpio); - } if (output->ddc) put_device(&output->ddc->dev); @@ -209,7 +195,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) * The connector is now registered and ready to receive hotplug events * so the hotplug interrupt can be enabled. */ - if (gpio_is_valid(output->hpd_gpio)) + if (output->hpd_gpio) enable_irq(output->hpd_irq); return 0; @@ -221,7 +207,7 @@ void tegra_output_exit(struct tegra_output *output) * The connector is going away, so the interrupt must be disabled to * prevent the hotplug interrupt handler from potentially crashing. */ - if (gpio_is_valid(output->hpd_gpio)) + if (output->hpd_gpio) disable_irq(output->hpd_irq); if (output->panel)