Skip to contentSkip to conversation

Rework MPC5121 DIU support (for 2.6.36)

PATCH In review Anatolij Gustschin 8 participants 21 messages Jul 23, 2010 – Dec 16, 2011 5 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Anatolij Gustschin

author maintainer
#0 lore raw

v4 cover Rework MPC5121 DIU support (for 2.6.36)

Support for MPC5121 DIU in mainline kernel is currently brocken. The intention of this patch series is to provide working 5121 DIU support in v2.6.36.

This patch series rework DIU support patches submitted previously. Comments to the previos patch series have been addressed, not related changes are dropped and some changes are split out to separate patches to simplify review. Furthermore a patch has been added to support setting display mode using EDID block in the device tree.

v4 series is rebased to apply on current tree. Timur did some testing of patches from previous version to ensure that these do not break DIU support for MPC8610 HPCD. He then has send his Acked-by, so I added it to the related patches.

The first patch is changed to provide another complete workaround to the observed issue as suggested by Freescale technical support.

Anatolij Gustschin (5):
fsl-diu-fb: fix issue with re-enabling DIU area descriptor
fsl-diu-fb: move fsl-diu-fb.h to include/linux powerpc/mpc5121: shared DIU framebuffer support
powerpc: doc/dts-bindings: update doc of FSL DIU bindings
fsl-diu-fb: Support setting display mode using EDID

 Documentation/powerpc/dts-bindings/fsl/diu.txt |   20 ++-
 arch/powerpc/include/asm/mpc5121.h             |   32 +++
 arch/powerpc/platforms/512x/mpc5121_ads.c      |    2 +
 arch/powerpc/platforms/512x/mpc5121_generic.c  |    2 +
 arch/powerpc/platforms/512x/mpc512x.h          |    2 +
 arch/powerpc/platforms/512x/mpc512x_shared.c   |  284 ++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_soc.h                  |    1 +
 drivers/video/Kconfig                          |    1 +
 drivers/video/fsl-diu-fb.c                     |  137 ++++++++++--
 {drivers/video => include/linux}/fsl-diu-fb.h  |    0
 10 files changed, 455 insertions(+), 26 deletions(-)
 rename {drivers/video => include/linux}/fsl-diu-fb.h (100%)
author maintainer
#1 lore raw

PATCH v4 1/5 fsl-diu-fb: fix issue with re-enabling DIU area descriptor

On MPC5121e Rev 2.0 re-configuring the DIU area descriptor by writing new descriptor address doesn't always work. As a result, DIU continues to display using old area descriptor even if the new one has been written to the descriptor register of the plane.

Add the code from Freescale MPC5121EADS BSP for writing descriptor addresses properly. This fixes the problem for Rev 2.0 silicon.

---
v4:
- use workaround code as suggested by FSL technical support.

v3:
- no changes since v1

 drivers/video/fsl-diu-fb.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)
drivers/video/fsl-diu-fb.c +23 -15
index 27455ce..9b8c991 100644
@@ -317,6 +317,17 @@ static void fsl_diu_free(void *virt, size_t size)
 		free_pages_exact(virt, size);
 }
 
+/*
+ * Workaround for failed writing desc register of planes.
+ * Needed with MPC5121 DIU rev 2.0 silicon.
+ */
+void wr_reg_wa(u32 *reg, u32 val)
+{
+	do {
+		out_be32(reg, val);
+	} while (in_be32(reg) != val);
+}
+
 static int fsl_diu_enable_panel(struct fb_info *info)
 {
 	struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
@@ -330,7 +341,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
 		switch (mfbi->index) {
 		case 0:				/* plane 0 */
 			if (hw->desc[0] != ad->paddr)
-				out_be32(&hw->desc[0], ad->paddr);
+				wr_reg_wa(&hw->desc[0], ad->paddr);
 			break;
 		case 1:				/* plane 1 AOI 0 */
 			cmfbi = machine_data->fsl_diu_info[2]->par;
@@ -340,7 +351,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
 						cpu_to_le32(cmfbi->ad->paddr);
 				else
 					ad->next_ad = 0;
-				out_be32(&hw->desc[1], ad->paddr);
+				wr_reg_wa(&hw->desc[1], ad->paddr);
 			}
 			break;
 		case 3:				/* plane 2 AOI 0 */
@@ -351,14 +362,14 @@ static int fsl_diu_enable_panel(struct fb_info *info)
 						cpu_to_le32(cmfbi->ad->paddr);
 				else
 					ad->next_ad = 0;
-				out_be32(&hw->desc[2], ad->paddr);
+				wr_reg_wa(&hw->desc[2], ad->paddr);
 			}
 			break;
 		case 2:				/* plane 1 AOI 1 */
 			pmfbi = machine_data->fsl_diu_info[1]->par;
 			ad->next_ad = 0;
 			if (hw->desc[1] == machine_data->dummy_ad->paddr)
-				out_be32(&hw->desc[1], ad->paddr);
+				wr_reg_wa(&hw->desc[1], ad->paddr);
 			else					/* AOI0 open */
 				pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
 			break;
@@ -366,7 +377,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
 			pmfbi = machine_data->fsl_diu_info[3]->par;
 			ad->next_ad = 0;
 			if (hw->desc[2] == machine_data->dummy_ad->paddr)
-				out_be32(&hw->desc[2], ad->paddr);
+				wr_reg_wa(&hw->desc[2], ad->paddr);
 			else				/* AOI0 was open */
 				pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
 			break;
@@ -390,27 +401,24 @@ static int fsl_diu_disable_panel(struct fb_info *info)
 	switch (mfbi->index) {
 	case 0:					/* plane 0 */
 		if (hw->desc[0] != machine_data->dummy_ad->paddr)
-			out_be32(&hw->desc[0],
-				machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[0], machine_data->dummy_ad->paddr);
 		break;
 	case 1:					/* plane 1 AOI 0 */
 		cmfbi = machine_data->fsl_diu_info[2]->par;
 		if (cmfbi->count > 0)	/* AOI1 is open */
-			out_be32(&hw->desc[1], cmfbi->ad->paddr);
+			wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
 					/* move AOI1 to the first */
 		else			/* AOI1 was closed */
-			out_be32(&hw->desc[1],
-				machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
 					/* close AOI 0 */
 		break;
 	case 3:					/* plane 2 AOI 0 */
 		cmfbi = machine_data->fsl_diu_info[4]->par;
 		if (cmfbi->count > 0)	/* AOI1 is open */
-			out_be32(&hw->desc[2], cmfbi->ad->paddr);
+			wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
 					/* move AOI1 to the first */
 		else			/* AOI1 was closed */
-			out_be32(&hw->desc[2],
-				machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
 					/* close AOI 0 */
 		break;
 	case 2:					/* plane 1 AOI 1 */
@@ -421,7 +429,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
 					/* AOI0 is open, must be the first */
 				pmfbi->ad->next_ad = 0;
 		} else			/* AOI1 is the first in the chain */
-			out_be32(&hw->desc[1], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
 					/* close AOI 1 */
 		break;
 	case 4:					/* plane 2 AOI 1 */
@@ -432,7 +440,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
 				/* AOI0 is open, must be the first */
 				pmfbi->ad->next_ad = 0;
 		} else		/* AOI1 is the first in the chain */
-			out_be32(&hw->desc[2], machine_data->dummy_ad->paddr);
+			wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
 				/* close AOI 1 */
 		break;
 	default:
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH v4 1/5] fsl-diu-fb: fix issue with re-enabling DIU area descriptor

Quoted 28 lines · Anatolij Gustschin

On MPC5121e Rev 2.0 re-configuring the DIU area descriptor by writing new descriptor address doesn't always work. As a result, DIU continues to display using old area descriptor even if the new one has been written to the descriptor register of the plane.

Add the code from Freescale MPC5121EADS BSP for writing descriptor addresses properly. This fixes the problem for Rev 2.0 silicon.

---
v4:
 - use workaround code as suggested by FSL technical support.

v3:
 - no changes since v1

 drivers/video/fsl-diu-fb.c |   38 +++++++++++++++++++++++---------------

 1 files changed, 23 insertions(+), 15 deletions(-)
drivers/video/fsl-diu-fb.c +0 -0
index 27455ce..9b8c991 100644
@@ -317,6 +317,17 @@ static void fsl_diu_free(void *virt, size_t size)
                free_pages_exact(virt, size);
  }
 

drivers/video/fsl-diu-fb.c static void fsl_diu_free(void *virt, size_t size) · line 329

Quoted 10 lines
drivers/video/fsl-diu-fb.c +10 -0
+/*
+ * Workaround for failed writing desc register of planes.
+ * Needed with MPC5121 DIU rev 2.0 silicon.
+ */
+void wr_reg_wa(u32 *reg, u32 val)
+{
+       do {
+               out_be32(reg, val);
+       } while (in_be32(reg) != val);
+}

I'll apply this one, but it looks like a potential problem. What happens if the write never succeeds? The kernel then gets stuck in a forever busy loop. You should look at reworking it.

g.

Quoted 103 lines
drivers/video/fsl-diu-fb.c +1 -0
+
  static int fsl_diu_enable_panel(struct fb_info *info)
  {
        struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
@@ -330,7 +341,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
                switch (mfbi->index) {

               case 0:                         /* plane 0 */ if (hw->desc[0] != ad->paddr)
-                               out_be32(&hw->desc[0], ad->paddr);
+                               wr_reg_wa(&hw->desc[0], ad->paddr); break;
               case 1:                         /* plane 1 AOI 0 */ cmfbi = machine_data->fsl_diu_info[2]->par;

drivers/video/fsl-diu-fb.c +0 -0
@@ -340,7 +351,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
                                                cpu_to_le32(cmfbi->ad->paddr);

                               else
                                       ad->next_ad = 0;
-                               out_be32(&hw->desc[1], ad->paddr);
+                               wr_reg_wa(&hw->desc[1], ad->paddr); }
                       break;
               case 3:                         /* plane 2 AOI 0 */

drivers/video/fsl-diu-fb.c +0 -0
@@ -351,14 +362,14 @@ static int fsl_diu_enable_panel(struct fb_info *info)
                                                cpu_to_le32(cmfbi->ad->paddr);

                               else
                                       ad->next_ad = 0;
-                               out_be32(&hw->desc[2], ad->paddr);
+                               wr_reg_wa(&hw->desc[2], ad->paddr); }
                       break;
               case 2:                         /* plane 1 AOI 1 */ pmfbi = machine_data->fsl_diu_info[1]->par; ad->next_ad = 0;
                       if (hw->desc[1] == machine_data->dummy_ad->paddr)
-                               out_be32(&hw->desc[1], ad->paddr);
+                               wr_reg_wa(&hw->desc[1], ad->paddr); else                                    /* AOI0 open */ pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); break;

drivers/video/fsl-diu-fb.c +1 -1
@@ -366,7 +377,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
                        pmfbi = machine_data->fsl_diu_info[3]->par;
                        ad->next_ad = 0;
                        if (hw->desc[2] == machine_data->dummy_ad->paddr)
-                               out_be32(&hw->desc[2], ad->paddr);
+                               wr_reg_wa(&hw->desc[2], ad->paddr);

                       else                            /* AOI0 was open */ pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); break;

drivers/video/fsl-diu-fb.c +0 -0
@@ -390,27 +401,24 @@ static int fsl_diu_disable_panel(struct fb_info *info)
        switch (mfbi->index) {

       case 0:                                 /* plane 0 */
               if (hw->desc[0] != machine_data->dummy_ad->paddr)
-                       out_be32(&hw->desc[0],
-                               machine_data->dummy_ad->paddr);
+                       wr_reg_wa(&hw->desc[0], machine_data->dummy_ad->paddr); break;
       case 1:                                 /* plane 1 AOI 0 */ cmfbi = machine_data->fsl_diu_info[2]->par;
               if (cmfbi->count > 0)   /* AOI1 is open */
-                       out_be32(&hw->desc[1], cmfbi->ad->paddr);
+                       wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr); /* move AOI1 to the first */ else                    /* AOI1 was closed */
-                       out_be32(&hw->desc[1],
-                               machine_data->dummy_ad->paddr);
+                       wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr); /* close AOI 0 */
               break;
       case 3:                                 /* plane 2 AOI 0 */ cmfbi = machine_data->fsl_diu_info[4]->par;
               if (cmfbi->count > 0)   /* AOI1 is open */
-                       out_be32(&hw->desc[2], cmfbi->ad->paddr);
+                       wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr); /* move AOI1 to the first */ else                    /* AOI1 was closed */
-                       out_be32(&hw->desc[2],
-                               machine_data->dummy_ad->paddr);
+                       wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr); /* close AOI 0 */
               break;
       case 2:                                 /* plane 1 AOI 1 */

drivers/video/fsl-diu-fb.c +1 -1
@@ -421,7 +429,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
                                        /* AOI0 is open, must be the first */
                                pmfbi->ad->next_ad = 0;
                } else                  /* AOI1 is the first in the chain */
-                       out_be32(&hw->desc[1], machine_data->dummy_ad->paddr);
+                       wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
                                        /* close AOI 1 */
                break;

       case 4:                                 /* plane 2 AOI 1 */

drivers/video/fsl-diu-fb.c +1 -1
@@ -432,7 +440,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
                                /* AOI0 is open, must be the first */
                                pmfbi->ad->next_ad = 0;
                } else          /* AOI1 is the first in the chain */
-                       out_be32(&hw->desc[2], machine_data->dummy_ad->paddr);
+                       wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
                                /* close AOI 1 */
                break;

       default:
--
1.7.0.4

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): AANLkTikkLVCxU4ZC_nmUhKTQogUNeQzxOX6KqgZcxiYr-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw

Re: [PATCH v4 1/5] fsl-diu-fb: fix issue with re-enabling DIU area descriptor

On Wed, 28 Jul 2010 01:02:59 -0600
Grant Likely <[email protected]> wrote:
...

Quoted 11 lines
Quoted 11 lines

 drivers/video/fsl-diu-fb.c |   38 +++++++++++++++++++++++---------------

 1 files changed, 23 insertions(+), 15 deletions(-)
drivers/video/fsl-diu-fb.c +0 -0
index 27455ce..9b8c991 100644
@@ -317,6 +317,17 @@ static void fsl_diu_free(void *virt, size_t size)
                free_pages_exact(virt, size);
  }
 
Quoted 14 lines

drivers/video/fsl-diu-fb.c static void fsl_diu_free(void *virt, size_t size) · line 329

Quoted 10 lines
drivers/video/fsl-diu-fb.c +10 -0
+/*
+ * Workaround for failed writing desc register of planes.
+ * Needed with MPC5121 DIU rev 2.0 silicon.
+ */
+void wr_reg_wa(u32 *reg, u32 val)
+{
+       do {
+               out_be32(reg, val);
+       } while (in_be32(reg) != val);
+}

I'll apply this one, but it looks like a potential problem. What happens if the write never succeeds? The kernel then gets stuck in a forever busy loop. You should look at reworking it.

I'll submit an incremental patch that prevents looping forever in the case if the write never succeeds. Thanks!

Anatolij
_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

A message that is not in the archive (sent off-list or not yet received): AANLkTikkLVCxU4ZC_nmUhKTQogUNeQzxOX6KqgZcxiYr__2540.83384429595$1280300644$gmane$org@mail.gmail.com

#6 lore raw

Re: [PATCH v4 1/5] fsl-diu-fb: fix issue with re-enabling DIU area descriptor

Hi Grant,

Quoted 29 lines · Anatolij Gustschin
Quoted 28 lines

On MPC5121e Rev 2.0 re-configuring the DIU area descriptor by writing new descriptor address doesn't always work. As a result, DIU continues to display using old area descriptor even if the new one has been written to the descriptor register of the plane.

Add the code from Freescale MPC5121EADS BSP for writing descriptor addresses properly. This fixes the problem for Rev 2.0 silicon.

---
v4:
 - use workaround code as suggested by FSL technical support.

v3:
 - no changes since v1

 drivers/video/fsl-diu-fb.c |   38 +++++++++++++++++++++++---------------

 1 files changed, 23 insertions(+), 15 deletions(-)
drivers/video/fsl-diu-fb.c +0 -0
index 27455ce..9b8c991 100644
@@ -317,6 +317,17 @@ static void fsl_diu_free(void *virt, size_t size)
                free_pages_exact(virt, size);
  }
 
Quoted 14 lines

drivers/video/fsl-diu-fb.c static void fsl_diu_free(void *virt, size_t size) · line 329

Quoted 10 lines
drivers/video/fsl-diu-fb.c +10 -0
+/*
+ * Workaround for failed writing desc register of planes.
+ * Needed with MPC5121 DIU rev 2.0 silicon.
+ */
+void wr_reg_wa(u32 *reg, u32 val)
+{
+       do {
+               out_be32(reg, val);
+       } while (in_be32(reg) != val);
+}

I'll apply this one, but it looks like a potential problem. What happens if the write never succeeds? The kernel then gets stuck in a forever busy loop. You should look at reworking it.

We would surely like to do this "the correct way(tm)". Unfortunately this commit reflects what we have been told by Freescale support and it fixes a real observed problem. We fail to find a better solution without any insight into the internal workings of the functional block.

Cheers
Detlev

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: [email protected]

author maintainer
#7 lore raw

PATCH v4 2/5 fsl-diu-fb: move fsl-diu-fb.h to include/linux

In reply to Anatolij Gustschin

Some DIU structures will be used in platform code in subsequent MPC5121 DIU patch, so we move this header to be able to include it elsewhere.

---
v4:
- added ack tag

v3:
- no changes since v1

 drivers/video/fsl-diu-fb.c                    |    2 +-
 {drivers/video => include/linux}/fsl-diu-fb.h |    0
 2 files changed, 1 insertions(+), 1 deletions(-)
 rename {drivers/video => include/linux}/fsl-diu-fb.h (100%)
drivers/video/fsl-diu-fb.c +1 -1
index 9b8c991..48905d5 100644
@@ -34,7 +34,7 @@
 #include <linux/of_platform.h>
 
 #include <sysdev/fsl_soc.h>
-#include "fsl-diu-fb.h"
+#include <linux/fsl-diu-fb.h>
 
 /*
  * These parameters give default parameters
include/linux/fsl-diu-fb.h renamed from drivers/video/fsl-diu-fb.h +0 -0
similarity index 100%
rename from drivers/video/fsl-diu-fb.h
rename to include/linux/fsl-diu-fb.h
Signature · 1 line
1.7.0.4
author maintainer
#8 lore raw

PATCH v4 3/5 powerpc/mpc5121: shared DIU framebuffer support

In reply to Anatolij Gustschin

MPC5121 DIU configuration/setup as initialized by the boot loader currently will get lost while booting Linux. As a result displaying the boot splash is not possible through the boot process.

To prevent this we reserve configured DIU frame buffer address range while booting and preserve AOI descriptor and gamma table so that DIU continues displaying through the whole boot process. On first open from user space DIU frame buffer driver releases the reserved frame buffer area and continues to operate as usual.

---
v4:
- rebased to apply on current tree
- added ack tag

v3:
- remove generic wrappers for early_init() and setup_arch() and assign needed callbacks directly as requested by Timur
- add comment explaning the reason for using reserve_bootmem()
- use less confusing name for "speed" variable in mpc512x_set_pixel_clock() and add a comment. Also initialize "err" variable to LONG_MAX.

v1 -> v2:
- use struct for CCM register access, don't use offset macros, so CCM struct definition is added now
- use struct for DIU descriptors access
- simplify code and correct variable types as suggested by Timur

 arch/powerpc/include/asm/mpc5121.h            |   32 +++
 arch/powerpc/platforms/512x/mpc5121_ads.c     |    2 +
 arch/powerpc/platforms/512x/mpc5121_generic.c |    2 +
 arch/powerpc/platforms/512x/mpc512x.h         |    2 +
 arch/powerpc/platforms/512x/mpc512x_shared.c  |  284 +++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_soc.h                 |    1 +
 drivers/video/fsl-diu-fb.c                    |   17 ++-
 7 files changed, 338 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/mpc5121.h +32 -0
index e6a30bb..8c0ab2c 100644
@@ -21,4 +21,36 @@ struct mpc512x_reset_module {
 	u32	rcer;	/* Reset Control Enable Register */
 };
 
+/*
+ * Clock Control Module
+ */
+struct mpc512x_ccm {
+	u32	spmr;	/* System PLL Mode Register */
+	u32	sccr1;	/* System Clock Control Register 1 */
+	u32	sccr2;	/* System Clock Control Register 2 */
+	u32	scfr1;	/* System Clock Frequency Register 1 */
+	u32	scfr2;	/* System Clock Frequency Register 2 */
+	u32	scfr2s;	/* System Clock Frequency Shadow Register 2 */
+	u32	bcr;	/* Bread Crumb Register */
+	u32	p0ccr;	/* PSC0 Clock Control Register */
+	u32	p1ccr;	/* PSC1 CCR */
+	u32	p2ccr;	/* PSC2 CCR */
+	u32	p3ccr;	/* PSC3 CCR */
+	u32	p4ccr;	/* PSC4 CCR */
+	u32	p5ccr;	/* PSC5 CCR */
+	u32	p6ccr;	/* PSC6 CCR */
+	u32	p7ccr;	/* PSC7 CCR */
+	u32	p8ccr;	/* PSC8 CCR */
+	u32	p9ccr;	/* PSC9 CCR */
+	u32	p10ccr;	/* PSC10 CCR */
+	u32	p11ccr;	/* PSC11 CCR */
+	u32	spccr;	/* SPDIF Clock Control Register */
+	u32	cccr;	/* CFM Clock Control Register */
+	u32	dccr;	/* DIU Clock Control Register */
+	u32	m1ccr;	/* MSCAN1 CCR */
+	u32	m2ccr;	/* MSCAN2 CCR */
+	u32	m3ccr;	/* MSCAN3 CCR */
+	u32	m4ccr;	/* MSCAN4 CCR */
+	u8	res[0x98]; /* Reserved */
+};
 #endif /* __ASM_POWERPC_MPC5121_H__ */
arch/powerpc/platforms/512x/mpc5121_ads.c +2 -0
index ee6ae12..dcef6ad 100644
@@ -42,6 +42,7 @@ static void __init mpc5121_ads_setup_arch(void)
 	for_each_compatible_node(np, "pci", "fsl,mpc5121-pci")
 		mpc83xx_add_bridge(np);
 #endif
+	mpc512x_setup_diu();
 }
 
 static void __init mpc5121_ads_init_IRQ(void)
@@ -65,6 +66,7 @@ define_machine(mpc5121_ads) {
 	.probe			= mpc5121_ads_probe,
 	.setup_arch		= mpc5121_ads_setup_arch,
 	.init			= mpc512x_init,
+	.init_early		= mpc512x_init_diu,
 	.init_IRQ		= mpc5121_ads_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
arch/powerpc/platforms/512x/mpc5121_generic.c +2 -0
index a6c0e3a..e487eb0 100644
@@ -52,6 +52,8 @@ define_machine(mpc5121_generic) {
 	.name			= "MPC5121 generic",
 	.probe			= mpc5121_generic_probe,
 	.init			= mpc512x_init,
+	.init_early		= mpc512x_init_diu,
+	.setup_arch		= mpc512x_setup_diu,
 	.init_IRQ		= mpc512x_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
arch/powerpc/platforms/512x/mpc512x.h +2 -0
index b2daca0..1ab6d11 100644
@@ -16,4 +16,6 @@ extern void __init mpc512x_init(void);
 extern int __init mpc5121_clk_init(void);
 void __init mpc512x_declare_of_platform_devices(void);
 extern void mpc512x_restart(char *cmd);
+extern void mpc512x_init_diu(void);
+extern void mpc512x_setup_diu(void);
 #endif				/* __MPC512X_H__ */
arch/powerpc/platforms/512x/mpc512x_shared.c +284 -0

297 lines not on this page · raw message

arch/powerpc/sysdev/fsl_soc.h +1 -0
index 42381bb..5360948 100644
@@ -30,6 +30,7 @@ struct platform_diu_data_ops {
 	void (*set_pixel_clock) (unsigned int pixclock);
 	ssize_t (*show_monitor_port) (int monitor_port, char *buf);
 	int (*set_sysfs_monitor_port) (int val);
+	void (*release_bootmem) (void);
 };
 
 extern struct platform_diu_data_ops diu_ops;
drivers/video/fsl-diu-fb.c +15 -2
index 48905d5..db3e360 100644
@@ -1108,6 +1108,10 @@ static int fsl_diu_open(struct fb_info *info, int user)
 	struct mfb_info *mfbi = info->par;
 	int res = 0;
 
+	/* free boot splash memory on first /dev/fb0 open */
+	if (!mfbi->index && diu_ops.release_bootmem)
+		diu_ops.release_bootmem();
+
 	spin_lock(&diu_lock);
 	mfbi->count++;
 	if (mfbi->count == 1) {
@@ -1435,6 +1439,7 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
 	int ret, i, error = 0;
 	struct resource res;
 	struct fsl_diu_data *machine_data;
+	int diu_mode;
 
 	machine_data = kzalloc(sizeof(struct fsl_diu_data), GFP_KERNEL);
 	if (!machine_data)
@@ -1471,7 +1476,9 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
 		goto error2;
 	}
 
-	out_be32(&dr.diu_reg->diu_mode, 0);		/* disable DIU anyway*/
+	diu_mode = in_be32(&dr.diu_reg->diu_mode);
+	if (diu_mode != MFB_MODE1)
+		out_be32(&dr.diu_reg->diu_mode, 0);	/* disable DIU */
 
 	/* Get the IRQ of the DIU */
 	machine_data->irq = irq_of_parse_and_map(np, 0);
@@ -1519,7 +1526,13 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
 	machine_data->dummy_ad->offset_xyd = 0;
 	machine_data->dummy_ad->next_ad = 0;
 
-	out_be32(&dr.diu_reg->desc[0], machine_data->dummy_ad->paddr);
+	/*
+	 * Let DIU display splash screen if it was pre-initialized
+	 * by the bootloader, set dummy area descriptor otherwise.
+	 */
+	if (diu_mode != MFB_MODE1)
+		out_be32(&dr.diu_reg->desc[0], machine_data->dummy_ad->paddr);
+
 	out_be32(&dr.diu_reg->desc[1], machine_data->dummy_ad->paddr);
 	out_be32(&dr.diu_reg->desc[2], machine_data->dummy_ad->paddr);
 
Signature · 1 line
1.7.0.4
#9 lore raw

Re: [PATCH v4 3/5] powerpc/mpc5121: shared DIU framebuffer support

drivers/video/fsl-diu-fb.c static int __devinit fsl_diu_probe(struct of_device *ofdev, · line 1481

Quoted 8 lines · Anatolij Gustschin
drivers/video/fsl-diu-fb.c +3 -1
@@ -1471,7 +1476,9 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
                goto error2;
        }
 
-       out_be32(&dr.diu_reg->diu_mode, 0);             /* disable DIU anyway*/
+       diu_mode = in_be32(&dr.diu_reg->diu_mode);
+       if (diu_mode != MFB_MODE1)
+               out_be32(&dr.diu_reg->diu_mode, 0);     /* disable DIU */

Anatolij,

I know this patch is old, but I just noticed something odd about it that I need your help with.

In the above snippet, you test for != MFB_MODE1. My understanding is that U-boot only supports modes 0 and 1, never modes 2 or 3. So diu_mode can only ever be 0 or 1. That means that that the above code is equivalent to:

diu_mode = in_be32(&dr.diu_reg->diu_mode);
if (diu_mode = 0)

        out_be32(&dr.diu_reg->diu_mode, 0);     /* disable DIU */

which is silly, because now we're writing 0 to diu_mode only if it's already 0.

Am I missing something?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
author maintainer
#10 lore raw

Re: [PATCH v4 3/5] powerpc/mpc5121: shared DIU framebuffer support

In reply to Anatolij Gustschin
Quoted 21 lines · On Thu, 15 Dec 2011 17:27:53 +0000 Tabi Timur-B04825 <[email protected]>…

drivers/video/fsl-diu-fb.c static int __devinit fsl_diu_probe(struct of_device *ofdev, · line 1481

Quoted 8 lines · Anatolij Gustschin
drivers/video/fsl-diu-fb.c +3 -1
@@ -1471,7 +1476,9 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
                goto error2;
        }
 
-       out_be32(&dr.diu_reg->diu_mode, 0);             /* disable DIU anyway*/
+       diu_mode = in_be32(&dr.diu_reg->diu_mode);
+       if (diu_mode != MFB_MODE1)
+               out_be32(&dr.diu_reg->diu_mode, 0);     /* disable DIU */

Anatolij,

I know this patch is old, but I just noticed something odd about it that I need your help with.

In the above snippet, you test for != MFB_MODE1. My understanding is that U-boot only supports modes 0 and 1, never modes 2 or 3. So diu_mode can only ever be 0 or 1. That means that that the above code is equivalent to:

Quoted 7 lines

diu_mode = in_be32(&dr.diu_reg->diu_mode);
if (diu_mode = 0)

        out_be32(&dr.diu_reg->diu_mode, 0);     /* disable DIU */

which is silly, because now we're writing 0 to diu_mode only if it's already 0.

Am I missing something?

the intention of the above code snippet was:
not to disable DIU if it is in mode 1 (displaying splash screen) and to disable DIU if it is in modes 2, 3 or 4 for some reason.

We cannot guarantee that the DIU is not in these modes. Even if U-Boot didn't set these modes there is still a possibility that such mode is configured. E.g. I've seen U-Boot binary standalone applications for other display controllers initializing the display controller.

But you are right. With this snippet, if the DIU is already disabled, there will be not needed mode register access. So the code should better look like:

diu_mode = in_be32(&dr.diu_reg->diu_mode);
if (diu_mode && diu_mode != MFB_MODE1)

	out_be32(&dr.diu_reg->diu_mode, 0);

Anatolij

#11 lore raw

Re: [PATCH v4 3/5] powerpc/mpc5121: shared DIU framebuffer support

In reply to Anatolij Gustschin
Quoted 5 lines · Anatolij Gustschin

We cannot guarantee that the DIU is not in these modes. Even if U-Boot didn't set these modes there is still a possibility that such mode is configured. E.g. I've seen U-Boot binary standalone applications for other display controllers initializing the display controller.

True, but modes 2 and 3 don't make any sense. 2 is just a color bar, and 3 writes back to memory (which means you need to have a reserved DMA buffer otherwise you'll crash). Have you really seen Linux boot with the DIU in either of these modes?

Quoted 7 lines

But you are right. With this snippet, if the DIU is already disabled, there will be not needed mode register access. So the code should better look like:

diu_mode = in_be32(&dr.diu_reg->diu_mode);
if (diu_mode && diu_mode != MFB_MODE1)

	out_be32(&dr.diu_reg->diu_mode, 0);

Ok. I'm planning on cleaning up the driver so that it does not initialize the DIU until the .open call, and once that's done, I should be able to remove most of the code from your patch.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
author maintainer
#12 lore raw

Re: [PATCH v4 3/5] powerpc/mpc5121: shared DIU framebuffer support

In reply to Anatolij Gustschin
Quoted 8 lines · On Fri, 16 Dec 2011 12:24:49 -0600 Timur Tabi <[email protected]> wrote:
Quoted 5 lines · Anatolij Gustschin

We cannot guarantee that the DIU is not in these modes. Even if U-Boot didn't set these modes there is still a possibility that such mode is configured. E.g. I've seen U-Boot binary standalone applications for other display controllers initializing the display controller.

Quoted 4 lines

True, but modes 2 and 3 don't make any sense. 2 is just a color bar, and 3 writes back to memory (which means you need to have a reserved DMA buffer otherwise you'll crash). Have you really seen Linux boot with the DIU in either of these modes?

No, but it doesn't mean that it is not possible.

Quoted 11 lines
Quoted 7 lines

But you are right. With this snippet, if the DIU is already disabled, there will be not needed mode register access. So the code should better look like:

diu_mode = in_be32(&dr.diu_reg->diu_mode);
if (diu_mode && diu_mode != MFB_MODE1)

	out_be32(&dr.diu_reg->diu_mode, 0);

Ok. I'm planning on cleaning up the driver so that it does not initialize the DIU until the .open call, and once that's done, I should be able to remove most of the code from your patch.

Will DIU splash screen functionality be preserved?

Anatolij

#13 lore raw

Re: [PATCH v4 3/5] powerpc/mpc5121: shared DIU framebuffer support

In reply to Anatolij Gustschin
Quoted 1 line · Anatolij Gustschin

Will DIU splash screen functionality be preserved?

That's the idea. The root cause is that the drive initializes the DIU during the probe, which is too early. It shouldn't touch the hardware until the open. At that point, Linux (X, console, whatever) wants to draw something.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
author maintainer
#14 lore raw

PATCH v4 4/5 powerpc: doc/dts-bindings: update doc of FSL DIU bindings

In reply to Anatolij Gustschin

Update compatible and interrupt properties description. Furthermore an example for the MPC5121 has been added.

---
v4:
- added ack tag

v2 and v3:
- no changes since v1

 Documentation/powerpc/dts-bindings/fsl/diu.txt |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
Documentation/powerpc/dts-bindings/fsl/diu.txt +12 -2
index deb35de..326cddf 100644
@@ -4,10 +4,12 @@ The Freescale DIU is a LCD controller, with proper hardware, it can also
 drive DVI monitors.
 
 Required properties:
-- compatible : should be "fsl-diu".
+- compatible : should be "fsl,diu" or "fsl,mpc5121-diu".
 - reg : should contain at least address and length of the DIU register
   set.
-- Interrupts : one DIU interrupt should be describe here.
+- interrupts : one DIU interrupt should be described here.
+- interrupt-parent : the phandle for the interrupt controller that
+  services interrupts for this device.
 
 Example (MPC8610HPCD):
 	display@2c000 {
@@ -16,3 +18,11 @@ Example (MPC8610HPCD):
 		interrupts = <72 2>;
 		interrupt-parent = <&mpic>;
 	};
+
+Example for MPC5121:
+	display@2100 {
+		compatible = "fsl,mpc5121-diu";
+		reg = <0x2100 0x100>;
+		interrupts = <64 0x8>;
+		interrupt-parent = <&ipic>;
+	};
Signature · 1 line
1.7.0.4
author maintainer
#15 lore raw

PATCH v4 5/5 fsl-diu-fb: Support setting display mode using EDID

In reply to Anatolij Gustschin

Adds support for encoding display mode information in the device tree using verbatim EDID block.

If the EDID entry in the DIU node is present, the driver will build mode database using EDID data and allow setting the display modes from this database. Otherwise display mode will be set using mode entries from driver's internal database as usual.

This patch also updates device tree bindings.

---
v4:
- rebased to apply on current tree
- added ack tag

v3:
- no changes

v1 -> v2:
- fix EDID property to be lower-case
- use u8 * type for EDID block pointer
- simplify "info->monspecs.modedb != NULL" condition test

 Documentation/powerpc/dts-bindings/fsl/diu.txt |    6 ++
 drivers/video/Kconfig                          |    1 +
 drivers/video/fsl-diu-fb.c                     |   80 ++++++++++++++++++++++--
 3 files changed, 81 insertions(+), 6 deletions(-)
Documentation/powerpc/dts-bindings/fsl/diu.txt +6 -0
index 326cddf..b66cb6d 100644
@@ -11,6 +11,11 @@ Required properties:
 - interrupt-parent : the phandle for the interrupt controller that
   services interrupts for this device.
 
+Optional properties:
+- edid : verbatim EDID data block describing attached display.
+  Data from the detailed timing descriptor will be used to
+  program the display controller.
+
 Example (MPC8610HPCD):
 	display@2c000 {
 		compatible = "fsl,diu";
@@ -25,4 +30,5 @@ Example for MPC5121:
 		reg = <0x2100 0x100>;
 		interrupts = <64 0x8>;
 		interrupt-parent = <&ipic>;
+		edid = [edid-data];
 	};
drivers/video/Kconfig +1 -0
index a9f9e5e..c01b648 100644
@@ -1871,6 +1871,7 @@ config FB_MBX_DEBUG
 config FB_FSL_DIU
 	tristate "Freescale DIU framebuffer support"
 	depends on FB && FSL_SOC
+	select FB_MODE_HELPERS
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
drivers/video/fsl-diu-fb.c +74 -6

126 lines not on this page · raw message

Signature · 1 line
1.7.0.4

A message that is not in the archive (sent off-list or not yet received): 1279893639-24333-6-git-send-email-agust-ynQEQJNshbs@public.gmane.org

#17 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 9 lines · Anatolij Gustschin

Adds support for encoding display mode information in the device tree using verbatim EDID block.

If the EDID entry in the DIU node is present, the driver will build mode database using EDID data and allow setting the display modes from this database. Otherwise display mode will be set using mode entries from driver's internal database as usual.

Quoted 5 lines

This patch also updates device tree bindings.

Anatolij,

I know this patch is old, but I'm now getting back to working on the DIU driver. One question I have: why are you reading the EDID data from the device tree? Why not just read it directly from the device using I2C? Who is supposed to put the EDID data into the device tree in the first place?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale

A message that is not in the archive (sent off-list or not yet received): AANLkTin-TL5_TKnyHYtZdixosfqpkPNoarSTC+K4tTUb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#19 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 16 lines · Timur Tabi
Quoted 9 lines · Anatolij Gustschin

Adds support for encoding display mode information in the device tree using verbatim EDID block.

If the EDID entry in the DIU node is present, the driver will build mode database using EDID data and allow setting the display modes from this database. Otherwise display mode will be set using mode entries from driver's internal database as usual.

Quoted 5 lines

This patch also updates device tree bindings.

Quoted 7 lines

Anatolij,

I know this patch is old, but I'm now getting back to working on the DIU driver.  One question I have: why are you reading the EDID data from the device tree?  Why not just read it directly from the device using I2C?  Who is supposed to put the EDID data into the device tree in the first place?

This is for devices which don't have an i2c edid channel.

g.

#20 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 1 line · Grant Likely

This is for devices which don't have an i2c edid channel.

So are we expecting board-specific code in U-Boot to add the data to the device tree?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 5 lines · Timur Tabi
Quoted 1 line · Grant Likely

This is for devices which don't have an i2c edid channel.

So are we expecting board-specific code in U-Boot to add the data to the device tree?

No. It is a static property of the board/machine. It is expected it to be encoded into the board's .dts file.

g.

#23 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 2 lines · Grant Likely

No. It is a static property of the board/machine. It is expected it to be encoded into the board's .dts file.

Ok, but that only makes sense if the monitor is hard-wired to the board itself.
If a user can attach any monitor he wants, then the EDID data can't be known at
compile time.

I guess it's no different than using hard-coded memory controller programming instead of SPD. You can safely avoid SPD only if the DDR chips are soldered on the board.

It looks like I need to add board-specific EDID reading to the DIU driver.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#24 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

Quoted 11 lines · Timur Tabi
Quoted 2 lines · Grant Likely

No.  It is a static property of the board/machine.  It is expected it to be encoded into the board's .dts file.

Ok, but that only makes sense if the monitor is hard-wired to the board itself. If a user can attach any monitor he wants, then the EDID data can't be known at compile time.

I guess it's no different than using hard-coded memory controller programming instead of SPD.  You can safely avoid SPD only if the DDR chips are soldered on the board.

Correct, if a real EDID i2c channel exists, then an edid property should *not* be specified in the device tree.

g.

author maintainer
#25 lore raw

Re: [PATCH v4 5/5] fsl-diu-fb: Support setting display mode using EDID

In reply to Timur Tabi
Quoted 16 lines · On Thu, 16 Dec 2010 10:47:53 -0600 Timur Tabi <[email protected]> wrote:
Quoted 9 lines · Anatolij Gustschin

Adds support for encoding display mode information in the device tree using verbatim EDID block.

If the EDID entry in the DIU node is present, the driver will build mode database using EDID data and allow setting the display modes from this database. Otherwise display mode will be set using mode entries from driver's internal database as usual.

Quoted 5 lines

This patch also updates device tree bindings.

Quoted 7 lines

Anatolij,

I know this patch is old, but I'm now getting back to working on the DIU driver. One question I have: why are you reading the EDID data from the device tree? Why not just read it directly from the device using I2C? Who is supposed to put the EDID data into the device tree in the first place?

Many embedded boards only hard-wire a panel which does not provide an i2c edid channel. For such boards the EDID data can be inserted by the bootloader or encoded in the board's .dts. Look at pdm360ng U-Boot board code, it inserts the EDID data into device tree using fdt_add_edid().

Anatolij