diff options
| -rw-r--r-- | drivers/char/nsc_gpio.c | 45 | ||||
| -rw-r--r-- | drivers/char/pc8736x_gpio.c | 3 | ||||
| -rw-r--r-- | drivers/char/scx200_gpio.c | 11 | ||||
| -rw-r--r-- | include/linux/nsc_gpio.h | 6 |
4 files changed, 34 insertions, 31 deletions
diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c index 929d68486c1a..d0b5d65a73fb 100644 --- a/drivers/char/nsc_gpio.c +++ b/drivers/char/nsc_gpio.c | |||
| @@ -14,22 +14,27 @@ | |||
| 14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 16 | #include <linux/nsc_gpio.h> | 16 | #include <linux/nsc_gpio.h> |
| 17 | #include <linux/platform_device.h> | ||
| 17 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
| 18 | #include <asm/io.h> | 19 | #include <asm/io.h> |
| 19 | 20 | ||
| 20 | #define NAME "nsc_gpio" | 21 | #define NAME "nsc_gpio" |
| 21 | 22 | ||
| 22 | void nsc_gpio_dump(unsigned index, u32 config) | 23 | void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index) |
| 23 | { | 24 | { |
| 24 | printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", | 25 | /* retrieve current config w/o changing it */ |
| 25 | index, (unsigned long)config, | 26 | u32 config = amp->gpio_config(index, ~0, 0); |
| 26 | (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ | 27 | |
| 27 | (config & 2) ? "PP" : "OD", /* push pull / open drain */ | 28 | /* user requested via 'v' command, so its INFO */ |
| 28 | (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ | 29 | dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\n", |
| 29 | (config & 8) ? "LOCKED" : "", /* locked / unlocked */ | 30 | index, config, |
| 30 | (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ | 31 | (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ |
| 31 | (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ | 32 | (config & 2) ? "PP" : "OD", /* push pull / open drain */ |
| 32 | (config & 64) ? "DEBOUNCE" : ""); /* debounce */ | 33 | (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ |
| 34 | (config & 8) ? "LOCKED" : "", /* locked / unlocked */ | ||
| 35 | (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ | ||
| 36 | (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ | ||
| 37 | (config & 64) ? "DEBOUNCE" : ""); /* debounce */ | ||
| 33 | } | 38 | } |
| 34 | 39 | ||
| 35 | ssize_t nsc_gpio_write(struct file *file, const char __user *data, | 40 | ssize_t nsc_gpio_write(struct file *file, const char __user *data, |
| @@ -37,6 +42,7 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data, | |||
| 37 | { | 42 | { |
| 38 | unsigned m = iminor(file->f_dentry->d_inode); | 43 | unsigned m = iminor(file->f_dentry->d_inode); |
| 39 | struct nsc_gpio_ops *amp = file->private_data; | 44 | struct nsc_gpio_ops *amp = file->private_data; |
| 45 | struct device *dev = amp->dev; | ||
| 40 | size_t i; | 46 | size_t i; |
| 41 | int err = 0; | 47 | int err = 0; |
| 42 | 48 | ||
| @@ -52,42 +58,41 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data, | |||
| 52 | amp->gpio_set(m, 1); | 58 | amp->gpio_set(m, 1); |
| 53 | break; | 59 | break; |
| 54 | case 'O': | 60 | case 'O': |
| 55 | printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); | 61 | dev_dbg(dev, "GPIO%d output enabled\n", m); |
| 56 | amp->gpio_config(m, ~1, 1); | 62 | amp->gpio_config(m, ~1, 1); |
| 57 | break; | 63 | break; |
| 58 | case 'o': | 64 | case 'o': |
| 59 | printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); | 65 | dev_dbg(dev, "GPIO%d output disabled\n", m); |
| 60 | amp->gpio_config(m, ~1, 0); | 66 | amp->gpio_config(m, ~1, 0); |
| 61 | break; | 67 | break; |
| 62 | case 'T': | 68 | case 'T': |
| 63 | printk(KERN_INFO NAME ": GPIO%d output is push pull\n", | 69 | dev_dbg(dev, "GPIO%d output is push pull\n", |
| 64 | m); | 70 | m); |
| 65 | amp->gpio_config(m, ~2, 2); | 71 | amp->gpio_config(m, ~2, 2); |
| 66 | break; | 72 | break; |
| 67 | case 't': | 73 | case 't': |
| 68 | printk(KERN_INFO NAME ": GPIO%d output is open drain\n", | 74 | dev_dbg(dev, "GPIO%d output is open drain\n", |
| 69 | m); | 75 | m); |
| 70 | amp->gpio_config(m, ~2, 0); | 76 | amp->gpio_config(m, ~2, 0); |
| 71 | break; | 77 | break; |
| 72 | case 'P': | 78 | case 'P': |
| 73 | printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); | 79 | dev_dbg(dev, "GPIO%d pull up enabled\n", m); |
| 74 | amp->gpio_config(m, ~4, 4); | 80 | amp->gpio_config(m, ~4, 4); |
| 75 | break; | 81 | break; |
| 76 | case 'p': | 82 | case 'p': |
| 77 | printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); | 83 | dev_dbg(dev, "GPIO%d pull up disabled\n", m); |
| 78 | amp->gpio_config(m, ~4, 0); | 84 | amp->gpio_config(m, ~4, 0); |
| 79 | break; | 85 | break; |
| 80 | case 'v': | 86 | case 'v': |
| 81 | /* View Current pin settings */ | 87 | /* View Current pin settings */ |
| 82 | amp->gpio_dump(m); | 88 | amp->gpio_dump(amp, m); |
| 83 | break; | 89 | break; |
| 84 | case '\n': | 90 | case '\n': |
| 85 | /* end of settings string, do nothing */ | 91 | /* end of settings string, do nothing */ |
| 86 | break; | 92 | break; |
| 87 | default: | 93 | default: |
| 88 | printk(KERN_ERR NAME | 94 | dev_err(dev, "io%2d bad setting: chr<0x%2x>\n", |
| 89 | ": GPIO-%2d bad setting: chr<0x%2x>\n", m, | 95 | m, (int)c); |
| 90 | (int)c); | ||
| 91 | err++; | 96 | err++; |
| 92 | } | 97 | } |
| 93 | } | 98 | } |
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index b16fbef816c2..48ff1fc8b06d 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c | |||
| @@ -207,8 +207,6 @@ static void pc8736x_gpio_change(unsigned index) | |||
| 207 | pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); | 207 | pc8736x_gpio_set(index, !pc8736x_gpio_get(index)); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | extern void nsc_gpio_dump(unsigned iminor); | ||
| 211 | |||
| 212 | static struct nsc_gpio_ops pc8736x_access = { | 210 | static struct nsc_gpio_ops pc8736x_access = { |
| 213 | .owner = THIS_MODULE, | 211 | .owner = THIS_MODULE, |
| 214 | .gpio_config = pc8736x_gpio_configure, | 212 | .gpio_config = pc8736x_gpio_configure, |
| @@ -260,6 +258,7 @@ static int __init pc8736x_gpio_init(void) | |||
| 260 | dev_err(&pdev->dev, "no device found\n"); | 258 | dev_err(&pdev->dev, "no device found\n"); |
| 261 | goto undo_platform_dev_add; | 259 | goto undo_platform_dev_add; |
| 262 | } | 260 | } |
| 261 | pc8736x_access.dev = &pdev->dev; | ||
| 263 | 262 | ||
| 264 | /* Verify that chip and it's GPIO unit are both enabled. | 263 | /* Verify that chip and it's GPIO unit are both enabled. |
| 265 | My BIOS does this, so I take minimum action here | 264 | My BIOS does this, so I take minimum action here |
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 442367b3f5dc..5a280a330401 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c | |||
| @@ -35,14 +35,6 @@ static int major = 0; /* default to dynamic major */ | |||
| 35 | module_param(major, int, 0); | 35 | module_param(major, int, 0); |
| 36 | MODULE_PARM_DESC(major, "Major device number"); | 36 | MODULE_PARM_DESC(major, "Major device number"); |
| 37 | 37 | ||
| 38 | extern void nsc_gpio_dump(unsigned index); | ||
| 39 | |||
| 40 | extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, | ||
| 41 | size_t len, loff_t *ppos); | ||
| 42 | |||
| 43 | extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, | ||
| 44 | size_t len, loff_t *ppos); | ||
| 45 | |||
| 46 | struct nsc_gpio_ops scx200_access = { | 38 | struct nsc_gpio_ops scx200_access = { |
| 47 | .owner = THIS_MODULE, | 39 | .owner = THIS_MODULE, |
| 48 | .gpio_config = scx200_gpio_configure, | 40 | .gpio_config = scx200_gpio_configure, |
| @@ -101,6 +93,9 @@ static int __init scx200_gpio_init(void) | |||
| 101 | if (rc) | 93 | if (rc) |
| 102 | goto undo_malloc; | 94 | goto undo_malloc; |
| 103 | 95 | ||
| 96 | /* nsc_gpio uses dev_dbg(), so needs this */ | ||
| 97 | scx200_access.dev = &pdev->dev; | ||
| 98 | |||
| 104 | if (major) | 99 | if (major) |
| 105 | rc = register_chrdev_region(dev, num_pins, "scx200_gpio"); | 100 | rc = register_chrdev_region(dev, num_pins, "scx200_gpio"); |
| 106 | else { | 101 | else { |
diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h index 27bf66f73868..135742cfada5 100644 --- a/include/linux/nsc_gpio.h +++ b/include/linux/nsc_gpio.h | |||
| @@ -22,13 +22,14 @@ | |||
| 22 | struct nsc_gpio_ops { | 22 | struct nsc_gpio_ops { |
| 23 | struct module* owner; | 23 | struct module* owner; |
| 24 | u32 (*gpio_config) (unsigned iminor, u32 mask, u32 bits); | 24 | u32 (*gpio_config) (unsigned iminor, u32 mask, u32 bits); |
| 25 | void (*gpio_dump) (unsigned iminor); | 25 | void (*gpio_dump) (struct nsc_gpio_ops *amp, unsigned iminor); |
| 26 | int (*gpio_get) (unsigned iminor); | 26 | int (*gpio_get) (unsigned iminor); |
| 27 | void (*gpio_set) (unsigned iminor, int state); | 27 | void (*gpio_set) (unsigned iminor, int state); |
| 28 | void (*gpio_set_high)(unsigned iminor); | 28 | void (*gpio_set_high)(unsigned iminor); |
| 29 | void (*gpio_set_low) (unsigned iminor); | 29 | void (*gpio_set_low) (unsigned iminor); |
| 30 | void (*gpio_change) (unsigned iminor); | 30 | void (*gpio_change) (unsigned iminor); |
| 31 | int (*gpio_current) (unsigned iminor); | 31 | int (*gpio_current) (unsigned iminor); |
| 32 | struct device* dev; /* for dev_dbg() support, set in init */ | ||
| 32 | }; | 33 | }; |
| 33 | 34 | ||
| 34 | extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, | 35 | extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, |
| @@ -36,3 +37,6 @@ extern ssize_t nsc_gpio_write(struct file *file, const char __user *data, | |||
| 36 | 37 | ||
| 37 | extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, | 38 | extern ssize_t nsc_gpio_read(struct file *file, char __user *buf, |
| 38 | size_t len, loff_t *ppos); | 39 | size_t len, loff_t *ppos); |
| 40 | |||
| 41 | extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index); | ||
| 42 | |||
