Skip to content

Commit 27071b5

Browse files
fancerwsakernel
authored andcommitted
i2c: designware: Use standard optional ref clock implementation
Even though the DW I2C controller reference clock source is requested by the method devm_clk_get() with non-optional clock requirement the way the clock handler is used afterwards has a pure optional clock semantic (though in some circumstances we can get a warning about the clock missing printed in the system console). There is no point in reimplementing that functionality seeing the kernel clock framework already supports the optional interface from scratch. Thus let's convert the platform driver to using it. Note by providing this commit we get to fix two problems. The first one was introduced in commit c62ebb3 ("i2c: designware: Add support for an interface clock"). It causes not having the interface clock (pclk) enabled/disabled in case if the reference clock isn't provided. The second problem was first introduced in commit b33af11 ("i2c: designware: Do not require clock when SSCN and FFCN are provided"). Since that modification the deferred probe procedure has been unsupported in case if the interface clock isn't ready. Fixes: c62ebb3 ("i2c: designware: Add support for an interface clock") Fixes: b33af11 ("i2c: designware: Do not require clock when SSCN and FFCN are provided") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 5edc99f commit 27071b5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare)
477477
{
478478
int ret;
479479

480-
if (IS_ERR(dev->clk))
481-
return PTR_ERR(dev->clk);
482-
483480
if (prepare) {
484481
/* Optional interface clock */
485482
ret = clk_prepare_enable(dev->pclk);

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
320320
goto exit_reset;
321321
}
322322

323-
dev->clk = devm_clk_get(&pdev->dev, NULL);
324-
if (!i2c_dw_prepare_clk(dev, true)) {
323+
dev->clk = devm_clk_get_optional(&pdev->dev, NULL);
324+
if (IS_ERR(dev->clk)) {
325+
ret = PTR_ERR(dev->clk);
326+
goto exit_reset;
327+
}
328+
329+
ret = i2c_dw_prepare_clk(dev, true);
330+
if (ret)
331+
goto exit_reset;
332+
333+
if (dev->clk) {
325334
u64 clk_khz;
326335

327336
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;

0 commit comments

Comments
 (0)