ddr4: read word instead of SMBus Block Read for all TS SPDs
While JEDEC 21-C 4.1.6 uses the term "block read", it has little to do with the SMBus Block Read protocol; instead, it is closer to the SMBus Read Word protocol, except in big endianess. Fixes: #400 ("Corsair memory protocol error")
This commit is contained in:
parent
c08656e1a1
commit
70630c6d3d
|
@ -231,7 +231,14 @@ class Ddr4Temperature(SmbusDriver):
|
|||
]
|
||||
|
||||
def _read_temperature_register(self):
|
||||
return self._smbus.read_block_data(self._ts_address, self._REG_TEMPERATURE)
|
||||
# while JEDEC 21-C 4.1.6 uses the term "block read", it has little to
|
||||
# do with the SMBus Block Read protocol; instead, it is closer to the
|
||||
# SMBus Read Word protocol, except in big endianess
|
||||
treg = self._smbus.read_word_data(self._ts_address, self._REG_TEMPERATURE)
|
||||
|
||||
# swap LSB and MSB before returning: read_word_data reads in little
|
||||
# endianess, but the register must be read in big endianess
|
||||
return ((treg & 0xff) << 8) | (treg >> 8)
|
||||
|
||||
def initialize(self, **kwargs):
|
||||
"""Initialize the device."""
|
||||
|
@ -302,14 +309,6 @@ class VengeanceRgb(Ddr4Temperature):
|
|||
|
||||
return 'Corsair Vengeance RGB'
|
||||
|
||||
def _read_temperature_register(self):
|
||||
# instead of using block reads, Vengeance RGB temperature sensor
|
||||
# devices must be read in words
|
||||
treg = self._smbus.read_word_data(self._ts_address, self._REG_TEMPERATURE)
|
||||
|
||||
# swap LSB and MSB before returning: read_word_data reads in little
|
||||
# endianess, but the register should be read in big endianess
|
||||
return ((treg & 0xff) << 8) | (treg >> 8)
|
||||
|
||||
def set_color(self, channel, mode, colors, speed='normal',
|
||||
transition_ticks=None, stable_ticks=None, **kwargs):
|
||||
|
|
|
@ -146,7 +146,7 @@ def test_tse2004_get_status_reads_temperature(smbus):
|
|||
dimm = next(Ddr4Temperature.probe(smbus))
|
||||
|
||||
with dimm.connect(unsafe=enable):
|
||||
smbus.write_block_data(0x19, 0x05, 0xe19c)
|
||||
smbus.write_word_data(0x19, 0x05, 0x9ce1)
|
||||
|
||||
status = dimm.get_status(unsafe=enable)
|
||||
expected = [
|
||||
|
@ -162,7 +162,7 @@ def test_tse2004_get_status_reads_negative_temperature(smbus):
|
|||
dimm = next(Ddr4Temperature.probe(smbus))
|
||||
|
||||
with dimm.connect(unsafe=enable):
|
||||
smbus.write_block_data(0x19, 0x05, 0x1e74)
|
||||
smbus.write_word_data(0x19, 0x05, 0x741e)
|
||||
|
||||
status = dimm.get_status(unsafe=enable)
|
||||
expected = [
|
||||
|
|
Loading…
Reference in New Issue