diff options
| author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-05-24 07:22:31 -0400 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-06-17 07:32:25 -0400 |
| commit | 84192742d9c26d75f26751f9e692cc68230d43a5 (patch) | |
| tree | 15cfeadc7f91a90d11ba156ebaf5bf6a750d73fe | |
| parent | dbc23840b4d70fd1c284987cea68a476e3634d5a (diff) | |
OMAPDSS: Add Sony ACX565AKM panel driver
Add Sony ACX565AKM panel driver which uses the new DSS device model and
DSS ops.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
| -rw-r--r-- | drivers/video/omap2/displays-new/Kconfig | 6 | ||||
| -rw-r--r-- | drivers/video/omap2/displays-new/Makefile | 1 | ||||
| -rw-r--r-- | drivers/video/omap2/displays-new/panel-sony-acx565akm.c | 865 | ||||
| -rw-r--r-- | include/video/omap-panel-data.h | 16 |
4 files changed, 888 insertions, 0 deletions
diff --git a/drivers/video/omap2/displays-new/Kconfig b/drivers/video/omap2/displays-new/Kconfig index efb72b352efd..25696583e206 100644 --- a/drivers/video/omap2/displays-new/Kconfig +++ b/drivers/video/omap2/displays-new/Kconfig | |||
| @@ -38,4 +38,10 @@ config DISPLAY_PANEL_DSI_CM | |||
| 38 | help | 38 | help |
| 39 | Driver for generic DSI command mode panels. | 39 | Driver for generic DSI command mode panels. |
| 40 | 40 | ||
| 41 | config DISPLAY_PANEL_SONY_ACX565AKM | ||
| 42 | tristate "ACX565AKM Panel" | ||
| 43 | depends on SPI && BACKLIGHT_CLASS_DEVICE | ||
| 44 | help | ||
| 45 | This is the LCD panel used on Nokia N900 | ||
| 46 | |||
| 41 | endmenu | 47 | endmenu |
diff --git a/drivers/video/omap2/displays-new/Makefile b/drivers/video/omap2/displays-new/Makefile index 557c48226296..c07bd1e17f47 100644 --- a/drivers/video/omap2/displays-new/Makefile +++ b/drivers/video/omap2/displays-new/Makefile | |||
| @@ -5,3 +5,4 @@ obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o | |||
| 5 | obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o | 5 | obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o |
| 6 | obj-$(CONFIG_DISPLAY_PANEL_DPI) += panel-dpi.o | 6 | obj-$(CONFIG_DISPLAY_PANEL_DPI) += panel-dpi.o |
| 7 | obj-$(CONFIG_DISPLAY_PANEL_DSI_CM) += panel-dsi-cm.o | 7 | obj-$(CONFIG_DISPLAY_PANEL_DSI_CM) += panel-dsi-cm.o |
| 8 | obj-$(CONFIG_DISPLAY_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o | ||
diff --git a/drivers/video/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c new file mode 100644 index 000000000000..e6d56f714ae4 --- /dev/null +++ b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c | |||
| @@ -0,0 +1,865 @@ | |||
| 1 | /* | ||
| 2 | * Sony ACX565AKM LCD Panel driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Nokia Corporation | ||
| 5 | * | ||
| 6 | * Original Driver Author: Imre Deak <imre.deak@nokia.com> | ||
| 7 | * Based on panel-generic.c by Tomi Valkeinen <tomi.valkeinen@nokia.com> | ||
| 8 | * Adapted to new DSS2 framework: Roger Quadros <roger.quadros@nokia.com> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify it | ||
| 11 | * under the terms of the GNU General Public License version 2 as published by | ||
| 12 | * the Free Software Foundation. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 17 | * more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License along with | ||
| 20 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/platform_device.h> | ||
| 26 | #include <linux/delay.h> | ||
| 27 | #include <linux/spi/spi.h> | ||
| 28 | #include <linux/jiffies.h> | ||
| 29 | #include <linux/sched.h> | ||
| 30 | #include <linux/backlight.h> | ||
| 31 | #include <linux/fb.h> | ||
| 32 | #include <linux/gpio.h> | ||
| 33 | |||
| 34 | #include <video/omapdss.h> | ||
| 35 | #include <video/omap-panel-data.h> | ||
| 36 | |||
| 37 | #define MIPID_CMD_READ_DISP_ID 0x04 | ||
| 38 | #define MIPID_CMD_READ_RED 0x06 | ||
| 39 | #define MIPID_CMD_READ_GREEN 0x07 | ||
| 40 | #define MIPID_CMD_READ_BLUE 0x08 | ||
| 41 | #define MIPID_CMD_READ_DISP_STATUS 0x09 | ||
| 42 | #define MIPID_CMD_RDDSDR 0x0F | ||
| 43 | #define MIPID_CMD_SLEEP_IN 0x10 | ||
| 44 | #define MIPID_CMD_SLEEP_OUT 0x11 | ||
| 45 | #define MIPID_CMD_DISP_OFF 0x28 | ||
| 46 | #define MIPID_CMD_DISP_ON 0x29 | ||
| 47 | #define MIPID_CMD_WRITE_DISP_BRIGHTNESS 0x51 | ||
| 48 | #define MIPID_CMD_READ_DISP_BRIGHTNESS 0x52 | ||
| 49 | #define MIPID_CMD_WRITE_CTRL_DISP 0x53 | ||
| 50 | |||
| 51 | #define CTRL_DISP_BRIGHTNESS_CTRL_ON (1 << 5) | ||
| 52 | #define CTRL_DISP_AMBIENT_LIGHT_CTRL_ON (1 << 4) | ||
| 53 | #define CTRL_DISP_BACKLIGHT_ON (1 << 2) | ||
| 54 | #define CTRL_DISP_AUTO_BRIGHTNESS_ON (1 << 1) | ||
| 55 | |||
| 56 | #define MIPID_CMD_READ_CTRL_DISP 0x54 | ||
| 57 | #define MIPID_CMD_WRITE_CABC 0x55 | ||
| 58 | #define MIPID_CMD_READ_CABC 0x56 | ||
| 59 | |||
| 60 | #define MIPID_VER_LPH8923 3 | ||
| 61 | #define MIPID_VER_LS041Y3 4 | ||
| 62 | #define MIPID_VER_L4F00311 8 | ||
| 63 | #define MIPID_VER_ACX565AKM 9 | ||
| 64 | |||
| 65 | struct panel_drv_data { | ||
| 66 | struct omap_dss_device dssdev; | ||
| 67 | struct omap_dss_device *in; | ||
| 68 | |||
| 69 | int reset_gpio; | ||
| 70 | int datapairs; | ||
| 71 | |||
| 72 | struct omap_video_timings videomode; | ||
| 73 | |||
| 74 | char *name; | ||
| 75 | int enabled; | ||
| 76 | int model; | ||
| 77 | int revision; | ||
| 78 | u8 display_id[3]; | ||
| 79 | unsigned has_bc:1; | ||
| 80 | unsigned has_cabc:1; | ||
| 81 | unsigned cabc_mode; | ||
| 82 | unsigned long hw_guard_end; /* next value of jiffies | ||
| 83 | when we can issue the | ||
| 84 | next sleep in/out command */ | ||
| 85 | unsigned long hw_guard_wait; /* max guard time in jiffies */ | ||
| 86 | |||
| 87 | struct spi_device *spi; | ||
| 88 | struct mutex mutex; | ||
| 89 | |||
| 90 | struct backlight_device *bl_dev; | ||
| 91 | }; | ||
| 92 | |||
| 93 | static const struct omap_video_timings acx565akm_panel_timings = { | ||
| 94 | .x_res = 800, | ||
| 95 | .y_res = 480, | ||
| 96 | .pixel_clock = 24000, | ||
| 97 | .hfp = 28, | ||
| 98 | .hsw = 4, | ||
| 99 | .hbp = 24, | ||
| 100 | .vfp = 3, | ||
| 101 | .vsw = 3, | ||
| 102 | .vbp = 4, | ||
| 103 | |||
| 104 | .vsync_level = OMAPDSS_SIG_ACTIVE_LOW, | ||
| 105 | .hsync_level = OMAPDSS_SIG_ACTIVE_LOW, | ||
| 106 | |||
| 107 | .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE, | ||
| 108 | .de_level = OMAPDSS_SIG_ACTIVE_HIGH, | ||
| 109 | .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES, | ||
| 110 | }; | ||
| 111 | |||
| 112 | #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev) | ||
| 113 | |||
| 114 | static void acx565akm_transfer(struct panel_drv_data *ddata, int cmd, | ||
| 115 | const u8 *wbuf, int wlen, u8 *rbuf, int rlen) | ||
| 116 | { | ||
| 117 | struct spi_message m; | ||
| 118 | struct spi_transfer *x, xfer[5]; | ||
| 119 | int r; | ||
| 120 | |||
| 121 | BUG_ON(ddata->spi == NULL); | ||
| 122 | |||
| 123 | spi_message_init(&m); | ||
| 124 | |||
| 125 | memset(xfer, 0, sizeof(xfer)); | ||
| 126 | x = &xfer[0]; | ||
| 127 | |||
| 128 | cmd &= 0xff; | ||
| 129 | x->tx_buf = &cmd; | ||
| 130 | x->bits_per_word = 9; | ||
| 131 | x->len = 2; | ||
| 132 | |||
| 133 | if (rlen > 1 && wlen == 0) { | ||
| 134 | /* | ||
| 135 | * Between the command and the response data there is a | ||
| 136 | * dummy clock cycle. Add an extra bit after the command | ||
| 137 | * word to account for this. | ||
| 138 | */ | ||
| 139 | x->bits_per_word = 10; | ||
| 140 | cmd <<= 1; | ||
| 141 | } | ||
| 142 | spi_message_add_tail(x, &m); | ||
| 143 | |||
| 144 | if (wlen) { | ||
| 145 | x++; | ||
| 146 | x->tx_buf = wbuf; | ||
| 147 | x->len = wlen; | ||
| 148 | x->bits_per_word = 9; | ||
| 149 | spi_message_add_tail(x, &m); | ||
| 150 | } | ||
| 151 | |||
| 152 | if (rlen) { | ||
| 153 | x++; | ||
| 154 | x->rx_buf = rbuf; | ||
| 155 | x->len = rlen; | ||
| 156 | spi_message_add_tail(x, &m); | ||
| 157 | } | ||
| 158 | |||
| 159 | r = spi_sync(ddata->spi, &m); | ||
| 160 | if (r < 0) | ||
| 161 | dev_dbg(&ddata->spi->dev, "spi_sync %d\n", r); | ||
| 162 | } | ||
| 163 | |||
| 164 | static inline void acx565akm_cmd(struct panel_drv_data *ddata, int cmd) | ||
| 165 | { | ||
| 166 | acx565akm_transfer(ddata, cmd, NULL, 0, NULL, 0); | ||
| 167 | } | ||
| 168 | |||
| 169 | static inline void acx565akm_write(struct panel_drv_data *ddata, | ||
| 170 | int reg, const u8 *buf, int len) | ||
| 171 | { | ||
| 172 | acx565akm_transfer(ddata, reg, buf, len, NULL, 0); | ||
| 173 | } | ||
| 174 | |||
| 175 | static inline void acx565akm_read(struct panel_drv_data *ddata, | ||
| 176 | int reg, u8 *buf, int len) | ||
| 177 | { | ||
| 178 | acx565akm_transfer(ddata, reg, NULL, 0, buf, len); | ||
| 179 | } | ||
| 180 | |||
| 181 | static void hw_guard_start(struct panel_drv_data *ddata, int guard_msec) | ||
| 182 | { | ||
| 183 | ddata->hw_guard_wait = msecs_to_jiffies(guard_msec); | ||
| 184 | ddata->hw_guard_end = jiffies + ddata->hw_guard_wait; | ||
| 185 | } | ||
| 186 | |||
| 187 | static void hw_guard_wait(struct panel_drv_data *ddata) | ||
| 188 | { | ||
| 189 | unsigned long wait = ddata->hw_guard_end - jiffies; | ||
| 190 | |||
| 191 | if ((long)wait > 0 && wait <= ddata->hw_guard_wait) { | ||
| 192 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
| 193 | schedule_timeout(wait); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | static void set_sleep_mode(struct panel_drv_data *ddata, int on) | ||
| 198 | { | ||
| 199 | int cmd; | ||
| 200 | |||
| 201 | if (on) | ||
| 202 | cmd = MIPID_CMD_SLEEP_IN; | ||
| 203 | else | ||
| 204 | cmd = MIPID_CMD_SLEEP_OUT; | ||
| 205 | /* | ||
| 206 | * We have to keep 120msec between sleep in/out commands. | ||
| 207 | * (8.2.15, 8.2.16). | ||
| 208 | */ | ||
| 209 | hw_guard_wait(ddata); | ||
| 210 | acx565akm_cmd(ddata, cmd); | ||
| 211 | hw_guard_start(ddata, 120); | ||
| 212 | } | ||
| 213 | |||
| 214 | static void set_display_state(struct panel_drv_data *ddata, int enabled) | ||
| 215 | { | ||
| 216 | int cmd = enabled ? MIPID_CMD_DISP_ON : MIPID_CMD_DISP_OFF; | ||
| 217 | |||
| 218 | acx565akm_cmd(ddata, cmd); | ||
| 219 | } | ||
| 220 | |||
| 221 | static int panel_enabled(struct panel_drv_data *ddata) | ||
| 222 | { | ||
| 223 | u32 disp_status; | ||
| 224 | int enabled; | ||
| 225 | |||
| 226 | acx565akm_read(ddata, MIPID_CMD_READ_DISP_STATUS, | ||
| 227 | (u8 *)&disp_status, 4); | ||
| 228 | disp_status = __be32_to_cpu(disp_status); | ||
| 229 | enabled = (disp_status & (1 << 17)) && (disp_status & (1 << 10)); | ||
| 230 | dev_dbg(&ddata->spi->dev, | ||
| 231 | "LCD panel %senabled by bootloader (status 0x%04x)\n", | ||
| 232 | enabled ? "" : "not ", disp_status); | ||
| 233 | return enabled; | ||
| 234 | } | ||
| 235 | |||
| 236 | static int panel_detect(struct panel_drv_data *ddata) | ||
| 237 | { | ||
| 238 | acx565akm_read(ddata, MIPID_CMD_READ_DISP_ID, ddata->display_id, 3); | ||
| 239 | dev_dbg(&ddata->spi->dev, "MIPI display ID: %02x%02x%02x\n", | ||
| 240 | ddata->display_id[0], | ||
| 241 | ddata->display_id[1], | ||
| 242 | ddata->display_id[2]); | ||
| 243 | |||
| 244 | switch (ddata->display_id[0]) { | ||
| 245 | case 0x10: | ||
| 246 | ddata->model = MIPID_VER_ACX565AKM; | ||
| 247 | ddata->name = "acx565akm"; | ||
| 248 | ddata->has_bc = 1; | ||
| 249 | ddata->has_cabc = 1; | ||
| 250 | break; | ||
| 251 | case 0x29: | ||
| 252 | ddata->model = MIPID_VER_L4F00311; | ||
| 253 | ddata->name = "l4f00311"; | ||
| 254 | break; | ||
| 255 | case 0x45: | ||
| 256 | ddata->model = MIPID_VER_LPH8923; | ||
| 257 | ddata->name = "lph8923"; | ||
| 258 | break; | ||
| 259 | case 0x83: | ||
| 260 | ddata->model = MIPID_VER_LS041Y3; | ||
| 261 | ddata->name = "ls041y3"; | ||
| 262 | break; | ||
| 263 | default: | ||
| 264 | ddata->name = "unknown"; | ||
| 265 | dev_err(&ddata->spi->dev, "invalid display ID\n"); | ||
| 266 | return -ENODEV; | ||
| 267 | } | ||
| 268 | |||
| 269 | ddata->revision = ddata->display_id[1]; | ||
| 270 | |||
| 271 | dev_info(&ddata->spi->dev, "omapfb: %s rev %02x LCD detected\n", | ||
| 272 | ddata->name, ddata->revision); | ||
| 273 | |||
| 274 | return 0; | ||
| 275 | } | ||
| 276 | |||
| 277 | /*----------------------Backlight Control-------------------------*/ | ||
| 278 | |||
| 279 | static void enable_backlight_ctrl(struct panel_drv_data *ddata, int enable) | ||
| 280 | { | ||
| 281 | u16 ctrl; | ||
| 282 | |||
| 283 | acx565akm_read(ddata, MIPID_CMD_READ_CTRL_DISP, (u8 *)&ctrl, 1); | ||
| 284 | if (enable) { | ||
| 285 | ctrl |= CTRL_DISP_BRIGHTNESS_CTRL_ON | | ||
| 286 | CTRL_DISP_BACKLIGHT_ON; | ||
| 287 | } else { | ||
| 288 | ctrl &= ~(CTRL_DISP_BRIGHTNESS_CTRL_ON | | ||
| 289 | CTRL_DISP_BACKLIGHT_ON); | ||
| 290 | } | ||
| 291 | |||
| 292 | ctrl |= 1 << 8; | ||
| 293 | acx565akm_write(ddata, MIPID_CMD_WRITE_CTRL_DISP, (u8 *)&ctrl, 2); | ||
| 294 | } | ||
| 295 | |||
| 296 | static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode) | ||
| 297 | { | ||
| 298 | u16 cabc_ctrl; | ||
| 299 | |||
| 300 | ddata->cabc_mode = mode; | ||
| 301 | if (!ddata->enabled) | ||
| 302 | return; | ||
| 303 | cabc_ctrl = 0; | ||
| 304 | acx565akm_read(ddata, MIPID_CMD_READ_CABC, (u8 *)&cabc_ctrl, 1); | ||
| 305 | cabc_ctrl &= ~3; | ||
| 306 | cabc_ctrl |= (1 << 8) | (mode & 3); | ||
| 307 | acx565akm_write(ddata, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2); | ||
| 308 | } | ||
| 309 | |||
| 310 | static unsigned get_cabc_mode(struct panel_drv_data *ddata) | ||
| 311 | { | ||
| 312 | return ddata->cabc_mode; | ||
| 313 | } | ||
| 314 | |||
| 315 | static unsigned get_hw_cabc_mode(struct panel_drv_data *ddata) | ||
| 316 | { | ||
| 317 | u8 cabc_ctrl; | ||
| 318 | |||
| 319 | acx565akm_read(ddata, MIPID_CMD_READ_CABC, &cabc_ctrl, 1); | ||
| 320 | return cabc_ctrl & 3; | ||
| 321 | } | ||
| 322 | |||
| 323 | static void acx565akm_set_brightness(struct panel_drv_data *ddata, int level) | ||
| 324 | { | ||
| 325 | int bv; | ||
| 326 | |||
| 327 | bv = level | (1 << 8); | ||
| 328 | acx565akm_write(ddata, MIPID_CMD_WRITE_DISP_BRIGHTNESS, (u8 *)&bv, 2); | ||
| 329 | |||
| 330 | if (level) | ||
| 331 | enable_backlight_ctrl(ddata, 1); | ||
| 332 | else | ||
| 333 | enable_backlight_ctrl(ddata, 0); | ||
| 334 | } | ||
| 335 | |||
| 336 | static int acx565akm_get_actual_brightness(struct panel_drv_data *ddata) | ||
| 337 | { | ||
| 338 | u8 bv; | ||
| 339 | |||
| 340 | acx565akm_read(ddata, MIPID_CMD_READ_DISP_BRIGHTNESS, &bv, 1); | ||
| 341 | |||
| 342 | return bv; | ||
| 343 | } | ||
| 344 | |||
| 345 | |||
| 346 | static int acx565akm_bl_update_status(struct backlight_device *dev) | ||
| 347 | { | ||
| 348 | struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); | ||
| 349 | int r; | ||
| 350 | int level; | ||
| 351 | |||
| 352 | dev_dbg(&ddata->spi->dev, "%s\n", __func__); | ||
| 353 | |||
| 354 | mutex_lock(&ddata->mutex); | ||
| 355 | |||
| 356 | if (dev->props.fb_blank == FB_BLANK_UNBLANK && | ||
| 357 | dev->props.power == FB_BLANK_UNBLANK) | ||
| 358 | level = dev->props.brightness; | ||
| 359 | else | ||
| 360 | level = 0; | ||
| 361 | |||
| 362 | r = 0; | ||
| 363 | if (ddata->has_bc) | ||
| 364 | acx565akm_set_brightness(ddata, level); | ||
| 365 | else | ||
| 366 | r = -ENODEV; | ||
| 367 | |||
| 368 | mutex_unlock(&ddata->mutex); | ||
| 369 | |||
| 370 | return r; | ||
| 371 | } | ||
| 372 | |||
| 373 | static int acx565akm_bl_get_intensity(struct backlight_device *dev) | ||
| 374 | { | ||
| 375 | struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); | ||
| 376 | |||
| 377 | dev_dbg(&dev->dev, "%s\n", __func__); | ||
| 378 | |||
| 379 | if (!ddata->has_bc) | ||
| 380 | return -ENODEV; | ||
| 381 | |||
| 382 | if (dev->props.fb_blank == FB_BLANK_UNBLANK && | ||
| 383 | dev->props.power == FB_BLANK_UNBLANK) { | ||
| 384 | if (ddata->has_bc) | ||
| 385 | return acx565akm_get_actual_brightness(ddata); | ||
| 386 | else | ||
| 387 | return dev->props.brightness; | ||
| 388 | } | ||
| 389 | |||
| 390 | return 0; | ||
| 391 | } | ||
| 392 | |||
| 393 | static const struct backlight_ops acx565akm_bl_ops = { | ||
| 394 | .get_brightness = acx565akm_bl_get_intensity, | ||
| 395 | .update_status = acx565akm_bl_update_status, | ||
| 396 | }; | ||
| 397 | |||
| 398 | /*--------------------Auto Brightness control via Sysfs---------------------*/ | ||
| 399 | |||
| 400 | static const char * const cabc_modes[] = { | ||
| 401 | "off", /* always used when CABC is not supported */ | ||
| 402 | "ui", | ||
| 403 | "still-image", | ||
| 404 | "moving-image", | ||
| 405 | }; | ||
| 406 | |||
| 407 | static ssize_t show_cabc_mode(struct device *dev, | ||
| 408 | struct device_attribute *attr, | ||
| 409 | char *buf) | ||
| 410 | { | ||
| 411 | struct panel_drv_data *ddata = dev_get_drvdata(dev); | ||
| 412 | const char *mode_str; | ||
| 413 | int mode; | ||
| 414 | int len; | ||
| 415 | |||
| 416 | if (!ddata->has_cabc) | ||
| 417 | mode = 0; | ||
| 418 | else | ||
| 419 | mode = get_cabc_mode(ddata); | ||
| 420 | mode_str = "unknown"; | ||
| 421 | if (mode >= 0 && mode < ARRAY_SIZE(cabc_modes)) | ||
| 422 | mode_str = cabc_modes[mode]; | ||
| 423 | len = snprintf(buf, PAGE_SIZE, "%s\n", mode_str); | ||
| 424 | |||
| 425 | return len < PAGE_SIZE - 1 ? len : PAGE_SIZE - 1; | ||
| 426 | } | ||
| 427 | |||
| 428 | static ssize_t store_cabc_mode(struct device *dev, | ||
| 429 | struct device_attribute *attr, | ||
| 430 | const char *buf, size_t count) | ||
| 431 | { | ||
| 432 | struct panel_drv_data *ddata = dev_get_drvdata(dev); | ||
| 433 | int i; | ||
| 434 | |||
| 435 | for (i = 0; i < ARRAY_SIZE(cabc_modes); i++) { | ||
| 436 | const char *mode_str = cabc_modes[i]; | ||
| 437 | int cmp_len = strlen(mode_str); | ||
| 438 | |||
| 439 | if (count > 0 && buf[count - 1] == '\n') | ||
| 440 | count--; | ||
| 441 | if (count != cmp_len) | ||
| 442 | continue; | ||
| 443 | |||
| 444 | if (strncmp(buf, mode_str, cmp_len) == 0) | ||
| 445 | break; | ||
| 446 | } | ||
| 447 | |||
| 448 | if (i == ARRAY_SIZE(cabc_modes)) | ||
| 449 | return -EINVAL; | ||
| 450 | |||
| 451 | if (!ddata->has_cabc && i != 0) | ||
| 452 | return -EINVAL; | ||
| 453 | |||
| 454 | mutex_lock(&ddata->mutex); | ||
| 455 | set_cabc_mode(ddata, i); | ||
| 456 | mutex_unlock(&ddata->mutex); | ||
| 457 | |||
| 458 | return count; | ||
| 459 | } | ||
| 460 | |||
| 461 | static ssize_t show_cabc_available_modes(struct device *dev, | ||
| 462 | struct device_attribute *attr, | ||
| 463 | char *buf) | ||
| 464 | { | ||
| 465 | struct panel_drv_data *ddata = dev_get_drvdata(dev); | ||
| 466 | int len; | ||
| 467 | int i; | ||
| 468 | |||
| 469 | if (!ddata->has_cabc) | ||
| 470 | return snprintf(buf, PAGE_SIZE, "%s\n", cabc_modes[0]); | ||
| 471 | |||
| 472 | for (i = 0, len = 0; | ||
| 473 | len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++) | ||
| 474 | len += snprintf(&buf[len], PAGE_SIZE - len, "%s%s%s", | ||
| 475 | i ? " " : "", cabc_modes[i], | ||
| 476 | i == ARRAY_SIZE(cabc_modes) - 1 ? "\n" : ""); | ||
| 477 | |||
| 478 | return len < PAGE_SIZE ? len : PAGE_SIZE - 1; | ||
| 479 | } | ||
| 480 | |||
| 481 | static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR, | ||
| 482 | show_cabc_mode, store_cabc_mode); | ||
| 483 | static DEVICE_ATTR(cabc_available_modes, S_IRUGO, | ||
| 484 | show_cabc_available_modes, NULL); | ||
| 485 | |||
| 486 | static struct attribute *bldev_attrs[] = { | ||
| 487 | &dev_attr_cabc_mode.attr, | ||
| 488 | &dev_attr_cabc_available_modes.attr, | ||
| 489 | NULL, | ||
| 490 | }; | ||
| 491 | |||
| 492 | static struct attribute_group bldev_attr_group = { | ||
| 493 | .attrs = bldev_attrs, | ||
| 494 | }; | ||
| 495 | |||
| 496 | static int acx565akm_connect(struct omap_dss_device *dssdev) | ||
| 497 | { | ||
| 498 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 499 | struct omap_dss_device *in = ddata->in; | ||
| 500 | int r; | ||
| 501 | |||
| 502 | if (omapdss_device_is_connected(dssdev)) | ||
| 503 | return 0; | ||
| 504 | |||
| 505 | r = in->ops.sdi->connect(in, dssdev); | ||
| 506 | if (r) | ||
| 507 | return r; | ||
| 508 | |||
| 509 | return 0; | ||
| 510 | } | ||
| 511 | |||
| 512 | static void acx565akm_disconnect(struct omap_dss_device *dssdev) | ||
| 513 | { | ||
| 514 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 515 | struct omap_dss_device *in = ddata->in; | ||
| 516 | |||
| 517 | if (!omapdss_device_is_connected(dssdev)) | ||
| 518 | return; | ||
| 519 | |||
| 520 | in->ops.sdi->disconnect(in, dssdev); | ||
| 521 | } | ||
| 522 | |||
| 523 | static int acx565akm_panel_power_on(struct omap_dss_device *dssdev) | ||
| 524 | { | ||
| 525 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 526 | struct omap_dss_device *in = ddata->in; | ||
| 527 | int r; | ||
| 528 | |||
| 529 | dev_dbg(&ddata->spi->dev, "%s\n", __func__); | ||
| 530 | |||
| 531 | in->ops.sdi->set_timings(in, &ddata->videomode); | ||
| 532 | in->ops.sdi->set_datapairs(in, ddata->datapairs); | ||
| 533 | |||
| 534 | r = in->ops.sdi->enable(in); | ||
| 535 | if (r) { | ||
| 536 | pr_err("%s sdi enable failed\n", __func__); | ||
| 537 | return r; | ||
| 538 | } | ||
| 539 | |||
| 540 | /*FIXME tweak me */ | ||
| 541 | msleep(50); | ||
| 542 | |||
| 543 | if (gpio_is_valid(ddata->reset_gpio)) | ||
| 544 | gpio_set_value(ddata->reset_gpio, 1); | ||
| 545 | |||
| 546 | if (ddata->enabled) { | ||
| 547 | dev_dbg(&ddata->spi->dev, "panel already enabled\n"); | ||
| 548 | return 0; | ||
| 549 | } | ||
| 550 | |||
| 551 | /* | ||
| 552 | * We have to meet all the following delay requirements: | ||
| 553 | * 1. tRW: reset pulse width 10usec (7.12.1) | ||
| 554 | * 2. tRT: reset cancel time 5msec (7.12.1) | ||
| 555 | * 3. Providing PCLK,HS,VS signals for 2 frames = ~50msec worst | ||
| 556 | * case (7.6.2) | ||
| 557 | * 4. 120msec before the sleep out command (7.12.1) | ||
| 558 | */ | ||
| 559 | msleep(120); | ||
| 560 | |||
| 561 | set_sleep_mode(ddata, 0); | ||
| 562 | ddata->enabled = 1; | ||
| 563 | |||
| 564 | /* 5msec between sleep out and the next command. (8.2.16) */ | ||
| 565 | usleep_range(5000, 10000); | ||
| 566 | set_display_state(ddata, 1); | ||
| 567 | set_cabc_mode(ddata, ddata->cabc_mode); | ||
| 568 | |||
| 569 | mutex_unlock(&ddata->mutex); | ||
| 570 | |||
| 571 | return acx565akm_bl_update_status(ddata->bl_dev); | ||
| 572 | } | ||
| 573 | |||
| 574 | static void acx565akm_panel_power_off(struct omap_dss_device *dssdev) | ||
| 575 | { | ||
| 576 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 577 | struct omap_dss_device *in = ddata->in; | ||
| 578 | |||
| 579 | dev_dbg(dssdev->dev, "%s\n", __func__); | ||
| 580 | |||
| 581 | if (!ddata->enabled) | ||
| 582 | return; | ||
| 583 | |||
| 584 | set_display_state(ddata, 0); | ||
| 585 | set_sleep_mode(ddata, 1); | ||
| 586 | ddata->enabled = 0; | ||
| 587 | /* | ||
| 588 | * We have to provide PCLK,HS,VS signals for 2 frames (worst case | ||
| 589 | * ~50msec) after sending the sleep in command and asserting the | ||
| 590 | * reset signal. We probably could assert the reset w/o the delay | ||
| 591 | * but we still delay to avoid possible artifacts. (7.6.1) | ||
| 592 | */ | ||
| 593 | msleep(50); | ||
| 594 | |||
| 595 | if (gpio_is_valid(ddata->reset_gpio)) | ||
| 596 | gpio_set_value(ddata->reset_gpio, 0); | ||
| 597 | |||
| 598 | /* FIXME need to tweak this delay */ | ||
| 599 | msleep(100); | ||
| 600 | |||
| 601 | in->ops.sdi->disable(in); | ||
| 602 | } | ||
| 603 | |||
| 604 | static int acx565akm_enable(struct omap_dss_device *dssdev) | ||
| 605 | { | ||
| 606 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 607 | int r; | ||
| 608 | |||
| 609 | dev_dbg(dssdev->dev, "%s\n", __func__); | ||
| 610 | |||
| 611 | if (!omapdss_device_is_connected(dssdev)) | ||
| 612 | return -ENODEV; | ||
| 613 | |||
| 614 | if (omapdss_device_is_enabled(dssdev)) | ||
| 615 | return 0; | ||
| 616 | |||
| 617 | mutex_lock(&ddata->mutex); | ||
| 618 | r = acx565akm_panel_power_on(dssdev); | ||
| 619 | mutex_unlock(&ddata->mutex); | ||
| 620 | |||
| 621 | if (r) | ||
| 622 | return r; | ||
| 623 | |||
| 624 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; | ||
| 625 | |||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | |||
| 629 | static void acx565akm_disable(struct omap_dss_device *dssdev) | ||
| 630 | { | ||
| 631 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 632 | |||
| 633 | dev_dbg(dssdev->dev, "%s\n", __func__); | ||
| 634 | |||
| 635 | if (!omapdss_device_is_enabled(dssdev)) | ||
| 636 | return; | ||
| 637 | |||
| 638 | mutex_lock(&ddata->mutex); | ||
| 639 | acx565akm_panel_power_off(dssdev); | ||
| 640 | mutex_unlock(&ddata->mutex); | ||
| 641 | |||
| 642 | dssdev->state = OMAP_DSS_DISPLAY_DISABLED; | ||
| 643 | } | ||
| 644 | |||
| 645 | static void acx565akm_set_timings(struct omap_dss_device *dssdev, | ||
| 646 | struct omap_video_timings *timings) | ||
| 647 | { | ||
| 648 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 649 | struct omap_dss_device *in = ddata->in; | ||
| 650 | |||
| 651 | ddata->videomode = *timings; | ||
| 652 | dssdev->panel.timings = *timings; | ||
| 653 | |||
| 654 | in->ops.sdi->set_timings(in, timings); | ||
| 655 | } | ||
| 656 | |||
| 657 | static void acx565akm_get_timings(struct omap_dss_device *dssdev, | ||
| 658 | struct omap_video_timings *timings) | ||
| 659 | { | ||
| 660 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 661 | |||
| 662 | *timings = ddata->videomode; | ||
| 663 | } | ||
| 664 | |||
| 665 | static int acx565akm_check_timings(struct omap_dss_device *dssdev, | ||
| 666 | struct omap_video_timings *timings) | ||
| 667 | { | ||
| 668 | struct panel_drv_data *ddata = to_panel_data(dssdev); | ||
| 669 | struct omap_dss_device *in = ddata->in; | ||
| 670 | |||
| 671 | return in->ops.sdi->check_timings(in, timings); | ||
| 672 | } | ||
| 673 | |||
| 674 | static struct omap_dss_driver acx565akm_ops = { | ||
| 675 | .connect = acx565akm_connect, | ||
| 676 | .disconnect = acx565akm_disconnect, | ||
| 677 | |||
| 678 | .enable = acx565akm_enable, | ||
| 679 | .disable = acx565akm_disable, | ||
| 680 | |||
| 681 | .set_timings = acx565akm_set_timings, | ||
| 682 | .get_timings = acx565akm_get_timings, | ||
| 683 | .check_timings = acx565akm_check_timings, | ||
| 684 | |||
| 685 | .get_resolution = omapdss_default_get_resolution, | ||
| 686 | }; | ||
| 687 | |||
| 688 | static int acx565akm_probe_pdata(struct spi_device *spi) | ||
| 689 | { | ||
| 690 | const struct panel_acx565akm_platform_data *pdata; | ||
| 691 | struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev); | ||
| 692 | struct omap_dss_device *dssdev, *in; | ||
| 693 | |||
| 694 | pdata = dev_get_platdata(&spi->dev); | ||
| 695 | |||
| 696 | ddata->reset_gpio = pdata->reset_gpio; | ||
| 697 | |||
| 698 | in = omap_dss_find_output(pdata->source); | ||
| 699 | if (in == NULL) { | ||
| 700 | dev_err(&spi->dev, "failed to find video source '%s'\n", | ||
| 701 | pdata->source); | ||
| 702 | return -EPROBE_DEFER; | ||
| 703 | } | ||
| 704 | ddata->in = in; | ||
| 705 | |||
| 706 | ddata->datapairs = pdata->datapairs; | ||
| 707 | |||
| 708 | dssdev = &ddata->dssdev; | ||
| 709 | dssdev->name = pdata->name; | ||
| 710 | |||
| 711 | return 0; | ||
| 712 | } | ||
| 713 | |||
| 714 | static int acx565akm_probe(struct spi_device *spi) | ||
| 715 | { | ||
| 716 | struct panel_drv_data *ddata; | ||
| 717 | struct omap_dss_device *dssdev; | ||
| 718 | struct backlight_device *bldev; | ||
| 719 | int max_brightness, brightness; | ||
| 720 | struct backlight_properties props; | ||
| 721 | int r; | ||
| 722 | |||
| 723 | dev_dbg(&spi->dev, "%s\n", __func__); | ||
| 724 | |||
| 725 | spi->mode = SPI_MODE_3; | ||
| 726 | |||
| 727 | ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); | ||
| 728 | if (ddata == NULL) | ||
| 729 | return -ENOMEM; | ||
| 730 | |||
| 731 | dev_set_drvdata(&spi->dev, ddata); | ||
| 732 | |||
| 733 | ddata->spi = spi; | ||
| 734 | |||
| 735 | mutex_init(&ddata->mutex); | ||
| 736 | |||
| 737 | if (dev_get_platdata(&spi->dev)) { | ||
| 738 | r = acx565akm_probe_pdata(spi); | ||
| 739 | if (r) | ||
| 740 | return r; | ||
| 741 | } else { | ||
| 742 | return -ENODEV; | ||
| 743 | } | ||
| 744 | |||
| 745 | if (gpio_is_valid(ddata->reset_gpio)) { | ||
| 746 | r = devm_gpio_request_one(&spi->dev, ddata->reset_gpio, | ||
| 747 | GPIOF_OUT_INIT_LOW, "lcd reset"); | ||
| 748 | if (r) | ||
| 749 | goto err_gpio; | ||
| 750 | } | ||
| 751 | |||
| 752 | if (gpio_is_valid(ddata->reset_gpio)) | ||
| 753 | gpio_set_value(ddata->reset_gpio, 1); | ||
| 754 | |||
| 755 | /* | ||
| 756 | * After reset we have to wait 5 msec before the first | ||
| 757 | * command can be sent. | ||
| 758 | */ | ||
| 759 | usleep_range(5000, 10000); | ||
| 760 | |||
| 761 | ddata->enabled = panel_enabled(ddata); | ||
| 762 | |||
| 763 | r = panel_detect(ddata); | ||
| 764 | |||
| 765 | if (!ddata->enabled && gpio_is_valid(ddata->reset_gpio)) | ||
| 766 | gpio_set_value(ddata->reset_gpio, 0); | ||
| 767 | |||
| 768 | if (r) { | ||
| 769 | dev_err(&spi->dev, "%s panel detect error\n", __func__); | ||
| 770 | goto err_detect; | ||
| 771 | } | ||
| 772 | |||
| 773 | memset(&props, 0, sizeof(props)); | ||
| 774 | props.fb_blank = FB_BLANK_UNBLANK; | ||
| 775 | props.power = FB_BLANK_UNBLANK; | ||
| 776 | props.type = BACKLIGHT_RAW; | ||
| 777 | |||
| 778 | bldev = backlight_device_register("acx565akm", &ddata->spi->dev, | ||
| 779 | ddata, &acx565akm_bl_ops, &props); | ||
| 780 | ddata->bl_dev = bldev; | ||
| 781 | if (ddata->has_cabc) { | ||
| 782 | r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group); | ||
| 783 | if (r) { | ||
| 784 | dev_err(&bldev->dev, | ||
| 785 | "%s failed to create sysfs files\n", __func__); | ||
| 786 | goto err_sysfs; | ||
| 787 | } | ||
| 788 | ddata->cabc_mode = get_hw_cabc_mode(ddata); | ||
| 789 | } | ||
| 790 | |||
| 791 | max_brightness = 255; | ||
| 792 | |||
| 793 | if (ddata->has_bc) | ||
| 794 | brightness = acx565akm_get_actual_brightness(ddata); | ||
| 795 | else | ||
| 796 | brightness = 0; | ||
| 797 | |||
| 798 | bldev->props.max_brightness = max_brightness; | ||
| 799 | bldev->props.brightness = brightness; | ||
| 800 | |||
| 801 | acx565akm_bl_update_status(bldev); | ||
| 802 | |||
| 803 | |||
| 804 | ddata->videomode = acx565akm_panel_timings; | ||
| 805 | |||
| 806 | dssdev = &ddata->dssdev; | ||
| 807 | dssdev->dev = &spi->dev; | ||
| 808 | dssdev->driver = &acx565akm_ops; | ||
| 809 | dssdev->type = OMAP_DISPLAY_TYPE_SDI; | ||
| 810 | dssdev->owner = THIS_MODULE; | ||
| 811 | dssdev->panel.timings = ddata->videomode; | ||
| 812 | |||
| 813 | r = omapdss_register_display(dssdev); | ||
| 814 | if (r) { | ||
| 815 | dev_err(&spi->dev, "Failed to register panel\n"); | ||
| 816 | goto err_reg; | ||
| 817 | } | ||
| 818 | |||
| 819 | return 0; | ||
| 820 | |||
| 821 | err_reg: | ||
| 822 | sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group); | ||
| 823 | err_sysfs: | ||
| 824 | backlight_device_unregister(bldev); | ||
| 825 | err_detect: | ||
| 826 | err_gpio: | ||
| 827 | omap_dss_put_device(ddata->in); | ||
| 828 | return r; | ||
| 829 | } | ||
| 830 | |||
| 831 | static int acx565akm_remove(struct spi_device *spi) | ||
| 832 | { | ||
| 833 | struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev); | ||
| 834 | struct omap_dss_device *dssdev = &ddata->dssdev; | ||
| 835 | struct omap_dss_device *in = ddata->in; | ||
| 836 | |||
| 837 | dev_dbg(&ddata->spi->dev, "%s\n", __func__); | ||
| 838 | |||
| 839 | sysfs_remove_group(&ddata->bl_dev->dev.kobj, &bldev_attr_group); | ||
| 840 | backlight_device_unregister(ddata->bl_dev); | ||
| 841 | |||
| 842 | omapdss_unregister_display(dssdev); | ||
| 843 | |||
| 844 | acx565akm_disable(dssdev); | ||
| 845 | acx565akm_disconnect(dssdev); | ||
| 846 | |||
| 847 | omap_dss_put_device(in); | ||
| 848 | |||
| 849 | return 0; | ||
| 850 | } | ||
| 851 | |||
| 852 | static struct spi_driver acx565akm_driver = { | ||
| 853 | .driver = { | ||
| 854 | .name = "acx565akm", | ||
| 855 | .owner = THIS_MODULE, | ||
| 856 | }, | ||
| 857 | .probe = acx565akm_probe, | ||
| 858 | .remove = acx565akm_remove, | ||
| 859 | }; | ||
| 860 | |||
| 861 | module_spi_driver(acx565akm_driver); | ||
| 862 | |||
| 863 | MODULE_AUTHOR("Nokia Corporation"); | ||
| 864 | MODULE_DESCRIPTION("acx565akm LCD Driver"); | ||
| 865 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/video/omap-panel-data.h b/include/video/omap-panel-data.h index d4d93a900709..678f5f70da1a 100644 --- a/include/video/omap-panel-data.h +++ b/include/video/omap-panel-data.h | |||
| @@ -264,4 +264,20 @@ struct panel_dsicm_platform_data { | |||
| 264 | struct omap_dsi_pin_config pin_config; | 264 | struct omap_dsi_pin_config pin_config; |
| 265 | }; | 265 | }; |
| 266 | 266 | ||
| 267 | /** | ||
| 268 | * panel_acx565akm platform data | ||
| 269 | * @name: name for this display entity | ||
| 270 | * @source: name of the display entity used as a video source | ||
| 271 | * @reset_gpio: gpio to reset the panel (or -1) | ||
| 272 | * @datapairs: number of SDI datapairs | ||
| 273 | */ | ||
| 274 | struct panel_acx565akm_platform_data { | ||
| 275 | const char *name; | ||
| 276 | const char *source; | ||
| 277 | |||
| 278 | int reset_gpio; | ||
| 279 | |||
| 280 | int datapairs; | ||
| 281 | }; | ||
| 282 | |||
| 267 | #endif /* __OMAP_PANEL_DATA_H */ | 283 | #endif /* __OMAP_PANEL_DATA_H */ |
