diff options
Diffstat (limited to 'drivers/hwmon')
38 files changed, 1106 insertions, 223 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index db358cfa7cb..c5829591436 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -350,6 +350,18 @@ config SENSORS_VIA686A This driver can also be built as a module. If so, the module will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated sensors + in the VIA VT8231 device. + + This driver can also be built as a module. If so, the module + will be called vt8231. + config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index f7d6a2f61ee..06d4a1d1410 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o +obj-$(CONFIG_SENSORS_VT8231) += vt8231.o obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 8102876c7c3..665612729cb 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -126,10 +126,10 @@ static int read_only; /* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { - .owner = THIS_MODULE, - .name = "adm1021", + .driver = { + .name = "adm1021", + }, .id = I2C_DRIVERID_ADM1021, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1021_attach_adapter, .detach_client = adm1021_detach_client, }; diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 3ec12421694..9331c56d2ba 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -118,10 +118,10 @@ static struct adm1025_data *adm1025_update_device(struct device *dev); */ static struct i2c_driver adm1025_driver = { - .owner = THIS_MODULE, - .name = "adm1025", + .driver = { + .name = "adm1025", + }, .id = I2C_DRIVERID_ADM1025, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1025_attach_adapter, .detach_client = adm1025_detach_client, }; @@ -287,8 +287,6 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char struct adm1025_data *data = adm1025_update_device(dev); return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); } -/* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ -static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) @@ -444,8 +442,6 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp2_max); device_create_file(&new_client->dev, &dev_attr_alarms); - /* in1_ref is deprecated, remove after 2005-11-11 */ - device_create_file(&new_client->dev, &dev_attr_in1_ref); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); device_create_file(&new_client->dev, &dev_attr_vrm); diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index e0f56549d1d..fefe6e74fd0 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -308,9 +308,9 @@ static void adm1026_init_client(struct i2c_client *client); static struct i2c_driver adm1026_driver = { - .owner = THIS_MODULE, - .name = "adm1026", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "adm1026", + }, .attach_adapter = adm1026_attach_adapter, .detach_client = adm1026_detach_client, }; @@ -1227,8 +1227,6 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c struct adm1026_data *data = adm1026_update_device(dev); return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); } -/* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ -static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) @@ -1673,8 +1671,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); - /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ - device_create_file(&new_client->dev, &dev_attr_vid); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); device_create_file(&new_client->dev, &dev_attr_vrm); device_create_file(&new_client->dev, &dev_attr_alarms); diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 7c545d5eee4..d0639796608 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -105,9 +105,9 @@ static struct adm1031_data *adm1031_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver adm1031_driver = { - .owner = THIS_MODULE, - .name = "adm1031", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "adm1031", + }, .attach_adapter = adm1031_attach_adapter, .detach_client = adm1031_detach_client, }; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 11dc95f8a17..5ddc22fea4a 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -137,10 +137,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev); /* driver data */ static struct i2c_driver adm9240_driver = { - .owner = THIS_MODULE, - .name = "adm9240", + .driver = { + .name = "adm9240", + }, .id = I2C_DRIVERID_ADM9240, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm9240_attach_adapter, .detach_client = adm9240_detach_client, }; diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 52c469722a6..ae9de63cf2e 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -217,10 +217,10 @@ static struct asb100_data *asb100_update_device(struct device *dev); static void asb100_init_client(struct i2c_client *client); static struct i2c_driver asb100_driver = { - .owner = THIS_MODULE, - .name = "asb100", + .driver = { + .name = "asb100", + }, .id = I2C_DRIVERID_ASB100, - .flags = I2C_DF_NOTIFY, .attach_adapter = asb100_attach_adapter, .detach_client = asb100_detach_client, }; diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 53324f56404..b0c490073c8 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -50,9 +50,9 @@ static struct atxp1_data * atxp1_update_device(struct device *dev); static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); static struct i2c_driver atxp1_driver = { - .owner = THIS_MODULE, - .name = "atxp1", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "atxp1", + }, .attach_adapter = atxp1_attach_adapter, .detach_client = atxp1_detach_client, }; diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 34f71b7c7f3..203f9c7abb2 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -89,10 +89,10 @@ static struct ds1621_data *ds1621_update_client(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver ds1621_driver = { - .owner = THIS_MODULE, - .name = "ds1621", + .driver = { + .name = "ds1621", + }, .id = I2C_DRIVERID_DS1621, - .flags = I2C_DF_NOTIFY, .attach_adapter = ds1621_attach_adapter, .detach_client = ds1621_detach_client, }; diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index a02e1c34c75..25409181d1e 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -118,10 +118,10 @@ static int fscher_write_value(struct i2c_client *client, u8 reg, u8 value); */ static struct i2c_driver fscher_driver = { - .owner = THIS_MODULE, - .name = "fscher", + .driver = { + .name = "fscher", + }, .id = I2C_DRIVERID_FSCHER, - .flags = I2C_DF_NOTIFY, .attach_adapter = fscher_attach_adapter, .detach_client = fscher_detach_client, }; diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 64e4edc64f8..6d0146b5702 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -100,10 +100,10 @@ static void reset_fan_alarm(struct i2c_client *client, int nr); * Driver data (common to all clients) */ static struct i2c_driver fscpos_driver = { - .owner = THIS_MODULE, - .name = "fscpos", + .driver = { + .name = "fscpos", + }, .id = I2C_DRIVERID_FSCPOS, - .flags = I2C_DF_NOTIFY, .attach_adapter = fscpos_attach_adapter, .detach_client = fscpos_detach_client, }; diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 2f178dbe3d8..9e685e3a3bc 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -151,10 +151,10 @@ static struct gl518_data *gl518_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver gl518_driver = { - .owner = THIS_MODULE, - .name = "gl518sm", + .driver = { + .name = "gl518sm", + }, .id = I2C_DRIVERID_GL518, - .flags = I2C_DF_NOTIFY, .attach_adapter = gl518_attach_adapter, .detach_client = gl518_detach_client, }; diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index c39ba123942..baee60e44b5 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -109,10 +109,10 @@ static struct gl520_data *gl520_update_device(struct device *dev); /* Driver data */ static struct i2c_driver gl520_driver = { - .owner = THIS_MODULE, - .name = "gl520sm", + .driver = { + .name = "gl520sm", + }, .id = I2C_DRIVERID_GL520, - .flags = I2C_DF_NOTIFY, .attach_adapter = gl520_attach_adapter, .detach_client = gl520_detach_client, }; diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 312769ad4da..e497274916c 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -49,20 +49,22 @@ . . . . 11110 = 0.800 V 11111 = 0.000 V (off) + + The 17 specification is in fact Intel Mobile Voltage Positioning - + (IMVP-II). You can find more information in the datasheet of Max1718 + http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 + */ /* vrm is the VRM/VRD document version multiplied by 10. val is the 4-, 5- or 6-bit VID code. Returned value is in mV to avoid floating point in the kernel. */ -int vid_from_reg(int val, int vrm) +int vid_from_reg(int val, u8 vrm) { int vid; switch(vrm) { - case 0: - return 0; - case 100: /* VRD 10.0 */ if((val & 0x1f) == 0x1f) return 0; @@ -91,10 +93,16 @@ int vid_from_reg(int val, int vrm) case 84: /* VRM 8.4 */ val &= 0x0f; /* fall through */ - default: /* VRM 8.2 */ + case 82: /* VRM 8.2 */ return(val == 0x1f ? 0 : val & 0x10 ? 5100 - (val) * 100 : 2050 - (val) * 50); + case 17: /* Intel IMVP-II */ + return(val & 0x10 ? 975 - (val & 0xF) * 25 : + 1750 - val * 50); + default: /* report 0 for unknown */ + printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); + return 0; } } @@ -108,30 +116,36 @@ struct vrm_model { u8 vendor; u8 eff_family; u8 eff_model; - int vrm_type; + u8 eff_stepping; + u8 vrm_type; }; #define ANY 0xFF #ifdef CONFIG_X86 +/* the stepping parameter is highest acceptable stepping for current line */ + static struct vrm_model vrm_models[] = { - {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */ - {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */ - {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */ - {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */ - {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */ - {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */ - {X86_VENDOR_INTEL, 0xF, 0x0, 90}, /* P4 */ - {X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */ - {X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */ - {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ - {X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */ - {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ - {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ + {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ + {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ + {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ + {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ + {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ + {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ + {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ + {X86_VENDOR_INTEL, 0xF, 0x1, ANY, 90}, /* P4 Willamette */ + {X86_VENDOR_INTEL, 0xF, 0x2, ANY, 90}, /* P4 Northwood */ + {X86_VENDOR_INTEL, 0xF, ANY, ANY, 100}, /* Prescott and above assume VRD 10 */ + {X86_VENDOR_INTEL, 0x10, ANY, ANY, 0}, /* Itanium 2 */ + {X86_VENDOR_CENTAUR, 0x6, 0x7, ANY, 85}, /* Eden ESP/Ezra */ + {X86_VENDOR_CENTAUR, 0x6, 0x8, 0x7, 85}, /* Ezra T */ + {X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nemiah */ + {X86_VENDOR_CENTAUR, 0x6, 0x9, ANY, 17}, /* C3-M */ + {X86_VENDOR_UNKNOWN, ANY, ANY, ANY, 0} /* stop here */ }; -static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) +static u8 find_vrm(u8 eff_family, u8 eff_model, u8 eff_stepping, u8 vendor) { int i = 0; @@ -139,7 +153,8 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) if (vrm_models[i].vendor==vendor) if ((vrm_models[i].eff_family==eff_family) && ((vrm_models[i].eff_model==eff_model) || - (vrm_models[i].eff_model==ANY))) + (vrm_models[i].eff_model==ANY)) && + (eff_stepping <= vrm_models[i].eff_stepping)) return vrm_models[i].vrm_type; i++; } @@ -147,12 +162,11 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) return 0; } -int vid_which_vrm(void) +u8 vid_which_vrm(void) { struct cpuinfo_x86 *c = cpu_data; u32 eax; - u8 eff_family, eff_model; - int vrm_ret; + u8 eff_family, eff_model, eff_stepping, vrm_ret; if (c->x86 < 6) /* Any CPU with family lower than 6 */ return 0; /* doesn't have VID and/or CPUID */ @@ -160,20 +174,21 @@ int vid_which_vrm(void) eax = cpuid_eax(1); eff_family = ((eax & 0x00000F00)>>8); eff_model = ((eax & 0x000000F0)>>4); + eff_stepping = eax & 0xF; if (eff_family == 0xF) { /* use extended model & family */ eff_family += ((eax & 0x00F00000)>>20); eff_model += ((eax & 0x000F0000)>>16)<<4; } - vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor); + vrm_ret = find_vrm(eff_family, eff_model, eff_stepping, c->x86_vendor); if (vrm_ret == 0) printk(KERN_INFO "hwmon-vid: Unknown VRM version of your " "x86 CPU\n"); return vrm_ret; } -/* and now something completely different for the non-x86 world */ +/* and now for something completely different for the non-x86 world */ #else -int vid_which_vrm(void) +u8 vid_which_vrm(void) { printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n"); return 0; diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index a61f5d00f10..0da7c9c508c 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -213,7 +213,7 @@ struct it87_data { u8 sensor; /* Register value */ u8 fan_div[3]; /* Register encoding, shifted right */ u8 vid; /* Register encoding, combined */ - int vrm; + u8 vrm; u32 alarms; /* Register encoding, combined */ u8 fan_main_ctrl; /* Register value */ u8 manual_pwm_ctl[3]; /* manual PWM value set by user */ @@ -234,17 +234,18 @@ static void it87_init_client(struct i2c_client *client, struct it87_data *data); static struct i2c_driver it87_driver = { - .owner = THIS_MODULE, - .name = "it87", + .driver = { + .name = "it87", + }, .id = I2C_DRIVERID_IT87, - .flags = I2C_DF_NOTIFY, .attach_adapter = it87_attach_adapter, .detach_client = it87_detach_client, }; static struct i2c_driver it87_isa_driver = { - .owner = THIS_MODULE, - .name = "it87-isa", + .driver = { + .name = "it87-isa", + }, .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, }; @@ -668,7 +669,7 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) { struct it87_data *data = it87_update_device(dev); - return sprintf(buf, "%ld\n", (long) data->vrm); + return sprintf(buf, "%u\n", data->vrm); } static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -761,7 +762,8 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) - if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) + if (!request_region(address, IT87_EXTENT, + it87_isa_driver.driver.name)) goto ERROR0; /* For now, we presume we have a valid client. We create the diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 954ec249724..6b1aa7ef552 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -139,9 +139,9 @@ static void lm63_init_client(struct i2c_client *client); */ static struct i2c_driver lm63_driver = { - .owner = THIS_MODULE, - .name = "lm63", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "lm63", + }, .attach_adapter = lm63_attach_adapter, .detach_client = lm63_detach_client, }; diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index d70f4c8fc1e..74ca2c8c61c 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -66,10 +66,10 @@ static struct lm75_data *lm75_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { - .owner = THIS_MODULE, - .name = "lm75", + .driver = { + .name = "lm75", + }, .id = I2C_DRIVERID_LM75, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm75_attach_adapter, .detach_client = lm75_detach_client, }; diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 9380fda7dcd..a2f420d01fb 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -74,9 +74,9 @@ static struct lm77_data *lm77_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm77_driver = { - .owner = THIS_MODULE, - .name = "lm77", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "lm77", + }, .attach_adapter = lm77_attach_adapter, .detach_client = lm77_detach_client, }; diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 78cdd506439..e404001e20d 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -164,17 +164,18 @@ static void lm78_init_client(struct i2c_client *client); static struct i2c_driver lm78_driver = { - .owner = THIS_MODULE, - .name = "lm78", + .driver = { + .name = "lm78", + }, .id = I2C_DRIVERID_LM78, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm78_attach_adapter, .detach_client = lm78_detach_client, }; static struct i2c_driver lm78_isa_driver = { - .owner = THIS_MODULE, - .name = "lm78-isa", + .driver = { + .name = "lm78-isa", + }, .attach_adapter = lm78_isa_attach_adapter, .detach_client = lm78_detach_client, }; @@ -497,7 +498,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) if (!request_region(address, LM78_EXTENT, - lm78_isa_driver.name)) { + lm78_isa_driver.driver.name)) { err = -EBUSY; goto ERROR0; } diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index c359fdea211..c9a7cdea7bd 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -143,10 +143,10 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); */ static struct i2c_driver lm80_driver = { - .owner = THIS_MODULE, - .name = "lm80", + .driver = { + .name = "lm80", + }, .id = I2C_DRIVERID_LM80, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm80_attach_adapter, .detach_client = lm80_detach_client, }; diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 9a70611a9f6..26dfa9e216c 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -124,10 +124,10 @@ static struct lm83_data *lm83_update_device(struct device *dev); */ static struct i2c_driver lm83_driver = { - .owner = THIS_MODULE, - .name = "lm83", + .driver = { + .name = "lm83", + }, .id = I2C_DRIVERID_LM83, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm83_attach_adapter, .detach_client = lm83_detach_client, }; diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index d1070ed2bee..7389a012754 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -380,10 +380,10 @@ static void lm85_init_client(struct i2c_client *client); static struct i2c_driver lm85_driver = { - .owner = THIS_MODULE, - .name = "lm85", + .driver = { + .name = "lm85", + }, .id = I2C_DRIVERID_LM85, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm85_attach_adapter, .detach_client = lm85_detach_client, }; @@ -443,7 +443,17 @@ show_fan_offset(4); static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) { struct lm85_data *data = lm85_update_device(dev); - return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); + int vid; + + if (data->type == adt7463 && (data->vid & 0x80)) { + /* 6-pin VID (VRM 10) */ + vid = vid_from_reg(data->vid & 0x3f, data->vrm); + } else { + /* 5-pin VID (VRM 9) */ + vid = vid_from_reg(data->vid & 0x1f, data->vrm); + } + + return sprintf(buf, "%d\n", vid); } static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); @@ -1176,17 +1186,14 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); device_create_file(&new_client->dev, &dev_attr_in3_input); - device_create_file(&new_client->dev, &dev_attr_in4_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in2_min); device_create_file(&new_client->dev, &dev_attr_in3_min); - device_create_file(&new_client->dev, &dev_attr_in4_min); device_create_file(&new_client->dev, &dev_attr_in0_max); device_create_file(&new_client->dev, &dev_attr_in1_max); device_create_file(&new_client->dev, &dev_attr_in2_max); device_create_file(&new_client->dev, &dev_attr_in3_max); - device_create_file(&new_client->dev, &dev_attr_in4_max); device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp3_input); @@ -1224,6 +1231,15 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit); device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit); + /* The ADT7463 has an optional VRM 10 mode where pin 21 is used + as a sixth digital VID input rather than an analog input. */ + data->vid = lm85_read_value(new_client, LM85_REG_VID); + if (!(kind == adt7463 && (data->vid & 0x80))) { + device_create_file(&new_client->dev, &dev_attr_in4_input); + device_create_file(&new_client->dev, &dev_attr_in4_min); + device_create_file(&new_client->dev, &dev_attr_in4_max); + } + return 0; /* Error out and cleanup code */ @@ -1382,11 +1398,18 @@ static struct lm85_data *lm85_update_device(struct device *dev) irrelevant. So it is left in 4*/ data->adc_scale = (data->type == emc6d102 ) ? 16 : 4; - for (i = 0; i <= 4; ++i) { + data->vid = lm85_read_value(client, LM85_REG_VID); + + for (i = 0; i <= 3; ++i) { data->in[i] = lm85_read_value(client, LM85_REG_IN(i)); } + if (!(data->type == adt7463 && (data->vid & 0x80))) { + data->in[4] = lm85_read_value(client, + LM85_REG_IN(4)); + } + for (i = 0; i <= 3; ++i) { data->fan[i] = lm85_read_value(client, LM85_REG_FAN(i)); @@ -1450,13 +1473,20 @@ static struct lm85_data *lm85_update_device(struct device *dev) /* Things that don't change often */ dev_dbg(&client->dev, "Reading config values\n"); - for (i = 0; i <= 4; ++i) { + for (i = 0; i <= 3; ++i) { data->in_min[i] = lm85_read_value(client, LM85_REG_IN_MIN(i)); data->in_max[i] = lm85_read_value(client, LM85_REG_IN_MAX(i)); } + if (!(data->type == adt7463 && (data->vid & 0x80))) { + data->in_min[4] = lm85_read_value(client, + LM85_REG_IN_MIN(4)); + data->in_max[4] = lm85_read_value(client, + LM85_REG_IN_MAX(4)); + } + if ( data->type == emc6d100 ) { for (i = 5; i <= 7; ++i) { data->in_min[i] = @@ -1478,8 +1508,6 @@ static struct lm85_data *lm85_update_device(struct device *dev) lm85_read_value(client, LM85_REG_TEMP_MAX(i)); } - data->vid = lm85_read_value(client, LM85_REG_VID); - for (i = 0; i <= 2; ++i) { int val ; data->autofan[i].config = diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index eeec1817786..6ba34c302d8 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -161,10 +161,10 @@ static struct lm87_data *lm87_update_device(struct device *dev); */ static struct i2c_driver lm87_driver = { - .owner = THIS_MODULE, - .name = "lm87", + .driver = { + .name = "lm87", + }, .id = I2C_DRIVERID_LM87, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm87_attach_adapter, .detach_client = lm87_detach_client, }; diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 83cf2e1b09f..5679464447c 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -186,10 +186,10 @@ static struct lm90_data *lm90_update_device(struct device *dev); */ static struct i2c_driver lm90_driver = { - .owner = THIS_MODULE, - .name = "lm90", + .driver = { + .name = "lm90", + }, .id = I2C_DRIVERID_LM90, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm90_attach_adapter, .detach_client = lm90_detach_client, }; diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 7a4b3701ed1..b0c4cb730a7 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -410,10 +410,10 @@ static int lm92_detach_client(struct i2c_client *client) */ static struct i2c_driver lm92_driver = { - .owner = THIS_MODULE, - .name = "lm92", + .driver = { + .name = "lm92", + }, .id = I2C_DRIVERID_LM92, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm92_attach_adapter, .detach_client = lm92_detach_client, }; diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 69e7e125683..3abe330b22c 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -90,9 +90,9 @@ static struct max1619_data *max1619_update_device(struct device *dev); */ static struct i2c_driver max1619_driver = { - .owner = THIS_MODULE, - .name = "max1619", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "max1619", + }, .attach_adapter = max1619_attach_adapter, .detach_client = max1619_detach_client, }; diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 17f745a23d0..f161e88e3bb 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -236,8 +236,9 @@ static struct pc87360_data *pc87360_update_device(struct device *dev); */ static struct i2c_driver pc87360_driver = { - .owner = THIS_MODULE, - .name = "pc87360", + .driver = { + .name = "pc87360", + }, .attach_adapter = pc87360_detect, .detach_client = pc87360_detach_client, }; @@ -798,7 +799,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) for (i = 0; i < 3; i++) { if (((data->address[i] = extra_isa[i])) && !request_region(extra_isa[i], PC87360_EXTENT, - pc87360_driver.name)) { + pc87360_driver.driver.name)) { dev_err(&new_client->dev, "Region 0x%x-0x%x already " "in use!\n", extra_isa[i], extra_isa[i]+PC87360_EXTENT-1); diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 9c6cadec108..8be5189d9bd 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -198,8 +198,9 @@ static struct sis5595_data *sis5595_update_device(struct device *dev); static void sis5595_init_client(struct i2c_client *client); static struct i2c_driver sis5595_driver = { - .owner = THIS_MODULE, - .name = "sis5595", + .driver = { + .name = "sis5595", + }, .attach_adapter = sis5595_detect, .detach_client = sis5595_detach_client, }; @@ -484,7 +485,8 @@ static int sis5595_detect(struct i2c_adapter *adapter) if (force_addr) address = force_addr & ~(SIS5595_EXTENT - 1); /* Reserve the ISA region */ - if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) { + if (!request_region(address, SIS5595_EXTENT, + sis5595_driver.driver.name)) { err = -EBUSY; goto exit; } diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 2a3e21b5b6b..8663bbbe97f 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -226,8 +226,9 @@ static int smsc47b397_detach_client(struct i2c_client *client) static int smsc47b397_detect(struct i2c_adapter *adapter); static struct i2c_driver smsc47b397_driver = { - .owner = THIS_MODULE, - .name = "smsc47b397", + .driver = { + .name = "smsc47b397", + }, .attach_adapter = smsc47b397_detect, .detach_client = smsc47b397_detach_client, }; @@ -238,7 +239,8 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) struct smsc47b397_data *data; int err = 0; - if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) { + if (!request_region(address, SMSC_EXTENT, + smsc47b397_driver.driver.name)) { dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); return -EBUSY; diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 5905c1af88f..d1e3ec0fe4d 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -126,8 +126,9 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static struct i2c_driver smsc47m1_driver = { - .owner = THIS_MODULE, - .name = "smsc47m1", + .driver = { + .name = "smsc47m1", + }, .attach_adapter = smsc47m1_detect, .detach_client = smsc47m1_detach_client, }; @@ -394,7 +395,7 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) int err = 0; int fan1, fan2, pwm1, pwm2; - if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { + if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.driver.name)) { dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); return -EBUSY; } diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 6f696f89717..cb01848729b 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -572,8 +572,9 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); /* The driver. I choose to use type i2c_driver, as at is identical to both smbus_driver and isa_driver, and clients could be of either kind */ static struct i2c_driver via686a_driver = { - .owner = THIS_MODULE, - .name = "via686a", + .driver = { + .name = "via686a", + }, .attach_adapter = via686a_detect, .detach_client = via686a_detach_client, }; @@ -615,7 +616,8 @@ static int via686a_detect(struct i2c_adapter *adapter) } /* Reserve the ISA region */ - if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { + if (!request_region(address, VIA686A_EXTENT, + via686a_driver.driver.name)) { dev_err(&adapter->dev, "region 0x%x already in use!\n", address); return -ENODEV; diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c new file mode 100644 index 00000000000..d00a726d023 --- /dev/null +++ b/drivers/hwmon/vt8231.c @@ -0,0 +1,862 @@ +/* + vt8231.c - Part of lm_sensors, Linux kernel modules + for hardware monitoring + + Copyright (c) 2005 Roger Lucas <roger@planbit.co.uk> + Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> + Aaron M. Marsh <amarsh@sdf.lonestar.org> + + 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. +*/ + +/* Supports VIA VT8231 South Bridge embedded sensors +*/ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/pci.h> +#include <linux/jiffies.h> +#include <linux/i2c.h> +#include <linux/i2c-isa.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/hwmon-vid.h> +#include <linux/err.h> +#include <asm/io.h> + +static int force_addr; +module_param(force_addr, int, 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 isa_address; + +#define VT8231_EXTENT 0x80 +#define VT8231_BASE_REG 0x70 +#define VT8231_ENABLE_REG 0x74 + +/* The VT8231 registers + + The reset value for the input channel configuration is used (Reg 0x4A=0x07) + which sets the selected inputs marked with '*' below if multiple options are + possible: + + Voltage Mode Temperature Mode + Sensor Linux Id Linux Id VIA Id + -------- -------- -------- ------ + CPU Diode N/A temp1 0 + UIC1 in0 temp2 * 1 + UIC2 in1 * temp3 2 + UIC3 in2 * temp4 3 + UIC4 in3 * temp5 4 + UIC5 in4 * temp6 5 + 3.3V in5 N/A + + Note that the BIOS may set the configuration register to a different value + to match the motherboard configuration. +*/ + +/* fans numbered 0-1 */ +#define VT8231_REG_FAN_MIN(nr) (0x3b + (nr)) +#define VT8231_REG_FAN(nr) (0x29 + (nr)) + +/* Voltage inputs numbered 0-5 */ + +static const u8 regvolt[] = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 }; +static const u8 regvoltmax[] = { 0x3d, 0x2b, 0x2d, 0x2f, 0x31, 0x33 }; +static const u8 regvoltmin[] = { 0x3e, 0x2c, 0x2e, 0x30, 0x32, 0x34 }; + +/* Temperatures are numbered 1-6 according to the Linux kernel specification. +** +** In the VIA datasheet, however, the temperatures are numbered from zero. +** Since it is important that this driver can easily be compared to the VIA +** datasheet, we will use the VIA numbering within this driver and map the +** kernel sysfs device name to the VIA number in the sysfs callback. +*/ + +#define VT8231_REG_TEMP_LOW01 0x49 +#define VT8231_REG_TEMP_LOW25 0x4d + +static const u8 regtemp[] = { 0x1f, 0x21, 0x22, 0x23, 0x24, 0x25 }; +static const u8 regtempmax[] = { 0x39, 0x3d, 0x2b, 0x2d, 0x2f, 0x31 }; +static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 }; + +#define TEMP_FROM_REG(reg) (((253 * 4 - (reg)) * 550 + 105) / 210) +#define TEMP_MAXMIN_FROM_REG(reg) (((253 - (reg)) * 2200 + 105) / 210) +#define TEMP_MAXMIN_TO_REG(val) (253 - ((val) * 210 + 1100) / 2200) + +#define VT8231_REG_CONFIG 0x40 +#define VT8231_REG_ALARM1 0x41 +#define VT8231_REG_ALARM2 0x42 +#define VT8231_REG_FANDIV 0x47 +#define VT8231_REG_UCH_CONFIG 0x4a +#define VT8231_REG_TEMP1_CONFIG 0x4b +#define VT8231_REG_TEMP2_CONFIG 0x4c + +/* temps 0-5 as numbered in VIA datasheet - see later for mapping to Linux +** numbering +*/ +#define ISTEMP(i, ch_config) ((i) == 0 ? 1 : \ + ((ch_config) >> ((i)+1)) & 0x01) +/* voltages 0-5 */ +#define ISVOLT(i, ch_config) ((i) == 5 ? 1 : \ + !(((ch_config) >> ((i)+2)) & 0x01)) + +#define DIV_FROM_REG(val) (1 << (val)) + +/* NB The values returned here are NOT temperatures. The calibration curves +** for the thermistor curves are board-specific and must go in the +** sensors.conf file. Temperature sensors are actually ten bits, but the +** VIA datasheet only considers the 8 MSBs obtained from the regtemp[] +** register. The temperature value returned should have a magnitude of 3, +** so we use the VIA scaling as the "true" scaling and use the remaining 2 +** LSBs as fractional precision. +** +** All the on-chip hardware temperature comparisons for the alarms are only +** 8-bits wide, and compare against the 8 MSBs of the temperature. The bits +** in the registers VT8231_REG_TEMP_LOW01 and VT8231_REG_TEMP_LOW25 are +** ignored. +*/ + +/******** FAN RPM CONVERSIONS ******** +** This chip saturates back at 0, not at 255 like many the other chips. +** So, 0 means 0 RPM +*/ +static inline u8 FAN_TO_REG(long rpm, int div) +{ + if (rpm == 0) + return 0; + return SENSORS_LIMIT(1310720 / (rpm * div), 1, 255); +} + +#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : 1310720 / ((val) * (div))) + +struct vt8231_data { + struct i2c_client client; + struct semaphore update_lock; + struct class_device *class_dev; + char valid; /* !=0 if following fields are valid */ + unsigned long last_updated; /* In jiffies */ + + u8 in[6]; /* Register value */ + u8 in_max[6]; /* Register value */ + u8 in_min[6]; /* Register value */ + u16 temp[6]; /* Register value 10 bit, right aligned */ + u8 temp_max[6]; /* Register value */ + u8 temp_min[6]; /* Register value */ + u8 fan[2]; /* Register value */ + u8 fan_min[2]; /* Register value */ + u8 fan_div[2]; /* Register encoding, shifted right */ + u16 alarms; /* Register encoding */ + u8 uch_config; +}; + +static struct pci_dev *s_bridge; +static int vt8231_detect(struct i2c_adapter *adapter); +static int vt8231_detach_client(struct i2c_client *client); +static struct vt8231_data *vt8231_update_device(struct device *dev); +static void vt8231_init_client(struct i2c_client *client); + +static inline int vt8231_read_value(struct i2c_client *client, u8 reg) +{ + return inb_p(client->addr + reg); +} + +static inline void vt8231_write_value(struct i2c_client *client, u8 reg, + u8 value) +{ + outb_p(value, client->addr + reg); +} + +/* following are the sysfs callback functions */ +static ssize_t show_in(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", ((data->in[nr] - 3) * 10000) / 958); +} + +static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", ((data->in_min[nr] - 3) * 10000) / 958); +} + +static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", (((data->in_max[nr] - 3) * 10000) / 958)); +} + +static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); + vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); + up(&data->update_lock); + return count; +} + +static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); + vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); + up(&data->update_lock); + return count; +} + +/* Special case for input 5 as this has 3.3V scaling built into the chip */ +static ssize_t show_in5(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t show_in5_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in_min[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t show_in5_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in_max[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, + 0, 255); + vt8231_write_value(client, regvoltmin[5], data->in_min[5]); + up(&data->update_lock); + return count; +} + +static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, + 0, 255); + vt8231_write_value(client, regvoltmax[5], data->in_max[5]); + up(&data->update_lock); + return count; +} + +#define define_voltage_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ + show_in, NULL, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ + show_in_min, set_in_min, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ + show_in_max, set_in_max, offset) + +define_voltage_sysfs(0); +define_voltage_sysfs(1); +define_voltage_sysfs(2); +define_voltage_sysfs(3); +define_voltage_sysfs(4); + +static DEVICE_ATTR(in5_input, S_IRUGO, show_in5, NULL); +static DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR, show_in5_min, set_in5_min); +static DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR, show_in5_max, set_in5_max); + +/* Temperatures */ +static ssize_t show_temp0(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp[0] * 250); +} + +static ssize_t show_temp0_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp_max[0] * 1000); +} + +static ssize_t show_temp0_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp_min[0] * 1000); +} + +static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); + vt8231_write_value(client, regtempmax[0], data->temp_max[0]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); + vt8231_write_value(client, regtempmin[0], data->temp_min[0]); + up(&data->update_lock); + return count; +} + +static ssize_t show_temp(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); +} + +static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_max[nr])); +} + +static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_min[nr])); +} + +static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); + vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); + vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); + up(&data->update_lock); + return count; +} + +/* Note that these map the Linux temperature sensor numbering (1-6) to the VIA +** temperature sensor numbering (0-5) +*/ +#define define_temperature_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ + show_temp, NULL, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ + show_temp_max, set_temp_max, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ + show_temp_min, set_temp_min, offset - 1) + +static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL); +static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max); +static DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min); + +define_temperature_sysfs(2); +define_temperature_sysfs(3); +define_temperature_sysfs(4); +define_temperature_sysfs(5); +define_temperature_sysfs(6); + +#define CFG_INFO_TEMP(id) { &sensor_dev_attr_temp##id##_input.dev_attr, \ + &sensor_dev_attr_temp##id##_min.dev_attr, \ + &sensor_dev_attr_temp##id##_max.dev_attr } +#define CFG_INFO_VOLT(id) { &sensor_dev_attr_in##id##_input.dev_attr, \ + &sensor_dev_attr_in##id##_min.dev_attr, \ + &sensor_dev_attr_in##id##_max.dev_attr } + +struct str_device_attr_table { + struct device_attribute *input; + struct device_attribute *min; + struct device_attribute *max; +}; + +static struct str_device_attr_table cfg_info_temp[] = { + { &dev_attr_temp1_input, &dev_attr_temp1_min, &dev_attr_temp1_max }, + CFG_INFO_TEMP(2), + CFG_INFO_TEMP(3), + CFG_INFO_TEMP(4), + CFG_INFO_TEMP(5), + CFG_INFO_TEMP(6) +}; + +static struct str_device_attr_table cfg_info_volt[] = { + CFG_INFO_VOLT(0), + CFG_INFO_VOLT(1), + CFG_INFO_VOLT(2), + CFG_INFO_VOLT(3), + CFG_INFO_VOLT(4), + { &dev_attr_in5_input, &dev_attr_in5_min, &dev_attr_in5_max } +}; + +/* Fans */ +static ssize_t show_fan(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], + DIV_FROM_REG(data->fan_div[nr]))); +} + +static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], + DIV_FROM_REG(data->fan_div[nr]))); +} + +static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); +} + +static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); + vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); + up(&data->update_lock); + return count; +} + +static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + unsigned long val = simple_strtoul(buf, NULL, 10); + int nr = sensor_attr->index; + int old = vt8231_read_value(client, VT8231_REG_FANDIV); + long min = FAN_FROM_REG(data->fan_min[nr], + DIV_FROM_REG(data->fan_div[nr])); + + down(&data->update_lock); + switch (val) { + case 1: data->fan_div[nr] = 0; break; + case 2: data->fan_div[nr] = 1; break; + case 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 supported." + "Choose one of 1, 2, 4 or 8!\n", val); + up(&data->update_lock); + return -EINVAL; + } + + /* Correct the fan minimum speed */ + data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); + vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); + + old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); + vt8231_write_value(client, VT8231_REG_FANDIV, old); + up(&data->update_lock); + return count; +} + + +#define define_fan_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ + show_fan, NULL, offset - 1); \ +static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ + show_fan_div, set_fan_div, offset - 1); \ +static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ + show_fan_min, set_fan_min, offset - 1) + +define_fan_sysfs(1); +define_fan_sysfs(2); + +/* Alarms */ +static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->alarms); +} + +static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); + +static struct i2c_driver vt8231_driver = { + .driver = { + .name = "vt8231", + }, + .attach_adapter = vt8231_detect, + .detach_client = vt8231_detach_client, +}; + +static struct pci_device_id vt8231_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, vt8231_pci_ids); + +static int __devinit vt8231_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id); + +static struct pci_driver vt8231_pci_driver = { + .name = "vt8231", + .id_table = vt8231_pci_ids, + .probe = vt8231_pci_probe, +}; + +int vt8231_detect(struct i2c_adapter *adapter) +{ + struct i2c_client *client; + struct vt8231_data *data; + int err = 0, i; + u16 val; + + /* 8231 requires multiple of 256 */ + if (force_addr) { + isa_address = force_addr & 0xFF00; + dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", + isa_address); + if (PCIBIOS_SUCCESSFUL != pci_write_config_word(s_bridge, + VT8231_BASE_REG, isa_address)) + return -ENODEV; + } + + if (PCIBIOS_SUCCESSFUL != + pci_read_config_word(s_bridge, VT8231_ENABLE_REG, &val)) + return -ENODEV; + + if (!(val & 0x0001)) { + dev_warn(&adapter->dev, "enabling sensors\n"); + if (PCIBIOS_SUCCESSFUL != + pci_write_config_word(s_bridge, VT8231_ENABLE_REG, + val | 0x0001)) + return -ENODEV; + } + + /* Reserve the ISA region */ + if (!request_region(isa_address, VT8231_EXTENT, + vt8231_pci_driver.name)) { + dev_err(&adapter->dev, "region 0x%x already in use!\n", + isa_address); + return -ENODEV; + } + + if (!(data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL))) { + err = -ENOMEM; + goto exit_release; + } + + client = &data->client; + i2c_set_clientdata(client, data); + client->addr = isa_address; + client->adapter = adapter; + client->driver = &vt8231_driver; + client->dev.parent = &adapter->dev; + + /* Fill in the remaining client fields and put into the global list */ + strlcpy(client->name, "vt8231", I2C_NAME_SIZE); + + init_MUTEX(&data->update_lock); + + /* Tell the I2C layer a new client has arrived */ + if ((err = i2c_attach_client(client))) + goto exit_free; + + vt8231_init_client(client); + + /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + + /* Must update device information to find out the config field */ + data->uch_config = vt8231_read_value(client, VT8231_REG_UCH_CONFIG); + + for (i = 0; i < ARRAY_SIZE(cfg_info_temp); i++) { + if (ISTEMP(i, data->uch_config)) { + device_create_file(&client->dev, + cfg_info_temp[i].input); + device_create_file(&client->dev, cfg_info_temp[i].max); + device_create_file(&client->dev, cfg_info_temp[i].min); + } + } + + for (i = 0; i < ARRAY_SIZE(cfg_info_volt); i++) { + if (ISVOLT(i, data->uch_config)) { + device_create_file(&client->dev, + cfg_info_volt[i].input); + device_create_file(&client->dev, cfg_info_volt[i].max); + device_create_file(&client->dev, cfg_info_volt[i].min); + } + } + + device_create_file(&client->dev, &sensor_dev_attr_fan1_input.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_input.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan1_min.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_min.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan1_div.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_div.dev_attr); + + device_create_file(&client->dev, &dev_attr_alarms); + return 0; + +exit_detach: + i2c_detach_client(client); +exit_free: + kfree(data); +exit_release: + release_region(isa_address, VT8231_EXTENT); + return err; +} + +static int vt8231_detach_client(struct i2c_client *client) +{ + struct vt8231_data *data = i2c_get_clientdata(client); + int err; + + hwmon_device_unregister(data->class_dev); + + if ((err = i2c_detach_client(client))) { + return err; + } + + release_region(client->addr, VT8231_EXTENT); + kfree(data); + + return 0; +} + +static void vt8231_init_client(struct i2c_client *client) +{ + vt8231_write_value(client, VT8231_REG_TEMP1_CONFIG, 0); + vt8231_write_value(client, VT8231_REG_TEMP2_CONFIG, 0); +} + +static struct vt8231_data *vt8231_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int i; + u16 low; + + down(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + for (i = 0; i < 6; i++) { + if (ISVOLT(i, data->uch_config)) { + data->in[i] = vt8231_read_value(client, + regvolt[i]); + data->in_min[i] = vt8231_read_value(client, + regvoltmin[i]); + data->in_max[i] = vt8231_read_value(client, + regvoltmax[i]); + } + } + for (i = 0; i < 2; i++) { + data->fan[i] = vt8231_read_value(client, + VT8231_REG_FAN(i)); + data->fan_min[i] = vt8231_read_value(client, + VT8231_REG_FAN_MIN(i)); + } + + low = vt8231_read_value(client, VT8231_REG_TEMP_LOW01); + low = (low >> 6) | ((low & 0x30) >> 2) + | (vt8231_read_value(client, VT8231_REG_TEMP_LOW25) << 4); + for (i = 0; i < 6; i++) { + if (ISTEMP(i, data->uch_config)) { + data->temp[i] = (vt8231_read_value(client, + regtemp[i]) << 2) + | ((low >> (2 * i)) & 0x03); + data->temp_max[i] = vt8231_read_value(client, + regtempmax[i]); + data->temp_min[i] = vt8231_read_value(client, + regtempmin[i]); + } + } + + i = vt8231_read_value(client, VT8231_REG_FANDIV); + data->fan_div[0] = (i >> 4) & 0x03; + data->fan_div[1] = i >> 6; + data->alarms = vt8231_read_value(client, VT8231_REG_ALARM1) | + (vt8231_read_value(client, VT8231_REG_ALARM2) << 8); + + /* Set alarm flags correctly */ + if (!data->fan[0] && data->fan_min[0]) { + data->alarms |= 0x40; + } else if (data->fan[0] && !data->fan_min[0]) { + data->alarms &= ~0x40; + } + + if (!data->fan[1] && data->fan_min[1]) { + data->alarms |= 0x80; + } else if (data->fan[1] && !data->fan_min[1]) { + data->alarms &= ~0x80; + } + + data->last_updated = jiffies; + data->valid = 1; + } + + up(&data->update_lock); + + return data; +} + +static int __devinit vt8231_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + u16 val; + + if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_BASE_REG, + &val)) + return -ENODEV; + + isa_address = val & ~(VT8231_EXTENT - 1); + if (isa_address == 0 && force_addr == 0) { + dev_err(&dev->dev, "base address not set -\ + upgrade BIOS or use force_addr=0xaddr\n"); + return -ENODEV; + } + + s_bridge = pci_dev_get(dev); + + if (i2c_isa_add_driver(&vt8231_driver)) { + pci_dev_put(s_bridge); + s_bridge = NULL; + } + + /* 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; +} + +static int __init sm_vt8231_init(void) +{ + return pci_module_init(&vt8231_pci_driver); +} + +static void __exit sm_vt8231_exit(void) +{ + pci_unregister_driver(&vt8231_pci_driver); + if (s_bridge != NULL) { + i2c_isa_del_driver(&vt8231_driver); + pci_dev_put(s_bridge); + s_bridge = NULL; + } +} + +MODULE_AUTHOR("Roger Lucas <roger@planbit.co.uk>"); +MODULE_DESCRIPTION("VT8231 sensors"); +MODULE_LICENSE("GPL"); + +module_init(sm_vt8231_init); +module_exit(sm_vt8231_exit); diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index eee22a57e92..12d79f5e490 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -676,7 +676,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) int i, err = 0; if (!request_region(address + REGION_OFFSET, REGION_LENGTH, - w83627ehf_driver.name)) { + w83627ehf_driver.driver.name)) { err = -EBUSY; goto exit; } @@ -785,8 +785,9 @@ static int w83627ehf_detach_client(struct i2c_client *client) } static struct i2c_driver w83627ehf_driver = { - .owner = THIS_MODULE, - .name = "w83627ehf", + .driver = { + .name = "w83627ehf", + }, .attach_adapter = w83627ehf_detect, .detach_client = w83627ehf_detach_client, }; diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bbb3dcde146..7ea441d4da6 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -332,8 +332,9 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev); static void w83627hf_init_client(struct i2c_client *client); static struct i2c_driver w83627hf_driver = { - .owner = THIS_MODULE, - .name = "w83627hf", + .driver = { + .name = "w83627hf", + }, .attach_adapter = w83627hf_detect, .detach_client = w83627hf_detach_client, }; @@ -1009,7 +1010,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) address = force_addr & WINB_ALIGNMENT; if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, - w83627hf_driver.name)) { + w83627hf_driver.driver.name)) { err = -EBUSY; goto ERROR0; } @@ -1122,11 +1123,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) if (kind != w83697hf) device_create_file_temp(new_client, 3); - if (kind != w83697hf) + if (kind != w83697hf && data->vid != 0xff) { device_create_file_vid(new_client); - - if (kind != w83697hf) device_create_file_vrm(new_client); + } device_create_file_fan_div(new_client, 1); device_create_file_fan_div(new_client, 2); @@ -1232,7 +1232,7 @@ static int w83627thf_read_gpio5(struct i2c_client *client) /* Make sure the pins are configured for input There must be at least five (VRM 9), and possibly 6 (VRM 10) */ - sel = superio_inb(W83627THF_GPIO5_IOSR); + sel = superio_inb(W83627THF_GPIO5_IOSR) & 0x3f; if ((sel & 0x1f) != 0x1f) { dev_dbg(&client->dev, "GPIO5 not configured for VID " "function\n"); @@ -1323,19 +1323,18 @@ static void w83627hf_init_client(struct i2c_client *client) int hi = w83627hf_read_value(client, W83781D_REG_CHIPID); data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); } else if (w83627thf == data->type) { - data->vid = w83627thf_read_gpio5(client) & 0x3f; + data->vid = w83627thf_read_gpio5(client); } /* Read VRM & OVT Config only once */ if (w83627thf == data->type || w83637hf == data->type) { data->vrm_ovt = w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); - data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82; - } else { - /* Convert VID to voltage based on default VRM */ - data->vrm = vid_which_vrm(); } + /* Convert VID to voltage based on VRM */ + data->vrm = vid_which_vrm(); + tmp = w83627hf_read_value(client, W83781D_REG_SCFG1); for (i = 1; i <= 3; i++) { if (!(tmp & BIT_SCFG1[i - 1])) { diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index ffdb3a03e2b..557114872f3 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -269,17 +269,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev); static void w83781d_init_client(struct i2c_client *client); static struct i2c_driver w83781d_driver = { - .owner = THIS_MODULE, - .name = "w83781d", + .driver = { + .name = "w83781d", + }, .id = I2C_DRIVERID_W83781D, - .flags = I2C_DF_NOTIFY, .attach_adapter = w83781d_attach_adapter, .detach_client = w83781d_detach_client, }; static struct i2c_driver w83781d_isa_driver = { - .owner = THIS_MODULE, - .name = "w83781d-isa", + .driver = { + .name = "w83781d-isa", + }, .attach_adapter = w83781d_isa_attach_adapter, .detach_client = w83781d_detach_client, }; @@ -1012,7 +1013,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) if (is_isa) if (!request_region(address, W83781D_EXTENT, - w83781d_isa_driver.name)) { + w83781d_isa_driver.driver.name)) { dev_dbg(&adapter->dev, "Request of region " "0x%x-0x%x for w83781d failed\n", address, address + W83781D_EXTENT - 1); diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 1ba07263036..b176bf0c4c7 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -269,7 +269,6 @@ DIV_TO_REG(long val) struct w83792d_data { struct i2c_client client; struct class_device *class_dev; - struct semaphore lock; enum chips type; struct semaphore update_lock; @@ -282,7 +281,7 @@ struct w83792d_data { u8 in[9]; /* Register value */ u8 in_max[9]; /* Register value */ u8 in_min[9]; /* Register value */ - u8 low_bits[2]; /* Additional resolution to voltage in0-6 */ + u16 low_bits; /* Additional resolution to voltage in6-0 */ u8 fan[7]; /* Register value */ u8 fan_min[7]; /* Register value */ u8 temp1[3]; /* current, over, thyst */ @@ -317,45 +316,17 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev); static void w83792d_init_client(struct i2c_client *client); static struct i2c_driver w83792d_driver = { - .owner = THIS_MODULE, - .name = "w83792d", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "w83792d", + }, .attach_adapter = w83792d_attach_adapter, .detach_client = w83792d_detach_client, }; -static long in_count_from_reg(int nr, struct w83792d_data *data) +static inline long in_count_from_reg(int nr, struct w83792d_data *data) { - u16 vol_count = data->in[nr]; - u16 low_bits = 0; - vol_count = (vol_count << 2); - switch (nr) - { - case 0: /* vin0 */ - low_bits = (data->low_bits[0]) & 0x03; - break; - case 1: /* vin1 */ - low_bits = ((data->low_bits[0]) & 0x0c) >> 2; - break; - case 2: /* vin2 */ - low_bits = ((data->low_bits[0]) & 0x30) >> 4; - break; - case 3: /* vin3 */ - low_bits = ((data->low_bits[0]) & 0xc0) >> 6; - break; - case 4: /* vin4 */ - low_bits = (data->low_bits[1]) & 0x03; - break; - case 5: /* vin5 */ - low_bits = ((data->low_bits[1]) & 0x0c) >> 2; - break; - case 6: /* vin6 */ - low_bits = ((data->low_bits[1]) & 0x30) >> 4; - default: - break; - } - vol_count = vol_count | low_bits; - return vol_count; + /* in7 and in8 do not have low bits, but the formula still works */ + return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03)); } /* following are the sysfs callback functions */ @@ -1192,7 +1163,6 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) new_client = &data->client; i2c_set_clientdata(new_client, data); new_client->addr = address; - init_MUTEX(&data->lock); new_client->adapter = adapter; new_client->driver = &w83792d_driver; new_client->flags = 0; @@ -1243,7 +1213,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) goto ERROR1; } val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); - if (val1 == 0x7a && address >= 0x2c) { + if (val1 == 0x7a) { kind = w83792d; } else { if (kind == 0) @@ -1416,26 +1386,17 @@ w83792d_detach_client(struct i2c_client *client) return 0; } -/* The SMBus locks itself, usually, but nothing may access the Winbond between - bank switches. ISA access must always be locked explicitly! - We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks, - would slow down the W83792D access and should not be necessary. - There are some ugly typecasts here, but the good news is - they should - nowhere else be necessary! */ -static int -w83792d_read_value(struct i2c_client *client, u8 reg) +/* The SMBus locks itself. The Winbond W83792D chip has a bank register, + but the driver only accesses registers in bank 0, so we don't have + to switch banks and lock access between switches. */ +static int w83792d_read_value(struct i2c_client *client, u8 reg) { - int res=0; - res = i2c_smbus_read_byte_data(client, reg); - - return res; + return i2c_smbus_read_byte_data(client, reg); } -static int -w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) +static int w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) { - i2c_smbus_write_byte_data(client, reg, value); - return 0; + return i2c_smbus_write_byte_data(client, reg, value); } static void @@ -1492,10 +1453,10 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) data->in_min[i] = w83792d_read_value(client, W83792D_REG_IN_MIN[i]); } - data->low_bits[0] = w83792d_read_value(client, - W83792D_REG_LOW_BITS1); - data->low_bits[1] = w83792d_read_value(client, - W83792D_REG_LOW_BITS2); + data->low_bits = w83792d_read_value(client, + W83792D_REG_LOW_BITS1) + + (w83792d_read_value(client, + W83792D_REG_LOW_BITS2) << 8); for (i = 0; i < 7; i++) { /* Update the Fan measured value and limits */ data->fan[i] = w83792d_read_value(client, @@ -1506,7 +1467,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) pwm_array_tmp[i] = w83792d_read_value(client, W83792D_REG_PWM[i]); data->pwm[i] = pwm_array_tmp[i] & 0x0f; - data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01; + data->pwm_mode[i] = pwm_array_tmp[i] >> 7; } reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); @@ -1607,8 +1568,8 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); } - dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); - dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); + dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff); + dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8); dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); for (i=0; i<7; i++) { dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index f495b637866..f66c0cfdeda 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -92,10 +92,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev); */ static struct i2c_driver w83l785ts_driver = { - .owner = THIS_MODULE, - .name = "w83l785ts", + .driver = { + .name = "w83l785ts", + }, .id = I2C_DRIVERID_W83L785TS, - .flags = I2C_DF_NOTIFY, .attach_adapter = w83l785ts_attach_adapter, .detach_client = w83l785ts_detach_client, }; |