Add an optional vddp-supply, and power VDDP and IOVCC up before VDD, with a 10 ms wait in between.
The panel has three supplies: IOVCC (1.8 V logic), VDDP (the input of its DC-DC converter) and VDD (backlight power). The Genio 520 and 720 EVKs switch VDDP from its own GPIO, separately from VDD and IOVCC. vddp-supply stays optional so that older device trees without it keep working. The panel's power-on sequence requires VDDP and IOVCC to be on at least 1 ms before DCDC_EN, which is what the enable GPIO drives on these boards. VDD is not part of that sequence, so enable it after the other two. On the Genio 360 EVK, whose supplies all point at the same regulator, the new order changes nothing: the later regulator_enable() calls only take a reference. The new wait makes power-up 10 ms longer. Note that the upstream Linux himax-hx8279 driver instead enables all of its supplies together. Signed-off-by: David Lechner <[email protected]> --- drivers/video/panel-startek-kd070fhfid078.c | 52 +++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/video/panel-startek-kd070fhfid078.c b/drivers/video/panel-startek-kd070fhfid078.c index 12bf04e9912..be85bbbef62 100644 --- a/drivers/video/panel-startek-kd070fhfid078.c +++ b/drivers/video/panel-startek-kd070fhfid078.c @@ -90,6 +90,7 @@ struct stk078_panel { struct mipi_dsi_device *dsi; struct udevice *iovcc; struct udevice *vdd; + struct udevice *vddp; struct udevice *backlight; }; @@ -219,16 +220,32 @@ static int stk078_panel_enable_backlight(struct udevice *dev) dm_gpio_set_value(stk->enable_gpio, 0); mdelay(10); - ret = regulator_enable(stk->vdd); - if (ret < 0) { - dev_err(dev, "enable vdd failed: %d\n", ret); - goto out_detach; + /* + * VDDP and IOVCC must both be up at least 1 ms before DCDC_EN (the + * enable GPIO). VDD only powers the backlight, so it comes last. + * Boards that switch VDD and IOVCC from a single regulator simply see + * the second regulator_enable() as a reference count. + */ + if (stk->vddp) { + ret = regulator_enable(stk->vddp); + if (ret < 0) { + dev_err(dev, "enable vddp failed: %d\n", ret); + goto out_detach; + } } ret = regulator_enable(stk->iovcc); if (ret < 0) { dev_err(dev, "enable iovcc failed: %d\n", ret); - goto out_vdd; + goto out_vddp; + } + + mdelay(10); + + ret = regulator_enable(stk->vdd); + if (ret < 0) { + dev_err(dev, "enable vdd failed: %d\n", ret); + goto out_iovcc; } mdelay(15); @@ -241,25 +258,28 @@ static int stk078_panel_enable_backlight(struct udevice *dev) ret = stk078_panel_init(stk); if (ret < 0) { dev_err(dev, "panel init sequence failed: %d\n", ret); - goto out_iovcc; + goto out_vdd; } ret = backlight_enable(stk->backlight); if (ret < 0) { dev_err(dev, "enable backlight failed: %d\n", ret); - goto out_iovcc; + goto out_vdd; } return 0; -out_iovcc: +out_vdd: dm_gpio_set_value(stk->reset_gpio, 0); udelay(100); if (stk->enable_gpio) dm_gpio_set_value(stk->enable_gpio, 0); - regulator_disable(stk->iovcc); -out_vdd: regulator_disable(stk->vdd); +out_iovcc: + regulator_disable(stk->iovcc); +out_vddp: + if (stk->vddp) + regulator_disable(stk->vddp); out_detach: mipi_dsi_detach(dsi); @@ -283,6 +303,18 @@ static int stk078_panel_add(struct udevice *dev) return ret; } + /* + * vddp-supply is optional only for compatibility with device trees + * that predate it. + */ + ret = device_get_supply_regulator(dev, "vddp-supply", &stk->vddp); + if (ret == -ENOENT) { + stk->vddp = NULL; + } else if (ret) { + dev_err(dev, "Failed to get vddp regulator: %d\n", ret); + return ret; + } + stk->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_IS_OUT); if (IS_ERR(stk->reset_gpio)) { ret = PTR_ERR(stk->reset_gpio); -- 2.53.0
