Skip to content

Commit caba40e

Browse files
hkallweitgregkh
authored andcommitted
eeprom: at24: Probe for DDR3 thermal sensor in the SPD case
The DDR3 SPD data structure advertises the presence of a thermal sensor on a DDR3 module in byte 32, bit 7. Let's use this information to explicitly instantiate the thermal sensor I2C client instead of having to rely on class-based I2C probing. The temp sensor i2c address can be derived from the SPD i2c address, so we can directly instantiate the device and don't have to probe for it. If the temp sensor has been instantiated already by other means (e.g. class-based auto-detection), then the busy-check in i2c_new_client_device will detect this. Note: Thermal sensors on DDR4 DIMM's are instantiated from the ee1004 driver. Signed-off-by: Heiner Kallweit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 393bd10 commit caba40e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,31 @@ static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len)
563563
}
564564
}
565565

566+
static void at24_probe_temp_sensor(struct i2c_client *client)
567+
{
568+
struct at24_data *at24 = i2c_get_clientdata(client);
569+
struct i2c_board_info info = { .type = "jc42" };
570+
int ret;
571+
u8 val;
572+
573+
/*
574+
* Byte 2 has value 11 for DDR3, earlier versions don't
575+
* support the thermal sensor present flag
576+
*/
577+
ret = at24_read(at24, 2, &val, 1);
578+
if (ret || val != 11)
579+
return;
580+
581+
/* Byte 32, bit 7 is set if temp sensor is present */
582+
ret = at24_read(at24, 32, &val, 1);
583+
if (ret || !(val & BIT(7)))
584+
return;
585+
586+
info.addr = 0x18 | (client->addr & 7);
587+
588+
i2c_new_client_device(client->adapter, &info);
589+
}
590+
566591
static int at24_probe(struct i2c_client *client)
567592
{
568593
struct regmap_config regmap_config = { };
@@ -762,6 +787,10 @@ static int at24_probe(struct i2c_client *client)
762787
}
763788
}
764789

790+
/* If this a SPD EEPROM, probe for DDR3 thermal sensor */
791+
if (cdata == &at24_data_spd)
792+
at24_probe_temp_sensor(client);
793+
765794
pm_runtime_idle(dev);
766795

767796
if (writable)

0 commit comments

Comments
 (0)