diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-14 13:42:06 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-14 13:42:06 +0200 |
commit | 80c37bca675f02fb2bfe71f6ae5ba0232c65bd40 (patch) | |
tree | 03e10a0b2b8d6784eecdb40c997a00fad063d9dc | |
parent | 891595b9307eb2695411d8e32e4addd9cd927ec8 (diff) |
week 2 done: fix driver (reboot'd)week-2
-rw-r--r-- | beaglebone/readme.md | 2 | ||||
-rw-r--r-- | driver/config.h | 2 | ||||
-rw-r--r-- | driver/fopdrv.c | 10 | ||||
-rw-r--r-- | driver/main.c | 10 |
4 files changed, 9 insertions, 15 deletions
diff --git a/beaglebone/readme.md b/beaglebone/readme.md index 5231d8f..1a82c25 100644 --- a/beaglebone/readme.md +++ b/beaglebone/readme.md @@ -5,7 +5,7 @@ image by doing the following: ``` (login as `debian` with password `temppwd`) -$ curl -sLo- https://git.pipeframe.xyz/school/drvo/plain/2/rice.sh | sudo sh -s +$ curl -sLo- https://git.pipeframe.xyz/school/drvo/plain/beaglebone/rice.sh | sudo sh -s ``` This will upgrade the kernel to version `6.6.15-ti-rt-arm32-r1`, which supports diff --git a/driver/config.h b/driver/config.h index dbe3a86..87eb81f 100644 --- a/driver/config.h +++ b/driver/config.h @@ -23,4 +23,4 @@ typedef uint32_t ti_am335x_word_t; // total size of GPIO registers from p. 4990 (in bytes) #define GPIO_REG_SIZE 0x198 -#define PIN 19 +#define PIN 18 diff --git a/driver/fopdrv.c b/driver/fopdrv.c index 18a1d35..87aa30e 100644 --- a/driver/fopdrv.c +++ b/driver/fopdrv.c @@ -7,8 +7,6 @@ bool printed = false; // driver/char/mem.c read_null (/dev/null) ssize_t fop_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - printk("%s(<file>, <buf>, %u, <ppos>)\n", __PRETTY_FUNCTION__, count); - if (count < 2) return 0; if (printed) return 0; @@ -29,8 +27,6 @@ ssize_t fop_read(struct file *file, char __user *buf, size_t count, loff_t *ppos } 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); - // only allow single character as input if (count < 1) return count; if (count > 2) return count; @@ -44,11 +40,11 @@ ssize_t fop_write(struct file *file, const char __user *buf, size_t count, loff_ barrier(); if (input_buf[0] == '0') { - printk("TODO: TURN OFF OUTPUT\n"); + printk(DRV_NAME": OUTPUT OFF\n"); iowrite32((1<<PIN), gpio1 + GPIO_CLEARDATAOUT); wmb(); } if (input_buf[0] == '1') { - printk("TODO: TURN ON OUTPUT\n"); + printk(DRV_NAME": OUTPUT ON\n"); iowrite32((1<<PIN), gpio1 + GPIO_SETDATAOUT); wmb(); } @@ -58,7 +54,6 @@ ssize_t fop_write(struct file *file, const char __user *buf, size_t count, loff_ } int fop_open(struct inode * inode, struct file * file) { - printk("%s(<inode>, <file>)\n", __PRETTY_FUNCTION__); printed = false; return 0; // 0 seems to be a safe return value as it's used in driver/char/mem.c. The @@ -68,7 +63,6 @@ int fop_open(struct inode * inode, struct file * file) { } int fop_release(struct inode * inode, struct file * file) { - printk("%s(<inode>, <file>)\n", __PRETTY_FUNCTION__); return 0; // same as above, but found in driver/char/lp.c } diff --git a/driver/main.c b/driver/main.c index d8ea7fc..e7d7d96 100644 --- a/driver/main.c +++ b/driver/main.c @@ -62,9 +62,6 @@ static int mod_init(void) { goto free_device; } - printk("%s() -> 0 (%d:%d)\n", __PRETTY_FUNCTION__, MAJOR(node), MINOR(node)); - printk("one = %d, two = %d\n", one, not_named_two); - // configure gpio mux uint32_t* conf_gpmc_a3 = ioremap(TI_AM335X_CM_GPMC_A3_ADDR, sizeof(ti_am335x_word_t)); if (conf_gpmc_a3 == NULL) @@ -84,6 +81,9 @@ static int mod_init(void) { iowrite32(oe_reg, gpio1 + GPIO_OE); wmb(); iounmap(gpio1); + // printk("%s() -> 0 (%d:%d)\n", __PRETTY_FUNCTION__, MAJOR(node), MINOR(node)); + // printk("one = %d, two = %d\n", one, not_named_two); + return 0; free_device: @@ -93,7 +93,7 @@ free_cdev: free_class: class_destroy(class); return_err: - printk("%s() -> %d\n", __PRETTY_FUNCTION__, err); + // printk("%s() -> %d\n", __PRETTY_FUNCTION__, err); return err; } @@ -101,7 +101,7 @@ static void mod_exit(void) { device_destroy(class, node); cdev_del(cdev); class_destroy(class); - printk("%s()\n", __PRETTY_FUNCTION__); + // printk("%s()\n", __PRETTY_FUNCTION__); } module_init(mod_init); |