Commit 67043d18 authored by Mahoda Ratnayaka's avatar Mahoda Ratnayaka Committed by Guenter Roeck

hwmon: (lm87) Allow channel data to be set from dts file

Currently there is no method for setting the channel
value from the DTS file. When, the driver uses a dts
file to initialize the driver platform_data is not set.
As a result channel variable may not be set correctly.

Without the channel variable set correctly, some of the
sensors will not be initialized correctly. For example
temp3 sensor sysfs entries.

This implements the schema agreed with the device tree
binding document.
Signed-off-by: default avatarMahoda Ratnayaka <mahoda.ratnayaka@alliedtelesis.co.nz>
Tested-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 36df6fb6
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <linux/hwmon-vid.h> #include <linux/hwmon-vid.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/regulator/consumer.h>
/* /*
* Addresses to scan * Addresses to scan
...@@ -855,8 +856,26 @@ static int lm87_init_client(struct i2c_client *client) ...@@ -855,8 +856,26 @@ static int lm87_init_client(struct i2c_client *client)
{ {
struct lm87_data *data = i2c_get_clientdata(client); struct lm87_data *data = i2c_get_clientdata(client);
int rc; int rc;
struct device_node *of_node = client->dev.of_node;
if (dev_get_platdata(&client->dev)) { u8 val = 0;
struct regulator *vcc = NULL;
if (of_node) {
if (of_property_read_bool(of_node, "has-temp3"))
val |= CHAN_TEMP3;
if (of_property_read_bool(of_node, "has-in6"))
val |= CHAN_NO_FAN(0);
if (of_property_read_bool(of_node, "has-in7"))
val |= CHAN_NO_FAN(1);
vcc = devm_regulator_get_optional(&client->dev, "vcc");
if (!IS_ERR(vcc)) {
if (regulator_get_voltage(vcc) == 5000000)
val |= CHAN_VCC_5V;
}
data->channel = val;
lm87_write_value(client,
LM87_REG_CHANNEL_MODE, data->channel);
} else if (dev_get_platdata(&client->dev)) {
data->channel = *(u8 *)dev_get_platdata(&client->dev); data->channel = *(u8 *)dev_get_platdata(&client->dev);
lm87_write_value(client, lm87_write_value(client,
LM87_REG_CHANNEL_MODE, data->channel); LM87_REG_CHANNEL_MODE, data->channel);
......
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