855-i2c-mt65xx-allow-optional-pmic-clock.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From 3bf827929a44c17bfb1bf1000b143c02ce26a929 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Sat, 26 Aug 2023 21:56:51 +0100
  4. Subject: [PATCH] i2c: mt65xx: allow optional pmic clock
  5. Using the I2C host controller on the MT7981 SoC requires 4 clocks to
  6. be enabled. One of them, the pmic clk, is only enabled in case
  7. 'mediatek,have-pmic' is also set which has other consequences which
  8. are not desired in this case.
  9. Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty
  10. is not present and the bus is not used to connect to a pmic, but may
  11. still require to enable the pmic clock.
  12. Signed-off-by: Daniel Golle <[email protected]>
  13. ---
  14. drivers/i2c/busses/i2c-mt65xx.c | 12 ++++++++----
  15. 1 file changed, 8 insertions(+), 4 deletions(-)
  16. --- a/drivers/i2c/busses/i2c-mt65xx.c
  17. +++ b/drivers/i2c/busses/i2c-mt65xx.c
  18. @@ -1444,15 +1444,19 @@ static int mtk_i2c_probe(struct platform
  19. if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk))
  20. return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk);
  21. + i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic");
  22. + if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
  23. + dev_err(&pdev->dev, "cannot get pmic clock\n");
  24. + return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
  25. + }
  26. +
  27. if (i2c->have_pmic) {
  28. - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic");
  29. - if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
  30. + if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) {
  31. dev_err(&pdev->dev, "cannot get pmic clock\n");
  32. - return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
  33. + return -ENODEV;
  34. }
  35. speed_clk = I2C_MT65XX_CLK_PMIC;
  36. } else {
  37. - i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL;
  38. speed_clk = I2C_MT65XX_CLK_MAIN;
  39. }