Skip to contentSkip to conversation

hwmon: (ads1015) Add devicetree documentation

PATCH Superseded Dirk Eibach 4 participants 11 messages Mar 3, 2011 – Mar 17, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (ads1015) Add devicetree documentation

---
 Documentation/devicetree/bindings/i2c/ads1015.txt |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/ads1015.txt
Documentation/devicetree/bindings/i2c/ads1015.txt new file +15 -0
new file mode 100644
index 0000000..3a7d67a
@@ -0,0 +1,15 @@
+ADS1015 (I2C)
+
+Optional properties:
+
+ - exported-channels : exported_channels is a bitmask that specifies which
+		       inputs should be exported to sysfs.
+
+Example:
+ads1015@49 {
+	compatible = "ti,ads1015";
+	reg = <0x49>;
+	exported-channels = <0x14>;
+};
+
+In this example only in2_input and in4_input would be created.
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 12 lines · Dirk Eibach
---
 Documentation/devicetree/bindings/i2c/ads1015.txt |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/ads1015.txt
Documentation/devicetree/bindings/i2c/ads1015.txt new file +0 -0
new file mode 100644
index 0000000..3a7d67a

Documentation/devicetree/bindings/i2c/ads1015.txt line 6

Quoted 6 lines
Documentation/devicetree/bindings/i2c/ads1015.txt new file +6 -0
@@ -0,0 +1,15 @@
+ADS1015 (I2C)
+
+Optional properties:
+
+ - exported-channels : exported_channels is a bitmask that specifies which
+		       inputs should be exported to sysfs.

Hmm, device tree bindings should be OS-neutral, sysfs is not. Maybe "active-channels" would be better; then the OS could decide what to do with the active channels. Then again, what is the drawback of exporting all channels? Is there another hwmon-driver doing so (couldn't find one)?

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

Hi Wolfram,

Quoted 7 lines · Wolfram Sang
Quoted 6 lines · Dirk Eibach
---
 Documentation/devicetree/bindings/i2c/ads1015.txt |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/ads1015.txt
Quoted 14 lines

Documentation/devicetree/bindings/i2c/ads1015.txt line 6

Quoted 12 lines
Documentation/devicetree/bindings/i2c/ads1015.txt new file +6 -0
new file mode 100644
index 0000000..3a7d67a
@@ -0,0 +1,15 @@
+ADS1015 (I2C)
+
+Optional properties:
+
+ - exported-channels : exported_channels is a bitmask that specifies which
+		       inputs should be exported to sysfs.

Hmm, device tree bindings should be OS-neutral, sysfs is not.

Why do we document this in the Linux kernel tree then?

Quoted 4 lines

Maybe
"active-channels" would be better; then the OS could decide what to do with the active channels. Then again, what is the drawback of exporting all channels?

Performance and user-friendliness. libsensors-based applications will read all available attributes by default, and each reading takes time. Letting the platform declare how the inputs are used allows for a sane output for "sensors" and other similar tools out of the box, without the user having to tinker with ignore statements in configuration files to discard the nonsensical values.

Quoted 1 line

Is there another hwmon-driver doing so (couldn't find one)?

If "doing so" means "letting the user define how the ADC inputs are used", then yes, the pcf8591 driver does something similar, except that it uses a module parameter for the setting, for historical reasons. Platform-provided, per-device data is better in my opinion.

Signature · 1 line
Jean Delvare
#3 lore raw
Quoted 3 lines
Quoted 1 line

Hmm, device tree bindings should be OS-neutral, sysfs is not.

Why do we document this in the Linux kernel tree then?

To describe which bindings Linux supports.

Quoted 9 lines
Quoted 2 lines

with the active channels. Then again, what is the drawback of exporting all channels?

Performance and user-friendliness. libsensors-based applications will read all available attributes by default, and each reading takes time. Letting the platform declare how the inputs are used allows for a sane output for "sensors" and other similar tools out of the box, without the user having to tinker with ignore statements in configuration files to discard the nonsensical values.

OK, that's fine I'd say.

Quoted 6 lines
Quoted 1 line

Is there another hwmon-driver doing so (couldn't find one)?

If "doing so" means "letting the user define how the ADC inputs are used", then yes, the pcf8591 driver does something similar, except that it uses a module parameter for the setting, for historical reasons. Platform-provided, per-device data is better in my opinion.

OK. The thing is you can't map platform_data 1:1 to bindings, because most are very specific to the Linux-driver. Do you think something like "active-channels" would be sufficent for those other hwmon devices, too? (I still do not like "exported-channels", because there is no need to export the channels for the OS. The devicetree is primarily a hardware description language) Or maybe we go specific and say "ads1015,channel1 = 1"? Maybe somebody knows of a similar chips as a reference?

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#4 lore raw
Quoted 25 lines · Wolfram Sang
Quoted 3 lines
Quoted 1 line

Hmm, device tree bindings should be OS-neutral, sysfs is not.

Why do we document this in the Linux kernel tree then?

To describe which bindings Linux supports.

Quoted 9 lines
Quoted 2 lines

with the active channels. Then again, what is the drawback of exporting all channels?

Performance and user-friendliness. libsensors-based applications will read all available attributes by default, and each reading takes time. Letting the platform declare how the inputs are used allows for a sane output for "sensors" and other similar tools out of the box, without the user having to tinker with ignore statements in configuration files to discard the nonsensical values.

OK, that's fine I'd say.

Quoted 6 lines
Quoted 1 line

Is there another hwmon-driver doing so (couldn't find one)?

If "doing so" means "letting the user define how the ADC inputs are used", then yes, the pcf8591 driver does something similar, except that it uses a module parameter for the setting, for historical reasons. Platform-provided, per-device data is better in my opinion.

Quoted 7 lines

OK. The thing is you can't map platform_data 1:1 to bindings, because most are very specific to the Linux-driver. Do you think something like "active-channels" would be sufficent for those other hwmon devices, too? (I still do not like "exported-channels", because there is no need to export the channels for the OS. The devicetree is primarily a hardware description language) Or maybe we go specific and say "ads1015,channel1 = 1"? Maybe somebody knows of a similar chips as a reference?

Yes, Wolfram's correct. The focus should be on what the connections actually are instead of what the OS should attempt to do with them. ie. give the active channels actual names for what they do, or use a phandle to reference them from another node. The driver can then make a decision based on whether or not a channel has a configuration provided.

Quoted 1 line

From the little information I have, I'd recommend something like:

sensor@49 {
	compatible = "ti,ads1015"
	reg = <0x49>;

	// Each child node (one node per channel) has an address with
	// no range
	#address-cells = <1>;
	#size-cells = <0>;

	adc@2 {
		ti,measurement = "cpu voltage";
		reg = <2>;
	};

	adc@4 {
		ti,measurement = "base voltage";
		reg = <4>;
	};
};

However, after taking a little look at the data sheet, this binding might end up being a little naive for what the part can do. It might make more sense to do something like:

sensor@49 {
	compatible = "ti,ads1015"
	reg = <0x49>;

	// Each child node (one node per channel) has an address with
	// no range
	#address-cells = <1>;
	#size-cells = <0>;

	measurement@0 {
		reg = <0>;	// This reg value no longer reflects
				// the chip, it's just a handle for
				// logical measurement channels
		ti,measurement = "cpu voltage";
		ti,multiplexer = <2>; // AIN0 vs. AIN3
		ti,gain = <5>; // +/-0.256V
		ti,inverse-polarity;
	};

	measurement@1 {
		reg = <1>;
		ti,measurement = "base voltage";
		ti,multiplexer = <4>; // AIN0 vs. GND
		ti,gain = <2>; // +/-2.048V
	};
};

...which splits it up by logical measurement configurations instead of only the multiplexer setting.

It's more verbose than a single exported-channels property, but it is flexible enough that it can be easily extended with extra configuration data per channel.

g.

#5 lore raw
Quoted 42 lines · Grant Likely
Quoted 7 lines · Wolfram Sang

OK. The thing is you can't map platform_data 1:1 to bindings, because most are very specific to the Linux-driver. Do you think something like "active-channels" would be sufficent for those other hwmon devices, too? (I still do not like "exported-channels", because there is no need to export the channels for the OS. The devicetree is primarily a hardware description language) Or maybe we go specific and say "ads1015,channel1 = 1"? Maybe somebody knows of a similar chips as a reference?

Yes, Wolfram's correct. The focus should be on what the connections actually are instead of what the OS should attempt to do with them. ie. give the active channels actual names for what they do, or use a phandle to reference them from another node. The driver can then make a decision based on whether or not a channel has a configuration provided.

From the little information I have, I'd recommend something like:

sensor@49 {
	compatible = "ti,ads1015"
	reg = <0x49>;

	// Each child node (one node per channel) has an address with
	// no range
	#address-cells = <1>;
	#size-cells = <0>;

	adc@2 {
		ti,measurement = "cpu voltage";
		reg = <2>;
	};

	adc@4 {
		ti,measurement = "base voltage";
		reg = <4>;
	};
};

However, after taking a little look at the data sheet, this binding might end up being a little naive for what the part can do. It might make more sense to do something like:

Quoted 13 lines
sensor@49 {
	compatible = "ti,ads1015"
	reg = <0x49>;

	// Each child node (one node per channel) has an address with
	// no range
	#address-cells = <1>;
	#size-cells = <0>;

	measurement@0 {
		reg = <0>;	// This reg value no longer reflects
				// the chip, it's just a handle for
				// logical measurement channels

If there any hard requirement for this? From the driver's perspective, the multiplexer setting can be used as the channel ID, and it's easier this way than using arbitrary identifiers.

Quoted 14 lines
		ti,measurement = "cpu voltage";
		ti,multiplexer = <2>; // AIN0 vs. AIN3
		ti,gain = <5>; // +/-0.256V
		ti,inverse-polarity;
	};

	measurement@1 {
		reg = <1>;
		ti,measurement = "base voltage";
		ti,multiplexer = <4>; // AIN0 vs. GND
		ti,gain = <2>; // +/-2.048V
	};
};
Quoted 2 lines

...which splits it up by logical measurement configurations instead of only the multiplexer setting.

I wouldn't disagree, as I did suggest making the gain a per-channel setting while reviewing Dirk's driver. I had not thought of labelling, but the hwmon sysfs API supports this too, so it would fit nicely (although it can also be handled in user-space if needed.)

Quoted 3 lines

It's more verbose than a single exported-channels property, but it is flexible enough that it can be easily extended with extra configuration data per channel.

I will leave it up to Dirk to decide how much time he wants to spend on this. He has already been very patient with the driver review process and I do not want to abuse his patience.

Signature · 1 line
Jean Delvare
#6 lore raw
Quoted 52 lines · Jean Delvare
Quoted 51 lines · Grant Likely
Quoted 7 lines · Wolfram Sang

OK. The thing is you can't map platform_data 1:1 to bindings, because most are very specific to the Linux-driver. Do you think something like "active-channels" would be sufficent for those other hwmon devices, too? (I still do not like "exported-channels", because there is no need to export the channels for the OS. The devicetree is primarily a hardware description language) Or maybe we go specific and say "ads1015,channel1 = 1"? Maybe somebody knows of a similar chips as a reference?

Yes, Wolfram's correct.  The focus should be on what the connections actually are instead of what the OS should attempt to do with them. ie. give the active channels actual names for what they do, or use a phandle to reference them from another node.  The driver can then make a decision based on whether or not a channel has a configuration provided.

From the little information I have, I'd recommend something like:

sensor@49 {
      compatible = "ti,ads1015"
      reg = <0x49>;

      // Each child node (one node per channel) has an address with // no range
      #address-cells = <1>;
      #size-cells = <0>;

      adc@2 {
              ti,measurement = "cpu voltage";
              reg = <2>;
      };

      adc@4 {
              ti,measurement = "base voltage";
              reg = <4>;
      };
};

However, after taking a little look at the data sheet, this binding might end up being a little naive for what the part can do.  It might make more sense to do something like:

sensor@49 {
      compatible = "ti,ads1015"
      reg = <0x49>;

      // Each child node (one node per channel) has an address with // no range
      #address-cells = <1>;
      #size-cells = <0>;

Quoted 8 lines
Quoted 4 lines

      measurement@0 {
              reg = <0>;      // This reg value no longer reflects // the chip, it's just a handle for // logical measurement channels

If there any hard requirement for this? From the driver's perspective, the multiplexer setting can be used as the channel ID, and it's easier this way than using arbitrary identifiers.

Nope, not a hard requirement. Just a suggestion. It would be valuable if (and only if) there was ever reason to have more than one configuration for a particular multiplexer setting.

Quoted 7 lines
Quoted 3 lines

It's more verbose than a single exported-channels property, but it is flexible enough that it can be easily extended with extra configuration data per channel.

I will leave it up to Dirk to decide how much time he wants to spend on this. He has already been very patient with the driver review process and I do not want to abuse his patience.

BTW Dirk, I'm happy to help show how to write the parser code for the sub-node approach if you need it.

g.

#7 lore raw
Quoted 7 lines · Grant Likely
Quoted 3 lines · Jean Delvare

I will leave it up to Dirk to decide how much time he wants to spend on this. He has already been very patient with the driver review process and I do not want to abuse his patience.

BTW Dirk, I'm happy to help show how to write the parser code for the sub-node approach if you need it.

Grant, Wolfram, how are such patches committed? Documentation/devicetree/ isn't listed in MAINTAINERS. Is it OK for me to commit it once Dirk gets your approval? Or do you prefer to commit it yourself?

Signature · 1 line
Jean Delvare
#8 lore raw
Quoted 6 lines · Jean Delvare
Quoted 5 lines · Grant Likely
Quoted 3 lines · Jean Delvare

I will leave it up to Dirk to decide how much time he wants to spend on this. He has already been very patient with the driver review process and I do not want to abuse his patience.

Quoted 6 lines
Quoted 2 lines

BTW Dirk, I'm happy to help show how to write the parser code for the sub-node approach if you need it.

Grant, Wolfram, how are such patches committed? Documentation/devicetree/ isn't listed in MAINTAINERS. Is it OK for me to commit it once Dirk gets your approval? Or do you prefer to commit it yourself?

Yup. It makes sense for the documentation to be committed along side the driver changes. I have no problem with you taking this patch.

g.

#9 lore raw
In reply to Jean Delvare
Quoted 25 lines · Jean Delvare

Hi Wolfram,

Quoted 7 lines · Wolfram Sang
Quoted 6 lines · Dirk Eibach
---
 Documentation/devicetree/bindings/i2c/ads1015.txt |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/ads1015.txt
Quoted 14 lines

Documentation/devicetree/bindings/i2c/ads1015.txt line 6

Quoted 12 lines
Documentation/devicetree/bindings/i2c/ads1015.txt new file +6 -0
new file mode 100644
index 0000000..3a7d67a
@@ -0,0 +1,15 @@
+ADS1015 (I2C)
+
+Optional properties:
+
+ - exported-channels : exported_channels is a bitmask that specifies which
+		       inputs should be exported to sysfs.

Hmm, device tree bindings should be OS-neutral, sysfs is not.

Quoted 1 line

Why do we document this in the Linux kernel tree then?

Lack of a better place and process for documenting and reviewing bindings. I've been toying with moving device tree bindings out to devicetree.org, but I don't have a good review model for that. I might end up splitting it out into a separate git repository.

g.

#10 lore raw

PATCH v3 1/1 hwmon: (ads1015) Add devicetree documentation

In reply to Wolfram Sang

---
Changes since v1:
- removed sysfs from description
- explain channels

Changes since v2:
- Replaced 'accessable' by 'accessible'.

 Documentation/devicetree/bindings/i2c/ads1015.txt |   29 +++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/ads1015.txt
Documentation/devicetree/bindings/i2c/ads1015.txt new file +29 -0
new file mode 100644
index 0000000..985e24d
@@ -0,0 +1,29 @@
+ADS1015 (I2C)
+
+This device is a 12-bit A-D converter with 4 inputs.
+
+The inputs can be used single ended or in certain differential combinations.
+
+For configuration all possible combinations are mapped to 8 channels:
+0: Voltage over AIN0 and AIN1.
+1: Voltage over AIN0 and AIN3.
+2: Voltage over AIN1 and AIN3.
+3: Voltage over AIN2 and AIN3.
+4: Voltage over AIN0 and GND.
+5: Voltage over AIN1 and GND.
+6: Voltage over AIN2 and GND.
+7: Voltage over AIN3 and GND.
+
+Optional properties:
+
+ - exported-channels : exported_channels is a bitmask that specifies which
+		       channels should be accessible by the user.
+
+Example:
+ads1015@49 {
+	compatible = "ti,ads1015";
+	reg = <0x49>;
+	exported-channels = <0x14>;
+};
+
+In this example only channel 2 and 4 would be accessible by the user.
Signature · 1 line
1.5.6.5