registers on proc filesystem
Matan Ziv-Av
matan@svgalib.org
Sat Jul 10 10:01:24 CEST 2004
The attached patch restores the 1100 and 1101 registers access through
proc filesystem.
--
Matan Ziv-Av. matan@svgalib.org
-------------- next part --------------
diff -urbB -x jornada820.c kernel26/arch/arm/mach-sa1100/Kconfig my2/arch/arm/mach-sa1100/Kconfig
--- kernel26/arch/arm/mach-sa1100/Kconfig 2004-07-03 16:29:33.000000000 +0300
+++ my2/arch/arm/mach-sa1100/Kconfig 2004-07-09 20:40:11.000000000 +0300
@@ -355,6 +355,10 @@
other devices, eg for BadgePAD 4 sensor support, or Jornada
720 touchscreen support.
+config REGISTERS
+ tristate "SA110/SA1101 Register access through /proc file system."
+ depends on ARCH_SA1100
+
config SA1100_USB
tristate "SA1100 USB function support"
depends on ARCH_SA1100
diff -urbB -x jornada820.c kernel26/arch/arm/mach-sa1100/regs-sa1100.c my2/arch/arm/mach-sa1100/regs-sa1100.c
--- kernel26/arch/arm/mach-sa1100/regs-sa1100.c 2004-06-24 19:58:36.000000000 +0300
+++ my2/arch/arm/mach-sa1100/regs-sa1100.c 2004-07-10 00:07:49.000000000 +0300
@@ -25,16 +25,6 @@
#define DEV_DIRNAME "sa1100"
#define REG_DIRNAME "registers"
-static ssize_t proc_read_reg(struct file * file, char * buf,
- size_t nbytes, loff_t *ppos);
-static ssize_t proc_write_reg(struct file * file, const char * buffer,
- size_t count, loff_t *ppos);
-
-static struct file_operations proc_reg_operations = {
- read: proc_read_reg,
- write: proc_write_reg
-};
-
typedef struct sa1100_reg_entry {
u32 phyaddr;
char* name;
@@ -234,50 +224,36 @@
#define NUM_OF_SA1100_REG_ENTRY (sizeof(sa1100_regs)/sizeof(sa1100_reg_entry_t))
-static int proc_read_reg(struct file * file, char * buf,
- size_t nbytes, loff_t *ppos)
+static int proc_read_reg(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
- int i_ino = (file->f_dentry->d_inode)->i_ino;
- char outputbuf[15];
- int count;
- int i;
- sa1100_reg_entry_t* current_reg=NULL;
- if (*ppos>0) /* Assume reading completed in previous read*/
- return 0;
- for (i=0;i<NUM_OF_SA1100_REG_ENTRY;i++) {
- if (sa1100_regs[i].low_ino==i_ino) {
- current_reg = &sa1100_regs[i];
- break;
- }
- }
+ char *p = page;
+ int len;
+ sa1100_reg_entry_t *current_reg=&sa1100_regs[(int)data];
+
if (current_reg==NULL)
return -EINVAL;
- count = sprintf(outputbuf, "0x%08X\n",
+ p += sprintf(p, "0x%08X\n",
*((volatile unsigned int *) io_p2v(current_reg->phyaddr)));
- *ppos+=count;
- if (count>nbytes) /* Assume output can be read at one time */
- return -EINVAL;
- if (copy_to_user(buf, outputbuf, count))
- return -EFAULT;
- return count;
+
+ len = (p - page) - off;
+ if (len < 0)
+ len = 0;
+
+ *eof = (len <= count) ? 1 : 0;
+ *start = page + off;
+
+ return len;
}
-static ssize_t proc_write_reg(struct file * file, const char * buffer,
- size_t count, loff_t *ppos)
+static ssize_t proc_write_reg(struct file * file, const __user char * buffer,
+ unsigned long count, void *data)
{
- int i_ino = (file->f_dentry->d_inode)->i_ino;
- sa1100_reg_entry_t* current_reg=NULL;
- int i;
+ sa1100_reg_entry_t *current_reg=&sa1100_regs[(int)data];
unsigned long newRegValue;
char *endp;
- for (i=0;i<NUM_OF_SA1100_REG_ENTRY;i++) {
- if (sa1100_regs[i].low_ino==i_ino) {
- current_reg = &sa1100_regs[i];
- break;
- }
- }
if (current_reg==NULL)
return -EINVAL;
@@ -311,8 +287,9 @@
S_IWUSR |S_IRUSR | S_IRGRP,
regdir);
if(entry) {
- sa1100_regs[i].low_ino = entry->low_ino;
- entry->proc_fops = &proc_reg_operations;
+ entry->read_proc = proc_read_reg;
+ entry->write_proc = proc_write_reg;
+ entry->data = (void *)i;
} else {
printk( KERN_ERR MODULE_NAME
": can't create /proc/" REG_DIRNAME
@@ -339,4 +316,3 @@
MODULE_DESCRIPTION("SA1100 Register monitor");
MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -urbB -x jornada820.c kernel26/arch/arm/mach-sa1100/regs-sa1101.c my2/arch/arm/mach-sa1100/regs-sa1101.c
--- kernel26/arch/arm/mach-sa1100/regs-sa1101.c 2004-06-27 16:21:37.000000000 +0300
+++ my2/arch/arm/mach-sa1100/regs-sa1101.c 2004-07-10 00:26:13.000000000 +0300
@@ -23,20 +23,12 @@
#include <asm/uaccess.h> /* to copy to/from userspace */
#include <asm/arch/hardware.h>
+#include <asm/arch/SA-1101.h>
+
#define MODULE_NAME "regmonsa1101"
#define DEV_DIRNAME "sa1101"
#define REG_DIRNAME "registers"
-static ssize_t proc_read_reg(struct file * file, char * buf,
- size_t nbytes, loff_t *ppos);
-static ssize_t proc_write_reg(struct file * file, const char * buffer,
- size_t count, loff_t *ppos);
-
-static struct file_operations proc_reg_operations = {
- read: proc_read_reg,
- write: proc_write_reg
-};
-
typedef struct sa1101_reg_entry {
u32 phyaddr;
char* name;
@@ -147,50 +139,36 @@
#define NUM_OF_SA1101_REG_ENTRY (sizeof(sa1101_regs)/sizeof(sa1101_reg_entry_t))
-static int proc_read_reg(struct file * file, char * buf,
- size_t nbytes, loff_t *ppos)
+static int proc_read_reg(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
- int i_ino = (file->f_dentry->d_inode)->i_ino;
- char outputbuf[15];
- int count;
- int i;
- sa1101_reg_entry_t* current_reg=NULL;
- if (*ppos>0) /* Assume reading completed in previous read*/
- return 0;
- for (i=0;i<NUM_OF_SA1101_REG_ENTRY;i++) {
- if (sa1101_regs[i].low_ino==i_ino) {
- current_reg = &sa1101_regs[i];
- break;
- }
- }
+ char *p = page;
+ int len;
+ sa1101_reg_entry_t *current_reg=&sa1101_regs[(int)data];
+
if (current_reg==NULL)
return -EINVAL;
- count = sprintf(outputbuf, "0x%08X\n",
+ p += sprintf(p, "0x%08X\n",
*((volatile unsigned int *) SA1101_p2v(current_reg->phyaddr)));
- *ppos+=count;
- if (count>nbytes) /* Assume output can be read at one time */
- return -EINVAL;
- if (copy_to_user(buf, outputbuf, count))
- return -EFAULT;
- return count;
+
+ len = (p - page) - off;
+ if (len < 0)
+ len = 0;
+
+ *eof = (len <= count) ? 1 : 0;
+ *start = page + off;
+
+ return len;
}
-static ssize_t proc_write_reg(struct file * file, const char * buffer,
- size_t count, loff_t *ppos)
+static ssize_t proc_write_reg(struct file * file, const __user char * buffer,
+ unsigned long count, void *data)
{
- int i_ino = (file->f_dentry->d_inode)->i_ino;
- sa1101_reg_entry_t* current_reg=NULL;
- int i;
+ sa1101_reg_entry_t *current_reg=&sa1101_regs[(int)data];
unsigned long newRegValue;
char *endp;
- for (i=0;i<NUM_OF_SA1101_REG_ENTRY;i++) {
- if (sa1101_regs[i].low_ino==i_ino) {
- current_reg = &sa1101_regs[i];
- break;
- }
- }
if (current_reg==NULL)
return -EINVAL;
@@ -224,8 +202,9 @@
S_IWUSR |S_IRUSR | S_IRGRP ,
regdir);
if(entry) {
- sa1101_regs[i].low_ino = entry->low_ino;
- entry->proc_fops = &proc_reg_operations;
+ entry->read_proc = proc_read_reg;
+ entry->write_proc = proc_write_reg;
+ entry->data = (void *)i;
} else {
printk( KERN_ERR MODULE_NAME
": can't create /proc/" REG_DIRNAME
@@ -252,4 +231,3 @@
MODULE_DESCRIPTION("SA1101 Register monitor");
MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
--- kernel26/include/asm-arm/arch-sa1100/SA-1101.h 2004-06-30 23:29:48.000000000 +0300
+++ my2/include/asm-arm/arch-sa1100/SA-1101.h 2004-07-10 00:42:38.000000000 +0300
@@ -7,9 +7,7 @@
* support chip for the sa1100
*
*/
-/* Jornada820 version based on SA-1101.h 1.1.1.1 from cvs.handhelds.org
- * $Id: SA-1101.h,v 1.3 2004/06/30 20:29:48 fare Exp $
- */
+
/* Be sure that virtual mapping is defined right */
#ifndef __ASM_ARCH_HARDWARE_H
@@ -28,14 +26,6 @@
# endif
#endif
-/*
- * We have mapped the sa1101 depending on the value of SA1101_BASE.
- * It then appears from 0xf4000000.
- */
-
-#define SA1101_p2v( x ) ((x) - SA1101_BASE + 0xf4000000)
-#define SA1101_v2p( x ) ((x) - 0xf4000000 + SA1101_BASE)
-
#ifndef SA1101_p2v
#define SA1101_p2v(PhAdd) (PhAdd)
#endif
@@ -634,72 +624,173 @@
/*
* PS/2 Trackpad and Mouse Interfaces
*
- * Registers
- * PS2CR Control Register
- * PS2STAT Status Register
- * PS2DATA Transmit/Receive Data register
- * PS2CLKDIV Clock Division Register
- * PS2PRECNT Clock Precount Register
- * PS2TEST1 Test register 1
- * PS2TEST2 Test register 2
- * PS2TEST3 Test register 3
- * PS2TEST4 Test register 4
+ * Registers (prefix kbd applies to trackpad interface, mse to mouse)
+ * KBDCR Control Register
+ * KBDSTAT Status Register
+ * KBDDATA Transmit/Receive Data register
+ * KBDCLKDIV Clock Division Register
+ * KBDPRECNT Clock Precount Register
+ * KBDTEST1 Test register 1
+ * KBDTEST2 Test register 2
+ * KBDTEST3 Test register 3
+ * KBDTEST4 Test register 4
+ * MSECR
+ * MSESTAT
+ * MSEDATA
+ * MSECLKDIV
+ * MSEPRECNT
+ * MSETEST1
+ * MSETEST2
+ * MSETEST3
+ * MSETEST4
+ *
*/
-/*
- * These are offsets from the above bases.
- * e.g. __MOUSE_INTERFACE + SA1101_PS2CR
- */
+#define _KBD( x ) _SA1101( ( x ) + __TRACK_INTERFACE )
+#define _MSE( x ) _SA1101( ( x ) + __MOUSE_INTERFACE )
+
+#define _KBDCR _KBD( 0x0000 )
+#define _KBDSTAT _KBD( 0x0400 )
+#define _KBDDATA _KBD( 0x0800 )
+#define _KBDCLKDIV _KBD( 0x0c00 )
+#define _KBDPRECNT _KBD( 0x1000 )
+#define _KBDTEST1 _KBD( 0x2000 )
+#define _KBDTEST2 _KBD( 0x2400 )
+#define _KBDTEST3 _KBD( 0x2800 )
+#define _KBDTEST4 _KBD( 0x2c00 )
+#define _MSECR _MSE( 0x0000 )
+#define _MSESTAT _MSE( 0x0400 )
+#define _MSEDATA _MSE( 0x0800 )
+#define _MSECLKDIV _MSE( 0x0c00 )
+#define _MSEPRECNT _MSE( 0x1000 )
+#define _MSETEST1 _MSE( 0x2000 )
+#define _MSETEST2 _MSE( 0x2400 )
+#define _MSETEST3 _MSE( 0x2800 )
+#define _MSETEST4 _MSE( 0x2c00 )
+
+#if ( LANGUAGE == C )
+
+#define KBDCR (*((volatile Word *) SA1101_p2v (_KBDCR)))
+#define KBDSTAT (*((volatile Word *) SA1101_p2v (_KBDSTAT)))
+#define KBDDATA (*((volatile Word *) SA1101_p2v (_KBDDATA)))
+#define KBDCLKDIV (*((volatile Word *) SA1101_p2v (_KBDCLKDIV)))
+#define KBDPRECNT (*((volatile Word *) SA1101_p2v (_KBDPRECNT)))
+#define KBDTEST1 (*((volatile Word *) SA1101_p2v (_KBDTEST1)))
+#define KBDTEST2 (*((volatile Word *) SA1101_p2v (_KBDTEST2)))
+#define KBDTEST3 (*((volatile Word *) SA1101_p2v (_KBDTEST3)))
+#define KBDTEST4 (*((volatile Word *) SA1101_p2v (_KBDTEST4)))
+#define MSECR (*((volatile Word *) SA1101_p2v (_MSECR)))
+#define MSESTAT (*((volatile Word *) SA1101_p2v (_MSESTAT)))
+#define MSEDATA (*((volatile Word *) SA1101_p2v (_MSEDATA)))
+#define MSECLKDIV (*((volatile Word *) SA1101_p2v (_MSECLKDIV)))
+#define MSEPRECNT (*((volatile Word *) SA1101_p2v (_MSEPRECNT)))
+#define MSETEST1 (*((volatile Word *) SA1101_p2v (_MSETEST1)))
+#define MSETEST2 (*((volatile Word *) SA1101_p2v (_MSETEST2)))
+#define MSETEST3 (*((volatile Word *) SA1101_p2v (_MSETEST3)))
+#define MSETEST4 (*((volatile Word *) SA1101_p2v (_MSETEST4)))
+
+
+#define KBDCR_ENA 0x08
+#define KBDCR_FKD 0x02
+#define KBDCR_FKC 0x01
+
+#define KBDSTAT_TXE 0x80
+#define KBDSTAT_TXB 0x40
+#define KBDSTAT_RXF 0x20
+#define KBDSTAT_RXB 0x10
+#define KBDSTAT_ENA 0x08
+#define KBDSTAT_RXP 0x04
+#define KBDSTAT_KBD 0x02
+#define KBDSTAT_KBC 0x01
+
+#define KBDCLKDIV_DivVal Fld(4,0)
+
+#define MSECR_ENA 0x08
+#define MSECR_FKD 0x02
+#define MSECR_FKC 0x01
+
+#define MSESTAT_TXE 0x80
+#define MSESTAT_TXB 0x40
+#define MSESTAT_RXF 0x20
+#define MSESTAT_RXB 0x10
+#define MSESTAT_ENA 0x08
+#define MSESTAT_RXP 0x04
+#define MSESTAT_MSD 0x02
+#define MSESTAT_MSC 0x01
+
+#define MSECLKDIV_DivVal Fld(4,0)
+
+#define KBDTEST1_CD 0x80
+#define KBDTEST1_RC1 0x40
+#define KBDTEST1_MC 0x20
+#define KBDTEST1_C Fld(2,3)
+#define KBDTEST1_T2 0x40
+#define KBDTEST1_T1 0x20
+#define KBDTEST1_T0 0x10
+#define KBDTEST2_TICBnRES 0x08
+#define KBDTEST2_RKC 0x04
+#define KBDTEST2_RKD 0x02
+#define KBDTEST2_SEL 0x01
+#define KBDTEST3_ms_16 0x80
+#define KBDTEST3_us_64 0x40
+#define KBDTEST3_us_16 0x20
+#define KBDTEST3_DIV8 0x10
+#define KBDTEST3_DIn 0x08
+#define KBDTEST3_CIn 0x04
+#define KBDTEST3_KD 0x02
+#define KBDTEST3_KC 0x01
+#define KBDTEST4_BC12 0x80
+#define KBDTEST4_BC11 0x40
+#define KBDTEST4_TRES 0x20
+#define KBDTEST4_CLKOE 0x10
+#define KBDTEST4_CRES 0x08
+#define KBDTEST4_RXB 0x04
+#define KBDTEST4_TXB 0x02
+#define KBDTEST4_SRX 0x01
+
+#define MSETEST1_CD 0x80
+#define MSETEST1_RC1 0x40
+#define MSETEST1_MC 0x20
+#define MSETEST1_C Fld(2,3)
+#define MSETEST1_T2 0x40
+#define MSETEST1_T1 0x20
+#define MSETEST1_T0 0x10
+#define MSETEST2_TICBnRES 0x08
+#define MSETEST2_RKC 0x04
+#define MSETEST2_RKD 0x02
+#define MSETEST2_SEL 0x01
+#define MSETEST3_ms_16 0x80
+#define MSETEST3_us_64 0x40
+#define MSETEST3_us_16 0x20
+#define MSETEST3_DIV8 0x10
+#define MSETEST3_DIn 0x08
+#define MSETEST3_CIn 0x04
+#define MSETEST3_KD 0x02
+#define MSETEST3_KC 0x01
+#define MSETEST4_BC12 0x80
+#define MSETEST4_BC11 0x40
+#define MSETEST4_TRES 0x20
+#define MSETEST4_CLKOE 0x10
+#define MSETEST4_CRES 0x08
+#define MSETEST4_RXB 0x04
+#define MSETEST4_TXB 0x02
+#define MSETEST4_SRX 0x01
+
+/* For sa1111ps2: */
#define SA1101_PS2CR 0x000000
#define SA1101_PS2STAT 0x000400
#define SA1101_PS2DATA 0x000800
#define SA1101_PS2CLKDIV 0x000c00
#define SA1101_PS2PRECNT 0x001000
-#if ( LANGUAGE == C )
-
-#define PS2CR_ENA 0x08
-#define PS2CR_FKD 0x02
-#define PS2CR_FKC 0x01
-
-#define PS2STAT_TXE 0x80
-#define PS2STAT_TXB 0x40
-#define PS2STAT_RXF 0x20
-#define PS2STAT_RXB 0x10
-#define PS2STAT_ENA 0x08
-#define PS2STAT_RXP 0x04
-#define PS2STAT_KBD 0x02
-#define PS2STAT_KBC 0x01
-
-#define PS2CLKDIV_DivVal Fld(4,0)
-
-#define PS2TEST1_CD 0x80
-#define PS2TEST1_RC1 0x40
-#define PS2TEST1_MC 0x20
-#define PS2TEST1_C Fld(2,3)
-#define PS2TEST1_T2 0x40
-#define PS2TEST1_T1 0x20
-#define PS2TEST1_T0 0x10
-#define PS2TEST2_TICBnRES 0x08
-#define PS2TEST2_RKC 0x04
-#define PS2TEST2_RKD 0x02
-#define PS2TEST2_SEL 0x01
-#define PS2TEST3_ms_16 0x80
-#define PS2TEST3_us_64 0x40
-#define PS2TEST3_us_16 0x20
-#define PS2TEST3_DIV8 0x10
-#define PS2TEST3_DIn 0x08
-#define PS2TEST3_CIn 0x04
-#define PS2TEST3_KD 0x02
-#define PS2TEST3_KC 0x01
-#define PS2TEST4_BC12 0x80
-#define PS2TEST4_BC11 0x40
-#define PS2TEST4_TRES 0x20
-#define PS2TEST4_CLKOE 0x10
-#define PS2TEST4_CRES 0x08
-#define PS2TEST4_RXB 0x04
-#define PS2TEST4_TXB 0x02
-#define PS2TEST4_SRX 0x01
+#define PS2STAT_RXF KBDSTAT_RXF
+#define PS2STAT_RXP KBDSTAT_RXP
+#define PS2STAT_TXE KBDSTAT_TXE
+#define PS2STAT_KBC KBDSTAT_KBC
+#define PS2STAT_KBD KBDSTAT_KBD
+#define PS2CR_ENA KBDCR_ENA
+#define PS2CR_FKC KBDCR_FKC
+#define PS2CR_FKD KBDCR_FKD
#endif /* LANGUAGE == C */
@@ -708,11 +799,11 @@
* General-Purpose I/O Interface
*
* Registers
- * PS2WR Port A Data Write Register
+ * PADWR Port A Data Write Register
* PBDWR Port B Data Write Register
- * PS2RR Port A Data Read Register
+ * PADRR Port A Data Read Register
* PBDRR Port B Data Read Register
- * PS2DR Port A Data Direction Register
+ * PADDR Port A Data Direction Register
* PBDDR Port B Data Direction Register
* PASSR Port A Sleep State Register
* PBSSR Port B Sleep State Register
@@ -721,11 +812,11 @@
#define _PIO( x ) _SA1101( ( x ) + __GPIO_INTERFACE )
-#define _PS2WR _PIO( 0x0000 )
+#define _PADWR _PIO( 0x0000 )
#define _PBDWR _PIO( 0x0400 )
-#define _PS2RR _PIO( 0x0000 )
+#define _PADRR _PIO( 0x0000 )
#define _PBDRR _PIO( 0x0400 )
-#define _PS2DR _PIO( 0x0800 )
+#define _PADDR _PIO( 0x0800 )
#define _PBDDR _PIO( 0x0c00 )
#define _PASSR _PIO( 0x1000 )
#define _PBSSR _PIO( 0x1400 )
@@ -733,11 +824,12 @@
#if ( LANGUAGE == C )
-#define PS2WR (*((volatile Word *) SA1101_p2v (_PS2WR)))
+
+#define PADWR (*((volatile Word *) SA1101_p2v (_PADWR)))
#define PBDWR (*((volatile Word *) SA1101_p2v (_PBDWR)))
-#define PS2RR (*((volatile Word *) SA1101_p2v (_PS2RR)))
+#define PADRR (*((volatile Word *) SA1101_p2v (_PADRR)))
#define PBDRR (*((volatile Word *) SA1101_p2v (_PBDRR)))
-#define PS2DR (*((volatile Word *) SA1101_p2v (_PS2DR)))
+#define PADDR (*((volatile Word *) SA1101_p2v (_PADDR)))
#define PBDDR (*((volatile Word *) SA1101_p2v (_PBDDR)))
#define PASSR (*((volatile Word *) SA1101_p2v (_PASSR)))
#define PBSSR (*((volatile Word *) SA1101_p2v (_PBSSR)))
@@ -788,9 +880,9 @@
#define _CARD( x ) _SA1101( ( x ) + __PCMCIA_INTERFACE )
-#define _PCSR _CARD( 0x0000 )
-#define _PCCR _CARD( 0x0400 )
-#define _PCSSR _CARD( 0x0800 )
+#define _PCCR _CARD( 0x0000 )
+#define _PCSSR _CARD( 0x0400 )
+#define _PCSR _CARD( 0x0800 )
#if ( LANGUAGE == C )
#define PCSR (*((volatile Word *) SA1101_p2v (_PCSR)))
More information about the Jornada820
mailing list