root/lm-sensors/trunk/kernel/busses/i2c-isa.c @ 496

Revision 496, 5.6 KB (checked in by frodo, 14 years ago)

First round of lm_sensors changes for the new I2C tree

* The i2c package can no longer be compiled as part of the lm_sensors tree
* The archive of the i2c package is removed
* smbus, i2c-dev and i2c-proc modules and headers have been removed; they

are now completely integrated into the i2c package

* The fake i2c.h header has been removed; this also allowed us to remove

the ugly LM_SENSORS and TBD defines.

* A new variable I2C_HEADERS is introduced in the Makefile. This allows

us to install the i2c headers in, for example, /usr/local/include/linux.

* All files now include <linux/i2c.h> instead of "i2c.h" and "smbus.h"

Status: 'make dep' works, all the right include files are found. 'make all'

does not yet work.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware
3            monitoring
4    Copyright (c) 1998, 1999  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/* This implements an i2c algorithm/adapter for ISA bus. Not that this is
22   on first sight very useful; almost no functionality is preserved.
23   Except that it makes writing drivers for chips which can be on both
24   the SMBus and the ISA bus very much easier. See lm78.c for an example
25   of this. */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29
30#include "compat.h"
31
32#include <linux/i2c.h>
33#if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,19)
34#include <linux/sched.h>
35#else
36#include <asm/semaphore.h>
37#endif
38
39#include "version.h"
40#include "i2c-isa.h"
41
42static int isa_master_xfer (struct isa_adapter *adap,
43                            struct i2c_msg msgs[], int num);
44static int isa_slave_send (struct isa_adapter *adap, char *data, int len);
45static int isa_slave_recv (struct isa_adapter *adap, char *data, int len);
46static int isa_algo_control (struct isa_adapter *adap, unsigned int cmd,
47                             unsigned long arg);
48static int isa_client_register (struct isa_client *client);
49static int isa_client_unregister (struct isa_client *client);
50
51static int isa_init(void);
52static int isa_cleanup(void);
53
54#ifdef MODULE
55extern int init_module(void);
56extern int cleanup_module(void);
57#endif /* MODULE */
58
59/* This is the actual algorithm we define */
60static struct isa_algorithm isa_algorithm = {
61  /* name */            "ISA bus adapter",
62  /* id */              ALGO_ISA,
63  /* master_xfer */     &isa_master_xfer,
64  /* slave_send */      &isa_slave_send,
65  /* slave_rcv */       &isa_slave_recv,
66  /* algo_control */    &isa_algo_control,
67  /* client_register */ &isa_client_register,
68  /* client_unregister*/&isa_client_unregister
69};
70
71/* There can only be one... */
72static struct isa_adapter isa_adapter;
73
74/* Used in isa_init/cleanup */
75static int isa_initialized;
76
77/* Algorithm master_xfer call-back implementation. Can't do that... */
78int isa_master_xfer (struct isa_adapter *adap, struct i2c_msg msgs[],
79                     int num)
80{
81#ifdef DEBUG
82  printk("i2c-isa.o: isa_master_xfer called for adapter `%s' "
83         "(no i2c level access possible!)\n",
84         adap->name);
85#endif
86  return -1;
87}
88
89/* Algorithm slave_send call-back implementation. Can't do that... */
90int isa_slave_send (struct isa_adapter *adap, char *data, int len)
91{
92#ifdef DEBUG
93  printk("i2c-isa.o: isa_slave_send called for adapter `%s' "
94         "(no i2c level access possible!)\n",
95         adap->name);
96#endif
97  return -1;
98}
99
100/* Algorithm slave_recv call-back implementation. Can't do that... */
101int isa_slave_recv (struct isa_adapter *adap, char *data, int len)
102{
103#ifdef DEBUG
104  printk("i2c-isa.o: isa_slave_recv called for adapter `%s' "
105         "(no i2c level access possible!)\n",
106         adap->name);
107#endif
108  return -1;
109}
110
111/* Here we can put additional calls to modify the workings of the algorithm.
112   But right now, there is no need for that. */
113int isa_algo_control (struct isa_adapter *adap, unsigned int cmd,
114                       unsigned long arg)
115{
116  return 0;
117}
118
119/* Ehm... This is called when a client is registered to an adapter. We could
120   do all kinds of neat stuff here like, ehm - returning success? */
121int isa_client_register (struct isa_client *client)
122{
123  return 0;
124}
125
126int isa_client_unregister (struct isa_client *client)
127{
128  return 0;
129}
130
131int isa_init(void)
132{
133  int res;
134  printk("isa.o version %s (%s)\n",LM_VERSION,LM_DATE);
135#ifdef DEBUG
136  if (isa_initialized) {
137    printk("i2c-isa.o: Oops, isa_init called a second time!\n");
138    return -EBUSY;
139  }
140#endif
141  isa_initialized = 0;
142  if ((res = isa_add_algorithm(&isa_algorithm))) {
143    printk("i2c-isa.o: Algorithm registration failed, module not inserted.\n");
144    isa_cleanup();
145    return res;
146  }
147  isa_initialized++;
148  strcpy(isa_adapter.name,"ISA main adapter");
149  isa_adapter.id = ALGO_ISA | ISA_MAIN;
150  isa_adapter.algo = &isa_algorithm;
151  if ((res = isa_add_adapter(&isa_adapter))) {
152    printk("i2c-isa.o: Adapter registration failed, "
153           "module isa.o is not inserted\n.");
154    isa_cleanup();
155    return res;
156  }
157  isa_initialized++;
158  printk("i2c-isa.o: ISA bus access for i2c modules initialized.\n");
159  return 0;
160}
161
162int isa_cleanup(void)
163{
164  int res;
165  if (isa_initialized >= 2)
166  {
167    if ((res = isa_del_adapter(&isa_adapter))) {
168      printk("i2c-isa.o: Adapter deregistration failed, module not removed.\n");
169      return res;
170    } else
171      isa_initialized--;
172  }
173  if (isa_initialized >= 1)
174  {
175    if ((res = isa_del_algorithm(&isa_algorithm))) {
176      printk("i2c-isa.o: Algorithm deregistration failed, module not removed.\n");
177      return res;
178    } else
179      isa_initialized--;
180  }
181  return 0;
182}
183
184#ifdef MODULE
185
186MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
187MODULE_DESCRIPTION("ISA bus access through i2c");
188
189int init_module(void)
190{
191  return isa_init();
192}
193
194int cleanup_module(void)
195{
196  return isa_cleanup();
197}
198
199#endif /* MODULE */
200
Note: See TracBrowser for help on using the browser.