panel-ili9881d.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * mipi_dsi.h - MIPI dsi module
  4. *
  5. * Copyright (c) 2020 Seeed Studio
  6. *
  7. * I2C slave address: 0x45
  8. */
  9. #ifndef __MIPI_DSI_H__
  10. #define __MIPI_DSI_H__
  11. #include <linux/interrupt.h>
  12. #include <linux/bitops.h>
  13. #include <linux/slab.h>
  14. #include <linux/string.h>
  15. #include <linux/delay.h>
  16. #include <linux/err.h>
  17. #include <linux/fb.h>
  18. #include <linux/gpio.h>
  19. #include <linux/gpio/consumer.h>
  20. #include <linux/i2c.h>
  21. #include <linux/module.h>
  22. #include <linux/of.h>
  23. #include <linux/of_device.h>
  24. #include <linux/of_graph.h>
  25. #include <linux/pm.h>
  26. #include <drm/drm_crtc.h>
  27. #include <drm/drm_device.h>
  28. #include <drm/drm_mipi_dsi.h>
  29. #include <drm/drm_panel.h>
  30. #include <drm/drm_modes.h>
  31. #include <video/mipi_display.h>
  32. #include <linux/input.h>
  33. #include <linux/input/mt.h>
  34. #include <linux/input/touchscreen.h>
  35. #ifdef I2C_DSI_DBG
  36. #define DBG_FUNC(format, x...) printk(KERN_INFO "[DSI]%s:" format"\n", __func__, ##x)
  37. #define DBG_PRINT(format, x...) printk(KERN_INFO "[DSI]" format"\n", ##x)
  38. #else
  39. #define DBG_FUNC(format, x...)
  40. #define DBG_PRINT(format, x...)
  41. #endif
  42. #define DSI_DRIVER_NAME "i2c_mipi_dsi"
  43. /* i2c: commands */
  44. enum REG_ADDR {
  45. REG_ID = 0x80,
  46. REG_PORTA, /* BIT(2) for horizontal flip, BIT(3) for vertical flip */
  47. REG_PORTB, // --
  48. REG_PORTC,
  49. REG_PORTD,
  50. REG_POWERON,// --
  51. REG_PWM, // --
  52. REG_DDRA,
  53. REG_DDRB,
  54. REG_DDRC,
  55. REG_DDRD,
  56. REG_TEST,
  57. REG_WR_ADDRL,
  58. REG_WR_ADDRH,
  59. REG_READH,
  60. REG_READL,
  61. REG_WRITEH,
  62. REG_WRITEL,
  63. REG_ID2,
  64. REG_LCD_RST,
  65. REG_TP_RST,
  66. REG_TP_STATUS,
  67. REG_TP_POINT,
  68. REG_TP_VERSION,
  69. REG_ADC1,
  70. REG_ADC2,
  71. REG_MCU_AUTO_RESET,
  72. REG_MAX
  73. };
  74. #define DSI_DCS_WRITE(dsi, seq...) \
  75. { \
  76. int ret = 0; \
  77. const u8 d[] = { seq }; \
  78. ret = mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); \
  79. if (ret < 0) \
  80. return ret; \
  81. }
  82. struct panel_data {
  83. void (*set_dsi)(struct mipi_dsi_device *dsi);
  84. const struct drm_panel_funcs *funcs;
  85. };
  86. struct i2c_mipi_dsi {
  87. struct i2c_client *i2c;
  88. struct mutex mutex;
  89. // panel
  90. struct drm_panel panel;
  91. struct panel_data *panel_data;
  92. // dsi
  93. struct mipi_dsi_device *dsi;
  94. // tp
  95. struct input_dev *input;
  96. struct touchscreen_properties prop;
  97. uint32_t tp_point_rotate;
  98. // backlight
  99. int brightness;
  100. // mcu auto reset enable when the tp driver is not working
  101. uint32_t mcu_auto_reset;
  102. };
  103. #define panel_to_md(_p) container_of(_p, struct i2c_mipi_dsi, panel)
  104. static int i2c_md_read(struct i2c_mipi_dsi *md, u8 reg, u8 *buf, int len);
  105. #endif /*End of header guard macro */