Commit ddcf6600 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
 - new driver to support GMT G762/G763 pwm fan controllers
 - add support for DS1631, DS1721, and DS1731 to ds1621 driver
 - remove detect function from ds1621 driver as unreliable
 - bug fixes in nct6775, iio_hwmon, and adm1021 drivers
 - remove redundant platform_set_drvdata in various drivers
 - add device tree support to ina2xx driver

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (ds1621) Fix temperature rounding operations
  hwmon: (nct6775) Drop unsupported fan alarm attributes for NCT6775
  hwmon: (nct6775) Fix temperature alarm attributes
  Add support for GMT G762/G763 PWM fan controllers
  hwmon: (ina2xx) Add device tree support to pass the shunt resistor
  hwmon: (ds1621) Update documentation
  hwmon: (ds1621) Add DS1731 chip support to ds1621 driver
  hwmon: (iio_hwmon) add alias table
  hwmon: (adm1021) Do not create min sysfs attributes for LM84
  hwmon: (ds1621) Remove detect function
  hwmon: (ds1621) Add ds1631 chip support to ds1621 driver and documentation
  hwmon: (ds1621) Add ds1721 update interval sysfs attribute
  hwmon: (ds1621) Add ds1721 chip support
  hwmon: (w83627ehf) Remove redundant platform_set_drvdata()
  hwmon: (ntc_thermistor) Remove redundant platform_set_drvdata()
  hwmon: (i5k_amb) Remove redundant platform_set_drvdata()
  hwmon: (coretemp) Remove redundant platform_set_drvdata()
  hwmon: (abituguru3) Remove redundant platform_set_drvdata()
parents c16bfeb2 a50d9a4d
GMT G762/G763 PWM Fan controller
Required node properties:
- "compatible": must be either "gmt,g762" or "gmt,g763"
- "reg": I2C bus address of the device
- "clocks": a fixed clock providing input clock frequency
on CLK pin of the chip.
Optional properties:
- "fan_startv": fan startup voltage. Accepted values are 0, 1, 2 and 3.
The higher the more.
- "pwm_polarity": pwm polarity. Accepted values are 0 (positive duty)
and 1 (negative duty).
- "fan_gear_mode": fan gear mode. Supported values are 0, 1 and 2.
If an optional property is not set in .dts file, then current value is kept
unmodified (e.g. u-boot installed value).
Additional information on operational parameters for the device is available
in Documentation/hwmon/g762. A detailed datasheet for the device is available
at http://natisbad.org/NAS/refs/GMT_EDS-762_763-080710-0.2.pdf.
Example g762 node:
clocks {
#address-cells = <1>;
#size-cells = <0>;
g762_clk: fixedclk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8192>;
}
}
g762: g762@3e {
compatible = "gmt,g762";
reg = <0x3e>;
clocks = <&g762_clk>
fan_gear_mode = <0>; /* chip default */
fan_startv = <1>; /* chip default */
pwm_polarity = <0>; /* chip default */
};
ina2xx properties
Required properties:
- compatible: Must be one of the following:
- "ti,ina219" for ina219
- "ti,ina220" for ina220
- "ti,ina226" for ina226
- "ti,ina230" for ina230
- reg: I2C address
Optional properties:
- shunt-resistor
Shunt resistor value in micro-Ohm
Example:
ina220@44 {
compatible = "ti,ina220";
reg = <0x44>;
shunt-resistor = <1000>;
};
...@@ -2,16 +2,30 @@ Kernel driver ds1621 ...@@ -2,16 +2,30 @@ Kernel driver ds1621
==================== ====================
Supported chips: Supported chips:
* Dallas Semiconductor DS1621 * Dallas Semiconductor / Maxim Integrated DS1621
Prefix: 'ds1621' Prefix: 'ds1621'
Addresses scanned: I2C 0x48 - 0x4f Addresses scanned: none
Datasheet: Publicly available at the Dallas Semiconductor website Datasheet: Publicly available from www.maximintegrated.com
http://www.dalsemi.com/
* Dallas Semiconductor DS1625 * Dallas Semiconductor DS1625
Prefix: 'ds1621' Prefix: 'ds1625'
Addresses scanned: I2C 0x48 - 0x4f Addresses scanned: none
Datasheet: Publicly available at the Dallas Semiconductor website Datasheet: Publicly available from www.datasheetarchive.com
http://www.dalsemi.com/
* Maxim Integrated DS1631
Prefix: 'ds1631'
Addresses scanned: none
Datasheet: Publicly available from www.maximintegrated.com
* Maxim Integrated DS1721
Prefix: 'ds1721'
Addresses scanned: none
Datasheet: Publicly available from www.maximintegrated.com
* Maxim Integrated DS1731
Prefix: 'ds1731'
Addresses scanned: none
Datasheet: Publicly available from www.maximintegrated.com
Authors: Authors:
Christian W. Zuckschwerdt <zany@triq.net> Christian W. Zuckschwerdt <zany@triq.net>
...@@ -59,5 +73,115 @@ any of the limits have ever been met or exceeded since last power-up or ...@@ -59,5 +73,115 @@ any of the limits have ever been met or exceeded since last power-up or
reset. Be aware: When testing, it showed that the status of Tout can change reset. Be aware: When testing, it showed that the status of Tout can change
with neither of the alarms set. with neither of the alarms set.
Temperature conversion of the DS1621 takes up to 1000ms; internal access to Since there is no version or vendor identification register, there is
non-volatile registers may last for 10ms or below. no unique identification for these devices. Therefore, explicit device
instantiation is required for correct device identification and functionality
(one device per address in this address range: 0x48..0x4f).
The DS1625 is pin compatible and functionally equivalent with the DS1621,
but the DS1621 is meant to replace it. The DS1631, DS1721, and DS1731 are
also pin compatible with the DS1621 and provide multi-resolution support.
Additionally, the DS1721 data sheet says the temperature flags (THF and TLF)
are used internally, however, these flags do get set and cleared as the actual
temperature crosses the min or max settings (which by default are set to 75
and 80 degrees respectively).
Temperature Conversion:
-----------------------
DS1621 - 750ms (older devices may take up to 1000ms)
DS1625 - 500ms
DS1631 - 93ms..750ms for 9..12 bits resolution, respectively.
DS1721 - 93ms..750ms for 9..12 bits resolution, respectively.
DS1731 - 93ms..750ms for 9..12 bits resolution, respectively.
Note:
On the DS1621, internal access to non-volatile registers may last for 10ms
or less (unverified on the other devices).
Temperature Accuracy:
---------------------
DS1621: +/- 0.5 degree Celsius (from 0 to +70 degrees)
DS1625: +/- 0.5 degree Celsius (from 0 to +70 degrees)
DS1631: +/- 0.5 degree Celsius (from 0 to +70 degrees)
DS1721: +/- 1.0 degree Celsius (from -10 to +85 degrees)
DS1731: +/- 1.0 degree Celsius (from -10 to +85 degrees)
Note:
Please refer to the device datasheets for accuracy at other temperatures.
Temperature Resolution:
-----------------------
As mentioned above, the DS1631, DS1721, and DS1731 provide multi-resolution
support, which is achieved via the R0 and R1 config register bits, where:
R0..R1
------
0 0 => 9 bits, 0.5 degrees Celcius
1 0 => 10 bits, 0.25 degrees Celcius
0 1 => 11 bits, 0.125 degrees Celcius
1 1 => 12 bits, 0.0625 degrees Celcius
Note:
At initial device power-on, the default resolution is set to 12-bits.
The resolution mode for the DS1631, DS1721, or DS1731 can be changed from
userspace, via the device 'update_interval' sysfs attribute. This attribute
will normalize the range of input values to the device maximum resolution
values defined in the datasheet as follows:
Resolution Conversion Time Input Range
(C/LSB) (msec) (msec)
------------------------------------------------
0.5 93.75 0....94
0.25 187.5 95...187
0.125 375 188..375
0.0625 750 376..infinity
------------------------------------------------
The following examples show how the 'update_interval' attribute can be
used to change the conversion time:
$ cat update_interval
750
$ cat temp1_input
22062
$
$ echo 300 > update_interval
$ cat update_interval
375
$ cat temp1_input
22125
$
$ echo 150 > update_interval
$ cat update_interval
188
$ cat temp1_input
22250
$
$ echo 1 > update_interval
$ cat update_interval
94
$ cat temp1_input
22000
$
$ echo 1000 > update_interval
$ cat update_interval
750
$ cat temp1_input
22062
$
As shown, the ds1621 driver automatically adjusts the 'update_interval'
user input, via a step function. Reading back the 'update_interval' value
after a write operation provides the conversion time used by the device.
Mathematically, the resolution can be derived from the conversion time
via the following function:
g(x) = 0.5 * [minimum_conversion_time/x]
where:
-> 'x' = the output from 'update_interval'
-> 'g(x)' = the resolution in degrees C per LSB.
-> 93.75ms = minimum conversion time
Kernel driver g762
==================
The GMT G762 Fan Speed PWM Controller is connected directly to a fan
and performs closed-loop or open-loop control of the fan speed. Two
modes - PWM or DC - are supported by the device.
For additional information, a detailed datasheet is available at
http://natisbad.org/NAS/ref/GMT_EDS-762_763-080710-0.2.pdf. sysfs
bindings are described in Documentation/hwmon/sysfs-interface.
The following entries are available to the user in a subdirectory of
/sys/bus/i2c/drivers/g762/ to control the operation of the device.
This can be done manually using the following entries but is usually
done via a userland daemon like fancontrol.
Note that those entries do not provide ways to setup the specific
hardware characteristics of the system (reference clock, pulses per
fan revolution, ...); Those can be modified via devicetree bindings
documented in Documentation/devicetree/bindings/hwmon/g762.txt or
using a specific platform_data structure in board initialization
file (see include/linux/platform_data/g762.h).
fan1_target: set desired fan speed. This only makes sense in closed-loop
fan speed control (i.e. when pwm1_enable is set to 2).
fan1_input: provide current fan rotation value in RPM as reported by
the fan to the device.
fan1_div: fan clock divisor. Supported value are 1, 2, 4 and 8.
fan1_pulses: number of pulses per fan revolution. Supported values
are 2 and 4.
fan1_fault: reports fan failure, i.e. no transition on fan gear pin for
about 0.7s (if the fan is not voluntarily set off).
fan1_alarm: in closed-loop control mode, if fan RPM value is 25% out
of the programmed value for over 6 seconds 'fan1_alarm' is
set to 1.
pwm1_enable: set current fan speed control mode i.e. 1 for manual fan
speed control (open-loop) via pwm1 described below, 2 for
automatic fan speed control (closed-loop) via fan1_target
above.
pwm1_mode: set or get fan driving mode: 1 for PWM mode, 0 for DC mode.
pwm1: get or set PWM fan control value in open-loop mode. This is an
integer value between 0 and 255. 0 stops the fan, 255 makes
it run at full speed.
Both in PWM mode ('pwm1_mode' set to 1) and DC mode ('pwm1_mode' set to 0),
when current fan speed control mode is open-loop ('pwm1_enable' set to 1),
the fan speed is programmed by setting a value between 0 and 255 via 'pwm1'
entry (0 stops the fan, 255 makes it run at full speed). In closed-loop mode
('pwm1_enable' set to 2), the expected rotation speed in RPM can be passed to
the chip via 'fan1_target'. In closed-loop mode, the target speed is compared
with current speed (available via 'fan1_input') by the device and a feedback
is performed to match that target value. The fan speed value is computed
based on the parameters associated with the physical characteristics of the
system: a reference clock source frequency, a number of pulses per fan
revolution, etc.
Note that the driver will update its values at most once per second.
...@@ -44,4 +44,6 @@ The INA226 monitors both a shunt voltage drop and bus supply voltage. ...@@ -44,4 +44,6 @@ The INA226 monitors both a shunt voltage drop and bus supply voltage.
The INA230 is a high or low side current shunt and power monitor with an I2C The INA230 is a high or low side current shunt and power monitor with an I2C
interface. The INA230 monitors both a shunt voltage drop and bus supply voltage. interface. The INA230 monitors both a shunt voltage drop and bus supply voltage.
The shunt value in micro-ohms can be set via platform data. The shunt value in micro-ohms can be set via platform data or device tree.
Please refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
if the device tree is used.
...@@ -348,11 +348,16 @@ config SENSORS_DS620 ...@@ -348,11 +348,16 @@ config SENSORS_DS620
will be called ds620. will be called ds620.
config SENSORS_DS1621 config SENSORS_DS1621
tristate "Dallas Semiconductor DS1621 and DS1625" tristate "Dallas Semiconductor DS1621 and compatibles"
depends on I2C depends on I2C
help help
If you say yes here you get support for Dallas Semiconductor If you say yes here you get support for Dallas Semiconductor/Maxim
DS1621 and DS1625 sensor chips. Integrated DS1621 sensor chips and compatible models including:
- Dallas Semiconductor DS1625
- Maxim Integrated DS1631
- Maxim Integrated DS1721
- Maxim Integrated DS1731
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called ds1621. will be called ds1621.
...@@ -456,6 +461,16 @@ config SENSORS_G760A ...@@ -456,6 +461,16 @@ config SENSORS_G760A
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called g760a. will be called g760a.
config SENSORS_G762
tristate "GMT G762 and G763"
depends on I2C
help
If you say yes here you get support for Global Mixed-mode
Technology Inc G762 and G763 fan speed PWM controller chips.
This driver can also be built as a module. If so, the module
will be called g762.
config SENSORS_GL518SM config SENSORS_GL518SM
tristate "Genesys Logic GL518SM" tristate "Genesys Logic GL518SM"
depends on I2C depends on I2C
......
...@@ -60,6 +60,7 @@ obj-$(CONFIG_SENSORS_F75375S) += f75375s.o ...@@ -60,6 +60,7 @@ obj-$(CONFIG_SENSORS_F75375S) += f75375s.o
obj-$(CONFIG_SENSORS_FAM15H_POWER) += fam15h_power.o obj-$(CONFIG_SENSORS_FAM15H_POWER) += fam15h_power.o
obj-$(CONFIG_SENSORS_FSCHMD) += fschmd.o obj-$(CONFIG_SENSORS_FSCHMD) += fschmd.o
obj-$(CONFIG_SENSORS_G760A) += g760a.o obj-$(CONFIG_SENSORS_G760A) += g760a.o
obj-$(CONFIG_SENSORS_G762) += g762.o
obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o
......
...@@ -1079,7 +1079,6 @@ static int abituguru3_remove(struct platform_device *pdev) ...@@ -1079,7 +1079,6 @@ static int abituguru3_remove(struct platform_device *pdev)
int i; int i;
struct abituguru3_data *data = platform_get_drvdata(pdev); struct abituguru3_data *data = platform_get_drvdata(pdev);
platform_set_drvdata(pdev, NULL);
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++)
device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
......
...@@ -284,15 +284,11 @@ static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power); ...@@ -284,15 +284,11 @@ static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power);
static struct attribute *adm1021_attributes[] = { static struct attribute *adm1021_attributes[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_min.dev_attr.attr,
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp2_max.dev_attr.attr, &sensor_dev_attr_temp2_max.dev_attr.attr,
&sensor_dev_attr_temp2_min.dev_attr.attr,
&sensor_dev_attr_temp2_input.dev_attr.attr, &sensor_dev_attr_temp2_input.dev_attr.attr,
&sensor_dev_attr_temp1_max_alarm.dev_attr.attr, &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
&sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
&sensor_dev_attr_temp2_max_alarm.dev_attr.attr, &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
&sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
&sensor_dev_attr_temp2_fault.dev_attr.attr, &sensor_dev_attr_temp2_fault.dev_attr.attr,
&dev_attr_alarms.attr, &dev_attr_alarms.attr,
&dev_attr_low_power.attr, &dev_attr_low_power.attr,
...@@ -303,6 +299,18 @@ static const struct attribute_group adm1021_group = { ...@@ -303,6 +299,18 @@ static const struct attribute_group adm1021_group = {
.attrs = adm1021_attributes, .attrs = adm1021_attributes,
}; };
static struct attribute *adm1021_min_attributes[] = {
&sensor_dev_attr_temp1_min.dev_attr.attr,
&sensor_dev_attr_temp2_min.dev_attr.attr,
&sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
&sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
NULL
};
static const struct attribute_group adm1021_min_group = {
.attrs = adm1021_min_attributes,
};
/* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */
static int adm1021_detect(struct i2c_client *client, static int adm1021_detect(struct i2c_client *client,
struct i2c_board_info *info) struct i2c_board_info *info)
...@@ -425,6 +433,12 @@ static int adm1021_probe(struct i2c_client *client, ...@@ -425,6 +433,12 @@ static int adm1021_probe(struct i2c_client *client,
if (err) if (err)
return err; return err;
if (data->type != lm84) {
err = sysfs_create_group(&client->dev.kobj, &adm1021_min_group);
if (err)
goto error;
}
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
...@@ -434,6 +448,7 @@ static int adm1021_probe(struct i2c_client *client, ...@@ -434,6 +448,7 @@ static int adm1021_probe(struct i2c_client *client,
return 0; return 0;
error: error:
sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
sysfs_remove_group(&client->dev.kobj, &adm1021_group); sysfs_remove_group(&client->dev.kobj, &adm1021_group);
return err; return err;
} }
...@@ -452,6 +467,7 @@ static int adm1021_remove(struct i2c_client *client) ...@@ -452,6 +467,7 @@ static int adm1021_remove(struct i2c_client *client)
struct adm1021_data *data = i2c_get_clientdata(client); struct adm1021_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
sysfs_remove_group(&client->dev.kobj, &adm1021_group); sysfs_remove_group(&client->dev.kobj, &adm1021_group);
return 0; return 0;
...@@ -477,9 +493,11 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) ...@@ -477,9 +493,11 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
data->temp_max[i] = 1000 * data->temp_max[i] = 1000 *
(s8) i2c_smbus_read_byte_data( (s8) i2c_smbus_read_byte_data(
client, ADM1021_REG_TOS_R(i)); client, ADM1021_REG_TOS_R(i));
if (data->type != lm84) {
data->temp_min[i] = 1000 * data->temp_min[i] = 1000 *
(s8) i2c_smbus_read_byte_data( (s8) i2c_smbus_read_byte_data(client,
client, ADM1021_REG_THYST_R(i)); ADM1021_REG_THYST_R(i));
}
} }
data->alarms = i2c_smbus_read_byte_data(client, data->alarms = i2c_smbus_read_byte_data(client,
ADM1021_REG_STATUS) & 0x7c; ADM1021_REG_STATUS) & 0x7c;
......
...@@ -578,7 +578,6 @@ static int coretemp_probe(struct platform_device *pdev) ...@@ -578,7 +578,6 @@ static int coretemp_probe(struct platform_device *pdev)
exit_name: exit_name:
device_remove_file(&pdev->dev, &pdata->name_attr); device_remove_file(&pdev->dev, &pdata->name_attr);
platform_set_drvdata(pdev, NULL);
exit_free: exit_free:
kfree(pdata); kfree(pdata);
return err; return err;
...@@ -595,7 +594,6 @@ static int coretemp_remove(struct platform_device *pdev) ...@@ -595,7 +594,6 @@ static int coretemp_remove(struct platform_device *pdev)
device_remove_file(&pdev->dev, &pdata->name_attr); device_remove_file(&pdev->dev, &pdata->name_attr);
hwmon_device_unregister(pdata->hwmon_dev); hwmon_device_unregister(pdata->hwmon_dev);
platform_set_drvdata(pdev, NULL);
kfree(pdata); kfree(pdata);
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -556,7 +556,6 @@ static int i5k_amb_probe(struct platform_device *pdev) ...@@ -556,7 +556,6 @@ static int i5k_amb_probe(struct platform_device *pdev)
err_init_failed: err_init_failed:
iounmap(data->amb_mmio); iounmap(data->amb_mmio);
platform_set_drvdata(pdev, NULL);
err_map_failed: err_map_failed:
release_mem_region(data->amb_base, data->amb_len); release_mem_region(data->amb_base, data->amb_len);
err: err:
...@@ -576,7 +575,6 @@ static int i5k_amb_remove(struct platform_device *pdev) ...@@ -576,7 +575,6 @@ static int i5k_amb_remove(struct platform_device *pdev)
kfree(data->attrs); kfree(data->attrs);
iounmap(data->amb_mmio); iounmap(data->amb_mmio);
release_mem_region(data->amb_base, data->amb_len); release_mem_region(data->amb_base, data->amb_len);
platform_set_drvdata(pdev, NULL);
kfree(data); kfree(data);
return 0; return 0;
} }
......
...@@ -180,6 +180,7 @@ static struct of_device_id iio_hwmon_of_match[] = { ...@@ -180,6 +180,7 @@ static struct of_device_id iio_hwmon_of_match[] = {
{ .compatible = "iio-hwmon", }, { .compatible = "iio-hwmon", },
{ } { }
}; };
MODULE_DEVICE_TABLE(of, iio_hwmon_of_match);
static struct platform_driver __refdata iio_hwmon_driver = { static struct platform_driver __refdata iio_hwmon_driver = {
.driver = { .driver = {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h> #include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/of.h>
#include <linux/platform_data/ina2xx.h> #include <linux/platform_data/ina2xx.h>
...@@ -221,6 +222,7 @@ static int ina2xx_probe(struct i2c_client *client, ...@@ -221,6 +222,7 @@ static int ina2xx_probe(struct i2c_client *client,
struct ina2xx_data *data; struct ina2xx_data *data;
struct ina2xx_platform_data *pdata; struct ina2xx_platform_data *pdata;
int ret; int ret;
u32 val;
long shunt = 10000; /* default shunt value 10mOhms */ long shunt = 10000; /* default shunt value 10mOhms */
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
...@@ -234,6 +236,9 @@ static int ina2xx_probe(struct i2c_client *client, ...@@ -234,6 +236,9 @@ static int ina2xx_probe(struct i2c_client *client,
pdata = pdata =
(struct ina2xx_platform_data *)client->dev.platform_data; (struct ina2xx_platform_data *)client->dev.platform_data;
shunt = pdata->shunt_uohms; shunt = pdata->shunt_uohms;
} else if (!of_property_read_u32(client->dev.of_node,
"shunt-resistor", &val)) {
shunt = val;
} }
if (shunt <= 0) if (shunt <= 0)
......
...@@ -199,7 +199,7 @@ static const s8 NCT6775_ALARM_BITS[] = { ...@@ -199,7 +199,7 @@ static const s8 NCT6775_ALARM_BITS[] = {
0, 1, 2, 3, 8, 21, 20, 16, /* in0.. in7 */ 0, 1, 2, 3, 8, 21, 20, 16, /* in0.. in7 */
17, -1, -1, -1, -1, -1, -1, /* in8..in14 */ 17, -1, -1, -1, -1, -1, -1, /* in8..in14 */
-1, /* unused */ -1, /* unused */
6, 7, 11, 10, 23, /* fan1..fan5 */ 6, 7, 11, -1, -1, /* fan1..fan5 */
-1, -1, -1, /* unused */ -1, -1, -1, /* unused */
4, 5, 13, -1, -1, -1, /* temp1..temp6 */ 4, 5, 13, -1, -1, -1, /* temp1..temp6 */
12, -1 }; /* intrusion0, intrusion1 */ 12, -1 }; /* intrusion0, intrusion1 */
...@@ -625,6 +625,7 @@ struct nct6775_data { ...@@ -625,6 +625,7 @@ struct nct6775_data {
u8 has_fan_min; /* some fans don't have min register */ u8 has_fan_min; /* some fans don't have min register */
bool has_fan_div; bool has_fan_div;
u8 num_temp_alarms; /* 2 or 3 */
u8 temp_fixed_num; /* 3 or 6 */ u8 temp_fixed_num; /* 3 or 6 */
u8 temp_type[NUM_TEMP_FIXED]; u8 temp_type[NUM_TEMP_FIXED];
s8 temp_offset[NUM_TEMP_FIXED]; s8 temp_offset[NUM_TEMP_FIXED];
...@@ -1193,6 +1194,42 @@ show_alarm(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1193,6 +1194,42 @@ show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
(unsigned int)((data->alarms >> nr) & 0x01)); (unsigned int)((data->alarms >> nr) & 0x01));
} }
static int find_temp_source(struct nct6775_data *data, int index, int count)
{
int source = data->temp_src[index];
int nr;
for (nr = 0; nr < count; nr++) {
int src;
src = nct6775_read_value(data,
data->REG_TEMP_SOURCE[nr]) & 0x1f;
if (src == source)
return nr;
}
return -1;
}
static ssize_t
show_temp_alarm(struct device *dev, struct device_attribute *attr, char *buf)
{
struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
struct nct6775_data *data = nct6775_update_device(dev);
unsigned int alarm = 0;
int nr;
/*
* For temperatures, there is no fixed mapping from registers to alarm
* bits. Alarm bits are determined by the temperature source mapping.
*/
nr = find_temp_source(data, sattr->index, data->num_temp_alarms);
if (nr >= 0) {
int bit = data->ALARM_BITS[nr + TEMP_ALARM_BASE];
alarm = (data->alarms >> bit) & 0x01;
}
return sprintf(buf, "%u\n", alarm);
}
static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in_reg, NULL, 0, 0); static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in_reg, NULL, 0, 0);
static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in_reg, NULL, 1, 0); static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in_reg, NULL, 1, 0);
static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in_reg, NULL, 2, 0); static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in_reg, NULL, 2, 0);
...@@ -1874,22 +1911,18 @@ static struct sensor_device_attribute sda_temp_type[] = { ...@@ -1874,22 +1911,18 @@ static struct sensor_device_attribute sda_temp_type[] = {
}; };
static struct sensor_device_attribute sda_temp_alarm[] = { static struct sensor_device_attribute sda_temp_alarm[] = {
SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, SENSOR_ATTR(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0),
TEMP_ALARM_BASE), SENSOR_ATTR(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 1),
SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, SENSOR_ATTR(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 2),
TEMP_ALARM_BASE + 1), SENSOR_ATTR(temp4_alarm, S_IRUGO, show_temp_alarm, NULL, 3),
SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, SENSOR_ATTR(temp5_alarm, S_IRUGO, show_temp_alarm, NULL, 4),
TEMP_ALARM_BASE + 2), SENSOR_ATTR(temp6_alarm, S_IRUGO, show_temp_alarm, NULL, 5),
SENSOR_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, SENSOR_ATTR(temp7_alarm, S_IRUGO, show_temp_alarm, NULL, 6),
TEMP_ALARM_BASE + 3), SENSOR_ATTR(temp8_alarm, S_IRUGO, show_temp_alarm, NULL, 7),
SENSOR_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL, SENSOR_ATTR(temp9_alarm, S_IRUGO, show_temp_alarm, NULL, 8),
TEMP_ALARM_BASE + 4), SENSOR_ATTR(temp10_alarm, S_IRUGO, show_temp_alarm, NULL, 9),
SENSOR_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL,
TEMP_ALARM_BASE + 5),
}; };
#define NUM_TEMP_ALARM ARRAY_SIZE(sda_temp_alarm)
static ssize_t static ssize_t
show_pwm_mode(struct device *dev, struct device_attribute *attr, char *buf) show_pwm_mode(struct device *dev, struct device_attribute *attr, char *buf)
{ {
...@@ -3215,13 +3248,11 @@ static void nct6775_device_remove_files(struct device *dev) ...@@ -3215,13 +3248,11 @@ static void nct6775_device_remove_files(struct device *dev)
device_remove_file(dev, &sda_temp_max[i].dev_attr); device_remove_file(dev, &sda_temp_max[i].dev_attr);
device_remove_file(dev, &sda_temp_max_hyst[i].dev_attr); device_remove_file(dev, &sda_temp_max_hyst[i].dev_attr);
device_remove_file(dev, &sda_temp_crit[i].dev_attr); device_remove_file(dev, &sda_temp_crit[i].dev_attr);
device_remove_file(dev, &sda_temp_alarm[i].dev_attr);
if (!(data->have_temp_fixed & (1 << i))) if (!(data->have_temp_fixed & (1 << i)))
continue; continue;
device_remove_file(dev, &sda_temp_type[i].dev_attr); device_remove_file(dev, &sda_temp_type[i].dev_attr);
device_remove_file(dev, &sda_temp_offset[i].dev_attr); device_remove_file(dev, &sda_temp_offset[i].dev_attr);
if (i >= NUM_TEMP_ALARM)
continue;
device_remove_file(dev, &sda_temp_alarm[i].dev_attr);
} }
device_remove_file(dev, &sda_caseopen[0].dev_attr); device_remove_file(dev, &sda_caseopen[0].dev_attr);
...@@ -3419,6 +3450,7 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3419,6 +3450,7 @@ static int nct6775_probe(struct platform_device *pdev)
data->auto_pwm_num = 6; data->auto_pwm_num = 6;
data->has_fan_div = true; data->has_fan_div = true;
data->temp_fixed_num = 3; data->temp_fixed_num = 3;
data->num_temp_alarms = 3;
data->ALARM_BITS = NCT6775_ALARM_BITS; data->ALARM_BITS = NCT6775_ALARM_BITS;
...@@ -3483,6 +3515,7 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3483,6 +3515,7 @@ static int nct6775_probe(struct platform_device *pdev)
data->auto_pwm_num = 4; data->auto_pwm_num = 4;
data->has_fan_div = false; data->has_fan_div = false;
data->temp_fixed_num = 3; data->temp_fixed_num = 3;
data->num_temp_alarms = 3;
data->ALARM_BITS = NCT6776_ALARM_BITS; data->ALARM_BITS = NCT6776_ALARM_BITS;
...@@ -3547,6 +3580,7 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3547,6 +3580,7 @@ static int nct6775_probe(struct platform_device *pdev)
data->auto_pwm_num = 4; data->auto_pwm_num = 4;
data->has_fan_div = false; data->has_fan_div = false;
data->temp_fixed_num = 6; data->temp_fixed_num = 6;
data->num_temp_alarms = 2;
data->ALARM_BITS = NCT6779_ALARM_BITS; data->ALARM_BITS = NCT6779_ALARM_BITS;
...@@ -3843,10 +3877,12 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3843,10 +3877,12 @@ static int nct6775_probe(struct platform_device *pdev)
&sda_fan_input[i].dev_attr); &sda_fan_input[i].dev_attr);
if (err) if (err)
goto exit_remove; goto exit_remove;
if (data->ALARM_BITS[FAN_ALARM_BASE + i] >= 0) {
err = device_create_file(dev, err = device_create_file(dev,
&sda_fan_alarm[i].dev_attr); &sda_fan_alarm[i].dev_attr);
if (err) if (err)
goto exit_remove; goto exit_remove;
}
if (data->kind != nct6776 && if (data->kind != nct6776 &&
data->kind != nct6779) { data->kind != nct6779) {
err = device_create_file(dev, err = device_create_file(dev,
...@@ -3897,6 +3933,12 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3897,6 +3933,12 @@ static int nct6775_probe(struct platform_device *pdev)
if (err) if (err)
goto exit_remove; goto exit_remove;
} }
if (find_temp_source(data, i, data->num_temp_alarms) >= 0) {
err = device_create_file(dev,
&sda_temp_alarm[i].dev_attr);
if (err)
goto exit_remove;
}
if (!(data->have_temp_fixed & (1 << i))) if (!(data->have_temp_fixed & (1 << i)))
continue; continue;
err = device_create_file(dev, &sda_temp_type[i].dev_attr); err = device_create_file(dev, &sda_temp_type[i].dev_attr);
...@@ -3905,12 +3947,6 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3905,12 +3947,6 @@ static int nct6775_probe(struct platform_device *pdev)
err = device_create_file(dev, &sda_temp_offset[i].dev_attr); err = device_create_file(dev, &sda_temp_offset[i].dev_attr);
if (err) if (err)
goto exit_remove; goto exit_remove;
if (i >= NUM_TEMP_ALARM ||
data->ALARM_BITS[TEMP_ALARM_BASE + i] < 0)
continue;
err = device_create_file(dev, &sda_temp_alarm[i].dev_attr);
if (err)
goto exit_remove;
} }
for (i = 0; i < ARRAY_SIZE(sda_caseopen); i++) { for (i = 0; i < ARRAY_SIZE(sda_caseopen); i++) {
......
...@@ -514,7 +514,6 @@ static int ntc_thermistor_remove(struct platform_device *pdev) ...@@ -514,7 +514,6 @@ static int ntc_thermistor_remove(struct platform_device *pdev)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
ntc_iio_channel_release(pdata); ntc_iio_channel_release(pdata);
platform_set_drvdata(pdev, NULL);
return 0; return 0;
} }
......
...@@ -2598,7 +2598,6 @@ static int w83627ehf_probe(struct platform_device *pdev) ...@@ -2598,7 +2598,6 @@ static int w83627ehf_probe(struct platform_device *pdev)
exit_remove: exit_remove:
w83627ehf_device_remove_files(dev); w83627ehf_device_remove_files(dev);
exit_release: exit_release:
platform_set_drvdata(pdev, NULL);
release_region(res->start, IOREGION_LENGTH); release_region(res->start, IOREGION_LENGTH);
exit: exit:
return err; return err;
...@@ -2611,7 +2610,6 @@ static int w83627ehf_remove(struct platform_device *pdev) ...@@ -2611,7 +2610,6 @@ static int w83627ehf_remove(struct platform_device *pdev)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
w83627ehf_device_remove_files(&pdev->dev); w83627ehf_device_remove_files(&pdev->dev);
release_region(data->addr, IOREGION_LENGTH); release_region(data->addr, IOREGION_LENGTH);
platform_set_drvdata(pdev, NULL);
return 0; return 0;
} }
......
/*
* Platform data structure for g762 fan controller driver
*
* Copyright (C) 2013, Arnaud EBALARD <arno@natisbad.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LINUX_PLATFORM_DATA_G762_H__
#define __LINUX_PLATFORM_DATA_G762_H__
/*
* Following structure can be used to set g762 driver platform specific data
* during board init. Note that passing a sparse structure is possible but
* will result in non-specified attributes to be set to default value, hence
* overloading those installed during boot (e.g. by u-boot).
*/
struct g762_platform_data {
u32 fan_startv;
u32 fan_gear_mode;
u32 pwm_polarity;
u32 clk_freq;
};
#endif /* __LINUX_PLATFORM_DATA_G762_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment