summaryrefslogtreecommitdiffstats
path: root/fpga
diff options
context:
space:
mode:
authorroot <root@new-fish.medaka.james.internal>2025-11-13 00:54:57 +0000
committerroot <root@new-fish.medaka.james.internal>2025-11-13 00:54:57 +0000
commit3500006e83a1b775499fb4cf5532b36f9a8c4664 (patch)
tree46b827178e45f7054703f7d24d7f8ccf9396978e /fpga
parentd584763fed1232f395f5bd33adafba344243bb9f (diff)
downloadhp_instrument_lcds-3500006e83a1b775499fb4cf5532b36f9a8c4664.tar.gz
hp_instrument_lcds-3500006e83a1b775499fb4cf5532b36f9a8c4664.tar.bz2
hp_instrument_lcds-3500006e83a1b775499fb4cf5532b36f9a8c4664.zip
maybe working linux fb driver
Diffstat (limited to 'fpga')
-rw-r--r--fpga/ebaz4205/Makefile6
-rw-r--r--fpga/ebaz4205/linux-6.16.4-pq/master/jmm-fb228
-rw-r--r--fpga/ebaz4205/src/uEnv.txt2
3 files changed, 142 insertions, 94 deletions
diff --git a/fpga/ebaz4205/Makefile b/fpga/ebaz4205/Makefile
index 0aebbe6..4c02b0f 100644
--- a/fpga/ebaz4205/Makefile
+++ b/fpga/ebaz4205/Makefile
@@ -5,12 +5,12 @@ UBO=${UB}/spl/boot.bin ${UB}/u-boot.img
LO=build/uImage
#LD=linux-4.19
LD=linux-6.16.4
-FD=ebaz4205_fpga
+FD=../hp_lcd_driver
DP=${DIP}:/boot/uboot/
DIP=10.16.66.234
-#VIVO=${FD}/build/ebaz4205_top.runs/impl_1/ebaz4205_top.bin
+VIVO=${FD}/build_ebaz4205/out/hp_lcd_driver.bin
RDO=build/nowt.cpio.uboot
DTB=build/ebaz4205-zynq7.dtb
@@ -40,7 +40,7 @@ build/nowt.cpio:
-${VIVO}: dummy
+${VIVO}:
(cd ${FD} && ${MAKE})
build/%.dtb:src/%.dts ${LD}/arch/arm/boot/zImage
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 f12063f..1b98045 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..2fe454b5f
+index 000000000..db164d714
--- /dev/null
+++ b/drivers/misc/jmm_fb.c
-@@ -0,0 +1,257 @@
+@@ -0,0 +1,305 @@
+#include <linux/miscdevice.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
@@ -53,62 +53,109 @@ index 000000000..2fe454b5f
+#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/gpio.h>
++#include <linux/fb.h>
+
+
+
-+static struct jmm_vcap {
-+ struct gpio_desc *gpio;
-+ int gpio_state;
-+ uint8_t *ocm_base;
-+ size_t ocm_len;
-+} jmm_vcap;
++
++static struct jmm_fb {
++ struct fb_info *info;
++ uint8_t *fb_base;
++ size_t fb_len;
++} jmm_fb;
++
++struct jmm_fb_par {
++ 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,
++};
++
++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
++};
++
++
++
++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,
++
++};
+
+
+/*
+** This function will be called when we open the Misc device file
+*/
-+static int jmm_vcap_open(struct inode *inode, struct file *file)
++static int jmm_fb_open(struct inode *inode, struct file *file)
+{
-+ pr_info("jmm_vcap device open\n");
++ pr_info("jmm_fb device open\n");
+ return 0;
+}
+
+/*
+** This function will be called when we close the Misc Device file
+*/
-+static int jmm_vcap_close(struct inode *inodep, struct file *filp)
++static int jmm_fb_close(struct inode *inodep, struct file *filp)
+{
-+ pr_info("jmm_vcap device close\n");
++ 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_vcap_write(struct file *file, const char __user *buf,
-+ size_t len, loff_t *ppos)
++static ssize_t jmm_fb_write(struct file *file, const char __user *buf,
++ size_t count, loff_t *f_pos)
+{
-+ pr_info("jmm_vcap device write\n");
-+
-+ /* We are not doing anything with this data now */
-+
-+ return -ENODEV;
++ 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 (copy_from_user(jmm_fb.fb_base+(*f_pos), buf, count))
++ return -EFAULT;
++
++ (*f_pos) += count;
++
++ return count;
+}
+
+/*
+** This function will be called when we read the Misc Device file
+*/
-+static ssize_t jmm_vcap_read(struct file *filp, char __user *buf,
++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_vcap.ocm_len) return 0;
-+
-+ if ((*f_pos+count)>jmm_vcap.ocm_len) {
-+ count=jmm_vcap.ocm_len-*f_pos;
++ if ((*f_pos+count)>jmm_fb.fb_len) {
++ count=jmm_fb.fb_len-*f_pos;
+ }
+
-+ if (copy_to_user(buf, jmm_vcap.ocm_base+(*f_pos), count))
++ if (copy_to_user(buf, jmm_fb.fb_base+(*f_pos), count))
+ return -EFAULT;
+
+ (*f_pos) += count;
@@ -116,7 +163,7 @@ index 000000000..2fe454b5f
+ return count;
+}
+
-+static loff_t jmm_vcap_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;
+
@@ -129,7 +176,7 @@ index 000000000..2fe454b5f
+ new_offset=filp->f_pos + offset;
+ break;
+case SEEK_END:
-+ new_offset=jmm_vcap.ocm_len + offset;
++ new_offset=jmm_fb.fb_len + offset;
+ break;
+default:
+ return -EINVAL;
@@ -138,7 +185,7 @@ index 000000000..2fe454b5f
+
+if (new_offset<0)
+ return -EINVAL;
-+if (new_offset>jmm_vcap.ocm_len)
++if (new_offset>jmm_fb.fb_len)
+ return -EINVAL;
+
+filp->f_pos=new_offset;
@@ -147,76 +194,84 @@ index 000000000..2fe454b5f
+}
+
+
++
++
+//File operation structure
+static const struct file_operations fops = {
+ .owner = THIS_MODULE,
-+ .write = jmm_vcap_write,
-+ .read = jmm_vcap_read,
-+ .open = jmm_vcap_open,
-+ .release = jmm_vcap_close,
-+ .llseek = jmm_vcap_llseek,
++ .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_vcap_device = {
++struct miscdevice jmm_fb_device = {
+ .minor = MISC_DYNAMIC_MINOR,
-+ .name = "jmm_vcap",
++ .name = "jmm_fb",
+ .fops = &fops,
+};
+
+
-+static const struct of_device_id jmm_vcap_of_match[] = {
-+ { .compatible = "jmm,video-capture-device" },
++static const struct of_device_id jmm_fb_of_match[] = {
++ { .compatible = "jmm,frame-buffer-device" },
+ { /* end of table */ }
+};
-+MODULE_DEVICE_TABLE(of, jmm_vcap_of_match);
++MODULE_DEVICE_TABLE(of, jmm_fb_of_match);
+
+
-+static int jmm_vcap_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;
+
+
-+ match = of_match_node(jmm_vcap_of_match, pdev->dev.of_node);
-+ pr_info("jmm_vcap match %px\n",match);
-+ printk(KERN_ERR "jmm_vcap" "jmm_vcap match %px\n",match);
++ 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_vcap" "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_vcap" "can't get parent mmio range\n");
++ printk(KERN_ERR "jmm_fb" "can't get parent mmio range\n");
+ return -EINVAL;
+ }
+
-+ jmm_vcap.gpio = devm_gpiod_get(&(pdev->dev), NULL, GPIOD_OUT_LOW);
-+ if (IS_ERR(jmm_vcap.gpio)) {
-+ dev_err(&pdev->dev, "can't get enable gpio\n");
-+ printk(KERN_ERR "jmm_vcap" "can't get enable gpio\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" "jmm_fb resource indicates length of 0x%x\n",jmm_fb.fb_len);
+
-+ jmm_vcap.ocm_len=res->end - res->start;
-+ jmm_vcap.ocm_len++;
-+ pr_info("jmm_vcap resource indicates length of 0x%x\n",jmm_vcap.ocm_len);
-+ printk(KERN_ERR "jmm_vcap" "jmm_vcap resource indicates length of 0x%x\n",jmm_vcap.ocm_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 );
+
+ ptr = devm_ioremap_resource(&pdev->dev, res);
-+ pr_info("jmm_vcap devm_ioremap_resource() gives %px\n",ptr);
-+ printk(KERN_ERR "jmm_vcap" "jmm_vcap devm_ioremap_resource() gives %px\n",ptr);
++ 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);
+
+ if (IS_ERR(ptr))
+ return PTR_ERR(ptr);
+
-+ jmm_vcap.ocm_base=ptr;
++ 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;
+
-+ gpiod_set_value(jmm_vcap.gpio,1);
++ jmm_fb.info->flags=0;
++
++ jmm_fb.info->var=jmm_fb_var;
+
+ return 0;
+}
@@ -227,75 +282,68 @@ index 000000000..2fe454b5f
+ *
+ * Return: 0 always
+ */
-+static void jmm_vcap_remove(struct platform_device *pdev)
++static void jmm_fb_remove(struct platform_device *pdev)
+{
+ //struct zynq_gpio *gpio = platform_get_drvdata(pdev);
+
-+ jmm_vcap.ocm_base=NULL;
++ unregister_framebuffer(jmm_fb.info);
++ framebuffer_release(jmm_fb.info);
++
++ jmm_fb.fb_base=NULL;
+}
+
-+static struct platform_driver jmm_vcap_driver = {
++static struct platform_driver jmm_fb_driver = {
+ .driver = {
-+ .name = "jmm-vcap",
-+ .of_match_table = jmm_vcap_of_match,
++ .name = "jmm-fb",
++ .of_match_table = jmm_fb_of_match,
+ },
-+ .probe = jmm_vcap_probe,
-+ .remove = jmm_vcap_remove,
++ .probe = jmm_fb_probe,
++ .remove = jmm_fb_remove,
+};
+
+
-+static int __init jmm_vcap_init(void)
++static int __init jmm_fb_init(void)
+{
+ int error;
+
-+ //jmm_vcap_driver->driver.owner = THIS_MODULE;
-+ //jmm_vcap_driver->driver.bus=&platform_bus_type;
++ //jmm_fb_driver->driver.owner = THIS_MODULE;
++ //jmm_fb_driver->driver.bus=&platform_bus_type;
+
-+ error=platform_driver_register(&jmm_vcap_driver);
++ error=platform_driver_register(&jmm_fb_driver);
+ if (error) {
+ pr_err("platform_driver_register failed!!!\n");
-+ printk(KERN_ERR "jmm_vcap" "platform_driver_register failed!!!\n");
++ printk(KERN_ERR "jmm_fb" "platform_driver_register failed!!!\n");
+ return error;
+ }
+
-+ error = misc_register(&jmm_vcap_device);
++ error = misc_register(&jmm_fb_device);
+ if (error) {
-+ platform_driver_unregister(&jmm_vcap_driver);
++ platform_driver_unregister(&jmm_fb_driver);
+ pr_err("misc_register failed!!!\n");
-+ printk(KERN_ERR "jmm_vcap" "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_vcap" "misc_register init done!!!\n");
-+
-+#if 0
-+ jmm_vcap = ioremap(0xfffc0000,0x40000);
-+ pr_info("jmm_vcap mapped at %px\n",jmm_vcap);
-+#endif
++ printk(KERN_ERR "jmm_fb" "misc_register init done!!!\n");
+
+ return 0;
+}
+
-+static void __exit jmm_vcap_exit(void)
++static void __exit jmm_fb_exit(void)
+{
-+ misc_deregister(&jmm_vcap_device);
-+ platform_driver_unregister(&jmm_vcap_driver);
++ misc_deregister(&jmm_fb_device);
++ platform_driver_unregister(&jmm_fb_driver);
+
+ pr_info("misc_register exit done!!!\n");
+
-+#if 0
-+ if (jmm_vcap.ocm_base) iounmap(jmm_vcap.ocm_base);
-+#endif
+}
+
-+module_init(jmm_vcap_init)
-+module_exit(jmm_vcap_exit)
++module_init(jmm_fb_init)
++module_exit(jmm_fb_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("meh");
-+MODULE_DESCRIPTION("jmm_vcap driver");
++MODULE_DESCRIPTION("jmm_fb driver");
+MODULE_VERSION("1.00");
+
-+
-+
diff --git a/fpga/ebaz4205/src/uEnv.txt b/fpga/ebaz4205/src/uEnv.txt
index 6935814..45f0791 100644
--- a/fpga/ebaz4205/src/uEnv.txt
+++ b/fpga/ebaz4205/src/uEnv.txt
@@ -6,7 +6,7 @@ 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
-bitstream_image=ebaz4205_top.bin
+bitstream_image=hp_lcd_driver.bin
bitstream_type=load
fpga_config=fpga ${bitstream_type} 0 ${bitstream_load_address} ${filesize}
sdboot=if mmcinfo; then run leds_bootstate_0;run uenvboot;echo Copying Linux from SD to RAM...; run mmc_loadkernel && run mmc_loaddtb && run mmc_loadramdisk && run mmc_loadfpga && run leds_bootstate_1; echo Configure FPGA...; run fpga_config && run leds_bootstate_2; echo Handoff to Linux kernel...;bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}; fi