root/lm-sensors/trunk/src/isa.h @ 96

Revision 96, 5.0 KB (checked in by frodo, 14 years ago)

Slightly better copyright messages, now telling what the file belongs

to.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    isa.h - Part of lm_sensors, Linux kernel modules for hardware
3            monitoring
4    Copyright (c) 1998  Frodo Looijaard <frodol@dds.nl>
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef SENSORS_SENSOR_H
22#define SENSORS_SENSOR_H
23
24#ifdef __KERNEL__
25
26/* This file must interface with Simon Vogl's i2c driver. Version 19981006 is
27   OK, earlier versions are not; later versions will probably give problems
28   too.
29*/
30#include <asm/types.h>
31
32/* SPINLOCK is defined in i2c.h. */
33#ifdef SPINLOCK
34#include <asm/spinlock.h>
35#else
36#include <asm/semaphore.h>
37#endif
38
39#ifdef LM_SENSORS
40#include "i2c.h"
41#else /* ndef LM_SENSORS */
42#include <linux/i2c.h>
43#endif /* def LM_SENSORS */
44
45/* Note that this driver is *not* built upon smbus.c, but is parallel to it.
46   We do not need SMBus facilities if we are on the ISA bus, after all */
47
48/* Declarations, to keep the compiler happy */
49struct isa_driver;
50struct isa_client;
51struct isa_algorithm;
52struct isa_adapter;
53
54/* A driver tells us how we should handle a specific kind of chip.
55   A specific instance of such a chip is called a client. 
56   This structure is essentially the same as i2c_driver. */
57struct isa_driver {
58  char name[32];
59  int id;
60  unsigned int flags;
61  int (* attach_adapter) (struct isa_adapter *);
62  int (* detach_client) (struct isa_client *);
63  int (* command) (struct isa_client *, unsigned int cmd, void *arg);
64  void (* inc_use) (struct isa_client *);
65  void (* dec_use) (struct isa_client *);
66};
67
68/* A client is a specifc instance of a chip: for each detected chip, there will
69   be a client. Its operation is controlled by a driver.
70   This structure is an extension of i2c_client. */
71struct isa_client {
72  char name[32];
73  int id;
74  unsigned int flags;
75  unsigned char addr;
76  struct isa_adapter *adapter;
77  struct isa_driver *driver;
78  void *data;
79
80  /* Here ended i2c_client */
81  unsigned int isa_addr;
82};
83
84/* An algorithm describes how a certain class of busses can be accessed.
85   A specific instance of sucj a bus is called an adapter.
86   This structure is essentially the same as i2c_adapter. */
87struct isa_algorithm {
88  char name[32];
89  unsigned int id;
90  int (* master_xfer) (struct isa_adapter *adap, struct i2c_msg msgs[],
91                       int num);
92  int (* slave_send) (struct isa_adapter *,char *, int);
93  int (* slave_recv) (struct isa_adapter *,char *, int);
94  int (* algo_control) (struct isa_adapter *, unsigned int, unsigned long);
95  int (* client_register) (struct isa_client *);
96  int (* client_unregister) (struct isa_client *);
97};
98
99/* An adapter is a specifc instance of a bus: for each detected bus, there will
100   be an adapter. Its operation is controlled by an algorithm.
101   SPINLOCK must be the same as declared in i2c.h.
102   This structure is essentially the same as i2c_algorithm. */
103struct isa_adapter {
104  char name[32];
105  unsigned int id;
106  struct isa_algorithm *algo;
107  void *data;
108#ifdef SPINLOCK
109  spinlock_t lock;
110  unsigned long lockflags;
111#else
112  struct semaphore lock;
113#endif
114  unsigned int flags;
115  struct isa_client *clients[I2C_CLIENT_MAX];
116  int client_count;
117  int timeout;
118  int retries;
119};
120
121
122/* Detect whether we are on the isa bus. If this returns true, all i2c
123  access will fail! */
124#define i2c_is_isa_client(clientptr) \
125        ((clientptr)->adapter->algo->id == ALGO_ISA)
126#define i2c_is_isa_adapter(adapptr) \
127        ((adapptr)->algo->id == ALGO_ISA)
128
129/* Next: define ISA variants of registering. */
130#define isa_add_algorithm(algoptr) \
131        i2c_add_algorithm((struct i2c_algorithm *) (algoptr))
132#define isa_del_algorithm(algoptr) \
133        i2c_del_algorithm((struct i2c_algorithm *) (algoptr))
134
135#define isa_add_adapter(adapptr) \
136        i2c_add_adapter((struct i2c_adapter *) (adapptr))
137#define isa_del_adapter(adapptr) \
138        i2c_del_adapter((struct i2c_adapter *) (adapptr))
139
140#define isa_add_driver(driverptr) \
141        i2c_add_driver((struct i2c_driver *) (driverptr))
142#define isa_del_driver(driverptr) \
143        i2c_add_driver((struct i2c_driver *) (driverptr))
144
145#define isa_attach_client(clientptr) \
146        i2c_attach_client((struct i2c_client *) (clientptr))
147#define isa_detach_client(clientptr) \
148        i2c_detach_client((struct i2c_client *) (clientptr))
149
150#endif /* def __KERNEL__ */
151
152/* We need to mark ISA algorithms in the algorithm structure. */
153#define ALGO_ISA 0x50000
154
155/* ISA Adapter ids */
156#define ISA_MAIN 1
157
158#endif /* ndef SENSORS_ISA_H */
Note: See TracBrowser for help on using the browser.