summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2011-03-16 09:28:30 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2011-03-16 09:28:30 (GMT)
commit2b19ea70a709702d26c2429c23546fe2adf02375 (patch)
tree9df8293d1bc0c421f3f7e6dc458ae778aefc1ebb
parentac8b957720cfb6dd4535c9c5cc47cf4ce53551cd (diff)
downloadopenipcam-2b19ea70a709702d26c2429c23546fe2adf02375.zip
openipcam-2b19ea70a709702d26c2429c23546fe2adf02375.tar.gz
openipcam-2b19ea70a709702d26c2429c23546fe2adf02375.tar.bz2
gpio driver for W90N745
-rw-r--r--uClinux-2.4.20-uc1/drivers/Makefile2
-rw-r--r--uClinux-2.4.20-uc1/drivers/gpio/Config.in7
-rw-r--r--uClinux-2.4.20-uc1/drivers/gpio/Makefile14
-rw-r--r--uClinux-2.4.20-uc1/drivers/gpio/gpio_core.c311
4 files changed, 333 insertions, 1 deletions
diff --git a/uClinux-2.4.20-uc1/drivers/Makefile b/uClinux-2.4.20-uc1/drivers/Makefile
index fb03e64..88d2f10 100644
--- a/uClinux-2.4.20-uc1/drivers/Makefile
+++ b/uClinux-2.4.20-uc1/drivers/Makefile
@@ -10,7 +10,7 @@ mod-subdirs := dio hil mtd sbus video macintosh usb input telephony sgi ide \
message/i2o message/fusion scsi md ieee1394 pnp isdn atm \
fc4 net/hamradio i2c acpi bluetooth
-subdir-y := parport char block net sound misc media cdrom hotplug
+subdir-y := parport char block net sound misc media cdrom hotplug gpio
subdir-m := $(subdir-y)
diff --git a/uClinux-2.4.20-uc1/drivers/gpio/Config.in b/uClinux-2.4.20-uc1/drivers/gpio/Config.in
new file mode 100644
index 0000000..fea208f
--- /dev/null
+++ b/uClinux-2.4.20-uc1/drivers/gpio/Config.in
@@ -0,0 +1,7 @@
+#
+# Gpio device configuration
+#
+mainmenu_option next_comment
+comment 'Winbond advanced setting'
+ dep_tristate 'Support W90N745 Chipset' CONFIG_W90N745
+endmenu
diff --git a/uClinux-2.4.20-uc1/drivers/gpio/Makefile b/uClinux-2.4.20-uc1/drivers/gpio/Makefile
new file mode 100644
index 0000000..2f78467
--- /dev/null
+++ b/uClinux-2.4.20-uc1/drivers/gpio/Makefile
@@ -0,0 +1,14 @@
+#
+# Makefile for the linux kernel.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+O_TARGET := gpio.o
+
+obj-y += gpio_core.o
+
+include $(TOPDIR)/Rules.make \ No newline at end of file
diff --git a/uClinux-2.4.20-uc1/drivers/gpio/gpio_core.c b/uClinux-2.4.20-uc1/drivers/gpio/gpio_core.c
new file mode 100644
index 0000000..8042e4d
--- /dev/null
+++ b/uClinux-2.4.20-uc1/drivers/gpio/gpio_core.c
@@ -0,0 +1,311 @@
+/*$6
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/locks.h>
+#include <linux/sched.h>
+
+#include <linux/slab.h> /* kmalloc */
+#include <asm/hardware.h>
+#include <linux/spinlock.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <gpio/gpio_interface.h>
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+
+void init_EBI(void) /* lsshi 2003-12-29 16:40 */
+{
+#if 0
+ DWORD_WRITE(EXT0CON, EXT0CON_DATA);
+ DWORD_WRITE(EXT1CON, EXT1CON_DATA);
+ DWORD_WRITE(EXT2CON, EXT2CON_DATA);
+ DWORD_WRITE(EXT3CON, EXT3CON_DATA);
+#endif
+ return;
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel0_3(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_0_3) | (mode & 0x3)
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel4_9(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_9_4) | ((mode & 0x3) << 2)
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel10_11(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_11_10) | (mode & 0x3) << 4
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel12(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_12) | (mode & 0x3) << 6
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel13(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_13) | (mode & 0x3) << 8
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel14(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_14) | (mode & 0x3) << 10
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel15_16(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_16_15) | (mode & 0x3) << 12
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ With IRQ capability
+ ===============================================================================
+ */
+int GPIO_EnableChannel17(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_17) | (mode & 0x3) << 14
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel18(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_18) | (mode & 0x3) << 16
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ mode=0x01 enable IRQ mode
+ ===============================================================================
+ */
+int GPIO_EnableChannel19(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_19) | (mode & 0x3) << 18
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_EnableChannel20(int mode)
+{
+ if(mode > 3) return GPIO_ERROR;
+ DWORD_WRITE
+ (
+ GPIO_CFG,
+ (DWORD_READ(GPIO_CFG) & GPIO_CHANNEL_20) | (mode & 0x3) << 20
+ );
+ return(GPIO_OK);
+}
+
+/*
+ ===============================================================================
+ gpio inline functions
+ ===============================================================================
+ */
+void GPIO_Enable_Channel(int channel) /* normal I/O mode */
+{
+ DWORD_WRITE(GPIO_CFG, (DWORD_READ(GPIO_CFG) & channel));
+ return;
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int Set_Dir(int channel, int dir)
+{
+ if(dir) /* out */
+ {
+ DWORD_WRITE(GPIO_DIR, DWORD_READ(GPIO_DIR) | (1 << channel));
+ }
+ else /* in */
+ {
+ DWORD_WRITE(GPIO_DIR, DWORD_READ(GPIO_DIR) &~(1 << channel));
+ }
+
+ return GPIO_OK;
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_Data_Out(int channel, int dataout)
+{
+ Set_Dir(channel, GPIO_OUT);
+
+ if(dataout > 1) return GPIO_ERROR;
+ if(dataout) /* write "1" */
+ {
+ DWORD_WRITE(GPIO_DATAOUT, DWORD_READ(GPIO_DATAOUT) | (1 << channel));
+ }
+ else /* write "0" */
+ {
+ DWORD_WRITE(GPIO_DATAOUT, DWORD_READ(GPIO_DATAOUT) &~(1 << channel));
+ }
+
+ return GPIO_OK;
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_Data_In(int channel)
+{
+ Set_Dir(channel, GPIO_IN);
+ return(DWORD_READ(GPIO_DATAIN) & (1 << channel));
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+void GPIO_SET(int line, int sig_status)
+{
+ GPIO_Data_Out(line, sig_status);
+
+ return;
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int GPIO_GET(int line)
+{
+ return GPIO_Data_In(line);
+}
+
+/*
+ ===============================================================================
+ ===============================================================================
+ */
+int check_irq_self(int main_type, int irq_type)
+{
+ /*--------------------------*/
+ volatile unsigned int value;
+ volatile unsigned char c;
+ /*--------------------------*/
+#if 0
+ value = CSR_READ_OFFSET(SHARE_IRQ_ADDR, main_type);
+ c = value & 0x0F;
+ printk("main_type=%d,check_irq_self=%x\n",main_type,c);
+
+ if(c==0x0f)
+ return 0;
+
+ if(irq_type & c)
+ return 1;
+ else
+ return 0;
+#endif
+}