Xilinx framebuffer device driver
Subsystems (2)
PATCH 1/1 Xilinx framebuffer device driver
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.
Reviews and comments are welcome.
Would be nice to get this driver into mainline for the 2.6.22.
Thanks,
Andrei
Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.
drivers/video/Kconfig | 15 + drivers/video/Makefile | 1 drivers/video/xilinxfb.c | 358 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+)
drivers/video/Kconfig +15 -0
@@ -1633,6 +1633,21 @@ 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_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB
drivers/video/Makefile +1 -0
@@ -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 +358 -0
358 lines not on this page · raw message
Quoted 11 lines · Andrei Konovalov
Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.
Signed-off-by Andrei Konovalov <[email protected]>---
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_deviceand make sureplatform_device_register()is called elsewhere.Reviews and comments are welcome.
Thanks, that's great. I've built it into my latest kernel and as soon as I can get the hardware to work I'll test it out. Watch this space :) -- Peter
Signature · 4 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.
Quoted 6 lines · Andrei Konovalov
Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.
Signed-off-by Andrei Konovalov <[email protected]>---
Quoted 7 lines
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_deviceand make sureplatform_device_register()is called elsewhere.Reviews and comments are welcome.
Would be nice to get this driver into mainline for the 2.6.22.
Quick comment on first perusal: The driver uses the out_be32 macro directly for accessing registers, which doesn't work if the FB block is configured for DCR access (like the ML403 reference design). There will need to be a property in the platform device binding to determine how to access registers.
Cheers,
g.
Signature · 4 lines
Grant Likely, B.Sc. P.Eng. Secret Lab Technologies Ltd. [email protected] (403) 399-0195
Quoted 11 lines · Grant Likely
Quoted 10 lines · Andrei Konovalov
Add support for the video controller IP block included into Xilinx ML300 and ML403 reference designs.
Signed-off-by Andrei Konovalov <[email protected]>---
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_deviceand make sureplatform_device_register()is called elsewhere.
Quoted 7 lines
Quoted 3 lines
Reviews and comments are welcome.
Would be nice to get this driver into mainline for the 2.6.22.
Quick comment on first perusal: The driver uses the
out_be32macro directly for accessing registers, which doesn't work if the FB block is configured for DCR access (like the ML403 reference design).
Yes, that's true.
But (at least) the EDK 8.1 reference design for ML403 has also opb2dcr bridge. That's why I've tested the patch without problems on ML403 (in addition to ML300).
I'll add DCR access, but not sure if I need a separate bitstream to test DCR access (could I access the DCR registers directly in presence of the bridge or not).
Quoted 2 lines
There will need to be a property in the platform device binding to determine how to access registers.
OK.
The only problem is that there is no indication in the xparameters.h of how the registers should be accessed (via DCR or opb).
Let's suppose XPAR_TFT_0_USE_DCR would be added by EDK (like XPAR_XINTC_USE_DCR is used for the interrupt controller).
Quoted 3 lines
Cheers,
g.
Thanks,
Andrei
PiAroKCgoKCgoC5hY3RpdmF0ZSA9oKCgoKBGQl9BQ1RJVkFURV9OT1csCj4gK6CgoKCgoKAuaGVp Z2h0ID0goKCgoKCgOTksoKCgoKAvKiBpbiBtbSBvZiBORUMgTkw2NDQ4QkMyMC0wOCBvbiBNTDMw MCAqLwo+ICugoKCgoKCgLndpZHRoID2goKCgoKCgoDEzMqCgoKCgLyogaW4gbW0gb2YgTkVDIE5M NjQ0OEJDMjAtMDggb24gTUwzMDAgKi8KPiArfTsKClRoZSBzaXplIGxvb2tzIHZlcnkgc3BlY2lm aWMgdG8gYSBwYXJ0aWN1bGFyIGRpc3BsYXkgaGFyZHdhcmUuIEkgZ3Vlc3MKd2hlbiB0aGUgZHJp dmVyIGdldHMgY29udmVydGVkIHRvIGFuIG9mX3BsYXRmb3JtX2RyaXZlciwgdGhpcyBzaG91bGQg Y29tZQpmcm9tIHRoZSBkZXZpY2UgdHJlZS4KClVudGlsIHRoZW4sIG1heWJlIGEgY29uZmlnIG9w dGlvbiwgd2l0aCBhIHJlYXNvbmFibGUgZGVmYXVsdCB3b3VsZCBiZQpyaWdodC4KCj4gKwo+ICtz dHJ1Y3QgeGlsaW54ZmJfZHJ2ZGF0YSB7Cj4gKwo+ICugoKCgoKCgc3RydWN0IGZiX2luZm+goGlu Zm87oKCgoKCgoKCgoKAvKiBGQiBkcml2ZXIgaW5mbyByZWNvcmQgKi8KPiArCj4gK6CgoKCgoKB1 bnNpZ25lZCBsb25noKCgcmVnc19waHlzO6CgoKCgoC8qIHBoeXMuIGFkZHJlc3Mgb2YgdGhlIGNv bnRyb2wgcmVnaXN0ZXJzICov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IGlvcmVtYXAocmVnc19yZXMtPnN0YXJ0LCA4KTsKCnUzMiBfX2lvbWVtKgoK CglBcm5kIDw+PAo=
Hi Arnd,
Quoted 11 lines · Arnd Bergmann
drivers/video/xilinxfb.c line 103
Quoted 4 lines
drivers/video/xilinxfb.c new file +4
-0+ .activate = FB_ACTIVATE_NOW, + .height = 99, /* in mm of NEC NL6448BC20-08 on ML300 */ + .width = 132 /* in mm of NEC NL6448BC20-08 on ML300 */ +};The size looks very specific to a particular display hardware. I guess when the driver gets converted to an
of_platform_driver, this should come from the device tree.Until then, maybe a config option, with a reasonable default would be right.
I could add these to platform data.
Together with the "use DCR access" option.
Say,
--------------------------------------------------------
struct xilinxfb_platform_data {
u32 use_dcr;
u32 screen_height_mm;
u32 screen_width_mm;
};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; };
...
/* ML300/403 reference design framebuffer */
#if defined(XPAR_TFT_0_BASEADDR)
{
.name = "xilinxfb",
.id = 0,
.dev.platform_data = &xilinxfb_pdata,
.num_resources = 1,
.resource = (struct resource[]) {
{
.start = XPAR_TFT_0_BASEADDR,
.end = XPAR_TFT_0_BASEADDR+7,
.flags = IORESOURCE_IO,
},
},
},#endif
--------------------------------------------------------
Does it look OK?
Quoted 4 lines
Quoted 4 lines
drivers/video/xilinxfb.c new file +4
-0+ +struct xilinxfb_drvdata { + +struct fb_info info;/* FB driver info record */
Quoted 8 lines
drivers/video/xilinxfb.c line 112
Quoted 5 lines
drivers/video/xilinxfb.c new file +5
-0+ +unsigned long regs_phys;/* phys. address of the control registers */ +u32 *regs;/* virt. address of the control registers */ + +unsigned char *fb_virt;/* virt. address of the frame buffer */ The virtual addresses should be marked as
__iomem, so you can check the correct usage with sparse.
OK. Thanks.
Quoted 1 line
Not sure about
regs_phys. Can this be beyond the 32 bit limit on any machine?
The driver is for Xilinx FPGAs only (the video controller is the "soft core" IP block).
My personal feeling is that someday in the future Virtex FPGAs would carry ppc440 "hard" cores. But all current FPGAs have only ppc405 "hard core" CPU blocks inside (0, 1 or several per chip). Another option is to use Microblaze "soft core" CPU which is 32-bit too.
I doubt someone would connect a Virtex FPGA to a "standalone" CPU to use
the FPGA as video controller (this is not impossible though).
I.e. for the moment
u32 regs_phys;
should be OK.
Other options could be
dma_addr_t regs_phys;
or
resource_size_t regs_phys;
which are u32 or u64 depending on the architecture.
But both don't sound like intended specifically for phys. addresses (not necessary DMA-able).
What would you recommend?
Quoted 10 lines
drivers/video/xilinxfb.c line 208
Quoted 7 lines
drivers/video/xilinxfb.c new file +7
-0+ + drvdata =kmalloc (sizeof (struct xilinxfb_drvdata ),GFP_KERNEL ); +if (!drvdata) { +printk (KERN_ERR "Couldn't allocate device private record\n" ); +return -ENOMEM ; + } +memset ((void *)drvdata,0 ,sizeof (struct xilinxfb_drvdata ));Use
drvdata = kzalloc(sizeof (*drvdata), GFP_KERNEL);
Oops.. Sure I will.
Quoted 4 lines
drivers/video/xilinxfb.c line 228
Quoted 2 lines
drivers/video/xilinxfb.c new file +2
-0+ drvdata->regs_phys = regs_res->start; + drvdata->regs = (u32 *)ioremap (regs_res->start,8 );u32 __iomem*
OK
Quoted 1 line
Arnd <><
Thanks,
Andrei
Grant,
Quoted 11 lines · Andrei Konovalov
I could add these to platform data.
Together with the "use DCR access" option.
Say,--------------------------------------------------------
struct xilinxfb_platform_data { u32 use_dcr; u32 screen_height_mm; u32 screen_width_mm; };
Quoted 6 lines
static struct
xilinxfb_platform_dataxilinxfb_pdata= {#if defined(XPAR_TFT_0_USE_DCR) && (XPAR_TFT_0_USE_DCR != 0) .use_dcr = 1; #else .use_dcr = 0;#endif
IOW I am trying to avoid conditional compilation like:
#if defined(XPAR_TFT_0_USE_DCR) && (XPAR_TFT_0_USE_DCR != 0)
#define xilinxfb_out_be32(addr, mask) mtdcr((addr), (mask))
#else
#define xilinxfb_out_be32(addr, mask) out_be32((addr), (mask))
#endif
- as this would make the driver to include xparameters.h which would be an issue when moving to the OF device tree.
Or "use DCR" could be a Kconfig option for the driver.
Thanks,
Andrei
Quoted 10 lines · Andrei Konovalov
Grant,
Quoted 6 lines
static struct
xilinxfb_platform_dataxilinxfb_pdata= {#if defined(XPAR_TFT_0_USE_DCR) && (XPAR_TFT_0_USE_DCR != 0) .use_dcr = 1; #else .use_dcr = 0;#endif
IOW I am trying to avoid conditional compilation like:
I agree 100%. All the device options should be specified dynamically. Heck, it should be possible to build a single kernel and boot it on just about any design.
Quoted 9 lines
#if
defined(XPAR_TFT_0_USE_DCR)&& (XPAR_TFT_0_USE_DCR!= 0)
#definexilinxfb_out_be32(addr, mask)mtdcr((addr), (mask))
#else
#definexilinxfb_out_be32(addr, mask)out_be32((addr), (mask))
#endif- as this would make the driver to include
xparameters.hwhich would be an issue when moving to the OF device tree.
Which is a bad thing. I believe that the Xilinx folks would like to use the device tree for the microblaze target also; but there is a fair bit of work that need to be done before that is feasable.
Quoted 2 lines
Or "use DCR" could be a
Kconfigoption for the driver.
My preference would be for it to be a runtime thing.
Signature · 4 lines
Grant Likely, B.Sc. P.Eng. Secret Lab Technologies Ltd. [email protected] (403) 399-0195