Skip to contentSkip to conversation

eeprom: ee1004: add support for temperature sensor

RFC PATCH In review Heiner Kallweit 2 participants 3 messages Nov 15, 2023 – Dec 19, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 eeprom: ee1004: add support for temperature sensor

Jean and me are discussing how to best instantiate temperature sensors that can be found on RAM modules. First idea was to extend i2c_register_spd() but I think reading the "temp sensor present" flag from SPD can't be properly done from an i2c core level. Therefore, for DDR4, do it from the ee1004 driver.

The temp sensor i2c address can be derived from the SPD i2c address, so I think 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.

---
 drivers/misc/eeprom/ee1004.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/misc/eeprom/ee1004.c +19 -0
index a1acd7713..4bce8f9d9 100644
@@ -158,6 +158,22 @@ static struct bin_attribute *ee1004_attrs[] = {
 
 BIN_ATTRIBUTE_GROUPS(ee1004);
 
+static void ee1004_probe_temp_sensor(struct i2c_client *client)
+{
+	struct i2c_board_info info = { .type = "jc42" };
+	u8 byte14;
+	int ret;
+
+	/* byte 14, bit 7 is set if temp sensor is present */
+	ret = ee1004_eeprom_read(client, &byte14, 14, 1);
+	if (ret != 1 || !(byte14 & BIT(7)))
+		return;
+
+	info.addr = 0x18 | (client->addr & 7);
+
+	i2c_new_client_device(client->adapter, &info);
+}
+
 static void ee1004_cleanup(int idx)
 {
 	if (--ee1004_dev_count == 0)
@@ -204,6 +220,9 @@ static int ee1004_probe(struct i2c_client *client)
 		err = -EOPNOTSUPP;
 		goto err_clients;
 	}
+
+	ee1004_probe_temp_sensor(client);
+
 	mutex_unlock(&ee1004_bus_lock);
 
 	dev_info(&client->dev,
Signature · 1 line
2.42.1
#1 lore raw
Quoted 47 lines · Heiner Kallweit

Jean and me are discussing how to best instantiate temperature sensors that can be found on RAM modules. First idea was to extend i2c_register_spd() but I think reading the "temp sensor present" flag from SPD can't be properly done from an i2c core level. Therefore, for DDR4, do it from the ee1004 driver.

The temp sensor i2c address can be derived from the SPD i2c address, so I think 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.

---
 drivers/misc/eeprom/ee1004.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/misc/eeprom/ee1004.c +16 -0
index a1acd7713..4bce8f9d9 100644
@@ -158,6 +158,22 @@ static struct bin_attribute *ee1004_attrs[] = {
 
 BIN_ATTRIBUTE_GROUPS(ee1004);
 
+static void ee1004_probe_temp_sensor(struct i2c_client *client)
+{
+	struct i2c_board_info info = { .type = "jc42" };
+	u8 byte14;
+	int ret;
+
+	/* byte 14, bit 7 is set if temp sensor is present */
+	ret = ee1004_eeprom_read(client, &byte14, 14, 1);
+	if (ret != 1 || !(byte14 & BIT(7)))
+		return;
+
+	info.addr = 0x18 | (client->addr & 7);
+
+	i2c_new_client_device(client->adapter, &info);
+}
+
 static void ee1004_cleanup(int idx)
 {
 	if (--ee1004_dev_count == 0)

drivers/misc/eeprom/ee1004.c static int ee1004_probe(struct i2c_client *client) · line 228

Quoted 9 lines
drivers/misc/eeprom/ee1004.c +3 -0
@@ -204,6 +220,9 @@ static int ee1004_probe(struct i2c_client *client)
 		err = -EOPNOTSUPP;
 		goto err_clients;
 	}
+
+	ee1004_probe_temp_sensor(client);
+
 	mutex_unlock(&ee1004_bus_lock);
 
 	dev_info(&client->dev,

Jean, do you have any feedback on this one?
Also not sure why this patch is marked "superseded" in patchwork.

#2 lore raw
Quoted 2 lines

Also not sure why this patch is marked "superseded" in patchwork.

Mistake on my side. Should have been "RFC".

Now on to your other patches...