panel-acx565akm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /*
  2. * Support for ACX565AKM LCD Panel used on Nokia N900
  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. #include <linux/kernel.h>
  23. #include <linux/module.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/jiffies.h>
  28. #include <linux/sched.h>
  29. #include <linux/backlight.h>
  30. #include <linux/fb.h>
  31. #include <linux/gpio.h>
  32. #include <video/omapdss.h>
  33. #include <video/omap-panel-data.h>
  34. #define MIPID_CMD_READ_DISP_ID 0x04
  35. #define MIPID_CMD_READ_RED 0x06
  36. #define MIPID_CMD_READ_GREEN 0x07
  37. #define MIPID_CMD_READ_BLUE 0x08
  38. #define MIPID_CMD_READ_DISP_STATUS 0x09
  39. #define MIPID_CMD_RDDSDR 0x0F
  40. #define MIPID_CMD_SLEEP_IN 0x10
  41. #define MIPID_CMD_SLEEP_OUT 0x11
  42. #define MIPID_CMD_DISP_OFF 0x28
  43. #define MIPID_CMD_DISP_ON 0x29
  44. #define MIPID_CMD_WRITE_DISP_BRIGHTNESS 0x51
  45. #define MIPID_CMD_READ_DISP_BRIGHTNESS 0x52
  46. #define MIPID_CMD_WRITE_CTRL_DISP 0x53
  47. #define CTRL_DISP_BRIGHTNESS_CTRL_ON (1 << 5)
  48. #define CTRL_DISP_AMBIENT_LIGHT_CTRL_ON (1 << 4)
  49. #define CTRL_DISP_BACKLIGHT_ON (1 << 2)
  50. #define CTRL_DISP_AUTO_BRIGHTNESS_ON (1 << 1)
  51. #define MIPID_CMD_READ_CTRL_DISP 0x54
  52. #define MIPID_CMD_WRITE_CABC 0x55
  53. #define MIPID_CMD_READ_CABC 0x56
  54. #define MIPID_VER_LPH8923 3
  55. #define MIPID_VER_LS041Y3 4
  56. #define MIPID_VER_L4F00311 8
  57. #define MIPID_VER_ACX565AKM 9
  58. struct acx565akm_device {
  59. char *name;
  60. int enabled;
  61. int model;
  62. int revision;
  63. u8 display_id[3];
  64. unsigned has_bc:1;
  65. unsigned has_cabc:1;
  66. unsigned cabc_mode;
  67. unsigned long hw_guard_end; /* next value of jiffies
  68. when we can issue the
  69. next sleep in/out command */
  70. unsigned long hw_guard_wait; /* max guard time in jiffies */
  71. struct spi_device *spi;
  72. struct mutex mutex;
  73. struct omap_dss_device *dssdev;
  74. struct backlight_device *bl_dev;
  75. };
  76. static struct acx565akm_device acx_dev;
  77. static int acx565akm_bl_update_status(struct backlight_device *dev);
  78. /*--------------------MIPID interface-----------------------------*/
  79. static void acx565akm_transfer(struct acx565akm_device *md, int cmd,
  80. const u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  81. {
  82. struct spi_message m;
  83. struct spi_transfer *x, xfer[5];
  84. int r;
  85. BUG_ON(md->spi == NULL);
  86. spi_message_init(&m);
  87. memset(xfer, 0, sizeof(xfer));
  88. x = &xfer[0];
  89. cmd &= 0xff;
  90. x->tx_buf = &cmd;
  91. x->bits_per_word = 9;
  92. x->len = 2;
  93. if (rlen > 1 && wlen == 0) {
  94. /*
  95. * Between the command and the response data there is a
  96. * dummy clock cycle. Add an extra bit after the command
  97. * word to account for this.
  98. */
  99. x->bits_per_word = 10;
  100. cmd <<= 1;
  101. }
  102. spi_message_add_tail(x, &m);
  103. if (wlen) {
  104. x++;
  105. x->tx_buf = wbuf;
  106. x->len = wlen;
  107. x->bits_per_word = 9;
  108. spi_message_add_tail(x, &m);
  109. }
  110. if (rlen) {
  111. x++;
  112. x->rx_buf = rbuf;
  113. x->len = rlen;
  114. spi_message_add_tail(x, &m);
  115. }
  116. r = spi_sync(md->spi, &m);
  117. if (r < 0)
  118. dev_dbg(&md->spi->dev, "spi_sync %d\n", r);
  119. }
  120. static inline void acx565akm_cmd(struct acx565akm_device *md, int cmd)
  121. {
  122. acx565akm_transfer(md, cmd, NULL, 0, NULL, 0);
  123. }
  124. static inline void acx565akm_write(struct acx565akm_device *md,
  125. int reg, const u8 *buf, int len)
  126. {
  127. acx565akm_transfer(md, reg, buf, len, NULL, 0);
  128. }
  129. static inline void acx565akm_read(struct acx565akm_device *md,
  130. int reg, u8 *buf, int len)
  131. {
  132. acx565akm_transfer(md, reg, NULL, 0, buf, len);
  133. }
  134. static void hw_guard_start(struct acx565akm_device *md, int guard_msec)
  135. {
  136. md->hw_guard_wait = msecs_to_jiffies(guard_msec);
  137. md->hw_guard_end = jiffies + md->hw_guard_wait;
  138. }
  139. static void hw_guard_wait(struct acx565akm_device *md)
  140. {
  141. unsigned long wait = md->hw_guard_end - jiffies;
  142. if ((long)wait > 0 && wait <= md->hw_guard_wait) {
  143. set_current_state(TASK_UNINTERRUPTIBLE);
  144. schedule_timeout(wait);
  145. }
  146. }
  147. /*----------------------MIPID wrappers----------------------------*/
  148. static void set_sleep_mode(struct acx565akm_device *md, int on)
  149. {
  150. int cmd;
  151. if (on)
  152. cmd = MIPID_CMD_SLEEP_IN;
  153. else
  154. cmd = MIPID_CMD_SLEEP_OUT;
  155. /*
  156. * We have to keep 120msec between sleep in/out commands.
  157. * (8.2.15, 8.2.16).
  158. */
  159. hw_guard_wait(md);
  160. acx565akm_cmd(md, cmd);
  161. hw_guard_start(md, 120);
  162. }
  163. static void set_display_state(struct acx565akm_device *md, int enabled)
  164. {
  165. int cmd = enabled ? MIPID_CMD_DISP_ON : MIPID_CMD_DISP_OFF;
  166. acx565akm_cmd(md, cmd);
  167. }
  168. static int panel_enabled(struct acx565akm_device *md)
  169. {
  170. u32 disp_status;
  171. int enabled;
  172. acx565akm_read(md, MIPID_CMD_READ_DISP_STATUS, (u8 *)&disp_status, 4);
  173. disp_status = __be32_to_cpu(disp_status);
  174. enabled = (disp_status & (1 << 17)) && (disp_status & (1 << 10));
  175. dev_dbg(&md->spi->dev,
  176. "LCD panel %senabled by bootloader (status 0x%04x)\n",
  177. enabled ? "" : "not ", disp_status);
  178. return enabled;
  179. }
  180. static int panel_detect(struct acx565akm_device *md)
  181. {
  182. acx565akm_read(md, MIPID_CMD_READ_DISP_ID, md->display_id, 3);
  183. dev_dbg(&md->spi->dev, "MIPI display ID: %02x%02x%02x\n",
  184. md->display_id[0], md->display_id[1], md->display_id[2]);
  185. switch (md->display_id[0]) {
  186. case 0x10:
  187. md->model = MIPID_VER_ACX565AKM;
  188. md->name = "acx565akm";
  189. md->has_bc = 1;
  190. md->has_cabc = 1;
  191. break;
  192. case 0x29:
  193. md->model = MIPID_VER_L4F00311;
  194. md->name = "l4f00311";
  195. break;
  196. case 0x45:
  197. md->model = MIPID_VER_LPH8923;
  198. md->name = "lph8923";
  199. break;
  200. case 0x83:
  201. md->model = MIPID_VER_LS041Y3;
  202. md->name = "ls041y3";
  203. break;
  204. default:
  205. md->name = "unknown";
  206. dev_err(&md->spi->dev, "invalid display ID\n");
  207. return -ENODEV;
  208. }
  209. md->revision = md->display_id[1];
  210. dev_info(&md->spi->dev, "omapfb: %s rev %02x LCD detected\n",
  211. md->name, md->revision);
  212. return 0;
  213. }
  214. /*----------------------Backlight Control-------------------------*/
  215. static void enable_backlight_ctrl(struct acx565akm_device *md, int enable)
  216. {
  217. u16 ctrl;
  218. acx565akm_read(md, MIPID_CMD_READ_CTRL_DISP, (u8 *)&ctrl, 1);
  219. if (enable) {
  220. ctrl |= CTRL_DISP_BRIGHTNESS_CTRL_ON |
  221. CTRL_DISP_BACKLIGHT_ON;
  222. } else {
  223. ctrl &= ~(CTRL_DISP_BRIGHTNESS_CTRL_ON |
  224. CTRL_DISP_BACKLIGHT_ON);
  225. }
  226. ctrl |= 1 << 8;
  227. acx565akm_write(md, MIPID_CMD_WRITE_CTRL_DISP, (u8 *)&ctrl, 2);
  228. }
  229. static void set_cabc_mode(struct acx565akm_device *md, unsigned mode)
  230. {
  231. u16 cabc_ctrl;
  232. md->cabc_mode = mode;
  233. if (!md->enabled)
  234. return;
  235. cabc_ctrl = 0;
  236. acx565akm_read(md, MIPID_CMD_READ_CABC, (u8 *)&cabc_ctrl, 1);
  237. cabc_ctrl &= ~3;
  238. cabc_ctrl |= (1 << 8) | (mode & 3);
  239. acx565akm_write(md, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2);
  240. }
  241. static unsigned get_cabc_mode(struct acx565akm_device *md)
  242. {
  243. return md->cabc_mode;
  244. }
  245. static unsigned get_hw_cabc_mode(struct acx565akm_device *md)
  246. {
  247. u8 cabc_ctrl;
  248. acx565akm_read(md, MIPID_CMD_READ_CABC, &cabc_ctrl, 1);
  249. return cabc_ctrl & 3;
  250. }
  251. static void acx565akm_set_brightness(struct acx565akm_device *md, int level)
  252. {
  253. int bv;
  254. bv = level | (1 << 8);
  255. acx565akm_write(md, MIPID_CMD_WRITE_DISP_BRIGHTNESS, (u8 *)&bv, 2);
  256. if (level)
  257. enable_backlight_ctrl(md, 1);
  258. else
  259. enable_backlight_ctrl(md, 0);
  260. }
  261. static int acx565akm_get_actual_brightness(struct acx565akm_device *md)
  262. {
  263. u8 bv;
  264. acx565akm_read(md, MIPID_CMD_READ_DISP_BRIGHTNESS, &bv, 1);
  265. return bv;
  266. }
  267. static int acx565akm_bl_update_status(struct backlight_device *dev)
  268. {
  269. struct acx565akm_device *md = dev_get_drvdata(&dev->dev);
  270. int r;
  271. int level;
  272. dev_dbg(&md->spi->dev, "%s\n", __func__);
  273. mutex_lock(&md->mutex);
  274. if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
  275. dev->props.power == FB_BLANK_UNBLANK)
  276. level = dev->props.brightness;
  277. else
  278. level = 0;
  279. r = 0;
  280. if (md->has_bc)
  281. acx565akm_set_brightness(md, level);
  282. else
  283. r = -ENODEV;
  284. mutex_unlock(&md->mutex);
  285. return r;
  286. }
  287. static int acx565akm_bl_get_intensity(struct backlight_device *dev)
  288. {
  289. struct acx565akm_device *md = dev_get_drvdata(&dev->dev);
  290. dev_dbg(&dev->dev, "%s\n", __func__);
  291. if (!md->has_bc)
  292. return -ENODEV;
  293. if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
  294. dev->props.power == FB_BLANK_UNBLANK) {
  295. if (md->has_bc)
  296. return acx565akm_get_actual_brightness(md);
  297. else
  298. return dev->props.brightness;
  299. }
  300. return 0;
  301. }
  302. static const struct backlight_ops acx565akm_bl_ops = {
  303. .get_brightness = acx565akm_bl_get_intensity,
  304. .update_status = acx565akm_bl_update_status,
  305. };
  306. /*--------------------Auto Brightness control via Sysfs---------------------*/
  307. static const char *cabc_modes[] = {
  308. "off", /* always used when CABC is not supported */
  309. "ui",
  310. "still-image",
  311. "moving-image",
  312. };
  313. static ssize_t show_cabc_mode(struct device *dev,
  314. struct device_attribute *attr,
  315. char *buf)
  316. {
  317. struct acx565akm_device *md = dev_get_drvdata(dev);
  318. const char *mode_str;
  319. int mode;
  320. int len;
  321. if (!md->has_cabc)
  322. mode = 0;
  323. else
  324. mode = get_cabc_mode(md);
  325. mode_str = "unknown";
  326. if (mode >= 0 && mode < ARRAY_SIZE(cabc_modes))
  327. mode_str = cabc_modes[mode];
  328. len = snprintf(buf, PAGE_SIZE, "%s\n", mode_str);
  329. return len < PAGE_SIZE - 1 ? len : PAGE_SIZE - 1;
  330. }
  331. static ssize_t store_cabc_mode(struct device *dev,
  332. struct device_attribute *attr,
  333. const char *buf, size_t count)
  334. {
  335. struct acx565akm_device *md = dev_get_drvdata(dev);
  336. int i;
  337. for (i = 0; i < ARRAY_SIZE(cabc_modes); i++) {
  338. const char *mode_str = cabc_modes[i];
  339. int cmp_len = strlen(mode_str);
  340. if (count > 0 && buf[count - 1] == '\n')
  341. count--;
  342. if (count != cmp_len)
  343. continue;
  344. if (strncmp(buf, mode_str, cmp_len) == 0)
  345. break;
  346. }
  347. if (i == ARRAY_SIZE(cabc_modes))
  348. return -EINVAL;
  349. if (!md->has_cabc && i != 0)
  350. return -EINVAL;
  351. mutex_lock(&md->mutex);
  352. set_cabc_mode(md, i);
  353. mutex_unlock(&md->mutex);
  354. return count;
  355. }
  356. static ssize_t show_cabc_available_modes(struct device *dev,
  357. struct device_attribute *attr,
  358. char *buf)
  359. {
  360. struct acx565akm_device *md = dev_get_drvdata(dev);
  361. int len;
  362. int i;
  363. if (!md->has_cabc)
  364. return snprintf(buf, PAGE_SIZE, "%s\n", cabc_modes[0]);
  365. for (i = 0, len = 0;
  366. len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++)
  367. len += snprintf(&buf[len], PAGE_SIZE - len, "%s%s%s",
  368. i ? " " : "", cabc_modes[i],
  369. i == ARRAY_SIZE(cabc_modes) - 1 ? "\n" : "");
  370. return len < PAGE_SIZE ? len : PAGE_SIZE - 1;
  371. }
  372. static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR,
  373. show_cabc_mode, store_cabc_mode);
  374. static DEVICE_ATTR(cabc_available_modes, S_IRUGO,
  375. show_cabc_available_modes, NULL);
  376. static struct attribute *bldev_attrs[] = {
  377. &dev_attr_cabc_mode.attr,
  378. &dev_attr_cabc_available_modes.attr,
  379. NULL,
  380. };
  381. static struct attribute_group bldev_attr_group = {
  382. .attrs = bldev_attrs,
  383. };
  384. /*---------------------------ACX Panel----------------------------*/
  385. static int acx_get_recommended_bpp(struct omap_dss_device *dssdev)
  386. {
  387. return 16;
  388. }
  389. static struct omap_video_timings acx_panel_timings = {
  390. .x_res = 800,
  391. .y_res = 480,
  392. .pixel_clock = 24000,
  393. .hfp = 28,
  394. .hsw = 4,
  395. .hbp = 24,
  396. .vfp = 3,
  397. .vsw = 3,
  398. .vbp = 4,
  399. .vsync_level = OMAPDSS_SIG_ACTIVE_LOW,
  400. .hsync_level = OMAPDSS_SIG_ACTIVE_LOW,
  401. .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
  402. .de_level = OMAPDSS_SIG_ACTIVE_HIGH,
  403. .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
  404. };
  405. static struct panel_acx565akm_data *get_panel_data(struct omap_dss_device *dssdev)
  406. {
  407. return (struct panel_acx565akm_data *) dssdev->data;
  408. }
  409. static int acx_panel_probe(struct omap_dss_device *dssdev)
  410. {
  411. int r;
  412. struct acx565akm_device *md = &acx_dev;
  413. struct panel_acx565akm_data *panel_data = get_panel_data(dssdev);
  414. struct backlight_device *bldev;
  415. int max_brightness, brightness;
  416. struct backlight_properties props;
  417. dev_dbg(&dssdev->dev, "%s\n", __func__);
  418. if (!panel_data)
  419. return -EINVAL;
  420. /* FIXME AC bias ? */
  421. dssdev->panel.timings = acx_panel_timings;
  422. if (gpio_is_valid(panel_data->reset_gpio)) {
  423. r = devm_gpio_request_one(&dssdev->dev, panel_data->reset_gpio,
  424. GPIOF_OUT_INIT_LOW, "lcd reset");
  425. if (r)
  426. return r;
  427. }
  428. if (gpio_is_valid(panel_data->reset_gpio))
  429. gpio_set_value(panel_data->reset_gpio, 1);
  430. /*
  431. * After reset we have to wait 5 msec before the first
  432. * command can be sent.
  433. */
  434. msleep(5);
  435. md->enabled = panel_enabled(md);
  436. r = panel_detect(md);
  437. if (r) {
  438. dev_err(&dssdev->dev, "%s panel detect error\n", __func__);
  439. if (!md->enabled && gpio_is_valid(panel_data->reset_gpio))
  440. gpio_set_value(panel_data->reset_gpio, 0);
  441. return r;
  442. }
  443. mutex_lock(&acx_dev.mutex);
  444. acx_dev.dssdev = dssdev;
  445. mutex_unlock(&acx_dev.mutex);
  446. if (!md->enabled) {
  447. if (gpio_is_valid(panel_data->reset_gpio))
  448. gpio_set_value(panel_data->reset_gpio, 0);
  449. }
  450. /*------- Backlight control --------*/
  451. memset(&props, 0, sizeof(props));
  452. props.fb_blank = FB_BLANK_UNBLANK;
  453. props.power = FB_BLANK_UNBLANK;
  454. props.type = BACKLIGHT_RAW;
  455. bldev = backlight_device_register("acx565akm", &md->spi->dev,
  456. md, &acx565akm_bl_ops, &props);
  457. md->bl_dev = bldev;
  458. if (md->has_cabc) {
  459. r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
  460. if (r) {
  461. dev_err(&bldev->dev,
  462. "%s failed to create sysfs files\n", __func__);
  463. backlight_device_unregister(bldev);
  464. return r;
  465. }
  466. md->cabc_mode = get_hw_cabc_mode(md);
  467. }
  468. max_brightness = 255;
  469. if (md->has_bc)
  470. brightness = acx565akm_get_actual_brightness(md);
  471. else
  472. brightness = 0;
  473. bldev->props.max_brightness = max_brightness;
  474. bldev->props.brightness = brightness;
  475. acx565akm_bl_update_status(bldev);
  476. return 0;
  477. }
  478. static void acx_panel_remove(struct omap_dss_device *dssdev)
  479. {
  480. struct acx565akm_device *md = &acx_dev;
  481. dev_dbg(&dssdev->dev, "%s\n", __func__);
  482. sysfs_remove_group(&md->bl_dev->dev.kobj, &bldev_attr_group);
  483. backlight_device_unregister(md->bl_dev);
  484. mutex_lock(&acx_dev.mutex);
  485. acx_dev.dssdev = NULL;
  486. mutex_unlock(&acx_dev.mutex);
  487. }
  488. static int acx_panel_power_on(struct omap_dss_device *dssdev)
  489. {
  490. struct acx565akm_device *md = &acx_dev;
  491. struct panel_acx565akm_data *panel_data = get_panel_data(dssdev);
  492. int r;
  493. dev_dbg(&dssdev->dev, "%s\n", __func__);
  494. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  495. return 0;
  496. mutex_lock(&md->mutex);
  497. omapdss_sdi_set_timings(dssdev, &dssdev->panel.timings);
  498. omapdss_sdi_set_datapairs(dssdev, dssdev->phy.sdi.datapairs);
  499. r = omapdss_sdi_display_enable(dssdev);
  500. if (r) {
  501. pr_err("%s sdi enable failed\n", __func__);
  502. goto fail_unlock;
  503. }
  504. /*FIXME tweak me */
  505. msleep(50);
  506. if (gpio_is_valid(panel_data->reset_gpio))
  507. gpio_set_value(panel_data->reset_gpio, 1);
  508. if (md->enabled) {
  509. dev_dbg(&md->spi->dev, "panel already enabled\n");
  510. mutex_unlock(&md->mutex);
  511. return 0;
  512. }
  513. /*
  514. * We have to meet all the following delay requirements:
  515. * 1. tRW: reset pulse width 10usec (7.12.1)
  516. * 2. tRT: reset cancel time 5msec (7.12.1)
  517. * 3. Providing PCLK,HS,VS signals for 2 frames = ~50msec worst
  518. * case (7.6.2)
  519. * 4. 120msec before the sleep out command (7.12.1)
  520. */
  521. msleep(120);
  522. set_sleep_mode(md, 0);
  523. md->enabled = 1;
  524. /* 5msec between sleep out and the next command. (8.2.16) */
  525. msleep(5);
  526. set_display_state(md, 1);
  527. set_cabc_mode(md, md->cabc_mode);
  528. mutex_unlock(&md->mutex);
  529. return acx565akm_bl_update_status(md->bl_dev);
  530. fail_unlock:
  531. mutex_unlock(&md->mutex);
  532. return r;
  533. }
  534. static void acx_panel_power_off(struct omap_dss_device *dssdev)
  535. {
  536. struct acx565akm_device *md = &acx_dev;
  537. struct panel_acx565akm_data *panel_data = get_panel_data(dssdev);
  538. dev_dbg(&dssdev->dev, "%s\n", __func__);
  539. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  540. return;
  541. mutex_lock(&md->mutex);
  542. if (!md->enabled) {
  543. mutex_unlock(&md->mutex);
  544. return;
  545. }
  546. set_display_state(md, 0);
  547. set_sleep_mode(md, 1);
  548. md->enabled = 0;
  549. /*
  550. * We have to provide PCLK,HS,VS signals for 2 frames (worst case
  551. * ~50msec) after sending the sleep in command and asserting the
  552. * reset signal. We probably could assert the reset w/o the delay
  553. * but we still delay to avoid possible artifacts. (7.6.1)
  554. */
  555. msleep(50);
  556. if (gpio_is_valid(panel_data->reset_gpio))
  557. gpio_set_value(panel_data->reset_gpio, 0);
  558. /* FIXME need to tweak this delay */
  559. msleep(100);
  560. omapdss_sdi_display_disable(dssdev);
  561. mutex_unlock(&md->mutex);
  562. }
  563. static int acx_panel_enable(struct omap_dss_device *dssdev)
  564. {
  565. int r;
  566. dev_dbg(&dssdev->dev, "%s\n", __func__);
  567. r = acx_panel_power_on(dssdev);
  568. if (r)
  569. return r;
  570. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  571. return 0;
  572. }
  573. static void acx_panel_disable(struct omap_dss_device *dssdev)
  574. {
  575. dev_dbg(&dssdev->dev, "%s\n", __func__);
  576. acx_panel_power_off(dssdev);
  577. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  578. }
  579. static void acx_panel_set_timings(struct omap_dss_device *dssdev,
  580. struct omap_video_timings *timings)
  581. {
  582. omapdss_sdi_set_timings(dssdev, timings);
  583. dssdev->panel.timings = *timings;
  584. }
  585. static int acx_panel_check_timings(struct omap_dss_device *dssdev,
  586. struct omap_video_timings *timings)
  587. {
  588. return 0;
  589. }
  590. static struct omap_dss_driver acx_panel_driver = {
  591. .probe = acx_panel_probe,
  592. .remove = acx_panel_remove,
  593. .enable = acx_panel_enable,
  594. .disable = acx_panel_disable,
  595. .set_timings = acx_panel_set_timings,
  596. .check_timings = acx_panel_check_timings,
  597. .get_recommended_bpp = acx_get_recommended_bpp,
  598. .driver = {
  599. .name = "panel-acx565akm",
  600. .owner = THIS_MODULE,
  601. },
  602. };
  603. /*--------------------SPI probe-------------------------*/
  604. static int acx565akm_spi_probe(struct spi_device *spi)
  605. {
  606. struct acx565akm_device *md = &acx_dev;
  607. dev_dbg(&spi->dev, "%s\n", __func__);
  608. spi->mode = SPI_MODE_3;
  609. md->spi = spi;
  610. mutex_init(&md->mutex);
  611. dev_set_drvdata(&spi->dev, md);
  612. omap_dss_register_driver(&acx_panel_driver);
  613. return 0;
  614. }
  615. static int acx565akm_spi_remove(struct spi_device *spi)
  616. {
  617. struct acx565akm_device *md = dev_get_drvdata(&spi->dev);
  618. dev_dbg(&md->spi->dev, "%s\n", __func__);
  619. omap_dss_unregister_driver(&acx_panel_driver);
  620. return 0;
  621. }
  622. static struct spi_driver acx565akm_spi_driver = {
  623. .driver = {
  624. .name = "acx565akm",
  625. .owner = THIS_MODULE,
  626. },
  627. .probe = acx565akm_spi_probe,
  628. .remove = acx565akm_spi_remove,
  629. };
  630. module_spi_driver(acx565akm_spi_driver);
  631. MODULE_AUTHOR("Nokia Corporation");
  632. MODULE_DESCRIPTION("acx565akm LCD Driver");
  633. MODULE_LICENSE("GPL");