* [PATCH 2/6] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
@ 2021-12-15 15:12 ` Jarkko Nikula
2021-12-16 21:17 ` Wolfram Sang
2021-12-15 15:12 ` [PATCH 3/6] i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage Jarkko Nikula
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jarkko Nikula @ 2021-12-15 15:12 UTC (permalink / raw)
To: linux-i2c
Cc: Wolfram Sang, Andy Shevchenko, Mika Westerberg,
Lakshmi Sowjanya D, Jarkko Nikula
From: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
The data type of hcnt and lcnt in the struct dw_i2c_dev is of type u16.
It's better to have same data type in struct dw_scl_sda_cfg as well.
Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 0f409a4c2da0..5b45941bcbdd 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -39,10 +39,10 @@ enum dw_pci_ctl_id_t {
};
struct dw_scl_sda_cfg {
- u32 ss_hcnt;
- u32 fs_hcnt;
- u32 ss_lcnt;
- u32 fs_lcnt;
+ u16 ss_hcnt;
+ u16 fs_hcnt;
+ u16 ss_lcnt;
+ u16 fs_lcnt;
u32 sda_hold;
};
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/6] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters
2021-12-15 15:12 ` [PATCH 2/6] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Jarkko Nikula
@ 2021-12-16 21:17 ` Wolfram Sang
0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2021-12-16 21:17 UTC (permalink / raw)
To: Jarkko Nikula
Cc: linux-i2c, Andy Shevchenko, Mika Westerberg, Lakshmi Sowjanya D
[-- Attachment #1: Type: text/plain, Size: 539 bytes --]
On Wed, Dec 15, 2021 at 05:12:01PM +0200, Jarkko Nikula wrote:
> From: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
>
> The data type of hcnt and lcnt in the struct dw_i2c_dev is of type u16.
> It's better to have same data type in struct dw_scl_sda_cfg as well.
>
> Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Added my Reported-by and applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/6] i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
2021-12-15 15:12 ` [PATCH 2/6] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Jarkko Nikula
@ 2021-12-15 15:12 ` Jarkko Nikula
2021-12-16 21:17 ` Wolfram Sang
2021-12-15 15:12 ` [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros Jarkko Nikula
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jarkko Nikula @ 2021-12-15 15:12 UTC (permalink / raw)
To: linux-i2c; +Cc: Wolfram Sang, Andy Shevchenko, Mika Westerberg, Jarkko Nikula
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Add a note about struct dw_scl_sda_cfg usage to discourage people
of using this structure on new platforms. Instead they should try
hard to put the needed information into firmware descriptions.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 5b45941bcbdd..f49c41ba5647 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -38,6 +38,13 @@ enum dw_pci_ctl_id_t {
navi_amd,
};
+/*
+ * This is a legacy structure to describe the hardware counters
+ * to configure signal timings on the bus. For Device Tree platforms
+ * one should use the respective properties and for ACPI there is
+ * a set of ACPI methods that provide these counters. No new
+ * platform should use this structure.
+ */
struct dw_scl_sda_cfg {
u16 ss_hcnt;
u16 fs_hcnt;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
2021-12-15 15:12 ` [PATCH 2/6] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Jarkko Nikula
2021-12-15 15:12 ` [PATCH 3/6] i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage Jarkko Nikula
@ 2021-12-15 15:12 ` Jarkko Nikula
2021-12-16 21:18 ` Wolfram Sang
2021-12-15 15:12 ` [PATCH 5/6] i2c: designware-pci: use __maybe_unused for PM functions Jarkko Nikula
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jarkko Nikula @ 2021-12-15 15:12 UTC (permalink / raw)
To: linux-i2c; +Cc: Wolfram Sang, Andy Shevchenko, Mika Westerberg, Jarkko Nikula
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
For better maintenance group MODULE_*() macros together.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index f49c41ba5647..021eee44fa3d 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -359,9 +359,6 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
pci_free_irq_vectors(pdev);
}
-/* work with hotplug and coldplug */
-MODULE_ALIAS("i2c_designware-pci");
-
static const struct pci_device_id i2_designware_pci_ids[] = {
/* Medfield */
{ PCI_VDEVICE(INTEL, 0x0817), medfield },
@@ -418,9 +415,11 @@ static struct pci_driver dw_i2c_driver = {
.pm = &i2c_dw_pm_ops,
},
};
-
module_pci_driver(dw_i2c_driver);
+/* Work with hotplug and coldplug */
+MODULE_ALIAS("i2c_designware-pci");
+
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter");
MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros
2021-12-15 15:12 ` [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros Jarkko Nikula
@ 2021-12-16 21:18 ` Wolfram Sang
2021-12-17 11:30 ` Andy Shevchenko
0 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2021-12-16 21:18 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: linux-i2c, Andy Shevchenko, Mika Westerberg
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
On Wed, Dec 15, 2021 at 05:12:03PM +0200, Jarkko Nikula wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> For better maintenance group MODULE_*() macros together.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> ---
Removed an empty line and applied to for-next, thanks!
> +MODULE_ALIAS("i2c_designware-pci");
> +
This one.
> MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros
2021-12-16 21:18 ` Wolfram Sang
@ 2021-12-17 11:30 ` Andy Shevchenko
0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2021-12-17 11:30 UTC (permalink / raw)
To: Wolfram Sang, Jarkko Nikula, linux-i2c, Mika Westerberg
On Thu, Dec 16, 2021 at 10:18:28PM +0100, Wolfram Sang wrote:
> On Wed, Dec 15, 2021 at 05:12:03PM +0200, Jarkko Nikula wrote:
> > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > For better maintenance group MODULE_*() macros together.
> Removed an empty line and applied to for-next, thanks!
Agree on the change and thanks!
> > +MODULE_ALIAS("i2c_designware-pci");
> > +
>
> This one.
>
> > MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/6] i2c: designware-pci: use __maybe_unused for PM functions
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
` (2 preceding siblings ...)
2021-12-15 15:12 ` [PATCH 4/6] i2c: designware-pci: Group MODULE_*() macros Jarkko Nikula
@ 2021-12-15 15:12 ` Jarkko Nikula
2021-12-16 21:18 ` Wolfram Sang
2021-12-15 15:12 ` [PATCH 6/6] i2c: designware-pci: Convert to use dev_err_probe() Jarkko Nikula
2021-12-16 21:17 ` [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Wolfram Sang
5 siblings, 1 reply; 13+ messages in thread
From: Jarkko Nikula @ 2021-12-15 15:12 UTC (permalink / raw)
To: linux-i2c; +Cc: Wolfram Sang, Andy Shevchenko, Mika Westerberg, Jarkko Nikula
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Use __maybe_unused for PM functions instead of ifdeffery.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
Jarkko: In my opinion this was worth to take before cleanups so hand
edited to apply to currect code.
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 021eee44fa3d..855ea666029f 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -213,8 +213,7 @@ static struct dw_pci_controller dw_pci_controllers[] = {
},
};
-#ifdef CONFIG_PM
-static int i2c_dw_pci_suspend(struct device *dev)
+static int __maybe_unused i2c_dw_pci_suspend(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
@@ -224,7 +223,7 @@ static int i2c_dw_pci_suspend(struct device *dev)
return 0;
}
-static int i2c_dw_pci_resume(struct device *dev)
+static int __maybe_unused i2c_dw_pci_resume(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
int ret;
@@ -234,7 +233,6 @@ static int i2c_dw_pci_resume(struct device *dev)
return ret;
}
-#endif
static UNIVERSAL_DEV_PM_OPS(i2c_dw_pm_ops, i2c_dw_pci_suspend,
i2c_dw_pci_resume, NULL);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/6] i2c: designware-pci: Convert to use dev_err_probe()
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
` (3 preceding siblings ...)
2021-12-15 15:12 ` [PATCH 5/6] i2c: designware-pci: use __maybe_unused for PM functions Jarkko Nikula
@ 2021-12-15 15:12 ` Jarkko Nikula
2021-12-16 21:18 ` Wolfram Sang
2021-12-16 21:17 ` [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Wolfram Sang
5 siblings, 1 reply; 13+ messages in thread
From: Jarkko Nikula @ 2021-12-15 15:12 UTC (permalink / raw)
To: linux-i2c; +Cc: Wolfram Sang, Andy Shevchenko, Mika Westerberg, Jarkko Nikula
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
Jarkko: In my opinion this was worth to take before cleanups so hand
edited to apply to current code. I split the dev_err_probe() lines
to have device pointer and error code in the first line and printable
string in the next for shorter lines.
While at it, change "invalid" -> "Invalid" (was before Andy's change).
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 24 +++++++++-------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 855ea666029f..6fde58878aa6 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -246,28 +246,24 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
struct dw_pci_controller *controller;
struct dw_scl_sda_cfg *cfg;
- if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) {
- dev_err(&pdev->dev, "%s: invalid driver data %ld\n", __func__,
- id->driver_data);
- return -EINVAL;
- }
+ if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers))
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "Invalid driver data %ld\n",
+ id->driver_data);
controller = &dw_pci_controllers[id->driver_data];
r = pcim_enable_device(pdev);
- if (r) {
- dev_err(&pdev->dev, "Failed to enable I2C PCI device (%d)\n",
- r);
- return r;
- }
+ if (r)
+ return dev_err_probe(&pdev->dev, r,
+ "Failed to enable I2C PCI device\n");
pci_set_master(pdev);
r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
- if (r) {
- dev_err(&pdev->dev, "I/O memory remapping failed\n");
- return r;
- }
+ if (r)
+ return dev_err_probe(&pdev->dev, r,
+ "I/O memory remapping failed\n");
dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL);
if (!dev)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt
2021-12-15 15:12 [PATCH 1/6] i2c: designware: Do not complete i2c read without RX_FULL interrupt Jarkko Nikula
` (4 preceding siblings ...)
2021-12-15 15:12 ` [PATCH 6/6] i2c: designware-pci: Convert to use dev_err_probe() Jarkko Nikula
@ 2021-12-16 21:17 ` Wolfram Sang
5 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2021-12-16 21:17 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: linux-i2c, Andy Shevchenko, Mika Westerberg, Tamal Saha
[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]
On Wed, Dec 15, 2021 at 05:12:00PM +0200, Jarkko Nikula wrote:
> From: Tamal Saha <tamal.saha@intel.com>
>
> Intel Keem Bay platform supports multi-master operations over same i2c
> bus using Synopsys i2c DesignWare IP. When multi-masters initiate i2c
> operation simultaneously in a loop, SCL line is stucked low forever
> after few i2c operations. Following interrupt sequences are observed
> in:
> working case: TX_EMPTY, RX_FULL and STOP_DET
> non working case: TX_EMPTY, STOP_DET, RX_FULL.
>
> DW_apb_i2c stretches the SCL line when the TX FIFO is empty or when
> RX FIFO is full. The DW_apb_i2c master will continue to hold the SCL
> line LOW until RX FIFO is read.
>
> Linux kernel i2c DesignWare driver does not handle above non working
> sequence. TX_EMPTY, RX_FULL and STOP_DET routine execution are required
> in sequence although RX_FULL interrupt is raised after STOP_DET by
> hardware. Clear STOP_DET for the following conditions:
> (STOP_DET ,RX_FULL, rx_outstanding)
> Write Operation: (1, 0, 0)
> Read Operation:
> RX_FULL followed by STOP_DET: (0, 1, 1) -> (1, 0, 0)
> STOP_DET followed by RX_FULL: (1, 0, 1) -> (1, 1, 0)
> RX_FULL and STOP_DET together: (1, 1, 1)
>
> Signed-off-by: Tamal Saha <tamal.saha@intel.com>
> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread