Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3417482pxj; Mon, 24 May 2021 06:22:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvh3E8y4/QrBBfXsPQLu+UigU1Nwu3+AIj2G1f26/33fXdIXb4rw1D3d8XANRhwYscd/l3 X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr25458524edc.263.1621862558147; Mon, 24 May 2021 06:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621862558; cv=none; d=google.com; s=arc-20160816; b=EDF6n8xVpCQo+IlPyT9xEy4HR/GRHEaoYT/o/pr8hEVBoZs6PtFatey7vvJG+qA4y5 94k/0NtSQnkgKxjxW5pqxATdRXwIZfKW29jI0HpHgZLEVcLthnqiMty6DszyY9KJInbt v2BmURfy4QN7C/uS3FtvNPEban2U/b87r8PpQSbTmGJ/6gFkgrYGk9PZQnXLtOmVJRNw ErB1vARpU0pHc16jpefUu34RGGNKbET0Intm2y+mzA1KCpP6sNK4Rpp4jH9WvWy2jnwG x0x/xCO0zHPSIb0FAbBkRVV++HVtBH4RWv/551ZaZ+MF08kJuN/qkz06iQyz756nloTE UTAg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=fuDtBAgTxfRRsuyiHlaCiOfs3SONm3r054MQGPMRRUY=; b=sMCA2XLMhx8YvaEVnUttNmLzPf9UC/VxZmtdjA07bN6YzO0sUekXcN5RGkDH5pDnYR F4PhTrZji+lelj7cUDb0KSZIrzkn1Iq5yk49n3LNK+RGzuC/JUrW/h9YQc6LJKxo7MhF MyQgqWsd+qBbSadp8UHPGeYKdeNHynOapTOBm0mMgS1jBgrCoZFAvnjkCp/GdSm/EwuR 0G/NqJ9jXaZTReaQXuQIbrK4raUxfKMolBgYf5/Hb2gG+uAOCt6k1G7TSnSG5PJSbmWI ac1Rf/HEi7NtDM9VoxDENG68CdYh79nSjcrxeiCsgq75WGC75J8ltC8HsdWKZgtjVJ/z H2zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=XxvgFUkz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RAB2wBaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si5647755ejb.436.2021.05.24.06.22.13; Mon, 24 May 2021 06:22:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=XxvgFUkz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RAB2wBaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232844AbhEXNUd (ORCPT + 99 others); Mon, 24 May 2021 09:20:33 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:49905 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232842AbhEXNUa (ORCPT ); Mon, 24 May 2021 09:20:30 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 01FB441FB; Mon, 24 May 2021 09:19:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 24 May 2021 09:19:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=fuDtBAgTxfRRs uyiHlaCiOfs3SONm3r054MQGPMRRUY=; b=XxvgFUkz2aWr5l2is4drQF7faLYdr w+dS80w6gSL/2Ll5fqL9auUmv7BR70la607qX8Ngz2NZmbcVdwmPjCHEKMbZHUIi Rj9ldDb4DZ9VLlvXo8tcEwICHO7awZ3mN/xMrVgGY4sr/bK6UCvuGNn54P0J7O9H lXwWpwpj9xj/4gwWiqrPZfeGUH1+bLh2TbUD/rWSGU9tOY8gsc++9V2or/ktVV9m bN3n1cNYJTfkHVpuRM+IkthFeslCZ3kfj0TbNqGsxi4uHCDguqP19tlW2JENQ5r9 cMHgbLQHXKlZzHz4bYrWcQcDkowxkzHBnNGKc/TTayJCOPsjOde+iprbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=fuDtBAgTxfRRsuyiHlaCiOfs3SONm3r054MQGPMRRUY=; b=RAB2wBaX Qwg/7bHVXxBBs9/SndDvot7NezO38EvTuNqQbzPGKna/9XlBsmXcqvwAg53zFUQs evwu/gPmA6Q+NScYCURz0PTNpM8wJGRtf5TNbCGr7jblEncO6GuE+Fuh84e7yXQc azDrY4B4vRMi5kG2aTihTEE3ACSzQbFKh56ivyj5N63+w096M17v431PZYV6W5+V 9PZWfTXXxivBinlV32PHIop5c7oyFzBQJG80B5nHG4qiWLX8r3dD9aAT58p68f90 g2bIywED44ACDY8QRWiA18IqFvCDBh/y0jQkuEBQET3q6ecTNaEkHB0UMmWCNu34 BHYCfRI5Zd7QZg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejledgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 May 2021 09:19:00 -0400 (EDT) From: Maxime Ripard To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: Eric Anholt , linux-kernel@vger.kernel.org, Linus Wallei , Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , Daniel Vetter , Hans Verkuil , Maxime Ripard Subject: [PATCH 2/2] drm/vc4: hdmi: Convert to gpiod Date: Mon, 24 May 2021 15:18:52 +0200 Message-Id: <20210524131852.263883-2-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524131852.263883-1-maxime@cerno.tech> References: <20210524131852.263883-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new gpiod interface takes care of parsing the GPIO flags and to return the logical value when accessing an active-low GPIO, so switching to it simplifies a lot the driver. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 24 +++++++----------------- drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index ccc6c8079dc6..34622c59f6a7 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -159,10 +159,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); bool connected = false; - if (vc4_hdmi->hpd_gpio) { - if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^ - vc4_hdmi->hpd_active_low) - connected = true; + if (vc4_hdmi->hpd_gpio && + gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) { + connected = true; } else if (drm_probe_ddc(vc4_hdmi->ddc)) { connected = true; } else if (HDMI_READ(HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED) { @@ -1993,7 +1992,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) struct vc4_hdmi *vc4_hdmi; struct drm_encoder *encoder; struct device_node *ddc_node; - u32 value; int ret; vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL); @@ -2031,18 +2029,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) /* Only use the GPIO HPD pin if present in the DT, otherwise * we'll use the HDMI core's register. */ - if (of_find_property(dev->of_node, "hpd-gpios", &value)) { - enum of_gpio_flags hpd_gpio_flags; - - vc4_hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node, - "hpd-gpios", 0, - &hpd_gpio_flags); - if (vc4_hdmi->hpd_gpio < 0) { - ret = vc4_hdmi->hpd_gpio; - goto err_put_ddc; - } - - vc4_hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW; + vc4_hdmi->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); + if (IS_ERR(vc4_hdmi->hpd_gpio)) { + ret = PTR_ERR(vc4_hdmi->hpd_gpio); + goto err_put_ddc; } vc4_hdmi->disable_wifi_frequencies = diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 060bcaefbeb5..2688a55461d6 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -146,8 +146,7 @@ struct vc4_hdmi { /* VC5 Only */ void __iomem *rm_regs; - int hpd_gpio; - bool hpd_active_low; + struct gpio_desc *hpd_gpio; /* * On some systems (like the RPi4), some modes are in the same -- 2.31.1