summaryrefslogtreecommitdiffstats
path: root/target/linux/adm5120-2.6/files/drivers/char
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-03-19 17:34:37 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-03-19 17:34:37 +0000
commit14f5c350584f1b0f282cfe7724965fb44494b3eb (patch)
treeb35da0cddc71a9b1cf8639b770a4994c7c8024ae /target/linux/adm5120-2.6/files/drivers/char
parent83cf826ce2d25cf77fdd8fc905611d0ea5de45ef (diff)
Preliminary ADM5120 support, marked as broken
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6614 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/adm5120-2.6/files/drivers/char')
-rw-r--r--target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c b/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c
new file mode 100644
index 000000000..6fccfb029
--- /dev/null
+++ b/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c
@@ -0,0 +1,58 @@
+/*
+ * ADM5120 LED (GPIO) driver
+ *
+ * Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005
+ */
+
+#include <linux/autoconf.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/fs.h>
+
+#define LED_MINOR 151
+#define GPIO_IO ((unsigned long *)0xb20000b8)
+
+static ssize_t adm5120_led_write(struct file *file, const char __user *data,
+ size_t len, loff_t *ppos)
+{
+ unsigned char val;
+
+ if (!len || get_user(val, data))
+ return -EFAULT;
+ *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (val<<24);
+ return 1;
+}
+
+static struct file_operations adm5120_led_fops = {
+ .owner = THIS_MODULE,
+ .write = adm5120_led_write,
+};
+
+static struct miscdevice adm5120_led_device = {
+ LED_MINOR,
+ "led",
+ &adm5120_led_fops,
+};
+
+static int __init adm5120_led_init(void)
+{
+ printk(KERN_INFO "ADM5120 LED & GPIO driver\n");
+ if (misc_register(&adm5120_led_device)) {
+ printk(KERN_WARNING "Couldn't register device %d\n", LED_MINOR);
+ return -EBUSY;
+ }
+ return 0;
+}
+
+static void __exit adm5120_led_exit(void)
+{
+ misc_deregister(&adm5120_led_device);
+}
+
+module_init(adm5120_led_init);
+module_exit(adm5120_led_exit);
+
+MODULE_DESCRIPTION("ADM5120 LED and GPIO driver");
+MODULE_AUTHOR("Jeroen Vreeken");
+MODULE_LICENSE("GPL");