void __init mapphone_panel_init(void)
{
	int ret;

	dss_pwrdm = pwrdm_lookup("dss_pwrdm");
	if (!dss_pwrdm)
		pr_info("%s: Not found dss_pwrdm\n", __func__);

	if (mapphone_dt_panel_init())
		printk(KERN_INFO "panel: using non-dt configuration\n");

	mapphone_panel_get_fb_info();
	omapfb_set_platform_data(&mapphone_fb_data);

	ret = gpio_request(mapphone_panel_data.reset_gpio, "display reset");
	if (ret) {
		printk(KERN_ERR "failed to get display reset gpio\n");
		goto failed_reset;
	}

	if (mapphone_displ_pwr_sup_en != 0) {
		printk(KERN_INFO "DT: display power supply en = %d\n",
					mapphone_displ_pwr_sup_en);
		ret = gpio_request(mapphone_displ_pwr_sup_en, "LCD-pwr_sup_en");
		if (ret) {
			printk(KERN_ERR "failed to req for LCD-pwr_sup_en\n");
			goto failed_reset;
		}

		gpio_direction_output(mapphone_displ_pwr_sup_en, 1);
	}

	if (mapphone_feature_hdmi && mapphone_hdmi_5v_enable != 0) {
		ret = gpio_request(mapphone_hdmi_5v_enable, "HDMI-5V-En");
		if (ret) {
			printk(KERN_ERR "Failed hdmi 5v en gpio request\n");
			goto failed_hdmi_5v;
		} else {
			printk(KERN_DEBUG "Enabing hdmi 5v gpio\n");
			gpio_direction_output(mapphone_hdmi_5v_enable, 1);
			gpio_set_value(mapphone_hdmi_5v_enable, 0);
		}

		platform_device_register(&omap_dssmgr_device);
	} else {
		/* Remove HDTV from the DSS device list */
		mapphone_dss_data.num_devices--;
	}

	platform_device_register(&omap_panel_device);
	omap_display_init(&mapphone_dss_data);

	return;

failed_hdmi_5v:
	gpio_free(mapphone_hdmi_5v_enable);
failed_reset:
	gpio_free(mapphone_panel_data.reset_gpio);
}
void __init mapphone_panel_init(void)
{
	struct mapphone_dsi_panel_pwr_supply *supply;
	struct mapphone_dsi_panel_data *panel_data =
		(struct mapphone_dsi_panel_data *)mapphone_lcd_device.data;
	int ret;
	int i;
	int num_gpio_handled = 0;

	dss_pwrdm = pwrdm_lookup("dss_pwrdm");
	if (!dss_pwrdm)
		pr_info("%s: Not found dss_pwrdm\n", __func__);

	if (mapphone_dt_panel_init())
		PANELINFO(": using non-dt configuration\n");

	mapphone_panel_get_fb_info();
	omapfb_set_platform_data(&mapphone_fb_data);

	ret = gpio_request(mapphone_panel_data.reset_gpio, "display reset");
	if (ret) {
		PANELERR("failed to get display reset gpio\n");
		goto failed_reset;
	}

	gpio_direction_output(mapphone_panel_data.reset_gpio, 1);

	for (i = 0; i < panel_data->num_pwr_supply; i++) {
		supply = &(panel_data->disp_vol_supply[i]);
		if (supply->en_gpio != 0) {
			ret = gpio_request(supply->en_gpio,
							"LCD-pwr_sup_en");
			if (ret) {
				PANELERR("Supply %d, failed to req for "
					"LCD-pwr_sup_en\n", i);
				num_gpio_handled = i;
				goto failed_pwr_supply;
			}

			gpio_direction_output(supply->en_gpio,
					supply->en_gpio_value);
		}
	}
	num_gpio_handled = panel_data->num_pwr_supply;

	if (mapphone_displ_lvds_cabc_en >= 0) {
		ret = gpio_request(mapphone_displ_lvds_cabc_en,
					"LCD-lvds_cabc_en");
		if (ret) {
			printk(KERN_ERR "Failed LCD-lvds_cabc_en req\n");
			goto failed_req_lvds_en;
		}
		gpio_direction_output(mapphone_displ_lvds_cabc_en, 1);
	}

	if (mapphone_displ_color_en >= 0) {
		ret = gpio_request(mapphone_displ_color_en, "LCD-color_en");
		if (ret) {
			printk(KERN_ERR "Failed LCD-color_en req\n");
			goto failed_req_color_en;
		}
		gpio_direction_output(mapphone_displ_color_en, 1);
	}

	if (mapphone_displ_lcd_bl_pwm >= 0) {
		ret = gpio_request(mapphone_displ_lcd_bl_pwm,
					"LCD-lcd_bl_pwm");
		if (ret) {
			printk(KERN_ERR "Failed LCD-lcd_bl_pwm req\n");
			goto failed_req_lcd_bl_pwm;
		}
		gpio_direction_output(mapphone_displ_lcd_bl_pwm, 0);
	}

	if (mapphone_displ_lvds_wp_g >= 0) {
		ret = gpio_request(mapphone_displ_lvds_wp_g,
					"LCD-lvds_wp_g");
		if (ret) {
			printk(KERN_ERR "Failed LCD-lvds_wp_g req\n");
			goto failed_req_lvds_wp_g;
		}
		gpio_direction_output(mapphone_displ_lvds_wp_g, 1);
	}

	if (mapphone_displ_lvds_wp_e >= 0) {
		ret = gpio_request(mapphone_displ_lvds_wp_e,
					"LCD-lvds_wp_e");
		if (ret) {
			printk(KERN_ERR "Failed LCD-lvds_wp_e req\n");
			goto failed_req_lvds_wp_e;
		}
		gpio_direction_output(mapphone_displ_lvds_wp_e, 1);
	}

	if (mapphone_feature_hdmi) {
		/* Set the bits to disable "internal pullups" for the DDC
		 * clk and data lines.  This is required for ES2.3 parts
		 * and beyond.  If these are not set EDID reads fails.
		 */
		if (cpu_is_omap44xx()) {
			omap_writel(HDMI_CONTROL_I2C_1_DDC_PU_DIS,
						HDMI_CONTROL_I2C_1_REG);
		}
		platform_device_register(&omap_dssmgr_device);
	} else {
		/* Remove HDTV from the DSS device list */
		mapphone_dss_data.num_devices--;
	}

	platform_device_register(&omap_panel_device);
	omap_display_init(&mapphone_dss_data);

	return;

failed_hdmi_5v:
	gpio_free(mapphone_displ_lvds_wp_e);
failed_req_lvds_wp_e:
	gpio_free(mapphone_displ_lvds_wp_g);
failed_req_lvds_wp_g:
	gpio_free(mapphone_displ_lcd_bl_pwm);
failed_req_lcd_bl_pwm:
	gpio_free(mapphone_displ_color_en);
failed_req_color_en:
	gpio_free(mapphone_displ_lvds_cabc_en);
failed_req_lvds_en:
failed_pwr_supply:
	for (i = 0; i < num_gpio_handled; i++) {
		supply = &(panel_data->disp_vol_supply[i]);
		if (supply->en_gpio != 0)
			gpio_free(supply->en_gpio);
	}
failed_reset:
	gpio_free(mapphone_panel_data.reset_gpio);
}