Skip to contentSkip to conversation

Xilinx framebuffer device driver - 2nd version

PATCH In review Andrei Konovalov 3 participants 5 messages Apr 26, 2007 – May 2, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xilinx framebuffer device driver - 2nd version

Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.

---

This patch relies on the "Patchset to establish sanity in Xilinx Virtex support" by Gran Likely to have the frame buffer device registered on the platform bus. Without this patchset one needs to fill in the struct platform_device and make sure platform_device_register() is called elsewhere. The DCR access has been added but not tested - my targets are configured in the "memory mapped IO" way. I would appreciate if those having the video controller registers accessible as DCRs test the DCR mode.

This is the 2nd version that addresses what was pointed out by Arnd and Grant.
Please find the interdiff against the 1st version below, and the whole patch attached to this message Comments are welcome.

Would be nice to get this driver into mainline for the 2.6.22.

Thanks,
Andrei

-----------------------------------------------------------------

drivers/video/Kconfig +10 -0
Index: linux-2.6.20/drivers/video/Kconfig
===================================================================
@@ -1648,6 +1648,16 @@ config FB_XILINX_ROTATE
 	bool "Rotate display"
 	depends on FB_XILINX
 
+config FB_XILINX_SCR_HEIGHT
+	int "Screen height in mm"
+	depends on FB_XILINX
+	default 99
+
+config FB_XILINX_SCR_WIDTH
+	int "Screen width in mm"
+	depends on FB_XILINX
+	default 132
+
 config FB_VIRTUAL
 	tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
 	depends on FB
drivers/video/xilinxfb.c +44 -25

159 lines not on this page · raw message

arch/ppc/syslib/virtex_devices.c +13 -0
Index: linux-2.6.20/arch/ppc/syslib/virtex_devices.c
===================================================================
@@ -90,6 +90,18 @@ struct plat_serial8250_port virtex_seria
 };
 
 
+/* ML300/403 reference design framebuffer driver platform data table */
+static struct xilinxfb_platform_data xilinxfb_pdata = {
+#if defined(XPAR_TFT_0_USE_DCR) && (XPAR_TFT_0_USE_DCR != 0)
+	.use_dcr = 1,
+#else
+	.use_dcr = 0,
+#endif
+	.screen_height_mm = CONFIG_FB_XILINX_SCR_HEIGHT,
+	.screen_width_mm = CONFIG_FB_XILINX_SCR_WIDTH,
+};
+
+
 struct platform_device virtex_platform_devices[] = {
 	/* UARTLITE instances */
 #if defined(XPAR_UARTLITE_0_BASEADDR)
@@ -127,6 +139,7 @@ struct platform_device virtex_platform_d
 	{
 		.name		= "xilinxfb",
 		.id		= 0,
+		.dev.platform_data = &xilinxfb_pdata,
 		.num_resources	= 1,
 		.resource = (struct resource[]) {
 			{
arch/ppc/syslib/virtex_devices.h +7 -0
Index: linux-2.6.20/arch/ppc/syslib/virtex_devices.h
===================================================================
@@ -13,6 +13,13 @@
 
 #include <linux/platform_device.h>
 
+/* ML300/403 reference design framebuffer driver platform data struct */
+struct xilinxfb_platform_data {
+	u32 use_dcr;
+	u32 screen_height_mm;
+	u32 screen_width_mm;
+};
+
 void __init virtex_early_serial_map(void);
 
 /* Prototype for device fixup routine.  Implement this routine in the

Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.

 arch/ppc/syslib/virtex_devices.c |   13 +
 arch/ppc/syslib/virtex_devices.h |    7 
 drivers/video/Kconfig            |   25 ++
 drivers/video/Makefile           |    1 
 drivers/video/xilinxfb.c         |  377 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 423 insertions(+)
drivers/video/Kconfig +25 -0
Index: linux-2.6.20/drivers/video/Kconfig
===================================================================
@@ -1633,6 +1633,31 @@ config FB_PS3_DEFAULT_SIZE_M
 	  The default value can be overridden on the kernel command line
 	  using the "ps3fb" option (e.g. "ps3fb=9M");
 
+config FB_XILINX
+	tristate "Xilinx frame buffer support"
+	depends on FB && XILINX_VIRTEX
+	select FB_CFB_FILLRECT
+	select FB_CFB_COPYAREA
+	select FB_CFB_IMAGEBLIT
+	---help---
+	  Include support for the Xilinx ML300/ML403 reference design
+	  framebuffer. ML300 carries a 640*480 LCD display on the board,
+	  ML403 uses a standard DB15 VGA connector.
+
+config FB_XILINX_ROTATE
+	bool "Rotate display"
+	depends on FB_XILINX
+
+config FB_XILINX_SCR_HEIGHT
+	int "Screen height in mm"
+	depends on FB_XILINX
+	default 99
+
+config FB_XILINX_SCR_WIDTH
+	int "Screen width in mm"
+	depends on FB_XILINX
+	default 132
+
 config FB_VIRTUAL
 	tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
 	depends on FB
drivers/video/Makefile +1 -0
Index: linux-2.6.20/drivers/video/Makefile
===================================================================
@@ -99,6 +99,7 @@ obj-$(CONFIG_FB_PNX4008_DUM_RGB)  += pnx
 obj-$(CONFIG_FB_IBM_GXT4500)	  += gxt4500.o
 obj-$(CONFIG_FB_PS3)		  += ps3fb.o
 obj-$(CONFIG_FB_SM501)            += sm501fb.o
+obj-$(CONFIG_FB_XILINX)           += xilinxfb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_VESA)             += vesafb.o
drivers/video/xilinxfb.c new file +377 -0

377 lines not on this page · raw message

arch/ppc/syslib/virtex_devices.c +13 -0
Index: linux-2.6.20/arch/ppc/syslib/virtex_devices.c
===================================================================
@@ -90,6 +90,18 @@ struct plat_serial8250_port virtex_seria
 };
 
 
+/* ML300/403 reference design framebuffer driver platform data table */
+static struct xilinxfb_platform_data xilinxfb_pdata = {
+#if defined(XPAR_TFT_0_USE_DCR) && (XPAR_TFT_0_USE_DCR != 0)
+	.use_dcr = 1,
+#else
+	.use_dcr = 0,
+#endif
+	.screen_height_mm = CONFIG_FB_XILINX_SCR_HEIGHT,
+	.screen_width_mm = CONFIG_FB_XILINX_SCR_WIDTH,
+};
+
+
 struct platform_device virtex_platform_devices[] = {
 	/* UARTLITE instances */
 #if defined(XPAR_UARTLITE_0_BASEADDR)
@@ -127,6 +139,7 @@ struct platform_device virtex_platform_d
 	{
 		.name		= "xilinxfb",
 		.id		= 0,
+		.dev.platform_data = &xilinxfb_pdata,
 		.num_resources	= 1,
 		.resource = (struct resource[]) {
 			{
arch/ppc/syslib/virtex_devices.h +7 -0
Index: linux-2.6.20/arch/ppc/syslib/virtex_devices.h
===================================================================
@@ -13,6 +13,13 @@
 
 #include <linux/platform_device.h>
 
+/* ML300/403 reference design framebuffer driver platform data struct */
+struct xilinxfb_platform_data {
+	u32 use_dcr;
+	u32 screen_height_mm;
+	u32 screen_width_mm;
+};
+
 void __init virtex_early_serial_map(void);
 
 /* Prototype for device fixup routine.  Implement this routine in the
#1 lore raw

drivers/video/xilinxfb.c struct xilinxfb_drvdata { · line 129

Quoted 13 lines
drivers/video/xilinxfb.c +6 -0
@@ -118,6 +118,12 @@ struct xilinxfb_drvdata {
  #define to_xilinxfb_drvdata(_info) \
  	container_of(_info, struct xilinxfb_drvdata, info)
 
+#define xilinx_fb_out_be32(driverdata, offset, val) \
+	if (driverdata->use_dcr) \
+		mtdcr(driverdata->regs_phys + offset, val); \
+	else \
+		out_be32(driverdata->regs + offset, val)
+
  static int
  xilinx_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
  	unsigned transp, struct fb_info *fbi)

This should probably be an inline function, or use do { ... } while (0) instead, to make it less error-prone, see
http://kernelnewbies.org/FAQ/DoWhile0 for an explanation.

	Arnd <><
#2 lore raw
Quoted 18 lines · Arnd Bergmann

drivers/video/xilinxfb.c struct xilinxfb_drvdata { · line 129

Quoted 13 lines
drivers/video/xilinxfb.c +6 -0
@@ -118,6 +118,12 @@ struct xilinxfb_drvdata {
 #define to_xilinxfb_drvdata(_info) \
 	container_of(_info, struct xilinxfb_drvdata, info)
 
+#define xilinx_fb_out_be32(driverdata, offset, val) \
+	if (driverdata->use_dcr) \
+		mtdcr(driverdata->regs_phys + offset, val); \
+	else \
+		out_be32(driverdata->regs + offset, val)
+
 static int
 xilinx_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
 	unsigned transp, struct fb_info *fbi)

This should probably be an inline function, or use do { ... } while (0) instead, to make it less error-prone, see
http://kernelnewbies.org/FAQ/DoWhile0 for an explanation.

Quoted 1 line
	Arnd <><

xilinx_fb_out_be32 macro doesn't declare local variables, and is a single "line of code" in terms of the web page you've referenced. IOW I can't get an example where this macro would do wrong off the top of my head. Anyway, the do { ... } while (0) is safe and common, so I'll regenerate the patch to use it.

Thanks a lot for reviewing that stuff!

Best regards,
Andrei

#3 lore raw
In reply to Andrei Konovalov
Quoted 13 lines · Andrei Konovalov

Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.

---

This patch relies on the "Patchset to establish sanity in Xilinx Virtex support" by Gran Likely to have the frame buffer device registered on the platform bus. Without this patchset one needs to fill in the struct platform_device and make sure platform_device_register() is called elsewhere. The DCR access has been added but not tested - my targets are configured in the "memory mapped IO" way. I would appreciate if those having the video controller registers accessible as DCRs test the DCR mode.

Quoted 3 lines

This is the 2nd version that addresses what was pointed out by Arnd and Grant.
Please find the interdiff against the 1st version below, and the whole patch attached to this message Comments are welcome.

First off; I'm an idiot. The ml403 ref design *does* use the opb2dcr bridge; and my design *does not* use DCR instructions; so I haven't been able to test direct DCR access. :-) It might just be better to drop the DCR stuff for now until it's accepted into mainline; or someone is able to test it.

I've got it running on my custom board. Seems to work well and it's
more featureful than my driver, so I'll migrate over to using yours. The design that I'm using has a different color map from the ml300 ref design. blue is at offset 0 and red offset 16 (vs. blue-16 and red-0
on the ml300 ref design). It's probably worthwhile to add those
parameters to the xilinxfb_platform_data structure.

Quoted 1 line

Would be nice to get this driver into mainline for the 2.6.22.

I certainly support getting it submitted. Have you emailed it to the linux-fb-devel list?

Can you split the driver and the platform device registration up into 2 patches? It will probably make submission less painful; the device registration patch can go through paulus, and the driver itself through the linux-fbdev-devel list.

Quoted 7 lines

===================================================================

drivers/video/Kconfig +0 -0
@@ -1648,6 +1648,16 @@ config FB_XILINX_ROTATE
        bool "Rotate display"
        depends on FB_XILINX
 

drivers/video/Kconfig config FB_XILINX_ROTATE · line 1660

Quoted 10 lines
drivers/video/Kconfig +10 -0
+config FB_XILINX_SCR_HEIGHT
+       int "Screen height in mm"
+       depends on FB_XILINX
+       default 99
+
+config FB_XILINX_SCR_WIDTH
+       int "Screen width in mm"
+       depends on FB_XILINX
+       default 132
+

I'm not so fond of doing this via KCONFIG options; at least not at the driver level. Also, the board I'm using will have 2 of these cores, each with different display dimesions. For these parameters, I think it makes more sense for the board setup code to override virtex_device_fixup() and insert the correct values into the pdata structure before virtex_init() registers the device. Individual board ports can add Kconfig setting for the dimensions if appropriate for the system.

Cheers,
g.

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#4 lore raw
Quoted 18 lines · Grant Likely
Quoted 13 lines · Andrei Konovalov

Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.

---

This patch relies on the "Patchset to establish sanity in Xilinx Virtex support" by Gran Likely to have the frame buffer device registered on the platform bus. Without this patchset one needs to fill in the struct platform_device and make sure platform_device_register() is called elsewhere. The DCR access has been added but not tested - my targets are configured in the "memory mapped IO" way. I would appreciate if those having the video controller registers accessible as DCRs test the DCR mode.

Quoted 3 lines

This is the 2nd version that addresses what was pointed out by Arnd and Grant.
Please find the interdiff against the 1st version below, and the whole patch attached to this message Comments are welcome.

Quoted 5 lines

First off; I'm an idiot. The ml403 ref design *does* use the opb2dcr bridge; and my design *does not* use DCR instructions; so I haven't been able to test direct DCR access. :-) It might just be better to drop the DCR stuff for now until it's accepted into mainline; or someone is able to test it.

I am inclined to leave the xilinx_fb_out_be32(driverdata, offset, val) macro in the form of:

/*
* The LCD controller has DCR interface to its registers, but all
* the boards and configurations the driver has been tested with
* use opb2dcr bridge. So the registers are seen as memory mapped.
* This macro is to make it simple to add the direct DCR access
* when it's needed.
*/

#define xilinx_fb_out_be32(driverdata, offset, val) \
	out_be32(driverdata->regs + offset, val)
Quoted 6 lines

I've got it running on my custom board. Seems to work well and it's
more featureful than my driver, so I'll migrate over to using yours. The design that I'm using has a different color map from the ml300 ref design. blue is at offset 0 and red offset 16 (vs. blue-16 and red-0
on the ml300 ref design). It's probably worthwhile to add those
parameters to the xilinxfb_platform_data structure.

I've tested the driver with both ML300 and ML403 reference designs, and *both* have blue at offset 0 and red at offset 16. The "PLB TFT LCD Controller" documentation I have doesn't notice any possibility to make the color map different from that.

Quoted 4 lines
Quoted 1 line

Would be nice to get this driver into mainline for the 2.6.22.

I certainly support getting it submitted. Have you emailed it to the linux-fb-devel list?

Not yet.
Not until we settle down on registers access, color map and other hardware related stuff.

Quoted 2 lines

Can you split the driver and the platform device registration up into 2 patches?

Good idea. Will do.

Quoted 22 lines

It will probably make submission less painful; the device registration patch can go through paulus, and the driver itself through the linux-fbdev-devel list.

Quoted 7 lines

===================================================================

drivers/video/Kconfig +0 -0
@@ -1648,6 +1648,16 @@ config FB_XILINX_ROTATE
        bool "Rotate display"
        depends on FB_XILINX
 

drivers/video/Kconfig config FB_XILINX_ROTATE · line 1660

Quoted 10 lines
drivers/video/Kconfig +10 -0
+config FB_XILINX_SCR_HEIGHT
+       int "Screen height in mm"
+       depends on FB_XILINX
+       default 99
+
+config FB_XILINX_SCR_WIDTH
+       int "Screen width in mm"
+       depends on FB_XILINX
+       default 132
+
Quoted 8 lines

I'm not so fond of doing this via KCONFIG options; at least not at the driver level. Also, the board I'm using will have 2 of these cores, each with different display dimesions. For these parameters, I think it makes more sense for the board setup code to override virtex_device_fixup() and insert the correct values into the pdata structure before virtex_init() registers the device. Individual board ports can add Kconfig setting for the dimensions if appropriate for the system.

Will remove these KCONFIG options and add virtex_device_fixup()
to arch/ppc/platforms/4xx/xilinx_ml300.c and arch/ppc/platforms/4xx/xilinx_ml403.c in the new version of the xilinxfb patch (the platform device registration part).

Thanks,
Andrei

Quoted 3 lines

Cheers,
g.