lkml.org 
[lkml]   [2006]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch -mm 16/20] chardev: GPIO for SCx200 & PC-8736x: fix gpio_current, use shadow regs
16/20. patch.shadow-current

Add a working gpio_current() to pc8736x_gpio.c (the previous
implementation just threw a dev_warn), and fix gpio_change() to use
gpio_current() rather than the incorrect (and temporary) gpio_get().
Initialize shadow-regs so this all works.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>

---

diffstat gpio-scx/patch.shadow-current
pc8736x_gpio.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)

diff -ruNp -X dontdiff -X exclude-diffs ax-15/drivers/char/pc8736x_gpio.c ax-16/drivers/char/pc8736x_gpio.c
--- ax-15/drivers/char/pc8736x_gpio.c 2006-06-17 01:45:49.000000000 -0600
+++ ax-16/drivers/char/pc8736x_gpio.c 2006-06-17 01:48:50.000000000 -0600
@@ -33,6 +33,7 @@ MODULE_PARM_DESC(major, "Major device nu

static DEFINE_SPINLOCK(pc8736x_gpio_config_lock);
static unsigned pc8736x_gpio_base;
+static u8 pc8736x_gpio_shadow[4];

#define SIO_BASE1 0x2E /* 1st command-reg to check */
#define SIO_BASE2 0x4E /* alt command-reg to check */
@@ -184,6 +185,7 @@ static void pc8736x_gpio_set(unsigned mi
val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN);

dev_dbg(&pdev->dev, "wrote %x, read: %x\n", curval, val);
+ pc8736x_gpio_shadow[port] = val;
}

static void pc8736x_gpio_set_high(unsigned index)
@@ -196,15 +198,18 @@ static void pc8736x_gpio_set_low(unsigne
pc8736x_gpio_set(index, 0);
}

-static int pc8736x_gpio_current(unsigned index)
+static int pc8736x_gpio_current(unsigned minor)
{
- dev_warn(&pdev->dev, "pc8736x_gpio_current unimplemented\n");
- return 0;
+ int port, bit;
+ minor &= 0x1f;
+ port = minor >> 3;
+ bit = minor & 7;
+ return pc8736x_gpio_shadow[port] >> bit & 0x01;
}

static void pc8736x_gpio_change(unsigned index)
{
- pc8736x_gpio_set(index, !pc8736x_gpio_get(index));
+ pc8736x_gpio_set(index, !pc8736x_gpio_current(index));
}

extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned iminor);
@@ -240,6 +245,18 @@ static struct file_operations pc8736x_gp
.read = nsc_gpio_read,
};

+static void __init pc8736x_init_shadow(void)
+{
+ int port;
+
+ /* read the current values driven on the GPIO signals */
+ for (port = 0; port < 4; ++port)
+ pc8736x_gpio_shadow[port]
+ = inb_p(pc8736x_gpio_base + port_offset[port]
+ + PORT_OUT);
+
+}
+
static int __init pc8736x_gpio_init(void)
{
int r, rc;
@@ -306,5 +323,7 @@ static void __exit pc8736x_gpio_cleanup(
unregister_chrdev(major, DEVNAME);
}

+EXPORT_SYMBOL(pc8736x_access);
+
module_init(pc8736x_gpio_init);
module_exit(pc8736x_gpio_cleanup);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-06-17 20:39    [W:0.028 / U:1.144 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site