[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
On Thu, 21 Aug 2014 11:41:59 +0200
Boris BREZILLON  wrote:

> On Thu, 21 Aug 2014 11:04:07 +0200
> Thierry Reding  wrote:
> 
> > On Thu, Aug 21, 2014 at 10:37:06AM +0200, Boris BREZILLON wrote:
> > > Hi Ludovic,
> > > 
> > > On Thu, 21 Aug 2014 10:16:19 +0200
> > > Ludovic Desroches  wrote:
> > > 
> > > > Hi Boris,
> > > > 
> > > > You can add
> > > > 
> > > > Tested-by: Ludovic Desroches 
> > > 
> > > Thanks for testing this driver.
> > > 
> > > > 
> > > > Only one issue but not related to your patches, you can't display
> > > > quickly the bootup logo since the panel detection takes too much
> > > > time.
> > > 
> > > Yes, actually this is related to the device probe order: the
> > > hlcdc-display-controller device is probed before the simple-panel, thus
> > > nothing is detected on the RGB connector (I use of_drm_find_panel to
> > > check for panel availability) when the display controller is
> > > instantiated. I rely on the default polling infrastructure provided by
> > > the DRM/KMS framework which polls for a new connector every 10s, and
> > > this is far more than you kernel boot time.
> > > 
> > > Do anyone see a solution to reduce this delay (without changing the
> > > polling interval). I thought we could add a notifier infrastructure to
> > > the DRM panel framework, but I'm not sure this is how you want things
> > > done...
> > 
> > Other drivers return -EPROBE_DEFER when a panel hasn't been registered
> > yet. This will automatically take care of ordering things in a way that
> > DRM/KMS will only be initialized after the panel has been probed.
> 
> Actually I'd like to avoid doing this with a deferred probe, because,
> AFAIU, the remote endpoint is not tightly linked with the display
> controller driver (I mean the display controller can still be
> initialized without having a display connected on it).
> Moreover the atmel dev kit I'm using has an HDMI bridge connected on
> the same RGB connector and I'd like to use it in a near future.
> Returning -EPROBE_DEFER in case of several devices connected on the
> same connector implies that I'll have to wait for all the remote
> end-points to be available before my display controller could be
> instantiated.
> 
> While this could be acceptable when all drivers are statically linked
> in the kernel, it might be problematic when you're using modules,
> meaning that you won't be able to display anything on your LCD panel
> until your HDMI bridge module has been loaded.
> 
> > That
> > will still cause some delay before everything gets set up, but hopefully
> > less than what you're seeing now. There's also another thread where this
> > is being discussed because deferred probing is causing "unacceptable"
> > delays as well.
> 
> Could you point this thread out to me please ?

Sorry, I didn't check my emails before asking this :-).

> 
> Best Regards,
> 
> Boris
> 



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
On Thu, 21 Aug 2014 11:52:03 +0200
Thierry Reding  wrote:

> On Thu, Aug 21, 2014 at 11:41:59AM +0200, Boris BREZILLON wrote:
> > On Thu, 21 Aug 2014 11:04:07 +0200
> > Thierry Reding  wrote:
> > 
> > > On Thu, Aug 21, 2014 at 10:37:06AM +0200, Boris BREZILLON wrote:
> > > > Hi Ludovic,
> > > > 
> > > > On Thu, 21 Aug 2014 10:16:19 +0200
> > > > Ludovic Desroches  wrote:
> > > > 
> > > > > Hi Boris,
> > > > > 
> > > > > You can add
> > > > > 
> > > > > Tested-by: Ludovic Desroches 
> > > > 
> > > > Thanks for testing this driver.
> > > > 
> > > > > 
> > > > > Only one issue but not related to your patches, you can't display
> > > > > quickly the bootup logo since the panel detection takes too much
> > > > > time.
> > > > 
> > > > Yes, actually this is related to the device probe order: the
> > > > hlcdc-display-controller device is probed before the simple-panel, thus
> > > > nothing is detected on the RGB connector (I use of_drm_find_panel to
> > > > check for panel availability) when the display controller is
> > > > instantiated. I rely on the default polling infrastructure provided by
> > > > the DRM/KMS framework which polls for a new connector every 10s, and
> > > > this is far more than you kernel boot time.
> > > > 
> > > > Do anyone see a solution to reduce this delay (without changing the
> > > > polling interval). I thought we could add a notifier infrastructure to
> > > > the DRM panel framework, but I'm not sure this is how you want things
> > > > done...
> > > 
> > > Other drivers return -EPROBE_DEFER when a panel hasn't been registered
> > > yet. This will automatically take care of ordering things in a way that
> > > DRM/KMS will only be initialized after the panel has been probed.
> > 
> > Actually I'd like to avoid doing this with a deferred probe, because,
> > AFAIU, the remote endpoint is not tightly linked with the display
> > controller driver (I mean the display controller can still be
> > initialized without having a display connected on it).
> > Moreover the atmel dev kit I'm using has an HDMI bridge connected on
> > the same RGB connector and I'd like to use it in a near future.
> > Returning -EPROBE_DEFER in case of several devices connected on the
> > same connector implies that I'll have to wait for all the remote
> > end-points to be available before my display controller could be
> > instantiated.
> > 
> > While this could be acceptable when all drivers are statically linked
> > in the kernel, it might be problematic when you're using modules,
> > meaning that you won't be able to display anything on your LCD panel
> > until your HDMI bridge module has been loaded.
> 
> No. HDMI should be using proper hotplugging anyway, hence it should be
> always be loaded anyway. You're in for a world of pain if you think you
> can run DRM with a driver that's composed of separate kernel modules.

I was talking about the external RGB to HDMI encoder, should the driver
for this encoder (which is not on On Chip block) be compiled
statically too ?

> 
> Also if you don't want to use deferred probe, then you're in for the
> full hotplugging panel dance and that implies that you need to fix a
> bunch of things in DRM (one being the framebuffer console instantiation
> that I referred to in the other thread).

For now, I wait until there is a device connected on the RGB connector
(connector status set to connector_status_connected) before creating an
fbdev. It might not be the cleanest way to solve this issue, but it
works :-).

> You also can't be using the
> current device tree bindings because they all assume a dependency from
> the display controller/output to the panel. For hotplugging you'd need
> the dependency the other way around (the panel needs to refer to the
> output by phandle).

Here [1] is a proposal for notification support in the drm_panel
infrastructure (which is not that complicated), and here [2] is how
I use it in my atmel-hlcdc driver to generate hotplug events.

Let me know if you want me to submit a proper patch series...

Best Regards,

Boris

[1]http://code.bulix.org/scq4g3-86804
[2]http://code.bulix.org/7dg501-86805

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
On Thu, 21 Aug 2014 15:16:08 +0200
Thierry Reding  wrote:

> On Thu, Aug 21, 2014 at 03:06:00PM +0200, Boris BREZILLON wrote:
> > On Thu, 21 Aug 2014 11:52:03 +0200
> > Thierry Reding  wrote:
> > 
> > > On Thu, Aug 21, 2014 at 11:41:59AM +0200, Boris BREZILLON wrote:
> > > > On Thu, 21 Aug 2014 11:04:07 +0200
> > > > Thierry Reding  wrote:
> > > > 
> > > > > On Thu, Aug 21, 2014 at 10:37:06AM +0200, Boris BREZILLON wrote:
> > > > > > Hi Ludovic,
> > > > > > 
> > > > > > On Thu, 21 Aug 2014 10:16:19 +0200
> > > > > > Ludovic Desroches  wrote:
> > > > > > 
> > > > > > > Hi Boris,
> > > > > > > 
> > > > > > > You can add
> > > > > > > 
> > > > > > > Tested-by: Ludovic Desroches 
> > > > > > 
> > > > > > Thanks for testing this driver.
> > > > > > 
> > > > > > > 
> > > > > > > Only one issue but not related to your patches, you can't display
> > > > > > > quickly the bootup logo since the panel detection takes too much
> > > > > > > time.
> > > > > > 
> > > > > > Yes, actually this is related to the device probe order: the
> > > > > > hlcdc-display-controller device is probed before the simple-panel, 
> > > > > > thus
> > > > > > nothing is detected on the RGB connector (I use of_drm_find_panel to
> > > > > > check for panel availability) when the display controller is
> > > > > > instantiated. I rely on the default polling infrastructure provided 
> > > > > > by
> > > > > > the DRM/KMS framework which polls for a new connector every 10s, and
> > > > > > this is far more than you kernel boot time.
> > > > > > 
> > > > > > Do anyone see a solution to reduce this delay (without changing the
> > > > > > polling interval). I thought we could add a notifier infrastructure 
> > > > > > to
> > > > > > the DRM panel framework, but I'm not sure this is how you want 
> > > > > > things
> > > > > > done...
> > > > > 
> > > > > Other drivers return -EPROBE_DEFER when a panel hasn't been registered
> > > > > yet. This will automatically take care of ordering things in a way 
> > > > > that
> > > > > DRM/KMS will only be initialized after the panel has been probed.
> > > > 
> > > > Actually I'd like to avoid doing this with a deferred probe, because,
> > > > AFAIU, the remote endpoint is not tightly linked with the display
> > > > controller driver (I mean the display controller can still be
> > > > initialized without having a display connected on it).
> > > > Moreover the atmel dev kit I'm using has an HDMI bridge connected on
> > > > the same RGB connector and I'd like to use it in a near future.
> > > > Returning -EPROBE_DEFER in case of several devices connected on the
> > > > same connector implies that I'll have to wait for all the remote
> > > > end-points to be available before my display controller could be
> > > > instantiated.
> > > > 
> > > > While this could be acceptable when all drivers are statically linked
> > > > in the kernel, it might be problematic when you're using modules,
> > > > meaning that you won't be able to display anything on your LCD panel
> > > > until your HDMI bridge module has been loaded.
> > > 
> > > No. HDMI should be using proper hotplugging anyway, hence it should be
> > > always be loaded anyway. You're in for a world of pain if you think you
> > > can run DRM with a driver that's composed of separate kernel modules.
> > 
> > I was talking about the external RGB to HDMI encoder, should the driver
> > for this encoder (which is not on On Chip block) be compiled
> > statically too ?
> > 
> > > 
> > > Also if you don't want to use deferred probe, then you're in for the
> > > full hotplugging panel dance and that implies that you need to fix a
> > > bunch of things in DRM (one being the framebuffer console instantiation
> > > that I referred to in the other thread).
> > 
> > For now, I wait until there is a device connected on the RGB connector
> > (connector status set to connector_stat

[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
On Thu, 21 Aug 2014 15:16:08 +0200
Thierry Reding  wrote:

> On Thu, Aug 21, 2014 at 03:06:00PM +0200, Boris BREZILLON wrote:
> > On Thu, 21 Aug 2014 11:52:03 +0200
> > Thierry Reding  wrote:
> > 
> > > On Thu, Aug 21, 2014 at 11:41:59AM +0200, Boris BREZILLON wrote:
> > > > On Thu, 21 Aug 2014 11:04:07 +0200
> > > > Thierry Reding  wrote:
> > > > 
> > > > > On Thu, Aug 21, 2014 at 10:37:06AM +0200, Boris BREZILLON wrote:
> > > > > > Hi Ludovic,
> > > > > > 
> > > > > > On Thu, 21 Aug 2014 10:16:19 +0200
> > > > > > Ludovic Desroches  wrote:
> > > > > > 
> > > > > > > Hi Boris,
> > > > > > > 
> > > > > > > You can add
> > > > > > > 
> > > > > > > Tested-by: Ludovic Desroches 
> > > > > > 
> > > > > > Thanks for testing this driver.
> > > > > > 
> > > > > > > 
> > > > > > > Only one issue but not related to your patches, you can't display
> > > > > > > quickly the bootup logo since the panel detection takes too much
> > > > > > > time.
> > > > > > 
> > > > > > Yes, actually this is related to the device probe order: the
> > > > > > hlcdc-display-controller device is probed before the simple-panel, 
> > > > > > thus
> > > > > > nothing is detected on the RGB connector (I use of_drm_find_panel to
> > > > > > check for panel availability) when the display controller is
> > > > > > instantiated. I rely on the default polling infrastructure provided 
> > > > > > by
> > > > > > the DRM/KMS framework which polls for a new connector every 10s, and
> > > > > > this is far more than you kernel boot time.
> > > > > > 
> > > > > > Do anyone see a solution to reduce this delay (without changing the
> > > > > > polling interval). I thought we could add a notifier infrastructure 
> > > > > > to
> > > > > > the DRM panel framework, but I'm not sure this is how you want 
> > > > > > things
> > > > > > done...
> > > > > 
> > > > > Other drivers return -EPROBE_DEFER when a panel hasn't been registered
> > > > > yet. This will automatically take care of ordering things in a way 
> > > > > that
> > > > > DRM/KMS will only be initialized after the panel has been probed.
> > > > 
> > > > Actually I'd like to avoid doing this with a deferred probe, because,
> > > > AFAIU, the remote endpoint is not tightly linked with the display
> > > > controller driver (I mean the display controller can still be
> > > > initialized without having a display connected on it).
> > > > Moreover the atmel dev kit I'm using has an HDMI bridge connected on
> > > > the same RGB connector and I'd like to use it in a near future.
> > > > Returning -EPROBE_DEFER in case of several devices connected on the
> > > > same connector implies that I'll have to wait for all the remote
> > > > end-points to be available before my display controller could be
> > > > instantiated.
> > > > 
> > > > While this could be acceptable when all drivers are statically linked
> > > > in the kernel, it might be problematic when you're using modules,
> > > > meaning that you won't be able to display anything on your LCD panel
> > > > until your HDMI bridge module has been loaded.
> > > 
> > > No. HDMI should be using proper hotplugging anyway, hence it should be
> > > always be loaded anyway. You're in for a world of pain if you think you
> > > can run DRM with a driver that's composed of separate kernel modules.
> > 
> > I was talking about the external RGB to HDMI encoder, should the driver
> > for this encoder (which is not on On Chip block) be compiled
> > statically too ?
> > 
> > > 
> > > Also if you don't want to use deferred probe, then you're in for the
> > > full hotplugging panel dance and that implies that you need to fix a
> > > bunch of things in DRM (one being the framebuffer console instantiation
> > > that I referred to in the other thread).
> > 
> > For now, I wait until there is a device connected on the RGB connector
> > (connector status set to connector_

[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
On Thu, 21 Aug 2014 17:04:34 +0200
Andrzej Hajda  wrote:

> On 08/21/2014 03:21 PM, Thierry Reding wrote:
> > On Thu, Aug 21, 2014 at 12:32:43PM +0200, Andrzej Hajda wrote:
> >> On 08/21/2014 11:52 AM, Thierry Reding wrote:
> >>> On Thu, Aug 21, 2014 at 11:41:59AM +0200, Boris BREZILLON wrote:
> >>>> On Thu, 21 Aug 2014 11:04:07 +0200
> >>>> Thierry Reding  wrote:
> >>>>
> >>>>> On Thu, Aug 21, 2014 at 10:37:06AM +0200, Boris BREZILLON wrote:
> >>>>>> Hi Ludovic,
> >>>>>>
> >>>>>> On Thu, 21 Aug 2014 10:16:19 +0200
> >>>>>> Ludovic Desroches  wrote:
> >>>>>>
> >>>>>>> Hi Boris,
> >>>>>>>
> >>>>>>> You can add
> >>>>>>>
> >>>>>>> Tested-by: Ludovic Desroches 
> >>>>>> Thanks for testing this driver.
> >>>>>>
> >>>>>>> Only one issue but not related to your patches, you can't display
> >>>>>>> quickly the bootup logo since the panel detection takes too much
> >>>>>>> time.
> >>>>>> Yes, actually this is related to the device probe order: the
> >>>>>> hlcdc-display-controller device is probed before the simple-panel, thus
> >>>>>> nothing is detected on the RGB connector (I use of_drm_find_panel to
> >>>>>> check for panel availability) when the display controller is
> >>>>>> instantiated. I rely on the default polling infrastructure provided by
> >>>>>> the DRM/KMS framework which polls for a new connector every 10s, and
> >>>>>> this is far more than you kernel boot time.
> >>>>>>
> >>>>>> Do anyone see a solution to reduce this delay (without changing the
> >>>>>> polling interval). I thought we could add a notifier infrastructure to
> >>>>>> the DRM panel framework, but I'm not sure this is how you want things
> >>>>>> done...
> >>>>> Other drivers return -EPROBE_DEFER when a panel hasn't been registered
> >>>>> yet. This will automatically take care of ordering things in a way that
> >>>>> DRM/KMS will only be initialized after the panel has been probed.
> >>>> Actually I'd like to avoid doing this with a deferred probe, because,
> >>>> AFAIU, the remote endpoint is not tightly linked with the display
> >>>> controller driver (I mean the display controller can still be
> >>>> initialized without having a display connected on it).
> >>>> Moreover the atmel dev kit I'm using has an HDMI bridge connected on
> >>>> the same RGB connector and I'd like to use it in a near future.
> >>>> Returning -EPROBE_DEFER in case of several devices connected on the
> >>>> same connector implies that I'll have to wait for all the remote
> >>>> end-points to be available before my display controller could be
> >>>> instantiated.
> >>>>
> >>>> While this could be acceptable when all drivers are statically linked
> >>>> in the kernel, it might be problematic when you're using modules,
> >>>> meaning that you won't be able to display anything on your LCD panel
> >>>> until your HDMI bridge module has been loaded.
> >>> No. HDMI should be using proper hotplugging anyway, hence it should be
> >>> always be loaded anyway. You're in for a world of pain if you think you
> >>> can run DRM with a driver that's composed of separate kernel modules.
> >>>
> >>> Also if you don't want to use deferred probe, then you're in for the
> >>> full hotplugging panel dance and that implies that you need to fix a
> >>> bunch of things in DRM (one being the framebuffer console instantiation
> >>> that I referred to in the other thread). You also can't be using the
> >>> current device tree bindings because they all assume a dependency from
> >>> the display controller/output to the panel. For hotplugging you'd need
> >>> the dependency the other way around (the panel needs to refer to the
> >>> output by phandle).
> >> I have tested panel as a module in exynos-dsi + panel-s6e8aa0
> >> configuration, everything works. There is a workaround for fb console
> >> not being reconfigurable, but it does not make thing worse than before.

[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-21 Thread Boris BREZILLON
Hi Laurent,

On Thu, 21 Aug 2014 19:08:53 +0200
Laurent Pinchart  wrote:

[...]

> > >> 
> > >> While this could be acceptable when all drivers are statically linked
> > >> in the kernel, it might be problematic when you're using modules,
> > >> meaning that you won't be able to display anything on your LCD panel
> > >> until your HDMI bridge module has been loaded.
> > > 
> > > No. HDMI should be using proper hotplugging anyway, hence it should be
> > > always be loaded anyway. You're in for a world of pain if you think you
> > > can run DRM with a driver that's composed of separate kernel modules.
> > 
> > I was talking about the external RGB to HDMI encoder, should the driver
> > for this encoder (which is not on On Chip block) be compiled
> > statically too ?
> 
> Given the move to multiplatform kernels we need to aim for as few modules 
> compiled in as possible. I'd say this includes HDMI encoders, panels and 
> display controllers.
> 
> > > Also if you don't want to use deferred probe, then you're in for the
> > > full hotplugging panel dance and that implies that you need to fix a
> > > bunch of things in DRM (one being the framebuffer console instantiation
> > > that I referred to in the other thread).
> > 
> > For now, I wait until there is a device connected on the RGB connector
> > (connector status set to connector_status_connected) before creating an
> > fbdev. It might not be the cleanest way to solve this issue, but it
> > works :-).
> 
> Do you create a new drm_encoder at runtime for the HDMI encoder when it 
> appears ? I thought the DRM core and API were not able to correctly cope with 
> that.

I haven't started to work on the HDMI encoder yet, and ATM I only have
a single connector (which is true from an HW POV), which is then bound
to an LCD panel (the only type of remote endpoint I currently support).

BTW, I wonder how my use case should be represented in the DRM
subsystem. As I said, from an HW POV I only have one RGB (or whatever
name you choose for it) connector. But on such kind of connectors you
can connect several output devices (panels, encoders, ...).
And in my case I have 2 devices on the same RGB connector: a panel and
an RGB to HDMI converter.

> 
> > > You also can't be using the current device tree bindings because they all
> > > assume a dependency from the display controller/output to the panel. For
> > > hotplugging you'd need the dependency the other way around (the panel
> > > needs to refer to the output by phandle).
> > 
> > Here [1] is a proposal for notification support in the drm_panel
> > infrastructure (which is not that complicated), and here [2] is how
> > I use it in my atmel-hlcdc driver to generate hotplug events.
> 
> Is there a way we could use the component framework for that ? I know that 
> partial notification isn't supported at the moment, but Russell agreed it was 
> a real use case that should be implemented at some point.

I'll give it a try.

Best Regards,

Boris



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-27 Thread Boris BREZILLON
Hi Laurent,

On Tue, 26 Aug 2014 01:39:21 +0200
Laurent Pinchart  wrote:

> Hi Boris,
> 
> On Thursday 21 August 2014 19:26:33 Boris BREZILLON wrote:
> > On Thu, 21 Aug 2014 19:08:53 +0200
> > Laurent Pinchart  wrote:
> > 
> > [...]
> > 
> > >>>> While this could be acceptable when all drivers are statically linked
> > >>>> in the kernel, it might be problematic when you're using modules,
> > >>>> meaning that you won't be able to display anything on your LCD panel
> > >>>> until your HDMI bridge module has been loaded.
> > >>> 
> > >>> No. HDMI should be using proper hotplugging anyway, hence it should be
> > >>> always be loaded anyway. You're in for a world of pain if you think
> > >>> you can run DRM with a driver that's composed of separate kernel
> > >>> modules.
> > >> 
> > >> I was talking about the external RGB to HDMI encoder, should the driver
> > >> for this encoder (which is not on On Chip block) be compiled
> > >> statically too ?
> > > 
> > > Given the move to multiplatform kernels we need to aim for as few modules
> > > compiled in as possible. I'd say this includes HDMI encoders, panels and
> > > display controllers.
> > > 
> > >>> Also if you don't want to use deferred probe, then you're in for the
> > >>> full hotplugging panel dance and that implies that you need to fix a
> > >>> bunch of things in DRM (one being the framebuffer console
> > >>> instantiation
> > >>> that I referred to in the other thread).
> > >> 
> > >> For now, I wait until there is a device connected on the RGB connector
> > >> (connector status set to connector_status_connected) before creating an
> > >> fbdev. It might not be the cleanest way to solve this issue, but it
> > >> works :-).
> > > 
> > > Do you create a new drm_encoder at runtime for the HDMI encoder when it
> > > appears ? I thought the DRM core and API were not able to correctly cope
> > > with that.
> > 
> > I haven't started to work on the HDMI encoder yet, and ATM I only have
> > a single connector (which is true from an HW POV), which is then bound
> > to an LCD panel (the only type of remote endpoint I currently support).
> > 
> > BTW, I wonder how my use case should be represented in the DRM
> > subsystem. As I said, from an HW POV I only have one RGB (or whatever
> > name you choose for it) connector. But on such kind of connectors you
> > can connect several output devices (panels, encoders, ...).
> > And in my case I have 2 devices on the same RGB connector: a panel and
> > an RGB to HDMI converter.
> 
> The DRM connector object was initially meant to model a physical user-
> accessible connector on a board (VGA, DVI, HDMI, ...) and the properties of 
> the monitor plugged into it. It has then been (ab)used to represent panels, 
> as 
> they're similar to monitors.
> 
> In your case the VGA and HDMI connectors should be modeled as DRM connectors, 
> the RGB to HDMI encoder as a DRM encoder, and the LCDC as a DRM CRTC.

I don't have any VGA connector (or I'm missing something :-)), but I
have an LCD panel and an RGB to HDMI encoder connected on the same RGB
connector.

> 
> As DRM hardcodes the pipeline model to CRTC -> encoder -> connector, you will 
> also need a DRM encoder in the VGA path. I suppose your board has a VGA DAC, 
> that's the component you should expose as a DRM encoder (even if it can't be 
> controlled and doesn't limit the valid modes).

Actually, my problem is that both devices are connected on the same RGB
connector, and thus share the same display mode (resolution, HSYNC,
VSYNC, RGB output mode, ...).
This means that all remote devices have to agree on a specific mode if
we want to mirror the display on several output devices, otherwise we
must disable one of the output devices.

> 
> > >>> You also can't be using the current device tree bindings because they
> > >>> all assume a dependency from the display controller/output to the
> > >>> panel. For hotplugging you'd need the dependency the other way around
> > >>> (the panel needs to refer to the output by phandle).
> > >> 
> > >> Here [1] is a proposal for notification support in the drm_panel
> > >> infrastructure (which is not that complicated), and here [2] is how
> > >> I use it in my atmel-hlcdc driver to generate hotplug events.
> > > 
> > > Is there a way we could use the component framework for that ? I know that
> > > partial notification isn't supported at the moment, but Russell agreed it
> > > was a real use case that should be implemented at some point.
> > 
> > I'll give it a try.
> 



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 00/11] drm: add support for Atmel HLCDC Display Controller

2014-08-28 Thread Boris BREZILLON
Hi Laurent,

On Thu, 28 Aug 2014 14:19:22 +0200
Laurent Pinchart  wrote:

> Hi Boris,

[...]

> >
> > I don't have any VGA connector (or I'm missing something :-)),
> 
> My bad.

No problem.

> 
> > but I have an LCD panel and an RGB to HDMI encoder connected on the same RGB
> > connector.
> 
> There's no such thing as an RGB connector in DRM. Your SoC has a parallel RGB 
> video output (I assume it's a DPI bus). From a DRM point of view, that bus 
> corresponds to the output of the CRTC.

Okay, this mean I'll have to dispatch some of the code I've put in
atmel_hlcdc_output.c into atmel_hlcdc_crtc.c (BTW, any chance you could
take a look at this files ?).

> 
> > > As DRM hardcodes the pipeline model to CRTC -> encoder -> connector, you
> > > will also need a DRM encoder in the VGA path. I suppose your board has a
> > > VGA DAC, that's the component you should expose as a DRM encoder (even if
> > > it can't be controlled and doesn't limit the valid modes).
> > 
> > Actually, my problem is that both devices are connected on the same RGB
> > connector, and thus share the same display mode (resolution, HSYNC,
> > VSYNC, RGB output mode, ...).
> > This means that all remote devices have to agree on a specific mode if
> > we want to mirror the display on several output devices, otherwise we
> > must disable one of the output devices.
> 
> That's not really a problem. From a DRM perspective you need to model your 
> device as
> 
> ,--.   ,---.   ,-.
> | CRTC | -+--> | Dummy Encoder | > | Panel Connector |
> `--?  |`---?   `-?
>   |,---.   ,-.
>   \--> | HDMI Encoder  | > | HDMI Connector  |
>`---?   `-?
> 
> The HDMI pipeline is pretty straightforward.
> 
> You have told me that the panel has a parallel RGB input without any encoder 
> in the panel pipeline (by the way, which panel model are you using ?). 
> However, DRM requires an encoder in every pipeline. You will thus need to 
> instantiate a dummy encoder. One option would be to set the encoder and 
> connector types to DRM_MODE_ENCODER_LVDS and DRM_MODE_CONNECTOR_LVDS 
> respectively, as that's what userspace usually expects for panels. That 
> doesn't reflect the reality in your case though, so creating a new 
> DRM_MODE_CONNECTOR_DPI type might be needed, possibly to be used with 
> DRM_MODE_ENCODER_NONE.
> 
> As neither encoder can modify the mode, the same mode will be output on the 
> two connectors.

There are still several things to I'd like to understand:
 1) who's gonna configure the RGB bus output format (RGB444, RGB666,
RGB888) which directly depends on the device connected on this bus:
the CRTC or the dummy and HDMI encoders.
 2) Where should the HDMI encoder/connector support be implemented:
in drivers/gpu/drm/atmel-hlcdc, drivers/gpu/drm/bridge or somewhere
else. My point is that I don't want to add specific support for the
Sil902x transmitter chip in the hlcdc driver.

Sorry if these are silly questions, but I'm still trying to understand
how my case should be modeled :-).

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 2/3] drm: panel: simple-panel: add support for bus_format retrieval

2014-12-01 Thread Boris Brezillon
Provide a way to specify panel requirement in terms of supported media bus
format (particularly useful for panels connected to an RGB or LVDS bus).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 23de22f..66838a5 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -61,6 +61,8 @@ struct panel_desc {
unsigned int disable;
unsigned int unprepare;
} delay;
+
+   u32 bus_format;
 };

 struct panel_simple {
@@ -111,6 +113,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple 
*panel)
connector->display_info.bpc = panel->desc->bpc;
connector->display_info.width_mm = panel->desc->size.width;
connector->display_info.height_mm = panel->desc->size.height;
+   if (panel->desc->bus_format)
+   drm_display_info_set_bus_formats(>display_info,
+>desc->bus_format, 1);

return num;
 }
-- 
1.9.1



[PATCH v4 3/3] drm: panel: simple-panel: add bus format information for foxlink panel

2014-12-01 Thread Boris Brezillon
Foxlink's fl500wvr00-a0t supports RGB888 format.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 66838a5..695f406 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -545,6 +545,7 @@ static const struct panel_desc foxlink_fl500wvr00_a0t = {
.width = 108,
.height = 65,
},
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
 };

 static const struct drm_display_mode innolux_n116bge_mode = {
-- 
1.9.1



[PATCH v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Add bus_formats and num_bus_formats fields and
drm_display_info_set_bus_formats helper function to specify the bus
formats supported by a given display.

This information can be used by display controller drivers to configure
the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
RGB or LVDS busses).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/drm_crtc.c | 32 
 include/drm/drm_crtc.h |  7 +++
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e79c8d3..d3b7ed0 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -763,6 +763,38 @@ static void drm_mode_remove(struct drm_connector 
*connector,
drm_mode_destroy(connector->dev, mode);
 }

+/*
+ * drm_display_info_set_bus_formats - set the supported bus formats
+ * @info: display info to store bus formats in
+ * @fmts: array containing the supported bus formats
+ * @nfmts: the number of entries in the fmts array
+ *
+ * Store the suppported bus formats in display info structure.
+ * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
+ * a full list of available formats.
+ */
+int drm_display_info_set_bus_formats(struct drm_display_info *info, const u32 
*fmts,
+unsigned int num_fmts)
+{
+   u32 *formats = NULL;
+
+   if (!fmts && num_fmts)
+   return -EINVAL;
+
+   if (fmts && num_fmts) {
+   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
+   if (!formats)
+   return -ENOMEM;
+   }
+
+   kfree(info->bus_formats);
+   info->bus_formats = formats;
+   info->num_bus_formats = num_fmts;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_display_info_set_bus_formats);
+
 /**
  * drm_connector_get_cmdline_mode - reads the user's cmdline mode
  * @connector: connector to quwery
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c40070a..a35844f 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +131,9 @@ struct drm_display_info {
enum subpixel_order subpixel_order;
u32 color_formats;

+   const u32 *bus_formats;
+   unsigned int num_bus_formats;
+
/* Mask of supported hdmi deep color modes */
u8 edid_hdmi_dc_modes;

@@ -982,6 +986,9 @@ extern int drm_mode_connector_set_path_property(struct 
drm_connector *connector,
 extern int drm_mode_connector_update_edid_property(struct drm_connector 
*connector,
struct edid *edid);

+extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
+   const u32 *fmts, unsigned int 
nfmts);
+
 static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
 {
-- 
1.9.1



[PATCH v4 0/3] drm: describe display bus format

2014-12-01 Thread Boris Brezillon
Hello,

This series makes use of the MEDIA_BUS_FMT definition to describe how
the data are transmitted to the display.

This will allow drivers to configure their output display bus according
to the display capabilities.
For example some display controllers support DPI (or raw RGB) connectors
and need to specify which format will be transmitted on the DPI bus
(RGB444, RGB565, RGB888, ...).

This series also adds a field to the panel_desc struct so that one
can specify which format is natevely supported by a panel.

Regards,

Boris

Changes since v3:
 - store num_bus_formats on an unsigned int
 - clearly state that fmts argument (in drm_display_info_set_bus_formats
   function) should be an array of MEDIA_BUS_FMT_* values.

Changes since v2:
 - use the MEDIA_BUS_FMT macros

Changes since v1:
 - rename nformats into num_formats
 - declare num_formats as an unsigned int

Boris Brezillon (3):
  drm: add bus_formats and num_bus_formats fields to drm_display_info
  drm: panel: simple-panel: add support for bus_format retrieval
  drm: panel: simple-panel: add bus format information for foxlink panel

 drivers/gpu/drm/drm_crtc.c   | 32 
 drivers/gpu/drm/panel/panel-simple.c |  6 ++
 include/drm/drm_crtc.h   |  7 +++
 3 files changed, 45 insertions(+)

-- 
1.9.1



[PATCH v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Add bus_formats and num_bus_formats fields and
drm_display_info_set_bus_formats helper function to specify the bus
formats supported by a given display.

This information can be used by display controller drivers to configure
the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
RGB or LVDS busses).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/drm_crtc.c | 32 
 include/drm/drm_crtc.h |  7 +++
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e79c8d3..d3b7ed0 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -763,6 +763,38 @@ static void drm_mode_remove(struct drm_connector 
*connector,
drm_mode_destroy(connector->dev, mode);
 }

+/*
+ * drm_display_info_set_bus_formats - set the supported bus formats
+ * @info: display info to store bus formats in
+ * @fmts: array containing the supported bus formats
+ * @nfmts: the number of entries in the fmts array
+ *
+ * Store the suppported bus formats in display info structure.
+ * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
+ * a full list of available formats.
+ */
+int drm_display_info_set_bus_formats(struct drm_display_info *info, const u32 
*fmts,
+unsigned int num_fmts)
+{
+   u32 *formats = NULL;
+
+   if (!fmts && num_fmts)
+   return -EINVAL;
+
+   if (fmts && num_fmts) {
+   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
+   if (!formats)
+   return -ENOMEM;
+   }
+
+   kfree(info->bus_formats);
+   info->bus_formats = formats;
+   info->num_bus_formats = num_fmts;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_display_info_set_bus_formats);
+
 /**
  * drm_connector_get_cmdline_mode - reads the user's cmdline mode
  * @connector: connector to quwery
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c40070a..a35844f 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +131,9 @@ struct drm_display_info {
enum subpixel_order subpixel_order;
u32 color_formats;

+   const u32 *bus_formats;
+   unsigned int num_bus_formats;
+
/* Mask of supported hdmi deep color modes */
u8 edid_hdmi_dc_modes;

@@ -982,6 +986,9 @@ extern int drm_mode_connector_set_path_property(struct 
drm_connector *connector,
 extern int drm_mode_connector_update_edid_property(struct drm_connector 
*connector,
struct edid *edid);

+extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
+   const u32 *fmts, unsigned int 
nfmts);
+
 static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
 {
-- 
1.9.1



[PATCH v4 3/3] drm: panel: simple-panel: add bus format information for foxlink panel

2014-12-01 Thread Boris Brezillon
Foxlink's fl500wvr00-a0t supports RGB888 format.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 66838a5..695f406 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -545,6 +545,7 @@ static const struct panel_desc foxlink_fl500wvr00_a0t = {
.width = 108,
.height = 65,
},
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
 };

 static const struct drm_display_mode innolux_n116bge_mode = {
-- 
1.9.1



[PATCH v4 0/3] drm: describe display bus format

2014-12-01 Thread Boris Brezillon
Hello,

This series makes use of the MEDIA_BUS_FMT definition to describe how
the data are transmitted to the display.

This will allow drivers to configure their output display bus according
to the display capabilities.
For example some display controllers support DPI (or raw RGB) connectors
and need to specify which format will be transmitted on the DPI bus
(RGB444, RGB565, RGB888, ...).

This series also adds a field to the panel_desc struct so that one
can specify which format is natevely supported by a panel.

Regards,

Boris

Changes since v3:
 - store num_bus_formats on an unsigned int
 - clearly state that fmts argument (in drm_display_info_set_bus_formats
   function) should be an array of MEDIA_BUS_FMT_* values.

Changes since v2:
 - use the MEDIA_BUS_FMT macros

Changes since v1:
 - rename nformats into num_formats
 - declare num_formats as an unsigned int

Boris Brezillon (3):
  drm: add bus_formats and num_bus_formats fields to drm_display_info
  drm: panel: simple-panel: add support for bus_format retrieval
  drm: panel: simple-panel: add bus format information for foxlink panel

 drivers/gpu/drm/drm_crtc.c   | 32 
 drivers/gpu/drm/panel/panel-simple.c |  6 ++
 include/drm/drm_crtc.h   |  7 +++
 3 files changed, 45 insertions(+)

-- 
1.9.1



[PATCH v4 2/3] drm: panel: simple-panel: add support for bus_format retrieval

2014-12-01 Thread Boris Brezillon
Provide a way to specify panel requirement in terms of supported media bus
format (particularly useful for panels connected to an RGB or LVDS bus).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 23de22f..66838a5 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -61,6 +61,8 @@ struct panel_desc {
unsigned int disable;
unsigned int unprepare;
} delay;
+
+   u32 bus_format;
 };

 struct panel_simple {
@@ -111,6 +113,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple 
*panel)
connector->display_info.bpc = panel->desc->bpc;
connector->display_info.width_mm = panel->desc->size.width;
connector->display_info.height_mm = panel->desc->size.height;
+   if (panel->desc->bus_format)
+   drm_display_info_set_bus_formats(>display_info,
+>desc->bus_format, 1);

return num;
 }
-- 
1.9.1



[PATCH RESEND v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Add bus_formats and num_bus_formats fields and
drm_display_info_set_bus_formats helper function to specify the bus
formats supported by a given display.

This information can be used by display controller drivers to configure
the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
RGB or LVDS busses).

Signed-off-by: Boris Brezillon 
---
Hi,

Sorry for the noise: I ran checkpatch after sending the series and it found
a typo and two "line over 80 characters" warnings.

This version fixes those warnings.

Regards,

Boris

 drivers/gpu/drm/drm_crtc.c | 33 +
 include/drm/drm_crtc.h |  8 
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e79c8d3..20030ec 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -763,6 +763,39 @@ static void drm_mode_remove(struct drm_connector 
*connector,
drm_mode_destroy(connector->dev, mode);
 }

+/*
+ * drm_display_info_set_bus_formats - set the supported bus formats
+ * @info: display info to store bus formats in
+ * @fmts: array containing the supported bus formats
+ * @nfmts: the number of entries in the fmts array
+ *
+ * Store the supported bus formats in display info structure.
+ * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
+ * a full list of available formats.
+ */
+int drm_display_info_set_bus_formats(struct drm_display_info *info,
+const u32 *fmts,
+unsigned int num_fmts)
+{
+   u32 *formats = NULL;
+
+   if (!fmts && num_fmts)
+   return -EINVAL;
+
+   if (fmts && num_fmts) {
+   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
+   if (!formats)
+   return -ENOMEM;
+   }
+
+   kfree(info->bus_formats);
+   info->bus_formats = formats;
+   info->num_bus_formats = num_fmts;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_display_info_set_bus_formats);
+
 /**
  * drm_connector_get_cmdline_mode - reads the user's cmdline mode
  * @connector: connector to quwery
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c40070a..65dd08a 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +131,9 @@ struct drm_display_info {
enum subpixel_order subpixel_order;
u32 color_formats;

+   const u32 *bus_formats;
+   unsigned int num_bus_formats;
+
/* Mask of supported hdmi deep color modes */
u8 edid_hdmi_dc_modes;

@@ -982,6 +986,10 @@ extern int drm_mode_connector_set_path_property(struct 
drm_connector *connector,
 extern int drm_mode_connector_update_edid_property(struct drm_connector 
*connector,
struct edid *edid);

+extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
+   const u32 *fmts,
+   unsigned int nfmts);
+
 static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
 {
-- 
1.9.1



[PATCH RESEND v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Hi Laurent,

On Mon, 01 Dec 2014 15:00:15 +0200
Laurent Pinchart  wrote:

> Hi Boris,
> 
> Thank you for the patch.
> 
> On Monday 01 December 2014 09:42:15 Boris Brezillon wrote:
> > Add bus_formats and num_bus_formats fields and
> > drm_display_info_set_bus_formats helper function to specify the bus
> > formats supported by a given display.
> > 
> > This information can be used by display controller drivers to configure
> > the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
> > RGB or LVDS busses).
> > 
> > Signed-off-by: Boris Brezillon 
> 
> Acked-by: Laurent Pinchart 
> 
> > ---
> > Hi,
> > 
> > Sorry for the noise: I ran checkpatch after sending the series and it found
> > a typo and two "line over 80 characters" warnings.
> > 
> > This version fixes those warnings.
> 
> Please remember to increment the version number next time, it gets confusing 
> otherwise when people start asking questions such as "which v4 ?".

Okay. I wasn't sure, and eventually decided to just prefix the version
with RESEND because these were only cosmetic changes, and I fixed them
right after sending the v4.

I'll know for next time ;-).

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Hi Philipp,

On Mon, 01 Dec 2014 16:06:26 +0100
Philipp Zabel  wrote:

> Am Montag, den 01.12.2014, 09:20 +0100 schrieb Boris Brezillon:
> > Add bus_formats and num_bus_formats fields and
> > drm_display_info_set_bus_formats helper function to specify the bus
> > formats supported by a given display.
> > 
> > This information can be used by display controller drivers to configure
> > the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
> > RGB or LVDS busses).
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  drivers/gpu/drm/drm_crtc.c | 32 
> >  include/drm/drm_crtc.h |  7 +++
> >  2 files changed, 39 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index e79c8d3..d3b7ed0 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -763,6 +763,38 @@ static void drm_mode_remove(struct drm_connector 
> > *connector,
> > drm_mode_destroy(connector->dev, mode);
> >  }
> >  
> > +/*
> > + * drm_display_info_set_bus_formats - set the supported bus formats
> > + * @info: display info to store bus formats in
> > + * @fmts: array containing the supported bus formats
> > + * @nfmts: the number of entries in the fmts array
> > + *
> > + * Store the suppported bus formats in display info structure.
> > + * See MEDIA_BUS_FMT_* definitions in 
> > include/uapi/linux/media-bus-format.h for
> > + * a full list of available formats.
> > + */
> > +int drm_display_info_set_bus_formats(struct drm_display_info *info, const 
> > u32 *fmts,
> > +unsigned int num_fmts)
> > +{
> > +   u32 *formats = NULL;
> > +
> > +   if (!fmts && num_fmts)
> > +   return -EINVAL;
> > +
> > +   if (fmts && num_fmts) {
> > +   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
> > +   if (!formats)
> > +   return -ENOMEM;
> > +   }
> > +
> > +   kfree(info->bus_formats);
> > +   info->bus_formats = formats;
> > +   info->num_bus_formats = num_fmts;
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL(drm_display_info_set_bus_formats);
> > +
> >  /**
> >   * drm_connector_get_cmdline_mode - reads the user's cmdline mode
> >   * @connector: connector to quwery
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index c40070a..a35844f 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -31,6 +31,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> 
> Nothing in drm_crtc.h uses MEDIA_BUS_FMT_*, is media-bus-format.h
> included here for the convenience of the user of
> drm_display_info_set_bus_formats?

Yes it is. Actually in the first versions MEDIA_BUS_FMT_* values were
part of an enum.
Still, I think keeping this include will help people finding where
those MEDIA_BUS_FMT_* macros are defined.

Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v4 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Hi Thierry,

On Mon, 1 Dec 2014 16:42:58 +0100
Thierry Reding  wrote:

> On Mon, Dec 01, 2014 at 09:20:59AM +0100, Boris Brezillon wrote:
> > Add bus_formats and num_bus_formats fields and
> > drm_display_info_set_bus_formats helper function to specify the bus
> > formats supported by a given display.
> > 
> > This information can be used by display controller drivers to configure
> > the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
> > RGB or LVDS busses).
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  drivers/gpu/drm/drm_crtc.c | 32 
> >  include/drm/drm_crtc.h |  7 +++
> >  2 files changed, 39 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index e79c8d3..d3b7ed0 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -763,6 +763,38 @@ static void drm_mode_remove(struct drm_connector 
> > *connector,
> > drm_mode_destroy(connector->dev, mode);
> >  }
> >  
> > +/*
> 
> This needs a /** marker to make it a valid kerneldoc comment.

Yep, I'll fix that.

> 
> > + * drm_display_info_set_bus_formats - set the supported bus formats
> > + * @info: display info to store bus formats in
> > + * @fmts: array containing the supported bus formats
> > + * @nfmts: the number of entries in the fmts array
> > + *
> > + * Store the suppported bus formats in display info structure.
> > + * See MEDIA_BUS_FMT_* definitions in 
> > include/uapi/linux/media-bus-format.h for
> > + * a full list of available formats.
> > + */
> > +int drm_display_info_set_bus_formats(struct drm_display_info *info, const 
> > u32 *fmts,
> 
> This one still exceeds 80-characters per line, but perhaps I'm reviewing
> the wrong patch? Also I think fmts should be formats here.
> 
> > +unsigned int num_fmts)
> 
> And this should be num_formats, for consistency. Also make sure to keep
> this consistent with the kerneldoc.
> 
> > +{
> > +   u32 *formats = NULL;
> 
> If you name the parameter formats, maybe bus_formats would be a good
> alternative for this local variable. Or fmts here. I think it's most
> important that the public API gets the more idiomatic name.

Okay, I'll rework the argument and variable names.

> 
> > +
> > +   if (!fmts && num_fmts)
> > +   return -EINVAL;
> > +
> > +   if (fmts && num_fmts) {
> > +   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
> > +   if (!formats)
> > +   return -ENOMEM;
> > +   }
> > +
> > +   kfree(info->bus_formats);
> > +   info->bus_formats = formats;
> > +   info->num_bus_formats = num_fmts;
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL(drm_display_info_set_bus_formats);
> 
> I think you'll want to call kfree() on the bus_formats array from
> drm_connector_cleanup() as well to make sure you don't leak this on
> driver unload.

Indeed, I'll fix that memory leak.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v5 0/3] drm: describe display bus format

2014-12-01 Thread Boris Brezillon
Hello,

This series makes use of the MEDIA_BUS_FMT definition to describe how
the data are transmitted to the display.

This will allow drivers to configure their output display bus according
to the display capabilities.
For example some display controllers support DPI (or raw RGB) connectors
and need to specify which format will be transmitted on the DPI bus
(RGB444, RGB565, RGB888, ...).

This series also adds a field to the panel_desc struct so that one
can specify which format is natevely supported by a panel.

Regards,

Boris

Changes since v4:
 - fix typo
 - fix 'line over 80 characters' warnings
 - fix leak of formats array

Changes since v3:
 - store num_bus_formats on an unsigned int
 - clearly state that fmts argument (in drm_display_info_set_bus_formats
   function) should be an array of MEDIA_BUS_FMT_* values.

Changes since v2:
 - use the MEDIA_BUS_FMT macros

Changes since v1:
 - rename nformats into num_formats
 - declare num_formats as an unsigned int

Boris Brezillon (3):
  drm: add bus_formats and num_bus_formats fields to drm_display_info
  drm: panel: simple-panel: add support for bus_format retrieval
  drm: panel: simple-panel: add bus format information for foxlink panel

 drivers/gpu/drm/drm_crtc.c   | 35 +++
 drivers/gpu/drm/panel/panel-simple.c |  6 ++
 include/drm/drm_crtc.h   |  8 
 3 files changed, 49 insertions(+)

-- 
1.9.1



[PATCH v5 1/3] drm: add bus_formats and num_bus_formats fields to drm_display_info

2014-12-01 Thread Boris Brezillon
Add bus_formats and num_bus_formats fields and
drm_display_info_set_bus_formats helper function to specify the bus
formats supported by a given display.

This information can be used by display controller drivers to configure
the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
RGB or LVDS busses).

Signed-off-by: Boris Brezillon 
Acked-by: Laurent Pinchart 
Acked-by: Philipp Zabel 
---
 drivers/gpu/drm/drm_crtc.c | 35 +++
 include/drm/drm_crtc.h |  8 
 2 files changed, 43 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e79c8d3..1295863 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -764,6 +764,40 @@ static void drm_mode_remove(struct drm_connector 
*connector,
 }

 /**
+ * drm_display_info_set_bus_formats - set the supported bus formats
+ * @info: display info to store bus formats in
+ * @fmts: array containing the supported bus formats
+ * @nfmts: the number of entries in the fmts array
+ *
+ * Store the supported bus formats in display info structure.
+ * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
+ * a full list of available formats.
+ */
+int drm_display_info_set_bus_formats(struct drm_display_info *info,
+const u32 *formats,
+unsigned int num_formats)
+{
+   u32 *fmts = NULL;
+
+   if (!formats && num_formats)
+   return -EINVAL;
+
+   if (formats && num_formats) {
+   fmts = kmemdup(formats, sizeof(*formats) * num_formats,
+  GFP_KERNEL);
+   if (!formats)
+   return -ENOMEM;
+   }
+
+   kfree(info->bus_formats);
+   info->bus_formats = fmts;
+   info->num_bus_formats = num_formats;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_display_info_set_bus_formats);
+
+/**
  * drm_connector_get_cmdline_mode - reads the user's cmdline mode
  * @connector: connector to quwery
  * @mode: returned mode
@@ -914,6 +948,7 @@ void drm_connector_cleanup(struct drm_connector *connector)
ida_remove(_connector_enum_list[connector->connector_type].ida,
   connector->connector_type_id);

+   kfree(connector->display_info.bus_formats);
drm_mode_object_put(dev, >base);
kfree(connector->name);
connector->name = NULL;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c40070a..5d351f5 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +131,9 @@ struct drm_display_info {
enum subpixel_order subpixel_order;
u32 color_formats;

+   const u32 *bus_formats;
+   unsigned int num_bus_formats;
+
/* Mask of supported hdmi deep color modes */
u8 edid_hdmi_dc_modes;

@@ -982,6 +986,10 @@ extern int drm_mode_connector_set_path_property(struct 
drm_connector *connector,
 extern int drm_mode_connector_update_edid_property(struct drm_connector 
*connector,
struct edid *edid);

+extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
+   const u32 *formats,
+   unsigned int num_formats);
+
 static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
 {
-- 
1.9.1



[PATCH v5 2/3] drm: panel: simple-panel: add support for bus_format retrieval

2014-12-01 Thread Boris Brezillon
Provide a way to specify panel requirement in terms of supported media bus
format (particularly useful for panels connected to an RGB or LVDS bus).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 23de22f..66838a5 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -61,6 +61,8 @@ struct panel_desc {
unsigned int disable;
unsigned int unprepare;
} delay;
+
+   u32 bus_format;
 };

 struct panel_simple {
@@ -111,6 +113,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple 
*panel)
connector->display_info.bpc = panel->desc->bpc;
connector->display_info.width_mm = panel->desc->size.width;
connector->display_info.height_mm = panel->desc->size.height;
+   if (panel->desc->bus_format)
+   drm_display_info_set_bus_formats(>display_info,
+>desc->bus_format, 1);

return num;
 }
-- 
1.9.1



[PATCH v5 3/3] drm: panel: simple-panel: add bus format information for foxlink panel

2014-12-01 Thread Boris Brezillon
Foxlink's fl500wvr00-a0t supports RGB888 format.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 66838a5..695f406 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -545,6 +545,7 @@ static const struct panel_desc foxlink_fl500wvr00_a0t = {
.width = 108,
.height = 65,
},
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
 };

 static const struct drm_display_mode innolux_n116bge_mode = {
-- 
1.9.1



[PATCH] drm: panel: simple-panel: remove useless drm_mode_set_name

2015-04-30 Thread Boris Brezillon
drm_display_mode_from_videomode() is already calling drm_mode_set_name() on
the provided mode.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 30904a9..d14b904 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -112,7 +112,6 @@ static int panel_simple_get_fixed_modes(struct panel_simple 
*panel)
}

drm_display_mode_from_videomode(, mode);
-   drm_mode_set_name(mode);

drm_mode_probed_add(connector, mode);
num++;
-- 
1.9.1



[PATCH] drm: panel: simple-panel: set appropriate mode type

2015-04-30 Thread Boris Brezillon
All modes exposed by simple panels should be tagged as driver defined
modes.
Moreover, if a panel supports only one mode, this mode is obviously the
preferred one.

Doing this also fix a problem occurring when a 'video=' parameter is passed
on the kernel cmdline. In some cases the user provided mode is preferred
over the simple panel ones, which might result in unpredictable behavior.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index d14b904..95ae390 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -111,6 +111,10 @@ static int panel_simple_get_fixed_modes(struct 
panel_simple *panel)
continue;
}

+   mode->type |= DRM_MODE_TYPE_DRIVER;
+   if (panel->desc->num_modes == 1)
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+
drm_display_mode_from_videomode(, mode);

drm_mode_probed_add(connector, mode);
@@ -127,6 +131,10 @@ static int panel_simple_get_fixed_modes(struct 
panel_simple *panel)
continue;
}

+   mode->type |= DRM_MODE_TYPE_DRIVER;
+   if (panel->desc->num_modes == 1)
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+
drm_mode_set_name(mode);

drm_mode_probed_add(connector, mode);
-- 
1.9.1



[PATCH v2 0/2] clk: adapt ->round_rate()/->determine_rate() prototypes

2015-04-30 Thread Boris Brezillon
Hello,

As previously discussed in this thread [1], this series is changing
clk_ops' ->round_rate()/->determine_rate() prototypes to avoid long
overflows when the returned rate is exceeding 2Ghz.

Most of those changes have been compile-tested, but none of them have
been tested on real hardware (the changes are quite simple though).

Best Regards,

Boris

[1]https://lkml.org/lkml/2015/4/14/528

Changes since v1:
- fix an 'uninitialized variable' bug reported by Heiko
- rebased on clk-next

CC: Jonathan Corbet 
CC: Shawn Guo 
CC: ascha Hauer 
CC: David Brown 
CC: Daniel Walker 
CC: Bryan Huntsman 
CC: Tony Lindgren 
CC: Paul Walmsley 
CC: Liviu Dudau 
CC: Sudeep Holla 
CC: Lorenzo Pieralisi 
CC: Ralf Baechle 
CC: Max Filippov 
CC: Heiko Stuebner 
CC: Sylwester Nawrocki  
CC: Tomasz Figa 
CC: Barry Song 
CC: Viresh Kumar 
CC: "Emilio López" 
CC: Maxime Ripard 
CC: Peter De Schrijver 
CC: Prashant Gaikwad 
CC: Stephen Warren 
CC: Thierry Reding 
CC: Alexandre Courbot 
CC: Tero Kristo 
CC: Ulf Hansson 
CC: Michal Simek 
CC: Philipp Zabel 
CC: linux-doc at vger.kernel.org
CC: linux-kernel at vger.kernel.org
CC: linux-arm-kernel at lists.infradead.org
CC: linux-arm-msm at vger.kernel.org
CC: linux-omap at vger.kernel.org
CC: linux-mips at linux-mips.org
CC: patches at opensource.wolfsonmicro.com
CC: linux-rockchip at lists.infradead.org
CC: linux-samsung-soc at vger.kernel.org
CC: spear-devel at list.st.com
CC: linux-tegra at vger.kernel.org
CC: dri-devel at lists.freedesktop.org
CC: linux-media at vger.kernel.org
CC: rtc-linux at googlegroups.com

Boris Brezillon (2):
  clk: change clk_ops' ->round_rate() prototype
  clk: change clk_ops' ->determine_rate() prototype

 Documentation/clk.txt|  8 +--
 arch/arm/mach-imx/clk-busy.c |  2 +-
 arch/arm/mach-imx/clk-cpu.c  | 12 +++-
 arch/arm/mach-imx/clk-fixup-div.c|  2 +-
 arch/arm/mach-imx/clk-pfd.c  | 11 ++--
 arch/arm/mach-imx/clk-pllv2.c|  8 ++-
 arch/arm/mach-imx/clk-pllv3.c| 46 +++--
 arch/arm/mach-msm/clock-pcom.c   |  4 +-
 arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 13 ++--
 arch/arm/mach-omap2/clkt_clksel.c|  6 +-
 arch/arm/mach-omap2/clkt_dpll.c  | 21 +++---
 arch/arm/mach-omap2/clock.h  |  4 +-
 arch/arm/mach-omap2/dpll3xxx.c   | 45 -
 arch/arm/mach-omap2/dpll44xx.c   | 44 +++--
 arch/arm/mach-vexpress/spc.c | 11 +++-
 arch/mips/alchemy/common/clock.c | 76 ++
 drivers/clk/at91/clk-h32mx.c | 24 ---
 drivers/clk/at91/clk-peripheral.c| 31 +
 drivers/clk/at91/clk-pll.c   | 14 ++--
 drivers/clk/at91/clk-plldiv.c| 22 ---
 drivers/clk/at91/clk-programmable.c  | 28 
 drivers/clk/at91/clk-smd.c   | 24 ---
 drivers/clk/at91/clk-usb.c   | 42 ++--
 drivers/clk/bcm/clk-kona.c   | 24 ---
 drivers/clk/clk-axi-clkgen.c |  5 +-
 drivers/clk/clk-cdce706.c| 46 ++---
 drivers/clk/clk-composite.c  | 27 
 drivers/clk/clk-divider.c| 16 +++--
 drivers/clk/clk-fixed-factor.c   |  7 +-
 drivers/clk/clk-fractional-divider.c | 16 +++--
 drivers/clk/clk-highbank.c   | 18 +++---
 drivers/clk/clk-si5351.c | 96 ++--
 drivers/clk/clk-si570.c  | 14 ++--
 drivers/clk/clk-u300.c   | 65 ++-
 drivers/clk/clk-vt8500.c | 27 
 drivers/clk/clk-wm831x.c | 11 ++--
 drivers/clk/clk-xgene.c  | 11 ++--
 drivers/clk/clk.c| 72 +++--
 drivers/clk/hisilicon/clk-hi3620.c   | 22 +++
 drivers/clk/mmp/clk-frac.c   | 14 ++--
 drivers/clk/mmp/clk-mix.c| 17 ++---
 drivers/clk/mvebu/clk-corediv.c  |  7 +-
 drivers/clk/mvebu/clk-cpu.c  |  9 +--
 drivers/clk/mxs/clk-div.c|  4 +-
 drivers/clk/mxs/clk-frac.c   | 11 ++--
 drivers/clk/mxs/clk-ref.c| 11 ++--
 drivers/clk/qcom/clk-pll.c   | 12 ++--
 drivers/clk/qcom/clk-rcg.c   | 32 +-
 drivers/clk/qcom/clk-rcg2.c  | 54 +---
 drivers/clk/qcom/clk-regmap-divider.c|  4 +-
 drivers/clk/rockchip/clk-pll.c   | 13 ++--
 drivers/clk/samsung/clk-pll.c| 13 ++--
 drivers/clk/shmobile/clk-div6.c  |  7 +-
 drivers/clk/shmobile/clk-rcar-gen2.c |  9 +--
 drivers/clk/sirf/clk-common.c| 18 +++---
 drivers/clk/spear/clk-aux-synth.c| 10 

[PATCH v2 1/2] clk: change clk_ops' ->round_rate() prototype

2015-04-30 Thread Boris Brezillon
Clock rates are stored in an unsigned long field, but ->round_rate()
(which returns a rounded rate from a requested one) returns a long
value (errors are reported using negative error codes), which can lead
to long overflow if the clock rate exceed 2Ghz.

Change ->round_rate() prototype to return 0 or an error code, and pass the
requested rate as a pointer so that it can be adjusted depending on
hardware capabilities.

Signed-off-by: Boris Brezillon 
Tested-by: Heiko Stuebner 
Tested-by: Mikko Perttunen 
Reviewed-by: Heiko Stuebner 
---
CC: Jonathan Corbet 
CC: Shawn Guo 
CC: ascha Hauer 
CC: David Brown 
CC: Daniel Walker 
CC: Bryan Huntsman 
CC: Tony Lindgren 
CC: Paul Walmsley 
CC: Liviu Dudau 
CC: Sudeep Holla 
CC: Lorenzo Pieralisi 
CC: Ralf Baechle 
CC: Max Filippov 
CC: Heiko Stuebner 
CC: Sylwester Nawrocki  
CC: Tomasz Figa 
CC: Barry Song 
CC: Viresh Kumar 
CC: "Emilio López" 
CC: Maxime Ripard 
CC: Peter De Schrijver 
CC: Prashant Gaikwad 
CC: Stephen Warren 
CC: Thierry Reding 
CC: Alexandre Courbot 
CC: Tero Kristo 
CC: Ulf Hansson 
CC: Michal Simek 
CC: Philipp Zabel 
CC: linux-doc at vger.kernel.org
CC: linux-kernel at vger.kernel.org
CC: linux-arm-kernel at lists.infradead.org
CC: linux-arm-msm at vger.kernel.org
CC: linux-omap at vger.kernel.org
CC: linux-mips at linux-mips.org
CC: patches at opensource.wolfsonmicro.com
CC: linux-rockchip at lists.infradead.org
CC: linux-samsung-soc at vger.kernel.org
CC: spear-devel at list.st.com
CC: linux-tegra at vger.kernel.org
CC: dri-devel at lists.freedesktop.org
CC: linux-media at vger.kernel.org
CC: rtc-linux at googlegroups.com

 Documentation/clk.txt|  4 +-
 arch/arm/mach-imx/clk-busy.c |  2 +-
 arch/arm/mach-imx/clk-cpu.c  | 12 +++-
 arch/arm/mach-imx/clk-fixup-div.c|  2 +-
 arch/arm/mach-imx/clk-pfd.c  | 11 ++--
 arch/arm/mach-imx/clk-pllv2.c|  8 ++-
 arch/arm/mach-imx/clk-pllv3.c| 46 +++--
 arch/arm/mach-msm/clock-pcom.c   |  4 +-
 arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 13 ++--
 arch/arm/mach-omap2/clkt_clksel.c|  6 +-
 arch/arm/mach-omap2/clkt_dpll.c  | 21 +++---
 arch/arm/mach-omap2/clock.h  |  4 +-
 arch/arm/mach-omap2/dpll3xxx.c   | 27 +---
 arch/arm/mach-omap2/dpll44xx.c   | 26 +---
 arch/arm/mach-vexpress/spc.c | 11 +++-
 arch/mips/alchemy/common/clock.c | 13 ++--
 drivers/clk/at91/clk-h32mx.c | 24 ---
 drivers/clk/at91/clk-peripheral.c| 31 +
 drivers/clk/at91/clk-pll.c   | 14 ++--
 drivers/clk/at91/clk-plldiv.c| 22 ---
 drivers/clk/at91/clk-smd.c   | 24 ---
 drivers/clk/at91/clk-usb.c   | 16 +++--
 drivers/clk/clk-axi-clkgen.c |  5 +-
 drivers/clk/clk-cdce706.c| 46 ++---
 drivers/clk/clk-composite.c  | 23 ---
 drivers/clk/clk-divider.c| 16 +++--
 drivers/clk/clk-fixed-factor.c   |  7 +-
 drivers/clk/clk-fractional-divider.c | 16 +++--
 drivers/clk/clk-highbank.c   | 18 +++---
 drivers/clk/clk-si5351.c | 96 ++--
 drivers/clk/clk-si570.c  | 14 ++--
 drivers/clk/clk-u300.c   | 65 ++-
 drivers/clk/clk-vt8500.c | 27 
 drivers/clk/clk-wm831x.c | 11 ++--
 drivers/clk/clk-xgene.c  | 11 ++--
 drivers/clk/clk.c| 14 ++--
 drivers/clk/mmp/clk-frac.c   | 14 ++--
 drivers/clk/mvebu/clk-corediv.c  |  7 +-
 drivers/clk/mvebu/clk-cpu.c  |  9 +--
 drivers/clk/mxs/clk-div.c|  4 +-
 drivers/clk/mxs/clk-frac.c   | 11 ++--
 drivers/clk/mxs/clk-ref.c| 11 ++--
 drivers/clk/qcom/clk-regmap-divider.c|  4 +-
 drivers/clk/rockchip/clk-pll.c   | 13 ++--
 drivers/clk/samsung/clk-pll.c| 13 ++--
 drivers/clk/shmobile/clk-div6.c  |  7 +-
 drivers/clk/shmobile/clk-rcar-gen2.c |  9 +--
 drivers/clk/sirf/clk-common.c| 18 +++---
 drivers/clk/spear/clk-aux-synth.c| 10 ++-
 drivers/clk/spear/clk-frac-synth.c   | 10 ++-
 drivers/clk/spear/clk-gpt-synth.c| 10 ++-
 drivers/clk/spear/clk-vco-pll.c  | 20 --
 drivers/clk/st/clk-flexgen.c | 11 ++--
 drivers/clk/st/clkgen-fsyn.c | 21 +++---
 drivers/clk/st/clkgen-mux.c  |  2 +-
 drivers/clk/sunxi/clk-factors.c  | 14 ++--
 drivers/clk/tegra/clk-audio-sync.c   |  8 +--
 drivers/clk/tegra/clk-divider.c  | 19 --
 drivers/clk/tegra/clk-periph.c   

[PATCH] drm/atmel-hlcdc: Compile suspend/resume for PM_SLEEP only

2015-08-17 Thread Boris Brezillon
On Fri, 14 Aug 2015 13:58:20 +0200
Thierry Reding  wrote:

> From: Thierry Reding 
> 
> If PM is enabled but PM_SLEEP is disabled, the suspend/resume functions
> are still unused and produce a compiler warning.
> 
> Signed-off-by: Thierry Reding 

Acked-by: Boris Brezillon 

Thanks,

Boris

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index b6bc5cb9b9ee..303ae68f983d 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -561,7 +561,7 @@ static int atmel_hlcdc_dc_drm_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> -#ifdef CONFIG_PM
> +#ifdef CONFIG_PM_SLEEP
>  static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
>  {
>   struct drm_device *drm_dev = dev_get_drvdata(dev);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH] drm/atmel-hlcdc: Compile suspend/resume for PM_SLEEP only

2015-08-18 Thread Boris Brezillon
On Fri, 14 Aug 2015 13:58:20 +0200
Thierry Reding  wrote:

> From: Thierry Reding 
> 
> If PM is enabled but PM_SLEEP is disabled, the suspend/resume functions
> are still unused and produce a compiler warning.
> 
> Signed-off-by: Thierry Reding 

I'm adding

Cc:  # 4.1+

while applying this commit to my fixes branch.

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index b6bc5cb9b9ee..303ae68f983d 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -561,7 +561,7 @@ static int atmel_hlcdc_dc_drm_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> -#ifdef CONFIG_PM
> +#ifdef CONFIG_PM_SLEEP
>  static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
>  {
>   struct drm_device *drm_dev = dev_get_drvdata(dev);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PULL] drm: atmel-hlcdc: fixes for 4.2 or 4.3

2015-08-18 Thread Boris Brezillon
Hello Dave,

This PR contains a single commit fixing a compilation error.
Ideally I would like to get this into 4.2 but since we're already at
4.1-rc7 I let you decide whether this should be queued for the next
release or not.

Thanks,

Boris

The following changes since commit 7945dc5885c51d05d9368fd0066755adca73f009:

  Merge tag 'topic/drm-fixes-2015-08-14' of 
git://anongit.freedesktop.org/drm-intel into drm-next (2015-08-15 14:52:12 
+1000)

are available in the git repository at:


  https://github.com/bbrezillon/linux-at91.git drm-atmel-hlcdc-fixes

for you to fetch changes up to dbb3df2d58754e4df58620e60370d166c2cb6744:

  drm/atmel-hlcdc: Compile suspend/resume for PM_SLEEP only (2015-08-18 
10:47:21 +0200)


Thierry Reding (1):
  drm/atmel-hlcdc: Compile suspend/resume for PM_SLEEP only

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[PULL] drm: atmel-hlcdc: new features for 4.3 or 4.4

2015-08-18 Thread Boris Brezillon
Hello Dave,

The following PR add support for 3 more atmel SoCs and for some missing
features (new input formats and PRIME support).

As for the other PR I just sent, ideally I would like to get those new
features into 4.3 but since we're already at 4.1-rc7 I'll let you decide
whether this should be queued for the next release or not.

Best Regards,

Boris

The following changes since commit 294947a5c7f6d228b70fcc51a89527e74a38a2c5:

  Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux 
into drm-next (2015-08-17 16:03:48 +1000)

are available in the git repository at:


  https://github.com/bbrezillon/linux-at91.git drm-atmel-hlcdc-devel

for you to fetch changes up to 5b9fb5e6c6c74666f88f34bd0db183b9c4269d97:

  drm: atmel-hlcdc: add support for sama5d4 SoCs (2015-08-18 11:02:27 +0200)


Boris Brezillon (6):
  drm: atmel-hlcdc: add PRIME support
  drm: atmel-hlcdc: add the missing DRM_ATOMIC flag
  drm: atmel-hlcdc: add RGB565 and RGB444 output support
  drm: atmel-hlcdc: add support for at91sam9x5 SoCs
  drm: atmel-hlcdc: add support for at91sam9n12 SoC
  drm: atmel-hlcdc: add support for sama5d4 SoCs

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 216 
+-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c |   4 
 2 files changed, 219 insertions(+), 1 deletion(-)


[PATCH v3 1/3] drm: add bus_formats and nbus_formats fields to drm_display_info

2014-11-30 Thread Boris Brezillon
Hi Laurent,

On Sat, 29 Nov 2014 00:13:47 +0200
Laurent Pinchart  wrote:

> Hi Boris,
> 
> Thank you for the patch. I just have two small comments.
> 
> On Tuesday 18 November 2014 14:46:18 Boris Brezillon wrote:
> > Add bus_formats and nbus_formats fields and
> > drm_display_info_set_bus_formats helper function to specify the bus
> > formats supported by a given display.
> > 
> > This information can be used by display controller drivers to configure
> > the output interface appropriately (i.e. RGB565, RGB666 or RGB888 on raw
> > RGB or LVDS busses).
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  drivers/gpu/drm/drm_crtc.c | 30 ++
> >  include/drm/drm_crtc.h |  7 +++
> >  2 files changed, 37 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index e79c8d3..17e3acf 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -763,6 +763,36 @@ static void drm_mode_remove(struct drm_connector
> > *connector, drm_mode_destroy(connector->dev, mode);
> >  }
> > 
> > +/*
> > + * drm_display_info_set_bus_formats - set the supported bus formats
> > + * @info: display info to store bus formats in
> > + * @fmts: array containing the supported bus formats
> > + * @nfmts: the number of entries in the fmts array
> > + *
> > + * Store the suppported bus formats in display info structure.
> 
> Could you document that the formats are specified as MEDIA_BUS_FMT_* values ?

Sure, I'll clearly state that.

> 
> > + */
> > +int drm_display_info_set_bus_formats(struct drm_display_info *info, const
> > u32 *fmts, + unsigned int num_fmts)
> > +{
> > +   u32 *formats = NULL;
> > +
> > +   if (!fmts && num_fmts)
> > +   return -EINVAL;
> > +
> > +   if (fmts && num_fmts) {
> > +   formats = kmemdup(fmts, sizeof(*fmts) * num_fmts, GFP_KERNEL);
> > +   if (!formats)
> > +   return -ENOMEM;
> > +   }
> > +
> > +   kfree(info->bus_formats);
> > +   info->bus_formats = formats;
> > +   info->num_bus_formats = num_fmts;
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL(drm_display_info_set_bus_formats);
> > +
> >  /**
> >   * drm_connector_get_cmdline_mode - reads the user's cmdline mode
> >   * @connector: connector to quwery
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index c40070a..2e0a3e8 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -31,6 +31,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -130,6 +131,9 @@ struct drm_display_info {
> > enum subpixel_order subpixel_order;
> > u32 color_formats;
> > 
> > +   const u32 *bus_formats;
> > +   int num_bus_formats;
> 
> As the number of formats is never negative, I would make it an unsigned int.

Okay, I'll make it an unsigned int.

Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v3 0/3] drm: describe display bus format

2014-11-30 Thread Boris Brezillon
Hi Laurent,

On Sat, 29 Nov 2014 00:29:10 +0200
Laurent Pinchart  wrote:

> Hi Boris,
> 
> On Thursday 27 November 2014 14:37:50 Boris Brezillon wrote:
> > On Tue, 18 Nov 2014 14:46:17 +0100 Boris Brezillon wrote:
> > > Hello,
> > > 
> > > This series makes use of the MEDIA_BUS_FMT definition to describe how
> > > the data are transmitted to the display.
> > > 
> > > This will allow drivers to configure their output display bus according
> > > to the display capabilities.
> > > For example some display controllers support DPI (or raw RGB) connectors
> > > and need to specify which format will be transmitted on the DPI bus
> > > (RGB444, RGB565, RGB888, ...).
> > > 
> > > This series also adds a field to the panel_desc struct so that one
> > > can specify which format is natevely supported by a panel.
> > 
> > Thierry, Laurent, Dave, can you take a look at this patch series: this
> > is the last missing dependency to get the atmel-hlcdc DRM driver
> > mainlined, and I was expecting to get this driver in 3.19...
> 
> I've reviewed the series, it looks globally fine to me. I just had two small 
> comments on patch 1/3.
> 

Thanks for the review, I'll address your comments in the next version.

Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 00/11] drm: add support for Atmel HLCDC Display Controller

2014-10-01 Thread Boris Brezillon
Hello,

This series is being sent for several weeks now and I wonder if I shouldn't
split it in several pieces:
1) the MFD driver + its DT doc
2) the PWM driver + its DT doc
3) the DRM/KMS driver + its DT doc
4) support for sama5d3 SoCs/boards

The first reason for doing this is that Lee already accepted the MFD part,
and I'm pretty sure he'd like me to stop sending him each new version of this
series.
The second reason being that smaller series are more likely to be reviewed by
subsystem maintainers :-).

Lee, if you still agree with this version, could you take the MTD part (other
drivers in this series depend on it).

Here is the usal description of the patch series :-) :

This patch series adds support for the Atmel HLCDC block (HLCD Controller)
available on some Atmel SoCs (i.e. the sama5d3 family).

The HLCDC actually provides a Display Controller and a PWM device, hence I
decided to declare an MFD device exposing 2 subdevices: a display
controller and a PWM chip.
This also solves a circular dependency issue preventing HLCDC driver from
unloading.
The HLCDC request a drm_panel device, which request a backlight device
(a PWM backlight), which depends on a PWM which is provided by the HLCDC
driver (hlcdc -> panel -> backlight -> hlcdc (pwm part)).

The current implementation only supports sama5d3 SoCs but other SoCs should
be easily ported by defining new compatible strings and adding HLCDC
description structures for these SoCs (Ludovic tested this driver on an
at91sam9x5 board).

The drivers supports basic CRTC functionalities, several overlays and an
hardware cursor.

At the moment, it only supports connection to LCD panels through an RGB
connector (defined as an LVDS connector in my implementation), though
connection to other kind of devices (like DRM bridges) could be added later.

It also supports several RGB formats on all planes and some YUV formats on
the HEO overlay plane.

This series depends on those ones: [1], [2] and [3].

Best Regards,

Boris

[1]http://lkml.iu.edu/hypermail/linux/kernel/1407.1/04171.html
[2]https://lkml.org/lkml/2014/9/29/330
[3]https://lkml.org/lkml/2014/9/22/575

Changes since v7:
- move interrupts property from hlcdc display controller node to its
  parent node (the MFD device)
- add mode_set_base implementation
- rework page flip handling to rely on vblank events instead of DMA
  transfer events (the end of a DMA transfer does not mean the frame
  is actually flipped: data are first copied to an output FIFO before
  being sent on the RGB/DPI connector)
- few minor coding style fixes

Changes since v5:
- fix Kconfig dependency bug
- use adjusted mode in crtc config
- move signal config (clk, hsync, vsync) from connector to crtc mode_set
  function
- use standard rotation property
- check display_mode validity in connecto mode_valid function
- remove dma_set_coherent mask call (now done in MFD core)
- do not use drm_platform_init

Changes since v4:
- fix a few more bugs in rotation handling (rotation was buggy on some
  formats)
- return connector_status_unknown until a panel is exposed by the
  drm_panel infrastructure (prevent fbdev creation until everyting is
  in place)
- rework Kconfig MFD_ATMEL_HLCDC selection to simplify the configuration
  (automatically select this option when selecting the HLCDC PMW or DRM
  driver, instead of depending on this option)

Changes since v3:
- rework the layer code to simplify several parts (locking and layer
  disabling)
- make use of the drm_flip_work infrastructure
- rely on default HW cursor implementation using on the cursor plane
- rework the display controller DT bindings (based on OF graph
  representation)
- add rotation support
- retrive RGB bus format from drm_display_info
- drop the dynamic pinctrl state selection
- rework HLCDC output handling (previously specialized to interface
  with LCD panels)
- drop ".module = THIS_MODULE" lines
- change display controller compatible string

Changes since v2:
- fix coding style issues (macro indentation)
- make use of GENMASK in several places
- declare regmap config as a static structure
- rework hlcdc plane update API
- rework cursor handling to make use of the new plane update API
- fix backporch config
- do not use devm_regmap_init_mmio_clk to avoid extra clk_enable
  clk disable calls when accessing registers
- explicitely include regmap and clk headers instead of relying on
  atmel-hlcdc.h inclusions
- make the atmel-hlcdc driver depends on CONFIG_OF
- separate DT bindings documentation from driver implementation
- support several pin muxing for HLCDC pins on sama5d3 SoCs

Changes since v1:
- replace the backlight driver by a PWM driver
- make use of drm_panel infrastructure
- split driver code in several subsystem: MFD, PWM and DRM
- add support for overlays
- add support for hardware cursor


Boris BREZILLON (10):
  mfd: add documentation for atmel-hlcdc DT bindings
  pwm: add support for atmel-hlcdc-pwm device
  pwm: add DT bindings documentation 

[PATCH v7 01/11] mfd: add atmel-hlcdc driver

2014-10-01 Thread Boris Brezillon
The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

The MFD device provides a regmap and several clocks (those connected
to this hardware block) to its subdevices.

This way concurrent accesses to the iomem range are handled by the regmap
framework, and each subdevice can safely access HLCDC registers.

Signed-off-by: Boris Brezillon 
Acked-by: Lee Jones 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 drivers/mfd/Kconfig |   6 ++
 drivers/mfd/Makefile|   1 +
 drivers/mfd/atmel-hlcdc.c   | 122 
 include/linux/mfd/atmel-hlcdc.h |  85 
 4 files changed, 214 insertions(+)
 create mode 100644 drivers/mfd/atmel-hlcdc.c
 create mode 100644 include/linux/mfd/atmel-hlcdc.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index de5abf2..1b925f7 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,12 @@ config MFD_AAT2870_CORE
  additional drivers must be enabled in order to use the
  functionality of the device.

+config MFD_ATMEL_HLCDC
+   tristate
+   select MFD_CORE
+   select REGMAP_MMIO
+   depends on OF
+
 config MFD_BCM590XX
tristate "Broadcom BCM590xx PMUs"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f001487..df36f68 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_MFD_PM8921_CORE)   += pm8921-core.o ssbi.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
+obj-$(CONFIG_MFD_ATMEL_HLCDC)  += atmel-hlcdc.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_PALMAS)   += palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)+= viperboard.o
diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
new file mode 100644
index 000..bd21f49
--- /dev/null
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_HLCDC_REG_MAX(0x4000 - 0x4)
+
+static const struct mfd_cell atmel_hlcdc_cells[] = {
+   {
+   .name = "atmel-hlcdc-pwm",
+   .of_compatible = "atmel,hlcdc-pwm",
+   },
+   {
+   .name = "atmel-hlcdc-dc",
+   .of_compatible = "atmel,hlcdc-display-controller",
+   },
+};
+
+static const struct regmap_config atmel_hlcdc_regmap_config = {
+   .reg_bits = 32,
+   .val_bits = 32,
+   .reg_stride = 4,
+   .max_register = ATMEL_HLCDC_REG_MAX,
+};
+
+static int atmel_hlcdc_probe(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct atmel_hlcdc *hlcdc;
+   struct resource *res;
+   void __iomem *regs;
+
+   hlcdc = devm_kzalloc(dev, sizeof(*hlcdc), GFP_KERNEL);
+   if (!hlcdc)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(regs))
+   return PTR_ERR(regs);
+
+   hlcdc->irq = platform_get_irq(pdev, 0);
+   if (hlcdc->irq < 0)
+   return hlcdc->irq;
+
+   hlcdc->periph_clk = devm_clk_get(dev, "periph_clk");
+   if (IS_ERR(hlcdc->periph_clk)) {
+   dev_err(dev, "failed to get peripheral clock\n");
+   return PTR_ERR(hlcdc->periph_clk);
+   }
+
+   hlcdc->sys_clk = devm_clk_get(dev, "sys_clk");
+   if (IS_ERR(hlcdc->sys_clk)) {
+   dev_err(dev, "failed to get system clock\n");
+   return PTR_ERR(hlcdc->sys_clk);
+   }
+
+   hlcdc->slow_clk = devm_clk_get(dev, "slow_clk");
+   if (IS_ERR(hlcdc->slow_clk)) {
+   dev_err(dev, "failed to get slow clock\n");
+   return PTR_ERR(hlcdc->slow_clk);
+   }
+
+   hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
+ 

[PATCH v7 03/11] pwm: add support for atmel-hlcdc-pwm device

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The HLCDC IP available in some Atmel SoCs (i.e. sam9x5i.e. at91sam9n12,
at91sam9x5 family or sama5d3 family) provide a PWM device.

This driver add support for a PWM chip exposing a single PWM device (which
will most likely be used to drive a backlight device).

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-atmel-hlcdc.c | 229 ++
 3 files changed, 240 insertions(+)
 create mode 100644 drivers/pwm/pwm-atmel-hlcdc.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index b800783..afb896b 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -50,6 +50,16 @@ config PWM_ATMEL
  To compile this driver as a module, choose M here: the module
  will be called pwm-atmel.

+config PWM_ATMEL_HLCDC_PWM
+   tristate "Atmel HLCDC PWM support"
+   select MFD_ATMEL_HLCDC
+   depends on OF
+   help
+ Generic PWM framework driver for Atmel HLCDC PWM.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-atmel.
+
 config PWM_ATMEL_TCB
tristate "Atmel TC Block PWM support"
depends on ATMEL_TCLIB && OF
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index f8c577d..eb0aae5 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_PWM)   += core.o
 obj-$(CONFIG_PWM_SYSFS)+= sysfs.o
 obj-$(CONFIG_PWM_AB8500)   += pwm-ab8500.o
 obj-$(CONFIG_PWM_ATMEL)+= pwm-atmel.o
+obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)  += pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)+= pwm-atmel-tcb.o
 obj-$(CONFIG_PWM_BCM_KONA) += pwm-bcm-kona.o
 obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
new file mode 100644
index 000..0238f7a
--- /dev/null
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_HLCDC_PWMCVAL_MASK   GENMASK(15, 8)
+#define ATMEL_HLCDC_PWMCVAL(x) ((x << 8) & ATMEL_HLCDC_PWMCVAL_MASK)
+#define ATMEL_HLCDC_PWMPOL BIT(4)
+#define ATMEL_HLCDC_PWMPS_MASK GENMASK(2, 0)
+#define ATMEL_HLCDC_PWMPS_MAX  0x6
+#define ATMEL_HLCDC_PWMPS(x)   ((x) & ATMEL_HLCDC_PWMPS_MASK)
+
+struct atmel_hlcdc_pwm_chip {
+   struct pwm_chip chip;
+   struct atmel_hlcdc *hlcdc;
+   struct clk *cur_clk;
+};
+
+static inline struct atmel_hlcdc_pwm_chip *
+pwm_chip_to_atmel_hlcdc_pwm_chip(struct pwm_chip *chip)
+{
+   return container_of(chip, struct atmel_hlcdc_pwm_chip, chip);
+}
+
+static int atmel_hlcdc_pwm_config(struct pwm_chip *c,
+ struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   struct atmel_hlcdc_pwm_chip *chip =
+   pwm_chip_to_atmel_hlcdc_pwm_chip(c);
+   struct atmel_hlcdc *hlcdc = chip->hlcdc;
+   struct clk *new_clk = hlcdc->slow_clk;
+   u64 pwmcval = duty_ns * 256;
+   unsigned long clk_freq;
+   u64 clk_period_ns;
+   u32 pwmcfg;
+   int pres;
+
+   clk_freq = clk_get_rate(new_clk);
+   clk_period_ns = 10;
+   clk_period_ns *= 256;
+   do_div(clk_period_ns, clk_freq);
+
+   if (clk_period_ns > period_ns) {
+   new_clk = hlcdc->sys_clk;
+   clk_freq = clk_get_rate(new_clk);
+   clk_period_ns = 10;
+   clk_period_ns *= 256;
+   do_div(clk_period_ns, clk_freq);
+   }
+
+   for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
+   if ((clk_period_ns << pres) >= period_ns)
+   break;
+   }
+
+   if (pres > ATMEL_HLCDC_PWMPS_MAX)
+   return -EINVAL;
+
+   pwmcfg = ATMEL_HLCDC_PWMPS(pres);
+
+   if (new_clk != chip->cur_clk) {
+   u32 gencfg = 0;
+
+   clk_prepare_enable(new_clk);
+

[PATCH v7 02/11] mfd: add documentation for atmel-hlcdc DT bindings

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

This patch adds documentation for atmel-hlcdc DT bindings.

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 .../devicetree/bindings/mfd/atmel-hlcdc.txt| 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt

diff --git a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt 
b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
new file mode 100644
index 000..f64de95a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
@@ -0,0 +1,51 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) MFD driver
+
+Required properties:
+ - compatible: value should be one of the following:
+   "atmel,sama5d3-hlcdc"
+ - reg: base address and size of the HLCDC device registers.
+ - clock-names: the name of the 3 clocks requested by the HLCDC device.
+   Should contain "periph_clk", "sys_clk" and "slow_clk".
+ - clocks: should contain the 3 clocks requested by the HLCDC device.
+ - interrupts: should contain the description of the HLCDC interrupt line
+
+The HLCDC IP exposes two subdevices:
+ - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt
+ - a Display Controller: see ../drm/atmel-hlcdc-dc.txt
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v7 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
controller device.

The HLCDC block provides a single RGB output port, and only supports LCD
panels connection to LCD panels for now.

The atmel,panel property link the HLCDC RGB output with the LCD panel
connected on this port (note that the HLCDC RGB connector implementation
makes use of the DRM panel framework).

Connection to other external devices (DRM bridges) might be added later by
mean of a new atmel,xxx (atmel,bridge) property.

Signed-off-by: Boris Brezillon 
---
 .../devicetree/bindings/drm/atmel-hlcdc-dc.txt | 53 ++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt

diff --git a/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt 
b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
new file mode 100644
index 000..ebc1a91
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
@@ -0,0 +1,53 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver
+
+The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD device.
+See ../mfd/atmel-hlcdc.txt for more details.
+
+Required properties:
+ - compatible: value should be "atmel,hlcdc-display-controller"
+ - pinctrl-names: the pin control state names. Should contain "default".
+ - pinctrl-0: should contain the default pinctrl states.
+ - #address-cells: should be set to 1.
+ - #size-cells: should be set to 0.
+
+Required children nodes:
+ Children nodes are encoding available output ports and their connections
+ to external devices using the OF graph reprensentation (see ../graph.txt).
+ At least one port node is required.
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v7 05/11] drm: add Atmel HLCDC Display Controller support

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
controller device.

This display controller supports at least one primary plane and might
provide several overlays and an hardware cursor depending on the IP
version.

At the moment, this driver only implements an RGB connector to interface
with LCD panels, but support for other kind of external devices might be
added later.

Signed-off-by: Boris Brezillon 
Reviewed-by: Rob Clark 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 drivers/gpu/drm/Kconfig  |   2 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/atmel-hlcdc/Kconfig  |  13 +
 drivers/gpu/drm/atmel-hlcdc/Makefile |   7 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c   | 390 +++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 531 +++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 216 ++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c  | 638 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h  | 394 +++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 443 
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c  | 831 +++
 11 files changed, 3466 insertions(+)
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/Kconfig
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/Makefile
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index b066bb3..2d97f7e 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -185,6 +185,8 @@ source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/armada/Kconfig"

+source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
+
 source "drivers/gpu/drm/rcar-du/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..abb4f29 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_ARMADA) += armada/
+obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc/
 obj-$(CONFIG_DRM_RCAR_DU) += rcar-du/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
 obj-$(CONFIG_DRM_OMAP) += omapdrm/
diff --git a/drivers/gpu/drm/atmel-hlcdc/Kconfig 
b/drivers/gpu/drm/atmel-hlcdc/Kconfig
new file mode 100644
index 000..942407f
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/Kconfig
@@ -0,0 +1,13 @@
+config DRM_ATMEL_HLCDC
+   tristate "DRM Support for ATMEL HLCDC Display Controller"
+   depends on DRM && OF && COMMON_CLK
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DRM_PANEL
+   select MFD_ATMEL_HLCDC
+   depends on OF
+   help
+ Choose this option if you have an ATMEL SoC with an HLCDC display
+ controller (i.e. at91sam9n12, at91sam9x5 family or sama5d3 family).
diff --git a/drivers/gpu/drm/atmel-hlcdc/Makefile 
b/drivers/gpu/drm/atmel-hlcdc/Makefile
new file mode 100644
index 000..10ae426
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/Makefile
@@ -0,0 +1,7 @@
+atmel-hlcdc-dc-y := atmel_hlcdc_crtc.o \
+   atmel_hlcdc_dc.o \
+   atmel_hlcdc_layer.o \
+   atmel_hlcdc_output.o \
+   atmel_hlcdc_plane.o
+
+obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc-dc.o
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
new file mode 100644
index 000..02f7a98
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (C) 2014 Traphandler
+ * Copyright (C) 2014 Free Electrons
+ *
+ * Author: Jean-Jacques Hiblot 
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Pub

[PATCH v7 04/11] pwm: add DT bindings documentation for atmel-hlcdc-pwm driver

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The HLCDC IP available in some Atmel SoCs (i.e. sam9x5i.e. at91sam9n12,
at91sam9x5 family or sama5d3 family) provide a PWM device.

The DT bindings used for this PWM device is following the default 3 cells
bindings described in Documentation/devicetree/bindings/pwm/pwm.txt.

Signed-off-by: Boris Brezillon 
---
 .../devicetree/bindings/pwm/atmel-hlcdc-pwm.txt| 55 ++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt

diff --git a/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt 
b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
new file mode 100644
index 000..86ad3e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
@@ -0,0 +1,55 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) PWM driver
+
+The Atmel HLCDC PWM is subdevice of the HLCDC MFD device.
+See ../mfd/atmel-hlcdc.txt for more details.
+
+Required properties:
+ - compatible: value should be one of the following:
+   "atmel,hlcdc-pwm"
+ - pinctr-names: the pin control state names. Should contain "default".
+ - pinctrl-0: should contain the pinctrl states described by pinctrl
+   default.
+ - #pwm-cells: should be set to 3. This PWM chip use the default 3 cells
+   bindings defined in Documentation/devicetree/bindings/pwm/pwm.txt.
+   The first cell encodes the PWM id (0 is the only acceptable value here,
+   because the chip only provide one PWM).
+   The second cell encodes the PWM period in nanoseconds.
+   The third cell encodes the PWM flags (the only supported flag is
+   PWM_POLARITY_INVERTED)
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v7 08/11] ARM: AT91/dt: add alternative pin muxing for sama5d3 lcd pins

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

Define alternative pin muxing for the LCDC pins.

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index 2186b89..e7581f6 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -82,6 +82,28 @@
 AT91_PIOA 13 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD13 pin */
 AT91_PIOA 14 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD14 pin */
 AT91_PIOA 15 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD15 pin */
+AT91_PIOA 16 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD16 pin */
+AT91_PIOA 17 
AT91_PERIPH_A AT91_PINCTRL_NONE>; /* LCDD17 pin */
+   };
+
+   pinctrl_lcd_rgb666_alt: lcd-rgb-2-alt {
+   atmel,pins =
+   ; /* LCDD17 pin */
};
@@ -104,6 +126,34 @@
 AT91_PIOA 13 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD13 pin */
 AT91_PIOA 14 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD14 pin */
 AT91_PIOA 15 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD15 pin */
+AT91_PIOA 16 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD16 pin */
+AT91_PIOA 17 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD17 pin */
+AT91_PIOA 18 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD18 pin */
+AT91_PIOA 19 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD19 pin */
+AT91_PIOA 20 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD20 pin */
+AT91_PIOA 21 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD21 pin */
+AT91_PIOA 22 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD22 pin */
+AT91_PIOA 23 
AT91_PERIPH_A AT91_PINCTRL_NONE>; /* LCDD23 pin */
+   };
+
+   pinctrl_lcd_rgb888_alt: lcd-rgb-3-alt {
+   atmel,pins =
+   

[PATCH v7 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

Add LCD panel related nodes (backlight, regulators and panel) to sama5d3
Display Module dtsi.

Reference LCD pin muxing used by sama5d3xek boards.

Signed-off-by: Boris Brezillon 
---
 arch/arm/boot/dts/sama5d3xdm.dtsi | 58 +++
 1 file changed, 58 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
b/arch/arm/boot/dts/sama5d3xdm.dtsi
index 035ab72..91975eb 100644
--- a/arch/arm/boot/dts/sama5d3xdm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xdm.dtsi
@@ -36,6 +36,64 @@
};
};
};
+
+   hlcdc: hlcdc at f003 {
+   hlcdc-display-controller {
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base 
_lcd_rgb888_alt>;
+
+   port at 0 {
+   hlcdc_panel_output: endpoint at 
0 {
+   reg = <0>;
+   remote-endpoint = 
<_input>;
+   };
+   };
+   };
+   };
+   };
+   };
+
+   bl_reg: backlight_regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "backlight-power-supply";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   status = "disabled";
+   };
+
+   panel_reg: panel_regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "panel-power-supply";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   status = "disabled";
+   };
+
+   backlight: backlight {
+   compatible = "pwm-backlight";
+   pwms = <_pwm 0 5 0>;
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <6>;
+   power-supply = <_reg>;
+   status = "disabled";
+   };
+
+   panel: panel {
+   compatible = "foxlink,fl500wvr00-a0t", "simple-panel";
+   backlight = <>;
+   power-supply = <_reg>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   panel_input: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_panel_output>;
+   };
};
};
 };
-- 
1.9.1



[PATCH v7 09/11] ARM: at91/dt: define the HLCDC node available on sama5d3 SoCs

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

Define the HLCDC (HLCD Controller) IP available on some sama5d3 SoCs
(i.e. sama5d31, sama5d33, sama5d34 and sama5d36) in sama5d3 dtsi file.

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 28 
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index e7581f6..611ff8a 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -166,6 +166,34 @@
};
};

+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", 
"slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = 
"atmel,hlcdc-display-controller";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
+
pmc: pmc at fc00 {
periphck {
lcdc_clk: lcdc_clk {
-- 
1.9.1



[PATCH v7 07/11] ARM: AT91/dt: split sama5d3 lcd pin definitions to match RGB mode configs

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

The HLCDC (HLCD Controller) IP supports 4 different output mode (RGB444,
RGB565, RGB666 and RGB888) and the pin muxing will depend on the chosen
RGB mode.

Split pin definitions to be able to set pin config according to the
selected mode.

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 127 -
 1 file changed, 96 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index 85d3027..2186b89 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -15,38 +15,103 @@
apb {
pinctrl at f200 {
lcd {
-   pinctrl_lcd: lcd-0 {
+   pinctrl_lcd_pwm: lcd-pwm-0 {
+   atmel,pins = ;/* LCDPWM */
+   };
+
+   pinctrl_lcd_base: lcd-base-0 {
+   atmel,pins =
+   ; /* LCDPCK */
+   };
+
+   pinctrl_lcd_rgb444: lcd-rgb-0 {
+   atmel,pins =
+   ; /* LCDD11 pin */
+   };
+
+   pinctrl_lcd_rgb565: lcd-rgb-1 {
+   atmel,pins =
+   ; /* LCDD15 pin */
+   };
+
+   pinctrl_lcd_rgb666: lcd-rgb-2 {
+   atmel,pins =
+   ; /* LCDD17 pin */
+   };
+
+   pinctrl_lcd_rgb888: lcd-rgb-3 {
atmel,pins =
-   ; /* PE28 periph C LCDD23 pin */
+   ; /* LCDD23 pin */
};
};
};
-- 
1.9.1



[PATCH v7 11/11] ARM: at91/dt: enable the LCD panel on sama5d3xek boards

2014-10-01 Thread Boris Brezillon
From: Boris BREZILLON <boris.brezil...@free-electrons.com>

Enable LCD related nodes.

Signed-off-by: Boris Brezillon 
---
 arch/arm/boot/dts/sama5d31ek.dts | 20 
 arch/arm/boot/dts/sama5d33ek.dts | 20 
 arch/arm/boot/dts/sama5d34ek.dts | 20 
 arch/arm/boot/dts/sama5d36ek.dts | 20 
 4 files changed, 80 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d31ek.dts b/arch/arm/boot/dts/sama5d31ek.dts
index 04eec0d..6e605fe 100644
--- a/arch/arm/boot/dts/sama5d31ek.dts
+++ b/arch/arm/boot/dts/sama5d31ek.dts
@@ -33,6 +33,10 @@
status = "okay";
};

+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
+
macb1: ethernet at f802c000 {
status = "okay";
};
@@ -46,6 +50,22 @@
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d33ek.dts b/arch/arm/boot/dts/sama5d33ek.dts
index cbd6a3f..0400641 100644
--- a/arch/arm/boot/dts/sama5d33ek.dts
+++ b/arch/arm/boot/dts/sama5d33ek.dts
@@ -36,9 +36,29 @@
macb0: ethernet at f0028000 {
status = "okay";
};
+
+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d34ek.dts b/arch/arm/boot/dts/sama5d34ek.dts
index 878aa16..9cf473e 100644
--- a/arch/arm/boot/dts/sama5d34ek.dts
+++ b/arch/arm/boot/dts/sama5d34ek.dts
@@ -46,6 +46,10 @@
macb0: ethernet at f0028000 {
status = "okay";
};
+
+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
};
};

@@ -56,6 +60,22 @@
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d36ek.dts b/arch/arm/boot/dts/sama5d36ek.dts
index 59576c6..1c65741 100644
--- a/arch/arm/boot/dts/sama5d36ek.dts
+++ b/arch/arm/boot/dts/sama5d36ek.dts
@@ -41,12 +41,32 @@
status = "okay";
};

+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
+
macb1: ethernet at f802c000 {
status = "okay";
};
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
-- 
1.9.1



[PATCH v7 00/11] drm: add support for Atmel HLCDC Display Controller

2014-10-01 Thread Boris Brezillon
On Wed,  1 Oct 2014 16:52:57 +0200
Boris Brezillon  wrote:

> Hello,
> 
> This series is being sent for several weeks now and I wonder if I shouldn't
> split it in several pieces:
> 1) the MFD driver + its DT doc
> 2) the PWM driver + its DT doc
> 3) the DRM/KMS driver + its DT doc
> 4) support for sama5d3 SoCs/boards
> 
> The first reason for doing this is that Lee already accepted the MFD part,
> and I'm pretty sure he'd like me to stop sending him each new version of this
> series.
> The second reason being that smaller series are more likely to be reviewed by
> subsystem maintainers :-).
> 
> Lee, if you still agree with this version, could you take the MTD part (other

 I meant MFD ^

> drivers in this series depend on it).




-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 01/11] mfd: add atmel-hlcdc driver

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 12:49:17 +0200
Thierry Reding  wrote:

> On Wed, Oct 01, 2014 at 04:52:58PM +0200, Boris Brezillon wrote:
> [...]
> > diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
> [...]
> > @@ -0,0 +1,122 @@
> > +/*
> > + * Copyright (C) 2014 Free Electrons
> > + * Copyright (C) 2014 Atmel
> > + *
> > + * Author: Boris BREZILLON 
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of the GNU General Public License version 2 as 
> > published by
> > + * the Free Software Foundation.
> [...]
> > +MODULE_LICENSE("GPL");
> 
> Should be "GPL v2" according to the header comment.

I'll fix that.

> 
> Thierry



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 03/11] pwm: add support for atmel-hlcdc-pwm device

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 12:46:35 +0200
Thierry Reding  wrote:

> On Wed, Oct 01, 2014 at 04:53:00PM +0200, Boris Brezillon wrote:
> [...]
> > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> > index b800783..afb896b 100644
> > --- a/drivers/pwm/Kconfig
> > +++ b/drivers/pwm/Kconfig
> > @@ -50,6 +50,16 @@ config PWM_ATMEL
> >   To compile this driver as a module, choose M here: the module
> >   will be called pwm-atmel.
> >  
> > +config PWM_ATMEL_HLCDC_PWM
> > +   tristate "Atmel HLCDC PWM support"
> > +   select MFD_ATMEL_HLCDC
> > +   depends on OF
> 
> This isn't really necessary since MFD_ATMEL_HLCDC already depends on OF.
> 
> > diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> [...]
> > new file mode 100644
> > index 000..0238f7a
> > --- /dev/null
> > +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> > @@ -0,0 +1,229 @@
> > +/*
> > + * Copyright (C) 2014 Free Electrons
> > + * Copyright (C) 2014 Atmel
> > + *
> > + * Author: Boris BREZILLON 
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of the GNU General Public License version 2 as 
> > published by
> > + * the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful, but 
> > WITHOUT
> > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
> > for
> > + * more details.
> > + *
> > + * You should have received a copy of the GNU General Public License along 
> > with
> > + * this program.  If not, see <http://www.gnu.org/licenses/>.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define ATMEL_HLCDC_PWMCVAL_MASK   GENMASK(15, 8)
> > +#define ATMEL_HLCDC_PWMCVAL(x) ((x << 8) & 
> > ATMEL_HLCDC_PWMCVAL_MASK)
> 
> You might want to use an extra pair of parentheses around the "x" above.
> 
> > +struct atmel_hlcdc_pwm_chip {
> 
> Can we make this...
> 
> > +   struct pwm_chip chip;
> > +   struct atmel_hlcdc *hlcdc;
> > +   struct clk *cur_clk;
> > +};
> > +
> > +static inline struct atmel_hlcdc_pwm_chip *
> > +pwm_chip_to_atmel_hlcdc_pwm_chip(struct pwm_chip *chip)
> 
> ... and this a little shorter? There is a lot of line-wrapping below
> only because this is very long. It seems like just dropping the
> pwm_chip_ prefix on this function would be enough to not exceed the
> 78/80 character limit.
> 
> > +{
> > +   return container_of(chip, struct atmel_hlcdc_pwm_chip, chip);
> > +}
> > +
> > +static int atmel_hlcdc_pwm_config(struct pwm_chip *c,
> > + struct pwm_device *pwm,
> > + int duty_ns, int period_ns)
> > +{
> > +   struct atmel_hlcdc_pwm_chip *chip =
> > +   pwm_chip_to_atmel_hlcdc_pwm_chip(c);
> > +   struct atmel_hlcdc *hlcdc = chip->hlcdc;
> > +   struct clk *new_clk = hlcdc->slow_clk;
> > +   u64 pwmcval = duty_ns * 256;
> > +   unsigned long clk_freq;
> > +   u64 clk_period_ns;
> > +   u32 pwmcfg;
> > +   int pres;
> > +
> > +   clk_freq = clk_get_rate(new_clk);
> > +   clk_period_ns = 10;
> 
> NSEC_PER_SEC?
> 
> > +   clk_period_ns *= 256;
> 
> Perhaps collapse the above two in a single line:
> 
>   clk_period_ns = NSEC_PER_SEC * 256;
> 
> ?
> 
> > +   do_div(clk_period_ns, clk_freq);
> > +
> > +   if (clk_period_ns > period_ns) {
> > +   new_clk = hlcdc->sys_clk;
> > +   clk_freq = clk_get_rate(new_clk);
> > +   clk_period_ns = 10;
> > +   clk_period_ns *= 256;
> 
> Maybe:
> 
>   clk_period_ns = NSEC_PER_SEC * 256;
> 
> ?
> 
> > +   do_div(clk_period_ns, clk_freq);
> > +   }
> > +
> > +   for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
> > +   if ((clk_period_ns << pres) >= period_ns)
> > +   break;
> > +   }
> 
> Technically there's no need for the curly braces.
> 
> > +
> > +   if (pres > ATMEL_HLCDC_PWMPS_MAX)
> > +   return -EINVAL;
> 
> I think the condition above needs to be "pres == ATMEL_HLCDC_PWMPS_MAX",
> otherwise this will never be true.

Actually the previo

[PATCH v7 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 12:54:34 +0200
Thierry Reding  wrote:

> On Wed, Oct 01, 2014 at 04:53:03PM +0200, Boris Brezillon wrote:
> > From: Boris BREZILLON 
> > 
> > The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
> > at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
> > controller device.
> > 
> > The HLCDC block provides a single RGB output port, and only supports LCD
> > panels connection to LCD panels for now.
> > 
> > The atmel,panel property link the HLCDC RGB output with the LCD panel
> > connected on this port (note that the HLCDC RGB connector implementation
> > makes use of the DRM panel framework).
> > 
> > Connection to other external devices (DRM bridges) might be added later by
> > mean of a new atmel,xxx (atmel,bridge) property.
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  .../devicetree/bindings/drm/atmel-hlcdc-dc.txt | 53 
> > ++
> >  1 file changed, 53 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt 
> > b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > new file mode 100644
> > index 000..ebc1a91
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > @@ -0,0 +1,53 @@
> > +Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver
> > +
> > +The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD device.
> > +See ../mfd/atmel-hlcdc.txt for more details.
> > +
> > +Required properties:
> > + - compatible: value should be "atmel,hlcdc-display-controller"
> > + - pinctrl-names: the pin control state names. Should contain "default".
> > + - pinctrl-0: should contain the default pinctrl states.
> > + - #address-cells: should be set to 1.
> > + - #size-cells: should be set to 0.
> > +
> > +Required children nodes:
> > + Children nodes are encoding available output ports and their connections
> > + to external devices using the OF graph reprensentation (see ../graph.txt).
> > + At least one port node is required.
> 
> Are the connections configurable at runtime? Does the SoC have IP blocks
> for HDMI or other types of outputs or does it provide only RGB output to
> external blocks?

No, there's only one RGB output port, but you can connect more than one
device on the RGB port (should we call it DPI port ?).
Actually Atmel connected an HDMI encoder and an LCD panel connected on
the same port on their dev kit.

> 
> When you say "at least one port", how are multiple ports going to work
> if you have only a single display controller?

No there's only one port for now, I'll rework the last statement.

> 
> Thierry



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 13:01:16 +0200
Thierry Reding  wrote:

> On Wed, Oct 01, 2014 at 04:53:07PM +0200, Boris Brezillon wrote:
> [...]
> > diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
> > b/arch/arm/boot/dts/sama5d3xdm.dtsi
> [...]
> > +   bl_reg: backlight_regulator {
> > +   compatible = "regulator-fixed";
> > +   regulator-name = "backlight-power-supply";
> > +   regulator-min-microvolt = <500>;
> > +   regulator-max-microvolt = <500>;
> > +   status = "disabled";
> > +   };
> > +
> > +   panel_reg: panel_regulator {
> > +   compatible = "regulator-fixed";
> > +   regulator-name = "panel-power-supply";
> > +   regulator-min-microvolt = <330>;
> > +   regulator-max-microvolt = <330>;
> > +   status = "disabled";
> > +   };
> > +
> > +   backlight: backlight {
> > +   compatible = "pwm-backlight";
> > +   pwms = <_pwm 0 5 0>;
> > +   brightness-levels = <0 4 8 16 32 64 128 255>;
> > +   default-brightness-level = <6>;
> > +   power-supply = <_reg>;
> > +   status = "disabled";
> > +   };
> 
> Why are these all disabled? Patch 11/11 now needs to enable all of them
> explicitly for each board that uses this display module.

Yes, these nodes should be enabled. I just thought we could include the
xdm dtsi and enable what we really need in the board file, but it
doesn't make any sense...

> 
> > +   panel: panel {
> > +   compatible = "foxlink,fl500wvr00-a0t", "simple-panel";
> 
> "simple-panel" shouldn't be in this list. There's nothing useful a
> driver can do by matching on it.

Sure, I'll remove the "simple-panel" compatible string.

> 
> > +   backlight = <>;
> > +   power-supply = <_reg>;
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +   status = "disabled";
> > +
> > +   port at 0 {
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +
> > +   panel_input: endpoint at 0 {
> > +   reg = <0>;
> > +   remote-endpoint = <_panel_output>;
> > +   };
> > };
> 
> There's no support for OF graphs in simple-panel, so this is unused,
> isn't it?

Actually I use it in my atmel_hlcdc_ouput implementation to figure out
the link between a panel and a device connected on the RGB/DPI bus. 



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 04/11] pwm: add DT bindings documentation for atmel-hlcdc-pwm driver

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 12:13:51 +0200
Thierry Reding  wrote:

> On Wed, Oct 01, 2014 at 04:53:01PM +0200, Boris Brezillon wrote:
> > From: Boris BREZILLON 
> > 
> > The HLCDC IP available in some Atmel SoCs (i.e. sam9x5i.e. at91sam9n12,
> > at91sam9x5 family or sama5d3 family) provide a PWM device.
> > 
> > The DT bindings used for this PWM device is following the default 3 cells
> > bindings described in Documentation/devicetree/bindings/pwm/pwm.txt.
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  .../devicetree/bindings/pwm/atmel-hlcdc-pwm.txt| 55 
> > ++
> >  1 file changed, 55 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt 
> > b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
> > new file mode 100644
> > index 000..86ad3e2
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
> > @@ -0,0 +1,55 @@
> > +Device-Tree bindings for Atmel's HLCDC (High LCD Controller) PWM driver
> > +
> > +The Atmel HLCDC PWM is subdevice of the HLCDC MFD device.
> > +See ../mfd/atmel-hlcdc.txt for more details.
> > +
> > +Required properties:
> > + - compatible: value should be one of the following:
> > +   "atmel,hlcdc-pwm"
> > + - pinctr-names: the pin control state names. Should contain "default".
> > + - pinctrl-0: should contain the pinctrl states described by pinctrl
> > +   default.
> > + - #pwm-cells: should be set to 3. This PWM chip use the default 3 cells
> > +   bindings defined in Documentation/devicetree/bindings/pwm/pwm.txt.
> > +   The first cell encodes the PWM id (0 is the only acceptable value here,
> > +   because the chip only provide one PWM).
> > +   The second cell encodes the PWM period in nanoseconds.
> > +   The third cell encodes the PWM flags (the only supported flag is
> > +   PWM_POLARITY_INVERTED)
> 
> Given that this already refers to the default 3 cells binding it doesn't
> need to repeat part of the contents of pwm.txt.
> 
> With that fixed and assuming you'd like this to be merged via the same
> tree that the DRM and or MFD driver is, this patch:
> 
> Acked-by: Thierry Reding 
> 
> If you'd prefer this to go through the PWM tree just let me know.

Yes I'd prefer this solution, but shouldn't we wait for Lee to take the
first two patches in his tree ?



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 14:40:15 +0200
Thierry Reding  wrote:

> On Mon, Oct 06, 2014 at 02:25:38PM +0200, Boris Brezillon wrote:
> > On Mon, 6 Oct 2014 13:01:16 +0200 Thierry Reding  > gmail.com> wrote:
> > > On Wed, Oct 01, 2014 at 04:53:07PM +0200, Boris Brezillon wrote:
> > > [...]
> > > > diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
> > > > b/arch/arm/boot/dts/sama5d3xdm.dtsi
> [...]
> > > > +   backlight = <>;
> > > > +   power-supply = <_reg>;
> > > > +   #address-cells = <1>;
> > > > +   #size-cells = <0>;
> > > > +   status = "disabled";
> > > > +
> > > > +   port at 0 {
> > > > +   #address-cells = <1>;
> > > > +   #size-cells = <0>;
> > > > +
> > > > +   panel_input: endpoint at 0 {
> > > > +   reg = <0>;
> > > > +   remote-endpoint = <_panel_output>;
> > > > +   };
> > > > };
> > > 
> > > There's no support for OF graphs in simple-panel, so this is unused,
> > > isn't it?
> > 
> > Actually I use it in my atmel_hlcdc_ouput implementation to figure out
> > the link between a panel and a device connected on the RGB/DPI bus. 
> 
> That's kind of weird and one of the reasons why I can't make myself like
> the OF graph bindings. It requires drivers for one device to reach into
> the device tree node of some other device and look for content. Or put
> another way, a DT node for a panel that works on one platform doesn't
> work on another because the display controller needs additional DT
> content that isn't required by the original binding for the panel.

I also have a working POC of a DPI bus implementation (with DPI support
in panel-simple driver).

This is a solution I developed to provide a generic DPI implementation
in my HLCDC driver and rely on generic external implementations for
slave devices (panels, encoders, ...).

But, IIRC, Laurent was not in favor of a bus approach because the DPI
bus is just a data bus and not a control bus.

Anyway, I'll clean it up and post an RFC.

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v8 0/2] mfd: add atmel-hlcdc driver

2014-10-06 Thread Boris Brezillon
Hi Lee,

As proposed in my last atmel-hlcdc series I have split the series in order
to get the accepted parts merged.

This series is the one all others depend on.
Could you take it in your tree so that other maintainers can rely on the
fact this part will be merged before other parts.

Moreover, I know this is late, but can you include it in one of your 3.18
pull request as suggested by Thierry.
If you can't, can you provide Thierry and Dave with a stable branch
including this driver ?

Best Regards,

Boris

Boris Brezillon (2):
  mfd: add atmel-hlcdc driver
  mfd: add documentation for atmel-hlcdc DT bindings

 .../devicetree/bindings/mfd/atmel-hlcdc.txt|  51 +
 drivers/mfd/Kconfig|   6 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/atmel-hlcdc.c  | 122 +
 include/linux/mfd/atmel-hlcdc.h|  85 ++
 5 files changed, 265 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
 create mode 100644 drivers/mfd/atmel-hlcdc.c
 create mode 100644 include/linux/mfd/atmel-hlcdc.h

-- 
1.9.1



[PATCH v8 1/2] mfd: add atmel-hlcdc driver

2014-10-06 Thread Boris Brezillon
The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

The MFD device provides a regmap and several clocks (those connected
to this hardware block) to its subdevices.

This way concurrent accesses to the iomem range are handled by the regmap
framework, and each subdevice can safely access HLCDC registers.

Signed-off-by: Boris Brezillon 
Acked-by: Lee Jones 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 drivers/mfd/Kconfig |   6 ++
 drivers/mfd/Makefile|   1 +
 drivers/mfd/atmel-hlcdc.c   | 122 
 include/linux/mfd/atmel-hlcdc.h |  85 
 4 files changed, 214 insertions(+)
 create mode 100644 drivers/mfd/atmel-hlcdc.c
 create mode 100644 include/linux/mfd/atmel-hlcdc.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index de5abf2..1b925f7 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,12 @@ config MFD_AAT2870_CORE
  additional drivers must be enabled in order to use the
  functionality of the device.

+config MFD_ATMEL_HLCDC
+   tristate
+   select MFD_CORE
+   select REGMAP_MMIO
+   depends on OF
+
 config MFD_BCM590XX
tristate "Broadcom BCM590xx PMUs"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f001487..df36f68 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_MFD_PM8921_CORE)   += pm8921-core.o ssbi.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
+obj-$(CONFIG_MFD_ATMEL_HLCDC)  += atmel-hlcdc.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_PALMAS)   += palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)+= viperboard.o
diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
new file mode 100644
index 000..cfd58f4
--- /dev/null
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_HLCDC_REG_MAX(0x4000 - 0x4)
+
+static const struct mfd_cell atmel_hlcdc_cells[] = {
+   {
+   .name = "atmel-hlcdc-pwm",
+   .of_compatible = "atmel,hlcdc-pwm",
+   },
+   {
+   .name = "atmel-hlcdc-dc",
+   .of_compatible = "atmel,hlcdc-display-controller",
+   },
+};
+
+static const struct regmap_config atmel_hlcdc_regmap_config = {
+   .reg_bits = 32,
+   .val_bits = 32,
+   .reg_stride = 4,
+   .max_register = ATMEL_HLCDC_REG_MAX,
+};
+
+static int atmel_hlcdc_probe(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct atmel_hlcdc *hlcdc;
+   struct resource *res;
+   void __iomem *regs;
+
+   hlcdc = devm_kzalloc(dev, sizeof(*hlcdc), GFP_KERNEL);
+   if (!hlcdc)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(regs))
+   return PTR_ERR(regs);
+
+   hlcdc->irq = platform_get_irq(pdev, 0);
+   if (hlcdc->irq < 0)
+   return hlcdc->irq;
+
+   hlcdc->periph_clk = devm_clk_get(dev, "periph_clk");
+   if (IS_ERR(hlcdc->periph_clk)) {
+   dev_err(dev, "failed to get peripheral clock\n");
+   return PTR_ERR(hlcdc->periph_clk);
+   }
+
+   hlcdc->sys_clk = devm_clk_get(dev, "sys_clk");
+   if (IS_ERR(hlcdc->sys_clk)) {
+   dev_err(dev, "failed to get system clock\n");
+   return PTR_ERR(hlcdc->sys_clk);
+   }
+
+   hlcdc->slow_clk = devm_clk_get(dev, "slow_clk");
+   if (IS_ERR(hlcdc->slow_clk)) {
+   dev_err(dev, "failed to get slow clock\n");
+   return PTR_ERR(hlcdc->slow_clk);
+   }
+
+   hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
+ 

[PATCH v8 2/2] mfd: add documentation for atmel-hlcdc DT bindings

2014-10-06 Thread Boris Brezillon
The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

This patch adds documentation for atmel-hlcdc DT bindings.

Signed-off-by: Boris Brezillon 
Tested-by: Anthony Harivel 
Tested-by: Ludovic Desroches 
---
 .../devicetree/bindings/mfd/atmel-hlcdc.txt| 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt

diff --git a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt 
b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
new file mode 100644
index 000..f64de95a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
@@ -0,0 +1,51 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) MFD driver
+
+Required properties:
+ - compatible: value should be one of the following:
+   "atmel,sama5d3-hlcdc"
+ - reg: base address and size of the HLCDC device registers.
+ - clock-names: the name of the 3 clocks requested by the HLCDC device.
+   Should contain "periph_clk", "sys_clk" and "slow_clk".
+ - clocks: should contain the 3 clocks requested by the HLCDC device.
+ - interrupts: should contain the description of the HLCDC interrupt line
+
+The HLCDC IP exposes two subdevices:
+ - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt
+ - a Display Controller: see ../drm/atmel-hlcdc-dc.txt
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v7 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 14:35:06 +0200
Thierry Reding  wrote:

> On Mon, Oct 06, 2014 at 02:14:40PM +0200, Boris Brezillon wrote:
> > On Mon, 6 Oct 2014 12:54:34 +0200
> > Thierry Reding  wrote:
> > 
> > > On Wed, Oct 01, 2014 at 04:53:03PM +0200, Boris Brezillon wrote:
> > > > From: Boris BREZILLON 
> > > > 
> > > > The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
> > > > at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
> > > > controller device.
> > > > 
> > > > The HLCDC block provides a single RGB output port, and only supports LCD
> > > > panels connection to LCD panels for now.
> > > > 
> > > > The atmel,panel property link the HLCDC RGB output with the LCD panel
> > > > connected on this port (note that the HLCDC RGB connector implementation
> > > > makes use of the DRM panel framework).
> > > > 
> > > > Connection to other external devices (DRM bridges) might be added later 
> > > > by
> > > > mean of a new atmel,xxx (atmel,bridge) property.
> > > > 
> > > > Signed-off-by: Boris Brezillon 
> > > > ---
> > > >  .../devicetree/bindings/drm/atmel-hlcdc-dc.txt | 53 
> > > > ++
> > > >  1 file changed, 53 insertions(+)
> > > >  create mode 100644 
> > > > Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt 
> > > > b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > new file mode 100644
> > > > index 000..ebc1a91
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > @@ -0,0 +1,53 @@
> > > > +Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver
> > > > +
> > > > +The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD 
> > > > device.
> > > > +See ../mfd/atmel-hlcdc.txt for more details.
> > > > +
> > > > +Required properties:
> > > > + - compatible: value should be "atmel,hlcdc-display-controller"
> > > > + - pinctrl-names: the pin control state names. Should contain 
> > > > "default".
> > > > + - pinctrl-0: should contain the default pinctrl states.
> > > > + - #address-cells: should be set to 1.
> > > > + - #size-cells: should be set to 0.
> > > > +
> > > > +Required children nodes:
> > > > + Children nodes are encoding available output ports and their 
> > > > connections
> > > > + to external devices using the OF graph reprensentation (see 
> > > > ../graph.txt).
> > > > + At least one port node is required.
> > > 
> > > Are the connections configurable at runtime? Does the SoC have IP blocks
> > > for HDMI or other types of outputs or does it provide only RGB output to
> > > external blocks?
> > 
> > No, there's only one RGB output port, but you can connect more than one
> > device on the RGB port (should we call it DPI port ?).
> > Actually Atmel connected an HDMI encoder and an LCD panel connected on
> > the same port on their dev kit.
> 
> This was discussed in some other thread if I remember correctly. I still
> think that the HLCDC node should only contain a single output, no matter
> how many encoders or panels get connected.
> 
> So the output represents the set of signals that exit the IP block, but
> what's connected to them on the board is a board-level detail and
> therefore should go into the board DTS.
> 
> In the above case of the Atmel devkit, is there any way to control where
> the signal goes or does it just go to both the panel and HDMI encoder at
> the same time and it's up to the user to properly configure the output
> in order to get either HDMI or panel to display anything?

No there's no way to control where the signal goes.
What you can control though, is the activation of the associated
encoder/connectors connected on this bus (using dpms).

And yes it's up to the user to choose the appropriate mode:
- display on only one slave device: in this case you're free to choose
  any of the mode supported by the slave device
- display on all slave devices: in this case you'll have to find a mode
  (drm_display_mode) and an bus format (video_bus_format) that suits all
  slave devices



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v7 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 15:30:59 +0200
Thierry Reding  wrote:

> On Mon, Oct 06, 2014 at 03:11:11PM +0200, Boris Brezillon wrote:
> > On Mon, 6 Oct 2014 14:40:15 +0200
> > Thierry Reding  wrote:
> > 
> > > On Mon, Oct 06, 2014 at 02:25:38PM +0200, Boris Brezillon wrote:
> > > > On Mon, 6 Oct 2014 13:01:16 +0200 Thierry Reding  > > > gmail.com> wrote:
> > > > > On Wed, Oct 01, 2014 at 04:53:07PM +0200, Boris Brezillon wrote:
> > > > > [...]
> > > > > > diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
> > > > > > b/arch/arm/boot/dts/sama5d3xdm.dtsi
> > > [...]
> > > > > > +   backlight = <>;
> > > > > > +   power-supply = <_reg>;
> > > > > > +   #address-cells = <1>;
> > > > > > +   #size-cells = <0>;
> > > > > > +   status = "disabled";
> > > > > > +
> > > > > > +   port at 0 {
> > > > > > +   #address-cells = <1>;
> > > > > > +   #size-cells = <0>;
> > > > > > +
> > > > > > +   panel_input: endpoint at 0 {
> > > > > > +   reg = <0>;
> > > > > > +   remote-endpoint = <_panel_output>;
> > > > > > +   };
> > > > > > };
> > > > > 
> > > > > There's no support for OF graphs in simple-panel, so this is unused,
> > > > > isn't it?
> > > > 
> > > > Actually I use it in my atmel_hlcdc_ouput implementation to figure out
> > > > the link between a panel and a device connected on the RGB/DPI bus. 
> > > 
> > > That's kind of weird and one of the reasons why I can't make myself like
> > > the OF graph bindings. It requires drivers for one device to reach into
> > > the device tree node of some other device and look for content. Or put
> > > another way, a DT node for a panel that works on one platform doesn't
> > > work on another because the display controller needs additional DT
> > > content that isn't required by the original binding for the panel.
> > 
> > I also have a working POC of a DPI bus implementation (with DPI support
> > in panel-simple driver).
> > 
> > This is a solution I developed to provide a generic DPI implementation
> > in my HLCDC driver and rely on generic external implementations for
> > slave devices (panels, encoders, ...).
> > 
> > But, IIRC, Laurent was not in favor of a bus approach because the DPI
> > bus is just a data bus and not a control bus.
> > 
> > Anyway, I'll clean it up and post an RFC.
> 
> According to the MIPI website there are also control signals and a
> command set to control display behaviour. Does your implementation
> handle any of that?

No it doesn't, and I'm pretty sure what I call DPI does not exactly
respect the MIPI DPI standard (and as such should not be called DPI,
but this is another problem).

This infrastructure provides a way for devices connected on a DPI bus
to agree on a video_bus_format (in my case RGB888, RGB666, ...).

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[RFC 2/7] drm: add DPI connector/encoder definitions

2014-10-06 Thread Boris Brezillon
Add DPI connector and encoder types so that we can properly define devices
directly connected on this kind of bus (like simple panels).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/drm_crtc.c  | 2 ++
 include/uapi/drm/drm_mode.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index c31420f..99b89ee 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -266,6 +266,7 @@ static struct drm_conn_prop_enum_list 
drm_connector_enum_list[] =
{ DRM_MODE_CONNECTOR_eDP, "eDP" },
{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
{ DRM_MODE_CONNECTOR_DSI, "DSI" },
+   { DRM_MODE_CONNECTOR_DPI, "DPI" },
 };

 static const struct drm_prop_enum_list drm_encoder_enum_list[] =
@@ -277,6 +278,7 @@ static const struct drm_prop_enum_list 
drm_encoder_enum_list[] =
{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
{ DRM_MODE_ENCODER_DSI, "DSI" },
{ DRM_MODE_ENCODER_DPMST, "DP MST" },
+   { DRM_MODE_ENCODER_DPI, "DPI" },
 };

 static const struct drm_prop_enum_list drm_subpixel_enum_list[] =
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index a0db2d4a..9a8669e 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -187,6 +187,7 @@ struct drm_mode_get_plane_res {
 #define DRM_MODE_ENCODER_VIRTUAL 5
 #define DRM_MODE_ENCODER_DSI   6
 #define DRM_MODE_ENCODER_DPMST 7
+#define DRM_MODE_ENCODER_DPI   8

 struct drm_mode_get_encoder {
__u32 encoder_id;
@@ -226,6 +227,7 @@ struct drm_mode_get_encoder {
 #define DRM_MODE_CONNECTOR_eDP 14
 #define DRM_MODE_CONNECTOR_VIRTUAL  15
 #define DRM_MODE_CONNECTOR_DSI 16
+#define DRM_MODE_CONNECTOR_DPI 17

 struct drm_mode_get_connector {

-- 
1.9.1



[RFC 0/7] drm: add DPI bus support

2014-10-06 Thread Boris Brezillon
Hello,

This is a proposal to address one of the issue I've been facing with the
atmel-hlcdc driver.

This driver provides a DPI (or raw RGB) bus on which we might access
several devices (a panel, an HDMI encoder, or any other type of encoder).

My problem is that I have to find the best bus format according to the
devices connected on the bus.
Another problem is when 2 devices on the same bus requires 2 orthogonal
formats, we should be able to detect this kind of issue and reject the
requested mode setting.

This implementation was designed in a few hours and thus is far from
perfect.
It is given as a starting point to further discuss the available
solution I have to support this kind of configuration.

Patches 1 and 2 implement a basic DPI bus infrastructure (or whatever name
we decide to use: DPI is a MIPI standard that involves more than just
video bus format description).

Patches 3 and 4 add DPI panel support, and patches 5, 6 and 7 implement a
DPI host in the atmel-hlcdc driver (the driver I'm currently working on).

This implementation also has the benefit of keeping the display controller
driver indepedant of slave device types (panels, encoders, bridges,
...).

Feel free to share your thoughts on this problem (and/or the proposed
solution).

Best Regards,

Boris

Boris Brezillon (7):
  drm: add DPI bus support
  drm: add DPI connector/encoder definitions
  drm: support panels connected on a DPI bus
  drm: panel: move foxlink fl500wvr00-a0t panel to the DPI panel list
  drm: atmel-hlcdc: add DPI support
  drm: atmel-hlcdc: move to DPI
  ARM: at91/dt: define sama5d3xek panel as a DPI device

 arch/arm/boot/dts/sama5d36ek.dts |  12 +-
 arch/arm/boot/dts/sama5d3_lcd.dtsi   |   6 +-
 arch/arm/boot/dts/sama5d3xdm.dtsi|  28 +-
 drivers/gpu/drm/Kconfig  |   4 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/atmel-hlcdc/Kconfig  |   1 +
 drivers/gpu/drm/atmel-hlcdc/Makefile |   2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c   |  11 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  12 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h |   6 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c| 212 +++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 443 ---
 drivers/gpu/drm/drm_crtc.c   |   2 +
 drivers/gpu/drm/drm_mipi_dpi.c   | 369 +++
 drivers/gpu/drm/panel/panel-simple.c | 331 +++--
 include/drm/drm_mipi_dpi.h   | 169 +
 include/uapi/drm/drm_mode.h  |   2 +
 17 files changed, 1100 insertions(+), 511 deletions(-)
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c
 delete mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
 create mode 100644 drivers/gpu/drm/drm_mipi_dpi.c
 create mode 100644 include/drm/drm_mipi_dpi.h

-- 
1.9.1



[RFC 1/7] drm: add DPI bus support

2014-10-06 Thread Boris Brezillon
The DPI bus is a parallel bus used to interface with video components.
This bus provide some control signals (HSYNC, VSYNC) and a parallel data
bus used to transfer content to slave devices (panels, encoders, ...)

This DPI layer is providing a way to negotiate a video format suiting all
the activated DPI devices on the bus.

As usual with busses, there are two ends:
- the host: this is the device aggregating the devices on a DPI bus.
It is also responsible for choosing the best format given the
devices connected on its bus.
- the device: it's describing a specific hardware (a panel, an encoder, or
  any other DRM device), and as such is attached to a driver.
  This driver will typically create a DRM encoder (and
  possibly the associated connector) and attach it to the DRM
  device embedding the DPI bus.

This approach will ease the work of display controllers, and
hopefully provide a standard way to bind slave DRM devices to DRM devices
(assuming your device is connected on DPI bus).

The term MIPI DPI or even DPI might not be the appropriate one as MIPI DPI
is a standard specify more things than just the video bus format being
used on the bus.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/Kconfig|   4 +
 drivers/gpu/drm/Makefile   |   1 +
 drivers/gpu/drm/drm_mipi_dpi.c | 369 +
 include/drm/drm_mipi_dpi.h | 169 +++
 4 files changed, 543 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_mipi_dpi.c
 create mode 100644 include/drm/drm_mipi_dpi.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 2d97f7e..8ad8983 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -20,6 +20,10 @@ menuconfig DRM
  details.  You should also select and configure AGP
  (/dev/agpgart) support if it is available for your platform.

+config DRM_MIPI_DPI
+   bool
+   depends on DRM
+
 config DRM_MIPI_DSI
bool
depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index abb4f29..a77b2bc 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 CFLAGS_drm_trace_points.o := -I$(src)

 obj-$(CONFIG_DRM)  += drm.o
+obj-$(CONFIG_DRM_MIPI_DPI) += drm_mipi_dpi.o
 obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
 obj-$(CONFIG_DRM_USB)   += drm_usb.o
 obj-$(CONFIG_DRM_TTM)  += ttm/
diff --git a/drivers/gpu/drm/drm_mipi_dpi.c b/drivers/gpu/drm/drm_mipi_dpi.c
new file mode 100644
index 000..403922c
--- /dev/null
+++ b/drivers/gpu/drm/drm_mipi_dpi.c
@@ -0,0 +1,369 @@
+/*
+ * MIPI DPI Bus
+ *
+ * Copyright (C) 2014, Atmel
+ * Copyright (C) 2014, Free Electrons
+ *
+ * Author: Boris Brezillon
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static int mipi_dpi_device_match(struct device *dev, struct device_driver *drv)
+{
+   return of_driver_match_device(dev, drv);
+}
+
+static const struct dev_pm_ops mipi_dpi_device_pm_ops = {
+   .runtime_suspend = pm_generic_runtime_suspend,
+   .runtime_resume = pm_generic_runtime_resume,
+   .suspend = pm_generic_suspend,
+   .resume = pm_generic_resume,
+   .freeze = pm_generic_freeze,
+   .thaw = pm_generic_thaw,
+   .poweroff = pm_generic_poweroff,
+   .restore = pm_generic_restore,
+};
+
+static struct bus_type mipi_dpi_bus_type = {
+   .name = "mipi-dpi",
+   .match = mipi_dpi_device_match,
+   .pm = _dpi_device_pm_ops,
+};
+
+static void mipi_dpi_dev_release(struct device *dev)
+{
+   struct mipi_dpi_device *dpi = to_mipi_dpi_device(dev);
+
+   of_node_put(dev->of_node);
+   kfree(dpi);
+}
+

[RFC 3/7] drm: support panels connected on a DPI bus

2014-10-06 Thread Boris Brezillon
Add support for panels connected on a DPI bus.
This implementation includes DRM encoder/connector creation and attachment
to the DRM device so that the only thing needed to access such a panel is
to implement a DPI host in your driver and define the appropriate node in
your DT (under the DPI node).

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 277 +++
 1 file changed, 277 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 11bff3f..fd448ca 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -30,7 +30,9 @@

 #include 
 #include 
+#include 
 #include 
+#include 
 #include 

 struct panel_desc {
@@ -851,6 +853,275 @@ static struct mipi_dsi_driver panel_simple_dsi_driver = {
.shutdown = panel_simple_dsi_shutdown,
 };

+struct panel_desc_dpi {
+   struct panel_desc desc;
+
+   enum video_bus_format format;
+};
+
+struct panel_dpi {
+   struct drm_encoder encoder;
+   struct drm_connector connector;
+   int dpms_mode;
+
+   struct mipi_dpi_device *dev;
+};
+
+static const struct of_device_id dpi_of_match[] = {
+   {
+   /* sentinel */
+   }
+};
+MODULE_DEVICE_TABLE(of, dsi_of_match);
+
+static inline struct panel_dpi *
+drm_encoder_to_panel_dpi(struct drm_encoder *encoder)
+{
+   return container_of(encoder, struct panel_dpi, encoder);
+}
+
+static void panel_dpi_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+   struct panel_dpi *dpanel = drm_encoder_to_panel_dpi(encoder);
+   struct panel_simple *panel = mipi_dpi_get_drvdata(dpanel->dev);
+
+   if (mode != DRM_MODE_DPMS_ON)
+   mode = DRM_MODE_DPMS_OFF;
+
+   if (mode == dpanel->dpms_mode)
+   return;
+
+   switch (mode) {
+   case DRM_MODE_DPMS_ON:
+   drm_panel_prepare(>base);
+   drm_panel_enable(>base);
+   mipi_dpi_enable(dpanel->dev);
+   break;
+   case DRM_MODE_DPMS_STANDBY:
+   case DRM_MODE_DPMS_SUSPEND:
+   case DRM_MODE_DPMS_OFF:
+   mipi_dpi_disable(dpanel->dev);
+   drm_panel_disable(>base);
+   drm_panel_unprepare(>base);
+   break;
+   }
+
+   dpanel->dpms_mode = mode;
+}
+
+static bool panel_dpi_encoder_mode_fixup(struct drm_encoder *encoder,
+const struct drm_display_mode *mode,
+struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void panel_dpi_encoder_mode_set(struct drm_encoder *encoder,
+  struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted)
+{
+}
+
+static void panel_dpi_encoder_prepare(struct drm_encoder *encoder)
+{
+   panel_dpi_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
+}
+
+static void panel_dpi_encoder_commit(struct drm_encoder *encoder)
+{
+   panel_dpi_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
+}
+
+static const struct drm_encoder_helper_funcs panel_dpi_encoder_helper_funcs = {
+   .dpms = panel_dpi_encoder_dpms,
+   .mode_fixup = panel_dpi_encoder_mode_fixup,
+   .mode_set = panel_dpi_encoder_mode_set,
+   .prepare = panel_dpi_encoder_prepare,
+   .commit = panel_dpi_encoder_commit,
+};
+
+static const struct drm_encoder_funcs panel_dpi_encoder_funcs = {
+   .destroy = drm_encoder_cleanup,
+};
+
+static inline struct panel_dpi *
+drm_connector_to_panel_dpi(struct drm_connector *connector)
+{
+   return container_of(connector, struct panel_dpi, connector);
+}
+
+static int panel_dpi_connector_get_modes(struct drm_connector *connector)
+{
+   struct panel_dpi *dpanel = drm_connector_to_panel_dpi(connector);
+   struct panel_simple *panel = mipi_dpi_get_drvdata(dpanel->dev);
+
+   return drm_panel_get_modes(>base);
+}
+
+static struct drm_encoder *
+panel_dpi_connector_best_encoder(struct drm_connector *connector)
+{
+   struct panel_dpi *dpanel = drm_connector_to_panel_dpi(connector);
+
+   return >encoder;
+}
+
+static int panel_dpi_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode)
+{
+   return MODE_OK;
+}
+
+static const struct drm_connector_helper_funcs 
panel_dpi_connector_helper_funcs = {
+   .get_modes = panel_dpi_connector_get_modes,
+   .mode_valid = panel_dpi_connector_mode_valid,
+   .best_encoder = panel_dpi_connector_best_encoder,
+};
+
+static enum drm_connector_status
+panel_dpi_connector_detect(struct drm_connector *connector, bool force)
+{
+   return connector_status_connected;
+}
+
+static void
+panel_dpi_connector_destroy(struct drm_connector *connector)
+{
+   drm_connector_unregister(connector);
+   drm_connector_cleanup(connector);
+}
+
+static const struct drm_conne

[RFC 4/7] drm: panel: move foxlink fl500wvr00-a0t panel to the DPI panel list

2014-10-06 Thread Boris Brezillon
Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/panel/panel-simple.c | 54 +++-
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index fd448ca..51715e8 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -503,29 +503,6 @@ static const struct panel_desc edt_etm0700g0dh6 = {
},
 };

-static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
-   .clock = 32260,
-   .hdisplay = 800,
-   .hsync_start = 800 + 168,
-   .hsync_end = 800 + 168 + 64,
-   .htotal = 800 + 168 + 64 + 88,
-   .vdisplay = 480,
-   .vsync_start = 480 + 37,
-   .vsync_end = 480 + 37 + 2,
-   .vtotal = 480 + 37 + 2 + 8,
-   .vrefresh = 60,
-};
-
-static const struct panel_desc foxlink_fl500wvr00_a0t = {
-   .modes = _fl500wvr00_a0t_mode,
-   .num_modes = 1,
-   .size = {
-   .width = 108,
-   .height = 65,
-   },
-   .bus_format = VIDEO_BUS_FMT_RGB888_1X24,
-};
-
 static const struct drm_display_mode innolux_n116bge_mode = {
.clock = 71000,
.hdisplay = 1366,
@@ -645,9 +622,6 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "edt,etm0700g0dh6",
.data = _etm0700g0dh6,
}, {
-   .compatible = "foxlink,fl500wvr00-a0t",
-   .data = _fl500wvr00_a0t,
-   }, {
.compatible = "innolux,n116bge",
.data = _n116bge,
}, {
@@ -867,8 +841,36 @@ struct panel_dpi {
struct mipi_dpi_device *dev;
 };

+static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
+   .clock = 32260,
+   .hdisplay = 800,
+   .hsync_start = 800 + 168,
+   .hsync_end = 800 + 168 + 64,
+   .htotal = 800 + 168 + 64 + 88,
+   .vdisplay = 480,
+   .vsync_start = 480 + 37,
+   .vsync_end = 480 + 37 + 2,
+   .vtotal = 480 + 37 + 2 + 8,
+   .vrefresh = 60,
+};
+
+static const struct panel_desc_dpi foxlink_fl500wvr00_a0t = {
+   .desc = {
+   .modes = _fl500wvr00_a0t_mode,
+   .num_modes = 1,
+   .size = {
+   .width = 108,
+   .height = 65,
+   },
+   },
+   .format = VIDEO_BUS_FMT_RGB888_1X24,
+};
+
 static const struct of_device_id dpi_of_match[] = {
{
+   .compatible = "foxlink,fl500wvr00-a0t",
+   .data = _fl500wvr00_a0t,
+   }, {
/* sentinel */
}
 };
-- 
1.9.1



[RFC 5/7] drm: atmel-hlcdc: add DPI support

2014-10-06 Thread Boris Brezillon
Implement a DPI host in the HLCDC driver.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/Kconfig   |   1 +
 drivers/gpu/drm/atmel-hlcdc/Makefile  |   1 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c | 212 ++
 3 files changed, 214 insertions(+)
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c

diff --git a/drivers/gpu/drm/atmel-hlcdc/Kconfig 
b/drivers/gpu/drm/atmel-hlcdc/Kconfig
index 942407f..af660e2 100644
--- a/drivers/gpu/drm/atmel-hlcdc/Kconfig
+++ b/drivers/gpu/drm/atmel-hlcdc/Kconfig
@@ -5,6 +5,7 @@ config DRM_ATMEL_HLCDC
select DRM_KMS_HELPER
select DRM_KMS_FB_HELPER
select DRM_KMS_CMA_HELPER
+   select DRM_MIPI_DPI
select DRM_PANEL
select MFD_ATMEL_HLCDC
depends on OF
diff --git a/drivers/gpu/drm/atmel-hlcdc/Makefile 
b/drivers/gpu/drm/atmel-hlcdc/Makefile
index 10ae426..979e431 100644
--- a/drivers/gpu/drm/atmel-hlcdc/Makefile
+++ b/drivers/gpu/drm/atmel-hlcdc/Makefile
@@ -1,5 +1,6 @@
 atmel-hlcdc-dc-y := atmel_hlcdc_crtc.o \
atmel_hlcdc_dc.o \
+   atmel_hlcdc_dpi.o \
atmel_hlcdc_layer.o \
atmel_hlcdc_output.o \
atmel_hlcdc_plane.o
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c
new file mode 100644
index 000..b563dfc
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dpi.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+
+#include 
+#include 
+
+#include "atmel_hlcdc_dc.h"
+
+enum atmel_hlcdc_output_mode {
+   ATMEL_HLCDC_OUTPUT_FMT_RGB444,
+   ATMEL_HLCDC_OUTPUT_FMT_RGB565,
+   ATMEL_HLCDC_OUTPUT_FMT_RGB666,
+   ATMEL_HLCDC_OUTPUT_FMT_RGB888,
+};
+
+struct atmel_hlcdc_dpi_host {
+   struct mipi_dpi_host base;
+   struct atmel_hlcdc_dc *dc;
+};
+
+static inline struct atmel_hlcdc_dpi_host *
+to_atmel_hlcdc_dpi_host(struct mipi_dpi_host *host)
+{
+   return container_of(host, struct atmel_hlcdc_dpi_host, base);
+}
+
+static int atmel_hlcdc_dpi_attach(struct mipi_dpi_host *host,
+ struct mipi_dpi_device *dpi)
+{
+   return 0;
+}
+
+static int atmel_hlcdc_dpi_detach(struct mipi_dpi_host *host,
+ struct mipi_dpi_device *dpi)
+{
+   return 0;
+}
+
+static int atmel_hlcdc_dpi_best_format_exclusive(struct mipi_dpi_host *host,
+enum video_bus_format *format)
+{
+   struct mipi_dpi_device *dpi;
+   bool agreed = false;
+   int i;
+
+   for (i = 0; i < host->num_supported_formats; i++) {
+   enum video_bus_format hfmt = host->supported_formats[i];
+   agreed = true;
+
+   list_for_each_entry(dpi, >devices, node) {
+   int j;
+
+   if (!dpi->enabled)
+   continue;
+
+   for (j = 0; j < dpi->num_supported_formats; j++) {
+   if (hfmt == dpi->supported_formats[j])
+   break;
+   }
+
+   if (j == dpi->num_supported_formats) {
+   agreed = false;
+   break;
+   }
+   }
+
+   if (agreed) {
+   *format = hfmt;
+   break;
+   }
+   }
+
+   if (!agreed)
+   return -EINVAL;
+
+   list_for_each_entry(dpi, >devices, node) {
+   if (!dpi->enabled)
+   continue;
+
+   dpi->next_format = *format;
+   }
+
+   return 0;
+}
+
+static int
+atmel_hlcdc_dpi_best_format_non_exclusive(struct mipi_dpi_host *host,
+ enum video_bus_format *format)
+{
+   struct mipi_dpi_device *dpi;
+   int best_format_index = 0;
+
+   list_for_each_entry(dpi, >devices, node) {
+   int i, j;
+
+   if (!dpi->enabled)
+   continue;
+
+   for (i = 0; i < host->num_supported_formats; i++) {
+ 

[RFC 6/7] drm: atmel-hlcdc: move to DPI

2014-10-06 Thread Boris Brezillon
Replace atmel output implementation with the DPI host implementation, which
will prevent adding support for new kind of slave devices (encoders,
 panels, ...).

Call mipi_dpi_host_apply_format in CRTC commit to apply the newly selected
video bus format to use on the DPI bus.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/Makefile |   1 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c   |  11 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  12 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h |   6 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 443 ---
 5 files changed, 17 insertions(+), 456 deletions(-)
 delete mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c

diff --git a/drivers/gpu/drm/atmel-hlcdc/Makefile 
b/drivers/gpu/drm/atmel-hlcdc/Makefile
index 979e431..83bdc37 100644
--- a/drivers/gpu/drm/atmel-hlcdc/Makefile
+++ b/drivers/gpu/drm/atmel-hlcdc/Makefile
@@ -2,7 +2,6 @@ atmel-hlcdc-dc-y := atmel_hlcdc_crtc.o \
atmel_hlcdc_dc.o \
atmel_hlcdc_dpi.o \
atmel_hlcdc_layer.o \
-   atmel_hlcdc_output.o \
atmel_hlcdc_plane.o

 obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc-dc.o
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9f2a056..dda4e7e 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -218,14 +218,17 @@ int atmel_hlcdc_crtc_mode_set_base(struct drm_crtc *c, 
int x, int y,
  mode->vdisplay << 16);
 }

-static void atmel_hlcdc_crtc_prepare(struct drm_crtc *crtc)
+static void atmel_hlcdc_crtc_prepare(struct drm_crtc *c)
 {
-   atmel_hlcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+   atmel_hlcdc_crtc_dpms(c, DRM_MODE_DPMS_OFF);
 }

-static void atmel_hlcdc_crtc_commit(struct drm_crtc *crtc)
+static void atmel_hlcdc_crtc_commit(struct drm_crtc *c)
 {
-   atmel_hlcdc_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
+   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+
+   mipi_dpi_host_apply_format(crtc->dc->dpi);
+   atmel_hlcdc_crtc_dpms(c, DRM_MODE_DPMS_ON);
 }

 static bool atmel_hlcdc_crtc_mode_fixup(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 70c8808..1e799b8 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -233,12 +233,6 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device 
*dev)

drm_mode_config_init(dev);

-   ret = atmel_hlcdc_create_outputs(dev);
-   if (ret) {
-   dev_err(dev->dev, "failed to create panel: %d\n", ret);
-   return ret;
-   }
-
planes = atmel_hlcdc_create_planes(dev);
if (IS_ERR(planes)) {
dev_err(dev->dev, "failed to create planes\n");
@@ -258,6 +252,12 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device 
*dev)
dc->layers[planes->overlays[i]->layer.desc->id] =
>overlays[i]->layer;

+   ret = atmel_hlcdc_dpi_create(dev);
+   if (ret) {
+   dev_err(dev->dev, "failed to create DPI host\n");
+   return ret;
+   }
+
ret = atmel_hlcdc_crtc_create(dev);
if (ret) {
dev_err(dev->dev, "failed to create crtc\n");
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index 8194152..24a4ee7 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 

@@ -176,6 +177,7 @@ struct atmel_hlcdc_dc {
struct atmel_hlcdc *hlcdc;
struct drm_fbdev_cma *fbdev;
struct drm_crtc *crtc;
+   struct mipi_dpi_host *dpi;
struct atmel_hlcdc_planes *planes;
struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS];
struct workqueue_struct *wq;
@@ -196,6 +198,8 @@ int atmel_hlcdc_plane_prepare_update_req(struct drm_plane 
*p,
 int atmel_hlcdc_plane_apply_update_req(struct drm_plane *p,
struct atmel_hlcdc_plane_update_req *req);

+int atmel_hlcdc_dpi_create(struct drm_device *dev);
+
 void atmel_hlcdc_crtc_irq(struct drm_crtc *c);

 void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc *crtc,
@@ -203,8 +207,6 @@ void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc 
*crtc,

 int atmel_hlcdc_crtc_create(struct drm_device *dev);

-int atmel_hlcdc_create_outputs(struct drm_device *dev);
-
 struct atmel_hlcdc_pwm_chip *atmel_hlcdc_pwm_create(struct drm_device *dev,
struct clk *slow_clk,

[RFC 7/7] ARM: at91/dt: define sama5d3xek panel as a DPI device

2014-10-06 Thread Boris Brezillon
Replace old panel node with a new one relying on DPI bus support.

Signed-off-by: Boris Brezillon 
---
 arch/arm/boot/dts/sama5d36ek.dts   | 12 
 arch/arm/boot/dts/sama5d3_lcd.dtsi |  6 +++---
 arch/arm/boot/dts/sama5d3xdm.dtsi  | 28 ++--
 3 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d36ek.dts b/arch/arm/boot/dts/sama5d36ek.dts
index 1c65741..c83b846 100644
--- a/arch/arm/boot/dts/sama5d36ek.dts
+++ b/arch/arm/boot/dts/sama5d36ek.dts
@@ -43,6 +43,14 @@

hlcdc: hlcdc at f003 {
status = "okay";
+
+hlcdc-display-controller {
+dpi {
+   panel at 0 {
+   status = "okay";
+   };
+};
+};
};

macb1: ethernet at f802c000 {
@@ -63,10 +71,6 @@
status = "okay";
};

-   panel: panel {
-   status = "okay";
-   };
-
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index 611ff8a..7c516c3 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -179,10 +179,10 @@
#address-cells = <1>;
#size-cells = <0>;

-   port at 0 {
-   #address-cells = <1>;
+   dpi {
+   compatible = 
"atmel,hlcdc-dpi-host";
#size-cells = <0>;
-   reg = <0>;
+   #address-cells = <1>;
};
};

diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
b/arch/arm/boot/dts/sama5d3xdm.dtsi
index 91975eb..39aba49 100644
--- a/arch/arm/boot/dts/sama5d3xdm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xdm.dtsi
@@ -42,10 +42,13 @@
pinctrl-names = "default";
pinctrl-0 = <_lcd_base 
_lcd_rgb888_alt>;

-   port at 0 {
-   hlcdc_panel_output: endpoint at 
0 {
+   dpi {
+   panel at 0 {
+   compatible = 
"foxlink,fl500wvr00-a0t";
reg = <0>;
-   remote-endpoint = 
<_input>;
+   backlight = 
<>;
+   power-supply = 
<_reg>;
+   status = "disabled";
};
};
};
@@ -77,23 +80,4 @@
power-supply = <_reg>;
status = "disabled";
};
-
-   panel: panel {
-   compatible = "foxlink,fl500wvr00-a0t", "simple-panel";
-   backlight = <>;
-   power-supply = <_reg>;
-   #address-cells = <1>;
-   #size-cells = <0>;
-   status = "disabled";
-
-   port at 0 {
-   #address-cells = <1>;
-   #size-cells = <0>;
-
-   panel_input: endpoint at 0 {
-   reg = <0>;
-   remote-endpoint = <_panel_output>;
-   };
-   };
-   };
 };
-- 
1.9.1



[PATCH v7 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver

2014-10-06 Thread Boris Brezillon
On Mon, 6 Oct 2014 16:26:10 +0200
Thierry Reding  wrote:

> On Mon, Oct 06, 2014 at 03:53:58PM +0200, Boris Brezillon wrote:
> > On Mon, 6 Oct 2014 14:35:06 +0200
> > Thierry Reding  wrote:
> > 
> > > On Mon, Oct 06, 2014 at 02:14:40PM +0200, Boris Brezillon wrote:
> > > > On Mon, 6 Oct 2014 12:54:34 +0200
> > > > Thierry Reding  wrote:
> > > > 
> > > > > On Wed, Oct 01, 2014 at 04:53:03PM +0200, Boris Brezillon wrote:
> > > > > > From: Boris BREZILLON 
> > > > > > 
> > > > > > The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs 
> > > > > > (i.e.
> > > > > > at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
> > > > > > controller device.
> > > > > > 
> > > > > > The HLCDC block provides a single RGB output port, and only 
> > > > > > supports LCD
> > > > > > panels connection to LCD panels for now.
> > > > > > 
> > > > > > The atmel,panel property link the HLCDC RGB output with the LCD 
> > > > > > panel
> > > > > > connected on this port (note that the HLCDC RGB connector 
> > > > > > implementation
> > > > > > makes use of the DRM panel framework).
> > > > > > 
> > > > > > Connection to other external devices (DRM bridges) might be added 
> > > > > > later by
> > > > > > mean of a new atmel,xxx (atmel,bridge) property.
> > > > > > 
> > > > > > Signed-off-by: Boris Brezillon  > > > > > free-electrons.com>
> > > > > > ---
> > > > > >  .../devicetree/bindings/drm/atmel-hlcdc-dc.txt | 53 
> > > > > > ++
> > > > > >  1 file changed, 53 insertions(+)
> > > > > >  create mode 100644 
> > > > > > Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > > > 
> > > > > > diff --git 
> > > > > > a/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt 
> > > > > > b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > > > new file mode 100644
> > > > > > index 000..ebc1a91
> > > > > > --- /dev/null
> > > > > > +++ b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
> > > > > > @@ -0,0 +1,53 @@
> > > > > > +Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM 
> > > > > > driver
> > > > > > +
> > > > > > +The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD 
> > > > > > device.
> > > > > > +See ../mfd/atmel-hlcdc.txt for more details.
> > > > > > +
> > > > > > +Required properties:
> > > > > > + - compatible: value should be "atmel,hlcdc-display-controller"
> > > > > > + - pinctrl-names: the pin control state names. Should contain 
> > > > > > "default".
> > > > > > + - pinctrl-0: should contain the default pinctrl states.
> > > > > > + - #address-cells: should be set to 1.
> > > > > > + - #size-cells: should be set to 0.
> > > > > > +
> > > > > > +Required children nodes:
> > > > > > + Children nodes are encoding available output ports and their 
> > > > > > connections
> > > > > > + to external devices using the OF graph reprensentation (see 
> > > > > > ../graph.txt).
> > > > > > + At least one port node is required.
> > > > > 
> > > > > Are the connections configurable at runtime? Does the SoC have IP 
> > > > > blocks
> > > > > for HDMI or other types of outputs or does it provide only RGB output 
> > > > > to
> > > > > external blocks?
> > > > 
> > > > No, there's only one RGB output port, but you can connect more than one
> > > > device on the RGB port (should we call it DPI port ?).
> > > > Actually Atmel connected an HDMI encoder and an LCD panel connected on
> > > > the same port on their dev kit.
> > > 
> > > This was discussed in some other thread if I remember correctly. I still
> > > think that the HLCDC node should only contain a single output, no matter
> > >

[PATCH v8 1/2] mfd: add atmel-hlcdc driver

2014-10-07 Thread Boris Brezillon
On Tue, 7 Oct 2014 12:38:14 +0100
Lee Jones  wrote:

> On Tue, 07 Oct 2014, Thierry Reding wrote:
> 
> > On Tue, Oct 07, 2014 at 11:17:43AM +0100, Lee Jones wrote:
> > > On Tue, 07 Oct 2014, Thierry Reding wrote:
> > > 
> > > > On Tue, Oct 07, 2014 at 10:59:32AM +0100, Lee Jones wrote:
> > > > > On Tue, 07 Oct 2014, Thierry Reding wrote:
> > > > > 
> > > > > > On Tue, Oct 07, 2014 at 10:44:27AM +0100, Lee Jones wrote:
> > > > > > > On Mon, 06 Oct 2014, Boris Brezillon wrote:
> > > > > > > 
> > > > > > > > The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, 
> > > > > > > > at91sam9x5
> > > > > > > > family or sama5d3 family) exposes 2 subdevices:
> > > > > > > > - a display controller (controlled by a DRM driver)
> > > > > > > > - a PWM chip
> > > > > > > > 
> > > > > > > > The MFD device provides a regmap and several clocks (those 
> > > > > > > > connected
> > > > > > > > to this hardware block) to its subdevices.
> > > > > > > > 
> > > > > > > > This way concurrent accesses to the iomem range are handled by 
> > > > > > > > the regmap
> > > > > > > > framework, and each subdevice can safely access HLCDC registers.
> > > > > > > > 
> > > > > > > > Signed-off-by: Boris Brezillon  > > > > > > > free-electrons.com>
> > > > > > > > Acked-by: Lee Jones 
> > > > > > > > Tested-by: Anthony Harivel 
> > > > > > > > Tested-by: Ludovic Desroches 
> > > > > > > > ---
> > > > > > > >  drivers/mfd/Kconfig |   6 ++
> > > > > > > >  drivers/mfd/Makefile|   1 +
> > > > > > > >  drivers/mfd/atmel-hlcdc.c   | 122 
> > > > > > > > 
> > > > > > > >  include/linux/mfd/atmel-hlcdc.h |  85 
> > > > > > > > 
> > > > > > > >  4 files changed, 214 insertions(+)
> > > > > > > >  create mode 100644 drivers/mfd/atmel-hlcdc.c
> > > > > > > >  create mode 100644 include/linux/mfd/atmel-hlcdc.h
> > > > > > > 
> > > > > > > Applied for v3.19.
> > > > > > 
> > > > > > Will you provide a stable branch that I can pull into the PWM tree?
> > > > > 
> > > > > I hadn't planned on it.  What do you need that for?
> > > > 
> > > > Because the PWM driver depends on this series. But if you prefer you
> > > > could also take the PWM driver through your tree.
> > > 
> > > Probably better to deal with that via Kconfig.
> > 
> > Do you have any suggestions? The PWM driver currently selects the
> > MFD_ATMEL_HLCDC symbol, which as I understand will cause a Kconfig error
> > if the latter isn't defined.
> 
> s/select/depends on/ for the desired effect.
> 

Don't forget the atmel-hlcdc.h header file which is referenced by both
the DRM and the PWM drivers.


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v5 00/11] drm: add support for Atmel HLCDC Display Controller

2014-09-08 Thread Boris BREZILLON
Hello,

This patch series adds support for Atmel HLCDC (HLCD Controller) available
on some Atmel SoCs (i.e. the sama5d3 family).

The HLCDC actually provides a Display Controller and a PWM device, hence I
decided to declare an MFD device exposing 2 subdevices: a display
controller and a PWM chip.
This also solves a circular dependency issue preventing HLCDC driver from
unloading.
The HLCDC request a drm_panel device, which request a backlight device
(a PWM backlight), which depends on a PWM which is provided by the HLCDC
driver (hlcdc -> panel -> backlight -> hlcdc (pwm part)).

The current implementation only supports sama5d3 SoCs but other SoCs should
be easily ported by defining new compatible strings and adding HLCDC
description structures for these SoCs (Ludovic tested this driver on an
at91sam9x5 board).

The drivers supports basic CRTC functionalities, several overlays and an
hardware cursor.

At the moment, it only supports connection to LCD panels through an RGB
connector (defined as an LVDS connector in my implementation), though
connection to other kind of devices (like DRM bridges) could be added later.

It also supports several RGB formats on all planes and some YUV formats on
the HEO overlay plane.

This series depends those series: [1] and [2].

I know you're all quite busy, but I was expecting to get support for
atmel's HLCDC block in 3.18, and given the lack of review I got on the
DRM and PWM parts I doubt it can happen :-(.

Moreover, the dependencies ([1] and [2]) are stuck too.
The first one has been reviewed by Rob, but didn't get any feedback after
that. David, Rob, is there anything blocking this series ?
The second patch series contains some rework I've done to describe the
transfer format used on a connector bus. Laurent, Thierry, you're the one
who suggested this rework. Could you give your opinion on my
implementation ?

Best Regards,

Boris

[1]http://lkml.iu.edu/hypermail/linux/kernel/1407.1/04171.html
[2]http://www.spinics.net/lists/kernel/msg1791681.html

Changes since v4:
- fix a few more bugs in rotation handling (rotation was buggy on some
  formats)
- return connector_status_unknown until a panel is exposed by the
  drm_panel infrastructure (prevent fbdev creation until everyting is
  in place)
- rework Kconfig MFD_ATMEL_HLCDC selection to simplify the configuration
  (automatically select this option when selecting the HLCDC PMW or DRM
  driver, instead of depending on this option)

Changes since v3:
- rework the layer code to simplify several parts (locking and layer
  disabling)
- make use of the drm_flip_work infrastructure
- rely on default HW cursor implementation using on the cursor plane
- rework the display controller DT bindings (based on OF graph
  representation)
- add rotation support
- retrive RGB bus format from drm_display_info
- drop the dynamic pinctrl state selection
- rework HLCDC output handling (previously specialized to interface
  with LCD panels)
- drop ".module = THIS_MODULE" lines
- change display controller compatible string

Changes since v2:
- fix coding style issues (macro indentation)
- make use of GENMASK in several places
- declare regmap config as a static structure
- rework hlcdc plane update API
- rework cursor handling to make use of the new plane update API
- fix backporch config
- do not use devm_regmap_init_mmio_clk to avoid extra clk_enable
  clk disable calls when accessing registers
- explicitely include regmap and clk headers instead of relying on
  atmel-hlcdc.h inclusions
- make the atmel-hlcdc driver depends on CONFIG_OF
- separate DT bindings documentation from driver implementation
- support several pin muxing for HLCDC pins on sama5d3 SoCs

Changes since v1:
- replace the backlight driver by a PWM driver
- make use of drm_panel infrastructure
- split driver code in several subsystem: MFD, PWM and DRM
- add support for overlays
- add support for hardware cursor

Boris BREZILLON (11):
  mfd: add atmel-hlcdc driver
  mfd: add documentation for atmel-hlcdc DT bindings
  pwm: add support for atmel-hlcdc-pwm device
  pwm: add DT bindings documentation for atmel-hlcdc-pwm driver
  drm: add Atmel HLCDC Display Controller support
  drm: add DT bindings documentation for atmel-hlcdc-dc driver
  ARM: AT91/dt: split sama5d3 lcd pin definitions to match RGB mode
configs
  ARM: AT91/dt: add alternative pin muxing for sama5d3 lcd pins
  ARM: at91/dt: define the HLCDC node available on sama5d3 SoCs
  ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi
  ARM: at91/dt: enable the LCD panel on sama5d3xek boards

 .../devicetree/bindings/drm/atmel-hlcdc-dc.txt |  54 ++
 .../devicetree/bindings/mfd/atmel-hlcdc.txt|  50 ++
 .../devicetree/bindings/pwm/atmel-hlcdc-pwm.txt|  55 ++
 arch/arm/boot/dts/sama5d31ek.dts   |  20 +
 arch/arm/boot/dts/sama5d33ek.dts   |  20 +
 arch/arm/boot/dts/sama5d34ek.dts   |  20 +
 arch/arm/boot/dts/sama5d36ek.dts 

[PATCH v5 01/11] mfd: add atmel-hlcdc driver

2014-09-08 Thread Boris BREZILLON
The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

The MFD device provides a regmap and several clocks (those connected
to this hardware block) to its subdevices.

This way concurrent accesses to the iomem range are handled by the regmap
framework, and each subdevice can safely access HLCDC registers.

Signed-off-by: Boris BREZILLON 
Acked-by: Lee Jones 
Tested-by: Ludovic Desroches 
---
 drivers/mfd/Kconfig |   6 ++
 drivers/mfd/Makefile|   1 +
 drivers/mfd/atmel-hlcdc.c   | 118 
 include/linux/mfd/atmel-hlcdc.h |  78 ++
 4 files changed, 203 insertions(+)
 create mode 100644 drivers/mfd/atmel-hlcdc.c
 create mode 100644 include/linux/mfd/atmel-hlcdc.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6cc4b6a..dbd1a16 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,12 @@ config MFD_AAT2870_CORE
  additional drivers must be enabled in order to use the
  functionality of the device.

+config MFD_ATMEL_HLCDC
+   tristate
+   select MFD_CORE
+   select REGMAP_MMIO
+   depends on OF
+
 config MFD_BCM590XX
tristate "Broadcom BCM590xx PMUs"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8afedba..5f25b0d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_MFD_PM8921_CORE)   += pm8921-core.o ssbi.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
+obj-$(CONFIG_MFD_ATMEL_HLCDC)  += atmel-hlcdc.o
 obj-$(CONFIG_MFD_INTEL_MSIC)   += intel_msic.o
 obj-$(CONFIG_MFD_PALMAS)   += palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)+= viperboard.o
diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
new file mode 100644
index 000..aadb371
--- /dev/null
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_HLCDC_REG_MAX(0x4000 - 0x4)
+
+static const struct mfd_cell atmel_hlcdc_cells[] = {
+   {
+   .name = "atmel-hlcdc-pwm",
+   .of_compatible = "atmel,hlcdc-pwm",
+   },
+   {
+   .name = "atmel-hlcdc-dc",
+   .of_compatible = "atmel,hlcdc-display-controller",
+   },
+};
+
+static const struct regmap_config atmel_hlcdc_regmap_config = {
+   .reg_bits = 32,
+   .val_bits = 32,
+   .reg_stride = 4,
+   .max_register = ATMEL_HLCDC_REG_MAX,
+};
+
+static int atmel_hlcdc_probe(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct atmel_hlcdc *hlcdc;
+   struct resource *res;
+   void __iomem *regs;
+
+   hlcdc = devm_kzalloc(dev, sizeof(*hlcdc), GFP_KERNEL);
+   if (!hlcdc)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(regs))
+   return PTR_ERR(regs);
+
+   hlcdc->periph_clk = devm_clk_get(dev, "periph_clk");
+   if (IS_ERR(hlcdc->periph_clk)) {
+   dev_err(dev, "failed to get peripheral clock\n");
+   return PTR_ERR(hlcdc->periph_clk);
+   }
+
+   hlcdc->sys_clk = devm_clk_get(dev, "sys_clk");
+   if (IS_ERR(hlcdc->sys_clk)) {
+   dev_err(dev, "failed to get system clock\n");
+   return PTR_ERR(hlcdc->sys_clk);
+   }
+
+   hlcdc->slow_clk = devm_clk_get(dev, "slow_clk");
+   if (IS_ERR(hlcdc->slow_clk)) {
+   dev_err(dev, "failed to get slow clock\n");
+   return PTR_ERR(hlcdc->slow_clk);
+   }
+
+   hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
+ _hlcdc_regmap_config);
+   if (IS_ERR(hlcdc->regmap))
+   return PTR_ERR(hlcdc->regmap);
+
+ 

[PATCH v5 03/11] pwm: add support for atmel-hlcdc-pwm device

2014-09-08 Thread Boris BREZILLON
The HLCDC IP available in some Atmel SoCs (i.e. sam9x5i.e. at91sam9n12,
at91sam9x5 family or sama5d3 family) provide a PWM device.

This driver add support for a PWM chip exposing a single PWM device (which
will most likely be used to drive a backlight device).

Signed-off-by: Boris BREZILLON 
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-atmel-hlcdc.c | 229 ++
 3 files changed, 240 insertions(+)
 create mode 100644 drivers/pwm/pwm-atmel-hlcdc.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 4ad7b89..ad1f362 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -50,6 +50,16 @@ config PWM_ATMEL
  To compile this driver as a module, choose M here: the module
  will be called pwm-atmel.

+config PWM_ATMEL_HLCDC_PWM
+   tristate "Atmel HLCDC PWM support"
+   select MFD_ATMEL_HLCDC
+   depends on OF
+   help
+ Generic PWM framework driver for Atmel HLCDC PWM.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-atmel.
+
 config PWM_ATMEL_TCB
tristate "Atmel TC Block PWM support"
depends on ATMEL_TCLIB && OF
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 5c86a19..26ae965 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_PWM)   += core.o
 obj-$(CONFIG_PWM_SYSFS)+= sysfs.o
 obj-$(CONFIG_PWM_AB8500)   += pwm-ab8500.o
 obj-$(CONFIG_PWM_ATMEL)+= pwm-atmel.o
+obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)  += pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)+= pwm-atmel-tcb.o
 obj-$(CONFIG_PWM_BCM_KONA) += pwm-bcm-kona.o
 obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
new file mode 100644
index 000..0238f7a
--- /dev/null
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ * Copyright (C) 2014 Atmel
+ *
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ATMEL_HLCDC_PWMCVAL_MASK   GENMASK(15, 8)
+#define ATMEL_HLCDC_PWMCVAL(x) ((x << 8) & ATMEL_HLCDC_PWMCVAL_MASK)
+#define ATMEL_HLCDC_PWMPOL BIT(4)
+#define ATMEL_HLCDC_PWMPS_MASK GENMASK(2, 0)
+#define ATMEL_HLCDC_PWMPS_MAX  0x6
+#define ATMEL_HLCDC_PWMPS(x)   ((x) & ATMEL_HLCDC_PWMPS_MASK)
+
+struct atmel_hlcdc_pwm_chip {
+   struct pwm_chip chip;
+   struct atmel_hlcdc *hlcdc;
+   struct clk *cur_clk;
+};
+
+static inline struct atmel_hlcdc_pwm_chip *
+pwm_chip_to_atmel_hlcdc_pwm_chip(struct pwm_chip *chip)
+{
+   return container_of(chip, struct atmel_hlcdc_pwm_chip, chip);
+}
+
+static int atmel_hlcdc_pwm_config(struct pwm_chip *c,
+ struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   struct atmel_hlcdc_pwm_chip *chip =
+   pwm_chip_to_atmel_hlcdc_pwm_chip(c);
+   struct atmel_hlcdc *hlcdc = chip->hlcdc;
+   struct clk *new_clk = hlcdc->slow_clk;
+   u64 pwmcval = duty_ns * 256;
+   unsigned long clk_freq;
+   u64 clk_period_ns;
+   u32 pwmcfg;
+   int pres;
+
+   clk_freq = clk_get_rate(new_clk);
+   clk_period_ns = 10;
+   clk_period_ns *= 256;
+   do_div(clk_period_ns, clk_freq);
+
+   if (clk_period_ns > period_ns) {
+   new_clk = hlcdc->sys_clk;
+   clk_freq = clk_get_rate(new_clk);
+   clk_period_ns = 10;
+   clk_period_ns *= 256;
+   do_div(clk_period_ns, clk_freq);
+   }
+
+   for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
+   if ((clk_period_ns << pres) >= period_ns)
+   break;
+   }
+
+   if (pres > ATMEL_HLCDC_PWMPS_MAX)
+   return -EINVAL;
+
+   pwmcfg = ATMEL_HLCDC_PWMPS(pres);
+
+   if (new_clk != chip->cur_clk) {
+   u32 gencfg = 0;
+
+   clk_prepare_enable(new_clk);
+   clk_disable_unprepare(chip->cur_clk);
+   chip->cur_clk = new_clk;
+
+   if

[PATCH v5 02/11] mfd: add documentation for atmel-hlcdc DT bindings

2014-09-08 Thread Boris BREZILLON
The HLCDC IP available on some Atmel SoCs (i.e. at91sam9n12, at91sam9x5
family or sama5d3 family) exposes 2 subdevices:
- a display controller (controlled by a DRM driver)
- a PWM chip

This patch adds documentation for atmel-hlcdc DT bindings.

Signed-off-by: Boris BREZILLON 
---
 .../devicetree/bindings/mfd/atmel-hlcdc.txt| 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt

diff --git a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt 
b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
new file mode 100644
index 000..e9cc1b2
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
@@ -0,0 +1,50 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) MFD driver
+
+Required properties:
+ - compatible: value should be one of the following:
+   "atmel,sama5d3-hlcdc"
+ - reg: base address and size of the HLCDC device registers.
+ - clock-names: the name of the 3 clocks requested by the HLCDC device.
+   Should contain "periph_clk", "sys_clk" and "slow_clk".
+ - clocks: should contain the 3 clocks requested by the HLCDC device.
+
+The HLCDC IP exposes two subdevices:
+ - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt
+ - a Display Controller: see ../drm/atmel-hlcdc-dc.txt
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v5 04/11] pwm: add DT bindings documentation for atmel-hlcdc-pwm driver

2014-09-08 Thread Boris BREZILLON
The HLCDC IP available in some Atmel SoCs (i.e. sam9x5i.e. at91sam9n12,
at91sam9x5 family or sama5d3 family) provide a PWM device.

The DT bindings used for this PWM device is following the default 3 cells
bindings described in Documentation/devicetree/bindings/pwm/pwm.txt.

Signed-off-by: Boris BREZILLON 
---
 .../devicetree/bindings/pwm/atmel-hlcdc-pwm.txt| 55 ++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt

diff --git a/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt 
b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
new file mode 100644
index 000..86ad3e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/atmel-hlcdc-pwm.txt
@@ -0,0 +1,55 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) PWM driver
+
+The Atmel HLCDC PWM is subdevice of the HLCDC MFD device.
+See ../mfd/atmel-hlcdc.txt for more details.
+
+Required properties:
+ - compatible: value should be one of the following:
+   "atmel,hlcdc-pwm"
+ - pinctr-names: the pin control state names. Should contain "default".
+ - pinctrl-0: should contain the pinctrl states described by pinctrl
+   default.
+ - #pwm-cells: should be set to 3. This PWM chip use the default 3 cells
+   bindings defined in Documentation/devicetree/bindings/pwm/pwm.txt.
+   The first cell encodes the PWM id (0 is the only acceptable value here,
+   because the chip only provide one PWM).
+   The second cell encodes the PWM period in nanoseconds.
+   The third cell encodes the PWM flags (the only supported flag is
+   PWM_POLARITY_INVERTED)
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v5 05/11] drm: add Atmel HLCDC Display Controller support

2014-09-08 Thread Boris BREZILLON
The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
controller device.

This display controller supports at least one primary plane and might
provide several overlays and an hardware cursor depending on the IP
version.

At the moment, this driver only implements an RGB connector to interface
with LCD panels, but support for other kind of external devices might be
added later.

Signed-off-by: Boris BREZILLON 
Tested-by: Ludovic Desroches 
---
 drivers/gpu/drm/Kconfig  |   2 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/atmel-hlcdc/Kconfig  |  13 +
 drivers/gpu/drm/atmel-hlcdc/Makefile |   7 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c   | 286 
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 488 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 224 ++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c  | 656 ++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h  | 403 +++
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 476 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c  | 836 +++
 11 files changed, 3392 insertions(+)
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/Kconfig
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/Makefile
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
 create mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f512004..9183a78 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -184,6 +184,8 @@ source "drivers/gpu/drm/cirrus/Kconfig"

 source "drivers/gpu/drm/armada/Kconfig"

+source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
+
 source "drivers/gpu/drm/rcar-du/Kconfig"

 source "drivers/gpu/drm/shmobile/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index af9a609..07d388c 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_ARMADA) += armada/
+obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc/
 obj-$(CONFIG_DRM_RCAR_DU) += rcar-du/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
 obj-$(CONFIG_DRM_OMAP) += omapdrm/
diff --git a/drivers/gpu/drm/atmel-hlcdc/Kconfig 
b/drivers/gpu/drm/atmel-hlcdc/Kconfig
new file mode 100644
index 000..6d0d785
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/Kconfig
@@ -0,0 +1,13 @@
+config DRM_ATMEL_HLCDC
+   tristate "DRM Support for ATMEL HLCDC Display Controller"
+   depends on DRM && OF && MFD_ATMEL_HLCDC && COMMON_CLK
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DRM_PANEL
+   select MFD_ATMEL_HLCDC
+   depends on OF
+   help
+ Choose this option if you have an ATMEL SoC with an HLCDC display
+ controller (i.e. at91sam9n12, at91sam9x5 family or sama5d3 family).
diff --git a/drivers/gpu/drm/atmel-hlcdc/Makefile 
b/drivers/gpu/drm/atmel-hlcdc/Makefile
new file mode 100644
index 000..10ae426
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/Makefile
@@ -0,0 +1,7 @@
+atmel-hlcdc-dc-y := atmel_hlcdc_crtc.o \
+   atmel_hlcdc_dc.o \
+   atmel_hlcdc_layer.o \
+   atmel_hlcdc_output.o \
+   atmel_hlcdc_plane.o
+
+obj-$(CONFIG_DRM_ATMEL_HLCDC)  += atmel-hlcdc-dc.o
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
new file mode 100644
index 000..2186830
--- /dev/null
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2014 Traphandler
+ * Copyright (C) 2014 Free Electrons
+ *
+ * Author: Jean-Jacques Hiblot 
+ * Author: Boris BREZILLON 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/&g

[PATCH v5 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver

2014-09-08 Thread Boris BREZILLON
The Atmel HLCDC (HLCD Controller) IP available on some Atmel SoCs (i.e.
at91sam9n12, at91sam9x5 family or sama5d3 family) provides a display
controller device.

The HLCDC block provides a single RGB output port, and only supports LCD
panels connection to LCD panels for now.

The atmel,panel property link the HLCDC RGB output with the LCD panel
connected on this port (note that the HLCDC RGB connector implementation
makes use of the DRM panel framework).

Connection to other external devices (DRM bridges) might be added later by
mean of a new atmel,xxx (atmel,bridge) property.

Signed-off-by: Boris BREZILLON 
---
 .../devicetree/bindings/drm/atmel-hlcdc-dc.txt | 54 ++
 1 file changed, 54 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt

diff --git a/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt 
b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
new file mode 100644
index 000..73b9860
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/atmel-hlcdc-dc.txt
@@ -0,0 +1,54 @@
+Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver
+
+The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD device.
+See ../mfd/atmel-hlcdc.txt for more details.
+
+Required properties:
+ - compatible: value should be "atmel,hlcdc-display-controller"
+ - interrupts: the HLCDC interrupt definition
+ - pinctrl-names: the pin control state names. Should contain "default".
+ - pinctrl-0: should contain the default pinctrl states.
+ - #address-cells: should be set to 1.
+ - #size-cells: should be set to 0.
+
+Required children nodes:
+ Children nodes are encoding available output ports and their connections
+ to external devices using the OF graph reprensentation (see ../graph.txt).
+ At least one port node is required.
+
+Example:
+
+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", "slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = "atmel,hlcdc-display-controller";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base _lcd_rgb888>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   hlcdc_panel_output: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_input>;
+   };
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
-- 
1.9.1



[PATCH v5 07/11] ARM: AT91/dt: split sama5d3 lcd pin definitions to match RGB mode configs

2014-09-08 Thread Boris BREZILLON
The HLCDC (HLCD Controller) IP supports 4 different output mode (RGB444,
RGB565, RGB666 and RGB888) and the pin muxing will depend on the chosen
RGB mode.

Split pin definitions to be able to set pin config according to the
selected mode.

Signed-off-by: Boris BREZILLON 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 127 -
 1 file changed, 96 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index 85d3027..2186b89 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -15,38 +15,103 @@
apb {
pinctrl at f200 {
lcd {
-   pinctrl_lcd: lcd-0 {
+   pinctrl_lcd_pwm: lcd-pwm-0 {
+   atmel,pins = ;/* LCDPWM */
+   };
+
+   pinctrl_lcd_base: lcd-base-0 {
+   atmel,pins =
+   ; /* LCDPCK */
+   };
+
+   pinctrl_lcd_rgb444: lcd-rgb-0 {
+   atmel,pins =
+   ; /* LCDD11 pin */
+   };
+
+   pinctrl_lcd_rgb565: lcd-rgb-1 {
+   atmel,pins =
+   ; /* LCDD15 pin */
+   };
+
+   pinctrl_lcd_rgb666: lcd-rgb-2 {
+   atmel,pins =
+   ; /* LCDD17 pin */
+   };
+
+   pinctrl_lcd_rgb888: lcd-rgb-3 {
atmel,pins =
-   ; /* PE28 periph C LCDD23 pin */
+   ; /* LCDD23 pin */
};
};
};
-- 
1.9.1



[PATCH v5 08/11] ARM: AT91/dt: add alternative pin muxing for sama5d3 lcd pins

2014-09-08 Thread Boris BREZILLON
Define alternative pin muxing for the LCDC pins.

Signed-off-by: Boris BREZILLON 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index 2186b89..e7581f6 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -82,6 +82,28 @@
 AT91_PIOA 13 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD13 pin */
 AT91_PIOA 14 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD14 pin */
 AT91_PIOA 15 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD15 pin */
+AT91_PIOA 16 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD16 pin */
+AT91_PIOA 17 
AT91_PERIPH_A AT91_PINCTRL_NONE>; /* LCDD17 pin */
+   };
+
+   pinctrl_lcd_rgb666_alt: lcd-rgb-2-alt {
+   atmel,pins =
+   ; /* LCDD17 pin */
};
@@ -104,6 +126,34 @@
 AT91_PIOA 13 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD13 pin */
 AT91_PIOA 14 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD14 pin */
 AT91_PIOA 15 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD15 pin */
+AT91_PIOA 16 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD16 pin */
+AT91_PIOA 17 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD17 pin */
+AT91_PIOA 18 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD18 pin */
+AT91_PIOA 19 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD19 pin */
+AT91_PIOA 20 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD20 pin */
+AT91_PIOA 21 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD21 pin */
+AT91_PIOA 22 
AT91_PERIPH_A AT91_PINCTRL_NONE   /* LCDD22 pin */
+AT91_PIOA 23 
AT91_PERIPH_A AT91_PINCTRL_NONE>; /* LCDD23 pin */
+   };
+
+   pinctrl_lcd_rgb888_alt: lcd-rgb-3-alt {
+   atmel,pins =
+   

[PATCH v5 09/11] ARM: at91/dt: define the HLCDC node available on sama5d3 SoCs

2014-09-08 Thread Boris BREZILLON
Define the HLCDC (HLCD Controller) IP available on some sama5d3 SoCs
(i.e. sama5d31, sama5d33, sama5d34 and sama5d36) in sama5d3 dtsi file.

Signed-off-by: Boris BREZILLON 
---
 arch/arm/boot/dts/sama5d3_lcd.dtsi | 28 
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3_lcd.dtsi 
b/arch/arm/boot/dts/sama5d3_lcd.dtsi
index e7581f6..1874cf7 100644
--- a/arch/arm/boot/dts/sama5d3_lcd.dtsi
+++ b/arch/arm/boot/dts/sama5d3_lcd.dtsi
@@ -166,6 +166,34 @@
};
};

+   hlcdc: hlcdc at f003 {
+   compatible = "atmel,sama5d3-hlcdc";
+   reg = <0xf003 0x2000>;
+   clocks = <_clk>, <>, <>;
+   clock-names = "periph_clk","sys_clk", 
"slow_clk";
+   status = "disabled";
+
+   hlcdc-display-controller {
+   compatible = 
"atmel,hlcdc-display-controller";
+   interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+   };
+   };
+
+   hlcdc_pwm: hlcdc-pwm {
+   compatible = "atmel,hlcdc-pwm";
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_pwm>;
+   #pwm-cells = <3>;
+   };
+   };
+
pmc: pmc at fc00 {
periphck {
lcdc_clk: lcdc_clk {
-- 
1.9.1



[PATCH v5 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi

2014-09-08 Thread Boris BREZILLON
Add LCD panel related nodes (backlight, regulators and panel) to sama5d3
Display Module dtsi.

Reference LCD pin muxing used by sama5d3xek boards.

Signed-off-by: Boris BREZILLON 
---
 arch/arm/boot/dts/sama5d3xdm.dtsi | 58 +++
 1 file changed, 58 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xdm.dtsi 
b/arch/arm/boot/dts/sama5d3xdm.dtsi
index 035ab72..91975eb 100644
--- a/arch/arm/boot/dts/sama5d3xdm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xdm.dtsi
@@ -36,6 +36,64 @@
};
};
};
+
+   hlcdc: hlcdc at f003 {
+   hlcdc-display-controller {
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcd_base 
_lcd_rgb888_alt>;
+
+   port at 0 {
+   hlcdc_panel_output: endpoint at 
0 {
+   reg = <0>;
+   remote-endpoint = 
<_input>;
+   };
+   };
+   };
+   };
+   };
+   };
+
+   bl_reg: backlight_regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "backlight-power-supply";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   status = "disabled";
+   };
+
+   panel_reg: panel_regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "panel-power-supply";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   status = "disabled";
+   };
+
+   backlight: backlight {
+   compatible = "pwm-backlight";
+   pwms = <_pwm 0 5 0>;
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <6>;
+   power-supply = <_reg>;
+   status = "disabled";
+   };
+
+   panel: panel {
+   compatible = "foxlink,fl500wvr00-a0t", "simple-panel";
+   backlight = <>;
+   power-supply = <_reg>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+
+   port at 0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   panel_input: endpoint at 0 {
+   reg = <0>;
+   remote-endpoint = <_panel_output>;
+   };
};
};
 };
-- 
1.9.1



[PATCH v5 11/11] ARM: at91/dt: enable the LCD panel on sama5d3xek boards

2014-09-08 Thread Boris BREZILLON
Enable LCD related nodes.

Signed-off-by: Boris BREZILLON 
---
 arch/arm/boot/dts/sama5d31ek.dts | 20 
 arch/arm/boot/dts/sama5d33ek.dts | 20 
 arch/arm/boot/dts/sama5d34ek.dts | 20 
 arch/arm/boot/dts/sama5d36ek.dts | 20 
 4 files changed, 80 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d31ek.dts b/arch/arm/boot/dts/sama5d31ek.dts
index 04eec0d..6e605fe 100644
--- a/arch/arm/boot/dts/sama5d31ek.dts
+++ b/arch/arm/boot/dts/sama5d31ek.dts
@@ -33,6 +33,10 @@
status = "okay";
};

+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
+
macb1: ethernet at f802c000 {
status = "okay";
};
@@ -46,6 +50,22 @@
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d33ek.dts b/arch/arm/boot/dts/sama5d33ek.dts
index cbd6a3f..0400641 100644
--- a/arch/arm/boot/dts/sama5d33ek.dts
+++ b/arch/arm/boot/dts/sama5d33ek.dts
@@ -36,9 +36,29 @@
macb0: ethernet at f0028000 {
status = "okay";
};
+
+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d34ek.dts b/arch/arm/boot/dts/sama5d34ek.dts
index 878aa16..9cf473e 100644
--- a/arch/arm/boot/dts/sama5d34ek.dts
+++ b/arch/arm/boot/dts/sama5d34ek.dts
@@ -46,6 +46,10 @@
macb0: ethernet at f0028000 {
status = "okay";
};
+
+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
};
};

@@ -56,6 +60,22 @@
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
diff --git a/arch/arm/boot/dts/sama5d36ek.dts b/arch/arm/boot/dts/sama5d36ek.dts
index 59576c6..1c65741 100644
--- a/arch/arm/boot/dts/sama5d36ek.dts
+++ b/arch/arm/boot/dts/sama5d36ek.dts
@@ -41,12 +41,32 @@
status = "okay";
};

+   hlcdc: hlcdc at f003 {
+   status = "okay";
+   };
+
macb1: ethernet at f802c000 {
status = "okay";
};
};
};

+   bl_reg: backlight_regulator {
+   status = "okay";
+   };
+
+   panel_reg: panel_regulator {
+   status = "okay";
+   };
+
+   backlight: backlight {
+   status = "okay";
+   };
+
+   panel: panel {
+   status = "okay";
+   };
+
sound {
status = "okay";
};
-- 
1.9.1



[RFC 1/3] atmel: drm: added drm driver for the atmel hlcd controller

2014-04-18 Thread Boris BREZILLON
struct atmel_hlcdc_drm_private *priv = dev->dev_private;
> + int dpms = atmel_hlcdc_crtc->dpms;
> + int hbp, hfp, hsw, vbp, vfp, vsw;
> + unsigned int depth, bpp;
> + unsigned long value;
> + int ret;
> +
> + ret = atmel_hlcdc_crtc_mode_valid(crtc, mode);
> + if (WARN_ON(ret))
> + return ret;
> +
> + pm_runtime_get_sync(dev->dev);
> +
> + if (dpms == DRM_MODE_DPMS_ON)
> + atmel_hlcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
> +
> + dev_dbg(dev->dev, "%s:\n", __func__);
> +
> +
> + /* Set pixel clock */
> + atmel_hlcdc_crtc_update_clk(crtc, mode->clock);
> +
> + /* Initialize control register 5 */
> + value = priv->default_lcdcfg5;
> + value |= (priv->guard_time << LCDC_LCDCFG5_GUARDTIME_OFFSET)
> + | LCDC_LCDCFG5_DISPDLY
> + | LCDC_LCDCFG5_VSPDLYS;
> +
> + if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC)
> + value |= LCDC_LCDCFG5_HSPOL;
> +
> + if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC)
> + value |= LCDC_LCDCFG5_VSPOL;
> +
> + dev_dbg(dev->dev, "  * LCDC_LCDCFG5 = %08lx\n", value);
> + hlcdc_write(dev, ATMEL_LCDC_LCDCFG5, value);
> +
> +
> + /* Configure timings: */
> + hbp = MAX(mode->htotal - mode->hsync_end, 1);
> + hfp = MAX(mode->hsync_start - mode->hdisplay, 1);
> + hsw = MAX(mode->hsync_end - mode->hsync_start, 1);
> + vbp = MAX(mode->vtotal - mode->vsync_end, 0);
> + vfp = MAX(mode->vsync_start - mode->vdisplay, 1);
> + vsw = MAX(mode->vsync_end - mode->vsync_start, 1);
> +
> + DBG("%dx%d, hbp=%u, hfp=%u, hsw=%u, vbp=%u, vfp=%u, vsw=%u",
> + mode->hdisplay, mode->vdisplay, hbp, hfp, hsw, vbp, vfp, vsw);
> +
> + /* Vertical & Horizontal Timing */
> + value = (vsw - 1) << LCDC_LCDCFG1_VSPW_OFFSET;
> + value |= (hsw - 1) << LCDC_LCDCFG1_HSPW_OFFSET;
> + dev_dbg(dev->dev, "  * LCDC_LCDCFG1 = %08lx\n", value);
> +     hlcdc_write(dev, ATMEL_LCDC_LCDCFG1, value);
> +
> + value = (vbp) << LCDC_LCDCFG2_VBPW_OFFSET;
> + value |= (vfp - 1) << LCDC_LCDCFG2_VFPW_OFFSET;
> + dev_dbg(dev->dev, "  * LCDC_LCDCFG2 = %08lx\n", value);
> + hlcdc_write(dev, ATMEL_LCDC_LCDCFG2, value);
> +
> + value = (hbp - 1) << LCDC_LCDCFG3_HBPW_OFFSET;
> + value |= (hfp - 1) << LCDC_LCDCFG3_HFPW_OFFSET;
> + dev_dbg(dev->dev, "  * LCDC_LCDCFG3 = %08lx\n", value);
> + hlcdc_write(dev, ATMEL_LCDC_LCDCFG3, value);
> +
> + /* Display size */
> + value = (mode->vdisplay - 1) << LCDC_LCDCFG4_RPF_OFFSET;
> + value |= (mode->hdisplay - 1) << LCDC_LCDCFG4_PPL_OFFSET;
> + dev_dbg(dev->dev, "  * LCDC_LCDCFG4 = %08lx\n", value);
> + hlcdc_write(dev, ATMEL_LCDC_LCDCFG4, value);
> +
> + hlcdc_write(dev, ATMEL_LCDC_BASECFG0,
> + LCDC_BASECFG0_BLEN_AHB_INCR16 | LCDC_BASECFG0_DLBO);
> +
> + drm_fb_get_bpp_depth(crtc->fb->pixel_format, , );
ditto
> + hlcdc_write(dev, ATMEL_LCDC_BASECFG1,
> + atmel_hlcdfb_get_rgbmode(dev->dev, depth, bpp));
> + hlcdc_write(dev, ATMEL_LCDC_BASECFG2, 0);
> + hlcdc_write(dev, ATMEL_LCDC_BASECFG3, 0);   /* Default color */
> + hlcdc_write(dev, ATMEL_LCDC_BASECFG4, LCDC_BASECFG4_DMA);
> +
>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com



[RFC 0/3] DRM driver for the ATMEL High end LCD controller

2014-04-18 Thread Boris BREZILLON
Hi JJ,

On 18/04/2014 11:45, Jean-Jacques Hiblot wrote:
> Hi,
>
> this patch serie implements a simple DRM driver for the ATMEL High end LCD
> controller found in the SAMA5 familly. It's based on the tilcdc driver.
> It uses the cma_helper for memory and fbdev stuff.
> Your comments are welcome !

Thanks for you work.

As I already told you, I started to work on a DRM/KMS driver for the
hlcdc too, and I'd be pleased to help you on this driver (either by
adding the missing stuff, debugging or reworking some parts).

Regarding the code itself, I only had a quick look, but I'll try to
review it next week. Anyway, I might not be the best person to give
advice on a DRM/KMS driver :-).

BTW, I tried to boot a kernel with your driver (statically compiled),
and it hangs (see http://pastebin.com/H24KpVHb). But I didn't have time
for further debugging.

Best Regards,

Boris
>
>
> Supported features:
> * the base layer (the main framebuffer)
> * a simple panel
> * a backlight driver
> * structure to 'easily' add other connectors (it comes from the tilcdc)
>
> On the todo list:
> * support overlays as drm_planes
> * support for the hardware cursor
> * support for the SiI9022 HDMI connector (present on sama5d36ek)
>
>
> Jean-Jacques Hiblot (3):
>   atmel: drm: added drm driver for the atmel hlcd controller
>   atmel: drm: dt: Added DT entry for the atmel hlcdc found in the sama5
>   atmel: dt: Add supports for the lcdc support on the sama5d36ek
>
>  arch/arm/boot/dts/sama5d36ek.dts   |  27 +-
>  arch/arm/boot/dts/sama5d3_lcd.dtsi |  11 +
>  drivers/gpu/drm/Kconfig|   2 +
>  drivers/gpu/drm/Makefile   |   1 +
>  drivers/gpu/drm/atmel_hlcdc/Kconfig|  13 +
>  drivers/gpu/drm/atmel_hlcdc/Makefile   |  12 +
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc.h  | 771 
> +
>  .../gpu/drm/atmel_hlcdc/atmel_hlcdc_backlight.c|  92 +++
>  .../gpu/drm/atmel_hlcdc/atmel_hlcdc_backlight.h|  25 +
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_crtc.c | 702 +++
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_drv.c  | 586 
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_drv.h  | 124 
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_ovl.h  | 190 +
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_panel.c| 459 
>  drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_panel.h|  28 +
>  15 files changed, 3042 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/Kconfig
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/Makefile
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc.h
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_backlight.c
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_backlight.h
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_crtc.c
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_drv.c
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_drv.h
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_ovl.h
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_panel.c
>  create mode 100644 drivers/gpu/drm/atmel_hlcdc/atmel_hlcdc_panel.h
>
> --
> 1.9.1
>

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com



[PATCH] drm: do not use device name as a format string

2015-12-07 Thread Boris Brezillon
On Wed, 18 Nov 2015 18:58:18 +0100
Nicolas Iooss  wrote:

> drm_dev_set_unique() formats its parameter using kvasprintf() but many
> of its callers directly pass dev_name(dev) as printf format string,
> without any format parameter.  This can cause some issues when the
> device name contains '%' characters.
> 
> To avoid any potential issue, always use "%s" when using
> drm_dev_set_unique() with dev_name().
> 
> Signed-off-by: Nicolas Iooss 

I'll let Daniel decide whether it's relevant or not to add a new
function/macro to hide this, but I'm fine with the current patch.

[for the atmel-hlcdc driver]
Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c| 2 +-
>  drivers/gpu/drm/tegra/drm.c  | 2 +-
>  drivers/gpu/drm/vc4/vc4_drv.c| 2 +-
>  include/drm/drmP.h   | 1 +
>  5 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 244df0a440b7..0d720d3a7ee0 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -733,7 +733,7 @@ static int atmel_hlcdc_dc_drm_probe(struct 
> platform_device *pdev)
>   if (!ddev)
>   return -ENOMEM;
>  
> - ret = drm_dev_set_unique(ddev, dev_name(ddev->dev));
> + ret = drm_dev_set_unique(ddev, "%s", dev_name(ddev->dev));
>   if (ret)
>   goto err_unref;
>  
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
> b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index 1930234ba5f1..947d75f59881 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -363,7 +363,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
>   fsl_dev->np = dev->of_node;
>   drm->dev_private = fsl_dev;
>   dev_set_drvdata(dev, fsl_dev);
> - drm_dev_set_unique(drm, dev_name(dev));
> + drm_dev_set_unique(drm, "%s", dev_name(dev));
>  
>   ret = drm_dev_register(drm, 0);
>   if (ret < 0)
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 159ef515cab1..b278f60f4376 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -991,7 +991,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
>   if (!drm)
>   return -ENOMEM;
>  
> - drm_dev_set_unique(drm, dev_name(>dev));
> + drm_dev_set_unique(drm, "%s", dev_name(>dev));
>   dev_set_drvdata(>dev, drm);
>  
>   err = drm_dev_register(drm, 0);
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
> index 6e730605edcc..c90a451aaa79 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.c
> +++ b/drivers/gpu/drm/vc4/vc4_drv.c
> @@ -168,7 +168,7 @@ static int vc4_drm_bind(struct device *dev)
>   vc4->dev = drm;
>   drm->dev_private = vc4;
>  
> - drm_dev_set_unique(drm, dev_name(dev));
> + drm_dev_set_unique(drm, "%s", dev_name(dev));
>  
>   drm_mode_config_init(drm);
>   if (ret)
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 0b921ae06cd8..995fb96cb740 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1049,6 +1049,7 @@ void drm_dev_ref(struct drm_device *dev);
>  void drm_dev_unref(struct drm_device *dev);
>  int drm_dev_register(struct drm_device *dev, unsigned long flags);
>  void drm_dev_unregister(struct drm_device *dev);
> +__printf(2, 3)
>  int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...);
>  
>  struct drm_minor *drm_minor_acquire(unsigned int minor_id);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH 2/2] drm: use dev_name as default unique name in drm_dev_alloc()

2015-12-09 Thread Boris Brezillon
On Tue,  8 Dec 2015 23:12:12 +0100
Nicolas Iooss  wrote:

> The following code pattern exists in some DRM drivers:
> 
> ddev = drm_dev_alloc(, parent_dev);
> drm_dev_set_unique(ddev, dev_name(parent_dev));
> 
> (Sometimes dev_name(ddev->dev) is used, which is the same.)
> 
> As suggested in
> http://lists.freedesktop.org/archives/dri-devel/2015-December/096441.html,
> the unique name of a new DRM device can be set as dev_name(parent_dev)
> when parent_dev is not NULL (vgem is a special case).
> 
> Signed-off-by: Nicolas Iooss 

[for atmel-hlcdc]
Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 4 
>  drivers/gpu/drm/drm_drv.c| 9 +
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c| 1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c| 4 
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c  | 4 
>  drivers/gpu/drm/tegra/drm.c  | 1 -
>  drivers/gpu/drm/vc4/vc4_drv.c| 2 --
>  7 files changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 244df0a440b7..fba4f72e7ae1 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -733,10 +733,6 @@ static int atmel_hlcdc_dc_drm_probe(struct 
> platform_device *pdev)
>   if (!ddev)
>   return -ENOMEM;
>  
> - ret = drm_dev_set_unique(ddev, dev_name(ddev->dev));
> - if (ret)
> - goto err_unref;
> -
>   ret = atmel_hlcdc_dc_load(ddev);
>   if (ret)
>   goto err_unref;
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 20eaa0aae205..df749a6156e0 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -633,8 +633,17 @@ struct drm_device *drm_dev_alloc(struct drm_driver 
> *driver,
>   }
>   }
>  
> + if (parent) {
> + ret = drm_dev_set_unique(dev, dev_name(parent));
> + if (ret)
> + goto err_setunique;
> + }
> +
>   return dev;
>  
> +err_setunique:
> + if (drm_core_check_feature(dev, DRIVER_GEM))
> + drm_gem_destroy(dev);
>  err_ctxbitmap:
>   drm_legacy_ctxbitmap_cleanup(dev);
>   drm_ht_remove(>map_hash);
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
> b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index 1930234ba5f1..fca97d3fc846 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -363,7 +363,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
>   fsl_dev->np = dev->of_node;
>   drm->dev_private = fsl_dev;
>   dev_set_drvdata(dev, fsl_dev);
> - drm_dev_set_unique(drm, dev_name(dev));
>  
>   ret = drm_dev_register(drm, 0);
>   if (ret < 0)
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
> b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 2d23f95f17ce..b3a563c44bcd 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1046,10 +1046,6 @@ nouveau_platform_device_create(const struct 
> nvkm_device_tegra_func *func,
>   goto err_free;
>   }
>  
> - err = drm_dev_set_unique(drm, dev_name(>dev));
> - if (err < 0)
> - goto err_free;
> -
>   drm->platformdev = pdev;
>   platform_set_drvdata(pdev, drm);
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
> b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 215d6c44af55..afbb7407c44f 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -450,10 +450,6 @@ static int rockchip_drm_bind(struct device *dev)
>   if (!drm)
>   return -ENOMEM;
>  
> - ret = drm_dev_set_unique(drm, dev_name(dev));
> - if (ret)
> - goto err_free;
> -
>   ret = drm_dev_register(drm, 0);
>   if (ret)
>   goto err_free;
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 159ef515cab1..12e2d3ccbc9d 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -991,7 +991,6 @@ static int host1x_drm_probe(struct host1x_device *dev)
>   if (!drm)
>   return -ENOMEM;
>  
> - drm_dev_set_unique(drm, dev_name(>dev));
>   dev_set_drvdata(>dev, drm);
>  
>   err = drm_dev_register(drm, 0);
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
> index d5db9e0f3b73..64

[RESEND PATCH 2/3] drm: atmel-hlcdc: add support for sama5d2 SoCs

2015-12-15 Thread Boris Brezillon
From: Nicolas Ferre <nicolas.fe...@atmel.com>

As the hardware description for this chip is the same as the sama5d4, we use
this SoC structures for layers and DC descriptions. Thus only 2 lines are added
to the atmel_hlcdc_of_match table.
The compatible string is already documented in the parent MFD driver's binding.

Signed-off-by: Nicolas Ferre 
Acked-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 0126918..44e670b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -333,6 +333,10 @@ static const struct of_device_id atmel_hlcdc_of_match[] = {
.data = _hlcdc_dc_at91sam9x5,
},
{
+   .compatible = "atmel,sama5d2-hlcdc",
+   .data = _hlcdc_dc_sama5d4,
+   },
+   {
.compatible = "atmel,sama5d3-hlcdc",
.data = _hlcdc_dc_sama5d3,
},
-- 
2.1.4



[RESEND PATCH 1/3] drm: atmel-hlcdc: Fix module autoload for OF platform driver

2015-12-15 Thread Boris Brezillon
From: Luis de Bethencourt <l...@debethencourt.com>

This platform driver has a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Luis de Bethencourt 
Acked-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 244df0a..0126918 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -342,6 +342,7 @@ static const struct of_device_id atmel_hlcdc_of_match[] = {
},
{ /* sentinel */ },
 };
+MODULE_DEVICE_TABLE(of, atmel_hlcdc_of_match);

 int atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
  struct drm_display_mode *mode)
-- 
2.1.4



[RESEND PATCH 3/3] drm/atmel-hlcdc: Constify function pointer structs

2015-12-15 Thread Boris Brezillon
From: Ville Syrjälä <ville.syrj...@linux.intel.com>

Moves a bunch of junk to .rodata from .data.

drivers/gpu/drm/atmel-hlcdc/atmel-hlcdc-dc.ko:
-.text   12488
+.text   12480
-.rodata  1696
+.rodata  1760
-.data 776
+.data 712

Signed-off-by: Ville Syrjälä 
Reviewed-by: Alex Deucher 
Acked-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 067e4c1..250f69e 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -146,7 +146,7 @@ atmel_hlcdc_rgb_encoder_mode_set(struct drm_encoder 
*encoder,
   cfg);
 }

-static struct drm_encoder_helper_funcs atmel_hlcdc_panel_encoder_helper_funcs 
= {
+static const struct drm_encoder_helper_funcs 
atmel_hlcdc_panel_encoder_helper_funcs = {
.mode_fixup = atmel_hlcdc_panel_encoder_mode_fixup,
.mode_set = atmel_hlcdc_rgb_encoder_mode_set,
.disable = atmel_hlcdc_panel_encoder_disable,
@@ -192,7 +192,7 @@ atmel_hlcdc_rgb_best_encoder(struct drm_connector 
*connector)
return >encoder;
 }

-static struct drm_connector_helper_funcs 
atmel_hlcdc_panel_connector_helper_funcs = {
+static const struct drm_connector_helper_funcs 
atmel_hlcdc_panel_connector_helper_funcs = {
.get_modes = atmel_hlcdc_panel_get_modes,
.mode_valid = atmel_hlcdc_rgb_mode_valid,
.best_encoder = atmel_hlcdc_rgb_best_encoder,
-- 
2.1.4



[RESEND PATCH 01/28] drm/gma500: Sanity-check pipe index

2015-12-15 Thread Boris Brezillon
From: Thierry Reding 

If the DSI output isn't connected, then mdfld_dsi_encoder_get_pipe()
will return -1. The mdfld_dsi_dp_mode_set() function doesn't properly
check for this condition and causes the following compiler warnings:

  CC  drivers/gpu/drm/gma500/mdfld_dsi_dpi.o
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c: In function 
‘mdfld_dsi_dpi_mode_set’:
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:828:35: warning: array subscript 
is below array bounds [-Warray-bounds]
  u32 pipeconf = dev_priv->pipeconf[pipe];
   ^
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:829:33: warning: array subscript 
is below array bounds [-Warray-bounds]
  u32 dspcntr = dev_priv->dspcntr[pipe];
 ^

Fix this by checking for a valid pipe before indexing the pipeconf and
dspcntr arrays.

Cc: Patrik Jakobsson 
Reviewed-by: Patrik Jakobsson 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c 
b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
index 1a1acd3..7cd87a0 100644
--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
@@ -821,14 +821,18 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
struct drm_device *dev = dsi_config->dev;
struct drm_psb_private *dev_priv = dev->dev_private;
int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder);
-
u32 pipeconf_reg = PIPEACONF;
u32 dspcntr_reg = DSPACNTR;
+   u32 pipeconf, dspcntr;

-   u32 pipeconf = dev_priv->pipeconf[pipe];
-   u32 dspcntr = dev_priv->dspcntr[pipe];
u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;

+   if (WARN_ON(pipe < 0))
+   return;
+
+   pipeconf = dev_priv->pipeconf[pipe];
+   dspcntr = dev_priv->dspcntr[pipe];
+
if (pipe) {
pipeconf_reg = PIPECCONF;
dspcntr_reg = DSPCCNTR;
-- 
2.1.4



[RESEND PATCH 00/28] drm: trivial patches from drm/trivial branch

2015-12-15 Thread Boris Brezillon
Hi Daniel,

As discussed on IRC, here are the patches taken by Thierry in his
drm/trivial/for-next branch. I rebased it on drm-next, and had to fix
a few conflicts, so it would be safer if someone else takes a closer
look at those changes.

The atmel-hlcdc are good, so feel free to take them.

Best Regards,

Boris

Frediano Ziglio (1):
  drm/qxl: use to_qxl_bo macro

Luis de Bethencourt (1):
  drm: atmel-hlcdc: Fix module autoload for OF platform driver

Nicolas Ferre (1):
  drm: atmel-hlcdc: add support for sama5d2 SoCs

Rasmus Villemoes (3):
  drm/omap: use kzalloc in sita_init()
  drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()
  drm/vmwgfx: check kmalloc return value

Thierry Reding (4):
  drm/gma500: Sanity-check pipe index
  drm/bochs: Store correct CRTC index in events
  drm/imx: Make pipe number unsigned
  drm/imx: Drop pipe field from struct imx_drm_crtc

Ville Syrjälä (18):
  drm: Constify drm_encoder_slave_funcs
  drm/armada: Constify function pointer structs
  drm/atmel-hlcdc: Constify function pointer structs
  drm/bochs: Constify function pointer structs
  drm/bridge/dw_hdmi: Constify function pointer structs
  drm/bridge/nxp-ptn3460: Constify function pointer structs
  drm/i2c/ch7006: Constify function pointer structs
  drm/cirrus: Constify function pointer structs
  drm/exynos: Constify function pointer structs
  drm/i2c/adv7511: Constify function pointer structs
  drm/i2c/sil164: Constify function pointer structs
  drm/imx: Constify function pointer structs
  drm/mgag200: Constify function pointer structs
  drm/nouveau: Constify function pointer structs
  drm/rockchip: Constify function pointer structs
  drm/tegra: Constify function pointer structs
  drm/udl: Constify function pointer structs
  drm/vmwgfx: Constify function pointer structs

 drivers/gpu/drm/armada/armada_crtc.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  5 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c |  4 ++--
 drivers/gpu/drm/bochs/bochs_kms.c|  8 
 drivers/gpu/drm/bridge/dw_hdmi.c |  6 +++---
 drivers/gpu/drm/bridge/nxp-ptn3460.c |  6 +++---
 drivers/gpu/drm/cirrus/cirrus_mode.c |  4 ++--
 drivers/gpu/drm/drm_encoder_slave.c  |  2 +-
 drivers/gpu/drm/exynos/exynos_dp_core.c  |  8 
 drivers/gpu/drm/exynos/exynos_drm_crtc.c |  4 ++--
 drivers/gpu/drm/exynos/exynos_drm_dpi.c  |  8 
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  |  8 
 drivers/gpu/drm/exynos/exynos_drm_fb.c   |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_mic.c  |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_vidi.c |  8 
 drivers/gpu/drm/exynos/exynos_hdmi.c |  8 
 drivers/gpu/drm/gma500/mdfld_dsi_dpi.c   | 10 +++---
 drivers/gpu/drm/i2c/adv7511.c|  2 +-
 drivers/gpu/drm/i2c/ch7006_drv.c |  2 +-
 drivers/gpu/drm/i2c/sil164_drv.c |  2 +-
 drivers/gpu/drm/imx/dw_hdmi-imx.c|  4 ++--
 drivers/gpu/drm/imx/imx-drm-core.c   | 23 +++
 drivers/gpu/drm/imx/imx-drm.h|  2 +-
 drivers/gpu/drm/imx/imx-ldb.c|  8 
 drivers/gpu/drm/imx/imx-tve.c|  8 
 drivers/gpu/drm/imx/ipuv3-crtc.c |  2 +-
 drivers/gpu/drm/imx/parallel-display.c   |  8 
 drivers/gpu/drm/mgag200/mgag200_mode.c   |  4 ++--
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c|  6 +++---
 drivers/gpu/drm/nouveau/nouveau_encoder.h|  2 +-
 drivers/gpu/drm/omapdrm/tcm-sita.c   |  7 ++-
 drivers/gpu/drm/qxl/qxl_object.c |  2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c|  4 ++--
 drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c|  6 +++---
 drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c|  8 
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c  |  4 ++--
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c   |  2 +-
 drivers/gpu/drm/tegra/fb.c   |  2 +-
 drivers/gpu/drm/udl/udl_connector.c  |  4 ++--
 drivers/gpu/drm/udl/udl_modeset.c|  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c  |  9 +++--
 include/drm/drm_encoder_slave.h  |  2 +-
 46 files changed, 122 insertions(+), 120 deletions(-)

-- 
2.1.4



[RESEND PATCH 05/28] drm/omap: use kzalloc in sita_init()

2015-12-15 Thread Boris Brezillon
From: Rasmus Villemoes 

Signed-off-by: Rasmus Villemoes 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/omapdrm/tcm-sita.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c 
b/drivers/gpu/drm/omapdrm/tcm-sita.c
index efb6095..6df1f2a 100644
--- a/drivers/gpu/drm/omapdrm/tcm-sita.c
+++ b/drivers/gpu/drm/omapdrm/tcm-sita.c
@@ -87,14 +87,11 @@ struct tcm *sita_init(u16 width, u16 height, struct tcm_pt 
*attr)
if (width == 0 || height == 0)
return NULL;

-   tcm = kmalloc(sizeof(*tcm), GFP_KERNEL);
-   pvt = kmalloc(sizeof(*pvt), GFP_KERNEL);
+   tcm = kzalloc(sizeof(*tcm), GFP_KERNEL);
+   pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
if (!tcm || !pvt)
goto error;

-   memset(tcm, 0, sizeof(*tcm));
-   memset(pvt, 0, sizeof(*pvt));
-
/* Updating the pointers to SiTA implementation APIs */
tcm->height = height;
tcm->width = width;
-- 
2.1.4



[RESEND PATCH 06/28] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()

2015-12-15 Thread Boris Brezillon
From: Rasmus Villemoes 

Signed-off-by: Rasmus Villemoes 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 7d620e8..a3ae985 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -815,11 +815,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void 
*data,
srf->sizes[0].height == 64 &&
srf->format == SVGA3D_A8R8G8B8) {

-   srf->snooper.image = kmalloc(64 * 64 * 4, GFP_KERNEL);
-   /* clear the image */
-   if (srf->snooper.image) {
-   memset(srf->snooper.image, 0x00, 64 * 64 * 4);
-   } else {
+   srf->snooper.image = kzalloc(64 * 64 * 4, GFP_KERNEL);
+   if (!srf->snooper.image) {
DRM_ERROR("Failed to allocate cursor_image\n");
ret = -ENOMEM;
goto out_no_copy;
-- 
2.1.4



[RESEND PATCH 08/28] drm/qxl: use to_qxl_bo macro

2015-12-15 Thread Boris Brezillon
From: Frediano Ziglio 

Instead of using container_of directly use to_qxl_bo macro.

Signed-off-by: Frediano Ziglio 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/qxl/qxl_object.c | 2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index b28370e..5e1d789 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -32,7 +32,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
struct qxl_bo *bo;
struct qxl_device *qdev;

-   bo = container_of(tbo, struct qxl_bo, tbo);
+   bo = to_qxl_bo(tbo);
qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;

qxl_surface_evict(qdev, bo, false);
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 0cbc4c9..9534127 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -201,7 +201,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
placement->num_busy_placement = 1;
return;
}
-   qbo = container_of(bo, struct qxl_bo, tbo);
+   qbo = to_qxl_bo(bo);
qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU, false);
*placement = qbo->placement;
 }
@@ -365,7 +365,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,

if (!qxl_ttm_bo_is_qxl_bo(bo))
return;
-   qbo = container_of(bo, struct qxl_bo, tbo);
+   qbo = to_qxl_bo(bo);
qdev = qbo->gem_base.dev->dev_private;

if (bo->mem.mem_type == TTM_PL_PRIV0 && qbo->surface_id)
-- 
2.1.4



[RESEND PATCH 09/28] drm: atmel-hlcdc: add support for sama5d2 SoCs

2015-12-15 Thread Boris Brezillon
From: Nicolas Ferre <nicolas.fe...@atmel.com>

As the hardware description for this chip is the same as the sama5d4, we use
this SoC structures for layers and DC descriptions. Thus only 2 lines are added
to the atmel_hlcdc_of_match table.
The compatible string is already documented in the parent MFD driver's binding.

Signed-off-by: Nicolas Ferre 
Acked-by: Boris Brezillon 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8168954..378 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -333,6 +333,10 @@ static const struct of_device_id atmel_hlcdc_of_match[] = {
.data = _hlcdc_dc_at91sam9x5,
},
{
+   .compatible = "atmel,sama5d2-hlcdc",
+   .data = _hlcdc_dc_sama5d4,
+   },
+   {
.compatible = "atmel,sama5d3-hlcdc",
.data = _hlcdc_dc_sama5d3,
},
-- 
2.1.4



[RESEND PATCH 10/28] drm: Constify drm_encoder_slave_funcs

2015-12-15 Thread Boris Brezillon
From: Ville Syrjälä 

Signed-off-by: Ville Syrjälä 
Reviewed-by: Alex Deucher 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_encoder_slave.c   | 2 +-
 drivers/gpu/drm/nouveau/nouveau_encoder.h | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c | 6 +++---
 drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c | 8 
 include/drm/drm_encoder_slave.h   | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_encoder_slave.c 
b/drivers/gpu/drm/drm_encoder_slave.c
index d18b88b..e862907 100644
--- a/drivers/gpu/drm/drm_encoder_slave.c
+++ b/drivers/gpu/drm/drm_encoder_slave.c
@@ -124,7 +124,7 @@ EXPORT_SYMBOL(drm_i2c_encoder_destroy);
  * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
  */

-static inline struct drm_encoder_slave_funcs *
+static inline const struct drm_encoder_slave_funcs *
 get_slave_funcs(struct drm_encoder *enc)
 {
return to_encoder_slave(enc)->slave_funcs;
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h 
b/drivers/gpu/drm/nouveau/nouveau_encoder.h
index c38a864..ee6a6d3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_encoder.h
+++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h
@@ -83,7 +83,7 @@ static inline struct drm_encoder *to_drm_encoder(struct 
nouveau_encoder *enc)
return >base.base;
 }

-static inline struct drm_encoder_slave_funcs *
+static inline const struct drm_encoder_slave_funcs *
 get_slave_funcs(struct drm_encoder *enc)
 {
return to_encoder_slave(enc)->slave_funcs;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c 
b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
index 96f2eb4..a37b6e2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
@@ -28,7 +28,7 @@ static int rcar_du_hdmi_connector_get_modes(struct 
drm_connector *connector)
 {
struct rcar_du_connector *con = to_rcar_connector(connector);
struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(con->encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);

if (sfuncs->get_modes == NULL)
return 0;
@@ -41,7 +41,7 @@ static int rcar_du_hdmi_connector_mode_valid(struct 
drm_connector *connector,
 {
struct rcar_du_connector *con = to_rcar_connector(connector);
struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(con->encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);

if (sfuncs->mode_valid == NULL)
return MODE_OK;
@@ -66,7 +66,7 @@ rcar_du_hdmi_connector_detect(struct drm_connector 
*connector, bool force)
 {
struct rcar_du_connector *con = to_rcar_connector(connector);
struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(con->encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);

if (sfuncs->detect == NULL)
return connector_status_unknown;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
index 11267de..2567efc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
@@ -35,7 +35,7 @@ struct rcar_du_hdmienc {
 static void rcar_du_hdmienc_disable(struct drm_encoder *encoder)
 {
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);

if (sfuncs->dpms)
sfuncs->dpms(encoder, DRM_MODE_DPMS_OFF);
@@ -50,7 +50,7 @@ static void rcar_du_hdmienc_disable(struct drm_encoder 
*encoder)
 static void rcar_du_hdmienc_enable(struct drm_encoder *encoder)
 {
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);

if (hdmienc->renc->lvds)
rcar_du_lvdsenc_enable(hdmienc->renc->lvds, encoder->crtc,
@@ -67,7 +67,7 @@ static int rcar_du_hdmienc_atomic_check(struct drm_encoder 
*encoder,
struct drm_connector_state *conn_state)
 {
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
-   struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
+   const struct drm_encoder_slave_funcs *sfuncs = to_slave_funcs(encoder);
struct drm_display_mode *adjusted_mode = _state->adjusted_mode;
const struct drm_display_mode *mode = _state->mode;

@@ -89,7 +89,7 @@ static void rcar_du_hdmienc_mode_set(struct drm_encoder 
*encoder,
 struct 

[RESEND PATCH 12/28] drm/atmel-hlcdc: Constify function pointer structs

2015-12-15 Thread Boris Brezillon
From: Ville Syrjälä <ville.syrj...@linux.intel.com>

Moves a bunch of junk to .rodata from .data.

drivers/gpu/drm/atmel-hlcdc/atmel-hlcdc-dc.ko:
-.text   12488
+.text   12480
-.rodata  1696
+.rodata  1760
-.data 776
+.data 712

Signed-off-by: Ville Syrjälä 
Reviewed-by: Alex Deucher 
Acked-by: Boris Brezillon 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index d112900..0f7ec01 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -146,7 +146,7 @@ atmel_hlcdc_rgb_encoder_mode_set(struct drm_encoder 
*encoder,
   cfg);
 }

-static struct drm_encoder_helper_funcs atmel_hlcdc_panel_encoder_helper_funcs 
= {
+static const struct drm_encoder_helper_funcs 
atmel_hlcdc_panel_encoder_helper_funcs = {
.mode_fixup = atmel_hlcdc_panel_encoder_mode_fixup,
.mode_set = atmel_hlcdc_rgb_encoder_mode_set,
.disable = atmel_hlcdc_panel_encoder_disable,
@@ -192,7 +192,7 @@ atmel_hlcdc_rgb_best_encoder(struct drm_connector 
*connector)
return >encoder;
 }

-static struct drm_connector_helper_funcs 
atmel_hlcdc_panel_connector_helper_funcs = {
+static const struct drm_connector_helper_funcs 
atmel_hlcdc_panel_connector_helper_funcs = {
.get_modes = atmel_hlcdc_panel_get_modes,
.mode_valid = atmel_hlcdc_rgb_mode_valid,
.best_encoder = atmel_hlcdc_rgb_best_encoder,
-- 
2.1.4



[RESEND PATCH 13/28] drm/bochs: Constify function pointer structs

2015-12-15 Thread Boris Brezillon
From: Ville Syrjälä 

Moves a bunch of junk to .rodata from .data.

 drivers/gpu/drm/bochs/bochs-drm.ko:
-.text7608
+.text7600
-.rodata   648
+.rodata   716
-.data 612
+.data 544

Signed-off-by: Ville Syrjälä 
Reviewed-by: Alex Deucher 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/bochs/bochs_kms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index 823858f..2849f1b 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -245,13 +245,13 @@ static enum drm_connector_status 
bochs_connector_detect(struct drm_connector
return connector_status_connected;
 }

-struct drm_connector_helper_funcs bochs_connector_connector_helper_funcs = {
+static const struct drm_connector_helper_funcs 
bochs_connector_connector_helper_funcs = {
.get_modes = bochs_connector_get_modes,
.mode_valid = bochs_connector_mode_valid,
.best_encoder = bochs_connector_best_encoder,
 };

-struct drm_connector_funcs bochs_connector_connector_funcs = {
+static const struct drm_connector_funcs bochs_connector_connector_funcs = {
.dpms = drm_helper_connector_dpms,
.detect = bochs_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
@@ -283,7 +283,7 @@ int bochs_kms_init(struct bochs_device *bochs)
bochs->dev->mode_config.preferred_depth = 24;
bochs->dev->mode_config.prefer_shadow = 0;

-   bochs->dev->mode_config.funcs = (void *)_mode_funcs;
+   bochs->dev->mode_config.funcs = _mode_funcs;

bochs_crtc_init(bochs->dev);
bochs_encoder_init(bochs->dev);
-- 
2.1.4



[RESEND PATCH 14/28] drm/bridge/dw_hdmi: Constify function pointer structs

2015-12-15 Thread Boris Brezillon
From: Ville Syrjälä 

Moves a bunch of junk to .rodata from .data.

 drivers/gpu/drm/bridge/dw_hdmi.ko:
-.rodata  120
+.rodata  216
-.data 96
+.data  0

Signed-off-by: Ville Syrjälä 
Reviewed-by: Alex Deucher 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 56de9f1..210d8df 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1514,7 +1514,7 @@ static void dw_hdmi_connector_force(struct drm_connector 
*connector)
mutex_unlock(>mutex);
 }

-static struct drm_connector_funcs dw_hdmi_connector_funcs = {
+static const struct drm_connector_funcs dw_hdmi_connector_funcs = {
.dpms = drm_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes,
.detect = dw_hdmi_connector_detect,
@@ -1522,13 +1522,13 @@ static struct drm_connector_funcs 
dw_hdmi_connector_funcs = {
.force = dw_hdmi_connector_force,
 };

-static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
+static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs 
= {
.get_modes = dw_hdmi_connector_get_modes,
.mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };

-static struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
+static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
.enable = dw_hdmi_bridge_enable,
.disable = dw_hdmi_bridge_disable,
.pre_enable = dw_hdmi_bridge_nop,
-- 
2.1.4



[RESEND PATCH 02/28] drm/bochs: Store correct CRTC index in events

2015-12-15 Thread Boris Brezillon
From: Thierry Reding 

Previously a negative pipe caused a special case to be triggered for
drivers that didn't have proper VBLANK support. The trigger for this
special case is now independent of the pipe, so the correct CRTC index
can now be stored in events.

v2: convert to use drm_crtc_send_vblank_event()

Cc: Gerd Hoffmann 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/bochs/bochs_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index a88be6d..823858f 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -119,7 +119,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
if (event) {
spin_lock_irqsave(>dev->event_lock, irqflags);
-   drm_send_vblank_event(bochs->dev, -1, event);
+   drm_crtc_send_vblank_event(crtc, event);
spin_unlock_irqrestore(>dev->event_lock, irqflags);
}
return 0;
-- 
2.1.4



[RESEND PATCH 03/28] drm/imx: Make pipe number unsigned

2015-12-15 Thread Boris Brezillon
From: Thierry Reding 

There's no reason whatsoever why this should ever be negative. The same
goes for the number of pipes added to the DRM device.

Cc: Philipp Zabel 
Acked-by: Philipp Zabel 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 6 +++---
 drivers/gpu/drm/imx/imx-drm.h  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 09e20ea..9211473 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -39,13 +39,13 @@ struct imx_drm_component {
 struct imx_drm_device {
struct drm_device   *drm;
struct imx_drm_crtc *crtc[MAX_CRTC];
-   int pipes;
+   unsigned intpipes;
struct drm_fbdev_cma*fbhelper;
 };

 struct imx_drm_crtc {
struct drm_crtc *crtc;
-   int pipe;
+   unsigned intpipe;
struct imx_drm_crtc_helper_funcsimx_drm_helper_funcs;
 };

@@ -54,7 +54,7 @@ static int legacyfb_depth = 16;
 module_param(legacyfb_depth, int, 0444);
 #endif

-int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
 {
return crtc->pipe;
 }
diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
index 83284b4..71cf6d9 100644
--- a/drivers/gpu/drm/imx/imx-drm.h
+++ b/drivers/gpu/drm/imx/imx-drm.h
@@ -13,7 +13,7 @@ struct drm_plane;
 struct imx_drm_crtc;
 struct platform_device;

-int imx_drm_crtc_id(struct imx_drm_crtc *crtc);
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc);

 struct imx_drm_crtc_helper_funcs {
int (*enable_vblank)(struct drm_crtc *crtc);
-- 
2.1.4



[RESEND PATCH 04/28] drm/imx: Drop pipe field from struct imx_drm_crtc

2015-12-15 Thread Boris Brezillon
From: Thierry Reding 

Use the drm_crtc_index() helper to determine the pipe number of the CRTC
instead.

Cc: Philipp Zabel 
Acked-by: Philipp Zabel 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 9211473..303a673 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -45,7 +45,6 @@ struct imx_drm_device {

 struct imx_drm_crtc {
struct drm_crtc *crtc;
-   unsigned intpipe;
struct imx_drm_crtc_helper_funcsimx_drm_helper_funcs;
 };

@@ -56,7 +55,7 @@ module_param(legacyfb_depth, int, 0444);

 unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
 {
-   return crtc->pipe;
+   return drm_crtc_index(crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_id);

@@ -124,19 +123,19 @@ EXPORT_SYMBOL_GPL(imx_drm_set_bus_format);

 int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc)
 {
-   return drm_vblank_get(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+   return drm_crtc_vblank_get(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_get);

 void imx_drm_crtc_vblank_put(struct imx_drm_crtc *imx_drm_crtc)
 {
-   drm_vblank_put(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+   drm_crtc_vblank_put(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_put);

 void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc)
 {
-   drm_handle_vblank(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+   drm_crtc_handle_vblank(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_handle_vblank);

@@ -356,12 +355,11 @@ int imx_drm_add_crtc(struct drm_device *drm, struct 
drm_crtc *crtc,
return -ENOMEM;

imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
-   imx_drm_crtc->pipe = imxdrm->pipes++;
imx_drm_crtc->crtc = crtc;

crtc->port = port;

-   imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc;
+   imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;

*new_crtc = imx_drm_crtc;

@@ -378,7 +376,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct 
drm_crtc *crtc,
return 0;

 err_register:
-   imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
+   imxdrm->crtc[--imxdrm->pipes] = NULL;
kfree(imx_drm_crtc);
return ret;
 }
@@ -390,10 +388,11 @@ EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
 int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
 {
struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
+   unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc);

drm_crtc_cleanup(imx_drm_crtc->crtc);

-   imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
+   imxdrm->crtc[pipe] = NULL;

kfree(imx_drm_crtc);

-- 
2.1.4



<    1   2   3   4   5   6   7   8   9   10   >