diff mbox series

[RFC,2/6] dt-bindings: hwmon: Add Raspberry Pi voltage sensor

Message ID 1526477827-10859-3-git-send-email-stefan.wahren@i2se.com
State Changes Requested, archived
Headers show
Series None | expand

Commit Message

Stefan Wahren May 16, 2018, 1:37 p.m. UTC
Recent VC4 firmware provides a hardware-independent way to retrieve the
under-voltage sensor on the following Raspberry Pi boards:
  - Raspberry Pi B+ (via GPIO on SoC)
  - Raspberry Pi A+ (via GPIO on SoC)
  - Raspberry Pi 2 B (via GPIO on SoC)
  - Raspberry Pi 3 B (via GPIO on port expander)
  - Raspberry Pi 3 B+ (via PMIC)

TODO:
  - try to make bcm2835 firmware a bus driver

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../devicetree/bindings/hwmon/raspberrypi-hwmon.txt   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt

Comments

Robin Murphy May 16, 2018, 2:23 p.m. UTC | #1
On 16/05/18 14:37, Stefan Wahren wrote:
> Recent VC4 firmware provides a hardware-independent way to retrieve the
> under-voltage sensor on the following Raspberry Pi boards:
>    - Raspberry Pi B+ (via GPIO on SoC)
>    - Raspberry Pi A+ (via GPIO on SoC)
>    - Raspberry Pi 2 B (via GPIO on SoC)
>    - Raspberry Pi 3 B (via GPIO on port expander)
>    - Raspberry Pi 3 B+ (via PMIC)
> 
> TODO:
>    - try to make bcm2835 firmware a bus driver

Do you actually need a DT binding? From the probe routine in patch 2 it 
looks like this capability can be discovered dynamically by asking the 
firmware, therefore it might be more straightforward for the firmware 
driver itself to probe that and create a child device iff the feature is 
present, which the hwmon driver can then bind to as a pure platform driver.

Robin.

> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>   .../devicetree/bindings/hwmon/raspberrypi-hwmon.txt   | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> new file mode 100644
> index 0000000..ec2523f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> @@ -0,0 +1,19 @@
> +Raspberry Pi voltage sensor
> +---------------------------
> +
> +The VC4 firmware exposes a mailbox interface that allows the ARM core
> +to access the board's voltage sensor.
> +
> +Required properties :
> +- compatible : Should be "raspberrypi,bcm2835-hwmon"
> +
> +Example:
> +
> +firmware: firmware-rpi {
> +	compatible = "raspberrypi,bcm2835-firmware";
> +	mboxes = <&mailbox>;
> +
> +	voltage-sensor {
> +		compatible = "raspberrypi,bcm2835-hwmon";
> +	};
> +};
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guenter Roeck May 16, 2018, 2:52 p.m. UTC | #2
On Wed, May 16, 2018 at 03:37:03PM +0200, Stefan Wahren wrote:
> Recent VC4 firmware provides a hardware-independent way to retrieve the
> under-voltage sensor on the following Raspberry Pi boards:
>   - Raspberry Pi B+ (via GPIO on SoC)
>   - Raspberry Pi A+ (via GPIO on SoC)
>   - Raspberry Pi 2 B (via GPIO on SoC)
>   - Raspberry Pi 3 B (via GPIO on port expander)
>   - Raspberry Pi 3 B+ (via PMIC)
> 
> TODO:
>   - try to make bcm2835 firmware a bus driver
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  .../devicetree/bindings/hwmon/raspberrypi-hwmon.txt   | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> new file mode 100644
> index 0000000..ec2523f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
> @@ -0,0 +1,19 @@
> +Raspberry Pi voltage sensor
> +---------------------------
> +
> +The VC4 firmware exposes a mailbox interface that allows the ARM core
> +to access the board's voltage sensor.
> +
> +Required properties :
> +- compatible : Should be "raspberrypi,bcm2835-hwmon"

'hwmon' is very Linux specific. DT bindings are supposed to be
OS agnostic.

Guenter

> +
> +Example:
> +
> +firmware: firmware-rpi {
> +	compatible = "raspberrypi,bcm2835-firmware";
> +	mboxes = <&mailbox>;
> +
> +	voltage-sensor {
> +		compatible = "raspberrypi,bcm2835-hwmon";
> +	};
> +};
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Anholt May 16, 2018, 5:51 p.m. UTC | #3
Robin Murphy <robin.murphy@arm.com> writes:

> On 16/05/18 14:37, Stefan Wahren wrote:
>> Recent VC4 firmware provides a hardware-independent way to retrieve the
>> under-voltage sensor on the following Raspberry Pi boards:
>>    - Raspberry Pi B+ (via GPIO on SoC)
>>    - Raspberry Pi A+ (via GPIO on SoC)
>>    - Raspberry Pi 2 B (via GPIO on SoC)
>>    - Raspberry Pi 3 B (via GPIO on port expander)
>>    - Raspberry Pi 3 B+ (via PMIC)
>> 
>> TODO:
>>    - try to make bcm2835 firmware a bus driver
>
> Do you actually need a DT binding? From the probe routine in patch 2 it 
> looks like this capability can be discovered dynamically by asking the 
> firmware, therefore it might be more straightforward for the firmware 
> driver itself to probe that and create a child device iff the feature is 
> present, which the hwmon driver can then bind to as a pure platform driver.

Agreed, let's skip doing this in DT.  I just switched the bcm2835-camera
driver over to not need DT, and I think you could do something similar
(and use the pdev->dev.parent to get at the firmware device).
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
new file mode 100644
index 0000000..ec2523f
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/raspberrypi-hwmon.txt
@@ -0,0 +1,19 @@ 
+Raspberry Pi voltage sensor
+---------------------------
+
+The VC4 firmware exposes a mailbox interface that allows the ARM core
+to access the board's voltage sensor.
+
+Required properties :
+- compatible : Should be "raspberrypi,bcm2835-hwmon"
+
+Example:
+
+firmware: firmware-rpi {
+	compatible = "raspberrypi,bcm2835-firmware";
+	mboxes = <&mailbox>;
+
+	voltage-sensor {
+		compatible = "raspberrypi,bcm2835-hwmon";
+	};
+};