Skip to contentSkip to conversation

i2c: i801: fix DNV's SMBCTRL register offset

PATCH Superseded Felipe Balbi 3 participants 6 messages Sep 3, 2018 – Sep 4, 2018

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

PATCH 1/1 i2c: i801: fix DNV's SMBCTRL register offset

DNV's iTCO is slightly different with SMBCTRL sitting at a differnt offset when compared to all other devices. Let's fix so that we can properly use iTCO watchdog.

Fixes 84d7f2ebd70d ("i2c: i801: Add support for Intel DNV")
Cc <[email protected]> # v4.4+
---
 drivers/i2c/busses/i2c-i801.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/i2c/busses/i2c-i801.c +5 -0
index 941c223f6491..390bf253b6ea 100644
@@ -1400,6 +1400,11 @@ static void i801_add_tco(struct i801_priv *priv)
 
 	res = &tco_res[ICH_RES_MEM_OFF];
 	res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+
+	/* DNV device has SMBCTRL at 0xcf000c */
+	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
+		res->start += 0x90000;
+
 	res->end = res->start + 3;
 	res->flags = IORESOURCE_MEM;
 
Signature · 1 line
2.18.0
#1 lore raw

Hi Felipe,

Quoted 17 lines · Felipe Balbi

DNV's iTCO is slightly different with SMBCTRL sitting at a differnt offset when compared to all other devices. Let's fix so that we can properly use iTCO watchdog.

Fixes 84d7f2ebd70d ("i2c: i801: Add support for Intel DNV")
Cc <[email protected]> # v4.4+
---
 drivers/i2c/busses/i2c-i801.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/i2c/busses/i2c-i801.c +0 -0
index 941c223f6491..390bf253b6ea 100644
@@ -1400,6 +1400,11 @@ static void i801_add_tco(struct i801_priv *priv)
 

drivers/i2c/busses/i2c-i801.c static void i801_add_tco(struct i801_priv *priv) · line 1410

Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +5 -0
 	res = &tco_res[ICH_RES_MEM_OFF];
 	res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+
+	/* DNV device has SMBCTRL at 0xcf000c */
+	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
+		res->start += 0x90000;
+
 	res->end = res->start + 3;
 	res->flags = IORESOURCE_MEM;
 

Thanks for catching this but this is not the way I want it to be fixed. Applying an arbitrary offset like that is pretty obscure and fragile too. The value of SMBCTRL for DNV should instead appear explicitly in the code. Something like that:

#define SBREG_SMBCTRL 0xc6000c
#define SBREG_SMBCTRL_DNV 0xcf000c

	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
	else
		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;

Alternatively you can add a member to struct i801_priv to store the register address in i801_probe(), and use that in i801_add_tco(). The above defines could even go away then. Both approaches are fine with me.

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#2 lore raw

PATCH v2 1/1 i2c: i801: fix DNV's SMBCTRL register offset

DNV's iTCO is slightly different with SMBCTRL sitting at a differnt offset when compared to all other devices. Let's fix so that we can properly use iTCO watchdog.

Fixes 84d7f2ebd70d ("i2c: i801: Add support for Intel DNV")
Cc <[email protected]> # v4.4+

---

Changes since v1:
- explicitly define DNV's register instead of adding an offset

 drivers/i2c/busses/i2c-i801.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +6 -1
index 941c223f6491..bdff45f99a56 100644
@@ -140,6 +140,7 @@
 
 #define SBREG_BAR		0x10
 #define SBREG_SMBCTRL		0xc6000c
+#define SBREG_SMBCTRL_DNV	0xcf000c
 
 /* Host status bits for SMBPCISTS */
 #define SMBPCISTS_INTS		BIT(3)
@@ -1399,7 +1400,11 @@ static void i801_add_tco(struct i801_priv *priv)
 	spin_unlock(&p2sb_spinlock);
 
 	res = &tco_res[ICH_RES_MEM_OFF];
-	res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
+		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
+	else
+		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+
 	res->end = res->start + 3;
 	res->flags = IORESOURCE_MEM;
 
Signature · 1 line
2.18.0
Reviewed-by on v2 1/1
#3 lore raw
Quoted 1 line · Felipe Balbi

DNV's iTCO is slightly different with SMBCTRL sitting at a differnt

Typo: different.

Quoted 29 lines

offset when compared to all other devices. Let's fix so that we can properly use iTCO watchdog.

Fixes 84d7f2ebd70d ("i2c: i801: Add support for Intel DNV")
Cc <[email protected]> # v4.4+

---

Changes since v1:
- explicitly define DNV's register instead of adding an offset

 drivers/i2c/busses/i2c-i801.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +1 -0
index 941c223f6491..bdff45f99a56 100644
@@ -140,6 +140,7 @@
 
 #define SBREG_BAR		0x10
 #define SBREG_SMBCTRL		0xc6000c
+#define SBREG_SMBCTRL_DNV	0xcf000c
 
 /* Host status bits for SMBPCISTS */
 #define SMBPCISTS_INTS		BIT(3)
@@ -1399,7 +1400,11 @@ static void i801_add_tco(struct i801_priv *priv)
 	spin_unlock(&p2sb_spinlock);
 

drivers/i2c/busses/i2c-i801.c static void i801_add_tco(struct i801_priv *priv) · line 1410

Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +5 -1
 	res = &tco_res[ICH_RES_MEM_OFF];
-	res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
+		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
+	else
+		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+
 	res->end = res->start + 3;
 	res->flags = IORESOURCE_MEM;
 

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#4 lore raw
Quoted 4 lines · Jean Delvare
Quoted 1 line · Felipe Balbi

DNV's iTCO is slightly different with SMBCTRL sitting at a differnt

Typo: different.

I'll fix it when applying.