From ff938cd14d67a7040258759b46e3d5b4548f4c2c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 15 Feb 2018 12:33:50 +0100 Subject: ARM: shmobile: stout: enable R-Car Gen2 regulator quirk Regulator setup is suboptimal on H2 Stout too. The Stout newly has two DA9210 regulators, so the quirk is extended to handle another DA9210 at i2c address 0x70. Signed-off-by: Marek Vasut Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c') diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 44438f344dc8..27fb3a5ec73e 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -1,9 +1,9 @@ /* * R-Car Generation 2 da9063/da9210 regulator quirk * - * The r8a7790/lager and r8a7791/koelsch development boards have da9063 and - * da9210 regulators. Both regulators have their interrupt request lines tied - * to the same interrupt pin (IRQ2) on the SoC. + * Certain Gen2 development boards have an da9063 and one or more da9210 + * regulators. All of these regulators have their interrupt request lines + * tied to the same interrupt pin (IRQ2) on the SoC. * * After cold boot or da9063-induced restart, both the da9063 and da9210 seem * to assert their interrupt request lines. Hence as soon as one driver @@ -50,7 +50,7 @@ static void __iomem *irqc; static u8 da9063_irq_clr[] = { DA9063_REG_IRQ_MASK_A, 0xff, 0xff, 0xff, 0xff }; static u8 da9210_irq_clr[] = { DA9210_REG_MASK_A, 0xff, 0xff }; -static struct i2c_msg da9xxx_msgs[2] = { +static struct i2c_msg da9xxx_msgs[3] = { { .addr = 0x58, .len = ARRAY_SIZE(da9063_irq_clr), @@ -59,6 +59,10 @@ static struct i2c_msg da9xxx_msgs[2] = { .addr = 0x68, .len = ARRAY_SIZE(da9210_irq_clr), .buf = da9210_irq_clr, + }, { + .addr = 0x70, + .len = ARRAY_SIZE(da9210_irq_clr), + .buf = da9210_irq_clr, }, }; @@ -85,11 +89,15 @@ static int regulator_quirk_notify(struct notifier_block *nb, dev_dbg(dev, "Detected %s\n", client->name); if ((client->addr == 0x58 && !strcmp(client->name, "da9063")) || - (client->addr == 0x68 && !strcmp(client->name, "da9210"))) { - int ret; + (client->addr == 0x68 && !strcmp(client->name, "da9210")) || + (client->addr == 0x70 && !strcmp(client->name, "da9210"))) { + int ret, len; + + /* There are two DA9210 on Stout, one on the other boards. */ + len = of_machine_is_compatible("renesas,stout") ? 3 : 2; dev_info(&client->dev, "clearing da9063/da9210 interrupts\n"); - ret = i2c_transfer(client->adapter, da9xxx_msgs, ARRAY_SIZE(da9xxx_msgs)); + ret = i2c_transfer(client->adapter, da9xxx_msgs, len); if (ret != ARRAY_SIZE(da9xxx_msgs)) dev_err(&client->dev, "i2c error %d\n", ret); } @@ -118,6 +126,7 @@ static int __init rcar_gen2_regulator_quirk(void) if (!of_machine_is_compatible("renesas,koelsch") && !of_machine_is_compatible("renesas,lager") && + !of_machine_is_compatible("renesas,stout") && !of_machine_is_compatible("renesas,gose")) return -ENODEV; -- cgit v1.2.3 From 60fc75bdf5b1b8ed3e0a372b7b35f27726ff542b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 28 Feb 2018 10:13:00 +0100 Subject: ARM: shmobile: rcar-gen2: Fix error check in regulator quirk On systems with two regulators, a bogus error message is printed on success: i2c 6-0058: i2c error 2 While adding support for Stout, the number of messages to send was made variable, but the corresponding return value check of i2c_transfer() wasn't updated. Fixes: ff938cd14d67a704 ("ARM: shmobile: stout: enable R-Car Gen2 regulator quirk") Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c') diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 27fb3a5ec73e..93f628acfd94 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -98,7 +98,7 @@ static int regulator_quirk_notify(struct notifier_block *nb, dev_info(&client->dev, "clearing da9063/da9210 interrupts\n"); ret = i2c_transfer(client->adapter, da9xxx_msgs, len); - if (ret != ARRAY_SIZE(da9xxx_msgs)) + if (ret != len) dev_err(&client->dev, "i2c error %d\n", ret); } -- cgit v1.2.3