linux/drivers/hwmon/pmbus
Andrew Jeffery d206636e76 hwmon: (pmbus) Add fan control support
Expose fanX_target, pwmX and pwmX_enable hwmon sysfs attributes.

Fans in a PMBus device are driven by the configuration of two registers,
FAN_CONFIG_x_y and FAN_COMMAND_x: FAN_CONFIG_x_y dictates how the fan
and the tacho operate (if installed), while FAN_COMMAND_x sets the
desired fan rate. The unit of FAN_COMMAND_x is dependent on the
operational fan mode, RPM or PWM percent duty, as determined by the
corresponding configuration in FAN_CONFIG_x_y.

The mapping of fanX_target, pwmX and pwmX_enable onto FAN_CONFIG_x_y and
FAN_COMMAND_x is implemented with the addition of virtual registers to
facilitate the necessary side-effects of each access:

1. PMBUS_VIRT_FAN_TARGET_x
2. PMBUS_VIRT_PWM_x
3. PMBUS_VIRT_PWM_ENABLE_x

Some complexity arises with the fanX_target and pwmX attributes both mapping
onto FAN_COMMAND_x: There is no general mapping between PWM percent duty and
RPM, so we can't display values in either attribute in terms of the other
(which in my mind is the intuitive, if impossible, behaviour). This problem
also affects the pwmX_enable attribute which allows userspace to switch between
full speed, manual PWM and a number of automatic control modes, possibly
including a switch to RPM behaviour (e.g. automatically adjusting PWM duty to
reach a RPM target, the behaviour of fanX_target).

The next most intuitive behaviour is for fanX_target and pwmX to simply be
independent, to retain their most recently set value even if that value is not
active on the hardware (due to switching to the alternative control mode). This
property of retaining the value independent of the hardware state has useful
results for both userspace and the kernel: Userspace always sees a sensible
value in the attribute (the last thing it was set to, as opposed to 0 or
receiving an error on read), and the kernel can use the attributes as a value
cache. This latter point eases the implementation of pwmX_enable, which can
look up the associated pmbus_sensor object, take its cached value and apply it
to hardware on changing control mode. This ensures we will not arbitrarily set
a PWM value as an RPM value or vice versa, and we can assume that the RPM or
PWM value set was sensible at least at some point in the past.

Finally, the DIRECT mode coefficients of some controllers is different between
RPM and PWM percent duty control modes, so PSC_PWM is introduced to capture the
necessary coefficients. As pmbus core had no PWM support previously PSC_FAN
continues to be used to capture the RPM DIRECT coefficients, but in order to
avoid falsely applying RPM scaling to PWM values I have introduced the
PMBUS_HAVE_PWM12 and PMB_BUS_HAVE_PWM34 feature bits. These feature bits allow
drivers to explicitly declare PWM support in order to have the attributes
exposed.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-01-02 15:05:34 -08:00
..
adm1275.c driver: (adm1275) set the m,b and R coefficients correctly for power 2017-03-27 19:43:36 -07:00
ibm-cffps.c hwmon: (pmbus) Add IBM Common Form Factor (CFF) power supply driver 2017-08-29 18:06:18 -07:00
ir35221.c hwmon: (pmbus) Add client driver for IR35221 2017-06-11 17:08:19 -07:00
Kconfig pmbus: Add driver for Maxim MAX31785 Intelligent Fan Controller 2017-11-05 06:06:33 -08:00
lm25066.c hwmon: (pmbus/lm25066) Drop support for LM25063 2018-01-02 15:05:34 -08:00
ltc2978.c hwmon: (ltc2978) Add support for LTM4675 2015-08-19 09:08:55 -07:00
ltc3815.c hwmon: (pmbus) Add client driver for LTC3815 2015-12-18 08:20:59 -08:00
Makefile hwmon updates for v4.15 2017-11-13 08:55:46 -08:00
max8688.c hwmon: (pmbus) Use BIT macro 2015-08-19 09:08:17 -07:00
max16064.c hwmon: (pmbus) Simplify remove functions 2012-03-18 18:27:46 -07:00
max20751.c hwmon: (pmbus) Add support for MAX20751 2015-08-09 13:44:27 -07:00
max31785.c pmbus: Add driver for Maxim MAX31785 Intelligent Fan Controller 2017-11-05 06:06:33 -08:00
max34440.c hwmon: (pmbus) Use BIT macro 2015-08-19 09:08:17 -07:00
pmbus_core.c hwmon: (pmbus) Add fan control support 2018-01-02 15:05:34 -08:00
pmbus.c hwmon: (pmbus) move header file out of I2C realm 2017-06-11 17:08:19 -07:00
pmbus.h hwmon: (pmbus) Add fan control support 2018-01-02 15:05:34 -08:00
tps40422.c hwmon: (pmbus) Add tps40422 front-end driver 2014-08-04 07:01:38 -07:00
tps53679.c hwmon: (pmbus) Add support for Texas Instruments tps53679 device 2017-08-30 18:01:08 -07:00
ucd9000.c hwmon: (pmbus) move header file out of I2C realm 2017-06-11 17:08:19 -07:00
ucd9200.c hwmon: (pmbus) move header file out of I2C realm 2017-06-11 17:08:19 -07:00
zl6100.c hwmon: (pmbus) Use BIT macro 2015-08-19 09:08:17 -07:00