Skip to content

Commit

Permalink
Merge pull request torvalds#191 from nascs/Radxa_cm3_rpi_cm4_io_emc2305
Browse files Browse the repository at this point in the history
hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Spee…
  • Loading branch information
RadxaYuntian authored Aug 23, 2023
2 parents 73bb55e + 02e34fc commit 22d04b0
Show file tree
Hide file tree
Showing 6 changed files with 878 additions and 0 deletions.
106 changes: 106 additions & 0 deletions Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---

$id: http://devicetree.org/schemas/hwmon/microchip,emc2305.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Microchip EMC2305 RPM-based PWM Fan Speed Controller

maintainers:
- Michael Shych <michaelsh@nvidia.com>

description: |
Microchip EMC2301/2/3/5 are RPM-based PWM Fan Controller.
The Fan Controller supports up to 5 independently controlled PWM fan drives.
Fan rotation speeds are reported in RPM.
Datasheet: https://www.microchip.com/en-us/product/EMC2305
additionalProperties: false

properties:
compatible:
enum:
- microchip,emc2305
- microchip,emc2303
- microchip,emc2302
- microchip,emc2301

reg:
maxItems: 1

"#address-cells":
const: 1

"#size-cells":
const: 0

microchip,cooling-levels:
description:
Quantity of cooling level state.
$ref: /schemas/types.yaml#/definitions/uint8
minimum: 0
maximum: 255

microchip,pwm-separate:
description:
This flag indicates that separate PWM setting will be used
for different channels.
$ref: /schemas/types.yaml#/definitions/flag

patternProperties:
"^channel@[0-4]$":
type: object

additionalProperties: false

properties:
reg:
items:
- enum:
- 0
- 1
- 2
- 3
- 4

pwm-min:
description:
Min pwm of emc2305 channel
$ref: /schemas/types.yaml#/definitions/uint8
minimum: 0
maximum: 255

required:
- reg

required:
- compatible


examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
fan-controller@4d {
compatible = "microchip,emc2305";
reg = <0x4d>;
#address-cells = <1>;
#size-cells = <0>;
microchip,pwm-separate;
microchip,cooling-levels = /bits/ 8 <10>;
channel@0 {
reg = <0>;
pwm-min = /bits/ 8 <0>;
};
channel@1 {
reg = <1>;
pwm-min = /bits/ 8 <0>;
};
};
};
40 changes: 40 additions & 0 deletions Documentation/hwmon/emc2305.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. SPDX-License-Identifier: GPL-2.0
Kernel driver emc2305
=====================

Supported chips:
Microchip EMC2305, EMC2303, EMC2302, EMC2301

Addresses scanned: I2C 0x27, 0x2c, 0x2d, 0x2e, 0x2f, 0x4c, 0x4d
Prefixes: 'emc2305'

Datasheet: Publicly available at the Microchip website :
https://www.microchip.com/en-us/product/EMC2305

Description:
-----------
This driver implements support for Microchip EMC2301/2/3/5 RPM-based PWM Fan Controller.
The EMC2305 Fan Controller supports up to 5 independently controlled PWM fan drives.
Fan rotation speeds are reported in RPM.
The driver supports the RPM-based PWM control to keep a fan at the desired speed.
The driver provides the possibility to have one common PWM interface for all FANs
or up to the maximum available or configured independent PWMs.

The driver provides the following sysfs interfaces in hwmon subsystem:

================= == ===================================================
fan[1-5]_fault RO files for tachometers TACH1-TACH5 fault indication
fan[1-5]_input RO files for tachometers TACH1-TACH5 input (in RPM)
pwm[1-5] RW file for fan[1-5] target duty cycle (0..255)
================= == ===================================================

sysfs interfaces in thermal subsystem:

================= == ========================================================================
cur_state RW file for the current cooling state of the cooling device (0..max_state)
max_state RO file for the maximum cooling state of the cooling device
================= == ========================================================================

Configuration is possible via device tree:
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
1 change: 1 addition & 0 deletions Documentation/hwmon/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Hardware Monitoring Kernel Drivers
ds620
emc1403
emc2103
emc2305
emc6w201
f71805f
f71882fg
Expand Down
13 changes: 13 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,19 @@ config SENSORS_EMC2103
This driver can also be built as a module. If so, the module
will be called emc2103.

config SENSORS_EMC2305
tristate "Microchip EMC2305 and compatible EMC2301/2/3"
depends on I2C
imply THERMAL
help
If you say yes here you get support for the Microchip EMC2305
fan controller chips.
The Microchip EMC2305 is a fan controller for up to 5 fans.
Fan rotation speeds are reported in RPM.

This driver can also be built as a module. If so, the module
will be called emc2305.

config SENSORS_EMC6W201
tristate "SMSC EMC6W201"
depends on I2C
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ obj-$(CONFIG_SENSORS_DS620) += ds620.o
obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o
obj-$(CONFIG_SENSORS_EMC2103) += emc2103.o
obj-$(CONFIG_SENSORS_EMC2305) += emc2305.o
obj-$(CONFIG_SENSORS_EMC6W201) += emc6w201.o
obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
obj-$(CONFIG_SENSORS_F71882FG) += f71882fg.o
Expand Down
Loading

0 comments on commit 22d04b0

Please sign in to comment.