Skip to contentSkip to conversation

hwmon: Add PEC support to the lm90 driver

PATCH New Greg KH 1 participant 1 message Oct 29, 2005

Subsystems (3)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 hwmon: Add PEC support to the lm90 driver

[PATCH] hwmon: Add PEC support to the lm90 driver

Add PEC support to the lm90 driver. Only the ADM1032 chip supports it, and in a rather tricky way, which is why this patch comes with documentation reinforcements. At least, this demonstrates that the new PEC support logic in i2c-core can properly deal with chips with partial PEC support.

As enabling PEC causes a significant performance drop, it can be disabled through a sysfs file (unsurprisingly named "pec").

---
commit c3df5806cdae6fac678c662b527cb974bef4b60c
tree a510da8447852247907dd6896cdf51c7e3d60844
parent 8256fe0f40f1cd72f80f2c46fe0ab1638f03a98d
author Jean Delvare <[email protected]> Wed, 26 Oct 2005 21:39:40 +0200 committer Greg Kroah-Hartman <[email protected]> Fri, 28 Oct 2005 14:02:14 -0700

 Documentation/hwmon/lm90            |   39 +++++++++++++++++++++++-
 Documentation/hwmon/sysfs-interface |    3 ++
 drivers/hwmon/lm90.c                |   57 ++++++++++++++++++++++++++++++++++-
 3 files changed, 96 insertions(+), 3 deletions(-)
Documentation/hwmon/lm90 +37 -2
index 2c4cf39..70abf93 100644
@@ -71,8 +71,8 @@ increased resolution of the remote tempe
 
 The different chipsets of the family are not strictly identical, although
 very similar. This driver doesn't handle any specific feature for now,
-but could if there ever was a need for it. For reference, here comes a
-non-exhaustive list of specific features:
+with the exception of SMBus PEC. For reference, here comes a non-exhaustive
+list of specific features:
 
 LM90:
   * Filter and alert configuration register at 0xBF.
@@ -91,6 +91,7 @@ ADM1032:
   * Conversion averaging.
   * Up to 64 conversions/s.
   * ALERT is triggered by open remote sensor.
+  * SMBus PEC support for Write Byte and Receive Byte transactions.
 
 ADT7461
   * Extended temperature range (breaks compatibility)
@@ -119,3 +120,37 @@ The lm90 driver will not update its valu
 other second; reading them more often will do no harm, but will return
 'old' values.
 
+PEC Support
+-----------
+
+The ADM1032 is the only chip of the family which supports PEC. It does
+not support PEC on all transactions though, so some care must be taken.
+
+When reading a register value, the PEC byte is computed and sent by the
+ADM1032 chip. However, in the case of a combined transaction (SMBus Read
+Byte), the ADM1032 computes the CRC value over only the second half of
+the message rather than its entirety, because it thinks the first half
+of the message belongs to a different transaction. As a result, the CRC
+value differs from what the SMBus master expects, and all reads fail.
+
+For this reason, the lm90 driver will enable PEC for the ADM1032 only if
+the bus supports the SMBus Send Byte and Receive Byte transaction types.
+These transactions will be used to read register values, instead of
+SMBus Read Byte, and PEC will work properly.
+
+Additionally, the ADM1032 doesn't support SMBus Send Byte with PEC.
+Instead, it will try to write the PEC value to the register (because the
+SMBus Send Byte transaction with PEC is similar to a Write Byte transaction
+without PEC), which is not what we want. Thus, PEC is explicitely disabled
+on SMBus Send Byte transactions in the lm90 driver.
+
+PEC on byte data transactions represents a significant increase in bandwidth
+usage (+33% for writes, +25% for reads) in normal conditions. With the need
+to use two SMBus transaction for reads, this overhead jumps to +50%. Worse,
+two transactions will typically mean twice as much delay waiting for
+transaction completion, effectively doubling the register cache refresh time.
+I guess reliability comes at a price, but it's quite expensive this time.
+
+So, as not everyone might enjoy the slowdown, PEC can be disabled through
+sysfs. Just write 0 to the "pec" file and PEC will be disabled. Write 1
+to that file to enable PEC again.
Documentation/hwmon/sysfs-interface +3 -0
index 3464005..764cdc5 100644
@@ -272,3 +272,6 @@ beep_mask	Bitmask for beep.
 
 eeprom		Raw EEPROM data in binary form.
 		Read only.
+
+pec		Enable or disable PEC (SMBus only)
+		Read/Write
drivers/hwmon/lm90.c +56 -1

83 lines not on this page · raw message