From 34e8ebf95a6b3fdefc97f9bfa18b1c06cbbd6180 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Mon, 2 Jun 2025 10:48:45 +0000 Subject: [PATCH 1/3] misc: amd-apml: Probe sbtsi device as per instance ID - From Fam: 0x1A, Model: 0x50, SBTSI device instance ID is 0, additionally PID for each silicon is different. SBRMI and SBTSI device PID's difference is in Instance ID. Modify the probe condition on basis of PID for legacy platform and on instance ID from Fam:0x1A Model:0x50. Reviewed-by: Naveen Krishna Chatradhi Signed-off-by: Akshay Gupta --- drivers/misc/amd-apml/apml_sbtsi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/misc/amd-apml/apml_sbtsi.c b/drivers/misc/amd-apml/apml_sbtsi.c index 64389739a431be..5209a243603d38 100644 --- a/drivers/misc/amd-apml/apml_sbtsi.c +++ b/drivers/misc/amd-apml/apml_sbtsi.c @@ -301,10 +301,8 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev) struct regmap *regmap; dev_err(dev, "SBTSI: PID: %llx\n", i3cdev->desc->info.pid); - if (!((i3cdev->desc->info.pid == 0x0) || (i3cdev->desc->info.pid == 0x22400000001) || - (i3cdev->desc->info.pid == 0x118) || (i3cdev->desc->info.pid == 0x010118) || - (i3cdev->desc->info.pid == 0x01000118) || (i3cdev->desc->info.pid == 0x01010118))) - { + if (!(I3C_PID_INSTANCE_ID(i3cdev->desc->info.pid) == 0 || + i3cdev->desc->info.pid == 0x22400000001)) { dev_err(dev, "SBTSI: Error PID: %llx\n", i3cdev->desc->info.pid); return -ENXIO; } From 5ce60dbc289a1cd09946e7ec7771446986c02b80 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Mon, 2 Jun 2025 10:51:38 +0000 Subject: [PATCH 2/3] misc: amd-apml: Add device IDs for Fam:0x1A, Fam:0x50 - SBRMI/TSI devices for new APML has PID as per below description. [11:0] Additional ID: 0x118 [15:12] SB-TSI(0x0) [31:16] [16]: DIE_ID, [25:24]: SOCKET ID sock 0 die 0: 0x0 sock 0 die 1: 0x1 sock 1 die 0: 0x100 sock 1 die 1: 0x101 [32]: PID type select, it is 0 now to select fixed vendor value; [47:33]: Manufacture ID, MIPI alliance has allocated the value for each company, AMD should be 0x0112 Reviewed-by: Naveen Krishna Chatradhi Signed-off-by: Akshay Gupta --- drivers/misc/amd-apml/apml_sbtsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/misc/amd-apml/apml_sbtsi.c b/drivers/misc/amd-apml/apml_sbtsi.c index 5209a243603d38..28cea9b82ddb3c 100644 --- a/drivers/misc/amd-apml/apml_sbtsi.c +++ b/drivers/misc/amd-apml/apml_sbtsi.c @@ -421,6 +421,10 @@ static const struct i3c_device_id sbtsi_i3c_id[] = { I3C_DEVICE_EXTRA_INFO(0, 0x0101, 0x118, NULL), /* P1 - IOD1 - SBTSI */ I3C_DEVICE_EXTRA_INFO(0x112, 0, 0x1, NULL), I3C_DEVICE_EXTRA_INFO(0, 0x0, 0x0, NULL), + I3C_DEVICE_EXTRA_INFO(0x112, 0x0, 0x118, NULL), /* Socket:0, IOD:0 */ + I3C_DEVICE_EXTRA_INFO(0x112, 0x1, 0x118, NULL), /* Socket:0, IOD:1 */ + I3C_DEVICE_EXTRA_INFO(0x112, 0x100, 0x118, NULL), /* Socket:1 IOD:0 */ + I3C_DEVICE_EXTRA_INFO(0x112, 0x101, 0x118, NULL), /* Socket:1 IOD:1 */ {} }; MODULE_DEVICE_TABLE(i3c, sbtsi_i3c_id); From 9472f3253d23e5fdc331b16969d827112d4f2502 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Mon, 2 Jun 2025 14:45:38 +0000 Subject: [PATCH 3/3] misc: amd-apml: Update label for hwmon entry to include socket_iod ID Data name label under hwmon for i2c is sbtsi and for i3c is sbtsi_i3c. In multi socket, this makes difficult to distinguish between socket 0 and socket 1. Hwmon entry names are updated for i2c/i3c to sbtsi_X.Y, where X is socket index and Y is IOD index in the socket Reviewed-by: Naveen Krishna Chatradhi Signed-off-by: Akshay Gupta --- drivers/misc/amd-apml/apml_sbtsi.c | 39 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/misc/amd-apml/apml_sbtsi.c b/drivers/misc/amd-apml/apml_sbtsi.c index 28cea9b82ddb3c..3bdd06c037d102 100644 --- a/drivers/misc/amd-apml/apml_sbtsi.c +++ b/drivers/misc/amd-apml/apml_sbtsi.c @@ -267,6 +267,23 @@ static const struct file_operations sbtsi_fops = { .compat_ioctl = sbtsi_ioctl, }; +/* Convert the static address to socket_die index */ +static const char *sbtsi_addr_to_label(u8 addr) +{ + switch (addr) { + case 0x44: + return "0.1"; + case 0x45: + return "1.1"; + case 0x48: + return "1.0"; + case 0x4c: + return "0.0"; + default: + return NULL; + } +} + static int create_misc_tsi_device(struct apml_sbtsi_device *tsi_dev, struct device *dev) { @@ -299,6 +316,7 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev) .val_bits = 8, }; struct regmap *regmap; + const char *hwmon_dev_name; dev_err(dev, "SBTSI: PID: %llx\n", i3cdev->desc->info.pid); if (!(I3C_PID_INSTANCE_ID(i3cdev->desc->info.pid) == 0 || @@ -324,8 +342,14 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev) tsi_dev->regmap = regmap; mutex_init(&tsi_dev->lock); + /* Need to verify for the static address for i3cdev */ + tsi_dev->dev_static_addr = i3cdev->desc->info.static_addr; + + hwmon_dev_name = devm_kasprintf(dev, GFP_KERNEL, "sbtsi_%s", + sbtsi_addr_to_label(tsi_dev->dev_static_addr)); + dev_set_drvdata(dev, (void *)tsi_dev); - hwmon_dev = devm_hwmon_device_register_with_info(dev, "sbtsi_i3c", tsi_dev, + hwmon_dev = devm_hwmon_device_register_with_info(dev, hwmon_dev_name, tsi_dev, &sbtsi_chip_info, NULL); if (!hwmon_dev) @@ -334,9 +358,6 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev) return PTR_ERR_OR_ZERO(hwmon_dev); } - /* Need to verify for the static address for i3cdev */ - tsi_dev->dev_static_addr = i3cdev->desc->info.static_addr; - return create_misc_tsi_device(tsi_dev, dev); } @@ -354,6 +375,7 @@ static int sbtsi_i2c_probe(struct i2c_client *client) .reg_bits = 8, .val_bits = 8, }; + const char *hwmon_dev_name; tsi_dev = devm_kzalloc(dev, sizeof(struct apml_sbtsi_device), GFP_KERNEL); if (!tsi_dev) @@ -366,7 +388,12 @@ static int sbtsi_i2c_probe(struct i2c_client *client) dev_set_drvdata(dev, (void *)tsi_dev); - hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, + tsi_dev->dev_static_addr = client->addr; + + hwmon_dev_name = devm_kasprintf(dev, GFP_KERNEL, "sbtsi_%s", + sbtsi_addr_to_label(tsi_dev->dev_static_addr)); + + hwmon_dev = devm_hwmon_device_register_with_info(dev, hwmon_dev_name, tsi_dev, &sbtsi_chip_info, NULL); @@ -374,8 +401,6 @@ static int sbtsi_i2c_probe(struct i2c_client *client) if (!hwmon_dev) return PTR_ERR_OR_ZERO(hwmon_dev); - tsi_dev->dev_static_addr = client->addr; - return create_misc_tsi_device(tsi_dev, dev); }