示例#1
0
static int hv070wx1_power_on(struct omap_dss_device *dssdev)
{
	struct hv070wx1 *lcd = dev_get_drvdata(&dssdev->dev);
	int ret;

	/* At power on the first vsync has not been received yet*/
	dssdev->first_vsync = false;

	/* VDD 3.3V power on */
	if (lcd->pdata->set_power)
		lcd->pdata->set_power(true);

	usleep_range(10000, 11000);

	/* VIDEO ON */
	ret = omapdss_dsi_display_enable(dssdev);
	if (ret) {
		pr_err("Failed to enable DSI\n");
		return ret;
	}

	/* reset s6e8aa0 bridge */
	if (!dssdev->skip_init) {
		hv070wx1_config(dssdev);

		/* DSI_DT_PXLSTREAM_24BPP_PACKED; */
		dsi_video_mode_enable(dssdev, MIPI_DSI_PACKED_PIXEL_STREAM_24);
	}

	if (dssdev->skip_init)
		dssdev->skip_init = false;

	return 0;
}
示例#2
0
static int sn65dsi86_power_on(struct omap_dss_device *dssdev)
{
	struct sn65dsi86_data *d2d = dev_get_drvdata(&dssdev->dev);
	uint8_t *buf = NULL;
	int r;

	dev_dbg(&dssdev->dev, "power_on\n");
	buf = kzalloc(256, GFP_KERNEL);

	if (dssdev->platform_enable)
		dssdev->platform_enable(dssdev);

	r = omapdss_dsi_display_enable(dssdev);
	if (r) {
		dev_err(&dssdev->dev, "failed to enable DSI\n");
		goto err_disp_enable;
	}

	/*turn on HS clock to bring up bridge i2c slave */
	omapdss_dsi_vc_enable_hs(dssdev, d2d->channel0, true);
	// todo
	msleep(10);
	sn65dsi86_hw_reset(dssdev);

	r = dsi_enable_video_output(dssdev, d2d->channel0);
	r = sn65dsi86_write_init_config(dssdev);
	if (r)
		goto err_write_init;

	dev_dbg(&dssdev->dev, "power_on done\n");
	return r;

err_write_init:
	omapdss_dsi_display_disable(dssdev, false, false);
err_disp_enable:
	if (dssdev->platform_disable)
		dssdev->platform_disable(dssdev);
	if (buf != NULL) kfree(buf);
	return r;
}
示例#3
0
static int s6e8aa0a01_probe(struct omap_dss_device *dssdev)
{
	struct device *lcd_dev;
	struct backlight_properties props = {
		.brightness	= 255,
		.max_brightness = 255,
		.type		= BACKLIGHT_RAW,
	};
	struct s6e8aa0a01_data *s6;
	int ret = 0;
#ifdef CONFIG_SMART_DIMMING
	u8 mtp_data[LDI_MTP_LENGTH] = { 0, };
#endif
	dev_dbg(&dssdev->dev, "%s is called", __func__);

	if (unlikely(!dssdev->data)) {
		dev_err(&dssdev->dev, "no platform data!\n");
		return -EINVAL;
	}

	dssdev->panel.config = OMAP_DSS_LCD_TFT;

	dssdev->panel.acbi = 0;
	dssdev->panel.acb = 40;

	s6 = kzalloc(sizeof(*s6), GFP_KERNEL);
	if (unlikely(!s6))
		return -ENOMEM;

	s6->dssdev = dssdev;
	s6->pdata = dssdev->data;

	s6->bl = GAMMA_MAX;
	s6->current_bl = GAMMA_MAX;

	if (!s6->pdata->seq_display_set || !s6->pdata->seq_etc_set) {
		dev_err(&dssdev->dev, "Invalid platform data\n");
		ret = -EINVAL;
		goto err;
	}

	ret = gpio_request(s6->pdata->reset_gpio, "s6e8aa0a01_reset");
	if (unlikely(ret < 0)) {
		dev_err(&dssdev->dev, "gpio_request %d failed!\n",
			s6->pdata->reset_gpio);
		goto err;
	}
	gpio_direction_output(s6->pdata->reset_gpio, 1);

	ret = gpio_request(s6->pdata->oled_id_gpio, "s6e8aa0a01_connected");
	if (unlikely(ret < 0)) {
		dev_err(&dssdev->dev, "gpio_request %d failed!\n",
			s6->pdata->oled_id_gpio);
		goto err;
	}
	gpio_direction_input(s6->pdata->oled_id_gpio);
	s6->connected = gpio_get_value(s6->pdata->oled_id_gpio);
	if (!s6->connected)
		dev_info(&dssdev->dev,
			 "*** s6e8aa0a01 panel is not connected!\n\n");

	ret = request_threaded_irq(s6->pdata->oled_det_irq, NULL,
				s6e8aa0a01_oled_det_thread,
				IRQF_TRIGGER_FALLING, "oled_detection", s6);
	if (ret)
		dev_err(&dssdev->dev, "Failed to request IRQ %d: %d\n",
			s6->pdata->oled_det_irq, ret);

	disable_irq_nosync(s6->pdata->oled_det_irq);

	mutex_init(&s6->lock);

	atomic_set(&s6->do_update, 0);

	dev_set_drvdata(&dssdev->dev, s6);

	/* Register DSI backlight  control */
	s6->bd = backlight_device_register("panel", &dssdev->dev, dssdev,
					   &s6e8aa0a01_backlight_ops, &props);
	if (IS_ERR(s6->bd)) {
		ret = PTR_ERR(s6->bd);
		goto err_backlight_device_register;
	}

	s6->acl_enable = true;

	if (cpu_is_omap44xx())
		s6->force_update = true;

	lcd_class = class_create(THIS_MODULE, "lcd");
	if (IS_ERR(lcd_class)) {
		pr_err("Failed to create lcd_class!");
		goto err_backlight_device_register;
	}

	lcd_dev = device_create(lcd_class, NULL, 0, NULL, "panel");
	if (IS_ERR(lcd_dev)) {
		pr_err("Failed to create device(panel)!\n");
		goto err_lcd_class;
	}

	dev_set_drvdata(lcd_dev, &dssdev->dev);

	ret = device_create_file(lcd_dev, &dev_attr_lcd_type);
	if (unlikely(ret < 0)) {
		dev_err(lcd_dev, "failed to add 'lcd_type' sysfs entries\n");
		goto err_lcd_device;
	}

	ret = device_create_file(lcd_dev, &dev_attr_lcd_power);
	if (unlikely(ret < 0)) {
		dev_err(lcd_dev, "failed to add 'lcd_power' sysfs entries\n");
		goto err_lcd_type;
	}

	ret = device_create_file(lcd_dev, &dev_attr_power_reduce);
	if (unlikely(ret < 0)) {
		dev_err(lcd_dev, "failed to add 'power_reduce' sysfs entries\n");
		goto err_lcd_power;
	}

	ret = device_create_file(&s6->bd->dev, &dev_attr_auto_brightness);
	if (unlikely(ret < 0)) {
		dev_err(lcd_dev, "failed to add 'auto_brightness' sysfs entries\n");
		goto err_power_reduce;
	}

	dsi_bus_lock(dssdev);
	s6e8aa0a01_read_id_info(s6);
	dev_info(&dssdev->dev, "ID: %x, %x, %x\n",
		 s6->panel_id[0], s6->panel_id[1], s6->panel_id[2]);

#ifdef CONFIG_SMART_DIMMING
	s6e8aa0a01_check_id(s6);

	init_table_info(&s6->smart);

	calc_voltage_table(&s6->smart, s6->pdata->mtp_data);

	if (s6->support_elvss)
		ret = init_elvss_table(s6);
	else {
		s6->elvss_table = (unsigned char **)ELVSS_TABLE;
		ret = 0;
	}

	ret += s6e8aa0a01_init_gamma_table(s6);

#ifdef CONFIG_AID_DIMMING
	if (s6->panel_id[1] == 0x01 || s6->panel_id[1] == 0x02) {
		pr_info("AID Dimming is started. %d\n", s6->panel_id[1]);
		s6->support_aid = 1;
		ret += s6e8aa0a01_init_aid_dimming_table(s6);
	}
#endif /* CONFIG_AID_DIMMING */

	if (unlikely(ret)) {
		pr_warn("gamma table generation is failed\n");
		s6->gamma_table = (unsigned char **)gamma22_table;
		s6->elvss_table = (unsigned char **)ELVSS_TABLE;
	}
#endif /* CONFIG_SMART_DIMMING */

	dsi_bus_unlock(dssdev);

	dev_dbg(&dssdev->dev, "s6e8aa0a01_probe\n");
	return ret;

err_power_reduce:
	device_remove_file(lcd_dev, &dev_attr_power_reduce);
err_lcd_power:
	device_remove_file(lcd_dev, &dev_attr_lcd_power);
err_lcd_type:
	device_remove_file(lcd_dev, &dev_attr_lcd_type);
err_lcd_device:
	device_destroy(lcd_class, 0);
err_lcd_class:
	class_destroy(lcd_class);
err_backlight_device_register:
	mutex_destroy(&s6->lock);
	gpio_free(s6->pdata->reset_gpio);
	gpio_free(s6->pdata->oled_id_gpio);
err:
	kfree(s6);

	return ret;
}

static void s6e8aa0a01_remove(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	backlight_device_unregister(s6->bd);
	mutex_destroy(&s6->lock);
	gpio_free(s6->pdata->reset_gpio);
	gpio_free(s6->pdata->oled_id_gpio);
	kfree(s6);
}

/**
 * s6e8aa0a01_config - Configure S6E8AA0A01
 *
 * Initial configuration for S6E8AA0A01 configuration registers, PLL...
 */
static void s6e8aa0a01_config(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	struct panel_s6e8aa0a01_data *pdata = s6->pdata;

	if (!s6->connected)
		return;

	s6e8aa0a01_write_sequence(dssdev, pdata->seq_display_set,
				  pdata->seq_display_set_size);

	s6e8aa0a01_update_brightness(dssdev, 1);

	s6e8aa0a01_write_sequence(dssdev, pdata->seq_etc_set,
				  pdata->seq_etc_set_size);
}

static int s6e8aa0a01_power_on(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	int ret = 0;

	pr_info(" %s, called + ", __func__);
	/* At power on the first vsync has not been received yet */
	dssdev->first_vsync = false;

	if (s6->enabled != 1) {
		if (s6->pdata->set_power)
			s6->pdata->set_power(true);

		ret = omapdss_dsi_display_enable(dssdev);
		if (ret) {
			dev_err(&dssdev->dev, "failed to enable DSI\n");
			goto err;
		}

		/* reset s6e8aa0a01 bridge */
		if (!dssdev->skip_init) {
			s6e8aa0a01_hw_reset(dssdev);

			/* XXX */
			msleep(100);
			s6e8aa0a01_config(dssdev);

			/* DSI_DT_PXLSTREAM_24BPP_PACKED; */
			dsi_video_mode_enable(dssdev, 0x3E);
		}

		s6->enabled = 1;
	}

	if (dssdev->skip_init)
		dssdev->skip_init = false;
	pr_info(" %s, called - ", __func__);
err:
	return ret;
}

static void s6e8aa0a01_power_off(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	pr_info(" %s, called + ", __func__);
	gpio_set_value(s6->pdata->reset_gpio, 0);
	usleep_range(10 * 1000, 11 * 1000);

	s6->enabled = 0;
	omapdss_dsi_display_disable(dssdev, 0, 0);

	if (s6->pdata->set_power)
		s6->pdata->set_power(false);
	pr_info(" %s, called - ", __func__);
}

static int s6e8aa0a01_start(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	unsigned long pclk;
	int ret;

	dsi_bus_lock(dssdev);

	ret = s6e8aa0a01_power_on(dssdev);

	dsi_bus_unlock(dssdev);

	if (ret) {
		dev_dbg(&dssdev->dev, "enable failed\n");
		dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
	} else {
		dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
		dssdev->manager->enable(dssdev->manager);
	}

	/* fixup pclk based on pll config */
	pclk = dispc_pclk_rate(dssdev->channel);
	if (pclk)
		dssdev->panel.timings.pixel_clock = (pclk + 500) / 1000;

	enable_irq(s6->pdata->oled_det_irq);

	return ret;
}

static void s6e8aa0a01_stop(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	disable_irq_nosync(s6->pdata->oled_det_irq);

	dssdev->manager->disable(dssdev->manager);

	dsi_bus_lock(dssdev);

	s6e8aa0a01_power_off(dssdev);

	dsi_bus_unlock(dssdev);
}

static void s6e8aa0a01_disable(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	dev_dbg(&dssdev->dev, "%s\n", __func__);

	mutex_lock(&s6->lock);
	if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
		s6e8aa0a01_stop(dssdev);

	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
	mutex_unlock(&s6->lock);
}

static int s6e8aa0a01_enable(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	int ret;

	dev_dbg(&dssdev->dev, "%s\n", __func__);

	mutex_lock(&s6->lock);
	if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
		ret = -EINVAL;
		goto out;
	}

	ret = s6e8aa0a01_start(dssdev);
out:
	mutex_unlock(&s6->lock);
	return ret;
}

static void s6e8aa0a01_framedone_cb(int err, void *data)
{
	struct omap_dss_device *dssdev = data;

	dev_dbg(&dssdev->dev, "framedone, err %d\n", err);
	dsi_bus_unlock(dssdev);
}

static int s6e8aa0a01_update(struct omap_dss_device *dssdev,
			     u16 x, u16 y, u16 w, u16 h)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	int ret = 0;

	dev_dbg(&dssdev->dev, "update %d, %d, %d x %d\n", x, y, w, h);

	mutex_lock(&s6->lock);
	dsi_bus_lock(dssdev);

	if (!s6->enabled) {
		ret = 0;
		goto out;
	}

	ret = omap_dsi_prepare_update(dssdev, &x, &y, &w, &h, true);
	if (ret)
		goto out;

	/* We use VC(0) for VideoPort Data and VC(1) for commands */
	ret = omap_dsi_update(dssdev, 0, x, y, w, h,
			      s6e8aa0a01_framedone_cb, dssdev);

out:
	dsi_bus_unlock(dssdev);
	mutex_unlock(&s6->lock);
	return ret;
}

static int s6e8aa0a01_sync(struct omap_dss_device *dssdev)
{
	/* TODO: */
	return 0;
}

static int s6e8aa0a01_set_update_mode(struct omap_dss_device *dssdev,
				      enum omap_dss_update_mode mode)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	if (s6->force_update) {
		if (mode != OMAP_DSS_UPDATE_AUTO)
			return -EINVAL;
	} else {
		if (mode != OMAP_DSS_UPDATE_MANUAL)
			return -EINVAL;
	}

	return 0;
}

static enum omap_dss_update_mode
s6e8aa0a01_get_update_mode(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);

	if (s6->force_update)
		return OMAP_DSS_UPDATE_AUTO;
	else
		return OMAP_DSS_UPDATE_MANUAL;
}

#ifdef CONFIG_PM
static int s6e8aa0a01_resume(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	int ret;

	dev_dbg(&dssdev->dev, "resume\n");

	mutex_lock(&s6->lock);
	if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED) {
		ret = -EINVAL;
		goto out;
	}
	ret = s6e8aa0a01_start(dssdev);

out:
	mutex_unlock(&s6->lock);
	return ret;
}

static int s6e8aa0a01_suspend(struct omap_dss_device *dssdev)
{
	struct s6e8aa0a01_data *s6 = dev_get_drvdata(&dssdev->dev);
	int ret = 0;

	dev_dbg(&dssdev->dev, "suspend\n");

	mutex_lock(&s6->lock);
	if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
		ret = -EINVAL;
		goto out;
	}
	s6e8aa0a01_stop(dssdev);
	dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;

out:
	mutex_unlock(&s6->lock);
	return ret;
}
#endif /* CONFIG_PM */

static struct omap_dss_driver s6e8aa0a01_driver = {
	.probe		= s6e8aa0a01_probe,
	.remove		= s6e8aa0a01_remove,
	.enable		= s6e8aa0a01_enable,
	.disable	= s6e8aa0a01_disable,
#ifdef CONFIG_PM
	.suspend	= s6e8aa0a01_suspend,
	.resume		= s6e8aa0a01_resume,
#endif
	.set_update_mode = s6e8aa0a01_set_update_mode,
	.get_update_mode = s6e8aa0a01_get_update_mode,

	.update		= s6e8aa0a01_update,
	.sync		= s6e8aa0a01_sync,

	.get_resolution = s6e8aa0a01_get_resolution,
	.get_recommended_bpp = omapdss_default_get_recommended_bpp,

	/* dummy entry start */
	.enable_te	= s6e8aa0a01_enable_te,
	.set_rotate	= s6e8aa0a01_rotate,
	.get_rotate	= s6e8aa0a01_get_rotate,
	.set_mirror	= s6e8aa0a01_mirror,
	.get_mirror	= s6e8aa0a01_get_mirror,
	/* dummy entry end */

	.get_timings	= s6e8aa0a01_get_timings,
	.set_timings	= s6e8aa0a01_set_timings,
	.check_timings	= s6e8aa0a01_check_timings,

	.driver = {
		.name	= "s6e8aa0a01",
		.owner	= THIS_MODULE,
	},
};

static int __init s6e8aa0a01_init(void)
{
	omap_dss_register_driver(&s6e8aa0a01_driver);

	return 0;
}