Skip to content

Commit 393bd10

Browse files
hkallweitgregkh
authored andcommitted
eeprom: ee1004: add support for temperature sensor
The EE1004 SPD data structure advertises the presence of a thermal sensor on a DDR4 module in byte 14, 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. Patch was successfully tested with a Corsair Vengeance RGB PRO DDR4 module which comes with a thermal sensor. Link: https://www.spinics.net/lists/linux-i2c/msg65963.html 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 a6c7e01 commit 393bd10

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/misc/eeprom/ee1004.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,22 @@ static struct bin_attribute *ee1004_attrs[] = {
182182

183183
BIN_ATTRIBUTE_GROUPS(ee1004);
184184

185+
static void ee1004_probe_temp_sensor(struct i2c_client *client)
186+
{
187+
struct i2c_board_info info = { .type = "jc42" };
188+
u8 byte14;
189+
int ret;
190+
191+
/* byte 14, bit 7 is set if temp sensor is present */
192+
ret = ee1004_eeprom_read(client, &byte14, 14, 1);
193+
if (ret != 1 || !(byte14 & BIT(7)))
194+
return;
195+
196+
info.addr = 0x18 | (client->addr & 7);
197+
198+
i2c_new_client_device(client->adapter, &info);
199+
}
200+
185201
static void ee1004_cleanup(int idx, struct ee1004_bus_data *bd)
186202
{
187203
if (--bd->dev_count == 0) {
@@ -234,6 +250,9 @@ static int ee1004_probe(struct i2c_client *client)
234250
dev_dbg(&client->dev, "Currently selected page: %d\n", err);
235251
bd->current_page = err;
236252
}
253+
254+
ee1004_probe_temp_sensor(client);
255+
237256
mutex_unlock(&ee1004_bus_lock);
238257

239258
dev_info(&client->dev,

0 commit comments

Comments
 (0)