-/**
- * Handle the next stage of device init
- */
-static int handle_stage(const void *blob, struct tegra_lcd_priv *priv)
-{
- debug("%s: stage %d\n", __func__, priv->stage);
-
- /* do the things for this stage */
- switch (priv->stage) {
- case STAGE_START:
- /*
- * It is possible that the FDT has requested that the LCD be
- * disabled. We currently don't support this. It would require
- * changes to U-Boot LCD subsystem to have LCD support
- * compiled in but not used. An easier option might be to
- * still have a frame buffer, but leave the backlight off and
- * remove all mention of lcd in the stdout environment
- * variable.
- */
-
- funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
- break;
- case STAGE_PANEL_VDD:
- if (dm_gpio_is_valid(&priv->panel_vdd))
- dm_gpio_set_value(&priv->panel_vdd, 1);
- break;
- case STAGE_LVDS:
- if (dm_gpio_is_valid(&priv->lvds_shutdown))
- dm_gpio_set_value(&priv->lvds_shutdown, 1);
- break;
- case STAGE_BACKLIGHT_VDD:
- if (dm_gpio_is_valid(&priv->backlight_vdd))
- dm_gpio_set_value(&priv->backlight_vdd, 1);
- break;
- case STAGE_PWM:
- /* Enable PWM at 15/16 high, 32768 Hz with divider 1 */
- pinmux_set_func(PMUX_PINGRP_GPU, PMUX_FUNC_PWM);
- pinmux_tristate_disable(PMUX_PINGRP_GPU);
-
- pwm_set_config(priv->pwm, priv->pwm_channel, 0xdf, 0xff);
- pwm_set_enable(priv->pwm, priv->pwm_channel, true);
- break;
- case STAGE_BACKLIGHT_EN:
- if (dm_gpio_is_valid(&priv->backlight_en))
- dm_gpio_set_value(&priv->backlight_en, 1);
- break;
- case STAGE_DONE:
- break;
- }
-
- /* set up timer for next stage */
- priv->timer_next = timer_get_us();
- if (priv->stage < FDT_LCD_TIMINGS)
- priv->timer_next += priv->panel_timings[priv->stage] * 1000;
-
- /* move to next stage */
- priv->stage++;
- return 0;
-}
-
-/**
- * Perform the next stage of the LCD init if it is time to do so.
- *
- * LCD init can be time-consuming because of the number of delays we need
- * while waiting for the backlight power supply, etc. This function can
- * be called at various times during U-Boot operation to advance the
- * initialization of the LCD to the next stage if sufficient time has
- * passed since the last stage. It keeps track of what stage it is up to
- * and the time that it is permitted to move to the next stage.
- *
- * The final call should have wait=1 to complete the init.
- *
- * @param blob fdt blob containing LCD information
- * @param wait 1 to wait until all init is complete, and then return
- * 0 to return immediately, potentially doing nothing if it is
- * not yet time for the next init.
- */
-static int tegra_lcd_check_next_stage(const void *blob,
- struct tegra_lcd_priv *priv, int wait)
-{
- if (priv->stage == STAGE_DONE)
- return 0;
-
- do {
- /* wait if we need to */
- debug("%s: stage %d\n", __func__, priv->stage);
- if (priv->stage != STAGE_START) {
- int delay = priv->timer_next - timer_get_us();
-
- if (delay > 0) {
- if (wait)
- udelay(delay);
- else
- return 0;
- }
- }
-
- if (handle_stage(blob, priv))
- return -1;
- } while (wait && priv->stage != STAGE_DONE);
- if (priv->stage == STAGE_DONE)
- debug("%s: LCD init complete\n", __func__);
-
- return 0;
-}
-