Hi Steve,

Steve Bennett wrote:
This patch adds a driver for simple access to the
Coldfire Internal Peripheral System (IPS) address space
via the /dev/ips char device.

Signed-Off-By: Steve Bennett <[EMAIL PROTECTED]>

I have some reservations about this one. Working with peripheral
space registers from user space is not something I want to
encourage.

And, even if I did, wouldn't mmap be a better interface to
them?

Regards
greg



diff -urN uClinux-dist.orig/linux-2.6.x/drivers/char/Makefile 
uClinux-dist/linux-2.6.x/drivers/char/Makefile
--- uClinux-dist.orig/linux-2.6.x/drivers/char/Makefile 2006-11-30 
12:03:15.000000000 +1000
+++ uClinux-dist/linux-2.6.x/drivers/char/Makefile      2007-05-11 
16:12:16.000000000 +1000
@@ -54,6 +54,7 @@
 obj-$(CONFIG_HVCS)             += hvcs.o
 obj-$(CONFIG_SGI_MBCS)         += mbcs.o
 obj-$(CONFIG_MCF_QSPI)         += mcf_qspi.o
+obj-$(CONFIG_MCF_IPS)          += mcf_ips.o
 obj-$(CONFIG_BRIQ_PANEL)       += briq_panel.o
obj-$(CONFIG_PRINTER) += lp.o
diff -urN uClinux-dist.orig/linux-2.6.x/drivers/char/mcf_ips.c 
uClinux-dist/linux-2.6.x/drivers/char/mcf_ips.c
--- uClinux-dist.orig/linux-2.6.x/drivers/char/mcf_ips.c        1970-01-01 
10:00:00.000000000 +1000
+++ uClinux-dist/linux-2.6.x/drivers/char/mcf_ips.c     2007-05-11 
16:12:16.000000000 +1000
@@ -0,0 +1,184 @@
+/*
+ * linux-2.4.x/drivers/char/mcf_ips.c
+ *
+ * Internal Peripheral System Access Driver
+ *
+ * Copyright (C) 2005 Intec Automation ([EMAIL PROTECTED])
+ *
+ *
+ * Provides simple access to the Coldfire Internal Peripheral System
+ * address space via the /dev/ips char device.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+
+#define DEVICE_NAME "ips"
+
+/* Use a dynamically assigned misc device minor */
+/*#define IPS_MAJOR 0*/
+/* Or a statically assigned device major */
+#define IPS_MAJOR 122
+
+MODULE_AUTHOR("Mike Lavender <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("Driver for Reading and Writing Peripherals");
+MODULE_SUPPORTED_DEVICE("Motorola MCF5282");
+MODULE_LICENSE("GPL");
+
+/* ioctl to set the read/write address */
+#define IPS_REG_SET 1
+
+static ssize_t
+    ips_read(
+        struct file *file,
+        char *buffer,
+            size_t length,
+            loff_t *offset )
+{
+    int ret = 0;
+
+    switch (length)
+    {
+        case 1:
+            *(char *)buffer = *(char *)file->private_data;
+            ret = 1;
+            break;
+        case 2:
+            *(short *)buffer = *(short *)file->private_data;
+            ret = 2;
+            break;
+        case 4:
+            *(int *)buffer = *(int *)file->private_data;
+            ret = 4;
+            break;
+        default:
+            memcpy( buffer, (char *)file->private_data, length );
+            ret = length;
+    }
+
+    return (ret);
+}
+
+static ssize_t
+    ips_write(
+        struct file *file,
+        const char *buffer,
+                size_t length,
+                loff_t *offset )
+{
+    int ret = 0;
+
+    switch (length)
+    {
+        case 1:
+            *(char *)file->private_data = *(char *)buffer;
+            ret = 1;
+            break;
+        case 2:
+            *(short *)file->private_data = *(short *)buffer;
+            ret = 2;
+            break;
+        case 4:
+            *(int *)file->private_data = *(int *)buffer;
+            ret = 4;
+            break;
+        default:
+            memcpy( (char *)file->private_data, buffer, length );
+            ret = length;
+    }
+
+    return (ret);
+}
+
+int
+    ips_ioctl(
+        struct inode *inode,
+        struct file *file,
+                unsigned int ioctl_num,
+                unsigned long ioctl_param )
+{
+    int ret = 0;
+
+    switch (ioctl_num) {
+        case IPS_REG_SET:
+            file->private_data = (void *)ioctl_param;
+            break;
+        default:
+            ret = -EINVAL;
+    }
+
+    return (ret);
+}
+
+static int
+    ips_open(
+        struct inode *inode,
+        struct file *file )
+{
+    return 0;
+}
+
+static int
+    ips_release(
+        struct inode *inode,
+        struct file *file )
+{
+    return 0;
+}
+
+/*  fixed for 2.4 kernel, owner was ifdef'ed out for 2.0 kernel */
+static struct file_operations fops = {
+        owner:          THIS_MODULE,
+        read:           ips_read,
+        write:          ips_write,
+        ioctl:          ips_ioctl,
+        open:           ips_open,
+        release:        ips_release  /* a.k.a. close */
+};
+
+#if IPS_MAJOR == 0
+static struct miscdevice misc_fops = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = DEVICE_NAME,
+       .fops = &fops
+};
+#endif
+
+int __init
+    ips_init(void)
+{
+       int ret;
+
+#if IPS_MAJOR == 0
+       ret = misc_register(&misc_fops);
+#else
+       ret = register_chrdev(IPS_MAJOR, DEVICE_NAME, &fops);
+#endif
+       
+       if (ret < 0) {
+               return -EIO;
+       }
+
+       printk("MCF IPS device driver installed\n");
+
+       return 0;
+}
+
+void __exit
+    ips_exit(void)
+{
+#if IPS_MAJOR == 0
+       misc_deregister(&misc_fops);
+#else
+       unregister_chrdev(IPS_MAJOR, DEVICE_NAME);
+#endif
+}
+
+module_init(ips_init);
+module_exit(ips_exit);
diff -urN uClinux-dist.orig/linux-2.6.x/drivers/char/Kconfig 
uClinux-dist/linux-2.6.x/drivers/char/Kconfig
--- uClinux-dist.orig/linux-2.6.x/drivers/char/Kconfig  2006-12-07 
17:19:47.000000000 +1000
+++ uClinux-dist/linux-2.6.x/drivers/char/Kconfig       2007-05-11 
16:12:16.000000000 +1000
@@ -1088,6 +1088,14 @@
        help
          Driver for Coldfire processors QSPI
+config MCF_IPS
+       tristate "Coldfire IPS access"
+       default n
+       depends on COLDFIRE
+       help
+         Simple access to the Coldfire Internal Peripheral System address space
+         via the /dev/ips char device.
+
 config M41T11M6
        tristate "M41T11M6 Real Time Clock (RTC) support"
        help


------------------------------------------------------------------------

_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

--
------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     [EMAIL PROTECTED]
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to