Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH v3] x86: sysfb: remove sysfb when probing real hw
From: Stephen Warren @ 2013-12-19 19:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: David Herrmann, linux-kernel, Takashi Iwai,
	the arch/x86 maintainers, linux-fbdev, Geert Uytterhoeven, stable
In-Reply-To: <20131219185517.GA303@gmail.com>

On 12/19/2013 11:55 AM, Ingo Molnar wrote:
> 
> * Stephen Warren <swarren@wwwdotorg.org> wrote:
> 
>> On 12/19/2013 03:13 AM, David Herrmann wrote:
>>> With CONFIG_X86_SYSFB=y, probing real hw-drivers may result in
>>> resource-conflicts and drivers will refuse to load. A call to
>>> request_mem_region() will fail, if the region overlaps with the mem-region
>>> used by simplefb. The common desktop DRM drivers (intel, nouveau, radeon)
>>> are not affected as they don't reserve their resources, but some others
>>> do, including (nvidiafb, cirrus, ..).
>>
>> I have validated that this doesn't cause any regressions on the/a
>> non-x86 platform using simplefb, although given the main point of this
>> patch is to fix issues on x86, I'm rather hesitant to give a tested-by
>> tag in case someone looking back interprets it incorrectly:-)
> 
> Tested-on-ARM-by: Stephen Warren <swarren@wwwdotorg.org>

I suppose with CC: stable there's some precedent for a comment after the
tag, so perhaps:

Tested-by: Stephen Warren <swarren@wwwdotorg.org> # on ARM only


^ permalink raw reply

* Re: [PATCH v3] x86: sysfb: remove sysfb when probing real hw
From: Ingo Molnar @ 2013-12-19 19:19 UTC (permalink / raw)
  To: Stephen Warren
  Cc: David Herrmann, linux-kernel, Takashi Iwai,
	the arch/x86 maintainers, linux-fbdev, Geert Uytterhoeven, stable
In-Reply-To: <52B34454.1040603@wwwdotorg.org>


* Stephen Warren <swarren@wwwdotorg.org> wrote:

> On 12/19/2013 11:55 AM, Ingo Molnar wrote:
> > 
> > * Stephen Warren <swarren@wwwdotorg.org> wrote:
> > 
> >> On 12/19/2013 03:13 AM, David Herrmann wrote:
> >>> With CONFIG_X86_SYSFB=y, probing real hw-drivers may result in
> >>> resource-conflicts and drivers will refuse to load. A call to
> >>> request_mem_region() will fail, if the region overlaps with the mem-region
> >>> used by simplefb. The common desktop DRM drivers (intel, nouveau, radeon)
> >>> are not affected as they don't reserve their resources, but some others
> >>> do, including (nvidiafb, cirrus, ..).
> >>
> >> I have validated that this doesn't cause any regressions on the/a
> >> non-x86 platform using simplefb, although given the main point of this
> >> patch is to fix issues on x86, I'm rather hesitant to give a tested-by
> >> tag in case someone looking back interprets it incorrectly:-)
> > 
> > Tested-on-ARM-by: Stephen Warren <swarren@wwwdotorg.org>
> 
> I suppose with CC: stable there's some precedent for a comment after the
> tag, so perhaps:
> 
> Tested-by: Stephen Warren <swarren@wwwdotorg.org> # on ARM only

That works too.

Thanks,

	Ingo

^ permalink raw reply

* [PATCH] fbcon: Clean up fbcon data in fb_info on FB_EVENT_FB_UNBIND with 0 fbs
From: Keith Packard @ 2013-12-20  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-fbdev; +Cc: Keith Packard

When FB_EVENT_FB_UNBIND is sent, fbcon has two paths, one path taken
when there is another frame buffer to switch any affected vcs to and
another path when there isn't.

In the case where there is another frame buffer to use,
fbcon_fb_unbind calls set_con2fb_map to remap all of the affected vcs
to the replacement frame buffer. set_con2fb_map will eventually call
con2fb_release_oldinfo when the last vcs gets unmapped from the old
frame buffer.

con2fb_release_oldinfo frees the fbcon data that is hooked off of the
fb_info structure, including the cursor timer.

In the case where there isn't another frame buffer to use,
fbcon_fb_unbind simply calls fbcon_unbind, which doesn't clear the
con2fb_map or free the fbcon data hooked from the fb_info
structure. In particular, it doesn't stop the cursor blink timer. When
the fb_info structure is then freed, we end up with a timer queue
pointing into freed memory and "bad things" start happening.

This patch first changes con2fb_release_oldinfo so that it can take a
NULL pointer for the new frame buffer, but still does all of the
deallocation and cursor timer cleanup.

Finally, the patch tries to replicate some of what set_con2fb_map does
by clearing the con2fb_map for the affected vcs and calling the
modified con2fb_release_info function to clean up the fb_info structure.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 drivers/video/console/fbcon.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index a92783e..ba9e149 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -787,7 +787,7 @@ static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
 		  newinfo in an undefined state. Thus, a call to
 		  fb_set_par() may be needed for the newinfo.
 		*/
-		if (newinfo->fbops->fb_set_par) {
+		if (newinfo && newinfo->fbops->fb_set_par) {
 			ret = newinfo->fbops->fb_set_par(newinfo);
 
 			if (ret)
@@ -3056,8 +3056,31 @@ static int fbcon_fb_unbind(int idx)
 			if (con2fb_map[i] = idx)
 				set_con2fb_map(i, new_idx, 0);
 		}
-	} else
+	} else {
+		struct fb_info *info = registered_fb[idx];
+
+		/* This is sort of like set_con2fb_map, except it maps
+		 * the consoles to no device and then releases the
+		 * oldinfo to free memory and cancel the cursor blink
+		 * timer. I can imagine this just becoming part of
+		 * set_con2fb_map where new_idx is -1
+		 */
+		for (i = first_fb_vc; i <= last_fb_vc; i++) {
+			if (con2fb_map[i] = idx) {
+				con2fb_map[i] = -1;
+				if (!search_fb_in_map(idx)) {
+					ret = con2fb_release_oldinfo(vc_cons[i].d,
+								     info, NULL, i,
+								     idx, 0);
+					if (ret) {
+						con2fb_map[i] = idx;
+						return ret;
+					}
+				}
+			}
+		}
 		ret = fbcon_unbind();
+	}
 
 	return ret;
 }
-- 
1.8.5.1


^ permalink raw reply related

* Re: [PATCH] fbcon: Clean up fbcon data in fb_info on FB_EVENT_FB_UNBIND with 0 fbs
From: Keith Packard @ 2013-12-20  7:10 UTC (permalink / raw)
  To: linux-kernel, linux-fbdev
In-Reply-To: <1387498677-25653-1-git-send-email-keithp@keithp.com>

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

Keith Packard <keithp@keithp.com> writes:

> When FB_EVENT_FB_UNBIND is sent, fbcon has two paths, one path taken
> when there is another frame buffer to switch any affected vcs to and
> another path when there isn't.

What I meant to attach to this bug report but clearly failed was that I think
this case essentially *always* occurs if you have a generic frame buffer
driver loaded before a 'real' driver is loaded. In my case, this is
efifb. So, we have a reference to freed memory hanging out on a timer
list.

I'm really unsure why this hasn't caused more grief, but I can say that
it was greatly aggravated by adding 'fbcon=vc:2-6' to the kernel command
line, which limits fbcon to supporting consoles only on vt 2-6.

Definitely one of those 'how could this ever have worked, and why hasn't
my machine been crashing every day' moments when I read through the
code.

As the patch indicates, I'm not sure this patch is actually what we
want, but I'd love to know if I've isolated the root cause correctly and
then figure out what patch we actually want.

For my own part, I've got a happy customer with the patch, which is
definitely a nice way to end the day.

-- 
keith.packard@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply

* [PATCH] video/logo: don't look for the logo after system boot
From: Sebastian Andrzej Siewior @ 2013-12-20 14:24 UTC (permalink / raw)
  To: linux-fbdev

If the primary GPU driver has been loaded _after_ system as a module
then this logo memory is no longer valid.
Managed to crash the system by booting a box without a GPU and then
hotpluggin => BOOM.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/video/logo/logo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index 080c35b..a26bb16 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -36,6 +36,9 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
 	if (nologo)
 		return NULL;
 
+	if (system_state != SYSTEM_BOOTING)
+		return NULL;
+
 	if (depth >= 1) {
 #ifdef CONFIG_LOGO_LINUX_MONO
 		/* Generic Linux logo */
-- 
1.8.4.3


^ permalink raw reply related

* Re: [PATCH v4] x86: sysfb: remove sysfb when probing real hw
From: David Herrmann @ 2013-12-20 14:46 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, H. Peter Anvin, Thomas Gleixner,
	the arch/x86 maintainers, linux-fbdev@vger.kernel.org, stable
In-Reply-To: <20131219183310.GF32508@gmail.com>

Hi

On Thu, Dec 19, 2013 at 7:33 PM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * David Herrmann <dh.herrmann@gmail.com> wrote:
>
>> +/*
>> + * Unregister the sysfb and prevent new sysfbs from getting registered. Can be
>> + * called from any context except recursively or from sysfb_register().
>> + * Used by remove_conflicting_framebuffers() and friends.
>> + */
>> +void sysfb_unregister(const struct apertures_struct *apert, bool primary)
>> +{
>> +     mutex_lock(&sysfb_lock);
>> +     if (!IS_ERR(sysfb_dev) && sysfb_dev) {
>> +             if (sysfb_match(apert, primary)) {
>> +                     platform_device_unregister(sysfb_dev);
>> +                     sysfb_dev = ERR_PTR(-EALREADY);
>> +             }
>> +     } else {
>> +             /* if !sysfb_dev, set err so no new sysfb is probed later */
>> +             sysfb_dev = ERR_PTR(-EALREADY);
>
> Just a small detail: we can get into this 'else' branch not just with
> NULL, but also with IS_ERR(sysfb_dev). In that case we override
> whatever error code is contained in sysfb_dev and overwrite it with
> ERR_PTR(-EALREADY).
>
> (Probably not a big deal, because we don't actually ever seem to
> extract the error code from the pointer, but wanted to mention it.)

Yepp, I know, but that's just fine.

>> +#ifdef CONFIG_X86_SYSFB
>> +#include <asm/sysfb.h>
>> +#endif
>
> Pet peeve, this looks sexier:
>
> #ifdef CONFIG_X86_SYSFB
> # include <asm/sysfb.h>
> #endif
>
>> @@ -1604,6 +1607,17 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
>>       }
>>  }
>>
>> +static void remove_conflicting_sysfb(const struct apertures_struct *apert,
>> +                                  bool primary)
>> +{
>> +     if (!apert)
>> +             return;
>> +
>> +#ifdef CONFIG_X86_SYSFB
>> +     sysfb_unregister(apert, primary);
>> +#endif
>> +}
>
> So why not make sysfb_unregister() accept a !apert parameter (it would
> simply return), at which point remove_conflicting_sysfb() could be
> eliminated and just be replaced with a direct sysfb_unregister() call
> - with no #ifdefs.
>
> We only need #ifdefs for the sysfb_unregister() declaration in the .h
> file.

I can do that but we still need the #ifdef. sysfb is an x86-asm header
so it's not available on other archs. Even with #ifdef in the header I
still need it around the actual function call.

Thanks
David

> At first sight this looks simpler and cleaner for the fix itself - no
> need for extra cleanups for this detail.
>
> Thanks,
>
>         Ingo

^ permalink raw reply

* Re: [PATCH] video/logo: don't look for the logo after system boot
From: Geert Uytterhoeven @ 2013-12-20 15:27 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387549460-18501-1-git-send-email-bigeasy@linutronix.de>

On Fri, Dec 20, 2013 at 3:24 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> If the primary GPU driver has been loaded _after_ system as a module
> then this logo memory is no longer valid.
> Managed to crash the system by booting a box without a GPU and then
> hotpluggin => BOOM.

Which GPU driver is this?

drivers/video/fbmem.c:fb_prepare_logo() has protection against this:

        if (info->flags & FBINFO_MISC_TILEBLITTING ||
            info->flags & FBINFO_MODULE)
                return 0;

> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/video/logo/logo.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
> index 080c35b..a26bb16 100644
> --- a/drivers/video/logo/logo.c
> +++ b/drivers/video/logo/logo.c
> @@ -36,6 +36,9 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
>         if (nologo)
>                 return NULL;
>
> +       if (system_state != SYSTEM_BOOTING)
> +               return NULL;
> +
>         if (depth >= 1) {
>  #ifdef CONFIG_LOGO_LINUX_MONO
>                 /* Generic Linux logo */

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH] video/logo: don't look for the logo after system boot
From: Sebastian Andrzej Siewior @ 2013-12-20 15:31 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387549460-18501-1-git-send-email-bigeasy@linutronix.de>

On 12/20/2013 04:27 PM, Geert Uytterhoeven wrote:
> On Fri, Dec 20, 2013 at 3:24 PM, Sebastian Andrzej Siewior
> <bigeasy@linutronix.de> wrote:
>> If the primary GPU driver has been loaded _after_ system as a module
>> then this logo memory is no longer valid.
>> Managed to crash the system by booting a box without a GPU and then
>> hotpluggin => BOOM.
> 
> Which GPU driver is this?

i915.

> 
> drivers/video/fbmem.c:fb_prepare_logo() has protection against this:
> 
>         if (info->flags & FBINFO_MISC_TILEBLITTING ||
>             info->flags & FBINFO_MODULE)
>                 return 0;

but gpu driver is built-in. I just add PCI device at run-time. The same
thing should happen if you go to sysfs and remove the PCI device and
then do
  echo 1 > /sys/bus/pci/rescan

Sebastian


^ permalink raw reply

* Re: [PATCH] video/logo: don't look for the logo after system boot
From: Sebastian Andrzej Siewior @ 2013-12-20 15:49 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387549460-18501-1-git-send-email-bigeasy@linutronix.de>

On 12/20/2013 04:31 PM, Sebastian Andrzej Siewior wrote:
> On 12/20/2013 04:27 PM, Geert Uytterhoeven wrote:
>> On Fri, Dec 20, 2013 at 3:24 PM, Sebastian Andrzej Siewior
>> <bigeasy@linutronix.de> wrote:
>>> If the primary GPU driver has been loaded _after_ system as a module
>>> then this logo memory is no longer valid.
>>> Managed to crash the system by booting a box without a GPU and then
>>> hotpluggin => BOOM.
>>
>> drivers/video/fbmem.c:fb_prepare_logo() has protection against this:
>>
>>         if (info->flags & FBINFO_MISC_TILEBLITTING ||
>>             info->flags & FBINFO_MODULE)
>>                 return 0;
> 
> but gpu driver is built-in. I just add PCI device at run-time. The same
> thing should happen if you go to sysfs and remove the PCI device and
> then do

No I see where you are going with this. My description of the problem
is wrong. The problem is nothing to do with the driver being a module.
If nobody objects this or suggests a different solution then I'm going
to provide a patch with a proper description.

Sebastian

^ permalink raw reply

* Re: [PATCH] video/logo: don't look for the logo after system boot
From: Geert Uytterhoeven @ 2013-12-20 16:20 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387549460-18501-1-git-send-email-bigeasy@linutronix.de>

On Fri, Dec 20, 2013 at 4:49 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> On 12/20/2013 04:31 PM, Sebastian Andrzej Siewior wrote:
>> On 12/20/2013 04:27 PM, Geert Uytterhoeven wrote:
>>> On Fri, Dec 20, 2013 at 3:24 PM, Sebastian Andrzej Siewior
>>> <bigeasy@linutronix.de> wrote:
>>>> If the primary GPU driver has been loaded _after_ system as a module
>>>> then this logo memory is no longer valid.
>>>> Managed to crash the system by booting a box without a GPU and then
>>>> hotpluggin => BOOM.
>>>
>>> drivers/video/fbmem.c:fb_prepare_logo() has protection against this:
>>>
>>>         if (info->flags & FBINFO_MISC_TILEBLITTING ||
>>>             info->flags & FBINFO_MODULE)
>>>                 return 0;
>>
>> but gpu driver is built-in. I just add PCI device at run-time. The same
>> thing should happen if you go to sysfs and remove the PCI device and
>> then do
>
> No I see where you are going with this. My description of the problem
> is wrong. The problem is nothing to do with the driver being a module.

Yes, I got confused by the "as a module".

> If nobody objects this or suggests a different solution then I'm going
> to provide a patch with a proper description.

Is "system_state != SYSTEM_BOOTING" the right check?
How long is is in the SYSTEM_BOOTING state?

Ah, kernel_init() does:

        free_initmem();
        mark_rodata_ro();
        system_state = SYSTEM_RUNNING;

So this looks OK to me.

We used to have an initmem_freed flag, but it was removed 15 years
ago. 11 years ago, we got system_state, for the same purpose ;-)

Looking at commit 70802c60379fb843c485dfd4cab9e8f527d8fe81
Author: Antonino A. Daplas <adaplas@gmail.com>
Date:   Tue May 8 00:38:14 2007 -0700

    fbdev: don't show logo if driver or fbcon are modular

it seems we were not aware of the existence of system_state....
I guess you can remove FBINFO_MODULE after your fix?

BTW, I'm wondering if modprobing newport_con.ko crashes, too, as
it seems to call fb_find_logo() without any protection.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* [RFC PATCH 0/5] Move IPUv3 core out of staging, add CSI support
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

Hi,

this is mostly about the first patch, which moves the IPUv3 core code
(drivers/staging/imx-drm/ipu-v3) to drivers/gpu. host1x, which
serves a similar purpose, already sits there.
The other four patches add the necessary code for CSI and SMFC handling,
which is used by the V4L2 CSI capture driver.

Currently this is based on Russell's patch
    [PATCH 62/64] imx-drm: pass an IPU ID to crtc and core

I am aware that there are now quite a few other patches in the pipeline
that touch drivers/staging/imx-drm/ipu-v3/*, so I am happy to rebase this
(or them) as needed. I'd like to move the core code out of staging so that
we can start submitting V4L2 code for video capture and scaling / colorspace
conversion in parallel.

Philipp Zabel (5):
  gpu: ipu-v3: Move i.MX IPUv3 core driver out of staging
  gpu: ipu-v3: Add SMFC code
  gpu: ipu-v3: Add ipu_idmac_get_current_buffer function
  gpu: ipu-v3: Add CSI and SMFC module enable wrappers
  gpu: ipu-v3: Register the CSI modules

 drivers/gpu/Makefile                               |  1 +
 drivers/gpu/ipu-v3/Kconfig                         |  7 ++
 drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile   |  4 +-
 .../{staging/imx-drm => gpu}/ipu-v3/ipu-common.c   | 81 ++++++++++++++++--
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c   |  3 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c   |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c   |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h  |  8 +-
 drivers/gpu/ipu-v3/ipu-smfc.c                      | 97 ++++++++++++++++++++++
 drivers/staging/imx-drm/Kconfig                    | 11 +--
 drivers/staging/imx-drm/Makefile                   |  1 -
 drivers/staging/imx-drm/imx-drm.h                  |  4 -
 drivers/staging/imx-drm/imx-tve.c                  |  1 +
 drivers/staging/imx-drm/ipuv3-crtc.c               |  2 +-
 drivers/staging/imx-drm/ipuv3-plane.c              |  2 +-
 drivers/video/Kconfig                              |  1 +
 .../imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h  | 18 ++++
 18 files changed, 217 insertions(+), 30 deletions(-)
 create mode 100644 drivers/gpu/ipu-v3/Kconfig
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile (51%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c (94%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h (96%)
 create mode 100644 drivers/gpu/ipu-v3/ipu-smfc.c
 rename {drivers/staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h (94%)

regards
Philipp

^ permalink raw reply

* [RFC PATCH 1/5] gpu: ipu-v3: Move i.MX IPUv3 core driver out of staging
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

The i.MX Image Processing Unit (IPU) contains a number of image processing
blocks that sit right in the middle between DRM and V4L2. Some of the modules,
such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS
Sensor Interface (CSI) and their FIFOs could be assigned to either framework,
but others, such as the dma controller (IDMAC) and image converter (IC) can
be used by both.
The IPUv3 core driver provides an internal API to access the modules, to be
used by both DRM and V4L2 IPUv3 drivers.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/Makefile                                          |  1 +
 drivers/gpu/ipu-v3/Kconfig                                    |  7 +++++++
 drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile              |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c          |  3 ++-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c              |  3 +--
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c              |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c            |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c              |  2 +-
 drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h             |  2 +-
 drivers/staging/imx-drm/Kconfig                               | 11 +----------
 drivers/staging/imx-drm/Makefile                              |  1 -
 drivers/staging/imx-drm/imx-drm.h                             |  4 ----
 drivers/staging/imx-drm/imx-tve.c                             |  1 +
 drivers/staging/imx-drm/ipuv3-crtc.c                          |  2 +-
 drivers/staging/imx-drm/ipuv3-plane.c                         |  2 +-
 drivers/video/Kconfig                                         |  1 +
 .../staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h     |  2 ++
 17 files changed, 23 insertions(+), 25 deletions(-)
 create mode 100644 drivers/gpu/ipu-v3/Kconfig
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile (59%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c (99%)
 rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h (99%)
 rename {drivers/staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h (99%)

diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index d8a22c2..70da9eb 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1,2 +1,3 @@
 obj-y			+= drm/ vga/
 obj-$(CONFIG_TEGRA_HOST1X)	+= host1x/
+obj-$(CONFIG_IMX_IPUV3_CORE)	+= ipu-v3/
diff --git a/drivers/gpu/ipu-v3/Kconfig b/drivers/gpu/ipu-v3/Kconfig
new file mode 100644
index 0000000..2f228a2
--- /dev/null
+++ b/drivers/gpu/ipu-v3/Kconfig
@@ -0,0 +1,7 @@
+config IMX_IPUV3_CORE
+	tristate "IPUv3 core support"
+	depends on SOC_IMX5 || SOC_IMX6Q || SOC_IMX6SL || ARCH_MULTIPLATFORM
+	depends on RESET_CONTROLLER
+	help
+	  Choose this if you have a i.MX5/6 system and want to use the Image
+	  Processing Unit. This option only enables IPU base support.
diff --git a/drivers/staging/imx-drm/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile
similarity index 59%
rename from drivers/staging/imx-drm/ipu-v3/Makefile
rename to drivers/gpu/ipu-v3/Makefile
index 28ed72e..d21cc37 100644
--- a/drivers/staging/imx-drm/ipu-v3/Makefile
+++ b/drivers/gpu/ipu-v3/Makefile
@@ -1,3 +1,3 @@
-obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o
+obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
 imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-common.c
rename to drivers/gpu/ipu-v3/ipu-common.c
index 96b1135..a59cc6c 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -32,7 +32,7 @@
 
 #include <drm/drm_fourcc.h>
 
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 static inline u32 ipu_cm_read(struct ipu_soc *ipu, unsigned offset)
@@ -539,6 +539,7 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 	case V4L2_PIX_FMT_RGB24:
 	case V4L2_PIX_FMT_BGR24:
 	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_BGR666:
 		return IPUV3_COLORSPACE_RGB;
 	default:
 		return IPUV3_COLORSPACE_UNKNOWN;
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/gpu/ipu-v3/ipu-dc.c
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-dc.c
rename to drivers/gpu/ipu-v3/ipu-dc.c
index d0e3bc3..e4c0daf 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
+++ b/drivers/gpu/ipu-v3/ipu-dc.c
@@ -20,8 +20,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 
-#include "../imx-drm.h"
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DC_MAP_CONF_PTR(n)	(0x108 + ((n) & ~0x1) * 2)
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-di.c
rename to drivers/gpu/ipu-v3/ipu-di.c
index 948a49b..3ab5204 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c
+++ b/drivers/gpu/ipu-v3/ipu-di.c
@@ -23,7 +23,7 @@
 #include <linux/clk-provider.h>
 #include <linux/clkdev.h>
 
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 struct ipu_di {
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c b/drivers/gpu/ipu-v3/ipu-dmfc.c
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c
rename to drivers/gpu/ipu-v3/ipu-dmfc.c
index 98070dd..d46de73 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c
+++ b/drivers/gpu/ipu-v3/ipu-dmfc.c
@@ -17,7 +17,7 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DMFC_RD_CHAN		0x0000
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/gpu/ipu-v3/ipu-dp.c
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-dp.c
rename to drivers/gpu/ipu-v3/ipu-dp.c
index 58f87c8..e17fa3f 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c
+++ b/drivers/gpu/ipu-v3/ipu-dp.c
@@ -19,7 +19,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DP_SYNC 0
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/ipu-prv.h
rename to drivers/gpu/ipu-v3/ipu-prv.h
index 4df0050..5cb075f 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h
+++ b/drivers/gpu/ipu-v3/ipu-prv.h
@@ -22,7 +22,7 @@ struct ipu_soc;
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 
-#include "imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 
 #define IPUV3_CHANNEL_CSI0			 0
 #define IPUV3_CHANNEL_CSI1			 1
diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig
index 5032ff7..dba241f 100644
--- a/drivers/staging/imx-drm/Kconfig
+++ b/drivers/staging/imx-drm/Kconfig
@@ -38,18 +38,9 @@ config DRM_IMX_LDB
 	  Choose this to enable the internal LVDS Display Bridge (LDB)
 	  found on i.MX53 and i.MX6 processors.
 
-config DRM_IMX_IPUV3_CORE
-	tristate "IPUv3 core support"
-	depends on DRM_IMX
-	depends on RESET_CONTROLLER
-	help
-	  Choose this if you have a i.MX5/6 system and want
-	  to use the IPU. This option only enables IPU base
-	  support.
-
 config DRM_IMX_IPUV3
 	tristate "DRM Support for i.MX IPUv3"
 	depends on DRM_IMX
-	depends on DRM_IMX_IPUV3_CORE
+	depends on IMX_IPUV3_CORE
 	help
 	  Choose this if you have a i.MX5 or i.MX6 processor.
diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile
index 8742432..4d4a506 100644
--- a/drivers/staging/imx-drm/Makefile
+++ b/drivers/staging/imx-drm/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_DRM_IMX_PARALLEL_DISPLAY) += parallel-display.o
 obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o
 obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 obj-$(CONFIG_DRM_IMX_FB_HELPER) += imx-fbdev.o
-obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/
 
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)	+= imx-ipuv3-crtc.o
diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h
index ae90c9c..6188948 100644
--- a/drivers/staging/imx-drm/imx-drm.h
+++ b/drivers/staging/imx-drm/imx-drm.h
@@ -1,10 +1,6 @@
 #ifndef _IMX_DRM_H_
 #define _IMX_DRM_H_
 
-#include <linux/videodev2.h>
-
-#define IPU_PIX_FMT_GBR24	v4l2_fourcc('G', 'B', 'R', '3')
-
 struct drm_crtc;
 struct drm_connector;
 struct drm_device;
diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c
index 2c44fef..7b668b0 100644
--- a/drivers/staging/imx-drm/imx-tve.c
+++ b/drivers/staging/imx-drm/imx-tve.c
@@ -29,6 +29,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <video/imx-ipu-v3.h>
 
 #include "imx-drm.h"
 
diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c
index ce6ba98..e4d96f2 100644
--- a/drivers/staging/imx-drm/ipuv3-crtc.c
+++ b/drivers/staging/imx-drm/ipuv3-crtc.c
@@ -29,7 +29,7 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include <video/imx-ipu-v3.h>
 #include "imx-drm.h"
 #include "ipuv3-plane.h"
 
diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c
index d97454a..2dde959 100644
--- a/drivers/staging/imx-drm/ipuv3-plane.c
+++ b/drivers/staging/imx-drm/ipuv3-plane.c
@@ -17,7 +17,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include "video/imx-ipu-v3.h"
 #include "ipuv3-plane.h"
 
 #define to_ipu_plane(x)	container_of(x, struct ipu_plane, base)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4f2e1b3..2195ff3 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -20,6 +20,7 @@ source "drivers/char/agp/Kconfig"
 source "drivers/gpu/vga/Kconfig"
 
 source "drivers/gpu/host1x/Kconfig"
+source "drivers/gpu/ipu-v3/Kconfig"
 
 source "drivers/gpu/drm/Kconfig"
 
diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
rename to include/video/imx-ipu-v3.h
index 7b879ac..fb13823 100644
--- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -25,6 +25,8 @@ enum ipuv3_type {
 	IPUV3H,
 };
 
+#define IPU_PIX_FMT_GBR24     v4l2_fourcc('G', 'B', 'R', '3')
+
 /*
  * Bitfield of Display Interface signal polarities.
  */
-- 
1.8.5.1


^ permalink raw reply related

* [RFC PATCH 2/5] gpu: ipu-v3: Add SMFC code
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

The Sensor Multi Fifo Controller (SMFC) is used as a buffer between
the two CSIs (writing simultaneously) and up to four IDMAC channels.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/ipu-v3/Makefile     |  2 +-
 drivers/gpu/ipu-v3/ipu-common.c | 10 +++++
 drivers/gpu/ipu-v3/ipu-prv.h    |  6 +++
 drivers/gpu/ipu-v3/ipu-smfc.c   | 97 +++++++++++++++++++++++++++++++++++++++++
 include/video/imx-ipu-v3.h      |  6 +++
 5 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/ipu-v3/ipu-smfc.c

diff --git a/drivers/gpu/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile
index d21cc37..1887972b 100644
--- a/drivers/gpu/ipu-v3/Makefile
+++ b/drivers/gpu/ipu-v3/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o
+imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o ipu-smfc.o
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index a59cc6c..8f98719 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -876,8 +876,17 @@ static int ipu_submodules_init(struct ipu_soc *ipu,
 		goto err_dp;
 	}
 
+	ret = ipu_smfc_init(ipu, dev, ipu_base +
+			devtype->cm_ofs + IPU_CM_SMFC_REG_OFS);
+	if (ret) {
+		unit = "smfc";
+		goto err_smfc;
+	}
+
 	return 0;
 
+err_smfc:
+	ipu_dp_exit(ipu);
 err_dp:
 	ipu_dmfc_exit(ipu);
 err_dmfc:
@@ -949,6 +958,7 @@ EXPORT_SYMBOL_GPL(ipu_idmac_channel_irq);
 
 static void ipu_submodules_exit(struct ipu_soc *ipu)
 {
+	ipu_smfc_exit(ipu);
 	ipu_dp_exit(ipu);
 	ipu_dmfc_exit(ipu);
 	ipu_dc_exit(ipu);
diff --git a/drivers/gpu/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h
index 5cb075f..acf1811 100644
--- a/drivers/gpu/ipu-v3/ipu-prv.h
+++ b/drivers/gpu/ipu-v3/ipu-prv.h
@@ -151,6 +151,8 @@ struct ipuv3_channel {
 struct ipu_dc_priv;
 struct ipu_dmfc_priv;
 struct ipu_di;
+struct ipu_smfc_priv;
+
 struct ipu_devtype;
 
 struct ipu_soc {
@@ -178,6 +180,7 @@ struct ipu_soc {
 	struct ipu_dp_priv	*dp_priv;
 	struct ipu_dmfc_priv	*dmfc_priv;
 	struct ipu_di		*di_priv[2];
+	struct ipu_smfc_priv	*smfc_priv;
 };
 
 void ipu_srm_dp_sync_update(struct ipu_soc *ipu);
@@ -203,4 +206,7 @@ void ipu_dc_exit(struct ipu_soc *ipu);
 int ipu_cpmem_init(struct ipu_soc *ipu, struct device *dev, unsigned long base);
 void ipu_cpmem_exit(struct ipu_soc *ipu);
 
+int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev, unsigned long base);
+void ipu_smfc_exit(struct ipu_soc *ipu);
+
 #endif				/* __IPU_PRV_H__ */
diff --git a/drivers/gpu/ipu-v3/ipu-smfc.c b/drivers/gpu/ipu-v3/ipu-smfc.c
new file mode 100644
index 0000000..e4f85ad
--- /dev/null
+++ b/drivers/gpu/ipu-v3/ipu-smfc.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#define DEBUG
+#include <linux/export.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/errno.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <video/imx-ipu-v3.h>
+
+#include "ipu-prv.h"
+
+struct ipu_smfc_priv {
+	void __iomem *base;
+	spinlock_t lock;
+};
+
+/*SMFC Registers */
+#define SMFC_MAP	0x0000
+#define SMFC_WMC	0x0004
+#define SMFC_BS		0x0008
+
+int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize)
+{
+	struct ipu_smfc_priv *smfc = ipu->smfc_priv;
+	unsigned long flags;
+	u32 val, shift;
+
+	spin_lock_irqsave(&smfc->lock, flags);
+
+	shift = channel * 4;
+	val = readl(smfc->base + SMFC_BS);
+	val &= ~(0xf << shift);
+	val |= burstsize << shift;
+	writel(val, smfc->base + SMFC_BS);
+
+	spin_unlock_irqrestore(&smfc->lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_smfc_set_burstsize);
+
+int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id)
+{
+	struct ipu_smfc_priv *smfc = ipu->smfc_priv;
+	unsigned long flags;
+	u32 val, shift;
+
+	spin_lock_irqsave(&smfc->lock, flags);
+
+	shift = channel * 3;
+	val = readl(smfc->base + SMFC_MAP);
+	val &= ~(0x7 << shift);
+	val |= ((csi_id << 2) | mipi_id) << shift;
+	writel(val, smfc->base + SMFC_MAP);
+
+	spin_unlock_irqrestore(&smfc->lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_smfc_map_channel);
+
+int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev,
+		  unsigned long base)
+{
+	struct ipu_smfc_priv *smfc;
+
+	smfc = devm_kzalloc(dev, sizeof(*smfc), GFP_KERNEL);
+	if (!smfc)
+		return -ENOMEM;
+
+	ipu->smfc_priv = smfc;
+	spin_lock_init(&smfc->lock);
+
+	smfc->base = devm_ioremap(dev, base, PAGE_SIZE);
+	if (!smfc->base)
+		return -ENOMEM;
+
+	pr_debug("%s: ioremap 0x%08lx -> %p\n", __func__, base, smfc->base);
+
+	return 0;
+}
+
+void ipu_smfc_exit(struct ipu_soc *ipu)
+{
+}
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index fb13823..274da71 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -160,6 +160,12 @@ int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos);
 int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha,
 		bool bg_chan);
 
+/*
+ * IPU Sensor Multiple FIFO Controller (SMFC) functions
+ */
+int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id);
+int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize);
+
 #define IPU_CPMEM_WORD(word, ofs, size) ((((word) * 160 + (ofs)) << 8) | (size))
 
 #define IPU_FIELD_UBO		IPU_CPMEM_WORD(0, 46, 22)
-- 
1.8.5.1


^ permalink raw reply related

* [RFC PATCH 3/5] gpu: ipu-v3: Add ipu_idmac_get_current_buffer function
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

This function returns the currently active buffer (0 or 1)
of a double buffered IDMAC channel. It is to be used by the
CSI driver.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/ipu-v3/ipu-common.c | 9 +++++++++
 include/video/imx-ipu-v3.h      | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 8f98719..29c89f2 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -663,6 +663,15 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask)
 }
 EXPORT_SYMBOL_GPL(ipu_module_disable);
 
+int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned int chno = channel->num;
+
+	return (ipu_cm_read(ipu, IPU_CHA_CUR_BUF(chno)) & idma_mask(chno)) ? 1 : 0;
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer);
+
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
 {
 	struct ipu_soc *ipu = channel->ipu;
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 274da71..78ea31b 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -103,6 +103,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
 
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer);
+int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel);
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
 
 /*
-- 
1.8.5.1


^ permalink raw reply related

* [RFC PATCH 4/5] gpu: ipu-v3: Add CSI and SMFC module enable wrappers
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

IPU_CONF_..._EN bits are implementation details, not to be made public.
Add wrappers around ipu_module_enable/disable, so the CSI V4L2 driver
can enable/disable the CSI and SMFC modules.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/ipu-v3/ipu-common.c | 24 ++++++++++++++++++++++++
 include/video/imx-ipu-v3.h      |  8 ++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 29c89f2..ad2639c 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -663,6 +663,30 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask)
 }
 EXPORT_SYMBOL_GPL(ipu_module_disable);
 
+int ipu_csi_enable(struct ipu_soc *ipu, int csi)
+{
+	return ipu_module_enable(ipu, csi ? IPU_CONF_CSI1_EN : IPU_CONF_CSI0_EN);
+}
+EXPORT_SYMBOL_GPL(ipu_csi_enable);
+
+int ipu_csi_disable(struct ipu_soc *ipu, int csi)
+{
+	return ipu_module_disable(ipu, csi ? IPU_CONF_CSI1_EN : IPU_CONF_CSI0_EN);
+}
+EXPORT_SYMBOL_GPL(ipu_csi_disable);
+
+int ipu_smfc_enable(struct ipu_soc *ipu)
+{
+	return ipu_module_enable(ipu, IPU_CONF_SMFC_EN);
+}
+EXPORT_SYMBOL_GPL(ipu_smfc_enable);
+
+int ipu_smfc_disable(struct ipu_soc *ipu)
+{
+	return ipu_module_disable(ipu, IPU_CONF_SMFC_EN);
+}
+EXPORT_SYMBOL_GPL(ipu_smfc_disable);
+
 int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel)
 {
 	struct ipu_soc *ipu = channel->ipu;
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 78ea31b..767302d 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -162,8 +162,16 @@ int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha,
 		bool bg_chan);
 
 /*
+ * IPU CMOS Sensor Interface (csi) functions
+ */
+int ipu_csi_enable(struct ipu_soc *ipu, int csi);
+int ipu_csi_disable(struct ipu_soc *ipu, int csi);
+
+/*
  * IPU Sensor Multiple FIFO Controller (SMFC) functions
  */
+int ipu_smfc_enable(struct ipu_soc *ipu);
+int ipu_smfc_disable(struct ipu_soc *ipu);
 int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id);
 int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize);
 
-- 
1.8.5.1


^ permalink raw reply related

* [RFC PATCH 5/5] gpu: ipu-v3: Register the CSI modules
From: Philipp Zabel @ 2013-12-20 17:52 UTC (permalink / raw)
  To: linux-fbdev

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/ipu-v3/ipu-common.c | 35 +++++++++++++++++++++++++++++++----
 include/video/imx-ipu-v3.h      |  1 +
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index ad2639c..7535e7a 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -1016,6 +1016,7 @@ static void platform_device_unregister_children(struct platform_device *pdev)
 struct ipu_platform_reg {
 	struct ipu_client_platformdata pdata;
 	const char *name;
+	int reg_offset;
 };
 
 static const struct ipu_platform_reg client_reg[] = {
@@ -1037,13 +1038,29 @@ static const struct ipu_platform_reg client_reg[] = {
 			.dma[1] = -EINVAL,
 		},
 		.name = "imx-ipuv3-crtc",
+	}, {
+		.pdata = {
+			.csi = 0,
+			.dma[0] = IPUV3_CHANNEL_CSI0,
+			.dma[1] = -EINVAL,
+		},
+		.reg_offset = IPU_CM_CSI0_REG_OFS,
+		.name = "imx-ipuv3-camera",
+	}, {
+		.pdata = {
+			.csi = 1,
+			.dma[0] = IPUV3_CHANNEL_CSI1,
+			.dma[1] = -EINVAL,
+		},
+		.reg_offset = IPU_CM_CSI1_REG_OFS,
+		.name = "imx-ipuv3-camera",
 	},
 };
 
 static DEFINE_MUTEX(ipu_client_id_mutex);
 static int ipu_client_id;
 
-static int ipu_add_client_devices(struct ipu_soc *ipu)
+static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 {
 	struct device *dev = ipu->dev;
 	unsigned i;
@@ -1062,11 +1079,21 @@ static int ipu_add_client_devices(struct ipu_soc *ipu)
 		const struct ipu_platform_reg *reg = &client_reg[i];
 		struct ipu_client_platformdata pdata = reg->pdata;
 		struct platform_device *pdev;
+		struct resource res;
 
 		pdata.ipu = ipu_id;
 
-		pdev = platform_device_register_data(dev, reg->name,
-			id++, &pdata, sizeof(pdata));
+		if (reg->reg_offset) {
+			memset(&res, 0, sizeof(res));
+			res.flags = IORESOURCE_MEM;
+			res.start = ipu_base + ipu->devtype->cm_ofs + reg->reg_offset;
+			res.end = res.start + PAGE_SIZE - 1;
+			pdev = platform_device_register_resndata(dev, reg->name,
+				id++, &res, 1, &pdata, sizeof(pdata));
+		} else {
+			pdev = platform_device_register_data(dev, reg->name,
+					id++, &pdata, sizeof(pdata));
+		}
 
 		if (IS_ERR(pdev))
 			goto err_register;
@@ -1262,7 +1289,7 @@ static int ipu_probe(struct platform_device *pdev)
 	if (ret)
 		goto failed_submodules_init;
 
-	ret = ipu_add_client_devices(ipu);
+	ret = ipu_add_client_devices(ipu, ipu_base);
 	if (ret) {
 		dev_err(&pdev->dev, "adding client devices failed with %d\n",
 				ret);
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 767302d..f5448d4 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -331,6 +331,7 @@ static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p,
 };
 
 struct ipu_client_platformdata {
+	int csi;
 	int di;
 	int dc;
 	int dp;
-- 
1.8.5.1


^ permalink raw reply related

* Re: [RFC PATCH 0/5] Move IPUv3 core out of staging, add CSI support
From: Greg Kroah-Hartman @ 2013-12-20 19:12 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387561966-31758-1-git-send-email-p.zabel@pengutronix.de>

On Fri, Dec 20, 2013 at 06:52:41PM +0100, Philipp Zabel wrote:
> Hi,
> 
> this is mostly about the first patch, which moves the IPUv3 core code
> (drivers/staging/imx-drm/ipu-v3) to drivers/gpu. host1x, which
> serves a similar purpose, already sits there.
> The other four patches add the necessary code for CSI and SMFC handling,
> which is used by the V4L2 CSI capture driver.
> 
> Currently this is based on Russell's patch
>     [PATCH 62/64] imx-drm: pass an IPU ID to crtc and core
> 
> I am aware that there are now quite a few other patches in the pipeline
> that touch drivers/staging/imx-drm/ipu-v3/*, so I am happy to rebase this
> (or them) as needed. I'd like to move the core code out of staging so that
> we can start submitting V4L2 code for video capture and scaling / colorspace
> conversion in parallel.

I'd recommend doing the move (if the gpu/drm maintainer agrees) after
3.14-rc1 as then all of my pending patches would be applied and we would
be synced up with everything.

Once this "core" is moved, what is keeping the rest in staging and why
isn't it moving out as well?

thanks,

greg k-h

^ permalink raw reply

* [PATCH] ARM: i.MX: Remove IMX_HAVE_PLATFORM_IMX_FB symbol
From: Alexander Shiyan @ 2013-12-21  7:58 UTC (permalink / raw)
  To: linux-arm-kernel

Symbol IMX_HAVE_PLATFORM_IMX_FB is selected by boards which
use it, so there is no way to compile the FB driver only with
DT configuration. This patch removes this dependency completely.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-imx/Kconfig          | 10 ----------
 arch/arm/mach-imx/devices/Kconfig  |  3 ---
 arch/arm/mach-imx/devices/Makefile |  3 +--
 drivers/video/Kconfig              |  2 +-
 4 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index d511e054..9498878 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -179,7 +179,6 @@ comment "MX21 platforms:"
 
 config MACH_MX21ADS
 	bool "MX21ADS platform"
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_MMC
 	select IMX_HAVE_PLATFORM_MXC_NAND
@@ -196,7 +195,6 @@ config MACH_MX25_3DS
 	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMXDI_RTC
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
@@ -211,7 +209,6 @@ config MACH_EUKREA_CPUIMX25SD
 	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMXDI_RTC
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
@@ -248,7 +245,6 @@ comment "MX27 platforms:"
 
 config MACH_MX27ADS
 	bool "MX27ADS platform"
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_MMC
@@ -281,7 +277,6 @@ choice
 
 config MACH_PCM970_BASEBOARD
 	bool "PHYTEC PCM970 development board"
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_MXC_MMC
 	help
 	  This adds board specific devices that can be found on Phytec's
@@ -326,7 +321,6 @@ choice
 
 config MACH_EUKREA_MBIMX27_BASEBOARD
 	bool "Eukrea MBIMX27 development board"
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_SSI
 	select IMX_HAVE_PLATFORM_IMX_UART
@@ -343,7 +337,6 @@ config MACH_MX27_3DS
 	bool "MX27PDK platform"
 	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_SSI
@@ -389,7 +382,6 @@ config MACH_PCA100
 	bool "Phytec phyCARD-s (pca100)"
 	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_SSI
 	select IMX_HAVE_PLATFORM_IMX_UART
@@ -406,7 +398,6 @@ config MACH_PCA100
 
 config MACH_MXT_TD60
 	bool "Maxtrack i-MXT TD60"
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_MMC
@@ -633,7 +624,6 @@ config MACH_MX35_3DS
 	bool "Support MX35PDK platform"
 	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
-	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_IPU_CORE
diff --git a/arch/arm/mach-imx/devices/Kconfig b/arch/arm/mach-imx/devices/Kconfig
index 68c74fb..99951a6 100644
--- a/arch/arm/mach-imx/devices/Kconfig
+++ b/arch/arm/mach-imx/devices/Kconfig
@@ -25,9 +25,6 @@ config IMX_HAVE_PLATFORM_IMX2_WDT
 config IMX_HAVE_PLATFORM_IMXDI_RTC
 	bool
 
-config IMX_HAVE_PLATFORM_IMX_FB
-	bool
-
 config IMX_HAVE_PLATFORM_IMX_I2C
 	bool
 
diff --git a/arch/arm/mach-imx/devices/Makefile b/arch/arm/mach-imx/devices/Makefile
index 67416fb..ba2642d 100644
--- a/arch/arm/mach-imx/devices/Makefile
+++ b/arch/arm/mach-imx/devices/Makefile
@@ -9,8 +9,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX21_HCD) += platform-imx21-hcd.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX27_CODA) += platform-imx27-coda.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX2_WDT) += platform-imx2-wdt.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMXDI_RTC) += platform-imxdi_rtc.o
-obj-y += platform-imx-dma.o
-obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_FB) += platform-imx-fb.o
+obj-y += platform-imx-dma.o platform-imx-fb.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_KEYPAD) += platform-imx-keypad.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_PATA_IMX) += platform-pata_imx.o
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4f2e1b3..e7d8d88 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -363,7 +363,7 @@ config FB_SA1100
 
 config FB_IMX
 	tristate "Freescale i.MX1/21/25/27 LCD support"
-	depends on FB && IMX_HAVE_PLATFORM_IMX_FB
+	depends on FB && (SOC_IMX1 || SOC_IMX21 || SOC_IMX25 || SOC_IMX27)
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] video: imxfb: Use regulator API with LCD class for powering
From: Alexander Shiyan @ 2013-12-21 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

This patch replaces custom lcd_power() callback with
regulator API over LCD class.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 .../devicetree/bindings/video/fsl,imx-fb.txt       |  1 +
 arch/arm/mach-imx/mach-mx27ads.c                   | 55 +++++++++++++++--
 drivers/video/imxfb.c                              | 71 +++++++++++++++++++---
 include/linux/platform_data/video-imxfb.h          |  1 -
 4 files changed, 114 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/fsl,imx-fb.txt b/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
index 46da08d..e6b1ee9 100644
--- a/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
+++ b/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
@@ -15,6 +15,7 @@ Required nodes:
 	- fsl,pcr: LCDC PCR value
 
 Optional properties:
+- lcd-supply: Regulator for LCD supply voltage.
 - fsl,dmacr: DMA Control Register value. This is optional. By default, the
 	register is not modified as recommended by the datasheet.
 - fsl,lscr1: LCDC Sharp Configuration Register value.
diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c
index 9821b824..a7a4a9c 100644
--- a/arch/arm/mach-imx/mach-mx27ads.c
+++ b/arch/arm/mach-imx/mach-mx27ads.c
@@ -21,6 +21,10 @@
 #include <linux/mtd/physmap.h>
 #include <linux/i2c.h>
 #include <linux/irq.h>
+
+#include <linux/regulator/fixed.h>
+#include <linux/regulator/machine.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
@@ -195,14 +199,58 @@ static const struct imxi2c_platform_data mx27ads_i2c1_data __initconst = {
 static struct i2c_board_info mx27ads_i2c_devices[] = {
 };
 
-void lcd_power(int on)
+static void vgpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-	if (on)
+	if (value)
 		__raw_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_SET_REG);
 	else
 		__raw_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_CLEAR_REG);
 }
 
+static int vgpio_dir_out(struct gpio_chip *chip, unsigned offset, int value)
+{
+	return 0;
+}
+
+#define MX27ADS_LCD_GPIO	(6 * 32)
+
+static struct regulator_consumer_supply mx27ads_lcd_regulator_consumer +	REGULATOR_SUPPLY("lcd", "imx-fb.0");
+
+static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
+	.constraints	= {
+		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
+},
+	.consumer_supplies	= &mx27ads_lcd_regulator_consumer,
+	.num_consumer_supplies	= 1,
+};
+
+static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
+	.supply_name	= "LCD",
+	.microvolts	= 3300000,
+	.gpio		= MX27ADS_LCD_GPIO,
+	.init_data	= &mx27ads_lcd_regulator_init_data,
+};
+
+static void __init mx27ads_regulator_init(void)
+{
+	struct gpio_chip *vchip;
+
+	vchip = kzalloc(sizeof(*vchip), GFP_KERNEL);
+	vchip->owner		= THIS_MODULE;
+	vchip->label		= "LCD";
+	vchip->base		= MX27ADS_LCD_GPIO;
+	vchip->ngpio		= 1;
+	vchip->direction_output	= vgpio_dir_out;
+	vchip->set		= vgpio_set;
+	gpiochip_add(vchip);
+
+	platform_device_register_data(&platform_bus, "reg-fixed-voltage",
+				      PLATFORM_DEVID_AUTO,
+				      &mx27ads_lcd_regulator_pdata,
+				      sizeof(mx27ads_lcd_regulator_pdata));
+}
+
 static struct imx_fb_videomode mx27ads_modes[] = {
 	{
 		.mode = {
@@ -239,8 +287,6 @@ static const struct imx_fb_platform_data mx27ads_fb_data __initconst = {
 	.pwmr		= 0x00A903FF,
 	.lscr1		= 0x00120300,
 	.dmacr		= 0x00020010,
-
-	.lcd_power	= lcd_power,
 };
 
 static int mx27ads_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
@@ -304,6 +350,7 @@ static void __init mx27ads_board_init(void)
 	i2c_register_board_info(1, mx27ads_i2c_devices,
 				ARRAY_SIZE(mx27ads_i2c_devices));
 	imx27_add_imx_i2c(1, &mx27ads_i2c1_data);
+	mx27ads_regulator_init();
 	imx27_add_imx_fb(&mx27ads_fb_data);
 	imx27_add_mxc_mmc(0, &sdhc1_pdata);
 	imx27_add_mxc_mmc(1, &sdhc2_pdata);
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 44ee678..e50b67f 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -30,10 +30,13 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
+#include <linux/lcd.h>
 #include <linux/math64.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
 
+#include <linux/regulator/consumer.h>
+
 #include <video/of_display_timing.h>
 #include <video/of_videomode.h>
 #include <video/videomode.h>
@@ -177,8 +180,9 @@ struct imxfb_info {
 	struct backlight_device *bl;
 #endif
 
-	void (*lcd_power)(int);
 	void (*backlight_power)(int);
+
+	struct regulator	*lcd_pwr;
 };
 
 static struct platform_device_id imxfb_devtype[] = {
@@ -591,8 +595,6 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
 
 	if (fbi->backlight_power)
 		fbi->backlight_power(1);
-	if (fbi->lcd_power)
-		fbi->lcd_power(1);
 }
 
 static void imxfb_disable_controller(struct imxfb_info *fbi)
@@ -604,8 +606,6 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
 
 	if (fbi->backlight_power)
 		fbi->backlight_power(0);
-	if (fbi->lcd_power)
-		fbi->lcd_power(0);
 
 	clk_disable_unprepare(fbi->clk_per);
 	clk_disable_unprepare(fbi->clk_ipg);
@@ -796,7 +796,6 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
 		fbi->lscr1			= pdata->lscr1;
 		fbi->dmacr			= pdata->dmacr;
 		fbi->pwmr			= pdata->pwmr;
-		fbi->lcd_power			= pdata->lcd_power;
 		fbi->backlight_power		= pdata->backlight_power;
 	} else {
 		np = pdev->dev.of_node;
@@ -810,9 +809,6 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
 
 		of_property_read_u32(np, "fsl,dmacr", &fbi->dmacr);
 
-		/* These two function pointers could be used by some specific
-		 * platforms. */
-		fbi->lcd_power = NULL;
 		fbi->backlight_power = NULL;
 	}
 
@@ -856,9 +852,50 @@ static int imxfb_of_read_mode(struct device *dev, struct device_node *np,
 	return 0;
 }
 
+static int imxfb_lcd_check_fb(struct lcd_device *lcddev, struct fb_info *fi)
+{
+	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
+
+	if (!fi || fi->par = fbi)
+		return 1;
+
+	return 0;
+}
+
+static int imxfb_lcd_get_power(struct lcd_device *lcddev)
+{
+	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
+
+	if (!IS_ERR(fbi->lcd_pwr))
+		return regulator_is_enabled(fbi->lcd_pwr);
+
+	return 1;
+}
+
+static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power)
+{
+	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
+
+	if (!IS_ERR(fbi->lcd_pwr)) {
+		if (power)
+			return regulator_enable(fbi->lcd_pwr);
+		else
+			return regulator_disable(fbi->lcd_pwr);
+	}
+
+	return 0;
+}
+
+static struct lcd_ops imxfb_lcd_ops = {
+	.check_fb	= imxfb_lcd_check_fb,
+	.get_power	= imxfb_lcd_get_power,
+	.set_power	= imxfb_lcd_set_power,
+};
+
 static int imxfb_probe(struct platform_device *pdev)
 {
 	struct imxfb_info *fbi;
+	struct lcd_device *lcd;
 	struct fb_info *info;
 	struct imx_fb_platform_data *pdata;
 	struct resource *res;
@@ -1020,6 +1057,19 @@ static int imxfb_probe(struct platform_device *pdev)
 		goto failed_register;
 	}
 
+	fbi->lcd_pwr = devm_regulator_get(&pdev->dev, "lcd");
+	if (IS_ERR(fbi->lcd_pwr) && (PTR_ERR(fbi->lcd_pwr) = -EPROBE_DEFER)) {
+		ret = -EPROBE_DEFER;
+		goto failed_lcd;
+	}
+
+	lcd = devm_lcd_device_register(&pdev->dev, "imxfb-lcd", &pdev->dev, fbi,
+				       &imxfb_lcd_ops);
+	if (IS_ERR(lcd)) {
+		ret = PTR_ERR(lcd);
+		goto failed_lcd;
+	}
+
 	imxfb_enable_controller(fbi);
 	fbi->pdev = pdev;
 #ifdef PWMR_BACKLIGHT_AVAILABLE
@@ -1028,6 +1078,9 @@ static int imxfb_probe(struct platform_device *pdev)
 
 	return 0;
 
+failed_lcd:
+	unregister_framebuffer(info);
+
 failed_register:
 	fb_dealloc_cmap(&info->cmap);
 failed_cmap:
diff --git a/include/linux/platform_data/video-imxfb.h b/include/linux/platform_data/video-imxfb.h
index 9de8f06..8902706 100644
--- a/include/linux/platform_data/video-imxfb.h
+++ b/include/linux/platform_data/video-imxfb.h
@@ -76,7 +76,6 @@ struct imx_fb_platform_data {
 	int (*init)(struct platform_device *);
 	void (*exit)(struct platform_device *);
 
-	void (*lcd_power)(int);
 	void (*backlight_power)(int);
 };
 
-- 
1.8.3.2


^ permalink raw reply related

* How are you doing today
From: adena ouattara @ 2013-12-21 15:03 UTC (permalink / raw)
  To: linux-fbdev

Hello
How are you doing today ,my name is miss Adena, to be brief i am seeking for
long-team relationship / business partnership and after reading your profile i became 
interested in you and i will like to know more about you if you don't mine,please 
contact me back through my email address so that i will tell you more about 
my self and send you some of my picture,thanks as i wait to hear from you soonest 
Yours new friends
Miss Adena.
adenaouattara2@hotmail.com

^ permalink raw reply

* Re: [RFC PATCH 1/5] gpu: ipu-v3: Move i.MX IPUv3 core driver out of staging
From: Geert Uytterhoeven @ 2013-12-21 19:09 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1387561966-31758-2-git-send-email-p.zabel@pengutronix.de>

On Fri, Dec 20, 2013 at 6:52 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> The i.MX Image Processing Unit (IPU) contains a number of image processing
> blocks that sit right in the middle between DRM and V4L2. Some of the modules,
> such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS
> Sensor Interface (CSI) and their FIFOs could be assigned to either framework,
> but others, such as the dma controller (IDMAC) and image converter (IC) can
> be used by both.
> The IPUv3 core driver provides an internal API to access the modules, to be
> used by both DRM and V4L2 IPUv3 drivers.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/Makefile                                          |  1 +
>  drivers/gpu/ipu-v3/Kconfig                                    |  7 +++++++
>  drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile              |  2 +-
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c          |  3 ++-
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c              |  3 +--
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c              |  2 +-
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c            |  2 +-
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c              |  2 +-
>  drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h             |  2 +-

The posted diff only shows the changes made during the move.

Has the actual code been reviewed here?
If not, please post it here (e.g. diff against /dev/null).
If yes, please ignore my comments.

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* [PATCH 1/2] drm/panel: Add support for Samsung LTN101NT05 panel
From: Marc Dietrich @ 2013-12-21 20:38 UTC (permalink / raw)
  To: linux-fbdev
  Cc: Thierry Reding, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Marc Dietrich,
	linux-fbdev-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, David Airlie

The Samsung LNT101NT05 10.1" WXVGA panel can be supported by the simple panel
driver.

Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Marc Dietrich <marvin24@gmx.de>
---
This isn't strickly required to get the panel up, but Thierry suggested on IRC to
include it anyway, in case someone else has some use for it.

 .../bindings/panel/samsung,ltn101nt05.txt          |    7 +++++
 drivers/gpu/drm/panel/panel-simple.c               |   27 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/panel/samsung,ltn101nt05.txt

diff --git a/Documentation/devicetree/bindings/panel/samsung,ltn101nt05.txt b/Documentation/devicetree/bindings/panel/samsung,ltn101nt05.txt
new file mode 100644
index 0000000..ef522c6
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/samsung,ltn101nt05.txt
@@ -0,0 +1,7 @@
+Samsung Electronics 10.1" WSVGA TFT LCD panel
+
+Required properties:
+- compatible: should be "samsung,ltn101nt05"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index 3e611af..7f9ddb5 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -338,6 +338,28 @@ static const struct panel_desc chunghwa_claa101wb01 = {
 	},
 };
 
+static const struct drm_display_mode samsung_ltn101nt05_mode = {
+	.clock = 54030,
+	.hdisplay = 1024,
+	.hsync_start = 1024 + 24,
+	.hsync_end = 1024 + 24 + 136,
+	.htotal = 1024 + 24 + 136 + 160,
+	.vdisplay = 600,
+	.vsync_start = 600 + 3,
+	.vsync_end = 600 + 3 + 6,
+	.vtotal = 600 + 3 + 6 + 61,
+	.vrefresh = 60,
+};
+
+static const struct panel_desc samsung_ltn101nt05 = {
+	.modes = &samsung_ltn101nt05_mode,
+	.num_modes = 1,
+	.size = {
+		.width = 1024,
+		.height = 600,
+	},
+};
+
 static const struct of_device_id platform_of_match[] = {
 	{
 		.compatible = "auo,b101aw03",
@@ -346,6 +368,9 @@ static const struct of_device_id platform_of_match[] = {
 		.compatible = "chunghwa,claa101wb01",
 		.data = &chunghwa_claa101wb01
 	}, {
+		.compatible = "samsung,ltn101nt05",
+		.data = &samsung_ltn101nt05,
+	}, {
 		.compatible = "simple-panel",
 	}, {
 		/* sentinel */
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH] ARM: i.MX: Remove IMX_HAVE_PLATFORM_IMX_FB symbol
From: Shawn Guo @ 2013-12-23  8:15 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1387612703-18512-1-git-send-email-shc_work@mail.ru>

On Sat, Dec 21, 2013 at 11:58:23AM +0400, Alexander Shiyan wrote:
<snip>
> @@ -9,8 +9,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX21_HCD) += platform-imx21-hcd.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX27_CODA) += platform-imx27-coda.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX2_WDT) += platform-imx2-wdt.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMXDI_RTC) += platform-imxdi_rtc.o
> -obj-y += platform-imx-dma.o
> -obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_FB) += platform-imx-fb.o
> +obj-y += platform-imx-dma.o platform-imx-fb.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_KEYPAD) += platform-imx-keypad.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_PATA_IMX) += platform-pata_imx.o
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 4f2e1b3..e7d8d88 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -363,7 +363,7 @@ config FB_SA1100
>  
>  config FB_IMX
>  	tristate "Freescale i.MX1/21/25/27 LCD support"
> -	depends on FB && IMX_HAVE_PLATFORM_IMX_FB
> +	depends on FB && (SOC_IMX1 || SOC_IMX21 || SOC_IMX25 || SOC_IMX27)

Denis had a patch below to address the same problem.

http://thread.gmane.org/gmane.linux.drivers.devicetree/49472

In this way, we can still have IMX_HAVE_PLATFORM_IMX_FB to control the
build of platform-imx-fb.o.

Shawn 

>  	select FB_CFB_FILLRECT
>  	select FB_CFB_COPYAREA
>  	select FB_CFB_IMAGEBLIT
> -- 
> 1.8.3.2
> 


^ permalink raw reply

* Re: [PATCH] video: imxfb: Use regulator API with LCD class for powering
From: Shawn Guo @ 2013-12-23  8:21 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1387624080-15312-1-git-send-email-shc_work@mail.ru>

On Sat, Dec 21, 2013 at 03:08:00PM +0400, Alexander Shiyan wrote:
> This patch replaces custom lcd_power() callback with
> regulator API over LCD class.

FYI.  Denis' effort on this already goes to v13.

http://thread.gmane.org/gmane.linux.ports.arm.kernel/285326

Shawn

> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  .../devicetree/bindings/video/fsl,imx-fb.txt       |  1 +
>  arch/arm/mach-imx/mach-mx27ads.c                   | 55 +++++++++++++++--
>  drivers/video/imxfb.c                              | 71 +++++++++++++++++++---
>  include/linux/platform_data/video-imxfb.h          |  1 -
>  4 files changed, 114 insertions(+), 14 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/video/fsl,imx-fb.txt b/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
> index 46da08d..e6b1ee9 100644
> --- a/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
> +++ b/Documentation/devicetree/bindings/video/fsl,imx-fb.txt
> @@ -15,6 +15,7 @@ Required nodes:
>  	- fsl,pcr: LCDC PCR value
>  
>  Optional properties:
> +- lcd-supply: Regulator for LCD supply voltage.
>  - fsl,dmacr: DMA Control Register value. This is optional. By default, the
>  	register is not modified as recommended by the datasheet.
>  - fsl,lscr1: LCDC Sharp Configuration Register value.
> diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c
> index 9821b824..a7a4a9c 100644
> --- a/arch/arm/mach-imx/mach-mx27ads.c
> +++ b/arch/arm/mach-imx/mach-mx27ads.c
> @@ -21,6 +21,10 @@
>  #include <linux/mtd/physmap.h>
>  #include <linux/i2c.h>
>  #include <linux/irq.h>
> +
> +#include <linux/regulator/fixed.h>
> +#include <linux/regulator/machine.h>
> +
>  #include <asm/mach-types.h>
>  #include <asm/mach/arch.h>
>  #include <asm/mach/time.h>
> @@ -195,14 +199,58 @@ static const struct imxi2c_platform_data mx27ads_i2c1_data __initconst = {
>  static struct i2c_board_info mx27ads_i2c_devices[] = {
>  };
>  
> -void lcd_power(int on)
> +static void vgpio_set(struct gpio_chip *chip, unsigned offset, int value)
>  {
> -	if (on)
> +	if (value)
>  		__raw_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_SET_REG);
>  	else
>  		__raw_writew(PBC_BCTRL1_LCDON, PBC_BCTRL1_CLEAR_REG);
>  }
>  
> +static int vgpio_dir_out(struct gpio_chip *chip, unsigned offset, int value)
> +{
> +	return 0;
> +}
> +
> +#define MX27ADS_LCD_GPIO	(6 * 32)
> +
> +static struct regulator_consumer_supply mx27ads_lcd_regulator_consumer > +	REGULATOR_SUPPLY("lcd", "imx-fb.0");
> +
> +static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
> +	.constraints	= {
> +		.valid_ops_mask	= REGULATOR_CHANGE_STATUS,
> +},
> +	.consumer_supplies	= &mx27ads_lcd_regulator_consumer,
> +	.num_consumer_supplies	= 1,
> +};
> +
> +static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
> +	.supply_name	= "LCD",
> +	.microvolts	= 3300000,
> +	.gpio		= MX27ADS_LCD_GPIO,
> +	.init_data	= &mx27ads_lcd_regulator_init_data,
> +};
> +
> +static void __init mx27ads_regulator_init(void)
> +{
> +	struct gpio_chip *vchip;
> +
> +	vchip = kzalloc(sizeof(*vchip), GFP_KERNEL);
> +	vchip->owner		= THIS_MODULE;
> +	vchip->label		= "LCD";
> +	vchip->base		= MX27ADS_LCD_GPIO;
> +	vchip->ngpio		= 1;
> +	vchip->direction_output	= vgpio_dir_out;
> +	vchip->set		= vgpio_set;
> +	gpiochip_add(vchip);
> +
> +	platform_device_register_data(&platform_bus, "reg-fixed-voltage",
> +				      PLATFORM_DEVID_AUTO,
> +				      &mx27ads_lcd_regulator_pdata,
> +				      sizeof(mx27ads_lcd_regulator_pdata));
> +}
> +
>  static struct imx_fb_videomode mx27ads_modes[] = {
>  	{
>  		.mode = {
> @@ -239,8 +287,6 @@ static const struct imx_fb_platform_data mx27ads_fb_data __initconst = {
>  	.pwmr		= 0x00A903FF,
>  	.lscr1		= 0x00120300,
>  	.dmacr		= 0x00020010,
> -
> -	.lcd_power	= lcd_power,
>  };
>  
>  static int mx27ads_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
> @@ -304,6 +350,7 @@ static void __init mx27ads_board_init(void)
>  	i2c_register_board_info(1, mx27ads_i2c_devices,
>  				ARRAY_SIZE(mx27ads_i2c_devices));
>  	imx27_add_imx_i2c(1, &mx27ads_i2c1_data);
> +	mx27ads_regulator_init();
>  	imx27_add_imx_fb(&mx27ads_fb_data);
>  	imx27_add_mxc_mmc(0, &sdhc1_pdata);
>  	imx27_add_mxc_mmc(1, &sdhc2_pdata);
> diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
> index 44ee678..e50b67f 100644
> --- a/drivers/video/imxfb.c
> +++ b/drivers/video/imxfb.c
> @@ -30,10 +30,13 @@
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/io.h>
> +#include <linux/lcd.h>
>  #include <linux/math64.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  
> +#include <linux/regulator/consumer.h>
> +
>  #include <video/of_display_timing.h>
>  #include <video/of_videomode.h>
>  #include <video/videomode.h>
> @@ -177,8 +180,9 @@ struct imxfb_info {
>  	struct backlight_device *bl;
>  #endif
>  
> -	void (*lcd_power)(int);
>  	void (*backlight_power)(int);
> +
> +	struct regulator	*lcd_pwr;
>  };
>  
>  static struct platform_device_id imxfb_devtype[] = {
> @@ -591,8 +595,6 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
>  
>  	if (fbi->backlight_power)
>  		fbi->backlight_power(1);
> -	if (fbi->lcd_power)
> -		fbi->lcd_power(1);
>  }
>  
>  static void imxfb_disable_controller(struct imxfb_info *fbi)
> @@ -604,8 +606,6 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
>  
>  	if (fbi->backlight_power)
>  		fbi->backlight_power(0);
> -	if (fbi->lcd_power)
> -		fbi->lcd_power(0);
>  
>  	clk_disable_unprepare(fbi->clk_per);
>  	clk_disable_unprepare(fbi->clk_ipg);
> @@ -796,7 +796,6 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
>  		fbi->lscr1			= pdata->lscr1;
>  		fbi->dmacr			= pdata->dmacr;
>  		fbi->pwmr			= pdata->pwmr;
> -		fbi->lcd_power			= pdata->lcd_power;
>  		fbi->backlight_power		= pdata->backlight_power;
>  	} else {
>  		np = pdev->dev.of_node;
> @@ -810,9 +809,6 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
>  
>  		of_property_read_u32(np, "fsl,dmacr", &fbi->dmacr);
>  
> -		/* These two function pointers could be used by some specific
> -		 * platforms. */
> -		fbi->lcd_power = NULL;
>  		fbi->backlight_power = NULL;
>  	}
>  
> @@ -856,9 +852,50 @@ static int imxfb_of_read_mode(struct device *dev, struct device_node *np,
>  	return 0;
>  }
>  
> +static int imxfb_lcd_check_fb(struct lcd_device *lcddev, struct fb_info *fi)
> +{
> +	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
> +
> +	if (!fi || fi->par = fbi)
> +		return 1;
> +
> +	return 0;
> +}
> +
> +static int imxfb_lcd_get_power(struct lcd_device *lcddev)
> +{
> +	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
> +
> +	if (!IS_ERR(fbi->lcd_pwr))
> +		return regulator_is_enabled(fbi->lcd_pwr);
> +
> +	return 1;
> +}
> +
> +static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power)
> +{
> +	struct imxfb_info *fbi = dev_get_drvdata(&lcddev->dev);
> +
> +	if (!IS_ERR(fbi->lcd_pwr)) {
> +		if (power)
> +			return regulator_enable(fbi->lcd_pwr);
> +		else
> +			return regulator_disable(fbi->lcd_pwr);
> +	}
> +
> +	return 0;
> +}
> +
> +static struct lcd_ops imxfb_lcd_ops = {
> +	.check_fb	= imxfb_lcd_check_fb,
> +	.get_power	= imxfb_lcd_get_power,
> +	.set_power	= imxfb_lcd_set_power,
> +};
> +
>  static int imxfb_probe(struct platform_device *pdev)
>  {
>  	struct imxfb_info *fbi;
> +	struct lcd_device *lcd;
>  	struct fb_info *info;
>  	struct imx_fb_platform_data *pdata;
>  	struct resource *res;
> @@ -1020,6 +1057,19 @@ static int imxfb_probe(struct platform_device *pdev)
>  		goto failed_register;
>  	}
>  
> +	fbi->lcd_pwr = devm_regulator_get(&pdev->dev, "lcd");
> +	if (IS_ERR(fbi->lcd_pwr) && (PTR_ERR(fbi->lcd_pwr) = -EPROBE_DEFER)) {
> +		ret = -EPROBE_DEFER;
> +		goto failed_lcd;
> +	}
> +
> +	lcd = devm_lcd_device_register(&pdev->dev, "imxfb-lcd", &pdev->dev, fbi,
> +				       &imxfb_lcd_ops);
> +	if (IS_ERR(lcd)) {
> +		ret = PTR_ERR(lcd);
> +		goto failed_lcd;
> +	}
> +
>  	imxfb_enable_controller(fbi);
>  	fbi->pdev = pdev;
>  #ifdef PWMR_BACKLIGHT_AVAILABLE
> @@ -1028,6 +1078,9 @@ static int imxfb_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> +failed_lcd:
> +	unregister_framebuffer(info);
> +
>  failed_register:
>  	fb_dealloc_cmap(&info->cmap);
>  failed_cmap:
> diff --git a/include/linux/platform_data/video-imxfb.h b/include/linux/platform_data/video-imxfb.h
> index 9de8f06..8902706 100644
> --- a/include/linux/platform_data/video-imxfb.h
> +++ b/include/linux/platform_data/video-imxfb.h
> @@ -76,7 +76,6 @@ struct imx_fb_platform_data {
>  	int (*init)(struct platform_device *);
>  	void (*exit)(struct platform_device *);
>  
> -	void (*lcd_power)(int);
>  	void (*backlight_power)(int);
>  };
>  
> -- 
> 1.8.3.2
> 


^ permalink raw reply

* Re: [PATCH] video: imxfb: Use regulator API w =?UTF-8?B?aXRoIExDRCBjbGFzc
From: Alexander Shiyan @ 2013-12-23  8:24 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20131223082107.GF26070@S2101-09.ap.freescale.net>

PiBPbiBTYXQsIERlYyAyMSwgMjAxMyBhdCAwMzowODowMFBNICswNDAwLCBBbGV4YW5kZXIgU2hp
eWFuIHdyb3RlOgo+ID4gVGhpcyBwYXRjaCByZXBsYWNlcyBjdXN0b20gbGNkX3Bvd2VyKCkgY2Fs
bGJhY2sgd2l0aAo+ID4gcmVndWxhdG9yIEFQSSBvdmVyIExDRCBjbGFzcy4KPiAKPiBGWUkuICBE
ZW5pcycgZWZmb3J0IG9uIHRoaXMgYWxyZWFkeSBnb2VzIHRvIHYxMy4KPiAKPiBodHRwOi8vdGhy
ZWFkLmdtYW5lLm9yZy9nbWFuZS5saW51eC5wb3J0cy5hcm0ua2VybmVsLzI4NTMyNgoKSG1tLCBP
SywgYnV0IGhhdmluZyBMQ0QgY2xhc3MgY291bGQgcmVzb2x2ZSBvdXIgcHJvYmxlbXMgd2l0aCBj
b250cmFzdCBjb250cm9sLgpodHRwczovL3d3dy5tYWlsLWFyY2hpdmUuY29tL2RldmljZXRyZWVA
dmdlci5rZXJuZWwub3JnL21zZzA3NjYwLmh0bWwKCi0tLQo

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox