Skip to contentSkip to conversation

SMSC LPC47M192 SMBus question

DISCUSSION wore 2 participants 6 messages May 19, 2005

lore
Share & tools
lore

wore

author
#0 lore raw

Hi,

Yesterday, I have bought ASUS P4G800-V board for my home linux server. I installed linux distribution, then I wanted to see and log cpu temp. So, I installed lm_sensors to my box, but part of SMSC LPC47M192 is supported. And I began to read datasheet(http://www.smsc.com/main/datasheets/47m192.pdf ).

It seems that I must access via SMBus to fetch temp and voltage. in datasheet (page 129)

Quoted 2 lines

The Hardware Monitoring Block is a standalone block in the 2. It can be accessed using SMBus interface.

Then, I browsed other chips codes and putted some printk debug and i2c_smbus_read_byte_data function as follows.

The result is failure.

Quoted 7 lines

smsc47m1.o version 2.9.0 (20041228) compiled Apr 11 2005 02:02:47 smsc47m1_find devid:0x60
smsc47m1.o addr: 0x680
i2c_check_functionality 0 i2c_get_functionality(adapter):0x0
i2c-core.o: I2C adapter 50000: I2C level transfers not supported 0x3e rets 0xffffffff

Anyone know how to access this chip via SMBus?

Regards,
wore

--

Here's my loaded modules.

$ /sbin/lsmod|grep i2c
i2c-proc                7748   0 [smsc47m1]
i2c-dev                 4576   0
i2c-i801                5884   0
i2c-isa                 1392   0
i2c-core               19588   0 [smsc47m1 i2c-proc i2c-dev i2c-i801 i2c-isa]
Signature · 63 lines
This is my debug test.

diff -aurN lm_sensors-2.9.0/kernel/chips/smsc47m1.c.orig lm_sensors-2.9.0/kernel/chips/smsc47m1.c
--- lm_sensors-2.9.0/kernel/chips/smsc47m1.c.orig	2005-04-10 15:48:04.000000000 +0900
+++ lm_sensors-2.9.0/kernel/chips/smsc47m1.c	2005-04-11 02:02:39.000000000 +0900
@@ -33,7 +33,7 @@
 MODULE_PARM_DESC(force_addr,
 		 "Initialize the base address of the sensors");
 
-static unsigned short normal_i2c[] = { SENSORS_I2C_END };
+static unsigned short normal_i2c[] = { 0x2c, 0x2d, SENSORS_I2C_END };
 static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };
 static unsigned int normal_isa[] = { 0x0000, SENSORS_ISA_END };
 static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
@@ -214,6 +214,7 @@
 		superio_exit();
 		return -ENODEV;
 	}
+	printk("smsc47m1_find devid:0x%x\n", val);
 
 	superio_select();
 	val = (superio_inb(SMSC_BASE_REG) << 8) |
@@ -245,6 +246,15 @@
 		return 0;
 	}
 
+	if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
+	  printk("i2c_check_functionality 1\n");
+	} else {
+	  printk("i2c_check_functionality 0\n");
+	}
+
+	printk("i2c_get_functionality(adapter):0x%x\n",
+	       i2c_get_functionality(adapter));
+
 	if(force_addr)
 		address = force_addr & ~(SMSC_EXTENT - 1);
 	if (check_region(address, SMSC_EXTENT)) {
@@ -344,6 +354,8 @@
 	/* configure pins for tach function */
 	smsc47m1_write_value(client, SMSC47M1_REG_TPIN1, 0x05);
 	smsc47m1_write_value(client, SMSC47M1_REG_TPIN2, 0x05);
+	printk("0x3e (company id) rets 0x%x\n", 
+	       i2c_smbus_read_byte_data(client, 0x3e));
 }
 
 static void smsc47m1_update_client(struct i2c_client *client)
@@ -488,12 +500,14 @@
 {
 	int addr;
 
-	printk("smsc47m1.o version %s (%s)\n", LM_VERSION, LM_DATE);
+	printk("smsc47m1.o version %s (%s) compiled %s %s\n",
+	       LM_VERSION, LM_DATE, __DATE__, __TIME__);
 
 	if (smsc47m1_find(&addr)) {
 		printk("smsc47m1.o: SMSC 47M1xx not detected, module not inserted.\n");
 		return -ENODEV;
 	}
+	printk("smsc47m1.o addr: 0x%x\n", addr);
 	normal_isa[0] = addr;
 
 	return i2c_add_driver(&smsc47m1_driver);
author
#1 lore raw

Hi,

I'm not member of this list, so would you subscribe me to this list?

After I have wrote previous mail, I got infomation from the archive, then I find my chip via SMBus.
http://archives.andrew.net.au/lm-sensors/msg30861.html

# check i2cdetect

According to PDF page 130,

Quoted 2 lines

The default power on SMBus address is 010110x binary, where x reflects the state defined by the A0 pin.

0x2d is 0101101, so it seems it is the chip.

Quoted 6 lines
$ sudo /usr/sbin/i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
Quoted 8 lines
00:          XX XX XX XX XX 08 XX XX XX 0c XX XX XX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX 2d XX XX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX
40: XX XX XX XX 44 XX XX XX XX XX XX XX XX XX XX XX
50: 50 XX 52 XX XX XX XX XX XX XX XX XX XX XX XX XX
60: XX XX XX XX XX XX XX XX XX 69 XX XX XX XX XX XX
70: XX XX XX XX XX XX XX XX
# check i2cdump

According to PDF page 184,
reg 0x3e is Company ID and default value is 0x55,
reg 0x3f is Stepping and default value is 0x20,

dump seems correct.

Quoted 14 lines
$ sudo /usr/sbin/i2cdump 1 0x2d
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1, address 0x2d, mode byte
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00    XXXXXXXXXXXXXX..
20: bf 7f c4 c5 c4 c4 1f 20 XX XX XX a7 99 72 ef af    ??????? XXX??r??
30: 76 6f 57 57 bf 77 cf f5 a4 bb 7d XX XX XX 55 20    voWW?w????}XXXU
40: 09 7f 0f XX XX XX XX 0d XX 80 00 72 00 00 XX 00    ???XXXX?X?.r..X.
50: ce bd 1f XX 1a ff fe c6 ed 3a XX XX XX XX XX XX    ???X?.???:XXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
Quoted 8 lines
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX

Then, I began to SMBus only driver on 2.4.29 kernel. Currently, no function is implemented.
Just check chip corp and exit.

I will complete it by the weekend.

here's syslog

Quoted 2 lines

smsc47m192.o version 2.9.0 (20041228) Apr 12 2005 10:27:13 0x3e rets 0x55

Regards,
wore

Signature · 201 lines
/*
 * smsc47m192.c test by wore <[email protected]>
 * based on asb100.c
 */

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-proc.h>
#include <linux/init.h>
#include "version.h"
#include "sensors_vid.h"

#ifndef I2C_DRIVERID_SMSC47M192
#define I2C_DRIVERID_SMSC47M192 1092
#endif

/* I2C addresses to scan */
static unsigned short normal_i2c[] = { 0x2d, SENSORS_I2C_END };
static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };

/* ISA addresses to scan (none) */
static unsigned int normal_isa[] = { SENSORS_ISA_END };
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };

/* Insmod parameters */
SENSORS_INSMOD_1(smsc47m192);
SENSORS_MODULE_PARM(force_subclients, "List of subclient addresses: " \
	"{bus, clientaddr, subclientaddr1, subclientaddr2}");


/* For each registered client, we need to keep some data in memory. That
   data is pointed to by client->data. The structure itself is
   dynamically allocated, at the same time the client itself is allocated. */
struct smsc47m192_data {
	struct i2c_client client;
	struct semaphore lock;
	int sysctl_id;
	enum chips type;

	struct semaphore update_lock;
	unsigned long last_updated;	/* In jiffies */

	char valid;		/* !=0 if following fields are valid */
};

static int smsc47m192_attach_adapter(struct i2c_adapter *adapter);
static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
		unsigned short flags, int kind);
static int smsc47m192_detach_client(struct i2c_client *client);

static struct i2c_driver smsc47m192_driver = {
	.name		= "smsc47m192",
	.id		= I2C_DRIVERID_SMSC47M192,
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= smsc47m192_attach_adapter,
	.detach_client	= smsc47m192_detach_client,
};

/* -- SENSORS SYSCTL END -- */

static int smsc47m192_attach_adapter(struct i2c_adapter *adapter)
{
	return i2c_detect(adapter, &addr_data, smsc47m192_detect);
}

static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
		unsigned short flags, int kind)
{
	int err;
	struct i2c_client *new_client;
	struct smsc47m192_data *data;

	/* asb100 is SMBus only */
	if (i2c_is_isa_adapter(adapter)) {
		pr_debug("smsc47m192.o: detect failed, "
				"cannot attach to legacy adapter!\n");
		err = -ENODEV;
		goto ERROR0;
	}

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
		pr_debug("smsc47m192.o: detect failed, "
				"smbus byte data not supported!\n");
		err = -ENODEV;
		goto ERROR0;
	}

	/* OK. For now, we presume we have a valid client. We now create the
	   client structure, even though we cannot fill it completely yet.
	   But it allows us to access asb100_{read,write}_value. */

	if (!(data = kmalloc(sizeof(struct smsc47m192_data), GFP_KERNEL))) {
		pr_debug("asb100.o: detect failed, kmalloc failed!\n");
		err = -ENOMEM;
		goto ERROR0;
	}

	new_client = &data->client;
	new_client->addr = address;
	init_MUTEX(&data->lock);
	new_client->data = data;
	new_client->adapter = adapter;
	new_client->driver = &smsc47m192_driver;
	new_client->flags = 0;

	/* Now, we do the remaining detection. */



        printk("0x3e rets 0x%x\n",
               i2c_smbus_read_byte_data(new_client, 0x3e));

	strcpy(new_client->name, "smsc47m192 chip");
	data->type = kind;

	data->valid = 0;
	init_MUTEX(&data->update_lock);

	/* Tell the I2C layer a new client has arrived */
	if ((err = i2c_attach_client(new_client)))
		goto ERROR1;

	/* Initialize the chip */
	/*
	asb100_init_client(new_client);
	*/

	return 0;

ERROR3:

ERROR2:
	i2c_detach_client(new_client);
ERROR1:
	kfree(data);
ERROR0:
	return err;
}

static int smsc47m192_detach_client(struct i2c_client *client)
{
	int err;
	struct smsc47m192_data *data = client->data;

	/* remove sysctl table (primary client only) */
	if ((data))
		i2c_deregister_entry(data->sysctl_id);

	if ((err = i2c_detach_client(client))) {
		printk (KERN_ERR "smsc47m192.o: Client deregistration failed; "
			"client not detached.\n");
		return err;
	}

	if (data) {
		/* primary client */
		kfree(data);
	} else {
		/* subclients */
		kfree(client);
	}

	return 0;
}

static void smsc47m192_init_client(struct i2c_client *client)
{
	struct smsc47m192_data *data = client->data;
	int vid = 0;
}

static void smsc47m192_update_client(struct i2c_client *client)
{
	struct smsc47m192_data *data = client->data;
	int i;

	down(&data->update_lock);

	up(&data->update_lock);
}


static int __init smsc47m192_init(void)
{
	printk(KERN_INFO "smsc47m192.o version %s (%s) %s %s\n",
	       LM_VERSION, LM_DATE, __DATE__, __TIME__);
	return i2c_add_driver(&smsc47m192_driver);
}

static void __exit smsc47m192_exit(void)
{
	i2c_del_driver(&smsc47m192_driver);
}

MODULE_AUTHOR("wore <[email protected]>");
MODULE_DESCRIPTION("smsc47m192 driver");
MODULE_LICENSE("GPL");

module_init(smsc47m192_init);
module_exit(smsc47m192_exit);
#2 lore raw
In reply to wore

Hi,

Quoted 12 lines
# check i2cdetect

According to PDF page 130,

Quoted 2 lines

The default power on SMBus address is 010110x binary, where x reflects the state defined by the A0 pin.

0x2d is 0101101, so it seems it is the chip.
(...)
According to PDF page 184,
reg 0x3e is Company ID and default value is 0x55,
reg 0x3f is Stepping and default value is 0x20,

Quoted 7 lines

dump seems correct.
(...)
Then, I began to SMBus only driver on 2.4.29 kernel. Currently, no function is implemented.
Just check chip corp and exit.

I will complete it by the weekend.

You might want to get in touch with Tomas Holmqvist, who contacted us some times ago for a similar problem:

http://archives.andrew.net.au/lm-sensors/msg29831.html

I think I remember that the LPC47M15x and LPC47M192 are mostly compatible (would need to verify with the datasheets whether this applied to the HWM block as well). If this is the case, it would probably make sense to join your forces and write a single driver for both chips.

Thanks,
--
Jean Delvare

#3 lore raw
In reply to wore

Hi,

Quoted 1 line

Oh, really? LPC47M15x and LPC47M192 are compatible?

I just checked the datasheet and they definitely are. They better be anyway, because they have the same identification registers.

I just added detection of these chips to our sensors-detect script.

Signature · 1 line
Jean Delvare
author
#4 lore raw
In reply to wore

Hi,

Quoted 3 lines

You might want to get in touch with Tomas Holmqvist, who contacted us some times ago for a similar problem:
http://archives.andrew.net.au/lm-sensors/msg29831.html

Thanks.

Quoted 4 lines

I think I remember that the LPC47M15x and LPC47M192 are mostly compatible (would need to verify with the datasheets whether this applied to the HWM block as well). If this is the case, it would probably make sense to join your forces and write a single driver for both chips.

Oh, really? LPC47M15x and LPC47M192 are compatible?
But, I cannot help writing code, because I do want to check my CPU temp. Then, I've wrote little code for just check up current temp and putted it into my local HotSaNIC graph.

My code is really stupid, but it can get temperature so I'm satisfied with it. Anyway, I will finish by this weekend.

Thanks,
wore

Signature · 314 lines
/*
    smsc47m192.c test by wore <[email protected]>
    smsc47m192.c - Part of lm_sensors, Linux kernel modules
                   for hardware monitoring

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-proc.h>
#include <linux/init.h>
#include "version.h"
#include "sensors_vid.h"

#ifndef I2C_DRIVERID_SMSC47M192
#define I2C_DRIVERID_SMSC47M192 1092
#endif

/* I2C addresses to scan */
/* 010110x */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, SENSORS_I2C_END };
static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };

/* ISA addresses to scan (none) */
static unsigned int normal_isa[] = { SENSORS_ISA_END };
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };

/* Insmod parameters */
SENSORS_INSMOD_1(smsc47m192);

/* Many SMSC47M192 constants specified below */

/* The SMSC47M192 registers */
/* r */
#define SMSC47M192_HMB_CORPID   0x3e
#define SMSC47M192_HMB_SETPPING 0x3f
#define SMSC47M192_HMB_TEMP1    0x26
#define SMSC47M192_HMB_TEMP1_H  0x37
#define SMSC47M192_HMB_TEMP1_L  0x38
#define SMSC47M192_HMB_TEMP2    0x27
#define SMSC47M192_HMB_TEMP2_H  0x39
#define SMSC47M192_HMB_TEMP2_L  0x3a

/* from lm78.c */
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)

struct smsc47m192_data {
	struct i2c_client client;
	struct semaphore lock;
	int sysctl_id;
	enum chips type;

	struct semaphore update_lock;
	unsigned long last_updated;	/* In jiffies */

	char valid;		/* !=0 if following fields are valid */

	u8 temp[2];
	u8 temp_high[2];
	u8 temp_low[2];
};

static int smsc47m192_attach_adapter(struct i2c_adapter *adapter);
static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
		unsigned short flags, int kind);
static int smsc47m192_detach_client(struct i2c_client *client);

static int smsc47m192_read_value(struct i2c_client *client, u8 reg);
/*
static int smsc47m192_write_value(struct i2c_client *client, u8 reg, u8 value);
*/
static void smsc47m192_update_client(struct i2c_client *client);
static void smsc47m192_init_client(struct i2c_client *client);

static void smsc47m192_temp(struct i2c_client *client, int operation,
			    int ctl_name, int *nrels_mag, long *results);

static int smsc47m192_id = 0;

static struct i2c_driver smsc47m192_driver = {
	.name		= "smsc47m192",
	.id		= I2C_DRIVERID_SMSC47M192,
	.flags		= I2C_DF_NOTIFY,
	.attach_adapter	= smsc47m192_attach_adapter,
	.detach_client	= smsc47m192_detach_client,
};

/* The /proc/sys entries */

/* -- SENSORS SYSCTL START -- */

#define SMSC47M192_SYSCTL_TEMP1 1200
#define SMSC47M192_SYSCTL_TEMP2 1201

/* -- SENSORS SYSCTL END -- */

#define SMSC47M192_SYSCTL_TEMP(nr) {SMSC47M192_SYSCTL_TEMP##nr, \
        "temp" #nr, NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, \
        NULL, &smsc47m192_temp}

static ctl_table smsc47m192_dir_table_template[] = {
  SMSC47M192_SYSCTL_TEMP(1),
  SMSC47M192_SYSCTL_TEMP(2),
  {0}
};

static int smsc47m192_attach_adapter(struct i2c_adapter *adapter)
{
	return i2c_detect(adapter, &addr_data, smsc47m192_detect);
}

static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
		unsigned short flags, int kind)
{
	int err;
	struct i2c_client *new_client;
	struct smsc47m192_data *data;

	pr_debug("smsc47m192.o: smsc47m192_detect\n");
	/* asb100 is SMBus only */
	if (i2c_is_isa_adapter(adapter)) {
		pr_debug("smsc47m192.o: detect failed, "
				"cannot attach to legacy adapter!\n");
		err = -ENODEV;
		goto ERROR0;
	}
	printk(KERN_INFO "smsc47m192.o: pass SMBus only\n");

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
		pr_debug("smsc47m192.o: detect failed, "
				"smbus byte data not supported!\n");
		err = -ENODEV;
		goto ERROR0;
	}
	printk(KERN_INFO "smsc47m192.o: pass SMBus func check\n");

	/* OK. For now, we presume we have a valid client. We now create the
	   client structure, even though we cannot fill it completely yet.
	   But it allows us to access smsc47m192_{read,write}_value. */

	if (!(data = kmalloc(sizeof(struct smsc47m192_data), GFP_KERNEL))) {
		pr_debug("smsc47m192.o: detect failed, kmalloc failed!\n");
		err = -ENOMEM;
		goto ERROR0;
	}
	printk(KERN_INFO "smsc47m192.o: pass kmalloc\n");

	new_client = &data->client;
	new_client->addr = address;
	init_MUTEX(&data->lock);
	new_client->data = data;
	new_client->adapter = adapter;
	new_client->driver = &smsc47m192_driver;
	new_client->flags = 0;

        printk(KERN_INFO "0x3e rets 0x%x\n",
               i2c_smbus_read_byte_data(new_client, 0x3e));

	strcpy(new_client->name, "smsc47m192 chip");
	data->type = kind;

	new_client->id = smsc47m192_id++;
	data->valid = 0;
	init_MUTEX(&data->update_lock);

	/* Tell the I2C layer a new client has arrived */
	if ((err = i2c_attach_client(new_client)))
		goto ERROR1;

	/* Initialize the chip */
	smsc47m192_init_client(new_client);

	if ((data->sysctl_id = i2c_register_entry(new_client, "smsc47m192",
		smsc47m192_dir_table_template, THIS_MODULE)) < 0) {
	  err = data->sysctl_id;
	  goto ERROR3;
	}
	return 0;

ERROR3:

ERROR2:
	i2c_detach_client(new_client);
ERROR1:
	kfree(data);
ERROR0:
	return err;
}

static int smsc47m192_detach_client(struct i2c_client *client)
{
	int err;
	struct smsc47m192_data *data = client->data;

	/* remove sysctl table (primary client only) */
	if ((data))
		i2c_deregister_entry(data->sysctl_id);

	if ((err = i2c_detach_client(client))) {
		printk (KERN_ERR "smsc47m192.o: Client deregistration failed; "
			"client not detached.\n");
		return err;
	}

	if (data) {
		/* primary client */
		kfree(data);
	} else {
		/* subclients */
		kfree(client);
	}

	return 0;
}


static int smsc47m192_read_value(struct i2c_client *client, u8 reg)
{
	struct smsc47m192_data *data = client->data;
	struct i2c_client *cl;
	int res;

	down(&data->lock);

	res = i2c_smbus_read_byte_data(client, reg & 0xff);

	up(&data->lock);

	return res;
}

static void smsc47m192_init_client(struct i2c_client *client)
{
	struct smsc47m192_data *data = client->data;
	int vid = 0;
}

static void smsc47m192_update_client(struct i2c_client *client)
{
	struct smsc47m192_data *data = client->data;
	int i;

	down(&data->update_lock);

        if (time_after(jiffies - data->last_updated, HZ + HZ / 2) ||
	    time_before(jiffies, data->last_updated) || !data->valid) {

	  /* 2 temperature inputs */
	  data->temp[0] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP1);
	  data->temp[1] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP2);

	  data->temp_high[0] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP1_H);
	  data->temp_high[1] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP2_H);

	  data->temp_low[0] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP1_L);
	  data->temp_low[1] = smsc47m192_read_value(client, SMSC47M192_HMB_TEMP2_L);
						     
	  data->last_updated = jiffies;
	  data->valid = 1;
	}
	up(&data->update_lock);
}

static void smsc47m192_temp(struct i2c_client *client, int operation,
			    int ctl_name, int *nrels_mag, long *results)
{
	struct smsc47m192_data *data = client->data;
	int nr = ctl_name - SMSC47M192_SYSCTL_TEMP1;

        if (operation = SENSORS_PROC_REAL_INFO) {
	  *nrels_mag = 1;
	} else if (operation = SENSORS_PROC_REAL_READ) {
	  smsc47m192_update_client(client);
	  results[0] = TEMP_FROM_REG(data->temp_high[nr]);
	  results[1] = TEMP_FROM_REG(data->temp_low[nr]);
	  results[2] = TEMP_FROM_REG(data->temp[nr]);
	  *nrels_mag = 3;
	}
}
static int __init sm_smsc47m192_init(void)
{
  int r;
	printk(KERN_INFO "smsc47m192.o version %s (%s) %s %s\n",
	       LM_VERSION, LM_DATE, __DATE__, __TIME__);
	r = i2c_add_driver(&smsc47m192_driver);
	printk(KERN_INFO "i2c_add_driver returns %d\n", r);
	return r;
}

static void __exit sm_smsc47m192_exit(void)
{
	i2c_del_driver(&smsc47m192_driver);
}

MODULE_AUTHOR("wore <[email protected]>");
MODULE_DESCRIPTION("smsc47m192 driver");
MODULE_LICENSE("GPL");

module_init(sm_smsc47m192_init);
module_exit(sm_smsc47m192_exit);
author
#5 lore raw
In reply to wore

Hi,

Quoted 2 lines

I just checked the datasheet and they definitely are. They better be anyway, because they have the same identification registers.

You are right. I saw the description in the smsc47m15x's datasheet. 47m15x: http://www.smsc.com/main/tools/discontinued/47m15x.pdf
47m192: http://www.smsc.com/main/datasheets/47m192.pdf

Quoted 1 line

I just added detection of these chips to our sensors-detect script.

Thanks.
Then, I got detect routine from prog/detect/sensors-detect.

Finally, I think I have finished writing.
I need testers on 2.4 kernel and porters for 2.6 kernel.

here's some results (some values are strange)

$ cat /proc/sys/dev/sensors/smsc47m192-i2c-0-2d/temp*
-11.0 -92.0 34.0
-69.0 125.0 31.0
-19.0 58.0 30.0
$ cat /proc/sys/dev/sensors/smsc47m192-i2c-0-2d/in*
1.99 2.17 2.48
2.80 1.33 1.48
2.02 3.00 3.36
2.26 2.89 5.13
11.93 5.43 12.18
2.91 1.67 2.75
Signature · 8 lines
wore
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smsc47m192.c
Type: application/octet-stream
Size: 11702 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050416/06a8c6f9/smsc47m192.obj