Changeset 8

Show
Ignore:
Timestamp:
11/19/98 04:07:18 (15 years ago)
Author:
frodo
Message:

Module smbus.o, many other small changes

Location:
lm-sensors/trunk
Files:
16 added
7 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/Makefile

    r6 r8  
     1#  Makefile - Makefile for a Linux module for reading sensor data. 
     2#  Copyright (c) 1998  Frodo Looijaard <frodol@dds.nl> 
     3# 
     4#  This program is free software; you can redistribute it and/or modify 
     5#  it under the terms of the GNU General Public License as published by 
     6#  the Free Software Foundation; either version 2 of the License, or 
     7#  (at your option) any later version. 
     8# 
     9#  This program is distributed in the hope that it will be useful, 
     10#  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     11#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     12#  GNU General Public License for more details. 
     13# 
     14#  You should have received a copy of the GNU General Public License 
     15#  along with this program; if not, write to the Free Software 
     16#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
     17 
     18 
    119# Uncomment the third line on SMP systems if the magic invocation fails. 
    220SMP := $(shell if grep -q '^SMP[[:space:]]*=' /usr/src/linux/Makefile; then echo 1; else echo 0; fi) 
     
    1331# i2c modules. WARNING! If the i2c module version does not match the  
    1432# smbus/sensor module versions, you will get into severe problems. 
     33# If you want to use a self-compiled version of the i2c modules, make 
     34# sure <linux/i2c.h> contains the *correct* i2c header file! 
    1535I2C := 1 
    1636#I2C := 0 
     
    4666 
    4767# The subdirectories we need to build things in  
    48 MODULES := 
     68MODULES := src 
    4969ifeq ($(I2C),1) 
    50 MODULES += i2c 
     70MODULES += i2c i2c/detect i2c/drivers i2c/eeprom 
    5171endif 
    5272 
     
    5474MKDIR := mkdir -p 
    5575RM := rm -f 
     76CC := gcc 
    5677 
    5778# Determine the default compiler flags 
    58 CFLAGS := -D__KERNEL__ -DMODULE -I. -O2 -fomit-frame-pointer 
     79# CFLAGS is to create in-kernel object files (modules); EXCFLAGS is to create 
     80# non-kernel object files (which are linked into executables). 
     81CFLAGS := -D__KERNEL__ -DMODULE -I. -Ii2c -O2 -fomit-frame-pointer 
     82EXCFLAGS := -I. -O2 -Ii2c 
    5983 
    6084ifeq ($(SMP),1) 
     
    6589CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 
    6690          -Wcast-align -Wwrite-strings -Wnested-externs -Winline 
     91EXCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 
     92            -Wcast-align -Wwrite-strings -Wnested-externs -Winline 
    6793endif 
    6894 
     
    7197endif 
    7298 
    73 .PHONY: all clean install version package 
     99ifeq ($(I2C),1) 
     100CFLAGS += -DI2C 
     101endif 
     102 
     103.PHONY: all clean install version package dep 
    74104 
    75105# Make all the default rule 
     
    79109include $(patsubst %,%/Module.mk,$(MODULES)) 
    80110 
     111# Making the dependency files - done automatically! 
     112dep: 
    81113 
    82 all:: 
     114all :: 
    83115 
    84 install:: 
     116install :: all 
    85117 
    86118clean:: 
    87119        $(RM) lm_sensors-* 
    88120 
    89 # Create a dependency file. Tricky. 
     121# Create a dependency file. Tricky. We sed rule puts dir/file.d and dir/file.c 
     122# in front of the dependency file rule. 
    90123%.d: %.c 
    91         gcc -M -MG $(CFLAGS) $< | \ 
    92         sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@ 
     124        $(CC) -M -MG $(CFLAGS) $< | \ 
     125        sed -e 's@^\(.*\)\.o:@$*.d $*.o Makefile '`dirname $*.d`/Module.mk':@' > $@ 
    93126         
    94127 
  • lm-sensors/trunk/doc/design

    r3 r8  
    55 
    66Document version 1.0, 19981101. 
     7                 1.1, 19981111. 
     8                 1.2, 19981118. 
    79 
    810 
     
    131133Main SMBus handling 
    132134Unites I2C adapters and SMBus hosts (like the PIIX4) 
     135Defines smbus_algorithm 
    133136 
    134137  piix4.o 
     
    332335we can add a hook somewhere in the i2c module to help us decide this. 
    333336 
    334  
    335 A driver, client and adapter 
    336 ------------------- 
     337This module consists in fact of two separate parts: first of all, it extends 
     338all i2c structs to accomodate the new smbus fields. Second, it defines a 
     339new algorithm (smbus_algorithm), that will be used by all non-i2c adapters. 
     340 
     341 
     342A driver, client and algorithm 
     343------------------------------ 
    337344 
    338345We will not need to extend i2c_driver, i2c_client or i2c_adapter. This means 
     
    347354 
    348355 
    349 An algorithm 
     356An adapter 
    350357------------ 
    351358 
    352 struct smbus_algorithm { 
     359struct smbus_adapter { 
    353360  char name[32]; 
    354361  unsigned int id; 
    355   int (* master_xfer) (struct smbus_adapter *adap, struct smbus_msg msgs[], 
    356                        int num); 
    357   int (* slave_send) (struct smbus_adapter *,char *, int); 
    358   int (* slave_recv) (struct smbus_adapter *,char *, int); 
    359   int (* algo_control) (struct smbus_adapter *, unsigned int, unsigned long); 
    360   int (* client_register) (struct smbus_client *); 
    361   int (* client_unregister) (struct smbus_client *); 
    362  
    363   int (* smbus_access) (struct smbus_adapter *, __u8 addr, char read_write, 
     362  struct smbus_algorithm *algo; 
     363  void *data; 
     364#ifdef SPINLOCK 
     365  spinlock_t lock; 
     366  unsigned long lockflags; 
     367#else 
     368  struct semaphore lock; 
     369#endif 
     370  unsigned int flags; 
     371  struct smbus_client *clients[I2C_CLIENT_MAX]; 
     372  int client_count; 
     373  int timeout; 
     374  int retries; 
     375 
     376  /* Here ended i2c_algorithm */ 
     377  s32 (* smbus_access) (__u8 addr, char read_write, 
    364378                        __u8 command, int size, union smbus_data * data); 
    365379} 
    366380 
    367  
    368 A description of the above struct: 
    369   smbus_access: A function to access the SMBus. If the algorithm describes 
    370       a i2c bus, it will use master_xfer to simulate this operation. In 
    371       case of a PIIX4, master_xfer, slave_send and slave_recv will not be 
    372       implemented. 
     381A description of the above struct: 
     382  smbus_access: A function to access the SMBus. It is only used for non-i2c 
     383      smbus adapters. 
    373384 
    374385 
  • lm-sensors/trunk/i2c/Module.mk

    r6 r8  
     1#  Module.mk - Makefile for a Linux module for reading sensor data. 
     2#  Copyright (c) 1998  Frodo Looijaard <frodol@dds.nl> 
     3# 
     4#  This program is free software; you can redistribute it and/or modify 
     5#  it under the terms of the GNU General Public License as published by 
     6#  the Free Software Foundation; either version 2 of the License, or 
     7#  (at your option) any later version. 
     8# 
     9#  This program is distributed in the hope that it will be useful, 
     10#  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     11#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     12#  GNU General Public License for more details. 
     13# 
     14#  You should have received a copy of the GNU General Public License 
     15#  along with this program; if not, write to the Free Software 
     16#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
     17 
    118# Note that MODULE_DIR (the directory in which this file resides) is a 
    219# 'simply expanded variable'. That means that its value is substituted 
     
    421MODULE_DIR := i2c 
    522 
    6 TARGETS := $(MODULE_DIR)/i2c-core.o  $(MODULE_DIR)/algo-bit.o \ 
    7            $(MODULE_DIR)/i2c-dev.o   $(MODULE_DIR)/bit-lp.o \ 
    8            $(MODULE_DIR)/bit-velle.o $(MODULE_DIR)/bit-mb.o 
     23# Regrettably, even 'simply expanded variables' will not put their currently 
     24# defined value verbatim into the command-list of rules... 
     25I2CTARGETS := $(MODULE_DIR)/i2c-core.o  $(MODULE_DIR)/algo-bit.o \ 
     26              $(MODULE_DIR)/i2c-dev.o   $(MODULE_DIR)/bit-lp.o \ 
     27              $(MODULE_DIR)/bit-velle.o $(MODULE_DIR)/bit-mb.o 
    928 
    1029# Include all dependency files 
    11 include $(TARGETS:.o=.d) 
     30include $(I2CTARGETS:.o=.d) 
    1231 
    13 all :: $(TARGETS) 
     32all :: $(I2CTARGETS) 
    1433 
    15 install :: $(TARGETS) 
     34install ::  
    1635        $(MKDIR) $(MODDIR) 
    17         install -o root -g root -m 644 $(TARGETS) $(MODDIR) 
     36        install -o root -g root -m 644 $(I2CTARGETS) $(MODDIR) 
    1837 
    1938clean :: 
    20         $(RM) $(TARGETS) $(TARGETS:.o=.d) 
     39        $(RM) $(I2CTARGETS) $(I2CTARGETS:.o=.d) 
  • lm-sensors/trunk/i2c/algo-bit.c

    r7 r8  
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    1919/* ------------------------------------------------------------------------- */ 
    20 static char alg_rcsid[] = "$Id: algo-bit.c,v 1.1 1998/11/02 20:29:27 frodo Exp $"; 
     20static char alg_rcsid[] = "$Id: algo-bit.c,v 1.2 1998/11/03 03:48:44 phil Exp $"; 
    2121 
    2222#include <linux/kernel.h> 
     
    639639MODULE_PARM_DESC(i2c_debug,"debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol"); 
    640640 
    641 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)) 
    642 EXPORT_SYMBOL(i2c_bit_add_bus); 
    643 EXPORT_SYMBOL(i2c_bit_del_bus); 
    644 #endif 
    645641 
    646642int init_module(void)  
  • lm-sensors/trunk/i2c/bit-lp.c

    r3 r8  
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    1919/* ------------------------------------------------------------------------- */ 
    20 static char rcsid[] = "$Id: bit-lp.c,v 1.5 1998/09/28 06:45:38 i2c Exp i2c $"; 
     20static char rcsid[] = "$Id: bit-lp.c,v 1.1 1998/11/02 20:29:27 frodo Exp $"; 
    2121/* ------------------------------------------------------------------------- */ 
    2222 
     
    152152MODULE_PARM(base, "i"); 
    153153 
    154 EXPORT_NO_SYMBOLS; 
    155  
    156154int init_module(void)  
    157155{ 
  • lm-sensors/trunk/i2c/i2c-core.c

    r7 r8  
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    1919/* ------------------------------------------------------------------------- */ 
    20 #define RCSID "$Id: i2c-core.c,v 1.1 1998/11/02 20:29:27 frodo Exp $" 
     20#define RCSID "$Id: i2c-core.c,v 1.2 1998/11/03 03:48:44 phil Exp $" 
    2121/* ------------------------------------------------------------------------- */ 
    2222 
     
    442442MODULE_PARM_DESC(i2c_debug,"debug level"); 
    443443 
    444 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)) 
    445 EXPORT_SYMBOL(i2c_add_algorithm); 
    446 EXPORT_SYMBOL(i2c_del_algorithm); 
    447 EXPORT_SYMBOL(i2c_add_adapter); 
    448 EXPORT_SYMBOL(i2c_del_adapter); 
    449 EXPORT_SYMBOL(i2c_add_driver); 
    450 EXPORT_SYMBOL(i2c_del_driver); 
    451 EXPORT_SYMBOL(i2c_attach_client); 
    452 EXPORT_SYMBOL(i2c_detach_client); 
    453  
    454 EXPORT_SYMBOL(i2c_master_send); 
    455 EXPORT_SYMBOL(i2c_master_recv); 
    456 EXPORT_SYMBOL(i2c_control); 
    457 EXPORT_SYMBOL(i2c_transfer); 
     444int init_module(void)  
     445{ 
     446        return i2c_init(); 
     447} 
     448 
     449void cleanup_module(void)  
     450{ 
     451} 
    458452#endif 
    459  
    460 int init_module(void)  
    461 { 
    462         return i2c_init(); 
    463 } 
    464  
    465 void cleanup_module(void)  
    466 { 
    467 } 
    468 #endif 
  • lm-sensors/trunk/i2c/i2c-dev.c

    r3 r8  
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    1919/* ------------------------------------------------------------------------- */ 
    20 #define RCSID "$Id: i2c-dev.c,v 1.6 1998/09/28 06:45:38 i2c Exp i2c $" 
     20#define RCSID "$Id: i2c-dev.c,v 1.1 1998/11/02 20:29:27 frodo Exp $" 
    2121/* ------------------------------------------------------------------------- */ 
    2222 
     
    338338MODULE_DESCRIPTION("I2C-Bus character device interface"); 
    339339 
    340 EXPORT_NO_SYMBOLS; 
    341  
    342340int init_module(void)  
    343341{