aboutsummaryrefslogtreecommitdiff
path: root/1/fopdrv.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-12 15:00:54 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-12 15:00:54 +0200
commitdfc09d8b14d15015b4afa5d674786ec74f616772 (patch)
treeb3c5955ecb2f970c306a2c0441c19d518547ebd2 /1/fopdrv.c
parent480640799470b4465d62348aaf73154423ddb896 (diff)
get pin 19 working
Diffstat (limited to '1/fopdrv.c')
-rw-r--r--1/fopdrv.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/1/fopdrv.c b/1/fopdrv.c
index e0ad41c..d048f15 100644
--- a/1/fopdrv.c
+++ b/1/fopdrv.c
@@ -1,4 +1,7 @@
+#include <linux/io.h>
+
#include "fopdrv.h"
+#include "config.h"
// driver/char/mem.c read_null (/dev/null)
ssize_t fop_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) {
@@ -6,7 +9,6 @@ ssize_t fop_read(struct file *file, char __user *buf, size_t count, loff_t *ppos
return 0;
}
-// driver/char/mem.c write_null
ssize_t fop_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) {
printk("%s(<file>, <buf>, %u, <ppos>)\n", __PRETTY_FUNCTION__, count);
@@ -18,13 +20,20 @@ ssize_t fop_write(struct file *file, const char __user *buf, size_t count, loff_
if (copy_from_user(input_buf + *ppos, buf, count))
return -EFAULT;
+ ti_am335x_word_t* gpio1 = ioremap(TI_AM335X_GPIO1_ADDR, GPIO_REG_SIZE);
+ barrier();
+
if (input_buf[0] == '0') {
printk("TODO: TURN OFF OUTPUT\n");
+ iowrite32((1<<PIN), gpio1 + GPIO_CLEARDATAOUT); wmb();
}
if (input_buf[0] == '1') {
printk("TODO: TURN ON OUTPUT\n");
+ iowrite32((1<<PIN), gpio1 + GPIO_SETDATAOUT); wmb();
}
+ iounmap(gpio1);
+
return count;
}