23 #include <linux/device.h>
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/errno.h>
27 #include <linux/string.h>
37 #include <linux/slab.h>
43 #define DRIVER_NAME "xilinxfb"
66 #define REG_CTRL_ENABLE 0x0001
67 #define REG_CTRL_ROTATE 0x0002
78 #define BYTES_PER_PIXEL 4
79 #define BITS_PER_PIXEL (BYTES_PER_PIXEL * 8)
85 #define PALETTE_ENTRIES_NO 16
113 .transp = { 0, 0, 0 },
119 #define PLB_ACCESS_FLAG 0x1
129 #ifdef CONFIG_PPC_DCR
131 unsigned int dcr_len;
145 #define to_xilinxfb_drvdata(_info) \
146 container_of(_info, struct xilinxfb_drvdata, info)
158 #ifdef CONFIG_PPC_DCR
160 dcr_write(drvdata->dcr_host, offset, val);
165 xilinx_fb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
unsigned blue,
173 if (fbi->
var.grayscale) {
177 (red * 77 + green * 151 + blue * 28 + 127) >> 8;
193 xilinx_fb_blank(
int blank_mode,
struct fb_info *fbi)
197 switch (blank_mode) {
208 xilinx_fb_out_be32(drvdata,
REG_CTRL, 0);
216 static struct fb_ops xilinxfb_ops =
219 .fb_setcolreg = xilinx_fb_setcolreg,
220 .fb_blank = xilinx_fb_blank,
230 static int xilinxfb_assign(
struct device *
dev,
232 unsigned long physaddr,
244 dev_err(dev,
"Couldn't lock memory region at 0x%08lX\n",
252 if (!drvdata->
regs) {
253 dev_err(dev,
"Couldn't lock memory region at 0x%08lX\n",
271 dev_err(dev,
"Could not allocate frame buffer memory\n");
289 xilinx_fb_out_be32(drvdata,
REG_CTRL,
295 drvdata->
info.fbops = &xilinxfb_ops;
296 drvdata->
info.fix = xilinx_fb_fix;
298 drvdata->
info.fix.smem_len = fbsize;
303 drvdata->
info.var = xilinx_fb_var;
306 drvdata->
info.var.xres = pdata->
xres;
307 drvdata->
info.var.yres = pdata->
yres;
308 drvdata->
info.var.xres_virtual = pdata->
xvirt;
309 drvdata->
info.var.yres_virtual = pdata->
yvirt;
314 dev_err(dev,
"Fail to allocate colormap (%d entries)\n",
322 dev_err(dev,
"Could not register frame buffer\n");
328 dev_dbg(dev,
"regs: phys=%lx, virt=%p\n", physaddr,
332 dev_dbg(dev,
"fb: phys=%llx, virt=%p, size=%x\n",
348 xilinx_fb_out_be32(drvdata,
REG_CTRL, 0);
365 static int xilinxfb_release(
struct device *dev)
369 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
384 xilinx_fb_out_be32(drvdata,
REG_CTRL, 0);
391 #ifdef CONFIG_PPC_DCR
393 dcr_unmap(drvdata->dcr_host, drvdata->dcr_len);
417 pdata = xilinx_fb_default_pdata;
420 drvdata = kzalloc(
sizeof(*drvdata),
GFP_KERNEL);
422 dev_err(&op->
dev,
"Couldn't allocate device private record\n");
431 tft_access = p ? *p : 0;
445 #ifdef CONFIG_PPC_DCR
451 drvdata->dcr_host = dcr_map(op->
dev.of_node, start, drvdata->dcr_len);
452 if (!DCR_MAP_OK(drvdata->dcr_host)) {
460 if ((prop) && (size >=
sizeof(
u32)*2)) {
466 if ((prop) && (size >=
sizeof(
u32)*2)) {
467 pdata.
xres = prop[0];
468 pdata.
yres = prop[1];
472 if ((prop) && (size >=
sizeof(
u32)*2)) {
473 pdata.
xvirt = prop[0];
474 pdata.
yvirt = prop[1];
481 return xilinxfb_assign(&op->
dev, drvdata,
res.start, &pdata);
490 return xilinxfb_release(&op->
dev);
495 { .compatible =
"xlnx,xps-tft-1.00.a", },
496 { .compatible =
"xlnx,xps-tft-2.00.a", },
497 { .compatible =
"xlnx,xps-tft-2.01.a", },
498 { .compatible =
"xlnx,plb-tft-cntlr-ref-1.00.a", },
499 { .compatible =
"xlnx,plb-dvi-cntlr-ref-1.00.c", },
505 .probe = xilinxfb_of_probe,
510 .of_match_table = xilinxfb_of_match,