linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: fix DNV's SMBCTRL register offset
@ 2018-09-03  5:37 Felipe Balbi
  2018-09-03  7:09 ` Jean Delvare
  0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2018-09-03  5:37 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-i2c, Felipe Balbi, stable

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: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/i2c/busses/i2c-i801.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 941c223f6491..390bf253b6ea 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -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;
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: i801: fix DNV's SMBCTRL register offset
  2018-09-03  5:37 [PATCH] i2c: i801: fix DNV's SMBCTRL register offset Felipe Balbi
@ 2018-09-03  7:09 ` Jean Delvare
  2018-09-03  8:24   ` [PATCH v2] " Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Delvare @ 2018-09-03  7:09 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-i2c, stable, Mika Westerberg, Jarkko Nikula

Hi Felipe,

On Mon,  3 Sep 2018 08:37:05 +0300, Felipe Balbi wrote:
> 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: <stable@vger.kernel.org> # v4.4+
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-i801.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 941c223f6491..390bf253b6ea 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -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;
>  

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.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] i2c: i801: fix DNV's SMBCTRL register offset
  2018-09-03  7:09 ` Jean Delvare
@ 2018-09-03  8:24   ` Felipe Balbi
  2018-09-03  9:02     ` Jean Delvare
  2018-09-04 16:04     ` Wolfram Sang
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Balbi @ 2018-09-03  8:24 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-i2c, Felipe Balbi, stable

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: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---

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(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 941c223f6491..bdff45f99a56 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -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;
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: i801: fix DNV's SMBCTRL register offset
  2018-09-03  8:24   ` [PATCH v2] " Felipe Balbi
@ 2018-09-03  9:02     ` Jean Delvare
  2018-09-03  9:04       ` Wolfram Sang
  2018-09-04 16:04     ` Wolfram Sang
  1 sibling, 1 reply; 6+ messages in thread
From: Jean Delvare @ 2018-09-03  9:02 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-i2c, stable, Mika Westerberg, Jarkko Nikula

On Mon,  3 Sep 2018 11:24:57 +0300, Felipe Balbi wrote:
> DNV's iTCO is slightly different with SMBCTRL sitting at a differnt

Typo: different.

> 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: <stable@vger.kernel.org> # v4.4+
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 941c223f6491..bdff45f99a56 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -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;
>  

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Thanks,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: i801: fix DNV's SMBCTRL register offset
  2018-09-03  9:02     ` Jean Delvare
@ 2018-09-03  9:04       ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2018-09-03  9:04 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Felipe Balbi, linux-i2c, stable, Mika Westerberg, Jarkko Nikula

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

On Mon, Sep 03, 2018 at 11:02:51AM +0200, Jean Delvare wrote:
> On Mon,  3 Sep 2018 11:24:57 +0300, Felipe Balbi wrote:
> > DNV's iTCO is slightly different with SMBCTRL sitting at a differnt
> 
> Typo: different.

I'll fix it when applying.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: i801: fix DNV's SMBCTRL register offset
  2018-09-03  8:24   ` [PATCH v2] " Felipe Balbi
  2018-09-03  9:02     ` Jean Delvare
@ 2018-09-04 16:04     ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2018-09-04 16:04 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Jean Delvare, linux-i2c, stable

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

On Mon, Sep 03, 2018 at 11:24:57AM +0300, Felipe Balbi wrote:
> 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: <stable@vger.kernel.org> # v4.4+
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-04 16:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-03  5:37 [PATCH] i2c: i801: fix DNV's SMBCTRL register offset Felipe Balbi
2018-09-03  7:09 ` Jean Delvare
2018-09-03  8:24   ` [PATCH v2] " Felipe Balbi
2018-09-03  9:02     ` Jean Delvare
2018-09-03  9:04       ` Wolfram Sang
2018-09-04 16:04     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).