From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Ripard Subject: Re: [PATCH v5 5/6] drm: sun4i: Add support for enabling DDC I2C bus to sun8i_dw_hdmi glue Date: Tue, 21 May 2019 13:46:11 +0200 Message-ID: <20190521114611.ylmbo2oqeanveil4@flea> References: <20190520235009.16734-1-megous@megous.com> <20190520235009.16734-6-megous@megous.com> Reply-To: maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rjlukvbwopyqxnek" Return-path: Sender: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Content-Disposition: inline In-Reply-To: <20190520235009.16734-6-megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org Cc: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, Chen-Yu Tsai , Rob Herring , David Airlie , Daniel Vetter , Mark Rutland , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Maxime Coquelin , dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-stm32-XDFAJ8BFU24N7RejjzZ/Li2xQDfSxrLKVpNB7YpNyf8@public.gmane.org List-Id: devicetree@vger.kernel.org --rjlukvbwopyqxnek Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Hi, On Tue, May 21, 2019 at 01:50:08AM +0200, megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org wrote: > 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); > + Do you really need this to be done all the time? I'm guessing you would only need this when running .get_modes, right? Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --rjlukvbwopyqxnek--