diff mbox series

[v2,06/12] drm/sun4i: sun6i_mipi_dsi: Probe tcon0 during dsi_bind

Message ID 20181116163916.29621-7-jagan@amarulasolutions.com (mailing list archive)
State New, archived
Headers show
Series drm/sun4i: Allwinner MIPI-DSI Burst mode support | expand

Commit Message

Jagan Teki Nov. 16, 2018, 4:39 p.m. UTC
Probe tcon0 during dsi_bind, so-that the tcon attributes like
divider value, clock rate can get whenever it need.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 7 +++++++
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 +
 2 files changed, 8 insertions(+)

Comments

Maxime Ripard Nov. 19, 2018, 8:38 a.m. UTC | #1
On Fri, Nov 16, 2018 at 10:09:10PM +0530, Jagan Teki wrote:
> Probe tcon0 during dsi_bind, so-that the tcon attributes like
> divider value, clock rate can get whenever it need.
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 7 +++++++
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> index d60955880c43..66a01061e51d 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> @@ -25,6 +25,7 @@
>  #include <drm/drm_panel.h>
>  
>  #include "sun4i_drv.h"
> +#include "sun4i_tcon.h"
>  #include "sun6i_mipi_dsi.h"
>  
>  #include <video/mipi_display.h>
> @@ -1007,6 +1008,7 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
>  	struct drm_device *drm = data;
>  	struct sun4i_drv *drv = drm->dev_private;
>  	struct sun6i_dsi *dsi = dev_get_drvdata(dev);
> +	struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm);
>  	int ret;
>  
>  	if (!dsi->panel)
> @@ -1014,6 +1016,11 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
>  
>  	dsi->drv = drv;
>  
> +	if (!tcon0)
> +		return -EPROBE_DEFER;

You can't fall in that condition. The component framework won't call
bind unless every components have been probed.
Jagan Teki Nov. 19, 2018, 11:36 a.m. UTC | #2
On Mon, Nov 19, 2018 at 2:08 PM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> On Fri, Nov 16, 2018 at 10:09:10PM +0530, Jagan Teki wrote:
> > Probe tcon0 during dsi_bind, so-that the tcon attributes like
> > divider value, clock rate can get whenever it need.
> >
> > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > ---
> >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 7 +++++++
> >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 +
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > index d60955880c43..66a01061e51d 100644
> > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > @@ -25,6 +25,7 @@
> >  #include <drm/drm_panel.h>
> >
> >  #include "sun4i_drv.h"
> > +#include "sun4i_tcon.h"
> >  #include "sun6i_mipi_dsi.h"
> >
> >  #include <video/mipi_display.h>
> > @@ -1007,6 +1008,7 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
> >       struct drm_device *drm = data;
> >       struct sun4i_drv *drv = drm->dev_private;
> >       struct sun6i_dsi *dsi = dev_get_drvdata(dev);
> > +     struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm);
> >       int ret;
> >
> >       if (!dsi->panel)
> > @@ -1014,6 +1016,11 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
> >
> >       dsi->drv = drv;
> >
> > +     if (!tcon0)
> > +             return -EPROBE_DEFER;
>
> You can't fall in that condition. The component framework won't call
> bind unless every components have been probed.

Since tcon0 is already probed is it? if so I can return -EINVAL is it ok?
Maxime Ripard Nov. 20, 2018, 3:44 p.m. UTC | #3
On Mon, Nov 19, 2018 at 05:06:32PM +0530, Jagan Teki wrote:
> On Mon, Nov 19, 2018 at 2:08 PM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> >
> > On Fri, Nov 16, 2018 at 10:09:10PM +0530, Jagan Teki wrote:
> > > Probe tcon0 during dsi_bind, so-that the tcon attributes like
> > > divider value, clock rate can get whenever it need.
> > >
> > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > > ---
> > >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 7 +++++++
> > >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 +
> > >  2 files changed, 8 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > index d60955880c43..66a01061e51d 100644
> > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > @@ -25,6 +25,7 @@
> > >  #include <drm/drm_panel.h>
> > >
> > >  #include "sun4i_drv.h"
> > > +#include "sun4i_tcon.h"
> > >  #include "sun6i_mipi_dsi.h"
> > >
> > >  #include <video/mipi_display.h>
> > > @@ -1007,6 +1008,7 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
> > >       struct drm_device *drm = data;
> > >       struct sun4i_drv *drv = drm->dev_private;
> > >       struct sun6i_dsi *dsi = dev_get_drvdata(dev);
> > > +     struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm);
> > >       int ret;
> > >
> > >       if (!dsi->panel)
> > > @@ -1014,6 +1016,11 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
> > >
> > >       dsi->drv = drv;
> > >
> > > +     if (!tcon0)
> > > +             return -EPROBE_DEFER;
> >
> > You can't fall in that condition. The component framework won't call
> > bind unless every components have been probed.
> 
> Since tcon0 is already probed is it? if so I can return -EINVAL is it ok?

Sounds good yes.

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index d60955880c43..66a01061e51d 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -25,6 +25,7 @@ 
 #include <drm/drm_panel.h>
 
 #include "sun4i_drv.h"
+#include "sun4i_tcon.h"
 #include "sun6i_mipi_dsi.h"
 
 #include <video/mipi_display.h>
@@ -1007,6 +1008,7 @@  static int sun6i_dsi_bind(struct device *dev, struct device *master,
 	struct drm_device *drm = data;
 	struct sun4i_drv *drv = drm->dev_private;
 	struct sun6i_dsi *dsi = dev_get_drvdata(dev);
+	struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm);
 	int ret;
 
 	if (!dsi->panel)
@@ -1014,6 +1016,11 @@  static int sun6i_dsi_bind(struct device *dev, struct device *master,
 
 	dsi->drv = drv;
 
+	if (!tcon0)
+		return -EPROBE_DEFER;
+
+	dsi->tcon = tcon0;
+
 	drm_encoder_helper_add(&dsi->encoder,
 			       &sun6i_dsi_enc_helper_funcs);
 	ret = drm_encoder_init(drm,
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
index 0df60f84bab3..3c532e83958d 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h
@@ -40,6 +40,7 @@  struct sun6i_dsi {
 
 	struct device		*dev;
 	struct sun4i_drv	*drv;
+	struct sun4i_tcon	*tcon;
 	struct mipi_dsi_device	*device;
 	struct drm_panel	*panel;
 	const struct sun6i_dsi_variant	*variant;