diff options
Diffstat (limited to 'fpga/ebaz4205')
| -rw-r--r-- | fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb | 415 | ||||
| -rw-r--r-- | fpga/ebaz4205/src/uEnv.txt | 3 |
2 files changed, 235 insertions, 183 deletions
diff --git a/fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb b/fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb index 1b98045..c892fad 100644 --- a/fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb +++ b/fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb @@ -38,10 +38,10 @@ index cef74a483..7f3eadf0e 100644 obj-$(CONFIG_NSM) += nsm.o diff --git a/drivers/misc/jmm_fb.c b/drivers/misc/jmm_fb.c new file mode 100644 -index 000000000..db164d714 +index 000000000..ed9dab898 --- /dev/null +++ b/drivers/misc/jmm_fb.c -@@ -0,0 +1,305 @@ +@@ -0,0 +1,356 @@ +#include <linux/miscdevice.h> +#include <linux/fs.h> +#include <linux/kernel.h> @@ -59,48 +59,51 @@ index 000000000..db164d714 + + +static struct jmm_fb { -+ struct fb_info *info; -+ uint8_t *fb_base; -+ size_t fb_len; ++ struct fb_info *info; ++ uint8_t *fb_base; ++ size_t fb_len; +} jmm_fb; + +struct jmm_fb_par { -+ int dummy; ++ int dummy; +}; + ++ +static const struct fb_var_screeninfo jmm_fb_var = { -+ .xres = 384, -+ .yres = 600, -+ .xres_virtual = 384, -+ .yres_virtual = 600, -+ .bits_per_pixel = 2, -+ .red = {0, 1, 0}, -+ .green = {0, 1, 0}, -+ .blue = {0, 1, 0}, -+ .transp = {1, 1, 0}, -+ .height = -1, -+ .width = -1, ++ .xres = 384, ++ .yres = 600, ++ .xres_virtual = 384, ++ .yres_virtual = 600, ++ .bits_per_pixel = 4, ++ .red = {0, 4, 0}, ++ .green = {0, 4, 0}, ++ .blue = {0, 4, 0}, ++ .transp = {0, 4, 0}, ++ .grayscale = 1, ++ .rotate = FB_ROTATE_CW, ++ .height = -1, ++ .width = -1, +}; + +static struct fb_fix_screeninfo jmm_fb_fix = { -+ .id = "jmm_fb", -+ .type = FB_TYPE_PACKED_PIXELS, /* (not sure) */ -+ .visual = FB_VISUAL_MONO10, -+ .xpanstep = 0, -+ .ypanstep = 0, -+ .line_length = 96, -+ .accel = FB_ACCEL_NONE ++ .id = "jmm_fb", ++ .type = FB_TYPE_PACKED_PIXELS, /* (not sure) */ ++ .visual = FB_VISUAL_STATIC_PSEUDOCOLOR, ++ .xpanstep = 0, ++ .ypanstep = 0, ++ .line_length = 96, ++ .accel = FB_ACCEL_NONE +}; + + + +static struct fb_ops jmm_fb_ops = { -+.owner = THIS_MODULE, -+ __FB_DEFAULT_IOMEM_OPS_RDWR, -+.fb_fillrect = cfb_fillrect, -+.fb_imageblit = cfb_imageblit, -+.fb_copyarea = cfb_copyarea, -+ __FB_DEFAULT_IOMEM_OPS_MMAP, ++ .owner = THIS_MODULE, ++ __FB_DEFAULT_IOMEM_OPS_RDWR, ++ .fb_fillrect = cfb_fillrect, ++ .fb_imageblit = cfb_imageblit, ++ .fb_copyarea = cfb_copyarea, ++ __FB_DEFAULT_IOMEM_OPS_MMAP, + +}; + @@ -108,242 +111,290 @@ index 000000000..db164d714 +/* +** This function will be called when we open the Misc device file +*/ -+static int jmm_fb_open(struct inode *inode, struct file *file) ++static int jmm_fb_open (struct inode *inode, struct file *file) +{ -+ pr_info("jmm_fb device open\n"); -+ return 0; ++ pr_info ("jmm_fb device open\n"); ++ return 0; +} + +/* +** This function will be called when we close the Misc Device file +*/ -+static int jmm_fb_close(struct inode *inodep, struct file *filp) ++static int jmm_fb_close (struct inode *inodep, struct file *filp) +{ -+ pr_info("jmm_fb device close\n"); -+ return 0; ++ pr_info ("jmm_fb device close\n"); ++ return 0; +} + +/* +** This function will be called when we write the Misc Device file +*/ -+static ssize_t jmm_fb_write(struct file *file, const char __user *buf, -+ size_t count, loff_t *f_pos) ++static ssize_t jmm_fb_write (struct file *file, const char __user *buf, ++ size_t count, loff_t *f_pos) +{ -+ if (*f_pos>=jmm_fb.fb_len) return 0; ++ if (*f_pos >= jmm_fb.fb_len) return 0; + -+ if ((*f_pos+count)>jmm_fb.fb_len) { -+ count=jmm_fb.fb_len-*f_pos; -+ } ++ if ((*f_pos + count) > jmm_fb.fb_len) ++ count = jmm_fb.fb_len - *f_pos; + -+ if (copy_from_user(jmm_fb.fb_base+(*f_pos), buf, count)) -+ return -EFAULT; ++ if (copy_from_user (jmm_fb.fb_base + (*f_pos), buf, count)) ++ return -EFAULT; + -+ (*f_pos) += count; ++ (*f_pos) += count; + -+ return count; ++ return count; +} -+ ++ +/* +** This function will be called when we read the Misc Device file +*/ -+static ssize_t jmm_fb_read(struct file *filp, char __user *buf, -+ size_t count, loff_t *f_pos) ++static ssize_t jmm_fb_read (struct file *filp, char __user *buf, ++ size_t count, loff_t *f_pos) +{ -+ if (*f_pos>=jmm_fb.fb_len) return 0; ++ if (*f_pos >= jmm_fb.fb_len) return 0; + -+ if ((*f_pos+count)>jmm_fb.fb_len) { -+ count=jmm_fb.fb_len-*f_pos; -+ } ++ if ((*f_pos + count) > jmm_fb.fb_len) ++ count = jmm_fb.fb_len - *f_pos; + -+ if (copy_to_user(buf, jmm_fb.fb_base+(*f_pos), count)) -+ return -EFAULT; ++ if (copy_to_user (buf, jmm_fb.fb_base + (*f_pos), count)) ++ return -EFAULT; + -+ (*f_pos) += count; ++ (*f_pos) += count; + -+ return count; ++ return count; +} + -+static loff_t jmm_fb_llseek(struct file *filp, loff_t offset, int whence) ++static loff_t jmm_fb_llseek (struct file *filp, loff_t offset, int whence) +{ -+loff_t new_offset; -+ -+ -+switch(whence) { -+case SEEK_SET: -+ new_offset=offset; -+ break; -+case SEEK_CUR: -+ new_offset=filp->f_pos + offset; -+ break; -+case SEEK_END: -+ new_offset=jmm_fb.fb_len + offset; -+ break; -+default: -+ return -EINVAL; -+} ++ loff_t new_offset; ++ ++ ++ switch (whence) { ++ case SEEK_SET: ++ new_offset = offset; ++ break; ++ ++ case SEEK_CUR: ++ new_offset = filp->f_pos + offset; ++ break; ++ ++ case SEEK_END: ++ new_offset = jmm_fb.fb_len + offset; ++ break; ++ ++ default: ++ return -EINVAL; ++ } + + -+if (new_offset<0) -+ return -EINVAL; -+if (new_offset>jmm_fb.fb_len) -+ return -EINVAL; ++ if (new_offset < 0) ++ return -EINVAL; + -+filp->f_pos=new_offset; ++ if (new_offset > jmm_fb.fb_len) ++ return -EINVAL; + -+return new_offset; ++ filp->f_pos = new_offset; ++ ++ return new_offset; +} + + + + -+//File operation structure ++//File operation structure +static const struct file_operations fops = { -+ .owner = THIS_MODULE, -+ .write = jmm_fb_write, -+ .read = jmm_fb_read, -+ .open = jmm_fb_open, -+ .release = jmm_fb_close, -+ .llseek = jmm_fb_llseek, ++ .owner = THIS_MODULE, ++ .write = jmm_fb_write, ++ .read = jmm_fb_read, ++ .open = jmm_fb_open, ++ .release = jmm_fb_close, ++ .llseek = jmm_fb_llseek, +}; + +//Misc device structure +struct miscdevice jmm_fb_device = { -+ .minor = MISC_DYNAMIC_MINOR, -+ .name = "jmm_fb", -+ .fops = &fops, ++ .minor = MISC_DYNAMIC_MINOR, ++ .name = "jmm_fb", ++ .fops = &fops, +}; + + +static const struct of_device_id jmm_fb_of_match[] = { -+ { .compatible = "jmm,frame-buffer-device" }, -+ { /* end of table */ } ++ { .compatible = "jmm,frame-buffer-device" }, ++ { /* end of table */ } +}; -+MODULE_DEVICE_TABLE(of, jmm_fb_of_match); ++MODULE_DEVICE_TABLE (of, jmm_fb_of_match); + + -+static int jmm_fb_probe(struct platform_device *pdev) ++static int jmm_fb_probe (struct platform_device *pdev) +{ -+ struct resource *res; -+ const struct of_device_id *match; -+ uint8_t *ptr; ++ struct resource *res; ++ const struct of_device_id *match; ++ uint8_t *ptr; ++ unsigned i; ++ ++ ++ match = of_match_node (jmm_fb_of_match, pdev->dev.of_node); ++ pr_info ("jmm_fb match %px\n", match); ++ printk (KERN_ERR "jmm_fb" "jmm_fb match %px\n", match); ++ ++ if (!match) { ++ dev_err (&pdev->dev, "of_match_node() failed\n"); ++ printk (KERN_ERR "jmm_fb" "of_match_node() failed\n"); ++ return -EINVAL; ++ } ++ ++ res = platform_get_resource (pdev, IORESOURCE_MEM, 0); ++ ++ if (!res) { ++ dev_err (&pdev->dev, "can't get parent mmio range\n"); ++ printk (KERN_ERR "jmm_fb" "can't get parent mmio range\n"); ++ return -EINVAL; ++ } ++ ++ jmm_fb.fb_len = res->end - res->start; ++ jmm_fb.fb_len++; ++ pr_info ("jmm_fb resource indicates length of 0x%x\n", jmm_fb.fb_len); ++ printk (KERN_ERR "jmm_fb resource indicates length of 0x%x\n", jmm_fb.fb_len); + ++ pr_info ("jmm_fb start %08x end %08x\n", (unsigned) res->start, (unsigned) res->end); ++ printk (KERN_ERR "jmm_fb start %08x end %08x\n", (unsigned) res->start, (unsigned) res->end); + -+ match = of_match_node(jmm_fb_of_match, pdev->dev.of_node); -+ pr_info("jmm_fb match %px\n",match); -+ printk(KERN_ERR "jmm_fb" "jmm_fb match %px\n",match); -+ if (!match) { -+ dev_err(&pdev->dev, "of_match_node() failed\n"); -+ printk(KERN_ERR "jmm_fb" "of_match_node() failed\n"); -+ return -EINVAL; -+ } ++ ptr = devm_ioremap_resource (&pdev->dev, res); ++ pr_info ("jmm_fb devm_ioremap_resource() gives %px\n", ptr); ++ printk (KERN_ERR "jmm_fb devm_ioremap_resource() gives %px\n", ptr); + -+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ if (!res) { -+ dev_err(&pdev->dev, "can't get parent mmio range\n"); -+ printk(KERN_ERR "jmm_fb" "can't get parent mmio range\n"); -+ return -EINVAL; -+ } ++ if (IS_ERR (ptr)) ++ return PTR_ERR (ptr); + -+ jmm_fb.fb_len=res->end - res->start; -+ jmm_fb.fb_len++; -+ pr_info("jmm_fb resource indicates length of 0x%x\n",jmm_fb.fb_len); -+ printk(KERN_ERR "jmm_fb" "jmm_fb resource indicates length of 0x%x\n",jmm_fb.fb_len); ++ jmm_fb.fb_base = ptr; + -+ pr_info("jmm_fb start %08x end %08x\n",(unsigned) res->start, (unsigned) res->end ); -+ printk(KERN_ERR "jmm_fb start %08x end %08x\n",(unsigned) res->start, (unsigned) res->end ); ++ jmm_fb.info = framebuffer_alloc (sizeof (struct jmm_fb_par), &pdev->dev); ++ jmm_fb.info->screen_base = ptr; ++ jmm_fb.info->fbops = &jmm_fb_ops; ++ jmm_fb.info->fix = jmm_fb_fix; ++ jmm_fb.info->fix.smem_start = res->start; ++ jmm_fb.info->fix.smem_len = jmm_fb.fb_len; ++ jmm_fb.info->fix.type = FB_TYPE_PACKED_PIXELS; + -+ ptr = devm_ioremap_resource(&pdev->dev, res); -+ pr_info("jmm_fb devm_ioremap_resource() gives %px\n",ptr); -+ printk(KERN_ERR "jmm_fb" "jmm_fb devm_ioremap_resource() gives %px\n",ptr); ++ jmm_fb.info->flags = 0; + -+ if (IS_ERR(ptr)) -+ return PTR_ERR(ptr); ++ jmm_fb.info->var = jmm_fb_var; + -+ jmm_fb.fb_base=ptr; + -+ jmm_fb.info = framebuffer_alloc(sizeof(struct jmm_fb_par), &pdev->dev); -+ jmm_fb.info->screen_base = ptr; -+ jmm_fb.info->fbops=&jmm_fb_ops; -+ jmm_fb.info->fix=jmm_fb_fix; -+ jmm_fb.info->fix.smem_start = res->start; -+ jmm_fb.info->fix.smem_len = jmm_fb.fb_len; -+ jmm_fb.info->fix.type=FB_TYPE_PACKED_PIXELS; ++ if (fb_alloc_cmap (&jmm_fb.info->cmap, 0x10, 1)) { ++ framebuffer_release (jmm_fb.info); ++ jmm_fb.info = NULL; ++ } + -+ jmm_fb.info->flags=0; ++ jmm_fb.info->cmap.start = 0; ++ jmm_fb.info->cmap.len = 4; + -+ jmm_fb.info->var=jmm_fb_var; ++ for (i=0;i<0x8;++i) { ++ jmm_fb.info->cmap.red[i] = (i &4) ? 0xaaaa:0x0; ++ jmm_fb.info->cmap.green[i] = (i &2) ? 0xaaaa:0x0; ++ jmm_fb.info->cmap.blue[i] = (i &1) ? 0xaaaa:0x0; ++ jmm_fb.info->cmap.transp[i] = 0; ++ } + -+ return 0; ++ for (;i<0x10;++i) { ++ jmm_fb.info->cmap.red[i] = (i &4) ? 0xffff:0x5555; ++ jmm_fb.info->cmap.green[i] = (i &2) ? 0xffff:0x5555; ++ jmm_fb.info->cmap.blue[i] = (i &1) ? 0xffff:0x5555; ++ jmm_fb.info->cmap.transp[i] = 0; ++ } ++ ++ ++ jmm_fb.info->cmap.green[6] = 0x5555; // Brown ++ jmm_fb.info->cmap.transp[i] = 0xffff; ++ ++ if (register_framebuffer (jmm_fb.info) < 0) { ++ printk (KERN_ERR "jmm_fb register framebuffer didn't\n"); ++ fb_dealloc_cmap (&jmm_fb.info->cmap); ++ framebuffer_release (jmm_fb.info); ++ jmm_fb.info = NULL; ++ } else ++ printk (KERN_ERR "jmm_fb registered framebuffer\n"); ++ ++ ++ return 0; +} + +/** + * zynq_gpio_remove - Driver removal function -+ * @pdev: platform device instance ++ * @pdev: platform device instance + * + * Return: 0 always + */ -+static void jmm_fb_remove(struct platform_device *pdev) ++static void jmm_fb_remove (struct platform_device *pdev) +{ -+ //struct zynq_gpio *gpio = platform_get_drvdata(pdev); ++ //struct zynq_gpio *gpio = platform_get_drvdata(pdev); ++ ++ if (jmm_fb.info) { ++ unregister_framebuffer (jmm_fb.info); ++ fb_dealloc_cmap (&jmm_fb.info->cmap); + -+ unregister_framebuffer(jmm_fb.info); -+ framebuffer_release(jmm_fb.info); ++ framebuffer_release (jmm_fb.info); ++ jmm_fb.info = NULL; ++ } + -+ jmm_fb.fb_base=NULL; ++ jmm_fb.fb_base = NULL; +} + +static struct platform_driver jmm_fb_driver = { -+ .driver = { -+ .name = "jmm-fb", -+ .of_match_table = jmm_fb_of_match, -+ }, -+ .probe = jmm_fb_probe, -+ .remove = jmm_fb_remove, ++ .driver = { ++ .name = "jmm-fb", ++ .of_match_table = jmm_fb_of_match, ++ }, ++ .probe = jmm_fb_probe, ++ .remove = jmm_fb_remove, +}; + + -+static int __init jmm_fb_init(void) ++static int __init jmm_fb_init (void) +{ -+ int error; -+ -+ //jmm_fb_driver->driver.owner = THIS_MODULE; -+ //jmm_fb_driver->driver.bus=&platform_bus_type; -+ -+ error=platform_driver_register(&jmm_fb_driver); -+ if (error) { -+ pr_err("platform_driver_register failed!!!\n"); -+ printk(KERN_ERR "jmm_fb" "platform_driver_register failed!!!\n"); -+ return error; -+ } -+ -+ error = misc_register(&jmm_fb_device); -+ if (error) { -+ platform_driver_unregister(&jmm_fb_driver); -+ pr_err("misc_register failed!!!\n"); -+ printk(KERN_ERR "jmm_fb" "misc_register failed!!!\n"); -+ return error; -+ } -+ -+ pr_info("misc_register init done!!!\n"); -+ printk(KERN_ERR "jmm_fb" "misc_register init done!!!\n"); -+ -+ return 0; ++ int error; ++ ++ //jmm_fb_driver->driver.owner = THIS_MODULE; ++ //jmm_fb_driver->driver.bus=&platform_bus_type; ++ ++ error = platform_driver_register (&jmm_fb_driver); ++ ++ if (error) { ++ pr_err ("platform_driver_register failed!!!\n"); ++ printk (KERN_ERR "jmm_fb" "platform_driver_register failed!!!\n"); ++ return error; ++ } ++ ++ error = misc_register (&jmm_fb_device); ++ ++ if (error) { ++ platform_driver_unregister (&jmm_fb_driver); ++ pr_err ("misc_register failed!!!\n"); ++ printk (KERN_ERR "jmm_fb" "misc_register failed!!!\n"); ++ return error; ++ } ++ ++ pr_info ("misc_register init done!!!\n"); ++ printk (KERN_ERR "jmm_fb" "misc_register init done!!!\n"); ++ ++ return 0; +} + -+static void __exit jmm_fb_exit(void) ++static void __exit jmm_fb_exit (void) +{ -+ misc_deregister(&jmm_fb_device); -+ platform_driver_unregister(&jmm_fb_driver); ++ misc_deregister (&jmm_fb_device); ++ platform_driver_unregister (&jmm_fb_driver); + -+ pr_info("misc_register exit done!!!\n"); ++ pr_info ("misc_register exit done!!!\n"); + +} -+ -+module_init(jmm_fb_init) -+module_exit(jmm_fb_exit) -+ -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("meh"); -+MODULE_DESCRIPTION("jmm_fb driver"); -+MODULE_VERSION("1.00"); ++ ++module_init (jmm_fb_init) ++module_exit (jmm_fb_exit) ++ ++MODULE_LICENSE ("GPL"); ++MODULE_AUTHOR ("meh"); ++MODULE_DESCRIPTION ("jmm_fb driver"); ++MODULE_VERSION ("1.00"); + diff --git a/fpga/ebaz4205/src/uEnv.txt b/fpga/ebaz4205/src/uEnv.txt index 45f0791..0bd8ee6 100644 --- a/fpga/ebaz4205/src/uEnv.txt +++ b/fpga/ebaz4205/src/uEnv.txt @@ -5,7 +5,8 @@ devicetree_image=ebaz4205-zynq7.dtb loaddtb=load mmc 0 ${devicetree_load_address} ${devicetree_image} ramdisk_image=nowt.cpio.uboot loadramdisk=load mmc 0 ${ramdisk_load_address} ${ramdisk_image} -bootargs=earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p3 ro rootwait +#bootargs=earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p3 ro rootwait +bootargs=fbcon=rotate:1 root=/dev/mmcblk0p3 ro rootwait bitstream_image=hp_lcd_driver.bin bitstream_type=load fpga_config=fpga ${bitstream_type} 0 ${bitstream_load_address} ${filesize} |
