summaryrefslogtreecommitdiffstats
path: root/fpga/ebaz4205/linux-6.16.4-pq/master/serial-test
diff options
context:
space:
mode:
Diffstat (limited to 'fpga/ebaz4205/linux-6.16.4-pq/master/serial-test')
-rw-r--r--fpga/ebaz4205/linux-6.16.4-pq/master/serial-test287
1 files changed, 287 insertions, 0 deletions
diff --git a/fpga/ebaz4205/linux-6.16.4-pq/master/serial-test b/fpga/ebaz4205/linux-6.16.4-pq/master/serial-test
new file mode 100644
index 0000000..ff0ea66
--- /dev/null
+++ b/fpga/ebaz4205/linux-6.16.4-pq/master/serial-test
@@ -0,0 +1,287 @@
+diff --git a/.config b/.config
+index e06bfbd12..baad3e250 100644
+--- a/.config
++++ b/.config
+@@ -1794,6 +1794,7 @@ CONFIG_PCI_ENDPOINT_TEST=m
+ # CONFIG_MCHP_LAN966X_PCI is not set
+ CONFIG_MISC_JMM_VCAP=y
+ CONFIG_MISC_JMM_FB=y
++CONFIG_MISC_SERIAL_TEST=y
+ # CONFIG_C2PORT is not set
+
+ #
+diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
+index b56499f42..35ac2299a 100644
+--- a/drivers/misc/Kconfig
++++ b/drivers/misc/Kconfig
+@@ -650,6 +650,9 @@ config MISC_JMM_VCAP
+ config MISC_JMM_FB
+ tristate "JMM_FB Driver"
+
++config MISC_SERIAL_TEST
++ tristate "serial test driver"
++
+ source "drivers/misc/c2port/Kconfig"
+ source "drivers/misc/eeprom/Kconfig"
+ source "drivers/misc/cb710/Kconfig"
+diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
+index 7f3eadf0e..9aff2404c 100644
+--- a/drivers/misc/Makefile
++++ b/drivers/misc/Makefile
+@@ -68,6 +68,7 @@ obj-$(CONFIG_TMR_MANAGER) += xilinx_tmr_manager.o
+ obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o
+ obj-$(CONFIG_MISC_JMM_VCAP) += jmm_vcap.o
+ obj-$(CONFIG_MISC_JMM_FB) += jmm_fb.o
++obj-$(CONFIG_MISC_SERIAL_TEST) += serial_test.o
+ obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o
+ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o
+ obj-$(CONFIG_NSM) += nsm.o
+diff --git a/drivers/misc/serial_test.c b/drivers/misc/serial_test.c
+new file mode 100644
+index 000000000..1dbb9fc37
+--- /dev/null
++++ b/drivers/misc/serial_test.c
+@@ -0,0 +1,243 @@
++#include <linux/miscdevice.h>
++#include <linux/fs.h>
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/uaccess.h>
++#include <linux/io.h>
++#include <linux/platform_device.h>
++#include <linux/pm_runtime.h>
++#include <linux/of.h>
++
++
++
++static struct serial_test {
++ uint8_t *reg_base;
++ size_t reg_len;
++} serial_test;
++
++
++/*
++** This function will be called when we open the Misc device file
++*/
++static int serial_test_open(struct inode *inode, struct file *file)
++{
++ pr_info("serial_test device open\n");
++ return 0;
++}
++
++/*
++** This function will be called when we close the Misc Device file
++*/
++static int serial_test_close(struct inode *inodep, struct file *filp)
++{
++ pr_info("serial_test device close\n");
++ return 0;
++}
++
++/*
++** This function will be called when we write the Misc Device file
++*/
++static ssize_t serial_test_write(struct file *file, const char __user *buf,
++ size_t len, loff_t *ppos)
++{
++ pr_info("serial_test device write\n");
++
++ /* We are not doing anything with this data now */
++
++ return -ENODEV;
++}
++
++/*
++** This function will be called when we read the Misc Device file
++*/
++static ssize_t serial_test_read(struct file *filp, char __user *buf,
++ size_t count, loff_t *f_pos)
++{
++
++ if (*f_pos>=serial_test.reg_len) return 0;
++
++ if ((*f_pos+count)>serial_test.reg_len) {
++ count=serial_test.reg_len-*f_pos;
++ }
++
++ if (copy_to_user(buf, serial_test.reg_base+(*f_pos), count))
++ return -EFAULT;
++
++ (*f_pos) += count;
++
++ return count;
++}
++
++static loff_t serial_test_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=serial_test.reg_len + offset;
++ break;
++default:
++ return -EINVAL;
++}
++
++
++if (new_offset<0)
++ return -EINVAL;
++if (new_offset>serial_test.reg_len)
++ return -EINVAL;
++
++filp->f_pos=new_offset;
++
++return new_offset;
++}
++
++
++//File operation structure
++static const struct file_operations fops = {
++ .owner = THIS_MODULE,
++ .write = serial_test_write,
++ .read = serial_test_read,
++ .open = serial_test_open,
++ .release = serial_test_close,
++ .llseek = serial_test_llseek,
++};
++
++//Misc device structure
++struct miscdevice serial_test_device = {
++ .minor = MISC_DYNAMIC_MINOR,
++ .name = "serial_test",
++ .fops = &fops,
++};
++
++
++static const struct of_device_id serial_test_of_match[] = {
++ { .compatible = "jmm,serial-test" },
++ { /* end of table */ }
++};
++MODULE_DEVICE_TABLE(of, serial_test_of_match);
++
++
++static int serial_test_probe(struct platform_device *pdev)
++{
++ struct resource *res;
++ const struct of_device_id *match;
++ uint8_t *ptr;
++
++
++ match = of_match_node(serial_test_of_match, pdev->dev.of_node);
++ pr_info("serial_test match %px\n",match);
++ printk(KERN_ERR "serial_test" "serial_test match %px\n",match);
++ if (!match) {
++ dev_err(&pdev->dev, "of_match_node() failed\n");
++ printk(KERN_ERR "serial_test" "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 "serial_test" "can't get parent mmio range\n");
++ return -EINVAL;
++ }
++
++ serial_test.reg_len=res->end - res->start;
++ serial_test.reg_len++;
++ pr_info("serial_test resource indicates length of 0x%x\n",serial_test.reg_len);
++ printk(KERN_ERR "serial_test" "serial_test resource indicates length of 0x%x\n",serial_test.reg_len);
++
++ ptr = devm_ioremap_resource(&pdev->dev, res);
++ pr_info("serial_test devm_ioremap_resource() gives %px\n",ptr);
++ printk(KERN_ERR "serial_test" "serial_test devm_ioremap_resource() gives %px\n",ptr);
++
++ if (IS_ERR(ptr))
++ return PTR_ERR(ptr);
++
++ serial_test.reg_base=ptr;
++
++ return 0;
++}
++
++/**
++ * zynq_gpio_remove - Driver removal function
++ * @pdev: platform device instance
++ *
++ * Return: 0 always
++ */
++static void serial_test_remove(struct platform_device *pdev)
++{
++ serial_test.reg_base=NULL;
++}
++
++static struct platform_driver serial_test_driver = {
++ .driver = {
++ .name = "jmm-serial-test",
++ .of_match_table = serial_test_of_match,
++ },
++ .probe = serial_test_probe,
++ .remove = serial_test_remove,
++};
++
++
++static int __init serial_test_init(void)
++{
++ int error;
++
++ //serial_test_driver->driver.owner = THIS_MODULE;
++ //serial_test_driver->driver.bus=&platform_bus_type;
++
++ error=platform_driver_register(&serial_test_driver);
++ if (error) {
++ pr_err("platform_driver_register failed!!!\n");
++ printk(KERN_ERR "serial_test" "platform_driver_register failed!!!\n");
++ return error;
++ }
++
++ error = misc_register(&serial_test_device);
++ if (error) {
++ platform_driver_unregister(&serial_test_driver);
++ pr_err("misc_register failed!!!\n");
++ printk(KERN_ERR "serial_test" "misc_register failed!!!\n");
++ return error;
++ }
++
++ pr_info("misc_register init done!!!\n");
++ printk(KERN_ERR "serial_test" "misc_register init done!!!\n");
++
++#if 0
++ serial_test = ioremap(0xfffc0000,0x40000);
++ pr_info("serial_test mapped at %px\n",serial_test);
++#endif
++
++ return 0;
++}
++
++static void __exit serial_test_exit(void)
++{
++ misc_deregister(&serial_test_device);
++ platform_driver_unregister(&serial_test_driver);
++
++ pr_info("misc_register exit done!!!\n");
++
++#if 0
++ if (serial_test.reg_base) iounmap(serial_test.reg_base);
++#endif
++}
++
++module_init(serial_test_init)
++module_exit(serial_test_exit)
++
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("meh");
++MODULE_DESCRIPTION("serial_test driver");
++MODULE_VERSION("1.00");
++
++
++