panel-sony-acx565akm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Sony ACX565AKM LCD Panel driver
  4. *
  5. * Copyright (C) 2019 Texas Instruments Incorporated
  6. *
  7. * Based on the omapdrm-specific panel-sony-acx565akm driver
  8. *
  9. * Copyright (C) 2010 Nokia Corporation
  10. * Author: Imre Deak <imre.deak@nokia.com>
  11. */
  12. /*
  13. * TODO (to be addressed with hardware access to test the changes):
  14. *
  15. * - Update backlight support to use backlight_update_status() etc.
  16. * - Use prepare/unprepare for the basic power on/off of the backligt
  17. */
  18. #include <linux/backlight.h>
  19. #include <linux/delay.h>
  20. #include <linux/gpio/consumer.h>
  21. #include <linux/jiffies.h>
  22. #include <linux/module.h>
  23. #include <linux/mutex.h>
  24. #include <linux/sched.h>
  25. #include <linux/spi/spi.h>
  26. #include <video/mipi_display.h>
  27. #include <drm/drm_connector.h>
  28. #include <drm/drm_modes.h>
  29. #include <drm/drm_panel.h>
  30. #define CTRL_DISP_BRIGHTNESS_CTRL_ON BIT(5)
  31. #define CTRL_DISP_AMBIENT_LIGHT_CTRL_ON BIT(4)
  32. #define CTRL_DISP_BACKLIGHT_ON BIT(2)
  33. #define CTRL_DISP_AUTO_BRIGHTNESS_ON BIT(1)
  34. #define MIPID_CMD_WRITE_CABC 0x55
  35. #define MIPID_CMD_READ_CABC 0x56
  36. #define MIPID_VER_LPH8923 3
  37. #define MIPID_VER_LS041Y3 4
  38. #define MIPID_VER_L4F00311 8
  39. #define MIPID_VER_ACX565AKM 9
  40. struct acx565akm_panel {
  41. struct drm_panel panel;
  42. struct spi_device *spi;
  43. struct gpio_desc *reset_gpio;
  44. struct backlight_device *backlight;
  45. struct mutex mutex;
  46. const char *name;
  47. u8 display_id[3];
  48. int model;
  49. int revision;
  50. bool has_bc;
  51. bool has_cabc;
  52. bool enabled;
  53. unsigned int cabc_mode;
  54. /*
  55. * Next value of jiffies when we can issue the next sleep in/out
  56. * command.
  57. */
  58. unsigned long hw_guard_end;
  59. unsigned long hw_guard_wait; /* max guard time in jiffies */
  60. };
  61. #define to_acx565akm_device(p) container_of(p, struct acx565akm_panel, panel)
  62. static void acx565akm_transfer(struct acx565akm_panel *lcd, int cmd,
  63. const u8 *wbuf, int wlen, u8 *rbuf, int rlen)
  64. {
  65. struct spi_message m;
  66. struct spi_transfer *x, xfer[5];
  67. int ret;
  68. spi_message_init(&m);
  69. memset(xfer, 0, sizeof(xfer));
  70. x = &xfer[0];
  71. cmd &= 0xff;
  72. x->tx_buf = &cmd;
  73. x->bits_per_word = 9;
  74. x->len = 2;
  75. if (rlen > 1 && wlen == 0) {
  76. /*
  77. * Between the command and the response data there is a
  78. * dummy clock cycle. Add an extra bit after the command
  79. * word to account for this.
  80. */
  81. x->bits_per_word = 10;
  82. cmd <<= 1;
  83. }
  84. spi_message_add_tail(x, &m);
  85. if (wlen) {
  86. x++;
  87. x->tx_buf = wbuf;
  88. x->len = wlen;
  89. x->bits_per_word = 9;
  90. spi_message_add_tail(x, &m);
  91. }
  92. if (rlen) {
  93. x++;
  94. x->rx_buf = rbuf;
  95. x->len = rlen;
  96. spi_message_add_tail(x, &m);
  97. }
  98. ret = spi_sync(lcd->spi, &m);
  99. if (ret < 0)
  100. dev_dbg(&lcd->spi->dev, "spi_sync %d\n", ret);
  101. }
  102. static inline void acx565akm_cmd(struct acx565akm_panel *lcd, int cmd)
  103. {
  104. acx565akm_transfer(lcd, cmd, NULL, 0, NULL, 0);
  105. }
  106. static inline void acx565akm_write(struct acx565akm_panel *lcd,
  107. int reg, const u8 *buf, int len)
  108. {
  109. acx565akm_transfer(lcd, reg, buf, len, NULL, 0);
  110. }
  111. static inline void acx565akm_read(struct acx565akm_panel *lcd,
  112. int reg, u8 *buf, int len)
  113. {
  114. acx565akm_transfer(lcd, reg, NULL, 0, buf, len);
  115. }
  116. /* -----------------------------------------------------------------------------
  117. * Auto Brightness Control Via sysfs
  118. */
  119. static unsigned int acx565akm_get_cabc_mode(struct acx565akm_panel *lcd)
  120. {
  121. return lcd->cabc_mode;
  122. }
  123. static void acx565akm_set_cabc_mode(struct acx565akm_panel *lcd,
  124. unsigned int mode)
  125. {
  126. u16 cabc_ctrl;
  127. lcd->cabc_mode = mode;
  128. if (!lcd->enabled)
  129. return;
  130. cabc_ctrl = 0;
  131. acx565akm_read(lcd, MIPID_CMD_READ_CABC, (u8 *)&cabc_ctrl, 1);
  132. cabc_ctrl &= ~3;
  133. cabc_ctrl |= (1 << 8) | (mode & 3);
  134. acx565akm_write(lcd, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2);
  135. }
  136. static unsigned int acx565akm_get_hw_cabc_mode(struct acx565akm_panel *lcd)
  137. {
  138. u8 cabc_ctrl;
  139. acx565akm_read(lcd, MIPID_CMD_READ_CABC, &cabc_ctrl, 1);
  140. return cabc_ctrl & 3;
  141. }
  142. static const char * const acx565akm_cabc_modes[] = {
  143. "off", /* always used when CABC is not supported */
  144. "ui",
  145. "still-image",
  146. "moving-image",
  147. };
  148. static ssize_t cabc_mode_show(struct device *dev,
  149. struct device_attribute *attr,
  150. char *buf)
  151. {
  152. struct acx565akm_panel *lcd = dev_get_drvdata(dev);
  153. const char *mode_str;
  154. int mode;
  155. if (!lcd->has_cabc)
  156. mode = 0;
  157. else
  158. mode = acx565akm_get_cabc_mode(lcd);
  159. mode_str = "unknown";
  160. if (mode >= 0 && mode < ARRAY_SIZE(acx565akm_cabc_modes))
  161. mode_str = acx565akm_cabc_modes[mode];
  162. return sprintf(buf, "%s\n", mode_str);
  163. }
  164. static ssize_t cabc_mode_store(struct device *dev,
  165. struct device_attribute *attr,
  166. const char *buf, size_t count)
  167. {
  168. struct acx565akm_panel *lcd = dev_get_drvdata(dev);
  169. unsigned int i;
  170. for (i = 0; i < ARRAY_SIZE(acx565akm_cabc_modes); i++) {
  171. const char *mode_str = acx565akm_cabc_modes[i];
  172. int cmp_len = strlen(mode_str);
  173. if (count > 0 && buf[count - 1] == '\n')
  174. count--;
  175. if (count != cmp_len)
  176. continue;
  177. if (strncmp(buf, mode_str, cmp_len) == 0)
  178. break;
  179. }
  180. if (i == ARRAY_SIZE(acx565akm_cabc_modes))
  181. return -EINVAL;
  182. if (!lcd->has_cabc && i != 0)
  183. return -EINVAL;
  184. mutex_lock(&lcd->mutex);
  185. acx565akm_set_cabc_mode(lcd, i);
  186. mutex_unlock(&lcd->mutex);
  187. return count;
  188. }
  189. static ssize_t cabc_available_modes_show(struct device *dev,
  190. struct device_attribute *attr,
  191. char *buf)
  192. {
  193. struct acx565akm_panel *lcd = dev_get_drvdata(dev);
  194. unsigned int i;
  195. size_t len = 0;
  196. if (!lcd->has_cabc)
  197. return sprintf(buf, "%s\n", acx565akm_cabc_modes[0]);
  198. for (i = 0; i < ARRAY_SIZE(acx565akm_cabc_modes); i++)
  199. len += sprintf(&buf[len], "%s%s", i ? " " : "",
  200. acx565akm_cabc_modes[i]);
  201. buf[len++] = '\n';
  202. return len;
  203. }
  204. static DEVICE_ATTR_RW(cabc_mode);
  205. static DEVICE_ATTR_RO(cabc_available_modes);
  206. static struct attribute *acx565akm_cabc_attrs[] = {
  207. &dev_attr_cabc_mode.attr,
  208. &dev_attr_cabc_available_modes.attr,
  209. NULL,
  210. };
  211. static const struct attribute_group acx565akm_cabc_attr_group = {
  212. .attrs = acx565akm_cabc_attrs,
  213. };
  214. /* -----------------------------------------------------------------------------
  215. * Backlight Device
  216. */
  217. static int acx565akm_get_actual_brightness(struct acx565akm_panel *lcd)
  218. {
  219. u8 bv;
  220. acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, &bv, 1);
  221. return bv;
  222. }
  223. static void acx565akm_set_brightness(struct acx565akm_panel *lcd, int level)
  224. {
  225. u16 ctrl;
  226. int bv;
  227. bv = level | (1 << 8);
  228. acx565akm_write(lcd, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, (u8 *)&bv, 2);
  229. acx565akm_read(lcd, MIPI_DCS_GET_CONTROL_DISPLAY, (u8 *)&ctrl, 1);
  230. if (level)
  231. ctrl |= CTRL_DISP_BRIGHTNESS_CTRL_ON |
  232. CTRL_DISP_BACKLIGHT_ON;
  233. else
  234. ctrl &= ~(CTRL_DISP_BRIGHTNESS_CTRL_ON |
  235. CTRL_DISP_BACKLIGHT_ON);
  236. ctrl |= 1 << 8;
  237. acx565akm_write(lcd, MIPI_DCS_WRITE_CONTROL_DISPLAY, (u8 *)&ctrl, 2);
  238. }
  239. static int acx565akm_bl_update_status_locked(struct backlight_device *dev)
  240. {
  241. struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev);
  242. int level;
  243. if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
  244. dev->props.power == FB_BLANK_UNBLANK)
  245. level = dev->props.brightness;
  246. else
  247. level = 0;
  248. acx565akm_set_brightness(lcd, level);
  249. return 0;
  250. }
  251. static int acx565akm_bl_update_status(struct backlight_device *dev)
  252. {
  253. struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev);
  254. int ret;
  255. mutex_lock(&lcd->mutex);
  256. ret = acx565akm_bl_update_status_locked(dev);
  257. mutex_unlock(&lcd->mutex);
  258. return ret;
  259. }
  260. static int acx565akm_bl_get_intensity(struct backlight_device *dev)
  261. {
  262. struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev);
  263. unsigned int intensity;
  264. mutex_lock(&lcd->mutex);
  265. if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
  266. dev->props.power == FB_BLANK_UNBLANK)
  267. intensity = acx565akm_get_actual_brightness(lcd);
  268. else
  269. intensity = 0;
  270. mutex_unlock(&lcd->mutex);
  271. return intensity;
  272. }
  273. static const struct backlight_ops acx565akm_bl_ops = {
  274. .get_brightness = acx565akm_bl_get_intensity,
  275. .update_status = acx565akm_bl_update_status,
  276. };
  277. static int acx565akm_backlight_init(struct acx565akm_panel *lcd)
  278. {
  279. struct backlight_properties props = {
  280. .fb_blank = FB_BLANK_UNBLANK,
  281. .power = FB_BLANK_UNBLANK,
  282. .type = BACKLIGHT_RAW,
  283. };
  284. int ret;
  285. lcd->backlight = backlight_device_register(lcd->name, &lcd->spi->dev,
  286. lcd, &acx565akm_bl_ops,
  287. &props);
  288. if (IS_ERR(lcd->backlight)) {
  289. ret = PTR_ERR(lcd->backlight);
  290. lcd->backlight = NULL;
  291. return ret;
  292. }
  293. if (lcd->has_cabc) {
  294. ret = sysfs_create_group(&lcd->backlight->dev.kobj,
  295. &acx565akm_cabc_attr_group);
  296. if (ret < 0) {
  297. dev_err(&lcd->spi->dev,
  298. "%s failed to create sysfs files\n", __func__);
  299. backlight_device_unregister(lcd->backlight);
  300. return ret;
  301. }
  302. lcd->cabc_mode = acx565akm_get_hw_cabc_mode(lcd);
  303. }
  304. lcd->backlight->props.max_brightness = 255;
  305. lcd->backlight->props.brightness = acx565akm_get_actual_brightness(lcd);
  306. acx565akm_bl_update_status_locked(lcd->backlight);
  307. return 0;
  308. }
  309. static void acx565akm_backlight_cleanup(struct acx565akm_panel *lcd)
  310. {
  311. if (lcd->has_cabc)
  312. sysfs_remove_group(&lcd->backlight->dev.kobj,
  313. &acx565akm_cabc_attr_group);
  314. backlight_device_unregister(lcd->backlight);
  315. }
  316. /* -----------------------------------------------------------------------------
  317. * DRM Bridge Operations
  318. */
  319. static void acx565akm_set_sleep_mode(struct acx565akm_panel *lcd, int on)
  320. {
  321. int cmd = on ? MIPI_DCS_ENTER_SLEEP_MODE : MIPI_DCS_EXIT_SLEEP_MODE;
  322. unsigned long wait;
  323. /*
  324. * We have to keep 120msec between sleep in/out commands.
  325. * (8.2.15, 8.2.16).
  326. */
  327. wait = lcd->hw_guard_end - jiffies;
  328. if ((long)wait > 0 && wait <= lcd->hw_guard_wait) {
  329. set_current_state(TASK_UNINTERRUPTIBLE);
  330. schedule_timeout(wait);
  331. }
  332. acx565akm_cmd(lcd, cmd);
  333. lcd->hw_guard_wait = msecs_to_jiffies(120);
  334. lcd->hw_guard_end = jiffies + lcd->hw_guard_wait;
  335. }
  336. static void acx565akm_set_display_state(struct acx565akm_panel *lcd,
  337. int enabled)
  338. {
  339. int cmd = enabled ? MIPI_DCS_SET_DISPLAY_ON : MIPI_DCS_SET_DISPLAY_OFF;
  340. acx565akm_cmd(lcd, cmd);
  341. }
  342. static int acx565akm_power_on(struct acx565akm_panel *lcd)
  343. {
  344. /*FIXME tweak me */
  345. msleep(50);
  346. gpiod_set_value(lcd->reset_gpio, 1);
  347. if (lcd->enabled) {
  348. dev_dbg(&lcd->spi->dev, "panel already enabled\n");
  349. return 0;
  350. }
  351. /*
  352. * We have to meet all the following delay requirements:
  353. * 1. tRW: reset pulse width 10usec (7.12.1)
  354. * 2. tRT: reset cancel time 5msec (7.12.1)
  355. * 3. Providing PCLK,HS,VS signals for 2 frames = ~50msec worst
  356. * case (7.6.2)
  357. * 4. 120msec before the sleep out command (7.12.1)
  358. */
  359. msleep(120);
  360. acx565akm_set_sleep_mode(lcd, 0);
  361. lcd->enabled = true;
  362. /* 5msec between sleep out and the next command. (8.2.16) */
  363. usleep_range(5000, 10000);
  364. acx565akm_set_display_state(lcd, 1);
  365. acx565akm_set_cabc_mode(lcd, lcd->cabc_mode);
  366. return acx565akm_bl_update_status_locked(lcd->backlight);
  367. }
  368. static void acx565akm_power_off(struct acx565akm_panel *lcd)
  369. {
  370. if (!lcd->enabled)
  371. return;
  372. acx565akm_set_display_state(lcd, 0);
  373. acx565akm_set_sleep_mode(lcd, 1);
  374. lcd->enabled = false;
  375. /*
  376. * We have to provide PCLK,HS,VS signals for 2 frames (worst case
  377. * ~50msec) after sending the sleep in command and asserting the
  378. * reset signal. We probably could assert the reset w/o the delay
  379. * but we still delay to avoid possible artifacts. (7.6.1)
  380. */
  381. msleep(50);
  382. gpiod_set_value(lcd->reset_gpio, 0);
  383. /* FIXME need to tweak this delay */
  384. msleep(100);
  385. }
  386. static int acx565akm_disable(struct drm_panel *panel)
  387. {
  388. struct acx565akm_panel *lcd = to_acx565akm_device(panel);
  389. mutex_lock(&lcd->mutex);
  390. acx565akm_power_off(lcd);
  391. mutex_unlock(&lcd->mutex);
  392. return 0;
  393. }
  394. static int acx565akm_enable(struct drm_panel *panel)
  395. {
  396. struct acx565akm_panel *lcd = to_acx565akm_device(panel);
  397. mutex_lock(&lcd->mutex);
  398. acx565akm_power_on(lcd);
  399. mutex_unlock(&lcd->mutex);
  400. return 0;
  401. }
  402. static const struct drm_display_mode acx565akm_mode = {
  403. .clock = 24000,
  404. .hdisplay = 800,
  405. .hsync_start = 800 + 28,
  406. .hsync_end = 800 + 28 + 4,
  407. .htotal = 800 + 28 + 4 + 24,
  408. .vdisplay = 480,
  409. .vsync_start = 480 + 3,
  410. .vsync_end = 480 + 3 + 3,
  411. .vtotal = 480 + 3 + 3 + 4,
  412. .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
  413. .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
  414. .width_mm = 77,
  415. .height_mm = 46,
  416. };
  417. static int acx565akm_get_modes(struct drm_panel *panel,
  418. struct drm_connector *connector)
  419. {
  420. struct drm_display_mode *mode;
  421. mode = drm_mode_duplicate(connector->dev, &acx565akm_mode);
  422. if (!mode)
  423. return -ENOMEM;
  424. drm_mode_set_name(mode);
  425. drm_mode_probed_add(connector, mode);
  426. connector->display_info.width_mm = acx565akm_mode.width_mm;
  427. connector->display_info.height_mm = acx565akm_mode.height_mm;
  428. connector->display_info.bus_flags = DRM_BUS_FLAG_DE_HIGH
  429. | DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE
  430. | DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE;
  431. return 1;
  432. }
  433. static const struct drm_panel_funcs acx565akm_funcs = {
  434. .disable = acx565akm_disable,
  435. .enable = acx565akm_enable,
  436. .get_modes = acx565akm_get_modes,
  437. };
  438. /* -----------------------------------------------------------------------------
  439. * Probe, Detect and Remove
  440. */
  441. static int acx565akm_detect(struct acx565akm_panel *lcd)
  442. {
  443. __be32 value;
  444. u32 status;
  445. int ret = 0;
  446. /*
  447. * After being taken out of reset the panel needs 5ms before the first
  448. * command can be sent.
  449. */
  450. gpiod_set_value(lcd->reset_gpio, 1);
  451. usleep_range(5000, 10000);
  452. acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_STATUS, (u8 *)&value, 4);
  453. status = __be32_to_cpu(value);
  454. lcd->enabled = (status & (1 << 17)) && (status & (1 << 10));
  455. dev_dbg(&lcd->spi->dev,
  456. "LCD panel %s by bootloader (status 0x%04x)\n",
  457. lcd->enabled ? "enabled" : "disabled ", status);
  458. acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_ID, lcd->display_id, 3);
  459. dev_dbg(&lcd->spi->dev, "MIPI display ID: %02x%02x%02x\n",
  460. lcd->display_id[0], lcd->display_id[1], lcd->display_id[2]);
  461. switch (lcd->display_id[0]) {
  462. case 0x10:
  463. lcd->model = MIPID_VER_ACX565AKM;
  464. lcd->name = "acx565akm";
  465. lcd->has_bc = 1;
  466. lcd->has_cabc = 1;
  467. break;
  468. case 0x29:
  469. lcd->model = MIPID_VER_L4F00311;
  470. lcd->name = "l4f00311";
  471. break;
  472. case 0x45:
  473. lcd->model = MIPID_VER_LPH8923;
  474. lcd->name = "lph8923";
  475. break;
  476. case 0x83:
  477. lcd->model = MIPID_VER_LS041Y3;
  478. lcd->name = "ls041y3";
  479. break;
  480. default:
  481. lcd->name = "unknown";
  482. dev_err(&lcd->spi->dev, "unknown display ID\n");
  483. ret = -ENODEV;
  484. goto done;
  485. }
  486. lcd->revision = lcd->display_id[1];
  487. dev_info(&lcd->spi->dev, "%s rev %02x panel detected\n",
  488. lcd->name, lcd->revision);
  489. done:
  490. if (!lcd->enabled)
  491. gpiod_set_value(lcd->reset_gpio, 0);
  492. return ret;
  493. }
  494. static int acx565akm_probe(struct spi_device *spi)
  495. {
  496. struct acx565akm_panel *lcd;
  497. int ret;
  498. lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL);
  499. if (!lcd)
  500. return -ENOMEM;
  501. spi_set_drvdata(spi, lcd);
  502. spi->mode = SPI_MODE_3;
  503. lcd->spi = spi;
  504. mutex_init(&lcd->mutex);
  505. lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH);
  506. if (IS_ERR(lcd->reset_gpio)) {
  507. dev_err(&spi->dev, "failed to get reset GPIO\n");
  508. return PTR_ERR(lcd->reset_gpio);
  509. }
  510. ret = acx565akm_detect(lcd);
  511. if (ret < 0) {
  512. dev_err(&spi->dev, "panel detection failed\n");
  513. return ret;
  514. }
  515. if (lcd->has_bc) {
  516. ret = acx565akm_backlight_init(lcd);
  517. if (ret < 0)
  518. return ret;
  519. }
  520. drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs,
  521. DRM_MODE_CONNECTOR_DPI);
  522. drm_panel_add(&lcd->panel);
  523. return 0;
  524. }
  525. static int acx565akm_remove(struct spi_device *spi)
  526. {
  527. struct acx565akm_panel *lcd = spi_get_drvdata(spi);
  528. drm_panel_remove(&lcd->panel);
  529. if (lcd->has_bc)
  530. acx565akm_backlight_cleanup(lcd);
  531. drm_panel_disable(&lcd->panel);
  532. drm_panel_unprepare(&lcd->panel);
  533. return 0;
  534. }
  535. static const struct of_device_id acx565akm_of_match[] = {
  536. { .compatible = "sony,acx565akm", },
  537. { /* sentinel */ },
  538. };
  539. MODULE_DEVICE_TABLE(of, acx565akm_of_match);
  540. static const struct spi_device_id acx565akm_ids[] = {
  541. { "acx565akm", 0 },
  542. { /* sentinel */ }
  543. };
  544. MODULE_DEVICE_TABLE(spi, acx565akm_ids);
  545. static struct spi_driver acx565akm_driver = {
  546. .probe = acx565akm_probe,
  547. .remove = acx565akm_remove,
  548. .id_table = acx565akm_ids,
  549. .driver = {
  550. .name = "panel-sony-acx565akm",
  551. .of_match_table = acx565akm_of_match,
  552. },
  553. };
  554. module_spi_driver(acx565akm_driver);
  555. MODULE_AUTHOR("Nokia Corporation");
  556. MODULE_DESCRIPTION("Sony ACX565AKM LCD Panel Driver");
  557. MODULE_LICENSE("GPL");