Skip to contentSkip to conversation

hwmon: Add StarFive JH7100 temperature sensor

PATCH In review Emil Renner Berthing 2 participants 7 messages Jul 26, 2021 – Aug 1, 2021

Subsystems (4)
lore
Share & tools
lore

Emil Renner Berthing

author maintainer
#0 lore raw

v3 cover hwmon: Add StarFive JH7100 temperature sensor

This adds a driver for the temperature sensor on the JH7100, a RISC-V SoC by StarFive Technology Co. Ltd., and most likely also the upcoming JH7110 version.

The SoC is used on the BeagleV Starlight board:
https://github.com/beagleboard/beaglev-starlight

Support for this SoC is not yet upstreamed, but is actively worked on, so it should only be a matter of time before that happens.

v3:
* Handle timeouts from wait_for_completion_interruptible_timeout properly.

v2:
* Fix checkpatch.pl --strict warnings
- Add myself to MAINTAINERS
- Fix multiline comments
- Use proper case and whitespace for #defines
- Add comment to sfctemp::lock mutex.
* Remaining comments by Guenter Roeck
- Add Documentation/hwmon/sfctemp.rst
- Use devm_add_action() and devm_hwmon_device_register_with_info() instead of a driver .remove function.
- Don't do test conversion at probe time.
- #include <linux/io.h>
- Remove unused #defines
- Use int return variable in sfctemp_convert().
* Add Samin's Signed-off-by to patch 2/2

Emil Renner Berthing (2):
dt-bindings: hwmon: add starfive,jh7100-temp bindings
hwmon: (sfctemp) Add StarFive JH7100 temperature sensor

 .../bindings/hwmon/starfive,jh7100-temp.yaml  |  43 +++
 Documentation/hwmon/index.rst                 |   1 +
 Documentation/hwmon/sfctemp.rst               |  32 ++
 MAINTAINERS                                   |   8 +
 drivers/hwmon/Kconfig                         |  10 +
 drivers/hwmon/Makefile                        |   1 +
 drivers/hwmon/sfctemp.c                       | 291 ++++++++++++++++++
 7 files changed, 386 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml
 create mode 100644 Documentation/hwmon/sfctemp.rst
 create mode 100644 drivers/hwmon/sfctemp.c
Signature · 1 line
2.32.0
author maintainer
#1 lore raw

PATCH v3 1/2 dt-bindings: hwmon: add starfive,jh7100-temp bindings

Add bindings for the temperature sensor on the StarFive JH7100 SoC.

---
 .../bindings/hwmon/starfive,jh7100-temp.yaml  | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml
Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml new file +43 -0
new file mode 100644
index 000000000000..5ca52c08d142
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/starfive,jh7100-temp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH7100 Temperature Sensor
+
+maintainers:
+  - Emil Renner Berthing <[email protected]>
+
+description: |
+  StarFive Technology Co. JH7100 embedded temperature sensor
+
+properties:
+  compatible:
+    enum:
+      - starfive,jh7100-temp
+
+  reg:
+    maxItems: 1
+
+  '#thermal-sensor-cells':
+    const: 0
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    tmon: tmon@124a0000 {
+        compatible = "starfive,jh7100-temp";
+        reg = <0x124a0000 0x10000>;
+        #thermal-sensor-cells = <0>;
+        interrupts = <122>;
+    };
Signature · 1 line
2.32.0
author maintainer
#2 lore raw

PATCH v3 2/2 hwmon: (sfctemp) Add StarFive JH7100 temperature sensor

In reply to Emil Renner Berthing

Register definitions and conversion constants based on sfctemp driver by Samin in the StarFive 5.10 kernel.

---
 Documentation/hwmon/index.rst   |   1 +
 Documentation/hwmon/sfctemp.rst |  32 ++++
 MAINTAINERS                     |   8 +
 drivers/hwmon/Kconfig           |  10 ++
 drivers/hwmon/Makefile          |   1 +
 drivers/hwmon/sfctemp.c         | 291 ++++++++++++++++++++++++++++++++
 6 files changed, 343 insertions(+)
 create mode 100644 Documentation/hwmon/sfctemp.rst
 create mode 100644 drivers/hwmon/sfctemp.c
Documentation/hwmon/index.rst +1 -0
index bc01601ea81a..961b6d93bead 100644
@@ -164,6 +164,7 @@ Hardware Monitoring Kernel Drivers
    sch5627
    sch5636
    scpi-hwmon
+   sfctemp
    sht15
    sht21
    sht3x
Documentation/hwmon/sfctemp.rst new file +32 -0
new file mode 100644
index 000000000000..465edce2fea5
@@ -0,0 +1,32 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver sfctemp
+=====================
+
+Supported chips:
+ - StarFive JH7100
+
+Authors:
+ - Emil Renner Berthing <[email protected]>
+
+Description
+-----------
+
+This driver adds support for reading the built-in temperature sensor on the
+JH7100 RISC-V SoC by StarFive Technology Co. Ltd.
+
+``sysfs`` interface
+-------------------
+
+The temperature sensor can be enabled, disabled and queried via the standard
+hwmon interface in sysfs under ``/sys/class/hwmon/hwmonX`` for some value of
+``X``:
+
+================ ==== =============================================
+Name             Perm Description
+================ ==== =============================================
+temp1_enable     RW   Enable or disable temperature sensor.
+                      Automatically enabled by the driver,
+                      but may be disabled to save power.
+temp1_input      RO   Temperature reading in milli-degrees Celsius.
+================ ==== =============================================
MAINTAINERS +8 -0
index 19135a9d778e..6fb1fd015c19 100644
@@ -16751,6 +16751,14 @@ L:	[email protected]
 S:	Supported
 F:	drivers/net/ethernet/sfc/
 
+SFCTEMP HWMON DRIVER
+M:	Emil Renner Berthing <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml
+F:	Documentation/hwmon/sfctemp.rst
+F:	drivers/hwmon/sfctemp.c
+
 SFF/SFP/SFP+ MODULE SUPPORT
 M:	Russell King <[email protected]>
 L:	[email protected]
drivers/hwmon/Kconfig +10 -0
index e3675377bc5d..ef3e345d6ce3 100644
@@ -1762,6 +1762,16 @@ config SENSORS_STTS751
 	  This driver can also be built as a module. If so, the module
 	  will be called stts751.
 
+config SENSORS_SFCTEMP
+	tristate "Starfive JH7100 temperature sensor"
+	depends on OF && (RISCV || COMPILE_TEST)
+	help
+	  If you say yes here you get support for temperature sensor
+	  on the Starfive JH7100 SoC.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called sfctemp.
+
 config SENSORS_SMM665
 	tristate "Summit Microelectronics SMM665"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index d712c61c1f5e..869f8806561e 100644
@@ -167,6 +167,7 @@ obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi_temp.o
 obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
 obj-$(CONFIG_SENSORS_SCH5627)	+= sch5627.o
 obj-$(CONFIG_SENSORS_SCH5636)	+= sch5636.o
+obj-$(CONFIG_SENSORS_SFCTEMP)	+= sfctemp.o
 obj-$(CONFIG_SENSORS_SL28CPLD)	+= sl28cpld-hwmon.o
 obj-$(CONFIG_SENSORS_SHT15)	+= sht15.o
 obj-$(CONFIG_SENSORS_SHT21)	+= sht21.o
drivers/hwmon/sfctemp.c new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
2.32.0
maintainer
#3 lore raw
In reply to Emil Renner Berthing
Quoted 10 lines · Emil Renner Berthing

This adds a driver for the temperature sensor on the JH7100, a RISC-V SoC by StarFive Technology Co. Ltd., and most likely also the upcoming JH7110 version.

The SoC is used on the BeagleV Starlight board:
https://github.com/beagleboard/beaglev-starlight

Support for this SoC is not yet upstreamed, but is actively worked on, so it should only be a matter of time before that happens.

Hmm, makes me wonder if I should apply the series now or later, when the chip is actually supported by the kernel. Comments/thoughts ?

Guenter

Quoted 36 lines

v3:
* Handle timeouts from wait_for_completion_interruptible_timeout properly.

v2:
* Fix checkpatch.pl --strict warnings
- Add myself to MAINTAINERS
- Fix multiline comments
- Use proper case and whitespace for #defines
- Add comment to sfctemp::lock mutex.
* Remaining comments by Guenter Roeck
- Add Documentation/hwmon/sfctemp.rst
- Use devm_add_action() and devm_hwmon_device_register_with_info() instead of a driver .remove function.
- Don't do test conversion at probe time.
- #include <linux/io.h>
- Remove unused #defines
- Use int return variable in sfctemp_convert().
* Add Samin's Signed-off-by to patch 2/2

Emil Renner Berthing (2):
dt-bindings: hwmon: add starfive,jh7100-temp bindings
hwmon: (sfctemp) Add StarFive JH7100 temperature sensor

  .../bindings/hwmon/starfive,jh7100-temp.yaml  |  43 +++
  Documentation/hwmon/index.rst                 |   1 +
  Documentation/hwmon/sfctemp.rst               |  32 ++
  MAINTAINERS                                   |   8 +
  drivers/hwmon/Kconfig                         |  10 +
  drivers/hwmon/Makefile                        |   1 +
  drivers/hwmon/sfctemp.c                       | 291 ++++++++++++++++++
  7 files changed, 386 insertions(+)

create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml create mode 100644 Documentation/hwmon/sfctemp.rst
create mode 100644 drivers/hwmon/sfctemp.c

author maintainer
#4 lore raw
Quoted 8 lines · Guenter Roeck
Quoted 7 lines · Emil Renner Berthing

This adds a driver for the temperature sensor on the JH7100, a RISC-V SoC by StarFive Technology Co. Ltd., and most likely also the upcoming JH7110 version.

The SoC is used on the BeagleV Starlight board:
https://github.com/beagleboard/beaglev-starlight

Quoted 8 lines
Quoted 3 lines

Support for this SoC is not yet upstreamed, but is actively worked on, so it should only be a matter of time before that happens.

Hmm, makes me wonder if I should apply the series now or later, when the chip is actually supported by the kernel. Comments/thoughts ?

Guenter

I'd of course love if it was applied now. That would at least mean fewer patches to rebase when keeping the beaglev patches [1] up to date, and I'd be very surprised if SoC support doesn't make it upstream eventually. But I'd also fully understand the position that this only makes sense to add when support for the SoC is upstream too. I'm adding Drew, as he might have something to say about this.

[1]: https://github.com/starfive-tech/linux/tree/beaglev

/Emil

Quoted 37 lines
Quoted 36 lines

v3:
* Handle timeouts from wait_for_completion_interruptible_timeout properly.

v2:
* Fix checkpatch.pl --strict warnings
- Add myself to MAINTAINERS
- Fix multiline comments
- Use proper case and whitespace for #defines
- Add comment to sfctemp::lock mutex.
* Remaining comments by Guenter Roeck
- Add Documentation/hwmon/sfctemp.rst
- Use devm_add_action() and devm_hwmon_device_register_with_info() instead of a driver .remove function.
- Don't do test conversion at probe time.
- #include <linux/io.h>
- Remove unused #defines
- Use int return variable in sfctemp_convert().
* Add Samin's Signed-off-by to patch 2/2

Emil Renner Berthing (2):
dt-bindings: hwmon: add starfive,jh7100-temp bindings
hwmon: (sfctemp) Add StarFive JH7100 temperature sensor

  .../bindings/hwmon/starfive,jh7100-temp.yaml  |  43 +++
  Documentation/hwmon/index.rst                 |   1 +
  Documentation/hwmon/sfctemp.rst               |  32 ++
  MAINTAINERS                                   |   8 +
  drivers/hwmon/Kconfig                         |  10 +
  drivers/hwmon/Makefile                        |   1 +
  drivers/hwmon/sfctemp.c                       | 291 ++++++++++++++++++
  7 files changed, 386 insertions(+)

create mode 100644 Documentation/devicetree/bindings/hwmon/starfive,jh7100-temp.yaml create mode 100644 Documentation/hwmon/sfctemp.rst
create mode 100644 drivers/hwmon/sfctemp.c

author maintainer
#5 lore raw
Quoted 16 lines · Emil Renner Berthing
Quoted 15 lines · Guenter Roeck
Quoted 10 lines · Emil Renner Berthing

This adds a driver for the temperature sensor on the JH7100, a RISC-V SoC by StarFive Technology Co. Ltd., and most likely also the upcoming JH7110 version.

The SoC is used on the BeagleV Starlight board:
https://github.com/beagleboard/beaglev-starlight

Support for this SoC is not yet upstreamed, but is actively worked on, so it should only be a matter of time before that happens.

Hmm, makes me wonder if I should apply the series now or later, when the chip is actually supported by the kernel. Comments/thoughts ?

Quoted 8 lines
Quoted 1 line

Guenter

I'd of course love if it was applied now. That would at least mean fewer patches to rebase when keeping the beaglev patches [1] up to date, and I'd be very surprised if SoC support doesn't make it upstream eventually. But I'd also fully understand the position that this only makes sense to add when support for the SoC is upstream too. I'm adding Drew, as he might have something to say about this.

Hi Guenter,

Things have changed. The BeagleBoard.org foundation is no longer planning to make any further boards using the JH7100 or upcoming JH7110 SoCs from StarFive. I still think support for the JH7100 will make it upstream eventually, but I'm no longer confident enough to recommend merging this before there are more concrete plans for the SoC. So thanks for the reviews. I'll repost it when I think it's time to consider it for upstream again.

/Emil

maintainer
#6 lore raw
Quoted 28 lines · Emil Renner Berthing
Quoted 16 lines · Emil Renner Berthing
Quoted 15 lines · Guenter Roeck
Quoted 10 lines · Emil Renner Berthing

This adds a driver for the temperature sensor on the JH7100, a RISC-V SoC by StarFive Technology Co. Ltd., and most likely also the upcoming JH7110 version.

The SoC is used on the BeagleV Starlight board:
https://github.com/beagleboard/beaglev-starlight

Support for this SoC is not yet upstreamed, but is actively worked on, so it should only be a matter of time before that happens.

Hmm, makes me wonder if I should apply the series now or later, when the chip is actually supported by the kernel. Comments/thoughts ?

Quoted 8 lines
Quoted 1 line

Guenter

I'd of course love if it was applied now. That would at least mean fewer patches to rebase when keeping the beaglev patches [1] up to date, and I'd be very surprised if SoC support doesn't make it upstream eventually. But I'd also fully understand the position that this only makes sense to add when support for the SoC is upstream too. I'm adding Drew, as he might have something to say about this.

Hi Guenter,

Quoted 8 lines

Things have changed. The BeagleBoard.org foundation is no longer planning to make any further boards using the JH7100 or upcoming JH7110 SoCs from StarFive. I still think support for the JH7100 will make it upstream eventually, but I'm no longer confident enough to recommend merging this before there are more concrete plans for the SoC. So thanks for the reviews. I'll repost it when I think it's time to consider it for upstream again.

Thanks for the update.

Guenter