static int n8x0_panel_resume(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = get_drv_data(dssdev); int r; dev_dbg(&dssdev->dev, "resume\n"); mutex_lock(&ddata->lock); rfbi_bus_lock(); r = n8x0_panel_power_on(dssdev); rfbi_bus_unlock(); if (r) { mutex_unlock(&ddata->lock); return r; } dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; mutex_unlock(&ddata->lock); return 0; }
static int n8x0_bl_update_status(struct backlight_device *dev) { struct omap_dss_device *dssdev = dev_get_drvdata(&dev->dev); struct panel_n8x0_data *bdata = get_board_data(dssdev); struct panel_drv_data *ddata = get_drv_data(dssdev); int r; int level; mutex_lock(&ddata->lock); if (dev->props.fb_blank == FB_BLANK_UNBLANK && dev->props.power == FB_BLANK_UNBLANK) level = dev->props.brightness; else level = 0; dev_dbg(&dssdev->dev, "update brightness to %d\n", level); if (!bdata->set_backlight) r = -EINVAL; else r = bdata->set_backlight(dssdev, level); mutex_unlock(&ddata->lock); return r; }
static int n8x0_panel_update(struct omap_dss_device *dssdev, u16 x, u16 y, u16 w, u16 h) { struct panel_drv_data *ddata = get_drv_data(dssdev); u16 dw, dh; dev_dbg(&dssdev->dev, "update\n"); dw = dssdev->panel.timings.x_res; dh = dssdev->panel.timings.y_res; if (x != 0 || y != 0 || w != dw || h != dh) { dev_err(&dssdev->dev, "invaid update region %d, %d, %d, %d\n", x, y, w, h); return -EINVAL; } mutex_lock(&ddata->lock); rfbi_bus_lock(); blizzard_ctrl_setup_update(dssdev, x, y, w, h); omap_rfbi_update(dssdev, update_done, NULL); mutex_unlock(&ddata->lock); return 0; }
static int n8x0_panel_sync(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = get_drv_data(dssdev); dev_dbg(&dssdev->dev, "sync\n"); mutex_lock(&ddata->lock); rfbi_bus_lock(); rfbi_bus_unlock(); mutex_unlock(&ddata->lock); return 0; }
static void n8x0_panel_remove(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = get_drv_data(dssdev); struct backlight_device *bldev; dev_dbg(&dssdev->dev, "remove\n"); bldev = ddata->bldev; bldev->props.power = FB_BLANK_POWERDOWN; n8x0_bl_update_status(bldev); backlight_device_unregister(bldev); dev_set_drvdata(&dssdev->dev, NULL); }
static void blizzard_ctrl_setup_update(struct omap_dss_device *dssdev, int x, int y, int w, int h) { struct panel_drv_data *ddata = get_drv_data(dssdev); u8 tmp[18]; int x_end, y_end; x_end = x + w - 1; y_end = y + h - 1; tmp[0] = x; tmp[1] = x >> 8; tmp[2] = y; tmp[3] = y >> 8; tmp[4] = x_end; tmp[5] = x_end >> 8; tmp[6] = y_end; tmp[7] = y_end >> 8; /* scaling? */ tmp[8] = x; tmp[9] = x >> 8; tmp[10] = y; tmp[11] = y >> 8; tmp[12] = x_end; tmp[13] = x_end >> 8; tmp[14] = y_end; tmp[15] = y_end >> 8; tmp[16] = BLIZZARD_COLOR_RGB565; if (ddata->blizzard_ver == BLIZZARD_VERSION_S1D13745) tmp[17] = BLIZZARD_SRC_WRITE_LCD_BACKGROUND; else tmp[17] = ddata->blizzard_ver == BLIZZARD_VERSION_S1D13744 ? BLIZZARD_SRC_WRITE_LCD : BLIZZARD_SRC_WRITE_LCD_DESTRUCTIVE; omapdss_rfbi_set_pixel_size(dssdev, 16); omapdss_rfbi_set_data_lines(dssdev, 8); omap_rfbi_configure(dssdev); blizzard_write(BLIZZARD_INPUT_WIN_X_START_0, tmp, 18); omapdss_rfbi_set_pixel_size(dssdev, 16); omapdss_rfbi_set_data_lines(dssdev, 16); omap_rfbi_configure(dssdev); }
static void n8x0_panel_disable(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = get_drv_data(dssdev); dev_dbg(&dssdev->dev, "disable\n"); mutex_lock(&ddata->lock); rfbi_bus_lock(); n8x0_panel_power_off(dssdev); rfbi_bus_unlock(); dssdev->state = OMAP_DSS_DISPLAY_DISABLED; mutex_unlock(&ddata->lock); }
static void n8x0_panel_power_off(struct omap_dss_device *dssdev) { struct panel_n8x0_data *bdata = get_board_data(dssdev); struct panel_drv_data *ddata = get_drv_data(dssdev); struct spi_device *spi = ddata->spidev; if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) return; send_display_off(spi); send_sleep_in(spi); if (bdata->platform_disable) bdata->platform_disable(dssdev); gpio_direction_output(bdata->ctrl_pwrdown, 0); omapdss_rfbi_display_disable(dssdev); }
static int n8x0_panel_update(struct omap_dss_device *dssdev, u16 x, u16 y, u16 w, u16 h) { struct panel_drv_data *ddata = get_drv_data(dssdev); dev_dbg(&dssdev->dev, "update\n"); mutex_lock(&ddata->lock); rfbi_bus_lock(); omap_rfbi_prepare_update(dssdev, &x, &y, &w, &h); blizzard_ctrl_setup_update(dssdev, x, y, w, h); omap_rfbi_update(dssdev, x, y, w, h, update_done, NULL); mutex_unlock(&ddata->lock); return 0; }
static int n8x0_panel_suspend(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = get_drv_data(dssdev); dev_dbg(&dssdev->dev, "suspend\n"); mutex_lock(&ddata->lock); rfbi_bus_lock(); n8x0_panel_power_off(dssdev); rfbi_bus_unlock(); dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED; mutex_unlock(&ddata->lock); return 0; }
static void n8x0_panel_power_off(struct omap_dss_device *dssdev) { struct panel_n8x0_data *bdata = get_board_data(dssdev); struct panel_drv_data *ddata = get_drv_data(dssdev); struct spi_device *spi = ddata->spidev; if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) return; send_display_off(spi); send_sleep_in(spi); if (bdata->platform_disable) bdata->platform_disable(dssdev); /* * HACK: we should turn off the panel here, but there is some problem * with the initialization sequence, and we fail to init the panel if we * have turned it off */ /* gpio_direction_output(bdata->panel_reset, 0); */ gpio_direction_output(bdata->ctrl_pwrdown, 0); omapdss_rfbi_display_disable(dssdev); }
static int n8x0_panel_power_on(struct omap_dss_device *dssdev) { int r; struct panel_n8x0_data *bdata = get_board_data(dssdev); struct panel_drv_data *ddata = get_drv_data(dssdev); struct spi_device *spi = ddata->spidev; u8 rev, conf; u8 display_id[3]; const char *panel_name; if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) return 0; gpio_direction_output(bdata->ctrl_pwrdown, 1); if (bdata->platform_enable) { r = bdata->platform_enable(dssdev); if (r) goto err_plat_en; } r = omapdss_rfbi_display_enable(dssdev); if (r) goto err_rfbi_en; rev = blizzard_read_reg(BLIZZARD_REV_CODE); conf = blizzard_read_reg(BLIZZARD_CONFIG); switch (rev & 0xfc) { case 0x9c: ddata->blizzard_ver = BLIZZARD_VERSION_S1D13744; dev_info(&dssdev->dev, "s1d13744 LCD controller rev %d " "initialized (CNF pins %x)\n", rev & 0x03, conf & 0x07); break; case 0xa4: ddata->blizzard_ver = BLIZZARD_VERSION_S1D13745; dev_info(&dssdev->dev, "s1d13745 LCD controller rev %d " "initialized (CNF pins %x)\n", rev & 0x03, conf & 0x07); break; default: dev_err(&dssdev->dev, "invalid s1d1374x revision %02x\n", rev); r = -ENODEV; goto err_inv_chip; } /* panel */ gpio_direction_output(bdata->panel_reset, 1); mipid_read(spi, MIPID_CMD_READ_DISP_ID, display_id, 3); dev_dbg(&spi->dev, "MIPI display ID: %02x%02x%02x\n", display_id[0], display_id[1], display_id[2]); switch (display_id[0]) { case 0x45: panel_name = "lph8923"; break; case 0x83: panel_name = "ls041y3"; break; default: dev_err(&dssdev->dev, "invalid display ID 0x%x\n", display_id[0]); r = -ENODEV; goto err_inv_panel; } dev_info(&dssdev->dev, "%s rev %02x LCD detected\n", panel_name, display_id[1]); send_sleep_out(spi); send_init_string(spi); set_data_lines(spi, 24); send_display_on(spi); return 0; err_inv_panel: /* * HACK: we should turn off the panel here, but there is some problem * with the initialization sequence, and we fail to init the panel if we * have turned it off */ /* gpio_direction_output(bdata->panel_reset, 0); */ err_inv_chip: omapdss_rfbi_display_disable(dssdev); err_rfbi_en: if (bdata->platform_disable) bdata->platform_disable(dssdev); err_plat_en: gpio_direction_output(bdata->ctrl_pwrdown, 0); return r; }