* [PATCH v2 00/12] i2c: designware: code consolidation & cleanups
@ 2023-11-09 18:19 Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() Andy Shevchenko
` (11 more replies)
0 siblings, 12 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
The series now consists the following subseries of patches:
- refactoring module alias and device ID tables (patches 1-2)
- unifying firmware parsing and configuring code (patches 3-7)
- miscellaneous cleanups (patches 8-11)
- consolidating PM ops (patch 12)
The last one might be considered as rft, however I don't think we
have any hardware where the behaviour will be changed, anyways, good
to test.
v1: https://lore.kernel.org/r/20230725143023.86325-1-andriy.shevchenko@linux.intel.com
Changelog v2:
- reworked the series to make it less twisted (Jarkko, Andi)
- added tags to the patches that have been rebased (Andi, Mario, Jarkko)
- introduced a few new changes (PM ops, export namespace)
Andy Shevchenko (12):
i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
i2c: designware: Always provide device ID tables
i2c: designware: Drop return value from i2c_dw_acpi_configure()
i2c: designware: Drop return value from dw_i2c_of_configure()
i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
i2c: designware: Consolidate firmware parsing and configuring code
i2c: desingware: Unify the firmware type checks
i2c: designware: Move exports to I2C_DW namespaces
i2c: designware: Get rid of redundant 'else'
i2c: designware: Fix spelling and other issues in the comments
i2c: designware: Remove ->disable() callback
i2c: designware: Consolidate PM ops
drivers/i2c/busses/i2c-designware-amdpsp.c | 10 +-
drivers/i2c/busses/i2c-designware-common.c | 150 ++++++++++++++--
drivers/i2c/busses/i2c-designware-core.h | 25 +--
drivers/i2c/busses/i2c-designware-master.c | 19 +-
drivers/i2c/busses/i2c-designware-pcidrv.c | 62 +------
drivers/i2c/busses/i2c-designware-platdrv.c | 183 +++++---------------
drivers/i2c/busses/i2c-designware-slave.c | 10 +-
7 files changed, 216 insertions(+), 243 deletions(-)
--
2.40.0.1996.gbec44491f096
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 20:33 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 02/12] i2c: designware: Always provide device ID tables Andy Shevchenko
` (10 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
As Krzysztof Kozlowski pointed out the better is to use
MODULE_DEVICE_TABLE() as it will be consistent with the content
of the real ID table of the platform devices.
While at it, drop unneeded and unused module alias in PCI glue
driver as PCI already has its own ID table and automatic loading
should just work.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-pcidrv.c | 2 --
drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 61d7a27aa070..bfafebecf680 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -424,8 +424,6 @@ static struct pci_driver dw_i2c_driver = {
};
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");
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 855b698e99c0..cb7796b57085 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -479,8 +479,11 @@ static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
};
-/* Work with hotplug and coldplug */
-MODULE_ALIAS("platform:i2c_designware");
+static const struct platform_device_id dw_i2c_platform_ids[] = {
+ { "i2c_designware" },
+ {}
+};
+MODULE_DEVICE_TABLE(platform, dw_i2c_platform_ids);
static struct platform_driver dw_i2c_driver = {
.probe = dw_i2c_plat_probe,
@@ -491,6 +494,7 @@ static struct platform_driver dw_i2c_driver = {
.acpi_match_table = ACPI_PTR(dw_i2c_acpi_match),
.pm = pm_ptr(&dw_i2c_dev_pm_ops),
},
+ .id_table = dw_i2c_platform_ids,
};
static int __init dw_i2c_init_driver(void)
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 02/12] i2c: designware: Always provide device ID tables
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
` (9 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
There is no need to have ugly ifdeffery and additional macros
for the device ID tables. Always provide them. Since we touch
the ACPI table, make it sorted by ID. Unify termination as well.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 62 ++++++++++-----------
1 file changed, 30 insertions(+), 32 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index cb7796b57085..7d960d3161c0 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -40,28 +40,6 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
return clk_get_rate(dev->clk) / KILO;
}
-#ifdef CONFIG_ACPI
-static const struct acpi_device_id dw_i2c_acpi_match[] = {
- { "INT33C2", 0 },
- { "INT33C3", 0 },
- { "INT3432", 0 },
- { "INT3433", 0 },
- { "80860F41", ACCESS_NO_IRQ_SUSPEND },
- { "808622C1", ACCESS_NO_IRQ_SUSPEND },
- { "AMD0010", ACCESS_INTR_MASK },
- { "AMDI0010", ACCESS_INTR_MASK },
- { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
- { "AMDI0510", 0 },
- { "APMC0D0F", 0 },
- { "HISI02A1", 0 },
- { "HISI02A2", 0 },
- { "HISI02A3", 0 },
- { "HYGO0010", ACCESS_INTR_MASK },
- { }
-};
-MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
-#endif
-
#ifdef CONFIG_OF
#define BT1_I2C_CTL 0x100
#define BT1_I2C_CTL_ADDR_MASK GENMASK(7, 0)
@@ -148,14 +126,6 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
return 0;
}
-
-static const struct of_device_id dw_i2c_of_match[] = {
- { .compatible = "snps,designware-i2c", },
- { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
- { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
- {},
-};
-MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
{
@@ -479,6 +449,34 @@ static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
};
+static const struct of_device_id dw_i2c_of_match[] = {
+ { .compatible = "snps,designware-i2c", },
+ { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
+ { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
+ {}
+};
+MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
+
+static const struct acpi_device_id dw_i2c_acpi_match[] = {
+ { "INT33C2", 0 },
+ { "INT33C3", 0 },
+ { "INT3432", 0 },
+ { "INT3433", 0 },
+ { "80860F41", ACCESS_NO_IRQ_SUSPEND },
+ { "808622C1", ACCESS_NO_IRQ_SUSPEND },
+ { "AMD0010", ACCESS_INTR_MASK },
+ { "AMDI0010", ACCESS_INTR_MASK },
+ { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
+ { "AMDI0510", 0 },
+ { "APMC0D0F", 0 },
+ { "HISI02A1", 0 },
+ { "HISI02A2", 0 },
+ { "HISI02A3", 0 },
+ { "HYGO0010", ACCESS_INTR_MASK },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
+
static const struct platform_device_id dw_i2c_platform_ids[] = {
{ "i2c_designware" },
{}
@@ -490,8 +488,8 @@ static struct platform_driver dw_i2c_driver = {
.remove_new = dw_i2c_plat_remove,
.driver = {
.name = "i2c_designware",
- .of_match_table = of_match_ptr(dw_i2c_of_match),
- .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match),
+ .of_match_table = dw_i2c_of_match,
+ .acpi_match_table = dw_i2c_acpi_match,
.pm = pm_ptr(&dw_i2c_dev_pm_ops),
},
.id_table = dw_i2c_platform_ids,
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure()
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 02/12] i2c: designware: Always provide device ID tables Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 20:35 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
` (8 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
i2c_dw_acpi_configure() is called without checking of the returned
value, hence just drop it by converting to void.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 4 +---
drivers/i2c/busses/i2c-designware-core.h | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index affcfb243f0f..8d2223d164e3 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -255,7 +255,7 @@ static void i2c_dw_acpi_params(struct device *device, char method[],
kfree(buf.pointer);
}
-int i2c_dw_acpi_configure(struct device *device)
+void i2c_dw_acpi_configure(struct device *device)
{
struct dw_i2c_dev *dev = dev_get_drvdata(device);
struct i2c_timings *t = &dev->timings;
@@ -285,8 +285,6 @@ int i2c_dw_acpi_configure(struct device *device)
dev->sda_hold_time = fs_ht;
break;
}
-
- return 0;
}
EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index a7f6f3eafad7..f4dc08139624 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -397,7 +397,7 @@ int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
#if IS_ENABLED(CONFIG_ACPI)
-int i2c_dw_acpi_configure(struct device *device);
+void i2c_dw_acpi_configure(struct device *device);
#else
-static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; }
+static inline void i2c_dw_acpi_configure(struct device *device) { }
#endif
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure()
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (2 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 20:36 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
` (7 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
dw_i2c_of_configure() is called without checking of the returned
value, hence just drop it by converting to void.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 7d960d3161c0..af772a2c7fb6 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -110,7 +110,7 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
return 0;
}
-static int dw_i2c_of_configure(struct platform_device *pdev)
+static void dw_i2c_of_configure(struct platform_device *pdev)
{
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
@@ -123,8 +123,6 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
default:
break;
}
-
- return 0;
}
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
@@ -132,9 +130,8 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
return -ENODEV;
}
-static inline int dw_i2c_of_configure(struct platform_device *pdev)
+static inline void dw_i2c_of_configure(struct platform_device *pdev)
{
- return -ENODEV;
}
#endif
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (3 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 20:41 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 06/12] i2c: designware: Consolidate firmware parsing and configuring code Andy Shevchenko
` (6 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
For the sake of consistency, rename dw_i2c_of_configure() and change
its parameter to be aligned with the i2c_dw_acpi_configure().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index af772a2c7fb6..c55fff3df8ca 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -110,9 +110,10 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
return 0;
}
-static void dw_i2c_of_configure(struct platform_device *pdev)
+static void i2c_dw_of_configure(struct device *device)
{
- struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(device);
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
switch (dev->flags & MODEL_MASK) {
case MODEL_MSCC_OCELOT:
@@ -130,7 +131,7 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
return -ENODEV;
}
-static inline void dw_i2c_of_configure(struct platform_device *pdev)
+static inline void i2c_dw_of_configure(struct device *device)
{
}
#endif
@@ -279,7 +280,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
i2c_dw_adjust_bus_speed(dev);
if (pdev->dev.of_node)
- dw_i2c_of_configure(pdev);
+ i2c_dw_of_configure(&pdev->dev);
if (has_acpi_companion(&pdev->dev))
i2c_dw_acpi_configure(&pdev->dev);
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 06/12] i2c: designware: Consolidate firmware parsing and configuring code
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (4 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 07/12] i2c: desingware: Unify the firmware type checks Andy Shevchenko
` (5 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
We have the same code flows in the PCI and plaform drivers. Moreover,
the flow requires the common code to export a few functions. Instead,
consolidate that flow under new function called
i2c_dw_fw_parse_and_configure() and drop unneeded exports.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 68 +++++++++++++++++++--
drivers/i2c/busses/i2c-designware-core.h | 9 +--
drivers/i2c/busses/i2c-designware-pcidrv.c | 11 +---
drivers/i2c/busses/i2c-designware-platdrv.c | 48 +--------------
4 files changed, 66 insertions(+), 70 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 8d2223d164e3..a5cae814a9c2 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/swab.h>
@@ -188,7 +189,7 @@ static const u32 supported_speeds[] = {
I2C_MAX_STANDARD_MODE_FREQ,
};
-int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
+static int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
unsigned int i;
@@ -208,7 +209,44 @@ int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
return -EINVAL;
}
-EXPORT_SYMBOL_GPL(i2c_dw_validate_speed);
+
+#ifdef CONFIG_OF
+
+#include <linux/platform_device.h>
+
+#define MSCC_ICPU_CFG_TWI_DELAY 0x0
+#define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0)
+#define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4
+
+static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
+{
+ writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE,
+ dev->ext + MSCC_ICPU_CFG_TWI_DELAY);
+
+ return 0;
+}
+
+static void i2c_dw_of_configure(struct device *device)
+{
+ struct platform_device *pdev = to_platform_device(device);
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ switch (dev->flags & MODEL_MASK) {
+ case MODEL_MSCC_OCELOT:
+ dev->ext = devm_platform_ioremap_resource(pdev, 1);
+ if (!IS_ERR(dev->ext))
+ dev->set_sda_hold_time = mscc_twi_set_sda_hold_time;
+ break;
+ default:
+ break;
+ }
+}
+
+#else /* CONFIG_OF */
+
+static inline void i2c_dw_of_configure(struct device *device) { }
+
+#endif /* CONFIG_OF */
#ifdef CONFIG_ACPI
@@ -255,7 +293,7 @@ static void i2c_dw_acpi_params(struct device *device, char method[],
kfree(buf.pointer);
}
-void i2c_dw_acpi_configure(struct device *device)
+static void i2c_dw_acpi_configure(struct device *device)
{
struct dw_i2c_dev *dev = dev_get_drvdata(device);
struct i2c_timings *t = &dev->timings;
@@ -286,7 +324,6 @@ void i2c_dw_acpi_configure(struct device *device)
break;
}
}
-EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
{
@@ -308,11 +345,13 @@ static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
#else /* CONFIG_ACPI */
+static inline void i2c_dw_acpi_configure(struct device *device) { }
+
static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
#endif /* CONFIG_ACPI */
-void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
+static void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
{
u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev);
struct i2c_timings *t = &dev->timings;
@@ -328,7 +367,24 @@ void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
else
t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
}
-EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed);
+
+int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
+{
+ struct i2c_timings *t = &dev->timings;
+ struct device *device = dev->dev;
+
+ i2c_parse_fw_timings(device, t, false);
+
+ i2c_dw_adjust_bus_speed(dev);
+
+ if (device->of_node)
+ i2c_dw_of_configure(device);
+ if (has_acpi_companion(device))
+ i2c_dw_acpi_configure(device);
+
+ return i2c_dw_validate_speed(dev);
+}
+EXPORT_SYMBOL_GPL(i2c_dw_fw_parse_and_configure);
u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
{
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index f4dc08139624..a2731179a42b 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -393,11 +393,4 @@ int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev);
int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev);
#endif
-int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
-void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
-
-#if IS_ENABLED(CONFIG_ACPI)
-void i2c_dw_acpi_configure(struct device *device);
-#else
-static inline void i2c_dw_acpi_configure(struct device *device) { }
-#endif
+int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index bfafebecf680..2e6c7bfb5bf7 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -253,7 +253,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
int r;
struct dw_pci_controller *controller;
struct dw_scl_sda_cfg *cfg;
- struct i2c_timings *t;
if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers))
return dev_err_probe(&pdev->dev, -EINVAL,
@@ -288,9 +287,6 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
dev->irq = pci_irq_vector(pdev, 0);
dev->flags |= controller->flags;
- t = &dev->timings;
- i2c_parse_fw_timings(&pdev->dev, t, false);
-
pci_set_drvdata(pdev, dev);
if (controller->setup) {
@@ -301,12 +297,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
}
}
- i2c_dw_adjust_bus_speed(dev);
-
- if (has_acpi_companion(&pdev->dev))
- i2c_dw_acpi_configure(&pdev->dev);
-
- r = i2c_dw_validate_speed(dev);
+ r = i2c_dw_fw_parse_and_configure(dev);
if (r) {
pci_free_irq_vectors(pdev);
return r;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index c55fff3df8ca..0b6d6f2b6198 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -21,7 +21,6 @@
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
-#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
@@ -97,43 +96,11 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg);
return PTR_ERR_OR_ZERO(dev->map);
}
-
-#define MSCC_ICPU_CFG_TWI_DELAY 0x0
-#define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0)
-#define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4
-
-static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
-{
- writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE,
- dev->ext + MSCC_ICPU_CFG_TWI_DELAY);
-
- return 0;
-}
-
-static void i2c_dw_of_configure(struct device *device)
-{
- struct platform_device *pdev = to_platform_device(device);
- struct dw_i2c_dev *dev = dev_get_drvdata(device);
-
- switch (dev->flags & MODEL_MASK) {
- case MODEL_MSCC_OCELOT:
- dev->ext = devm_platform_ioremap_resource(pdev, 1);
- if (!IS_ERR(dev->ext))
- dev->set_sda_hold_time = mscc_twi_set_sda_hold_time;
- break;
- default:
- break;
- }
-}
#else
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
{
return -ENODEV;
}
-
-static inline void i2c_dw_of_configure(struct device *device)
-{
-}
#endif
static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev)
@@ -245,7 +212,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
{
struct i2c_adapter *adap;
struct dw_i2c_dev *dev;
- struct i2c_timings *t;
int irq, ret;
irq = platform_get_irq(pdev, 0);
@@ -274,18 +240,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
reset_control_deassert(dev->rst);
- t = &dev->timings;
- i2c_parse_fw_timings(&pdev->dev, t, false);
-
- i2c_dw_adjust_bus_speed(dev);
-
- if (pdev->dev.of_node)
- i2c_dw_of_configure(&pdev->dev);
-
- if (has_acpi_companion(&pdev->dev))
- i2c_dw_acpi_configure(&pdev->dev);
-
- ret = i2c_dw_validate_speed(dev);
+ ret = i2c_dw_fw_parse_and_configure(dev);
if (ret)
goto exit_reset;
@@ -313,6 +268,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
goto exit_reset;
if (dev->clk) {
+ struct i2c_timings *t = &dev->timings;
u64 clk_khz;
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 07/12] i2c: desingware: Unify the firmware type checks
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (5 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 06/12] i2c: designware: Consolidate firmware parsing and configuring code Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 08/12] i2c: designware: Move exports to I2C_DW namespaces Andy Shevchenko
` (4 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
Instead of asymmetrical checks for the firmware type use
the is_*_node() calls.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index a5cae814a9c2..49d9d5f83071 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/swab.h>
#include <linux/types.h>
@@ -372,14 +373,15 @@ int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
struct device *device = dev->dev;
+ struct fwnode_handle *fwnode = dev_fwnode(device);
i2c_parse_fw_timings(device, t, false);
i2c_dw_adjust_bus_speed(dev);
- if (device->of_node)
+ if (is_of_node(fwnode))
i2c_dw_of_configure(device);
- if (has_acpi_companion(device))
+ else if (is_acpi_node(fwnode))
i2c_dw_acpi_configure(device);
return i2c_dw_validate_speed(dev);
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 08/12] i2c: designware: Move exports to I2C_DW namespaces
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (6 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 07/12] i2c: desingware: Unify the firmware type checks Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 09/12] i2c: designware: Get rid of redundant 'else' Andy Shevchenko
` (3 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
Reduce scope of the I²C DesignWare driver exports to I2C_DW namespaces.
This will prevent abuse of the symbols and clean up global namespace.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 2 ++
drivers/i2c/busses/i2c-designware-master.c | 3 +++
drivers/i2c/busses/i2c-designware-pcidrv.c | 2 ++
drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++
drivers/i2c/busses/i2c-designware-slave.c | 3 +++
5 files changed, 12 insertions(+)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 49d9d5f83071..50cf4cbfeff3 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -28,6 +28,8 @@
#include <linux/types.h>
#include <linux/units.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW_COMMON
+
#include "i2c-designware-core.h"
static char *abort_sources[] = {
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 85dbd0eb5392..0b6576d7f811 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -22,6 +22,8 @@
#include <linux/regmap.h>
#include <linux/reset.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW
+
#include "i2c-designware-core.h"
#define AMD_TIMEOUT_MIN_US 25
@@ -1079,3 +1081,4 @@ EXPORT_SYMBOL_GPL(i2c_dw_probe_master);
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus master adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 2e6c7bfb5bf7..68c2e1a3a035 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -418,3 +418,5 @@ module_pci_driver(dw_i2c_driver);
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW);
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0b6d6f2b6198..92e9199a5fdb 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -464,3 +464,5 @@ module_exit(dw_i2c_exit_driver);
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(I2C_DW);
+MODULE_IMPORT_NS(I2C_DW_COMMON);
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 2e079cf20bb5..70d183fa3bff 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -16,6 +16,8 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
+#define DEFAULT_SYMBOL_NAMESPACE I2C_DW
+
#include "i2c-designware-core.h"
static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev)
@@ -279,3 +281,4 @@ EXPORT_SYMBOL_GPL(i2c_dw_probe_slave);
MODULE_AUTHOR("Luis Oliveira <lolivei@synopsys.com>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus slave adapter");
MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS(I2C_DW_COMMON);
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 09/12] i2c: designware: Get rid of redundant 'else'
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (7 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 08/12] i2c: designware: Move exports to I2C_DW namespaces Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 10/12] i2c: designware: Fix spelling and other issues in the comments Andy Shevchenko
` (2 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
In the snippets like the following
if (...)
return / goto / break / continue ...;
else
...
the 'else' is redundant. Get rid of it.
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 50cf4cbfeff3..4d7dc346e619 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -638,10 +638,10 @@ int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev)
if (abort_source & DW_IC_TX_ARB_LOST)
return -EAGAIN;
- else if (abort_source & DW_IC_TX_ABRT_GCALL_READ)
+ if (abort_source & DW_IC_TX_ABRT_GCALL_READ)
return -EINVAL; /* wrong msgs[] data */
- else
- return -EIO;
+
+ return -EIO;
}
int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev)
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 10/12] i2c: designware: Fix spelling and other issues in the comments
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (8 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 09/12] i2c: designware: Get rid of redundant 'else' Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 11/12] i2c: designware: Remove ->disable() callback Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 12/12] i2c: designware: Consolidate PM ops Andy Shevchenko
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
Fix spelling and other issues, such as kernel-doc reported about,
in the comments.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-amdpsp.c | 10 +++++-----
drivers/i2c/busses/i2c-designware-common.c | 8 +++++---
drivers/i2c/busses/i2c-designware-core.h | 10 +++++-----
drivers/i2c/busses/i2c-designware-master.c | 15 +++++++++------
drivers/i2c/busses/i2c-designware-slave.c | 6 ++++--
5 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c
index 63454b06e5da..8fbd2a10c31a 100644
--- a/drivers/i2c/busses/i2c-designware-amdpsp.c
+++ b/drivers/i2c/busses/i2c-designware-amdpsp.c
@@ -155,7 +155,7 @@ static void psp_release_i2c_bus_deferred(struct work_struct *work)
/*
* If there is any pending transaction, cannot release the bus here.
- * psp_release_i2c_bus will take care of this later.
+ * psp_release_i2c_bus() will take care of this later.
*/
if (psp_i2c_access_count)
goto cleanup;
@@ -210,12 +210,12 @@ static void psp_release_i2c_bus(void)
{
mutex_lock(&psp_i2c_access_mutex);
- /* Return early if mailbox was malfunctional */
+ /* Return early if mailbox was malfunctioned */
if (psp_i2c_mbox_fail)
goto cleanup;
/*
- * If we are last owner of PSP semaphore, need to release aribtration
+ * If we are last owner of PSP semaphore, need to release arbitration
* via mailbox.
*/
psp_i2c_access_count--;
@@ -235,9 +235,9 @@ static void psp_release_i2c_bus(void)
/*
* Locking methods are based on the default implementation from
- * drivers/i2c/i2c-core-base.c, but with psp acquire and release operations
+ * drivers/i2c/i2c-core-base.c, but with PSP acquire and release operations
* added. With this in place we can ensure that i2c clients on the bus shared
- * with psp are able to lock HW access to the bus for arbitrary number of
+ * with PSP are able to lock HW access to the bus for arbitrary number of
* operations - that is e.g. write-wait-read.
*/
static void i2c_adapter_dw_psp_lock_bus(struct i2c_adapter *adapter,
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 4d7dc346e619..5d4e39663438 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -126,6 +126,8 @@ static int dw_reg_write_word(void *context, unsigned int reg, unsigned int val)
* Autodetects needed register access mode and creates the regmap with
* corresponding read/write callbacks. This must be called before doing any
* other register access.
+ *
+ * Return: 0 on success, or negative errno otherwise.
*/
int i2c_dw_init_regmap(struct dw_i2c_dev *dev)
{
@@ -173,7 +175,7 @@ int i2c_dw_init_regmap(struct dw_i2c_dev *dev)
/*
* Note we'll check the return value of the regmap IO accessors only
* at the probe stage. The rest of the code won't do this because
- * basically we have MMIO-based regmap so non of the read/write methods
+ * basically we have MMIO-based regmap, so none of the read/write methods
* can fail.
*/
dev->map = devm_regmap_init(dev->dev, NULL, dev, &map_cfg);
@@ -335,7 +337,7 @@ static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
acpi_speed = i2c_acpi_find_bus_speed(device);
/*
- * Some DSTDs use a non standard speed, round down to the lowest
+ * Some DSDTs use a non standard speed, round down to the lowest
* standard speed.
*/
for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
@@ -531,7 +533,7 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev)
/*
* Wait 10 times the signaling period of the highest I2C
- * transfer supported by the driver (for 400KHz this is
+ * transfer supported by the driver (for 400kHz this is
* 25us) as described in the DesignWare I2C databook.
*/
usleep_range(25, 250);
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index a2731179a42b..9f8e5bf61ec0 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -142,10 +142,10 @@
#define DW_IC_SLAVE 1
/*
- * Hardware abort codes from the DW_IC_TX_ABRT_SOURCE register
+ * Hardware abort codes from the DW_IC_TX_ABRT_SOURCE register.
*
- * Only expected abort codes are listed here
- * refer to the datasheet for the full list
+ * Only expected abort codes are listed here,
+ * refer to the datasheet for the full list.
*/
#define ABRT_7B_ADDR_NOACK 0
#define ABRT_10ADDR1_NOACK 1
@@ -200,7 +200,7 @@ struct reset_control;
* @rst: optional reset for the controller
* @slave: represent an I2C slave device
* @get_clk_rate_khz: callback to retrieve IP specific bus speed
- * @cmd_err: run time hadware error code
+ * @cmd_err: run time hardware error code
* @msgs: points to an array of messages currently being transferred
* @msgs_num: the number of elements in msgs
* @msg_write_idx: the element index of the current tx message in the msgs array
@@ -235,7 +235,7 @@ struct reset_control;
* @release_lock: function to release a hardware lock on the bus
* @semaphore_idx: Index of table with semaphore type attached to the bus. It's
* -1 if there is no semaphore.
- * @shared_with_punit: true if this bus is shared with the SoCs PUNIT
+ * @shared_with_punit: true if this bus is shared with the SoC's PUNIT
* @disable: function to disable the controller
* @init: function to initialize the I2C hardware
* @set_sda_hold_time: callback to retrieve IP specific SDA hold timing
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 0b6576d7f811..9d06dd7ffe37 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -168,12 +168,14 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
}
/**
- * i2c_dw_init_master() - Initialize the designware I2C master hardware
+ * i2c_dw_init_master() - Initialize the DesignWare I2C master hardware
* @dev: device private data
*
* This functions configures and enables the I2C master.
* This function is called during I2C init function, and in case of timeout at
* run time.
+ *
+ * Return: 0 on success, or negative errno otherwise.
*/
static int i2c_dw_init_master(struct dw_i2c_dev *dev)
{
@@ -314,7 +316,7 @@ static int amd_i2c_dw_xfer_quirk(struct i2c_adapter *adap, struct i2c_msg *msgs,
/*
* Initiate the i2c read/write transaction of buffer length,
* and poll for bus busy status. For the last message transfer,
- * update the command with stopbit enable.
+ * update the command with stop bit enable.
*/
for (msg_itr_lmt = buf_len; msg_itr_lmt > 0; msg_itr_lmt--) {
if (msg_wrt_idx == num_msgs - 1 && msg_itr_lmt == 1)
@@ -421,7 +423,7 @@ static int txgbe_i2c_dw_xfer_quirk(struct i2c_adapter *adap, struct i2c_msg *msg
/*
* Initiate (and continue) low level master read/write transaction.
- * This function is only called from i2c_dw_isr, and pumping i2c_msg
+ * This function is only called from i2c_dw_isr(), and pumping i2c_msg
* messages into the tx buffer. Even if the size of i2c_msg data is
* longer than the size of the tx buffer, it handles everything.
*/
@@ -459,7 +461,8 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
buf = msgs[dev->msg_write_idx].buf;
buf_len = msgs[dev->msg_write_idx].len;
- /* If both IC_EMPTYFIFO_HOLD_MASTER_EN and
+ /*
+ * If both IC_EMPTYFIFO_HOLD_MASTER_EN and
* IC_RESTART_EN are set, we must manually
* set restart bit between messages.
*/
@@ -949,7 +952,7 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
rinfo->unprepare_recovery = i2c_dw_unprepare_recovery;
adap->bus_recovery_info = rinfo;
- dev_info(dev->dev, "running with gpio recovery mode! scl%s",
+ dev_info(dev->dev, "running with GPIO recovery mode! scl%s",
rinfo->sda_gpiod ? ",sda" : "");
return 0;
@@ -1054,7 +1057,7 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
ret = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, irq_flags,
dev_name(dev->dev), dev);
if (ret) {
- dev_err(dev->dev, "failure requesting irq %i: %d\n",
+ dev_err(dev->dev, "failure requesting IRQ %i: %d\n",
dev->irq, ret);
return ret;
}
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 70d183fa3bff..0fa3a3d7a724 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -32,12 +32,14 @@ static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev)
}
/**
- * i2c_dw_init_slave() - Initialize the designware i2c slave hardware
+ * i2c_dw_init_slave() - Initialize the DesignWare i2c slave hardware
* @dev: device private data
*
* This function configures and enables the I2C in slave mode.
* This function is called during I2C init function, and in case of timeout at
* run time.
+ *
+ * Return: 0 on success, or negative errno otherwise.
*/
static int i2c_dw_init_slave(struct dw_i2c_dev *dev)
{
@@ -265,7 +267,7 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
ret = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr_slave,
IRQF_SHARED, dev_name(dev->dev), dev);
if (ret) {
- dev_err(dev->dev, "failure requesting irq %i: %d\n",
+ dev_err(dev->dev, "failure requesting IRQ %i: %d\n",
dev->irq, ret);
return ret;
}
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 11/12] i2c: designware: Remove ->disable() callback
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (9 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 10/12] i2c: designware: Fix spelling and other issues in the comments Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
2023-11-09 22:38 ` kernel test robot
2023-11-11 4:20 ` kernel test robot
2023-11-09 18:19 ` [PATCH v2 12/12] i2c: designware: Consolidate PM ops Andy Shevchenko
11 siblings, 2 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
Commit 90312351fd1e ("i2c: designware: MASTER mode as separated driver")
introduced ->disable() callback but there is no real use for it. Both
i2c-designware-master.c and i2c-designware-slave.c set it to the same
i2c_dw_disable() and scope is inside the same kernel module.
That said, replace the callback by explicitly calling the i2c_dw_disable().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-core.h | 2 --
drivers/i2c/busses/i2c-designware-master.c | 1 -
drivers/i2c/busses/i2c-designware-pcidrv.c | 5 +++--
drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++--
drivers/i2c/busses/i2c-designware-slave.c | 1 -
5 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 9f8e5bf61ec0..a22f2cd5faf8 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -236,7 +236,6 @@ struct reset_control;
* @semaphore_idx: Index of table with semaphore type attached to the bus. It's
* -1 if there is no semaphore.
* @shared_with_punit: true if this bus is shared with the SoC's PUNIT
- * @disable: function to disable the controller
* @init: function to initialize the I2C hardware
* @set_sda_hold_time: callback to retrieve IP specific SDA hold timing
* @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE
@@ -293,7 +292,6 @@ struct dw_i2c_dev {
void (*release_lock)(void);
int semaphore_idx;
bool shared_with_punit;
- void (*disable)(struct dw_i2c_dev *dev);
int (*init)(struct dw_i2c_dev *dev);
int (*set_sda_hold_time)(struct dw_i2c_dev *dev);
int mode;
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 9d06dd7ffe37..4ef4160db01f 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -993,7 +993,6 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
init_completion(&dev->cmd_complete);
dev->init = i2c_dw_init_master;
- dev->disable = i2c_dw_disable;
ret = i2c_dw_init_regmap(dev);
if (ret)
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 68c2e1a3a035..b8bf4ae4fab1 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -198,7 +198,7 @@ static int __maybe_unused i2c_dw_pci_runtime_suspend(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
- i_dev->disable(i_dev);
+ i2c_dw_disable(i_dev);
return 0;
}
@@ -345,7 +345,8 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
{
struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
- dev->disable(dev);
+ i2c_dw_disable(dev);
+
pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 92e9199a5fdb..d7c39ef16a32 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -331,7 +331,7 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
i2c_del_adapter(&dev->adapter);
- dev->disable(dev);
+ i2c_dw_disable(dev);
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_put_sync(&pdev->dev);
@@ -360,7 +360,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
if (i_dev->shared_with_punit)
return 0;
- i_dev->disable(i_dev);
+ i2c_dw_disable(i_dev);
i2c_dw_prepare_clk(i_dev, false);
return 0;
diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
index 0fa3a3d7a724..8921f6d49129 100644
--- a/drivers/i2c/busses/i2c-designware-slave.c
+++ b/drivers/i2c/busses/i2c-designware-slave.c
@@ -239,7 +239,6 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
int ret;
dev->init = i2c_dw_init_slave;
- dev->disable = i2c_dw_disable;
ret = i2c_dw_init_regmap(dev);
if (ret)
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 12/12] i2c: designware: Consolidate PM ops
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
` (10 preceding siblings ...)
2023-11-09 18:19 ` [PATCH v2 11/12] i2c: designware: Remove ->disable() callback Andy Shevchenko
@ 2023-11-09 18:19 ` Andy Shevchenko
11 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2023-11-09 18:19 UTC (permalink / raw)
To: Jarkko Nikula, Herbert Xu, Mario Limonciello, Andy Shevchenko,
Wolfram Sang, linux-i2c, linux-kernel
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, Hans de Goede
We have the same (*) PM ops in the PCI and plaform drivers.
Instead, consolidate that PM ops under exported variable and
deduplicate them.
*)
With the subtle ACPI and P-Unit behaviour differences in PCI case.
But this is not a problem as for ACPI we need to take care of the
P-Unit semaphore anyway and calling PM ops for ACPI makes sense as
it might provide specific operation regions in (however there are
no known devices on market that are using it with PCI enabled I2C).
Note, the clocks are not in use in the PCI case.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-common.c | 62 ++++++++++++++++++++
drivers/i2c/busses/i2c-designware-core.h | 4 +-
drivers/i2c/busses/i2c-designware-pcidrv.c | 44 +-------------
drivers/i2c/busses/i2c-designware-platdrv.c | 63 +--------------------
4 files changed, 68 insertions(+), 105 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 5d4e39663438..c211693d760f 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -21,6 +21,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regmap.h>
@@ -714,5 +715,66 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)
i2c_dw_release_lock(dev);
}
+static int i2c_dw_prepare(struct device *device)
+{
+ /*
+ * If the ACPI companion device object is present for this device,
+ * it may be accessed during suspend and resume of other devices via
+ * I2C operation regions, so tell the PM core and middle layers to
+ * avoid skipping system suspend/resume callbacks for it in that case.
+ */
+ return !has_acpi_companion(device);
+}
+
+static int i2c_dw_runtime_suspend(struct device *device)
+{
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ if (dev->shared_with_punit)
+ return 0;
+
+ i2c_dw_disable(dev);
+ i2c_dw_prepare_clk(dev, false);
+
+ return 0;
+}
+
+static int i2c_dw_suspend(struct device *device)
+{
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ i2c_mark_adapter_suspended(&dev->adapter);
+
+ return i2c_dw_runtime_suspend(device);
+}
+
+static int i2c_dw_runtime_resume(struct device *device)
+{
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ if (!dev->shared_with_punit)
+ i2c_dw_prepare_clk(dev, true);
+
+ dev->init(dev);
+
+ return 0;
+}
+
+static int i2c_dw_resume(struct device *device)
+{
+ struct dw_i2c_dev *dev = dev_get_drvdata(device);
+
+ i2c_dw_runtime_resume(device);
+ i2c_mark_adapter_resumed(&dev->adapter);
+
+ return 0;
+}
+
+EXPORT_GPL_DEV_PM_OPS(i2c_dw_dev_pm_ops) = {
+ .prepare = pm_sleep_ptr(i2c_dw_prepare),
+ LATE_SYSTEM_SLEEP_PM_OPS(i2c_dw_suspend, i2c_dw_resume)
+ RUNTIME_PM_OPS(i2c_dw_runtime_suspend, i2c_dw_runtime_resume, NULL)
+};
+
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core");
MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index a22f2cd5faf8..399b4304e215 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -335,7 +335,8 @@ int i2c_dw_wait_bus_not_busy(struct dw_i2c_dev *dev);
int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev);
int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev);
u32 i2c_dw_func(struct i2c_adapter *adap);
-void i2c_dw_disable(struct dw_i2c_dev *dev);
+
+extern const struct dev_pm_ops i2c_dw_dev_pm_ops;
static inline void __i2c_dw_enable(struct dw_i2c_dev *dev)
{
@@ -350,6 +351,7 @@ static inline void __i2c_dw_disable_nowait(struct dw_i2c_dev *dev)
}
void __i2c_dw_disable(struct dw_i2c_dev *dev);
+void i2c_dw_disable(struct dw_i2c_dev *dev);
extern void i2c_dw_configure_master(struct dw_i2c_dev *dev);
extern int i2c_dw_probe_master(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index b8bf4ae4fab1..afe85599ed1a 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -19,6 +19,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/power_supply.h>
#include <linux/sched.h>
@@ -194,47 +195,6 @@ static struct dw_pci_controller dw_pci_controllers[] = {
},
};
-static int __maybe_unused i2c_dw_pci_runtime_suspend(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- i2c_dw_disable(i_dev);
- return 0;
-}
-
-static int __maybe_unused i2c_dw_pci_suspend(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- i2c_mark_adapter_suspended(&i_dev->adapter);
-
- return i2c_dw_pci_runtime_suspend(dev);
-}
-
-static int __maybe_unused i2c_dw_pci_runtime_resume(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- return i_dev->init(i_dev);
-}
-
-static int __maybe_unused i2c_dw_pci_resume(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
- int ret;
-
- ret = i2c_dw_pci_runtime_resume(dev);
-
- i2c_mark_adapter_resumed(&i_dev->adapter);
-
- return ret;
-}
-
-static const struct dev_pm_ops i2c_dw_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(i2c_dw_pci_suspend, i2c_dw_pci_resume)
- SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL)
-};
-
static const struct property_entry dgpu_properties[] = {
/* USB-C doesn't power the system */
PROPERTY_ENTRY_U8("scope", POWER_SUPPLY_SCOPE_DEVICE),
@@ -411,7 +371,7 @@ static struct pci_driver dw_i2c_driver = {
.probe = i2c_dw_pci_probe,
.remove = i2c_dw_pci_remove,
.driver = {
- .pm = &i2c_dw_pm_ops,
+ .pm = pm_ptr(&i2c_dw_dev_pm_ops),
},
};
module_pci_driver(dw_i2c_driver);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d7c39ef16a32..99498823563f 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -342,67 +342,6 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
reset_control_assert(dev->rst);
}
-static int dw_i2c_plat_prepare(struct device *dev)
-{
- /*
- * If the ACPI companion device object is present for this device, it
- * may be accessed during suspend and resume of other devices via I2C
- * operation regions, so tell the PM core and middle layers to avoid
- * skipping system suspend/resume callbacks for it in that case.
- */
- return !has_acpi_companion(dev);
-}
-
-static int dw_i2c_plat_runtime_suspend(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- if (i_dev->shared_with_punit)
- return 0;
-
- i2c_dw_disable(i_dev);
- i2c_dw_prepare_clk(i_dev, false);
-
- return 0;
-}
-
-static int dw_i2c_plat_suspend(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- i2c_mark_adapter_suspended(&i_dev->adapter);
-
- return dw_i2c_plat_runtime_suspend(dev);
-}
-
-static int dw_i2c_plat_runtime_resume(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- if (!i_dev->shared_with_punit)
- i2c_dw_prepare_clk(i_dev, true);
-
- i_dev->init(i_dev);
-
- return 0;
-}
-
-static int dw_i2c_plat_resume(struct device *dev)
-{
- struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
-
- dw_i2c_plat_runtime_resume(dev);
- i2c_mark_adapter_resumed(&i_dev->adapter);
-
- return 0;
-}
-
-static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
- .prepare = pm_sleep_ptr(dw_i2c_plat_prepare),
- LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
- RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
-};
-
static const struct of_device_id dw_i2c_of_match[] = {
{ .compatible = "snps,designware-i2c", },
{ .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
@@ -444,7 +383,7 @@ static struct platform_driver dw_i2c_driver = {
.name = "i2c_designware",
.of_match_table = dw_i2c_of_match,
.acpi_match_table = dw_i2c_acpi_match,
- .pm = pm_ptr(&dw_i2c_dev_pm_ops),
+ .pm = pm_ptr(&i2c_dw_dev_pm_ops),
},
.id_table = dw_i2c_platform_ids,
};
--
2.40.0.1996.gbec44491f096
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
2023-11-09 18:19 ` [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() Andy Shevchenko
@ 2023-11-09 20:33 ` Andi Shyti
0 siblings, 0 replies; 19+ messages in thread
From: Andi Shyti @ 2023-11-09 20:33 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, Herbert Xu, Mario Limonciello, Wolfram Sang,
linux-i2c, linux-kernel, Mika Westerberg, Jan Dabros,
Hans de Goede
Hi Andy,
On Thu, Nov 09, 2023 at 08:19:11PM +0200, Andy Shevchenko wrote:
> As Krzysztof Kozlowski pointed out the better is to use
> MODULE_DEVICE_TABLE() as it will be consistent with the content
> of the real ID table of the platform devices.
>
> While at it, drop unneeded and unused module alias in PCI glue
> driver as PCI already has its own ID table and automatic loading
> should just work.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Andi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure()
2023-11-09 18:19 ` [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
@ 2023-11-09 20:35 ` Andi Shyti
0 siblings, 0 replies; 19+ messages in thread
From: Andi Shyti @ 2023-11-09 20:35 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, Herbert Xu, Mario Limonciello, Wolfram Sang,
linux-i2c, linux-kernel, Mika Westerberg, Jan Dabros,
Hans de Goede
Hi Andy,
On Thu, Nov 09, 2023 at 08:19:13PM +0200, Andy Shevchenko wrote:
> i2c_dw_acpi_configure() is called without checking of the returned
> value, hence just drop it by converting to void.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Andi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure()
2023-11-09 18:19 ` [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
@ 2023-11-09 20:36 ` Andi Shyti
0 siblings, 0 replies; 19+ messages in thread
From: Andi Shyti @ 2023-11-09 20:36 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, Herbert Xu, Mario Limonciello, Wolfram Sang,
linux-i2c, linux-kernel, Mika Westerberg, Jan Dabros,
Hans de Goede
Hi Andy,
On Thu, Nov 09, 2023 at 08:19:14PM +0200, Andy Shevchenko wrote:
> dw_i2c_of_configure() is called without checking of the returned
> value, hence just drop it by converting to void.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Andi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure()
2023-11-09 18:19 ` [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
@ 2023-11-09 20:41 ` Andi Shyti
0 siblings, 0 replies; 19+ messages in thread
From: Andi Shyti @ 2023-11-09 20:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, Herbert Xu, Mario Limonciello, Wolfram Sang,
linux-i2c, linux-kernel, Mika Westerberg, Jan Dabros,
Hans de Goede
Hi Andy,
On Thu, Nov 09, 2023 at 08:19:15PM +0200, Andy Shevchenko wrote:
> For the sake of consistency, rename dw_i2c_of_configure() and change
> its parameter to be aligned with the i2c_dw_acpi_configure().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Thanks,
Andi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 11/12] i2c: designware: Remove ->disable() callback
2023-11-09 18:19 ` [PATCH v2 11/12] i2c: designware: Remove ->disable() callback Andy Shevchenko
@ 2023-11-09 22:38 ` kernel test robot
2023-11-11 4:20 ` kernel test robot
1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2023-11-09 22:38 UTC (permalink / raw)
To: Andy Shevchenko, Jarkko Nikula, Herbert Xu, Mario Limonciello,
Wolfram Sang, linux-i2c, linux-kernel
Cc: oe-kbuild-all, Mika Westerberg, Jan Dabros, Andi Shyti,
Hans de Goede
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.6 next-20231109]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-designware-Replace-MODULE_ALIAS-with-MODULE_DEVICE_TABLE/20231110-040556
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20231109182823.3531846-12-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 11/12] i2c: designware: Remove ->disable() callback
config: arc-randconfig-002-20231110 (https://download.01.org/0day-ci/archive/20231110/202311100640.B5B7MhDJ-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231110/202311100640.B5B7MhDJ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311100640.B5B7MhDJ-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/i2c/busses/i2c-designware-slave.c: In function 'i2c_dw_unreg_slave':
>> drivers/i2c/busses/i2c-designware-slave.c:95:12: error: 'struct dw_i2c_dev' has no member named 'disable'
95 | dev->disable(dev);
| ^~
vim +95 drivers/i2c/busses/i2c-designware-slave.c
9f3e065c54b05b Luis Oliveira 2017-06-22 89
9f3e065c54b05b Luis Oliveira 2017-06-22 90 static int i2c_dw_unreg_slave(struct i2c_client *slave)
9f3e065c54b05b Luis Oliveira 2017-06-22 91 {
9f3e065c54b05b Luis Oliveira 2017-06-22 92 struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter);
9f3e065c54b05b Luis Oliveira 2017-06-22 93
fee61247b7f67a Jarkko Nikula 2022-11-07 94 regmap_write(dev->map, DW_IC_INTR_MASK, 0);
9f3e065c54b05b Luis Oliveira 2017-06-22 @95 dev->disable(dev);
c486dcd2f1bbdd Jarkko Nikula 2019-08-15 96 synchronize_irq(dev->irq);
9f3e065c54b05b Luis Oliveira 2017-06-22 97 dev->slave = NULL;
2a86cdd2e7d3c7 Jarkko Nikula 2017-08-15 98 pm_runtime_put(dev->dev);
9f3e065c54b05b Luis Oliveira 2017-06-22 99
9f3e065c54b05b Luis Oliveira 2017-06-22 100 return 0;
9f3e065c54b05b Luis Oliveira 2017-06-22 101 }
9f3e065c54b05b Luis Oliveira 2017-06-22 102
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 11/12] i2c: designware: Remove ->disable() callback
2023-11-09 18:19 ` [PATCH v2 11/12] i2c: designware: Remove ->disable() callback Andy Shevchenko
2023-11-09 22:38 ` kernel test robot
@ 2023-11-11 4:20 ` kernel test robot
1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2023-11-11 4:20 UTC (permalink / raw)
To: Andy Shevchenko, Jarkko Nikula, Herbert Xu, Mario Limonciello,
Wolfram Sang, linux-i2c, linux-kernel
Cc: llvm, oe-kbuild-all, Mika Westerberg, Jan Dabros, Andi Shyti,
Hans de Goede
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.6 next-20231110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/i2c-designware-Replace-MODULE_ALIAS-with-MODULE_DEVICE_TABLE/20231110-040556
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20231109182823.3531846-12-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 11/12] i2c: designware: Remove ->disable() callback
config: powerpc64-allmodconfig (https://download.01.org/0day-ci/archive/20231111/202311111250.CfK3aPG4-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231111/202311111250.CfK3aPG4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311111250.CfK3aPG4-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/i2c/busses/i2c-designware-slave.c:95:7: error: no member named 'disable' in 'struct dw_i2c_dev'
95 | dev->disable(dev);
| ~~~ ^
1 error generated.
vim +95 drivers/i2c/busses/i2c-designware-slave.c
9f3e065c54b05b Luis Oliveira 2017-06-22 89
9f3e065c54b05b Luis Oliveira 2017-06-22 90 static int i2c_dw_unreg_slave(struct i2c_client *slave)
9f3e065c54b05b Luis Oliveira 2017-06-22 91 {
9f3e065c54b05b Luis Oliveira 2017-06-22 92 struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter);
9f3e065c54b05b Luis Oliveira 2017-06-22 93
fee61247b7f67a Jarkko Nikula 2022-11-07 94 regmap_write(dev->map, DW_IC_INTR_MASK, 0);
9f3e065c54b05b Luis Oliveira 2017-06-22 @95 dev->disable(dev);
c486dcd2f1bbdd Jarkko Nikula 2019-08-15 96 synchronize_irq(dev->irq);
9f3e065c54b05b Luis Oliveira 2017-06-22 97 dev->slave = NULL;
2a86cdd2e7d3c7 Jarkko Nikula 2017-08-15 98 pm_runtime_put(dev->dev);
9f3e065c54b05b Luis Oliveira 2017-06-22 99
9f3e065c54b05b Luis Oliveira 2017-06-22 100 return 0;
9f3e065c54b05b Luis Oliveira 2017-06-22 101 }
9f3e065c54b05b Luis Oliveira 2017-06-22 102
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2023-11-11 4:21 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-09 18:19 [PATCH v2 00/12] i2c: designware: code consolidation & cleanups Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 01/12] i2c: designware: Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE() Andy Shevchenko
2023-11-09 20:33 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 02/12] i2c: designware: Always provide device ID tables Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 03/12] i2c: designware: Drop return value from i2c_dw_acpi_configure() Andy Shevchenko
2023-11-09 20:35 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 04/12] i2c: designware: Drop return value from dw_i2c_of_configure() Andy Shevchenko
2023-11-09 20:36 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 05/12] i2c: designware: Rename dw_i2c_of_configure() -> i2c_dw_of_configure() Andy Shevchenko
2023-11-09 20:41 ` Andi Shyti
2023-11-09 18:19 ` [PATCH v2 06/12] i2c: designware: Consolidate firmware parsing and configuring code Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 07/12] i2c: desingware: Unify the firmware type checks Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 08/12] i2c: designware: Move exports to I2C_DW namespaces Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 09/12] i2c: designware: Get rid of redundant 'else' Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 10/12] i2c: designware: Fix spelling and other issues in the comments Andy Shevchenko
2023-11-09 18:19 ` [PATCH v2 11/12] i2c: designware: Remove ->disable() callback Andy Shevchenko
2023-11-09 22:38 ` kernel test robot
2023-11-11 4:20 ` kernel test robot
2023-11-09 18:19 ` [PATCH v2 12/12] i2c: designware: Consolidate PM ops Andy Shevchenko
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).