Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1552684
| From | Alexander Koch <mail@alexanderkoch.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 2/4] hwmon: adc128d818: Implement mode selection via dt |
| Date | 2017-01-06 11:50 +0100 |
| Message-ID | <sWAfU-w2-31@gated-at.bofh.it> (permalink) |
| References | <sWAfT-w2-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Implement operation mode selection using the optional 'ti,mode' devicetree
property (see [1]). The ADC128D818 supports four operation modes differing
in the number and type of input readings (see datasheet, sec. 8.4.1), of
which mode 0 is the default.
We only add handling of the 'ti,mode' property here, the driver still
supports nothing else than the default mode 0.
[1] Documentation/devicetree/bindings/hwmon/adc128d818.txt
Signed-off-by: Alexander Koch <mail@alexanderkoch.net>
Acked-by: Michael Hornung <mhornung.linux@gmail.com>
---
drivers/hwmon/adc128d818.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c
index ad2b47e40345..2b61936c32ff 100644
--- a/drivers/hwmon/adc128d818.c
+++ b/drivers/hwmon/adc128d818.c
@@ -28,6 +28,7 @@
#include <linux/regulator/consumer.h>
#include <linux/mutex.h>
#include <linux/bitops.h>
+#include <linux/of.h>
/* Addresses to scan
* The chip also supports addresses 0x35..0x37. Don't scan those addresses
@@ -63,6 +64,7 @@ struct adc128_data {
struct regulator *regulator;
int vref; /* Reference voltage in mV */
struct mutex update_lock;
+ u8 mode; /* Operation mode */
bool valid; /* true if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -387,6 +389,15 @@ static int adc128_init_client(struct adc128_data *data)
if (err)
return err;
+ /* Set operation mode, if non-default */
+ if (data->mode != 0) {
+ err = i2c_smbus_write_byte_data(client,
+ ADC128_REG_CONFIG_ADV,
+ data->mode << 1);
+ if (err)
+ return err;
+ }
+
/* Start monitoring */
err = i2c_smbus_write_byte_data(client, ADC128_REG_CONFIG, 0x01);
if (err)
@@ -433,6 +444,19 @@ static int adc128_probe(struct i2c_client *client,
data->vref = 2560; /* 2.56V, in mV */
}
+ /* Operation mode is optional and defaults to mode 0 */
+ if (of_property_read_u8(dev->of_node, "ti,mode", &data->mode) == 0) {
+ /* Currently only mode 0 supported */
+ if (data->mode != 0) {
+ dev_err(dev, "unsupported operation mode %d\n",
+ data->mode);
+ err = -EINVAL;
+ goto error;
+ }
+ } else {
+ data->mode = 0;
+ }
+
data->client = client;
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 0/4] hwmon: adc128d818: Support missing operation modes Alexander Koch <mail@alexanderkoch.net> - 2017-01-06 11:50 +0100
[PATCH v3 4/4] hwmon: adc128d818: Preserve operation mode Alexander Koch <mail@alexanderkoch.net> - 2017-01-06 11:50 +0100
[PATCH v3 2/4] hwmon: adc128d818: Implement mode selection via dt Alexander Koch <mail@alexanderkoch.net> - 2017-01-06 11:50 +0100
[PATCH v3 1/4] devicetree: hwmon: Add bindings for ADC128D818 Alexander Koch <mail@alexanderkoch.net> - 2017-01-06 11:50 +0100
Re: [PATCH v3 1/4] devicetree: hwmon: Add bindings for ADC128D818 Rob Herring <robh@kernel.org> - 2017-01-10 06:40 +0100
Re: [PATCH v3 0/4] hwmon: adc128d818: Support missing operation modes Guenter Roeck <linux@roeck-us.net> - 2017-01-10 18:20 +0100
csiph-web