Exemplo n.º 1
0
static int tegra_lcd_probe(struct udevice *dev)
{
    struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
    struct video_priv *uc_priv = dev_get_uclass_priv(dev);
    struct tegra_lcd_priv *priv = dev_get_priv(dev);
    const void *blob = gd->fdt_blob;
    int type = DCACHE_OFF;

    /* Initialize the Tegra display controller */
    if (tegra_display_probe(blob, priv, (void *)plat->base)) {
        printf("%s: Failed to probe display driver\n", __func__);
        return -1;
    }

    tegra_lcd_check_next_stage(blob, priv, 1);

    /* Set up the LCD caching as requested */
    if (priv->cache_type & FDT_LCD_CACHE_WRITE_THROUGH)
        type = DCACHE_WRITETHROUGH;
    else if (priv->cache_type & FDT_LCD_CACHE_WRITE_BACK)
        type = DCACHE_WRITEBACK;
    mmu_set_region_dcache_behaviour(priv->frame_buffer, plat->size, type);

    /* Enable flushing after LCD writes if requested */
    video_set_flush_dcache(dev, priv->cache_type & FDT_LCD_CACHE_FLUSH);

    uc_priv->xsize = priv->width;
    uc_priv->ysize = priv->height;
    uc_priv->bpix = priv->log2_bpp;
    debug("LCD frame buffer at %pa, size %x\n", &priv->frame_buffer,
          plat->size);

    return 0;
}
Exemplo n.º 2
0
Arquivo: tegra.c Projeto: JamesAng/ub
/**
 * Handle the next stage of device init
 */
static int handle_stage(const void *blob)
{
	debug("%s: stage %d\n", __func__, stage);

	/* do the things for this stage */
	switch (stage) {
	case STAGE_START:
		/* Initialize the Tegra display controller */
		if (tegra_display_probe(gd->fdt_blob, (void *)gd->fb_base)) {
			printf("%s: Failed to probe display driver\n",
			__func__);
			return -1;
		}

		/* get panel details */
		if (fdt_decode_lcd(blob, &config)) {
			printf("No valid LCD information in device tree\n");
			return -1;
		}

		/*
		 * 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);

		fdtdec_setup_gpio(&config.panel_vdd);
		fdtdec_setup_gpio(&config.lvds_shutdown);
		fdtdec_setup_gpio(&config.backlight_vdd);
		fdtdec_setup_gpio(&config.backlight_en);

		/*
		 * TODO: If fdt includes output flag we can omit this code
		 * since fdtdec_setup_gpio will do it for us.
		 */
		if (fdt_gpio_isvalid(&config.panel_vdd))
			gpio_direction_output(config.panel_vdd.gpio, 0);
		if (fdt_gpio_isvalid(&config.lvds_shutdown))
			gpio_direction_output(config.lvds_shutdown.gpio, 0);
		if (fdt_gpio_isvalid(&config.backlight_vdd))
			gpio_direction_output(config.backlight_vdd.gpio, 0);
		if (fdt_gpio_isvalid(&config.backlight_en))
			gpio_direction_output(config.backlight_en.gpio, 0);
		break;
	case STAGE_PANEL_VDD:
		if (fdt_gpio_isvalid(&config.panel_vdd))
			gpio_direction_output(config.panel_vdd.gpio, 1);
		break;
	case STAGE_LVDS:
		if (fdt_gpio_isvalid(&config.lvds_shutdown))
			gpio_set_value(config.lvds_shutdown.gpio, 1);
		break;
	case STAGE_BACKLIGHT_VDD:
		if (fdt_gpio_isvalid(&config.backlight_vdd))
			gpio_set_value(config.backlight_vdd.gpio, 1);
		break;
	case STAGE_PWM:
		/* Enable PWM at 15/16 high, 32768 Hz with divider 1 */
		pinmux_set_func(PINGRP_GPU, PMUX_FUNC_PWM);
		pinmux_tristate_disable(PINGRP_GPU);

		pwm_enable(config.pwm_channel, 32768, 0xdf, 1);
		break;
	case STAGE_BACKLIGHT_EN:
		if (fdt_gpio_isvalid(&config.backlight_en))
			gpio_set_value(config.backlight_en.gpio, 1);
		break;
	case STAGE_DONE:
		break;
	}

	/* set up timer for next stage */
	timer_next = timer_get_us();
	if (stage < FDT_LCD_TIMINGS)
		timer_next += config.panel_timings[stage] * 1000;

	/* move to next stage */
	stage++;
	return 0;
}