Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp308894ybm; Mon, 20 May 2019 16:51:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwemoSjlafPxLc1JqFuuGDjGT7HXicUdeEqUMJsSM7MUj6ZZ/cHsZTHBg5pUc5rS5D9iK+p X-Received: by 2002:aa7:9577:: with SMTP id x23mr83071441pfq.164.1558396297977; Mon, 20 May 2019 16:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558396297; cv=none; d=google.com; s=arc-20160816; b=qH7BvCnHiiNCHFELmeAMTqNLhs+S8NThkgOeYVBoYT0fp0fgLFmcK7nJA0+qliG0Ts o5OPo8UypYP1HQ5QS2RMyR93DGIxpTn6UQYkxNVvY8eHzrbs8/MEZeo5j1FvoetrbR5o /PFlVbnNyLcFuhskI77W1h8Qej6Cnz38yBd3R++o7RP39TBh5J/qb5C9ozKSXmb99aG3 sAWQ8WJ0uXhnSD6OL8wyKTlgzTbbk8oQhtCpRnLMCkEO8WJFFQgj+aIlICFvrMu+Aqee bLyBvP6atRktBJqloml0mLo4KOAyPv0dFpQAapf03spoUAnm0HW0aFSewb/HV2A1xxkb Ml0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dW0l+YWcAeViZvjH6sJMtks5+To9wc1C2+uj3y5RDHE=; b=meWMjLhjkt2LZNjP5UNZLC4Lx6vMNCnWn+wY9g1n5Q7JHHx1TlnnMJcqa32FKcYC+y ppfqxIVy6wtrxAZK2tSwdcXRokqP+9qmqFDk9ogws+Ax6sot+mFszjp/SxtpE9SsVpt4 jKJAS17QXdRI3KD+FnKBV4y3pIVzPzdz/jtjwcwAKvfS/LyhEVLfEVWF1IgkSW6ykk6p IQlL5mnVaJMgIxBG9ic8AnnLSHn/EDJYpkAu3dE5DwM28vqa4QyYNGKD68RHBwChC03C MWMA5uw+D9SFdhvd/7D7RqYPG+0E7kXFva1Hzd99bB5k1MBrDqaZpWVYcOKh89OuQ7Yb rWLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=mSJZE97R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p25si20297556pgd.486.2019.05.20.16.51.23; Mon, 20 May 2019 16:51:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=mSJZE97R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727390AbfETXuT (ORCPT + 99 others); Mon, 20 May 2019 19:50:19 -0400 Received: from vps.xff.cz ([195.181.215.36]:58656 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbfETXuQ (ORCPT ); Mon, 20 May 2019 19:50:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1558396213; bh=f3M/l5dBGPUqrlBmQUEjiKu9RFMozTVLiPXiToeGQwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSJZE97R+iw4ljWWwvmbB8Pu/56mx387qtF9J3ZOwmR252uCAL8MLhkt0WNWguPoz rZNyTQaQ58D89zn7AJg+kFwbqPPIIV9eQhX9Ke/9yqa6pAfHV5EvZVR7cbSEs7Xsr4 nGFUUOupFYB9oV0fI0kK3ykQ7UlN3mnVZvWP1K5o= From: megous@megous.com To: linux-sunxi@googlegroups.com, Maxime Ripard , Chen-Yu Tsai , Rob Herring Cc: Ondrej Jirman , David Airlie , Daniel Vetter , Mark Rutland , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Maxime Coquelin , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v5 5/6] drm: sun4i: Add support for enabling DDC I2C bus to sun8i_dw_hdmi glue Date: Tue, 21 May 2019 01:50:08 +0200 Message-Id: <20190520235009.16734-6-megous@megous.com> In-Reply-To: <20190520235009.16734-1-megous@megous.com> References: <20190520235009.16734-1-megous@megous.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ondrej Jirman Orange Pi 3 board requires enabling a voltage shifting circuit via GPIO for the DDC bus to be usable. Add support for hdmi-connector node's optional ddc-en-gpios property to support this use case. Signed-off-by: Ondrej Jirman --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 55 +++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 3 ++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 39d8509d96a0..59b81ba02d96 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -98,6 +98,30 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm, return crtcs; } +static int sun8i_dw_hdmi_find_connector_pdev(struct device *dev, + struct platform_device **pdev_out) +{ + struct platform_device *pdev; + struct device_node *remote; + + remote = of_graph_get_remote_node(dev->of_node, 1, -1); + if (!remote) + return -ENODEV; + + if (!of_device_is_compatible(remote, "hdmi-connector")) { + of_node_put(remote); + return -ENODEV; + } + + pdev = of_find_device_by_node(remote); + of_node_put(remote); + if (!pdev) + return -ENODEV; + + *pdev_out = pdev; + return 0; +} + static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, void *data) { @@ -151,16 +175,29 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, return PTR_ERR(hdmi->regulator); } + ret = sun8i_dw_hdmi_find_connector_pdev(dev, &hdmi->connector_pdev); + if (!ret) { + hdmi->ddc_en = gpiod_get_optional(&hdmi->connector_pdev->dev, + "ddc-en", GPIOD_OUT_HIGH); + if (IS_ERR(hdmi->ddc_en)) { + platform_device_put(hdmi->connector_pdev); + dev_err(dev, "Couldn't get ddc-en gpio\n"); + return PTR_ERR(hdmi->ddc_en); + } + } + ret = regulator_enable(hdmi->regulator); if (ret) { dev_err(dev, "Failed to enable regulator\n"); - return ret; + goto err_unref_ddc_en; } + gpiod_set_value(hdmi->ddc_en, 1); + ret = reset_control_deassert(hdmi->rst_ctrl); if (ret) { dev_err(dev, "Could not deassert ctrl reset control\n"); - goto err_disable_regulator; + goto err_disable_ddc_en; } ret = clk_prepare_enable(hdmi->clk_tmds); @@ -213,8 +250,14 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, clk_disable_unprepare(hdmi->clk_tmds); err_assert_ctrl_reset: reset_control_assert(hdmi->rst_ctrl); -err_disable_regulator: +err_disable_ddc_en: + gpiod_set_value(hdmi->ddc_en, 0); regulator_disable(hdmi->regulator); +err_unref_ddc_en: + if (hdmi->ddc_en) + gpiod_put(hdmi->ddc_en); + + platform_device_put(hdmi->connector_pdev); return ret; } @@ -228,7 +271,13 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, sun8i_hdmi_phy_remove(hdmi); clk_disable_unprepare(hdmi->clk_tmds); reset_control_assert(hdmi->rst_ctrl); + gpiod_set_value(hdmi->ddc_en, 0); regulator_disable(hdmi->regulator); + + if (hdmi->ddc_en) + gpiod_put(hdmi->ddc_en); + + platform_device_put(hdmi->connector_pdev); } static const struct component_ops sun8i_dw_hdmi_ops = { diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h index 720c5aa8adc1..dad66b8301c2 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -190,6 +191,8 @@ struct sun8i_dw_hdmi { struct regulator *regulator; const struct sun8i_dw_hdmi_quirks *quirks; struct reset_control *rst_ctrl; + struct platform_device *connector_pdev; + struct gpio_desc *ddc_en; }; static inline struct sun8i_dw_hdmi * -- 2.21.0