int __init enterprise_panel_init(void)
{
	int err;
	struct resource __maybe_unused *res;

	bl_output = enterprise_bl_output_measured;

	if (WARN_ON(ARRAY_SIZE(enterprise_bl_output_measured) != 256))
		pr_err("bl_output array does not have 256 elements\n");

	enterprise_dsi.chip_id = tegra_get_chipid();
	enterprise_dsi.chip_rev = tegra_get_revision();

	enterprise_carveouts[1].base = tegra_carveout_start;
	enterprise_carveouts[1].size = tegra_carveout_size;

	tegra_gpio_enable(enterprise_hdmi_hpd);
	gpio_request(enterprise_hdmi_hpd, "hdmi_hpd");
	gpio_direction_input(enterprise_hdmi_hpd);

	tegra_gpio_enable(enterprise_lcd_2d_3d);
	gpio_request(enterprise_lcd_2d_3d, "lcd_2d_3d");
	gpio_direction_output(enterprise_lcd_2d_3d, 0);
	enterprise_stereo_set_mode(enterprise_stereo.mode_2d_3d);

	tegra_gpio_enable(enterprise_lcd_swp_pl);
	gpio_request(enterprise_lcd_swp_pl, "lcd_swp_pl");
	gpio_direction_output(enterprise_lcd_swp_pl, 0);
	enterprise_stereo_set_orientation(enterprise_stereo.orientation);

#if !(DC_CTRL_MODE & TEGRA_DC_OUT_ONE_SHOT_MODE)
	tegra_gpio_enable(enterprise_lcd_te);
	gpio_request(enterprise_lcd_swp_pl, "lcd_te");
	gpio_direction_input(enterprise_lcd_te);
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
	enterprise_panel_early_suspender.suspend = enterprise_panel_early_suspend;
	enterprise_panel_early_suspender.resume = enterprise_panel_late_resume;
	enterprise_panel_early_suspender.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	register_early_suspend(&enterprise_panel_early_suspender);
#endif

	err = platform_add_devices(enterprise_gfx_devices,
				ARRAY_SIZE(enterprise_gfx_devices));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	res = nvhost_get_resource_byname(&enterprise_disp1_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb_start;
	res->end = tegra_fb_start + tegra_fb_size - 1;
#endif

	/* Copy the bootloader fb to the fb. */
	tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
		min(tegra_fb_size, tegra_bootloader_fb_size));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if (!err)
		err = nvhost_device_register(&enterprise_disp1_device);

	res = nvhost_get_resource_byname(&enterprise_disp2_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb2_start;
	res->end = tegra_fb2_start + tegra_fb2_size - 1;
	if (!err)
		err = nvhost_device_register(&enterprise_disp2_device);
#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
	if (!err)
		err = nvhost_device_register(&nvavp_device);
#endif

	if (!err)
		err = platform_add_devices(enterprise_bl_devices,
				ARRAY_SIZE(enterprise_bl_devices));
	return err;
}
예제 #2
0
int __init enterprise_panel_init(void)
{
	int err;
	struct resource __maybe_unused *res;
	struct board_info board_info;
	struct platform_device *phost1x;

	tegra_get_board_info(&board_info);

	BUILD_BUG_ON(ARRAY_SIZE(enterprise_bl_output_measured_a03) != 256);
	BUILD_BUG_ON(ARRAY_SIZE(enterprise_bl_output_measured_a02) != 256);

	if (board_info.board_id != BOARD_E1239) {
		if (board_info.fab >= BOARD_FAB_A03) {
#if !(IS_EXTERNAL_PWM)
			enterprise_disp1_backlight_data.clk_div = 0x1D;
#endif
			bl_output = enterprise_bl_output_measured_a03;
		} else
			bl_output = enterprise_bl_output_measured_a02;
	} else {
		enterprise_bl_devices[0] = &external_pwm_disp1_backlight_device;
		bl_output = tai_bl_output_measured;
	}
	enterprise_dsi.chip_id = tegra_get_chipid();
	enterprise_dsi.chip_rev = tegra_revision;

#if defined(CONFIG_TEGRA_NVMAP)
	enterprise_carveouts[1].base = tegra_carveout_start;
	enterprise_carveouts[1].size = tegra_carveout_size;
#endif

	err = gpio_request(enterprise_hdmi_hpd, "hdmi_hpd");
	if (err < 0) {
		pr_err("%s: gpio_request failed %d\n", __func__, err);
		return err;
	}
	err = gpio_direction_input(enterprise_hdmi_hpd);
	if (err < 0) {
		pr_err("%s: gpio_direction_input failed %d\n",
			__func__, err);
		gpio_free(enterprise_hdmi_hpd);
		return err;
	}

	if (board_info.board_id != BOARD_E1239) {
		err = gpio_request(enterprise_lcd_2d_3d, "lcd_2d_3d");
		if (err < 0) {
			pr_err("%s: gpio_request failed %d\n", __func__, err);
			return err;
		}
		err = gpio_direction_output(enterprise_lcd_2d_3d, 0);
		if (err < 0) {
			pr_err("%s: gpio_direction_ouput failed %d\n",
				__func__, err);
			gpio_free(enterprise_lcd_2d_3d);
			return err;
		}
		enterprise_stereo_set_mode(enterprise_stereo.mode_2d_3d);

		err = gpio_request(enterprise_lcd_swp_pl, "lcd_swp_pl");
		if (err < 0) {
			pr_err("%s: gpio_request failed %d\n", __func__, err);
			return err;
		}
		err = gpio_direction_output(enterprise_lcd_swp_pl, 0);
		if (err < 0) {
			pr_err("%s: gpio_direction_ouput failed %d\n",
				__func__, err);
			gpio_free(enterprise_lcd_swp_pl);
			return err;
		}
		enterprise_stereo_set_orientation(
						enterprise_stereo.orientation);
#if IS_EXTERNAL_PWM
		err = gpio_request(enterprise_bl_pwm, "bl_pwm");
		if (err < 0) {
			pr_err("%s: gpio_request failed %d\n", __func__, err);
			return err;
		}
		gpio_free(enterprise_bl_pwm);
#endif
	} else {
		/* External pwm is used but do not use IS_EXTERNAL_PWM
		compiler switch for TAI */
		err = gpio_request(enterprise_bl_pwm, "bl_pwm");
		if (err < 0) {
			pr_err("%s: gpio_request failed %d\n", __func__, err);
			return err;
		}
		gpio_free(enterprise_bl_pwm);
	}

#if !(DC_CTRL_MODE & TEGRA_DC_OUT_ONE_SHOT_MODE)
	err = gpio_request(enterprise_lcd_swp_pl, "lcd_te");
	if (err < 0) {
		pr_err("%s: gpio_request failed %d\n", __func__, err);
		return err;
	}
	err = gpio_direction_input(enterprise_lcd_te);
	if (err < 0) {
		pr_err("%s: gpio_direction_input failed %d\n",
			__func__, err);
		gpio_free(enterprise_lcd_te);
		return err;
	}
#endif

	if (board_info.board_id != BOARD_E1239)
		err = platform_add_devices(enterprise_gfx_devices,
			ARRAY_SIZE(enterprise_gfx_devices));
	else
		err = platform_add_devices(external_pwm_gfx_devices,
			ARRAY_SIZE(external_pwm_gfx_devices));

#ifdef CONFIG_TEGRA_GRHOST
	phost1x = tegra3_register_host1x_devices();
	if (!phost1x)
		return -EINVAL;
#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	res = platform_get_resource_byname(&enterprise_disp1_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb_start;
	res->end = tegra_fb_start + tegra_fb_size - 1;
#endif

	/* Copy the bootloader fb to the fb. */
	__tegra_move_framebuffer(&enterprise_nvmap_device,
		tegra_fb_start, tegra_bootloader_fb_start,
		min(tegra_fb_size, tegra_bootloader_fb_size));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if (!err) {
		enterprise_disp1_device.dev.parent = &phost1x->dev;
		err = platform_device_register(&enterprise_disp1_device);
	}

	res = platform_get_resource_byname(&enterprise_disp2_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb2_start;
	res->end = tegra_fb2_start + tegra_fb2_size - 1;
	if (!err) {
		enterprise_disp2_device.dev.parent = &phost1x->dev;
		err = platform_device_register(&enterprise_disp2_device);
	}
#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
	if (!err) {
		nvavp_device.dev.parent = &phost1x->dev;
		err = platform_device_register(&nvavp_device);
	}
#endif

	if (!err)
		err = platform_add_devices(enterprise_bl_devices,
				ARRAY_SIZE(enterprise_bl_devices));

	return err;
}