From: John Crispin Date: Thu, 13 Dec 2007 21:18:28 +0000 (+0000) Subject: danube gpio cleanup X-Git-Tag: reboot~27503 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0b9ea77b885be6140b24f06bc421f5cca4a2de35;p=oweals%2Fopenwrt.git danube gpio cleanup SVN-Revision: 9739 --- diff --git a/target/linux/danube/files/drivers/char/danube_gpio.c b/target/linux/danube/files/drivers/char/danube_gpio.c index 0157446ec4..e6fe5fa40f 100644 --- a/target/linux/danube/files/drivers/char/danube_gpio.c +++ b/target/linux/danube/files/drivers/char/danube_gpio.c @@ -27,8 +27,32 @@ #include #include #include -#include -#include "port_defs.h" +#include + + +#define DANUBE_PORT_OUT_REG 0x00000010 +#define DANUBE_PORT_IN_REG 0x00000014 +#define DANUBE_PORT_DIR_REG 0x00000018 +#define DANUBE_PORT_ALTSEL0_REG 0x0000001C +#define DANUBE_PORT_ALTSEL1_REG 0x00000020 +#define DANUBE_PORT_OD_REG 0x00000024 +#define DANUBE_PORT_STOFF_REG 0x00000028 +#define DANUBE_PORT_PUDSEL_REG 0x0000002C +#define DANUBE_PORT_PUDEN_REG 0x00000030 + +#define PORT_MODULE_ID 0xff + +#define PORT_WRITE_REG(reg, value) \ + *((volatile u32*)(reg)) = (u32)value; + +#define PORT_READ_REG(reg, value) \ + value = (u32)*((volatile u32*)(reg)); + +#define PORT_IOC_CALL(ret,port,pin,func) \ + ret=danube_port_reserve_pin(port,pin,PORT_MODULE_ID); \ + if (ret == 0) ret=func(port,pin,PORT_MODULE_ID); \ + if (ret == 0) ret=danube_port_free_pin(port,pin,PORT_MODULE_ID); + #define MAX_PORTS 2 // Number of ports in system #define PINS_PER_PORT 16 // Number of available pins per port @@ -57,7 +81,7 @@ danube_port_reserve_pin (int port, int pin, int module_id) return -EBUSY; } - return OK; + return 0; } int @@ -73,7 +97,7 @@ danube_port_free_pin (int port, int pin, int module_id) return -EBUSY; danube_port_pin_usage[port][pin] = 0; - return OK; + return 0; } int @@ -93,7 +117,7 @@ danube_port_set_open_drain (int port, int pin, int module_id) reg |= (1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_OD_REG, reg); - return OK; + return 0; } int @@ -113,7 +137,7 @@ danube_port_clear_open_drain (int port, int pin, int module_id) reg &= ~(1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_OD_REG, reg); - return OK; + return 0; } int @@ -134,7 +158,7 @@ danube_port_set_pudsel (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_PUDSEL_REG, reg); - return OK; + return 0; } int @@ -155,7 +179,7 @@ danube_port_clear_pudsel (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_PUDSEL_REG, reg); - return OK; + return 0; } int @@ -175,7 +199,7 @@ danube_port_set_puden (int port, int pin, int module_id) reg |= (1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_PUDEN_REG, reg); - return OK; + return 0; } int @@ -195,7 +219,7 @@ danube_port_clear_puden (int port, int pin, int module_id) reg &= ~(1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_PUDEN_REG, reg); - return OK; + return 0; } int @@ -215,7 +239,7 @@ danube_port_set_stoff (int port, int pin, int module_id) reg |= (1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_STOFF_REG, reg); - return OK; + return 0; } int @@ -235,7 +259,7 @@ danube_port_clear_stoff (int port, int pin, int module_id) reg &= ~(1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_STOFF_REG, reg); - return OK; + return 0; } int @@ -255,7 +279,7 @@ danube_port_set_dir_out (int port, int pin, int module_id) reg |= (1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_DIR_REG, reg); - return OK; + return 0; } int @@ -275,7 +299,7 @@ danube_port_set_dir_in (int port, int pin, int module_id) reg &= ~(1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_DIR_REG, reg); - return OK; + return 0; } int @@ -295,7 +319,7 @@ danube_port_set_output (int port, int pin, int module_id) reg |= (1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_OUT_REG, reg); - return OK; + return 0; } int @@ -315,7 +339,7 @@ danube_port_clear_output (int port, int pin, int module_id) reg &= ~(1 << pin); PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_OUT_REG, reg); - return OK; + return 0; } int @@ -358,7 +382,7 @@ danube_port_set_altsel0 (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_ALTSEL0_REG, reg); - return OK; + return 0; } int @@ -380,7 +404,7 @@ danube_port_clear_altsel0 (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_ALTSEL0_REG, reg); - return OK; + return 0; } int @@ -402,7 +426,7 @@ danube_port_set_altsel1 (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_ALTSEL1_REG, reg); - return OK; + return 0; } int @@ -424,7 +448,7 @@ danube_port_clear_altsel1 (int port, int pin, int module_id) PORT_WRITE_REG (danube_port_bases[port] + DANUBE_PORT_ALTSEL1_REG, reg); - return OK; + return 0; } int @@ -652,13 +676,13 @@ danube_port_read_procmem (char *buf, char **start, off_t offset, int count, static int danube_port_open (struct inode *inode, struct file *filep) { - return OK; + return 0; } static int danube_port_release (struct inode *inode, struct file *filelp) { - return OK; + return 0; } static int @@ -828,7 +852,7 @@ danube_port_init (void) create_proc_read_entry ("driver/danube_port", 0, NULL, danube_port_read_procmem, NULL); - return OK; + return 0; } module_init (danube_port_init); diff --git a/target/linux/danube/files/include/asm-mips/danube/danube_ioctl.h b/target/linux/danube/files/include/asm-mips/danube/danube_ioctl.h new file mode 100644 index 0000000000..6d14f5d060 --- /dev/null +++ b/target/linux/danube/files/include/asm-mips/danube/danube_ioctl.h @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) 2007 John Crispin + * + */ +#ifndef _DANUBE_IOCTL_H__ +#define _DANUBE_IOCTL_H__ + +/*------------ LED */ + +struct danube_port_ioctl_parm +{ + int port; + int pin; + int value; +}; + +#define DANUBE_PORT_IOC_MAGIC 0xbf +#define DANUBE_PORT_IOCOD _IOW(DANUBE_PORT_IOC_MAGIC,0,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCPUDSEL _IOW(DANUBE_PORT_IOC_MAGIC,1,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCPUDEN _IOW(DANUBE_PORT_IOC_MAGIC,2,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCSTOFF _IOW(DANUBE_PORT_IOC_MAGIC,3,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCDIR _IOW(DANUBE_PORT_IOC_MAGIC,4,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCOUTPUT _IOW(DANUBE_PORT_IOC_MAGIC,5,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCINPUT _IOWR(DANUBE_PORT_IOC_MAGIC,6,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCALTSEL0 _IOW(DANUBE_PORT_IOC_MAGIC,7,struct danube_port_ioctl_parm) +#define DANUBE_PORT_IOCALTSEL1 _IOW(DANUBE_PORT_IOC_MAGIC,8,struct danube_port_ioctl_parm) + +#endif