#include <linux/module.h>
#include <linux/delay.h>
-#define RDC3210_CFGREG_ADDR 0x0CF8
-#define RDC3210_CFGREG_DATA 0x0CFC
+#include <asm/mach-rdc/rdc321x_defs.h>
+
+static inline int rdc_gpio_is_valid(unsigned gpio)
+{
+ return ((gpio > RDC_MAX_GPIO) ? 0 : 1);
+}
static unsigned int rdc_gpio_read(unsigned gpio)
{
unsigned int val;
- val = 0x80000000 | (7 << 11) | ((0x48));
+ val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x84:0x48));
outl(val, RDC3210_CFGREG_ADDR);
udelay(10);
val = inl(RDC3210_CFGREG_DATA);
- val |= (0x1 << gpio);
+ val |= (0x1 << (gpio & 0x1F));
outl(val, RDC3210_CFGREG_DATA);
udelay(10);
- val = 0x80000000 | (7 << 11) | ((0x4C));
+ val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x88:0x4C));
outl(val, RDC3210_CFGREG_ADDR);
udelay(10);
val = inl(RDC3210_CFGREG_DATA);
return val;
}
-void rdc_gpio_write(unsigned int val)
+static void rdc_gpio_write(unsigned int val)
{
if (val) {
outl(val, RDC3210_CFGREG_DATA);
int rdc_gpio_get_value(unsigned gpio)
{
- return ((int)rdc_gpio_read(gpio));
+ if (rdc_gpio_is_valid(gpio))
+ return (int)rdc_gpio_read(gpio);
}
EXPORT_SYMBOL(rdc_gpio_get_value);
{
unsigned int val;
+ if (!rdc_gpio_is_valid(gpio))
+ return;
+
val = rdc_gpio_read(gpio);
if (value)
- val &= ~(0x1 << gpio);
+ val &= ~(0x1 << (gpio & 0x1F));
else
- val |= (0x1 << gpio);
+ val |= (0x1 << (gpio & 0x1F));
rdc_gpio_write(val);
}