[prev in list] [next in list] [prev in thread] [next in thread] 

List:       leaf-cvs-commits
Subject:    [leaf-cvs-ci] devel/hejl/gpio 4501driver.c,1.3,1.4 4801driver.c,1.5,1.6 changelog.txt,1.3,1.4 common
From:       Martin Hejl <hejl () users ! sourceforge ! net>
Date:       2005-05-04 20:36:32
Message-ID: E1DTQbg-0002q0-N5 () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/leaf/devel/hejl/gpio
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10783

Modified Files:
	4501driver.c 4801driver.c changelog.txt common.c common.h
	readme.txt
Removed Files:
	4501writelcd.c
Log Message:
added patch by Andy that adds support for reading/writing the reset switch


Index: common.h
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/common.h,v retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** common.h	4 May 2005 19:17:57 -0000	1.5
--- common.h	4 May 2005 20:36:29 -0000	1.6
***************
*** 46,50 ****
  #define TEMPERATURE_PROC_FILENAME "driver/soekris_temp"
  #define VOLTAGE_PROC_FILENAME 	"driver/soekris_voltage"
! #define VERSION                 "1.3.2"

  /* by default, we use dynamic allocation of major numbers */
--- 46,51 ----
  #define TEMPERATURE_PROC_FILENAME "driver/soekris_temp"
  #define VOLTAGE_PROC_FILENAME 	"driver/soekris_voltage"
! #define RB_PROC_FILENAME       "driver/soekris_reset_button"
! #define VERSION                 "1.3.2a"

  /* by default, we use dynamic allocation of major numbers */
***************
*** 56,59 ****
--- 57,61 ----
  #define MINOR_FULL 1        /* access to GPIO0-GPIOxx (driver dependant) */
  #define MINOR_LED  254      /* access to the error LED */
+ #define MINOR_RB   253      /* access to the reset button */

  /* Read/write bitmask that determines input/output pins (1 means output, 0 input) \
                */
***************
*** 78,82 ****
--- 80,86 ----
  struct gpio_operations {
  	void (*writeErrorLed)(unsigned int);
+ 	void (*writeResetButton)(unsigned int);
  	unsigned int (*readErrorLed)();
+ 	unsigned int (*readResetButton)();
  	void (*write8Bit)(unsigned char);
  	unsigned char (*read8Bit)();

Index: changelog.txt
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/changelog.txt,v retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** changelog.txt	4 May 2005 19:17:57 -0000	1.3
--- changelog.txt	4 May 2005 20:36:29 -0000	1.4
***************
*** 45,46 ****
--- 45,50 ----
  * fixed (?) problem with MODVERSIONS enabled in the kernel
  * corrected JP5 description in 4801gpio.h
+
+ 1.3.2a 2005-05-04
+ * added patch by Andy (wireless@windsorcarclub.co.uk) that adds support for
+   reading/writing the reset switch
\ No newline at end of file

--- 4501writelcd.c DELETED ---

Index: 4801driver.c
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/4801driver.c,v retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** 4801driver.c	4 May 2005 19:17:57 -0000	1.5
--- 4801driver.c	4 May 2005 20:36:29 -0000	1.6
***************
*** 101,104 ****
--- 101,141 ----
  }

+ static void _net4801_write_reset_button(unsigned int on) {
+        static unsigned char value;
+
+         // ensure that the pin is configured as an output!
+        outl(47,geode_gpio_base+GEODE_GPIO_CFG_SEL);
+        outl(3, geode_gpio_base+GEODE_GPIO_CFG_ACCESS);
+
+         // note that the dword register order is
+         // bytes 0-3 = gpio 0-31 output
+         // bytes 4-7 = gpio 0-31 input
+         // bytes 16-19 = gpio 32-63 output
+         // bytes 20-23 = gpio 32-63 input
+         // thus to clear the reset button (GPIO47) we need
+         // the second byte in the second block - byte 17
+        value = inb(geode_gpio_base+GEODE_GPIO_DATA_OUT+17);
+        if (on!=0) {
+                set_bit(7, &value);
+        } else {
+                clear_bit(7, &value);
+        };
+        outb(value,geode_gpio_base+GEODE_GPIO_DATA_OUT+17);
+ }
+
+ static unsigned int _net4801_read_reset_button() {
+        return ((inb(geode_gpio_base+GEODE_GPIO_DATA_IN+2)&0x04)!=0?1:0);
+ }
+
+ static void _net4801_writeGPIO07(unsigned char new_value) {
+        device_select(SIO_GPIO_DEV);
+        outb(new_value, SIO_GPIO_BANK2_OUT);
+ }
+
+ static unsigned char _net4801_readGPIO07() {
+        device_select(SIO_GPIO_DEV);
+        return inb(SIO_GPIO_BANK2_IN);
+ }
+
  static void _net4801_select_pin(unsigned short port, unsigned short pin) {
  	/* select port/pin */
***************
*** 130,143 ****
  }

- static void _net4801_writeGPIO07(unsigned char new_value) {
- 	device_select(SIO_GPIO_DEV);
- 	outb(new_value, SIO_GPIO_BANK2_OUT);
- }
-
- static unsigned char _net4801_readGPIO07() {
- 	device_select(SIO_GPIO_DEV);
- 	return inb(SIO_GPIO_BANK2_IN);
- }
-

  static void _net4801_setGPIO07Direction(unsigned char new_direction) {
--- 167,170 ----
***************
*** 321,324 ****
--- 348,353 ----
  	.writeErrorLed       = _net4801_write_error_led,
  	.readErrorLed        = _net4801_read_error_led,
+ 	.writeResetButton    = _net4801_write_reset_button,
+ 	.readResetButton     = _net4801_read_reset_button,
  	.write8Bit           = _net4801_writeGPIO07,
  	.read8Bit            = _net4801_readGPIO07,
***************
*** 329,333 ****
  	.set16BitDirection   = _net4801_setGPIODirection,
  	.get16BitDirection   = _net4801_getGPIODirection,
! 	.init                = net4801_init,
  	.cleanup             = _net4801_cleanup,
  	.readTemperature     = _net4801_readTemperature_string,
--- 358,362 ----
  	.set16BitDirection   = _net4801_setGPIODirection,
  	.get16BitDirection   = _net4801_getGPIODirection,
! 	.init                =  net4801_init,
  	.cleanup             = _net4801_cleanup,
  	.readTemperature     = _net4801_readTemperature_string,

Index: 4501driver.c
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/4501driver.c,v retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 4501driver.c	4 May 2005 19:17:57 -0000	1.3
--- 4501driver.c	4 May 2005 20:36:29 -0000	1.4
***************
*** 42,45 ****
--- 42,60 ----
  extern int toString(unsigned long , char* , int );

+ static unsigned int read_reset_button() {
+        static unsigned int data;
+
+        /* fetch the current status  */
+ #if 0
+        data = readb(mmcr_virt_addr + SC520_PIODATA15_0 + 1);
+
+        if ((data & 0x2) ==0) return 0;
+        return 1;
+ #else
+         printk(OUR_NAME ": Reset button is not supported on the 4501!\n");
+         return 0;
+ #endif
+ }
+
  static unsigned int read_error_led() {
  	static unsigned int data;
***************
*** 164,167 ****
--- 179,183 ----
  	.writeErrorLed     = write_error_led,
  	.readErrorLed      = read_error_led,
+ 	.readResetButton   = read_reset_button,
  	.write8Bit         = write_gpio,
  	.read8Bit          = read_gpio,

Index: common.c
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/common.c,v retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** common.c	4 May 2005 19:17:57 -0000	1.5
--- common.c	4 May 2005 20:36:29 -0000	1.6
***************
*** 35,38 ****
--- 35,39 ----
  #define TEMP_PROC_FILE 8
  #define VOLT_PROC_FILE 16
+ #define RB_PROC_FILE 32

  #include "common.h"
***************
*** 129,132 ****
--- 130,137 ----
  				break;

+ 			case MINOR_RB:
+ 				driver_ops->writeResetButton(port_status);
+ 				break;
+
  			default:
  				ret=-EINVAL;
***************
*** 203,206 ****
--- 208,223 ----
  			break;

+ 			case MINOR_RB:
+ 				port_status = driver_ops->readResetButton();
+ 				if (copy_to_user(buf, &port_status, sizeof(char))) {
+ 					ret = -EFAULT;
+ 					goto out;
+ 				}
+ 				bytes_read++;
+ 				buf++;
+ 				*ppos = *ppos+1;
+ 				ret = bytes_read;
+ 				break;
+
  		case MINOR_LED:
  			port_status = driver_ops->readErrorLed();
***************
*** 230,234 ****
  {
  	unsigned m = minor(inode->i_rdev);
! 	if (m!=MINOR_BYTE && m!=MINOR_FULL && m!=MINOR_LED )
  		return -EINVAL;

--- 247,251 ----
  {
  	unsigned m = minor(inode->i_rdev);
! 	if (m!=MINOR_BYTE && m!=MINOR_FULL && m!=MINOR_LED && m!=MINOR_RB )
  		return -EINVAL;

***************
*** 444,447 ****
--- 461,544 ----
  }

+ static int procfile_rb_read(
+                                        char *buffer,
+                                        __attribute__ ((unused)) char **start,
+                                        off_t offset,
+                                        int len,
+                                        int *eof,
+                                        __attribute__ ((unused)) void *data)
+
+ {
+        unsigned int rb_status;
+
+        if (offset > 0 || len<3) {
+                return 0;
+        }
+
+        if (down_interruptible(&gpio_sema))
+                return -ERESTARTSYS;
+
+        MOD_INC_USE_COUNT;
+
+        rb_status = driver_ops->readResetButton();
+
+        if (rb_status) {
+                buffer[0] = '1';
+        } else {
+                buffer[0] = '0';
+        }
+
+        buffer[1] = '\n';
+        buffer[2] = 0;
+
+        /* *start = buffer;*/
+        *eof=1;
+
+        MOD_DEC_USE_COUNT;
+
+        up(&gpio_sema);
+
+        return 2;
+ }
+
+ static int procfile_rb_write( __attribute__ ((unused)) struct file *file,
+                                const char *buf,
+                                unsigned long count,
+                                __attribute__ ((unused)) void *data)
+ {
+        int len;
+        char new_rb_state[MAX_NUMBER_OF_PINS+1];
+
+        if (count==0) return 0;
+
+        if (down_interruptible(&gpio_sema))
+                return -ERESTARTSYS;
+
+        MOD_INC_USE_COUNT;
+
+        if(count > __number_of_pins) {
+                len = __number_of_pins;
+        } else {
+                len = count;
+        }
+
+        if(copy_from_user(new_rb_state, buf, len)) {
+                MOD_DEC_USE_COUNT;
+                return -EFAULT;
+        }
+
+        if (new_rb_state[0] == '1') {
+                driver_ops->writeResetButton(1);
+        } else {
+                driver_ops->writeResetButton(0);
+        }
+
+        MOD_DEC_USE_COUNT;
+
+        up(&gpio_sema);
+
+        return len;
+ }
+
  static int procfile_led_read(
  					char *buffer,
***************
*** 722,725 ****
--- 819,848 ----
  			break;

+ 			case MINOR_RB:        // /dev/gpio253 controls the reset button
+ 				switch(cmd) {
+ 					case PPCLAIM:
+ 					case PPRELEASE:
+ 					case PPFCONTROL:
+ 					case PPDATADIR: /* Doesn't work the same way */
+ 						break;
+
+ 					case PPWDATA:
+ 						ret = __get_user(value, (unsigned char *)arg);
+ 						if (ret==0) {
+ 							driver_ops->writeResetButton(value);
+ 						}
+
+ 						break;
+
+ 					case PPRDATA:
+ 						value = driver_ops->readResetButton();
+ 						ret = __put_user(value, (unsigned char *)arg);
+ 						break;
+
+ 					default:
+ 						return -ENOTTY;
+ 				}
+ 				break;
+
  		case MINOR_LED:        // /dev/gpio254 controls the error led
  			switch(cmd) {
***************
*** 772,775 ****
--- 895,899 ----
  	static struct proc_dir_entry *GPIO_Proc_File;
  	static struct proc_dir_entry *ErrorLED_Proc_File;
+ 	static struct proc_dir_entry *ResetButton_Proc_File;
  	static struct proc_dir_entry *Settings_Proc_File;
  	static struct proc_dir_entry *Temperature_Proc_File;
***************
*** 823,826 ****
--- 947,966 ----
  	}

+ 	ResetButton_Proc_File = create_proc_entry(
+ 						RB_PROC_FILENAME,
+ 						S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH,
+ 						NULL);
+
+ 	if(ResetButton_Proc_File == NULL) {
+ 		printk(KERN_ERR OUR_NAME ":Could not register " RB_PROC_FILENAME ". \
Terminating\n"); + 		common_cleanup();
+ 		return -ENOMEM;
+ 	} else {
+ 		ResetButton_Proc_File->write_proc=procfile_rb_write;
+ 		ResetButton_Proc_File->read_proc=procfile_rb_read;
+ 		init_map |= RB_PROC_FILE;
+ 	}
+
+
  	Settings_Proc_File = create_proc_entry(
  			SETTINGS_PROC_FILENAME,
***************
*** 894,897 ****
--- 1034,1040 ----
  		remove_proc_entry(LED_PROC_FILENAME, NULL);

+ 	if (init_map&RB_PROC_FILE)
+ 		remove_proc_entry(RB_PROC_FILENAME, NULL);
+
  	if (init_map&GPIO_PROC_FILE)
  		remove_proc_entry(GPIO_PROC_FILENAME, NULL);

Index: readme.txt
==================================================================RCS file: \
/cvsroot/leaf/devel/hejl/gpio/readme.txt,v retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** readme.txt	4 May 2005 19:16:28 -0000	1.2
--- readme.txt	4 May 2005 20:36:29 -0000	1.3
***************
*** 31,34 ****
--- 31,38 ----
          FreeBSD Soekris Net4801 Environmental Monitor
                  (http://phk.freebsd.dk/soekris/env4801/)
+ 		Dave Johnson (dave-soekris-mailinglist@centerclick.org)
+ 			various suggestions/fixes
+ 		Andy (wireless@windsorcarclub.co.uk)
+ 			reset-switch support

  Instructions for running the driver on a Soekris Net4501:



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r 
_______________________________________________
leaf-cvs-commits mailing list
leaf-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic