Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) Kernel driver w83791d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) Supported chips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)   * Winbond W83791D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)     Prefix: 'w83791d'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)     Addresses scanned: I2C 0x2c - 0x2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)     Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83791D_W83791Gb.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) Author: Charles Spirakis <bezaur@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) This driver was derived from the w83781d.c and w83792d.c source files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) Credits:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)   w83781d.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)     - Frodo Looijaard <frodol@dds.nl>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)     - Philip Edelbrock <phil@netroedge.com>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)     - Mark Studebaker <mdsxyz123@yahoo.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)   w83792d.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)     - Shane Huang (Winbond),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)     - Rudolf Marek <r.marek@assembler.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) Additional contributors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)     - Sven Anders <anders@anduras.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)     - Marc Hulsman <m.hulsman@tudelft.nl>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) Module Parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) * init boolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)     (default 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)     Use 'init=1' to have the driver do extra software initializations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)     The default behavior is to do the minimum initialization possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)     and depend on the BIOS to properly setup the chip. If you know you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)     have a w83791d and you're having problems, try init=1 before trying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)     reset=1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) * reset boolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)     (default 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)     Use 'reset=1' to reset the chip (via index 0x40, bit 7). The default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     behavior is no chip reset to preserve BIOS settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) * force_subclients=bus,caddr,saddr,saddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)     This is used to force the i2c addresses for subclients of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     a certain chip. Example usage is `force_subclients=0,0x2f,0x4a,0x4b`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)     to force the subclients of chip 0x2f on bus 0 to i2c addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)     0x4a and 0x4b.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) This driver implements support for the Winbond W83791D chip. The W83791G
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) chip appears to be the same as the W83791D but is lead free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) Detection of the chip can sometimes be foiled because it can be in an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) internal state that allows no clean access (Bank with ID register is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) currently selected). If you know the address of the chip, use a 'force'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) parameter; this will put it into a more well-behaved state first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) The driver implements three temperature sensors, ten voltage sensors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) five fan rotation speed sensors and manual PWM control of each fan.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) Temperatures are measured in degrees Celsius and measurement resolution is 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) the temperature gets higher than the Overtemperature Shutdown value; it stays
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) on until the temperature falls below the Hysteresis value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) Voltage sensors (also known as IN sensors) report their values in millivolts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) An alarm is triggered if the voltage has crossed a programmable minimum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) or maximum limit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) triggered if the rotation speed has dropped below a programmable limit. Fan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) readings can be divided by a programmable divider (1, 2, 4, 8, 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 32, 64 or 128 for all fans) to give the readings more range or accuracy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) Each fan controlled is controlled by PWM. The PWM duty cycle can be read and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) set for each fan separately. Valid values range from 0 (stop) to 255 (full).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) PWM 1-3 support Thermal Cruise mode, in which the PWMs are automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) regulated to keep respectively temp 1-3 at a certain target temperature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) See below for the description of the sysfs-interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) The w83791d has a global bit used to enable beeping from the speaker when an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) alarm is triggered as well as a bitmask to enable or disable the beep for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) specific alarms. You need both the global beep enable bit and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) corresponding beep bit to be on for a triggered alarm to sound a beep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) The sysfs interface to the global enable is via the sysfs beep_enable file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) This file is used for both legacy and new code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) The sysfs interface to the beep bitmask has migrated from the original legacy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) method of a single sysfs beep_mask file to a newer method using multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) `*_beep` files as described in `Documentation/hwmon/sysfs-interface.rst`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) A similar change has occurred for the bitmap corresponding to the alarms. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) original legacy method used a single sysfs alarms file containing a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) of triggered alarms. The newer method uses multiple sysfs `*_alarm` files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) (again following the pattern described in sysfs-interface).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) Since both methods read and write the underlying hardware, they can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) interchangeably and changes in one will automatically be reflected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) the other. If you use the legacy bitmask method, your user-space code is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) responsible for handling the fact that the alarms and beep_mask bitmaps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) are not the same (see the table below).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) NOTE: All new code should be written to use the newer sysfs-interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) specification as that avoids bitmap problems and is the preferred interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) going forward.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) The driver reads the hardware chip values at most once every three seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) User mode code requesting values more often will receive cached values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /sys files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) The sysfs-interface is documented in the 'sysfs-interface' file. Only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) chip-specific options are documented here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ======================= =======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) pwm[1-3]_enable		this file controls mode of fan/temperature control for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			fan 1-3. Fan/PWM 4-5 only support manual mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			    * 1 Manual mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			    * 2 Thermal Cruise mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			    * 3 Fan Speed Cruise mode (no further support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) temp[1-3]_target	defines the target temperature for Thermal Cruise mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) temp[1-3]_tolerance	temperature tolerance for Thermal Cruise mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			Specifies an interval around the target temperature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			in which the fan speed is not changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ======================= =======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) Alarms bitmap vs. beep_mask bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) -----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) For legacy code using the alarms and beep_mask files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) =============  ========  ========= ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) Signal         Alarms    beep_mask Obs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) =============  ========  ========= ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) in0 (VCORE)    0x000001  0x000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) in1 (VINR0)    0x000002  0x002000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) in2 (+3.3VIN)  0x000004  0x000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) in3 (5VDD)     0x000008  0x000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) in4 (+12VIN)   0x000100  0x000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) in5 (-12VIN)   0x000200  0x000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) in6 (-5VIN)    0x000400  0x000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) in7 (VSB)      0x080000  0x010000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) in8 (VBAT)     0x100000  0x020000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) in9 (VINR1)    0x004000  0x004000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) temp1          0x000010  0x000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) temp2          0x000020  0x000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) temp3          0x002000  0x000002  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) fan1           0x000040  0x000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) fan2           0x000080  0x000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) fan3           0x000800  0x000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) fan4           0x200000  0x200000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) fan5           0x400000  0x400000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) tart1          0x010000  0x040000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) tart2          0x020000  0x080000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) tart3          0x040000  0x100000  <== mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) case_open      0x001000  0x001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) global_enable  -         0x800000  (modified via beep_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) =============  ========  ========= ==========================