Skip to content

Commit bcfaaa9

Browse files
dangowrtwsakernel
authored andcommitted
i2c: mt65xx: allow optional pmic clock
Using the I2C host controller on the MT7981 SoC requires 4 clocks to be enabled. One of them, the pmic clk, is only enabled in case 'mediatek,have-pmic' is also set which has other consequences which are not desired in this case. Allow defining a pmic clk even in case the 'mediatek,have-pmic' propterty is not present and the bus is not used to connect to a pmic, but may still require to enable the pmic clock. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 19b6ffd commit bcfaaa9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/i2c/busses/i2c-mt65xx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev)
14421442
if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk))
14431443
return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk);
14441444

1445+
i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic");
1446+
if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
1447+
dev_err(&pdev->dev, "cannot get pmic clock\n");
1448+
return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
1449+
}
1450+
14451451
if (i2c->have_pmic) {
1446-
i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic");
1447-
if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
1452+
if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) {
14481453
dev_err(&pdev->dev, "cannot get pmic clock\n");
1449-
return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
1454+
return -ENODEV;
14501455
}
14511456
speed_clk = I2C_MT65XX_CLK_PMIC;
14521457
} else {
1453-
i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL;
14541458
speed_clk = I2C_MT65XX_CLK_MAIN;
14551459
}
14561460

0 commit comments

Comments
 (0)