Changeset 9

Show
Ignore:
Timestamp:
11/19/98 16:14:01 (15 years ago)
Author:
frodo
Message:

piix4.c basic skeleton

The real PIIX4 access code must still be written; perhaps somebody else could
do this? Most of it could be copied from the old piix4.c. But check carefully
what you are doing, as some things *have* changed (like the SMBUS_{BYTE,...}
variables!).

Location:
lm-sensors/trunk
Files:
3 added
6 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/Module.mk

    r8 r9  
    2323# Regrettably, even 'simply expanded variables' will not put their currently 
    2424# defined value verbatim into the command-list of rules... 
    25 SRCTARGETS := $(MODULE_DIR)/smbus.o  
     25SRCTARGETS := $(MODULE_DIR)/smbus.o $(MODULE_DIR)/piix4.o 
    2626 
    2727# Include all dependency files 
  • lm-sensors/trunk/kernel/include/smbus.h

    r8 r9  
    110110  int retries; 
    111111 
    112   /* Here ended i2c_algorithm */ 
    113   s32 (* smbus_access) (__u8 addr, char read_write, 
    114                         __u8 command, int size, union smbus_data * data); 
     112  /* Here ended i2c_adapter */ 
     113  s32 (* smbus_access) (u8 addr, char read_write, 
     114                        u8 command, int size, union smbus_data * data); 
    115115}; 
    116116 
     
    122122#define ALGO_SMBUS 0x40000 
    123123 
     124/* SMBus Adapter ids */ 
     125#define SMBUS_PIIX4 1 
     126 
    124127/* This union is used within smbus_access routines */ 
    125128union smbus_data {  
    126         __u8 byte; 
    127         __u16 word; 
    128         __u8 block[32]; 
     129        u8 byte; 
     130        u16 word; 
     131        u8 block[32]; 
    129132}; 
    130133 
  • lm-sensors/trunk/kernel/smbus.c

    r8 r9  
    2020#include <linux/module.h> 
    2121#include <linux/kernel.h> 
     22 
     23#ifdef SPINLOCK 
     24#include <asm/spinlock.h> 
     25#else 
     26#include <asm/semaphore.h> 
     27#endif 
     28 
    2229#include "smbus.h" 
    2330 
     
    5865/* OK, so you want to access a bus using the SMBus protocols. Well, it either 
    5966   is registered as a SMBus-only adapter (like the PIIX4), or we need to 
    60    simulate the SMBus commands using the i2c access routines. */ 
     67   simulate the SMBus commands using the i2c access routines.  
     68   We do all locking here, so you can ignore that in the adapter-specific 
     69   smbus_accesss routine. */ 
    6170s32 smbus_access (struct smbus_adapter * adapter, u8 addr, char read_write, 
    6271                  u8 command, int size, union smbus_data * data) 
    6372{ 
     73  int res; 
     74#ifdef SPINLOCK 
     75  spin_lock_irqsave(&adapter->lock,adapter->lockflags); 
     76#else 
     77  down(&adapter->lock); 
     78#endif 
    6479  if (adapter->id & ALGO_SMBUS)  
    65     return adapter->smbus_access(addr,read_write,command,size,data); 
     80    res = adapter->smbus_access(addr,read_write,command,size,data); 
    6681  else 
    67     return smbus_access_i2c(adapter,addr,read_write,command,size,data); 
     82    res = smbus_access_i2c(adapter,addr,read_write,command,size,data); 
     83#ifdef SPINLOCK 
     84  spin_unlock_irqrestore(&adapter->lock,adapter->lockflags); 
     85#else 
     86  up(&adapter->lock); 
     87#endif 
     88  return res; 
    6889} 
    6990   
  • lm-sensors/trunk/src/Module.mk

    r8 r9  
    2323# Regrettably, even 'simply expanded variables' will not put their currently 
    2424# defined value verbatim into the command-list of rules... 
    25 SRCTARGETS := $(MODULE_DIR)/smbus.o  
     25SRCTARGETS := $(MODULE_DIR)/smbus.o $(MODULE_DIR)/piix4.o 
    2626 
    2727# Include all dependency files 
  • lm-sensors/trunk/src/smbus.c

    r8 r9  
    2020#include <linux/module.h> 
    2121#include <linux/kernel.h> 
     22 
     23#ifdef SPINLOCK 
     24#include <asm/spinlock.h> 
     25#else 
     26#include <asm/semaphore.h> 
     27#endif 
     28 
    2229#include "smbus.h" 
    2330 
     
    5865/* OK, so you want to access a bus using the SMBus protocols. Well, it either 
    5966   is registered as a SMBus-only adapter (like the PIIX4), or we need to 
    60    simulate the SMBus commands using the i2c access routines. */ 
     67   simulate the SMBus commands using the i2c access routines.  
     68   We do all locking here, so you can ignore that in the adapter-specific 
     69   smbus_accesss routine. */ 
    6170s32 smbus_access (struct smbus_adapter * adapter, u8 addr, char read_write, 
    6271                  u8 command, int size, union smbus_data * data) 
    6372{ 
     73  int res; 
     74#ifdef SPINLOCK 
     75  spin_lock_irqsave(&adapter->lock,adapter->lockflags); 
     76#else 
     77  down(&adapter->lock); 
     78#endif 
    6479  if (adapter->id & ALGO_SMBUS)  
    65     return adapter->smbus_access(addr,read_write,command,size,data); 
     80    res = adapter->smbus_access(addr,read_write,command,size,data); 
    6681  else 
    67     return smbus_access_i2c(adapter,addr,read_write,command,size,data); 
     82    res = smbus_access_i2c(adapter,addr,read_write,command,size,data); 
     83#ifdef SPINLOCK 
     84  spin_unlock_irqrestore(&adapter->lock,adapter->lockflags); 
     85#else 
     86  up(&adapter->lock); 
     87#endif 
     88  return res; 
    6889} 
    6990   
  • lm-sensors/trunk/src/smbus.h

    r8 r9  
    110110  int retries; 
    111111 
    112   /* Here ended i2c_algorithm */ 
    113   s32 (* smbus_access) (__u8 addr, char read_write, 
    114                         __u8 command, int size, union smbus_data * data); 
     112  /* Here ended i2c_adapter */ 
     113  s32 (* smbus_access) (u8 addr, char read_write, 
     114                        u8 command, int size, union smbus_data * data); 
    115115}; 
    116116 
     
    122122#define ALGO_SMBUS 0x40000 
    123123 
     124/* SMBus Adapter ids */ 
     125#define SMBUS_PIIX4 1 
     126 
    124127/* This union is used within smbus_access routines */ 
    125128union smbus_data {  
    126         __u8 byte; 
    127         __u16 word; 
    128         __u8 block[32]; 
     129        u8 byte; 
     130        u16 word; 
     131        u8 block[32]; 
    129132}; 
    130133