hwmon/sis5595: Convert to a platform driver
PATCH 1/2 hwmon/sis5595: Convert to a platform driver
Convert the sis5595 driver from the nonsensical i2c-isa hack to a regular platform driver.
---
Anyone with a SiS5595 chip could please test this patch and the following one? Thanks.
drivers/hwmon/Kconfig | 3 drivers/hwmon/sis5595.c | 317 +++++++++++++++++++++++++---------------------- 2 files changed, 171 insertions(+), 149 deletions(-)
drivers/hwmon/Kconfig +1 -2
@@ -431,8 +431,7 @@ config SENSORS_PC87427 config SENSORS_SIS5595 tristate "Silicon Integrated Systems Corp. SiS5595" - depends on I2C && PCI && EXPERIMENTAL - select I2C_ISA + depends on PCI help If you say yes here you get support for the integrated sensors in SiS5595 South Bridges.
drivers/hwmon/sis5595.c +166 -132
568 lines not on this page · raw message
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
Hey Jean,
I just noticed this post, and since I've got a crappy motherboard (PCCHIPS) with a sis5595 chipset, which outputs almost only bogus information (wrong voltages, no temprature), I am wondering if this patch could fix that,?
I didn't have the time to look deeply into it, but I will within a week or so. I will report back with more information as soon as I get the system up and (completely) running.
So I'll also test this patch for you, as good as I can get it to work:
=
Problems with readings:
VCC 2.5V and VCC 3.3V seems to be readed rightly.
The other voltages just don't make sense; i still need to figure them out. I also get a in4 instead a temp; the docs say this seems to be a BIOS "feature". Any way to bypass this?
Fan reading is not working, but neither is it in the bios.
DMI Info
Sys: PCCHIPS-M748LMRT-0000000
Baseboard: PCCHIPS-M748LMRT-1.0
Ivo
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "LM Sensors" <[email protected]>
Sent: Sunday 3 June 2007 17:42
Subject: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 641 lines
Convert the sis5595 driver from the nonsensical i2c-isa hack to a regular platform driver.
Signed-off-by Jean Delvare <[email protected]>---
Anyone with a SiS5595 chip could please test this patch and the following one? Thanks.
drivers/hwmon/Kconfig| 3drivers/hwmon/sis5595.c| 317
+++++++++++++++++++++++++----------------------2 files changed, 171 insertions(+), 149 deletions(-)--- linux-2.6.22-rc3.orig/drivers/hwmon/Kconfig 2007-06-03 17:16:09.000000000 +0200
+++ linux-2.6.22-rc3/drivers/hwmon/Kconfig 2007-06-03 17:27:34.000000000 +0200(quoted diff) +0
-0@@ -431,8 +431,7 @@ config SENSORS_PC87427config
SENSORS_SIS5595
tristate "Silicon Integrated Systems Corp. SiS5595"
- depends on I2C && PCI && EXPERIMENTAL
- selectI2C_ISA
+ depends on PCI
help
If you say yes here you get support for the integrated sensors in SiS5595 South Bridges.
---linux-2.6.22-rc3.orig/drivers/hwmon/sis5595.c2007-06-03 17:16:09.000000000 +0200
+++linux-2.6.22-rc3/drivers/hwmon/sis5595.c2007-06-03 17:33:48.000000000 +0200drivers/hwmon/sis5595.c +4
-7@@ -54,8 +54,7 @@#include <linux/slab.h> #include <linux/ioport.h> #include <linux/pci.h> -#include <linux/i2c.h> -#include <linux/i2c-isa.h> +#include <linux/platform_device.h> #include <linux/hwmon.h> #include <linux/err.h> #include <linux/init.h> @@ -72,10 +71,7 @@ module_param(force_addr, ushort, 0);MODULE_PARM_DESC (force_addr,"Initialize the base address of the sensors" ); -/* Device address -Note that we can't determine the ISA address until we have initialized -our module */ -static unsigned short address; +static struct platform_device *pdev;/* Many SIS5595 constants specified below */ @@ -165,7 +161,8 @@ static inline u8 DIV_TO_REG(int val)/* For each registered chip, we need to keep some data in memory. The structure is dynamically allocated. */ struct sis5595_data { -struct i2c_client client; +unsigned short addr; +const char *name;struct class_device *class_dev;struct mutex lock;@@ -189,21 +186,21 @@ struct sis5595_data {static struct
pci_dev*s_bridge; /* pointer to the (only) sis5595 */drivers/hwmon/sis5595.c +2
-4-static int sis5595_detect (struct i2c_adapter *adapter); -static int sis5595_detach_client (struct i2c_client *client); +static int sis5595_probe (struct platform_device *pdev); +static int sis5595_remove (struct platform_device *pdev); -static int sis5595_read_value (struct i2c_client *client,u8 reg); -static int sis5595_write_value(struct i2c_client *client, u8 reg, u8value);
(quoted diff) +2
-0+static int sis5595_read_value(struct sis5595_data *data, u8 reg); +static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8value);
static structsis5595_data*sis5595_update_device(struct device *dev);drivers/hwmon/sis5595.c +4
-4-static void sis5595_init_client (struct i2c_client *client); +static void sis5595_init_device (struct sis5595_data *data); -static struct i2c_driver sis5595_driver = { +static struct platform_driver sis5595_driver = { .driver = { .owner =THIS_MODULE , .name ="sis5595" , }, - .attach_adapter = sis5595_detect, - .detach_client = sis5595_detach_client, + .probe = sis5595_probe, + .remove =__devexit_p (sis5595_remove),};
/* 4 Voltages */
drivers/hwmon/sis5595.c +4
-6@@ -228,13 +225,12 @@ static ssize_t show_in_max(struct devicestatic ssize_t set_in_min (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->in_min[nr] =IN_TO_REG (val); -sis5595_write_value (client,SIS5595_REG_IN_MIN (nr), data->in_min[nr]); +sis5595_write_value (data,SIS5595_REG_IN_MIN (nr), data->in_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -242,13 +238,12 @@ static ssize_t set_in_min(struct devicestatic ssize_t set_in_max (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->in_max[nr] =IN_TO_REG (val); -sis5595_write_value (client,SIS5595_REG_IN_MAX (nr), data->in_max[nr]); +sis5595_write_value (data,SIS5595_REG_IN_MAX (nr), data->in_max[nr]);mutex_unlock (&data->update_lock);return count; }@@ -307,13 +302,12 @@ static ssize_t show_temp_over(struct devstatic
ssize_tset_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
- structi2c_client*client =to_i2c_client(dev);
- structsis5595_data*data =i2c_get_clientdata(client);
+ structsis5595_data*data =dev_get_drvdata(dev);
long val =simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock);
data->temp_over=TEMP_TO_REG(val);
-sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
+sis5595_write_value(data, SIS5595_REG_TEMP_OVER, data->temp_over);mutex_unlock(&data->update_lock);
return count;
}(quoted diff) +0
-0@@ -326,13 +320,12 @@ static ssize_t show_temp_hyst(struct devstatic
ssize_tset_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
- structi2c_client*client =to_i2c_client(dev);
- structsis5595_data*data =i2c_get_clientdata(client);
+ structsis5595_data*data =dev_get_drvdata(dev);
long val =simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock);
data->temp_hyst=TEMP_TO_REG(val);
-sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
+sis5595_write_value(data, SIS5595_REG_TEMP_HYST, data->temp_hyst);mutex_unlock(&data->update_lock);
return count;
}drivers/hwmon/sis5595.c +15
-9@@ -361,13 +354,12 @@ static ssize_t show_fan_min(struct devicstatic ssize_t set_fan_min (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->fan_min[nr] =FAN_TO_REG (val,DIV_FROM_REG (data->fan_div[nr])); -sis5595_write_value (client,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]); +sis5595_write_value (data,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -385,8 +377,7 @@ static ssize_t show_fan_div(struct devicstatic ssize_t set_fan_div (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long min;unsigned long val =simple_strtoul (buf,NULL ,10 );int reg;@@ -394,7 +385,7 @@ static ssize_t set_fan_div(struct devicemutex_lock (&data->update_lock); min =FAN_FROM_REG (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); - reg =sis5595_read_value (client,SIS5595_REG_FANDIV ); + reg =sis5595_read_value (data,SIS5595_REG_FANDIV );switch (val) {case 1 : data->fan_div[nr] =0 ;break ;@@ -402,7 +393,7 @@ static ssize_t set_fan_div(struct devicecase 4 : data->fan_div[nr] =2 ;break ;case 8 : data->fan_div[nr] =3 ;break ;default : -dev_err (&client->dev,"fan_div value %ld not " +dev_err (dev,"fan_div value %ld not " "supported. Choose one of 1, 2, 4 or 8!\n" , val);mutex_unlock (&data->update_lock);return -EINVAL ;@@ -416,10 +407,10 @@ static ssize_t set_fan_div(struct device reg = (reg &0x3f ) | (data->fan_div[nr] <<6 );break ; } -sis5595_write_value (client,SIS5595_REG_FANDIV , reg); +sis5595_write_value (data,SIS5595_REG_FANDIV , reg); data->fan_min[nr] >FAN_TO_REG (min,DIV_FROM_REG (data->fan_div[nr])); -sis5595_write_value (client,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]); +sis5595_write_value (data,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -473,6 +464,14 @@ static ssize_t show_alarms(struct device } static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); +static ssize_t show_name (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct sis5595_data *data =dev_get_drvdata (dev); +return sprintf (buf,"%s\n" , data->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); +static struct attribute *sis5595_attributes[] = { &dev_attr_in0_input.attr,&dev_attr_in0_min.attr,
drivers/hwmon/sis5595.c +20
-57@@ -495,6 +494,7 @@ static struct attribute *sis5595_attribu &dev_attr_fan2_div.attr, &dev_attr_alarms.attr, + &dev_attr_name.attr, NULL };@@ -518,65 +518,32 @@ static const struct attribute_group sis5 };/* This is called when the module is loaded */ -static int sis5595_detect (struct i2c_adapter *adapter) +static int __devinit sis5595_probe (struct platform_device *pdev) {int err =0 ;int i; -struct i2c_client *new_client;struct sis5595_data *data; +struct resource *res;char val; -u16 a; -if (force_addr) - address = force_addr & ~(SIS5595_EXTENT -1 );/* Reserve the ISA region */ -if (!request_region (address,SIS5595_EXTENT , + res =platform_get_resource (pdev,IORESOURCE_IO ,0 ); +if (!request_region (res->start,SIS5595_EXTENT , sis5595_driver.driver.name)) { err = -EBUSY ; goto exit; } -if (force_addr) { -dev_warn (&adapter->dev,"forcing ISA address 0x%04X\n" , address); - if (PCIBIOS_SUCCESSFUL !> - pci_write_config_word(s_bridge, SIS5595_BASE_REG, address)) - goto exit_release; - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_word(s_bridge, SIS5595_BASE_REG, &a)) - goto exit_release; -if ((a & ~(SIS5595_EXTENT -1 )) != address) -/* doesn't work for some chips? */ - goto exit_release; - } - - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) { - goto exit_release; - } -if ((val &0x80 ) =0 ) { - if (PCIBIOS_SUCCESSFUL !> - pci_write_config_byte(s_bridge, SIS5595_ENABLE_REG, - val |0x80 )) - goto exit_release; - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) - goto exit_release; -if ((val &0x80 ) =0 ) -/* doesn't work for some chips! */ - goto exit_release; - }if (!(data =kzalloc (sizeof (struct sis5595_data ),GFP_KERNEL ))) { err = -ENOMEM ; goto exit_release; } - new_client = &data->client; - new_client->addr = address;mutex_init (&data->lock); -i2c_set_clientdata (new_client, data); - new_client->adapter = adapter; - new_client->driver = &sis5595_driver; - new_client->flags =0 ; +mutex_init (&data->update_lock); + data->addr = res->start; + data->name ="sis5595" ; +platform_set_drvdata (pdev, data);/* Check revision and pin registers to determine whether 4 or 5 voltages */ pci_read_config_byte (s_bridge,SIS5595_REVISION_REG , &(data->revision));@@ -589,47 +556,37 @@ static int sis5595_detect(struct i2c_adadata->maxins = 4; } -/* Fill in the remaining client fields and put it into the global list */ -strlcpy (new_client->name,"sis5595" ,I2C_NAME_SIZE ); - - data->valid =0 ; -mutex_init (&data->update_lock); - -/* Tell the I2C layer a new client has arrived */ -if ((err =i2c_attach_client (new_client))) - goto exit_free; -/* Initialize the SIS5595 chip */ -sis5595_init_client (new_client); +sis5595_init_device (data);/* A few vars need to be filled upon startup */ for (i =0 ; i <2 ; i++) { - data->fan_min[i] =sis5595_read_value (new_client, + data->fan_min[i] =sis5595_read_value (data,SIS5595_REG_FAN_MIN (i)); }/* Register sysfs hooks */ -if ((err =sysfs_create_group (&new_client->dev.kobj, &sis5595_group))) - goto exit_detach; +if ((err =sysfs_create_group (&pdev->dev.kobj, &sis5595_group))) + goto exit_free;if (data->maxins =4 ) { -if ((err =device_create_file (&new_client->dev, +if ((err =device_create_file (&pdev->dev, &dev_attr_in4_input)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_in4_min)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_in4_max))) goto exit_remove_files; }else { -if ((err =device_create_file (&new_client->dev, +if ((err =device_create_file (&pdev->dev, &dev_attr_temp1_input)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_temp1_max)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_temp1_max_hyst))) goto exit_remove_files; } - data->class_dev =hwmon_device_register (&new_client->dev); + data->class_dev =hwmon_device_register (&pdev->dev);if (IS_ERR (data->class_dev)) { err =PTR_ERR (data->class_dev);goto
exit_remove_files;drivers/hwmon/sis5595.c +0
-0@@ -638,32 +595,26 @@ static int sis5595_detect(struct i2c_adareturn 0 ;
exit_remove_files:
-sysfs_remove_group(&new_client->dev.kobj, &sis5595_group);
-sysfs_remove_group(&new_client->dev.kobj, &sis5595_group_opt); -exit_detach:
-i2c_detach_client(new_client);
+sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
+sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt);exit_free:
kfree(data);exit_release:
-release_region(address, SIS5595_EXTENT);
+release_region(res->start, SIS5595_EXTENT);
exit:
return err;
}drivers/hwmon/sis5595.c +1
-1-static int sis5595_detach_client (struct i2c_client *client) +static int __devexit sis5595_remove(struct platform_device *pdev){
- structsis5595_data*data =i2c_get_clientdata(client);
- int err;
+ structsis5595_data*data =platform_get_drvdata(pdev);
hwmon_device_unregister(data->class_dev);
-sysfs_remove_group(&client->dev.kobj, &sis5595_group);
-sysfs_remove_group(&client->dev.kobj, &sis5595_group_opt);drivers/hwmon/sis5595.c +14
-19- -if ((err =i2c_detach_client (client))) -return err; - -release_region (client->addr,SIS5595_EXTENT ); +sysfs_remove_group (&pdev->dev.kobj, &sis5595_group); +sysfs_remove_group (&pdev->dev.kobj, &sis5595_group_opt); +release_region (data->addr,SIS5595_EXTENT ); +platform_set_drvdata (pdev,NULL );kfree (data);return 0 ;@@ -671,41 +622,37 @@ static int sis5595_detach_client(struct/* ISA access must be locked explicitly. */ -static int sis5595_read_value (struct i2c_client *client,u8 reg) +static int sis5595_read_value (struct sis5595_data *data,u8 reg) {int res; -struct sis5595_data *data =i2c_get_clientdata (client);mutex_lock (&data->lock); -outb_p (reg, client->addr +SIS5595_ADDR_REG_OFFSET ); - res =inb_p (client->addr +SIS5595_DATA_REG_OFFSET ); +outb_p (reg, data->addr +SIS5595_ADDR_REG_OFFSET ); + res =inb_p (data->addr +SIS5595_DATA_REG_OFFSET );mutex_unlock (&data->lock);return res; } -static int sis5595_write_value (struct i2c_client *client,u8 reg,u8 value) +static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value) { -struct sis5595_data *data =i2c_get_clientdata (client);mutex_lock (&data->lock); -outb_p (reg, client->addr +SIS5595_ADDR_REG_OFFSET ); -outb_p (value, client->addr +SIS5595_DATA_REG_OFFSET ); +outb_p (reg, data->addr +SIS5595_ADDR_REG_OFFSET ); +outb_p (value, data->addr +SIS5595_DATA_REG_OFFSET );mutex_unlock (&data->lock); -return 0 ; }/* Called when we have found a new SIS5595. */ -static void sis5595_init_client (struct i2c_client *client) +static void __devinit sis5595_init_device (struct sis5595_data *data) { -u8 config =sis5595_read_value (client,SIS5595_REG_CONFIG ); +u8 config =sis5595_read_value (data,SIS5595_REG_CONFIG );if (!(config &0x01 )) -sis5595_write_value (client,SIS5595_REG_CONFIG , +sis5595_write_value (data,SIS5595_REG_CONFIG , (config &0xf7 ) |0x01 ); }static struct sis5595_data *sis5595_update_device (struct device *dev) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);int i;
mutex_lock(&data->update_lock);drivers/hwmon/sis5595.c +92
-10@@ -715,35 +662,35 @@ static struct sis5595_data *sis5595_updafor (i =0 ; i <= data->maxins; i++) { data->in[i] > -sis5595_read_value (client,SIS5595_REG_IN (i)); +sis5595_read_value (data,SIS5595_REG_IN (i)); data->in_min[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_IN_MIN(i)); data->in_max[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_IN_MAX(i)); }for (i =0 ; i <2 ; i++) { data->fan[i] > -sis5595_read_value (client,SIS5595_REG_FAN (i)); +sis5595_read_value (data,SIS5595_REG_FAN (i)); data->fan_min[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_FAN_MIN(i)); }if (data->maxins =3 ) { data->temp > -sis5595_read_value (client,SIS5595_REG_TEMP ); +sis5595_read_value (data,SIS5595_REG_TEMP ); data->temp_over > -sis5595_read_value (client,SIS5595_REG_TEMP_OVER ); +sis5595_read_value (data,SIS5595_REG_TEMP_OVER ); data->temp_hyst > -sis5595_read_value (client,SIS5595_REG_TEMP_HYST ); +sis5595_read_value (data,SIS5595_REG_TEMP_HYST ); } - i =sis5595_read_value (client,SIS5595_REG_FANDIV ); + i =sis5595_read_value (data,SIS5595_REG_FANDIV ); data->fan_div[0 ] = (i >>4 ) &0x03 ; data->fan_div[1 ] = i >>6 ; data->alarms > -sis5595_read_value (client,SIS5595_REG_ALARM1 ) | - (sis5595_read_value (client,SIS5595_REG_ALARM2 ) <<8 ); +sis5595_read_value (data,SIS5595_REG_ALARM1 ) | + (sis5595_read_value (data,SIS5595_REG_ALARM2 ) <<8 ); data->last_updated = jiffies; data->valid =1 ; }@@ -774,10 +721,50 @@ static int blacklist[] __devinitdata = {PCI_DEVICE_ID_SI_5598 , 0 }; +static int __devinit sis5595_device_add (unsigned short address) +{ +struct resource res = { + .start = address, + .end = address +SIS5595_EXTENT -1 , + .name ="sis5595" , + .flags =IORESOURCE_IO , + }; +int err; + + pdev =platform_device_alloc ("sis5595" , address); +if (!pdev) { + err = -ENOMEM ; +printk (KERN_ERR "sis5595: Device allocation failed\n" ); + goto exit; + } + + err =platform_device_add_resources (pdev, &res,1 ); +if (err) { +printk (KERN_ERR "sis5595: Device resource addition failed " +"(%d)\n" , err); + goto exit_device_put; + } + + err =platform_device_add (pdev); +if (err) { +printk (KERN_ERR "sis5595: Device addition failed (%d)\n" , + err); + goto exit_device_put; + } + +return 0 ; + +exit_device_put: +platform_device_put (pdev); +exit: +return err; +} +static int __devinit sis5595_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) { -u16 val; +u16 address; +u8 enable;int *i;for (i = blacklist; *i !=0 ; i++) {@@ -790,26 +777,61 @@ static int __devinit sis5595_pci_probe(s } } + force_addr &= ~(SIS5595_EXTENT -1 ); +if (force_addr) { +dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , force_addr); + if (PCIBIOS_SUCCESSFUL !> + pci_write_config_word(dev, SIS5595_BASE_REG, force_addr)) +return -ENODEV ; + } + if (PCIBIOS_SUCCESSFUL !> - pci_read_config_word(dev, SIS5595_BASE_REG, &val)) + pci_read_config_word(dev, SIS5595_BASE_REG, &address)) return -ENODEV; - address = val & ~(SIS5595_EXTENT -1 ); -if (address =0 && force_addr =0 ) { + address &= ~(SIS5595_EXTENT -1 ); +if (!address) { dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } +if (force_addr && address != force_addr) { +/* doesn't work for some chips? */ +dev_warn (&dev->dev,"Failed to force ISA address\n" ); +return -ENODEV ; + } - s_bridge =pci_dev_get (dev); -if (i2c_isa_add_driver (&sis5595_driver)) { -pci_dev_put (s_bridge); - s_bridge =NULL ; + if (PCIBIOS_SUCCESSFUL !> + pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) { +return -ENODEV ; + } +if (!(enable &0x80 )) { + if ((PCIBIOS_SUCCESSFUL !> + pci_write_config_byte(dev, SIS5595_ENABLE_REG, + enable |0x80 )) + || (PCIBIOS_SUCCESSFUL !> + pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) + || (!(enable &0x80 ))) +/* doesn't work for some chips! */ +return -ENODEV ; } +if (platform_driver_register (&sis5595_driver)) + goto exit; + +/* Sets global pdev as a side effect */ +if (sis5595_device_add (address)) + goto exit_unregister; +/* Always return failure here. This is to allow other drivers to bind * to this pci device. We don't really want to have control over the * pci device, we only wanted to read as few register values from it. */ + s_bridge =pci_dev_get (dev); +return -ENODEV ; + +exit_unregister: +platform_driver_unregister (&sis5595_driver); +exit:return -ENODEV ; }@@ -828,7 +850,8 @@ static void __exit sm_sis5595_exit(void) {pci_unregister_driver (&sis5595_pci_driver);if (s_bridge !=NULL ) { -i2c_isa_del_driver (&sis5595_driver); +platform_device_unregister (pdev); +platform_driver_unregister (&sis5595_driver);pci_dev_put (s_bridge); s_bridge =NULL ; }Signature · 7 lines
-- Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHi Ivo,
Quoted 3 lines · Ivo Manca
I just noticed this post, and since I've got a crappy motherboard (PCCHIPS) with a sis5595 chipset, which outputs almost only bogus information (wrong voltages, no temprature), I am wondering if this patch could fix that,?
Most probably not. My patch only changes the driver type, it doesn't affect the functionality.
Quoted 11 lines
I didn't have the time to look deeply into it, but I will within a week or so. I will report back with more information as soon as I get the system up and (completely) running.
So I'll also test this patch for you, as good as I can get it to work:=
Problems with readings:
VCC 2.5V and VCC 3.3V seems to be readed rightly.
The other voltages just don't make sense; i still need to figure them out. I also get a in4 instead a temp; the docs say this seems to be a BIOS "feature". Any way to bypass this?
Depends on which revision of the chip you have, some always have the temperature, some (rev >= 0xb0) can have a voltage instead. The driver gets the correct setup from a bit in the PCI configuration space. The datasheet says the bit is R/W, so we must hope that the BIOS wrote the correct value. There is no way to change this in the driver, however you could always use "setpci" to change the value before you load the sis5595 driver.
Quoted 5 lines
Fan reading is not working, but neither is it in the bios.
DMI Info
Sys: PCCHIPS-M748LMRT-0000000
Baseboard: PCCHIPS-M748LMRT-1.0
Do the voltage and temperature work in the BIOS?
The SiS5595 has integrated sensors, but is primarily an I/O chip. It is entirely possible that the chip isn't wired for hardware monitoring at all because the manufacturer didn't care.
Here follows an updated version of my patch, the first version was using s_bridge before it was defined.
* * * * *
Convert the sis5595 driver from the nonsensical i2c-isa hack to a regular platform driver.
--- drivers/hwmon/Kconfig | 3 drivers/hwmon/sis5595.c | 318 +++++++++++++++++++++++++---------------------- 2 files changed, 172 insertions(+), 149 deletions(-)
drivers/hwmon/Kconfig +1 -2
@@ -431,8 +431,7 @@ config SENSORS_PC87427 config SENSORS_SIS5595 tristate "Silicon Integrated Systems Corp. SiS5595" - depends on I2C && PCI && EXPERIMENTAL - select I2C_ISA + depends on PCI help If you say yes here you get support for the integrated sensors in SiS5595 South Bridges.
drivers/hwmon/sis5595.c +167 -132
570 lines not on this page · raw message
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHey Jean
Quoted 2 lines
Most probably not. My patch only changes the driver type, it doesn't affect the functionality.
Ok. Already thought so :)
Quoted 7 lines
Depends on which revision of the chip you have, some always have the temperature, some (rev >=
0xb0) can have a voltage instead. The driver gets the correct setup from a bit in the PCI configuration space. The datasheet says the bit is R/W, so we must hope that the BIOS wrote the correct value. There is no way to change this in the driver, however you could always use "setpci" to change the value before you load the sis5595 driver.
I will try this as soon as I get the PC up and running again (propably later today or tommorrow).
Quoted 3 lines
Do the voltage and temperature work in the BIOS?
Yes, they show quite some sensible information, even though they seem to be different voltages as labeld in the default sensors.conf. I only got to get the VCC 2.5 and 3.3V right.
My BIOS shows:
As far as I can remember, my bios shows (with sensible output) CPU TEMP
CPU FAN:
CHASIS FAN:
VCC 5.0V
VCC 3.3V
VCC 2.5V
VCORE 2.0V
Quoted 6 lines
The SiS5595 has integrated sensors, but is primarily an I/O chip. It is entirely possible that the chip isn't wired for hardware monitoring at all because the manufacturer didn't care.
Here follows an updated version of my patch, the first version was using
s_bridgebefore it was defined.
I'll try to get it working on the pc. Since it's only a 333mhz Celeron cpu with about 32MB of ram, it might take some while to fetch a new kernel and compile it ;). Or are there any other ways I can compile it with less effort?
Quoted 637 lines
* * * * *
Convert the sis5595 driver from the nonsensical i2c-isa hack to a regular platform driver.
Signed-off-by Jean Delvare <[email protected]>---
drivers/hwmon/Kconfig| 3drivers/hwmon/sis5595.c| 318
+++++++++++++++++++++++++----------------------2 files changed, 172 insertions(+), 149 deletions(-)--- linux-2.6.22-rc3.orig/drivers/hwmon/Kconfig 2007-06-04 13:55:49.000000000 +0200
+++ linux-2.6.22-rc3/drivers/hwmon/Kconfig 2007-06-04 13:55:49.000000000 +0200(quoted diff) +0
-0@@ -431,8 +431,7 @@ config SENSORS_PC87427config
SENSORS_SIS5595
tristate "Silicon Integrated Systems Corp. SiS5595"
- depends on I2C && PCI && EXPERIMENTAL
- selectI2C_ISA
+ depends on PCI
help
If you say yes here you get support for the integrated sensors in SiS5595 South Bridges.
---linux-2.6.22-rc3.orig/drivers/hwmon/sis5595.c2007-06-04 09:58:45.000000000 +0200
+++linux-2.6.22-rc3/drivers/hwmon/sis5595.c2007-06-04 14:11:37.000000000 +0200drivers/hwmon/sis5595.c +4
-7@@ -54,8 +54,7 @@#include <linux/slab.h> #include <linux/ioport.h> #include <linux/pci.h> -#include <linux/i2c.h> -#include <linux/i2c-isa.h> +#include <linux/platform_device.h> #include <linux/hwmon.h> #include <linux/err.h> #include <linux/init.h> @@ -72,10 +71,7 @@ module_param(force_addr, ushort, 0);MODULE_PARM_DESC (force_addr,"Initialize the base address of the sensors" ); -/* Device address -Note that we can't determine the ISA address until we have initialized -our module */ -static unsigned short address; +static struct platform_device *pdev;/* Many SIS5595 constants specified below */ @@ -165,7 +161,8 @@ static inline u8 DIV_TO_REG(int val)/* For each registered chip, we need to keep some data in memory. The structure is dynamically allocated. */ struct sis5595_data { -struct i2c_client client; +unsigned short addr; +const char *name;struct class_device *class_dev;struct mutex lock;@@ -189,21 +186,21 @@ struct sis5595_data {static struct
pci_dev*s_bridge; /* pointer to the (only) sis5595 */drivers/hwmon/sis5595.c +2
-4-static int sis5595_detect (struct i2c_adapter *adapter); -static int sis5595_detach_client (struct i2c_client *client); +static int sis5595_probe (struct platform_device *pdev); +static int sis5595_remove (struct platform_device *pdev); -static int sis5595_read_value (struct i2c_client *client,u8 reg); -static int sis5595_write_value(struct i2c_client *client, u8 reg, u8value);
(quoted diff) +2
-0+static int sis5595_read_value(struct sis5595_data *data, u8 reg); +static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8value);
static structsis5595_data*sis5595_update_device(struct device *dev);drivers/hwmon/sis5595.c +4
-4-static void sis5595_init_client (struct i2c_client *client); +static void sis5595_init_device (struct sis5595_data *data); -static struct i2c_driver sis5595_driver = { +static struct platform_driver sis5595_driver = { .driver = { .owner =THIS_MODULE , .name ="sis5595" , }, - .attach_adapter = sis5595_detect, - .detach_client = sis5595_detach_client, + .probe = sis5595_probe, + .remove =__devexit_p (sis5595_remove),};
/* 4 Voltages */
drivers/hwmon/sis5595.c +4
-6@@ -228,13 +225,12 @@ static ssize_t show_in_max(struct devicestatic ssize_t set_in_min (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->in_min[nr] =IN_TO_REG (val); -sis5595_write_value (client,SIS5595_REG_IN_MIN (nr), data->in_min[nr]); +sis5595_write_value (data,SIS5595_REG_IN_MIN (nr), data->in_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -242,13 +238,12 @@ static ssize_t set_in_min(struct devicestatic ssize_t set_in_max (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->in_max[nr] =IN_TO_REG (val); -sis5595_write_value (client,SIS5595_REG_IN_MAX (nr), data->in_max[nr]); +sis5595_write_value (data,SIS5595_REG_IN_MAX (nr), data->in_max[nr]);mutex_unlock (&data->update_lock);return count; }@@ -307,13 +302,12 @@ static ssize_t show_temp_over(struct devstatic
ssize_tset_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
- structi2c_client*client =to_i2c_client(dev);
- structsis5595_data*data =i2c_get_clientdata(client);
+ structsis5595_data*data =dev_get_drvdata(dev);
long val =simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock);
data->temp_over=TEMP_TO_REG(val);
-sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
+sis5595_write_value(data, SIS5595_REG_TEMP_OVER, data->temp_over);mutex_unlock(&data->update_lock);
return count;
}(quoted diff) +0
-0@@ -326,13 +320,12 @@ static ssize_t show_temp_hyst(struct devstatic
ssize_tset_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
- structi2c_client*client =to_i2c_client(dev);
- structsis5595_data*data =i2c_get_clientdata(client);
+ structsis5595_data*data =dev_get_drvdata(dev);
long val =simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock);
data->temp_hyst=TEMP_TO_REG(val);
-sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
+sis5595_write_value(data, SIS5595_REG_TEMP_HYST, data->temp_hyst);mutex_unlock(&data->update_lock);
return count;
}drivers/hwmon/sis5595.c +15
-9@@ -361,13 +354,12 @@ static ssize_t show_fan_min(struct devicstatic ssize_t set_fan_min (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->fan_min[nr] =FAN_TO_REG (val,DIV_FROM_REG (data->fan_div[nr])); -sis5595_write_value (client,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]); +sis5595_write_value (data,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -385,8 +377,7 @@ static ssize_t show_fan_div(struct devicstatic ssize_t set_fan_div (struct device *dev,const char *buf,size_t count,int nr) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);unsigned long min;unsigned long val =simple_strtoul (buf,NULL ,10 );int reg;@@ -394,7 +385,7 @@ static ssize_t set_fan_div(struct devicemutex_lock (&data->update_lock); min =FAN_FROM_REG (data->fan_min[nr],DIV_FROM_REG (data->fan_div[nr])); - reg =sis5595_read_value (client,SIS5595_REG_FANDIV ); + reg =sis5595_read_value (data,SIS5595_REG_FANDIV );switch (val) {case 1 : data->fan_div[nr] =0 ;break ;@@ -402,7 +393,7 @@ static ssize_t set_fan_div(struct devicecase 4 : data->fan_div[nr] =2 ;break ;case 8 : data->fan_div[nr] =3 ;break ;default : -dev_err (&client->dev,"fan_div value %ld not " +dev_err (dev,"fan_div value %ld not " "supported. Choose one of 1, 2, 4 or 8!\n" , val);mutex_unlock (&data->update_lock);return -EINVAL ;@@ -416,10 +407,10 @@ static ssize_t set_fan_div(struct device reg = (reg &0x3f ) | (data->fan_div[nr] <<6 );break ; } -sis5595_write_value (client,SIS5595_REG_FANDIV , reg); +sis5595_write_value (data,SIS5595_REG_FANDIV , reg); data->fan_min[nr] >FAN_TO_REG (min,DIV_FROM_REG (data->fan_div[nr])); -sis5595_write_value (client,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]); +sis5595_write_value (data,SIS5595_REG_FAN_MIN (nr), data->fan_min[nr]);mutex_unlock (&data->update_lock);return count; }@@ -473,6 +464,14 @@ static ssize_t show_alarms(struct device } static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); +static ssize_t show_name (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct sis5595_data *data =dev_get_drvdata (dev); +return sprintf (buf,"%s\n" , data->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); +static struct attribute *sis5595_attributes[] = { &dev_attr_in0_input.attr,&dev_attr_in0_min.attr,
drivers/hwmon/sis5595.c +20
-57@@ -495,6 +494,7 @@ static struct attribute *sis5595_attribu &dev_attr_fan2_div.attr, &dev_attr_alarms.attr, + &dev_attr_name.attr, NULL };@@ -518,65 +518,32 @@ static const struct attribute_group sis5 };/* This is called when the module is loaded */ -static int sis5595_detect (struct i2c_adapter *adapter) +static int __devinit sis5595_probe (struct platform_device *pdev) {int err =0 ;int i; -struct i2c_client *new_client;struct sis5595_data *data; +struct resource *res;char val; -u16 a; -if (force_addr) - address = force_addr & ~(SIS5595_EXTENT -1 );/* Reserve the ISA region */ -if (!request_region (address,SIS5595_EXTENT , + res =platform_get_resource (pdev,IORESOURCE_IO ,0 ); +if (!request_region (res->start,SIS5595_EXTENT , sis5595_driver.driver.name)) { err = -EBUSY ; goto exit; } -if (force_addr) { -dev_warn (&adapter->dev,"forcing ISA address 0x%04X\n" , address); - if (PCIBIOS_SUCCESSFUL !> - pci_write_config_word(s_bridge, SIS5595_BASE_REG, address)) - goto exit_release; - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_word(s_bridge, SIS5595_BASE_REG, &a)) - goto exit_release; -if ((a & ~(SIS5595_EXTENT -1 )) != address) -/* doesn't work for some chips? */ - goto exit_release; - } - - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) { - goto exit_release; - } -if ((val &0x80 ) =0 ) { - if (PCIBIOS_SUCCESSFUL !> - pci_write_config_byte(s_bridge, SIS5595_ENABLE_REG, - val |0x80 )) - goto exit_release; - if (PCIBIOS_SUCCESSFUL !> - pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) - goto exit_release; -if ((val &0x80 ) =0 ) -/* doesn't work for some chips! */ - goto exit_release; - }if (!(data =kzalloc (sizeof (struct sis5595_data ),GFP_KERNEL ))) { err = -ENOMEM ; goto exit_release; } - new_client = &data->client; - new_client->addr = address;mutex_init (&data->lock); -i2c_set_clientdata (new_client, data); - new_client->adapter = adapter; - new_client->driver = &sis5595_driver; - new_client->flags =0 ; +mutex_init (&data->update_lock); + data->addr = res->start; + data->name ="sis5595" ; +platform_set_drvdata (pdev, data);/* Check revision and pin registers to determine whether 4 or 5 voltages */ pci_read_config_byte (s_bridge,SIS5595_REVISION_REG , &(data->revision));@@ -589,47 +556,37 @@ static int sis5595_detect(struct i2c_adadata->maxins = 4; } -/* Fill in the remaining client fields and put it into the global list */ -strlcpy (new_client->name,"sis5595" ,I2C_NAME_SIZE ); - - data->valid =0 ; -mutex_init (&data->update_lock); - -/* Tell the I2C layer a new client has arrived */ -if ((err =i2c_attach_client (new_client))) - goto exit_free; -/* Initialize the SIS5595 chip */ -sis5595_init_client (new_client); +sis5595_init_device (data);/* A few vars need to be filled upon startup */ for (i =0 ; i <2 ; i++) { - data->fan_min[i] =sis5595_read_value (new_client, + data->fan_min[i] =sis5595_read_value (data,SIS5595_REG_FAN_MIN (i)); }/* Register sysfs hooks */ -if ((err =sysfs_create_group (&new_client->dev.kobj, &sis5595_group))) - goto exit_detach; +if ((err =sysfs_create_group (&pdev->dev.kobj, &sis5595_group))) + goto exit_free;if (data->maxins =4 ) { -if ((err =device_create_file (&new_client->dev, +if ((err =device_create_file (&pdev->dev, &dev_attr_in4_input)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_in4_min)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_in4_max))) goto exit_remove_files; }else { -if ((err =device_create_file (&new_client->dev, +if ((err =device_create_file (&pdev->dev, &dev_attr_temp1_input)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_temp1_max)) - || (err =device_create_file (&new_client->dev, + || (err =device_create_file (&pdev->dev, &dev_attr_temp1_max_hyst))) goto exit_remove_files; } - data->class_dev =hwmon_device_register (&new_client->dev); + data->class_dev =hwmon_device_register (&pdev->dev);if (IS_ERR (data->class_dev)) { err =PTR_ERR (data->class_dev);goto
exit_remove_files;drivers/hwmon/sis5595.c +0
-0@@ -638,32 +595,26 @@ static int sis5595_detect(struct i2c_adareturn 0 ;
exit_remove_files:
-sysfs_remove_group(&new_client->dev.kobj, &sis5595_group);
-sysfs_remove_group(&new_client->dev.kobj, &sis5595_group_opt); -exit_detach:
-i2c_detach_client(new_client);
+sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
+sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt);exit_free:
kfree(data);exit_release:
-release_region(address, SIS5595_EXTENT);
+release_region(res->start, SIS5595_EXTENT);
exit:
return err;
}drivers/hwmon/sis5595.c +1
-1-static int sis5595_detach_client (struct i2c_client *client) +static int __devexit sis5595_remove(struct platform_device *pdev){
- structsis5595_data*data =i2c_get_clientdata(client);
- int err;
+ structsis5595_data*data =platform_get_drvdata(pdev);
hwmon_device_unregister(data->class_dev);
-sysfs_remove_group(&client->dev.kobj, &sis5595_group);
-sysfs_remove_group(&client->dev.kobj, &sis5595_group_opt);drivers/hwmon/sis5595.c +14
-19- -if ((err =i2c_detach_client (client))) -return err; - -release_region (client->addr,SIS5595_EXTENT ); +sysfs_remove_group (&pdev->dev.kobj, &sis5595_group); +sysfs_remove_group (&pdev->dev.kobj, &sis5595_group_opt); +release_region (data->addr,SIS5595_EXTENT ); +platform_set_drvdata (pdev,NULL );kfree (data);return 0 ;@@ -671,41 +622,37 @@ static int sis5595_detach_client(struct/* ISA access must be locked explicitly. */ -static int sis5595_read_value (struct i2c_client *client,u8 reg) +static int sis5595_read_value (struct sis5595_data *data,u8 reg) {int res; -struct sis5595_data *data =i2c_get_clientdata (client);mutex_lock (&data->lock); -outb_p (reg, client->addr +SIS5595_ADDR_REG_OFFSET ); - res =inb_p (client->addr +SIS5595_DATA_REG_OFFSET ); +outb_p (reg, data->addr +SIS5595_ADDR_REG_OFFSET ); + res =inb_p (data->addr +SIS5595_DATA_REG_OFFSET );mutex_unlock (&data->lock);return res; } -static int sis5595_write_value (struct i2c_client *client,u8 reg,u8 value) +static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value) { -struct sis5595_data *data =i2c_get_clientdata (client);mutex_lock (&data->lock); -outb_p (reg, client->addr +SIS5595_ADDR_REG_OFFSET ); -outb_p (value, client->addr +SIS5595_DATA_REG_OFFSET ); +outb_p (reg, data->addr +SIS5595_ADDR_REG_OFFSET ); +outb_p (value, data->addr +SIS5595_DATA_REG_OFFSET );mutex_unlock (&data->lock); -return 0 ; }/* Called when we have found a new SIS5595. */ -static void sis5595_init_client (struct i2c_client *client) +static void __devinit sis5595_init_device (struct sis5595_data *data) { -u8 config =sis5595_read_value (client,SIS5595_REG_CONFIG ); +u8 config =sis5595_read_value (data,SIS5595_REG_CONFIG );if (!(config &0x01 )) -sis5595_write_value (client,SIS5595_REG_CONFIG , +sis5595_write_value (data,SIS5595_REG_CONFIG , (config &0xf7 ) |0x01 ); }static struct sis5595_data *sis5595_update_device (struct device *dev) { -struct i2c_client *client =to_i2c_client (dev); -struct sis5595_data *data =i2c_get_clientdata (client); +struct sis5595_data *data =dev_get_drvdata (dev);int i;
mutex_lock(&data->update_lock);drivers/hwmon/sis5595.c +93
-10@@ -715,35 +662,35 @@ static struct sis5595_data *sis5595_updafor (i =0 ; i <= data->maxins; i++) { data->in[i] > -sis5595_read_value (client,SIS5595_REG_IN (i)); +sis5595_read_value (data,SIS5595_REG_IN (i)); data->in_min[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_IN_MIN(i)); data->in_max[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_IN_MAX(i)); }for (i =0 ; i <2 ; i++) { data->fan[i] > -sis5595_read_value (client,SIS5595_REG_FAN (i)); +sis5595_read_value (data,SIS5595_REG_FAN (i)); data->fan_min[i] > -sis5595_read_value (client, +sis5595_read_value (data, SIS5595_REG_FAN_MIN(i)); }if (data->maxins =3 ) { data->temp > -sis5595_read_value (client,SIS5595_REG_TEMP ); +sis5595_read_value (data,SIS5595_REG_TEMP ); data->temp_over > -sis5595_read_value (client,SIS5595_REG_TEMP_OVER ); +sis5595_read_value (data,SIS5595_REG_TEMP_OVER ); data->temp_hyst > -sis5595_read_value (client,SIS5595_REG_TEMP_HYST ); +sis5595_read_value (data,SIS5595_REG_TEMP_HYST ); } - i =sis5595_read_value (client,SIS5595_REG_FANDIV ); + i =sis5595_read_value (data,SIS5595_REG_FANDIV ); data->fan_div[0 ] = (i >>4 ) &0x03 ; data->fan_div[1 ] = i >>6 ; data->alarms > -sis5595_read_value (client,SIS5595_REG_ALARM1 ) | - (sis5595_read_value (client,SIS5595_REG_ALARM2 ) <<8 ); +sis5595_read_value (data,SIS5595_REG_ALARM1 ) | + (sis5595_read_value (data,SIS5595_REG_ALARM2 ) <<8 ); data->last_updated = jiffies; data->valid =1 ; }@@ -774,10 +721,50 @@ static int blacklist[] __devinitdata = {PCI_DEVICE_ID_SI_5598 , 0 }; +static int __devinit sis5595_device_add (unsigned short address) +{ +struct resource res = { + .start = address, + .end = address +SIS5595_EXTENT -1 , + .name ="sis5595" , + .flags =IORESOURCE_IO , + }; +int err; + + pdev =platform_device_alloc ("sis5595" , address); +if (!pdev) { + err = -ENOMEM ; +printk (KERN_ERR "sis5595: Device allocation failed\n" ); + goto exit; + } + + err =platform_device_add_resources (pdev, &res,1 ); +if (err) { +printk (KERN_ERR "sis5595: Device resource addition failed " +"(%d)\n" , err); + goto exit_device_put; + } + + err =platform_device_add (pdev); +if (err) { +printk (KERN_ERR "sis5595: Device addition failed (%d)\n" , + err); + goto exit_device_put; + } + +return 0 ; + +exit_device_put: +platform_device_put (pdev); +exit: +return err; +} +static int __devinit sis5595_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) { -u16 val; +u16 address; +u8 enable;int *i;for (i = blacklist; *i !=0 ; i++) {@@ -790,27 +777,63 @@ static int __devinit sis5595_pci_probe(s } } + force_addr &= ~(SIS5595_EXTENT -1 ); +if (force_addr) { +dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , force_addr); + if (PCIBIOS_SUCCESSFUL !> + pci_write_config_word(dev, SIS5595_BASE_REG, force_addr)) +return -ENODEV ; + } + if (PCIBIOS_SUCCESSFUL !> - pci_read_config_word(dev, SIS5595_BASE_REG, &val)) + pci_read_config_word(dev, SIS5595_BASE_REG, &address)) return -ENODEV; - address = val & ~(SIS5595_EXTENT -1 ); -if (address =0 && force_addr =0 ) { + address &= ~(SIS5595_EXTENT -1 ); +if (!address) { dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } +if (force_addr && address != force_addr) { +/* doesn't work for some chips? */ +dev_warn (&dev->dev,"Failed to force ISA address\n" ); +return -ENODEV ; + } - s_bridge =pci_dev_get (dev); -if (i2c_isa_add_driver (&sis5595_driver)) { -pci_dev_put (s_bridge); - s_bridge =NULL ; + if (PCIBIOS_SUCCESSFUL !> + pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) { +return -ENODEV ; + } +if (!(enable &0x80 )) { + if ((PCIBIOS_SUCCESSFUL !> + pci_write_config_byte(dev, SIS5595_ENABLE_REG, + enable |0x80 )) + || (PCIBIOS_SUCCESSFUL !> + pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) + || (!(enable &0x80 ))) +/* doesn't work for some chips! */ +return -ENODEV ; } +if (platform_driver_register (&sis5595_driver)) + goto exit; + + s_bridge =pci_dev_get (dev); +/* Sets global pdev as a side effect */ +if (sis5595_device_add (address)) + goto exit_unregister; +/* Always return failure here. This is to allow other drivers to bind * to this pci device. We don't really want to have control over the * pci device, we only wanted to read as few register values from it. */ return -ENODEV ; + +exit_unregister: +pci_dev_put (dev); +platform_driver_unregister (&sis5595_driver); +exit: +return -ENODEV ; }static struct pci_driver sis5595_pci_driver = {@@ -828,7 +851,8 @@ static void __exit sm_sis5595_exit(void) {pci_unregister_driver (&sis5595_pci_driver);if (s_bridge !=NULL ) { -i2c_isa_del_driver (&sis5595_driver); +platform_device_unregister (pdev); +platform_driver_unregister (&sis5595_driver);pci_dev_put (s_bridge); s_bridge =NULL ; }Signature · 2 lines
-- Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareIvo,
Quoted 4 lines · Ivo Manca
I'll try to get it working on the pc. Since it's only a 333mhz Celeron cpu with about 32MB of ram, it might take some while to fetch a new kernel and compile it ;). Or are there any other ways I can compile it with less effort?
If you have another system of the same architecture, you can simply compile your kernel there, make a staged install (set INSTALL_PATH and INSTALL_MOD_PATH) and copy all the files over the network.
Or if you have other systems with the same architecture _and_ compiler, look into distcc. I have been using it some times ago and it was working fine.
http://distcc.samba.org/
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHey Jean,
I succeeded in compiling and testing 2.6.22-rc3 with your submitted patches. It does not seem to work. Maybe I'm doing something wrong here, or am overlooking something really big? I am quite new to this, after all. I will patch a new and clean kernel tomorrow and compile it again, just to make sure I didn't mess anything up (which might be the case). Is it possible for you to send the patches as attachment? Seems like my mailclient messed them up the first time, so I might have messed it up trying to get them to work (even though it didn't give any errors the last time I patched..) ;/. It also doesn't give errors upon modprobing.
So far my output:
--
[root@localhost detect]# uname -r
2.6.22-rc3
[root@localhost detect]# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are.
[root@localhost detect]# lsmod
Module Size Used by i2c_dev 9860 0 ne2k_pci 12128 0 8390 11520 1 ne2k_pci sis5595 15500 0 hwmon 6404 1 sis5595 i2c_sis630 11276 0 i2c_sis5595 10244 0
--
[root@localhost ~]# uname -r
2.6.19-1.2911.fc6
[root@localhost ~]# sensors
sis5595-isa-0290
Adapter: ISA adapter VCore 1: +2.86 V (min = +0.00 V, max = +0.00 V) ALARM VCore 2: +3.41 V (min = +0.00 V, max = +0.00 V) ALARM +3.3V: +2.77 V (min = +0.00 V, max = +0.00 V) ALARM +5V: +3.44 V (min = +0.00 V, max = +0.00 V) ALARM +12V: +14.90 V (min = +0.00 V, max = +0.00 V) ALARM fan1: 0 RPM (min = -1 RPM, div = 2) ALARM fan2: 0 RPM (min = -1 RPM, div = 2) ALARM
alarms: Board temperature input (usually LM75 chips) ALARM
[root@localhost ~]# lsmod
Module Size Used by autofs4 25797 2 dmfe 24677 0 ipv6 276481 12 dm_mirror 26897 0 dm_multipath 23241 0 dm_mod 63449 2 dm_mirror,dm_multipath parport_pc 31205 1 lp 16905 0 parport 40841 2 parport_pc,lp snd_cmipci 39521 0 gameport 20297 1 snd_cmipci floppy 61477 0 snd_seq_dummy 8133 0 snd_seq_oss 37057 0 snd_seq_midi_event 11841 1 snd_seq_oss snd_seq 57009 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event snd_pcm_oss 46433 0 snd_mixer_oss 20545 1 snd_pcm_oss snd_pcm 80965 2 snd_cmipci,snd_pcm_oss snd_page_alloc 14281 1 snd_pcm snd_opl3_lib 14913 1 snd_cmipci ne2k_pci 15265 0 snd_timer 26693 3 snd_seq,snd_pcm,snd_opl3_lib 8390 14789 1 ne2k_pci snd_hwdep 13637 1 snd_opl3_lib pcspkr 7360 0 i2c_sis630 11853 0 i2c_sis5595 11717 0 sis5595 19401 0 hwmon 7621 1 sis5595 i2c_isa 9665 1 sis5595 snd_mpu401_uart 13249 1 snd_cmipci i2c_core 26049 4 i2c_sis630,i2c_sis5595,sis5595,i2c_isa snd_rawmidi 28481 1 snd_mpu401_uart snd_seq_device 12365 5 snd_seq_dummy,snd_seq_oss,snd_seq,snd_opl3_lib,snd_rawmidi snd 58181 12 snd_cmipci,snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_opl3_lib,snd_timer,snd_hwdep,snd_mpu401_uart,snd_rawmidi,snd_seq_device soundcore 12193 1 snd ext3 136905 2 jbd 65001 1 ext3 ehci_hcd 35661 0 ohci_hcd 25433 0 uhci_hcd 28237 0
Ivo
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "Ivo Manca" <[email protected]>
Cc: <[email protected]>
Sent: Monday 4 June 2007 17:37
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 10 lines
Ivo,
Quoted 6 lines · Ivo Manca
I'll try to get it working on the pc. Since it's only a 333mhz Celeron cpu
with about 32MB of ram, it might take some while to fetch a new kernel and
compile it ;). Or are there any other ways I can compile it with less effort?
Quoted 11 lines
If you have another system of the same architecture, you can simply compile your kernel there, make a staged install (set
INSTALL_PATHandINSTALL_MOD_PATH) and copy all the files over the network.Or if you have other systems with the same architecture _and_ compiler, look into distcc. I have been using it some times ago and it was working fine.
http://distcc.samba.org/Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHi Jean,
I've removed the kernel source, extracted a fresh tarball, applied the patches and recompiled the kernel&modules.
After copying them to the other pc and rebooting it, the following output was shown:
[root@localhost ~]# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are.
If you need more information, just ask
Ivo
----- Original Message -----
From: "Ivo Manca" <[email protected]>
To: "Jean Delvare" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday 6 June 2007 0:08
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 97 lines
Hey Jean,
I succeeded in compiling and testing 2.6.22-rc3 with your submitted patches. It does not seem to work. Maybe I'm doing something wrong here, or am overlooking something really big? I am quite new to this, after all. I will patch a new and clean kernel tomorrow and compile it again, just to make sure I didn't mess anything up (which might be the case). Is it possible for you to send the patches as attachment? Seems like my mailclient messed them up the first time, so I might have messed it up trying to get them to work (even though it didn't give any errors the last time I patched..) ;/. It also doesn't give errors upon modprobing.
So far my output:
--
[root@localhost detect]# uname -r
2.6.22-rc3[root@localhost detect]# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are.[root@localhost detect]# lsmod
Module Size Used by i2c_dev 9860 0 ne2k_pci 12128 0 8390 11520 1 ne2k_pci sis5595 15500 0 hwmon 6404 1 sis5595 i2c_sis630 11276 0 i2c_sis5595 10244 0--
[root@localhost ~]# uname -r
2.6.19-1.2911.fc6[root@localhost ~]# sensors
sis5595-isa-0290Adapter: ISA adapter VCore 1: +2.86 V (min = +0.00 V, max = +0.00 V) ALARM VCore 2: +3.41 V (min = +0.00 V, max = +0.00 V) ALARM +3.3V: +2.77 V (min = +0.00 V, max = +0.00 V) ALARM +5V: +3.44 V (min = +0.00 V, max = +0.00 V) ALARM +12V: +14.90 V (min = +0.00 V, max = +0.00 V) ALARM fan1: 0 RPM (min = -1 RPM, div = 2) ALARM fan2: 0 RPM (min = -1 RPM, div = 2) ALARMalarms: Board temperature input (usually LM75 chips) ALARM
[root@localhost ~]# lsmod
Module Size Used by autofs4 25797 2 dmfe 24677 0 ipv6 276481 12 dm_mirror 26897 0 dm_multipath 23241 0 dm_mod 63449 2 dm_mirror,dm_multipath parport_pc 31205 1 lp 16905 0 parport 40841 2 parport_pc,lp snd_cmipci 39521 0 gameport 20297 1 snd_cmipci floppy 61477 0 snd_seq_dummy 8133 0 snd_seq_oss 37057 0 snd_seq_midi_event 11841 1 snd_seq_oss snd_seq 57009 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event snd_pcm_oss 46433 0 snd_mixer_oss 20545 1 snd_pcm_oss snd_pcm 80965 2 snd_cmipci,snd_pcm_oss snd_page_alloc 14281 1 snd_pcm snd_opl3_lib 14913 1 snd_cmipci ne2k_pci 15265 0 snd_timer 26693 3 snd_seq,snd_pcm,snd_opl3_lib 8390 14789 1 ne2k_pci snd_hwdep 13637 1 snd_opl3_lib pcspkr 7360 0 i2c_sis630 11853 0 i2c_sis5595 11717 0 sis5595 19401 0 hwmon 7621 1 sis5595 i2c_isa 9665 1 sis5595 snd_mpu401_uart 13249 1 snd_cmipci i2c_core 26049 4 i2c_sis630,i2c_sis5595,sis5595,i2c_isa snd_rawmidi 28481 1 snd_mpu401_uart snd_seq_device 12365 5 snd_seq_dummy,snd_seq_oss,snd_seq,snd_opl3_lib,snd_rawmidi snd 58181 12 snd_cmipci,snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_opl3_lib,snd_timer,snd_hwdep,snd_mpu401_uart,snd_rawmidi,snd_seq_device soundcore 12193 1 snd ext3 136905 2 jbd 65001 1 ext3 ehci_hcd 35661 0 ohci_hcd 25433 0 uhci_hcd 28237 0
Quoted 32 lines
Ivo
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "Ivo Manca" <[email protected]>
Cc: <[email protected]>
Sent: Monday 4 June 2007 17:37
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driverQuoted 21 lines
Ivo,
Quoted 6 lines · Ivo Manca
I'll try to get it working on the pc. Since it's only a 333mhz Celeron cpu
with about 32MB of ram, it might take some while to fetch a new kernel and
compile it ;). Or are there any other ways I can compile it with less effort?If you have another system of the same architecture, you can simply compile your kernel there, make a staged install (set
INSTALL_PATHandINSTALL_MOD_PATH) and copy all the files over the network.Or if you have other systems with the same architecture _and_ compiler, look into distcc. I have been using it some times ago and it was working fine.
http://distcc.samba.org/Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHi Ivo,
Quoted 11 lines · Ivo Manca
I've removed the kernel source, extracted a fresh tarball, applied the patches and recompiled the kernel&modules.
After copying them to the other pc and rebooting it, the following output was shown:[root@localhost ~]# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are.If you need more information, just ask
Which version of lm-sensors are you using? Platform device support was only added in 2.10.0, and received some fixes in 2.10.1. (With 2.10.0 you need to load at least one i2c driver, even unrelated, for it to work.)
If you already have lm-sensors version >= 2.10.1, please compile with CONFIG_HWMON_DEBUG_CHIP=y and look into your logs when loading the driver. Also check what you see under /sys/class/hwmon
and /sys/bus/platform.
Thanks,
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareIvo,
Please don't forget the mailing list!
Quoted 4 lines · Ivo Manca
[root@localhost ~]# sensors -v
sensors version 2.10.1 with libsensors version 2.10.1I'll update it if you want.
No, that should be OK.
Quoted 8 lines
Quoted 4 lines
If you already have lm-sensors version >= 2.10.1, please compile with
CONFIG_HWMON_DEBUG_CHIP=yand look into your logs when loading the driver. Also check what you see under/sys/class/hwmon
and/sys/bus/platform.I already enabled
hwmon_debug_chip, however, nothing seems to get logged. It should go somewhere to/var/log, shouldn't it? Only log file changing is my messages, but that's just moaning about nmbd ;)
If should show in the output of "dmesg" to start with, and indeed also in /var/log/messages and/or /var/log/debug.
Quoted 38 lines
[ivo@localhost log]$ ls -l
/sys/class/hwmon/
total 0[ivo@localhost log]$ ls -lR
/sys/bus/platform//sys/bus/platform/:
total 0drwxr-xr-x 2 root root 0 Jun 6 10:05 devices drwxr-xr-x 4 root root 0 Jun 6 10:05 drivers -rw-r--r-- 1 root root 4096 Jun 6 10:56 drivers_autoprobe --w------- 1 root root 4096 Jun 6 10:56 drivers_probe
/sys/bus/platform/devices:
total 0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 floppy.0 -> ../../../devices/platform/floppy.0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 i8042 -> ../../../devices/platform/i8042
lrwxrwxrwx 1 root root 0 Jun 6 10:05 microcode -> ../../../devices/platform/microcode lrwxrwxrwx 1 root root 0 Jun 6 10:05 pcspkr -> ../../../devices/platform/pcspkr
lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250 -> ../../../devices/platform/serial8250 lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250.0 -> ../../../devices/platform/serial8250.0
/sys/bus/platform/drivers:
total 0
drwxr-xr-x 2 root root 0 Jun 6 10:05 i8042
drwxr-xr-x 2 root root 0 Jun 6 10:05 serial8250
/sys/bus/platform/drivers/i8042:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 i8042 ->
../../../../devices/platform/i8042
--w------- 1 root root 4096 Jun 6 10:57 unbind
Quoted 8 lines
/sys/bus/platform/drivers/serial8250:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250 ->
../../../../devices/platform/serial8250
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250.0 ->
../../../../devices/platform/serial8250.0
--w------- 1 root root 4096 Jun 6 10:57 unbind
Odd. No sign of sis5595 anywhere.
Quoted 10 lines
[ivo@localhost log]$ lsmod
Module Size Used by sis5595 14348 0 i2c_sis5595 10244 0 i2c_dev 9860 0 hwmon 6404 1 sis5595 ne2k_pci 12128 0 8390 11520 1 ne2k_pci
/sys/class/hwmonshouldn't be empty, should it?
It shouldn't, but OTOH given that the sis5595 platform driver seemingly wasn't registered properly, I am not surprised.
My previous patch had some error paths which didn't display any error nor debug message. I guess that one of these error conditions occurred and this is why you don't see anything in the logs. So I attached a new version of the patch with messages on all the error paths. Please revert the previous patch and apply this one instead, leaving debugging enabled of course. Hopefully you'll have something in the log this time, and from there we'll see what needs to be fixed.
Thanks,
Signature · 1 line
Jean Delvare
Subject: hwmon/sis5595: Convert to a platform driver
Convert the sis5595 driver from the nonsensical i2c-isa hack to a regular platform driver.
--- drivers/hwmon/Kconfig | 3 drivers/hwmon/sis5595.c | 323 +++++++++++++++++++++++++---------------------- 2 files changed, 177 insertions(+), 149 deletions(-)
drivers/hwmon/Kconfig +1 -2
@@ -431,8 +431,7 @@ config SENSORS_PC87427 config SENSORS_SIS5595 tristate "Silicon Integrated Systems Corp. SiS5595" - depends on I2C && PCI && EXPERIMENTAL - select I2C_ISA + depends on PCI help If you say yes here you get support for the integrated sensors in SiS5595 South Bridges.
drivers/hwmon/sis5595.c +176 -147
595 lines not on this page · raw message
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareOops, sorry, I indeed forgot it!
Quoted 8 lines
Ivo,
Please don't forget the mailing list!
No, that should be OK.
If should show in the output of "dmesg" to start with, and indeed also in
/var/log/messagesand/or/var/log/debug.
Attached messages and dmesg. Seems like quite some things are going wrong?
Quoted 11 lines
It shouldn't, but OTOH given that the sis5595 platform driver seemingly wasn't registered properly, I am not surprised.
My previous patch had some error paths which didn't display any error nor debug message. I guess that one of these error conditions occurred and this is why you don't see anything in the logs. So I attached a new version of the patch with messages on all the error paths. Please revert the previous patch and apply this one instead, leaving debugging enabled of course. Hopefully you'll have something in the log this time, and from there we'll see what needs to be fixed.
Will do, will report back in an hour or so
Quoted 3 lines
Thanks,
Signature · 1 line
Jean Delvare
Anytime,
Ivo
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHey Jean,
I can't get _anything_ to enter my logs. Is there something required, besided enabling the hwmon debugging messages? I've tried to find more information about logging on the web, but couldn't find anything relevant.
Ivo
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "Ivo Manca" <[email protected]>
Cc: "LM Sensors" <[email protected]>
Sent: Wednesday 6 June 2007 14:51
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 97 lines
Ivo,
Please don't forget the mailing list!
Quoted 4 lines · Ivo Manca
[root@localhost ~]# sensors -v
sensors version 2.10.1 with libsensors version 2.10.1I'll update it if you want.
No, that should be OK.
Quoted 10 lines
Quoted 4 lines
If you already have lm-sensors version >= 2.10.1, please compile with
CONFIG_HWMON_DEBUG_CHIP=yand look into your logs when loading the driver. Also check what you see under/sys/class/hwmon
and/sys/bus/platform.I already enabled
hwmon_debug_chip, however, nothing seems to get logged. It
should go somewhere to/var/log, shouldn't it? Only log file changing is my
messages, but that's just moaning about nmbd ;)If should show in the output of "dmesg" to start with, and indeed also in
/var/log/messagesand/or/var/log/debug.Quoted 38 lines
[ivo@localhost log]$ ls -l
/sys/class/hwmon/
total 0[ivo@localhost log]$ ls -lR
/sys/bus/platform//sys/bus/platform/:
total 0drwxr-xr-x 2 root root 0 Jun 6 10:05 devices drwxr-xr-x 4 root root 0 Jun 6 10:05 drivers -rw-r--r-- 1 root root 4096 Jun 6 10:56 drivers_autoprobe --w------- 1 root root 4096 Jun 6 10:56 drivers_probe
/sys/bus/platform/devices:
total 0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 floppy.0 -> ../../../devices/platform/floppy.0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 i8042 -> ../../../devices/platform/i8042
lrwxrwxrwx 1 root root 0 Jun 6 10:05 microcode -> ../../../devices/platform/microcode lrwxrwxrwx 1 root root 0 Jun 6 10:05 pcspkr -> ../../../devices/platform/pcspkr
lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250 -> ../../../devices/platform/serial8250 lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250.0 -> ../../../devices/platform/serial8250.0
/sys/bus/platform/drivers:
total 0
drwxr-xr-x 2 root root 0 Jun 6 10:05 i8042
drwxr-xr-x 2 root root 0 Jun 6 10:05 serial8250
/sys/bus/platform/drivers/i8042:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 i8042 ->
../../../../devices/platform/i8042
--w------- 1 root root 4096 Jun 6 10:57 unbindQuoted 8 lines
/sys/bus/platform/drivers/serial8250:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250 ->
../../../../devices/platform/serial8250
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250.0 ->
../../../../devices/platform/serial8250.0
--w------- 1 root root 4096 Jun 6 10:57 unbindOdd. No sign of sis5595 anywhere.
Quoted 10 lines
[ivo@localhost log]$ lsmod
Module Size Used by sis5595 14348 0 i2c_sis5595 10244 0 i2c_dev 9860 0 hwmon 6404 1 sis5595 ne2k_pci 12128 0 8390 11520 1 ne2k_pci
/sys/class/hwmonshouldn't be empty, should it?It shouldn't, but OTOH given that the sis5595 platform driver seemingly wasn't registered properly, I am not surprised.
My previous patch had some error paths which didn't display any error nor debug message. I guess that one of these error conditions occurred and this is why you don't see anything in the logs. So I attached a new version of the patch with messages on all the error paths. Please revert the previous patch and apply this one instead, leaving debugging enabled of course. Hopefully you'll have something in the log this time, and from there we'll see what needs to be fixed.
Quoted 4 lines
Thanks,
Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareQuoted 3 lines · Ivo Manca
I can't get _anything_ to enter my logs. Is there something required, besided enabling the hwmon debugging messages? I've tried to find more information about logging on the web, but couldn't find anything relevant.
Hmmm. Try unloading i2c-sis630 and i2c-sis5595 first, then reload sis5595?
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareHey Jean,
No idea what I did, but it works now?
I'll try to debug what actually happened. Must be something with the order the modules are loaded.
I will report back when I find more information
--
[root@localhost log]# cat kern
Jun 6 15:17:28 localhost kernel: klogd 1.4.1, log source = /proc/kmsg started. Jun 6 15:17:44 localhost kernel: device class 'hwmon': registering Jun 6 15:17:44 localhost kernel: bus pci: add driver sis5595 Jun 6 15:17:44 localhost kernel: pci: Matched Device 0000:00:01.0 with Driver s is5595 Jun 6 15:17:44 localhost kernel: pci: Probing driver sis5595 with device 0000:0 0:01.0 Jun 6 15:17:44 localhost kernel: bus platform: add driver sis5595 Jun 6 15:17:44 localhost kernel: Registering platform device 'sis5595.656'. Par ent at platform Jun 6 15:17:44 localhost kernel: DEV: registering device: ID = 'sis5595.656' Jun 6 15:17:44 localhost kernel: PM: Adding info for platform:sis5595.656 Jun 6 15:17:44 localhost kernel: bus platform: add device sis5595.656 Jun 6 15:17:44 localhost kernel: platform: Matched Device sis5595.656 with Driv er sis5595 Jun 6 15:17:44 localhost kernel: platform: Probing driver sis5595 with device s is5595.656 Jun 6 15:17:44 localhost kernel: CLASS: registering class device: ID = 'hwmon0' Jun 6 15:17:44 localhost kernel: class_uevent - name = hwmon0 Jun 6 15:17:44 localhost kernel: class_device_create_uevent called for hwmon0 Jun 6 15:17:44 localhost kernel: bound device 'sis5595.656' to driver 'sis5595' Jun 6 15:17:44 localhost kernel: platform: Bound Device sis5595.656 to
Driver s
is5595
[root@localhost log]# sensors
sis5595-isa-0290
Adapter: ISA adapter VCore 1: +2.96 V (min = +0.00 V, max = +0.00 V) ALARM VCore 2: +3.41 V (min = +0.00 V, max = +0.00 V) ALARM +3.3V: +2.74 V (min = +0.00 V, max = +0.00 V) ALARM +5V: +3.44 V (min = +0.00 V, max = +0.00 V) ALARM +12V: +13.80 V (min = +0.00 V, max = +0.00 V) ALARM fan1: 0 RPM (min = -1 RPM, div = 2) ALARM fan2: 0 RPM (min = -1 RPM, div = 2) ALARM
alarms: Board temperature input (usually LM75 chips) ALARM
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "Ivo Manca" <[email protected]>
Cc: "LM Sensors" <[email protected]>
Sent: Wednesday 6 June 2007 14:51
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 97 lines
Ivo,
Please don't forget the mailing list!
Quoted 4 lines · Ivo Manca
[root@localhost ~]# sensors -v
sensors version 2.10.1 with libsensors version 2.10.1I'll update it if you want.
No, that should be OK.
Quoted 10 lines
Quoted 4 lines
If you already have lm-sensors version >= 2.10.1, please compile with
CONFIG_HWMON_DEBUG_CHIP=yand look into your logs when loading the driver. Also check what you see under/sys/class/hwmon
and/sys/bus/platform.I already enabled
hwmon_debug_chip, however, nothing seems to get logged. It
should go somewhere to/var/log, shouldn't it? Only log file changing is my
messages, but that's just moaning about nmbd ;)If should show in the output of "dmesg" to start with, and indeed also in
/var/log/messagesand/or/var/log/debug.Quoted 38 lines
[ivo@localhost log]$ ls -l
/sys/class/hwmon/
total 0[ivo@localhost log]$ ls -lR
/sys/bus/platform//sys/bus/platform/:
total 0drwxr-xr-x 2 root root 0 Jun 6 10:05 devices drwxr-xr-x 4 root root 0 Jun 6 10:05 drivers -rw-r--r-- 1 root root 4096 Jun 6 10:56 drivers_autoprobe --w------- 1 root root 4096 Jun 6 10:56 drivers_probe
/sys/bus/platform/devices:
total 0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 floppy.0 -> ../../../devices/platform/floppy.0
lrwxrwxrwx 1 root root 0 Jun 6 10:05 i8042 -> ../../../devices/platform/i8042
lrwxrwxrwx 1 root root 0 Jun 6 10:05 microcode -> ../../../devices/platform/microcode lrwxrwxrwx 1 root root 0 Jun 6 10:05 pcspkr -> ../../../devices/platform/pcspkr
lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250 -> ../../../devices/platform/serial8250 lrwxrwxrwx 1 root root 0 Jun 6 10:05 serial8250.0 -> ../../../devices/platform/serial8250.0
/sys/bus/platform/drivers:
total 0
drwxr-xr-x 2 root root 0 Jun 6 10:05 i8042
drwxr-xr-x 2 root root 0 Jun 6 10:05 serial8250
/sys/bus/platform/drivers/i8042:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 i8042 ->
../../../../devices/platform/i8042
--w------- 1 root root 4096 Jun 6 10:57 unbindQuoted 8 lines
/sys/bus/platform/drivers/serial8250:
total 0
--w------- 1 root root 4096 Jun 6 10:57 bind
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250 ->
../../../../devices/platform/serial8250
lrwxrwxrwx 1 root root 0 Jun 6 10:57 serial8250.0 ->
../../../../devices/platform/serial8250.0
--w------- 1 root root 4096 Jun 6 10:57 unbindOdd. No sign of sis5595 anywhere.
Quoted 10 lines
[ivo@localhost log]$ lsmod
Module Size Used by sis5595 14348 0 i2c_sis5595 10244 0 i2c_dev 9860 0 hwmon 6404 1 sis5595 ne2k_pci 12128 0 8390 11520 1 ne2k_pci
/sys/class/hwmonshouldn't be empty, should it?It shouldn't, but OTOH given that the sis5595 platform driver seemingly wasn't registered properly, I am not surprised.
My previous patch had some error paths which didn't display any error nor debug message. I guess that one of these error conditions occurred and this is why you don't see anything in the logs. So I attached a new version of the patch with messages on all the error paths. Please revert the previous patch and apply this one instead, leaving debugging enabled of course. Hopefully you'll have something in the log this time, and from there we'll see what needs to be fixed.
Quoted 4 lines
Thanks,
Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareYeah, it seems like this was the problem.
Strange though, since it did work in my 2.6.19 kernel. Loading them in the way sensors-detect suggest (first i2c-sis5595, then sis5595), gives me the following output:
Jun 6 15:23:01 localhost kernel: i2c-dev: adapter [SMBus SIS5595 adapter at 0438] registered as minor 0 Jun 6 15:23:02 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x705, arg=0xbf886b54 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x5401, arg=0xbfa9e818 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: i2c ioctl, cmd: 0x5401, arg: 0xbfa9e818 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x705, arg=0x82ff3c0 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x703, arg=0x09 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x720, arg=0x82ff550 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: SMBus busy (0400). Resetting... Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: Failed! (400)
Then it repeats:
Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x703, arg=0x77 Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x720, arg=0x82ff550 Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: SMBus busy (0400). Resetting... Jun 6 15:23:08 localhost kernel: i2c-adapter i2c-0: Failed! (400)
Where it changes the 0x77 from 0x09 to 0x77
Bug or feature?
Ivo
----- Original Message -----
From: "Jean Delvare" <[email protected]>
To: "Ivo Manca" <[email protected]>
Cc: "LM Sensors" <[email protected]>
Sent: Wednesday 6 June 2007 17:43
Subject: Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform driver
Quoted 11 lines · Ivo Manca
Quoted 4 lines
I can't get _anything_ to enter my logs. Is there something required, besided enabling the hwmon debugging messages? I've tried to find more information about logging on the web, but couldn't find anything relevant.
Hmmm. Try unloading i2c-sis630 and i2c-sis5595 first, then reload sis5595?
Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareQuoted 5 lines · Ivo Manca
Hey Jean,
No idea what I did, but it works now?
I'll try to debug what actually happened. Must be something with the order the modules are loaded.
Most likely the problem or that least I had the same problem with my Intel SRSH4 motherboard.
Quoted 3 lines
I will report back when I find more information
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 1/2] hwmon/sis5595: Convert to a platform
In reply to Jean DelvareQuoted 2 lines · Ivo Manca
Yeah, it seems like this was the problem. Strange though, since it did work in my 2.6.19 kernel.
Depends on the order in which the modules are loaded, and a number of different things can change that. The good news is that my patch seems to work. Please try unloaded and reloading the sis5595 driver to make sure (without i2c-sis5595 nor i2c-sis630 loaded, of course.)
The conflict between sis5595 and i2c-sis5595/i2c-sis630 is of the same nature as the conflict between via686a/vt8231 and i2c-viapro. It _was_ solved for the VIA drivers (in 2.6.10), but seemingly not for the SiS drivers. I'm surprised nobody ever reported it, I guess SiS hardware is way less popular than VIA hardware. It's not too difficult to fix, I could give it a try if you want.
Quoted 30 lines
Loading them in the way sensors-detect suggest (first i2c-sis5595, then sis5595), gives me the following output:
Jun 6 15:23:01 localhost kernel: i2c-dev: adapter [SMBus SIS5595 adapter at 0438] registered as minor 0 Jun 6 15:23:02 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x705, arg=0xbf886b54 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x5401, arg=0xbfa9e818 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: i2c ioctl, cmd: 0x5401, arg: 0xbfa9e818 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x705, arg=0x82ff3c0 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x703, arg=0x09 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x720, arg=0x82ff550 Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: SMBus busy (0400). Resetting... Jun 6 15:23:03 localhost kernel: i2c-adapter i2c-0: Failed! (400)Then it repeats:
Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x703, arg=0x77 Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: ioctl, cmd=0x720, arg=0x82ff550 Jun 6 15:23:07 localhost kernel: i2c-adapter i2c-0: SMBus busy (0400). Resetting... Jun 6 15:23:08 localhost kernel: i2c-adapter i2c-0: Failed! (400)
Quoted 2 lines
Where it changes the
0x77from0x09to0x77
Bug or feature?
You see these messages only because you have CONFIG_I2C_DEBUG_BUS=y. I'm a bit surprised that the reset is said to have failed, but other than that, these messages are caused by failed probes, which sensors-detect and i2c-detect do a lot by design, so you can just ignore them.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors