root/lm-sensors/trunk/i2c/old-code/pcf-elektor.c @ 3

Revision 3, 3.1 KB (checked in by frodo, 16 years ago)

The basic directory structure for lmsensors2.

README.directories contains a description of the directories I created;

read it if you have questions about them.

doc/design is the design document I sent before through email.
doc/useful_addresses.html contains links to I2C, SMBus and sensors

information.

Note that we may have to change minor i2c things, like Makefiles; this
is why I put it in the archive too (we should, of course, send important
changes to Simon Vogl).

  • Property svn:eol-style set to native
Line 
1/* ------------------------------------------------------------------------- */
2/* pcf-lp.c i2c-hw access for PCF 8584 on bidir. parallel ports              */
3/* ------------------------------------------------------------------------- */
4/*
5    Copyright (C) 1995-97 Simon G. Vogl
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
20/* ------------------------------------------------------------------------- */
21static char rcsid[] = "$Id: pcf-elektor.c,v 1.1 1998/09/05 18:20:09 i2c Exp $";
22/*
23 * $Log: pcf-elektor.c,v $
24 * Revision 1.1  1998/09/05 18:20:09  i2c
25 * Initial revision
26 *
27 * Revision 1.1  1998/01/20 10:01:29  i2c
28 * Initial revision
29 *
30 * Revision 1.2  1997/06/03 06:00:10  i2c
31 * first version that works
32 *
33 * Revision 1.2  1996/11/20 20:20:46  i2c
34 * first version for ISA bus.
35 *
36 * Revision 1.1  1996/11/17 11:00:03  i2c
37 * Initial revision
38 *
39 *
40 */
41
42#include <linux/kernel.h>
43#include <linux/delay.h>
44#include <linux/ioport.h>
45#include <asm/io.h>
46#include <linux/errno.h>
47
48#include "i2c.h"
49#include "i2c-priv.h"
50
51/* ----- global defines ----------------------------------------------- */
52#define DEB(x)          /* should be reasonable open, close &c.         */
53#define DEB2(x)         /* low level debugging - very slow              */
54#define DEBE(x) x       /* error messages                               */
55
56#define DEBHW(x) x      /* lowest level hardware debug -- log changes of*/
57                        /* the bit lines...                             */
58                       
59#define basePort(port)  (i2c_table[minor].base+(port))
60
61/* ----- local functions ---------------------------------------------- */
62
63#if (PCFADAPS) > 1
64#  define Local static
65#else
66#  define Local inline
67#endif
68
69
70
71Local   int  pcf_read (int minor, int adr)
72{
73        int ret;
74        udelay(10);               /* Give the card some time */
75        ret = inb(basePort( (adr!=0) ));/* force max. increment of 1 */
76        return ret;
77}
78
79
80Local   void pcf_write (int minor, int adr,char data)
81{
82        udelay(10);               /* Give the card some time */
83        outb(data,basePort( (adr!=0) ));
84}
85
86
87Local   int  pcf_init (int minor)
88{
89        if (check_region(i2c_table[minor].base, 4) < 0 ) {
90                return -ENODEV;
91        } else {
92                request_region(i2c_table[minor].base,  4, "i2c (Elektor)");
93        }
94        return 0;
95}
96
97
98Local   void pcf_exit   (int minor)
99{
100        release_region( i2c_table[minor].base,  4 );
101}
102
103
104/* ------------------------------------------------------------------------
105 * Encapsulate the above functions in the correct operations structure.
106 * This is only done when more than one hardware adapter is supported.
107 */
108#if (PCFADAPS) > 1
109struct i2c_pcf_ops pcf_lp_ops = {
110        pcf_read,
111        pcf_write,
112        pcf_init,
113        pcf_exit
114};
115#endif
Note: See TracBrowser for help on using the browser.