18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * MIPI DSI Bus 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd. 68c2ecf20Sopenharmony_ci * Andrzej Hajda <a.hajda@samsung.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __DRM_MIPI_DSI_H__ 108c2ecf20Sopenharmony_ci#define __DRM_MIPI_DSI_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/device.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct mipi_dsi_host; 158c2ecf20Sopenharmony_cistruct mipi_dsi_device; 168c2ecf20Sopenharmony_cistruct drm_dsc_picture_parameter_set; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* request ACK from peripheral */ 198c2ecf20Sopenharmony_ci#define MIPI_DSI_MSG_REQ_ACK BIT(0) 208c2ecf20Sopenharmony_ci/* use Low Power Mode to transmit message */ 218c2ecf20Sopenharmony_ci#define MIPI_DSI_MSG_USE_LPM BIT(1) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/** 248c2ecf20Sopenharmony_ci * struct mipi_dsi_msg - read/write DSI buffer 258c2ecf20Sopenharmony_ci * @channel: virtual channel id 268c2ecf20Sopenharmony_ci * @type: payload data type 278c2ecf20Sopenharmony_ci * @flags: flags controlling this message transmission 288c2ecf20Sopenharmony_ci * @tx_len: length of @tx_buf 298c2ecf20Sopenharmony_ci * @tx_buf: data to be written 308c2ecf20Sopenharmony_ci * @rx_len: length of @rx_buf 318c2ecf20Sopenharmony_ci * @rx_buf: data to be read, or NULL 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_cistruct mipi_dsi_msg { 348c2ecf20Sopenharmony_ci u8 channel; 358c2ecf20Sopenharmony_ci u8 type; 368c2ecf20Sopenharmony_ci u16 flags; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci size_t tx_len; 398c2ecf20Sopenharmony_ci const void *tx_buf; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci size_t rx_len; 428c2ecf20Sopenharmony_ci void *rx_buf; 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cibool mipi_dsi_packet_format_is_short(u8 type); 468c2ecf20Sopenharmony_cibool mipi_dsi_packet_format_is_long(u8 type); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/** 498c2ecf20Sopenharmony_ci * struct mipi_dsi_packet - represents a MIPI DSI packet in protocol format 508c2ecf20Sopenharmony_ci * @size: size (in bytes) of the packet 518c2ecf20Sopenharmony_ci * @header: the four bytes that make up the header (Data ID, Word Count or 528c2ecf20Sopenharmony_ci * Packet Data, and ECC) 538c2ecf20Sopenharmony_ci * @payload_length: number of bytes in the payload 548c2ecf20Sopenharmony_ci * @payload: a pointer to a buffer containing the payload, if any 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_cistruct mipi_dsi_packet { 578c2ecf20Sopenharmony_ci size_t size; 588c2ecf20Sopenharmony_ci u8 header[4]; 598c2ecf20Sopenharmony_ci size_t payload_length; 608c2ecf20Sopenharmony_ci const u8 *payload; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciint mipi_dsi_create_packet(struct mipi_dsi_packet *packet, 648c2ecf20Sopenharmony_ci const struct mipi_dsi_msg *msg); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/** 678c2ecf20Sopenharmony_ci * struct mipi_dsi_host_ops - DSI bus operations 688c2ecf20Sopenharmony_ci * @attach: attach DSI device to DSI host 698c2ecf20Sopenharmony_ci * @detach: detach DSI device from DSI host 708c2ecf20Sopenharmony_ci * @transfer: transmit a DSI packet 718c2ecf20Sopenharmony_ci * 728c2ecf20Sopenharmony_ci * DSI packets transmitted by .transfer() are passed in as mipi_dsi_msg 738c2ecf20Sopenharmony_ci * structures. This structure contains information about the type of packet 748c2ecf20Sopenharmony_ci * being transmitted as well as the transmit and receive buffers. When an 758c2ecf20Sopenharmony_ci * error is encountered during transmission, this function will return a 768c2ecf20Sopenharmony_ci * negative error code. On success it shall return the number of bytes 778c2ecf20Sopenharmony_ci * transmitted for write packets or the number of bytes received for read 788c2ecf20Sopenharmony_ci * packets. 798c2ecf20Sopenharmony_ci * 808c2ecf20Sopenharmony_ci * Note that typically DSI packet transmission is atomic, so the .transfer() 818c2ecf20Sopenharmony_ci * function will seldomly return anything other than the number of bytes 828c2ecf20Sopenharmony_ci * contained in the transmit buffer on success. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_cistruct mipi_dsi_host_ops { 858c2ecf20Sopenharmony_ci int (*attach)(struct mipi_dsi_host *host, 868c2ecf20Sopenharmony_ci struct mipi_dsi_device *dsi); 878c2ecf20Sopenharmony_ci int (*detach)(struct mipi_dsi_host *host, 888c2ecf20Sopenharmony_ci struct mipi_dsi_device *dsi); 898c2ecf20Sopenharmony_ci ssize_t (*transfer)(struct mipi_dsi_host *host, 908c2ecf20Sopenharmony_ci const struct mipi_dsi_msg *msg); 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/** 948c2ecf20Sopenharmony_ci * struct mipi_dsi_host - DSI host device 958c2ecf20Sopenharmony_ci * @dev: driver model device node for this DSI host 968c2ecf20Sopenharmony_ci * @ops: DSI host operations 978c2ecf20Sopenharmony_ci * @list: list management 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_cistruct mipi_dsi_host { 1008c2ecf20Sopenharmony_ci struct device *dev; 1018c2ecf20Sopenharmony_ci const struct mipi_dsi_host_ops *ops; 1028c2ecf20Sopenharmony_ci struct list_head list; 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciint mipi_dsi_host_register(struct mipi_dsi_host *host); 1068c2ecf20Sopenharmony_civoid mipi_dsi_host_unregister(struct mipi_dsi_host *host); 1078c2ecf20Sopenharmony_cistruct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* DSI mode flags */ 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* video mode */ 1128c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO BIT(0) 1138c2ecf20Sopenharmony_ci/* video burst mode */ 1148c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_BURST BIT(1) 1158c2ecf20Sopenharmony_ci/* video pulse mode */ 1168c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_SYNC_PULSE BIT(2) 1178c2ecf20Sopenharmony_ci/* enable auto vertical count mode */ 1188c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_AUTO_VERT BIT(3) 1198c2ecf20Sopenharmony_ci/* enable hsync-end packets in vsync-pulse and v-porch area */ 1208c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_HSE BIT(4) 1218c2ecf20Sopenharmony_ci/* disable hfront-porch area */ 1228c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_HFP BIT(5) 1238c2ecf20Sopenharmony_ci/* disable hback-porch area */ 1248c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_HBP BIT(6) 1258c2ecf20Sopenharmony_ci/* disable hsync-active area */ 1268c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VIDEO_HSA BIT(7) 1278c2ecf20Sopenharmony_ci/* flush display FIFO on vsync pulse */ 1288c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_VSYNC_FLUSH BIT(8) 1298c2ecf20Sopenharmony_ci/* disable EoT packets in HS mode */ 1308c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_EOT_PACKET BIT(9) 1318c2ecf20Sopenharmony_ci/* device supports non-continuous clock behavior (DSI spec 5.6.1) */ 1328c2ecf20Sopenharmony_ci#define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10) 1338c2ecf20Sopenharmony_ci/* transmit data in low power */ 1348c2ecf20Sopenharmony_ci#define MIPI_DSI_MODE_LPM BIT(11) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cienum mipi_dsi_pixel_format { 1378c2ecf20Sopenharmony_ci MIPI_DSI_FMT_RGB888, 1388c2ecf20Sopenharmony_ci MIPI_DSI_FMT_RGB666, 1398c2ecf20Sopenharmony_ci MIPI_DSI_FMT_RGB666_PACKED, 1408c2ecf20Sopenharmony_ci MIPI_DSI_FMT_RGB565, 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define DSI_DEV_NAME_SIZE 20 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci/** 1468c2ecf20Sopenharmony_ci * struct mipi_dsi_device_info - template for creating a mipi_dsi_device 1478c2ecf20Sopenharmony_ci * @type: DSI peripheral chip type 1488c2ecf20Sopenharmony_ci * @channel: DSI virtual channel assigned to peripheral 1498c2ecf20Sopenharmony_ci * @node: pointer to OF device node or NULL 1508c2ecf20Sopenharmony_ci * 1518c2ecf20Sopenharmony_ci * This is populated and passed to mipi_dsi_device_new to create a new 1528c2ecf20Sopenharmony_ci * DSI device 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_cistruct mipi_dsi_device_info { 1558c2ecf20Sopenharmony_ci char type[DSI_DEV_NAME_SIZE]; 1568c2ecf20Sopenharmony_ci u32 channel; 1578c2ecf20Sopenharmony_ci struct device_node *node; 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/** 1618c2ecf20Sopenharmony_ci * struct mipi_dsi_device - DSI peripheral device 1628c2ecf20Sopenharmony_ci * @host: DSI host for this peripheral 1638c2ecf20Sopenharmony_ci * @dev: driver model device node for this peripheral 1648c2ecf20Sopenharmony_ci * @attached: the DSI device has been successfully attached 1658c2ecf20Sopenharmony_ci * @name: DSI peripheral chip type 1668c2ecf20Sopenharmony_ci * @channel: virtual channel assigned to the peripheral 1678c2ecf20Sopenharmony_ci * @format: pixel format for video mode 1688c2ecf20Sopenharmony_ci * @lanes: number of active data lanes 1698c2ecf20Sopenharmony_ci * @mode_flags: DSI operation mode related flags 1708c2ecf20Sopenharmony_ci * @hs_rate: maximum lane frequency for high speed mode in hertz, this should 1718c2ecf20Sopenharmony_ci * be set to the real limits of the hardware, zero is only accepted for 1728c2ecf20Sopenharmony_ci * legacy drivers 1738c2ecf20Sopenharmony_ci * @lp_rate: maximum lane frequency for low power mode in hertz, this should 1748c2ecf20Sopenharmony_ci * be set to the real limits of the hardware, zero is only accepted for 1758c2ecf20Sopenharmony_ci * legacy drivers 1768c2ecf20Sopenharmony_ci */ 1778c2ecf20Sopenharmony_cistruct mipi_dsi_device { 1788c2ecf20Sopenharmony_ci struct mipi_dsi_host *host; 1798c2ecf20Sopenharmony_ci struct device dev; 1808c2ecf20Sopenharmony_ci bool attached; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci char name[DSI_DEV_NAME_SIZE]; 1838c2ecf20Sopenharmony_ci unsigned int channel; 1848c2ecf20Sopenharmony_ci unsigned int lanes; 1858c2ecf20Sopenharmony_ci enum mipi_dsi_pixel_format format; 1868c2ecf20Sopenharmony_ci unsigned long mode_flags; 1878c2ecf20Sopenharmony_ci unsigned long hs_rate; 1888c2ecf20Sopenharmony_ci unsigned long lp_rate; 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define MIPI_DSI_MODULE_PREFIX "mipi-dsi:" 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistatic inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev) 1948c2ecf20Sopenharmony_ci{ 1958c2ecf20Sopenharmony_ci return container_of(dev, struct mipi_dsi_device, dev); 1968c2ecf20Sopenharmony_ci} 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci/** 1998c2ecf20Sopenharmony_ci * mipi_dsi_pixel_format_to_bpp - obtain the number of bits per pixel for any 2008c2ecf20Sopenharmony_ci * given pixel format defined by the MIPI DSI 2018c2ecf20Sopenharmony_ci * specification 2028c2ecf20Sopenharmony_ci * @fmt: MIPI DSI pixel format 2038c2ecf20Sopenharmony_ci * 2048c2ecf20Sopenharmony_ci * Returns: The number of bits per pixel of the given pixel format. 2058c2ecf20Sopenharmony_ci */ 2068c2ecf20Sopenharmony_cistatic inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt) 2078c2ecf20Sopenharmony_ci{ 2088c2ecf20Sopenharmony_ci switch (fmt) { 2098c2ecf20Sopenharmony_ci case MIPI_DSI_FMT_RGB888: 2108c2ecf20Sopenharmony_ci case MIPI_DSI_FMT_RGB666: 2118c2ecf20Sopenharmony_ci return 24; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci case MIPI_DSI_FMT_RGB666_PACKED: 2148c2ecf20Sopenharmony_ci return 18; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci case MIPI_DSI_FMT_RGB565: 2178c2ecf20Sopenharmony_ci return 16; 2188c2ecf20Sopenharmony_ci } 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci return -EINVAL; 2218c2ecf20Sopenharmony_ci} 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistruct mipi_dsi_device * 2248c2ecf20Sopenharmony_cimipi_dsi_device_register_full(struct mipi_dsi_host *host, 2258c2ecf20Sopenharmony_ci const struct mipi_dsi_device_info *info); 2268c2ecf20Sopenharmony_civoid mipi_dsi_device_unregister(struct mipi_dsi_device *dsi); 2278c2ecf20Sopenharmony_cistruct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np); 2288c2ecf20Sopenharmony_ciint mipi_dsi_attach(struct mipi_dsi_device *dsi); 2298c2ecf20Sopenharmony_ciint mipi_dsi_detach(struct mipi_dsi_device *dsi); 2308c2ecf20Sopenharmony_ciint mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi); 2318c2ecf20Sopenharmony_ciint mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi); 2328c2ecf20Sopenharmony_ciint mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, 2338c2ecf20Sopenharmony_ci u16 value); 2348c2ecf20Sopenharmony_cissize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable); 2358c2ecf20Sopenharmony_cissize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi, 2368c2ecf20Sopenharmony_ci const struct drm_dsc_picture_parameter_set *pps); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_cissize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, 2398c2ecf20Sopenharmony_ci size_t size); 2408c2ecf20Sopenharmony_cissize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params, 2418c2ecf20Sopenharmony_ci size_t num_params, void *data, size_t size); 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/** 2448c2ecf20Sopenharmony_ci * enum mipi_dsi_dcs_tear_mode - Tearing Effect Output Line mode 2458c2ecf20Sopenharmony_ci * @MIPI_DSI_DCS_TEAR_MODE_VBLANK: the TE output line consists of V-Blanking 2468c2ecf20Sopenharmony_ci * information only 2478c2ecf20Sopenharmony_ci * @MIPI_DSI_DCS_TEAR_MODE_VHBLANK : the TE output line consists of both 2488c2ecf20Sopenharmony_ci * V-Blanking and H-Blanking information 2498c2ecf20Sopenharmony_ci */ 2508c2ecf20Sopenharmony_cienum mipi_dsi_dcs_tear_mode { 2518c2ecf20Sopenharmony_ci MIPI_DSI_DCS_TEAR_MODE_VBLANK, 2528c2ecf20Sopenharmony_ci MIPI_DSI_DCS_TEAR_MODE_VHBLANK, 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci#define MIPI_DSI_DCS_POWER_MODE_DISPLAY (1 << 2) 2568c2ecf20Sopenharmony_ci#define MIPI_DSI_DCS_POWER_MODE_NORMAL (1 << 3) 2578c2ecf20Sopenharmony_ci#define MIPI_DSI_DCS_POWER_MODE_SLEEP (1 << 4) 2588c2ecf20Sopenharmony_ci#define MIPI_DSI_DCS_POWER_MODE_PARTIAL (1 << 5) 2598c2ecf20Sopenharmony_ci#define MIPI_DSI_DCS_POWER_MODE_IDLE (1 << 6) 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_cissize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, 2628c2ecf20Sopenharmony_ci const void *data, size_t len); 2638c2ecf20Sopenharmony_cissize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, 2648c2ecf20Sopenharmony_ci const void *data, size_t len); 2658c2ecf20Sopenharmony_cissize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, 2668c2ecf20Sopenharmony_ci size_t len); 2678c2ecf20Sopenharmony_ciint mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi); 2688c2ecf20Sopenharmony_ciint mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi); 2698c2ecf20Sopenharmony_ciint mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode); 2708c2ecf20Sopenharmony_ciint mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format); 2718c2ecf20Sopenharmony_ciint mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi); 2728c2ecf20Sopenharmony_ciint mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi); 2738c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi); 2748c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi); 2758c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start, 2768c2ecf20Sopenharmony_ci u16 end); 2778c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start, 2788c2ecf20Sopenharmony_ci u16 end); 2798c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi); 2808c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, 2818c2ecf20Sopenharmony_ci enum mipi_dsi_dcs_tear_mode mode); 2828c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format); 2838c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline); 2848c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, 2858c2ecf20Sopenharmony_ci u16 brightness); 2868c2ecf20Sopenharmony_ciint mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, 2878c2ecf20Sopenharmony_ci u16 *brightness); 2888c2ecf20Sopenharmony_ciint mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi, 2898c2ecf20Sopenharmony_ci u16 brightness); 2908c2ecf20Sopenharmony_ciint mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi, 2918c2ecf20Sopenharmony_ci u16 *brightness); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci/** 2948c2ecf20Sopenharmony_ci * struct mipi_dsi_driver - DSI driver 2958c2ecf20Sopenharmony_ci * @driver: device driver model driver 2968c2ecf20Sopenharmony_ci * @probe: callback for device binding 2978c2ecf20Sopenharmony_ci * @remove: callback for device unbinding 2988c2ecf20Sopenharmony_ci * @shutdown: called at shutdown time to quiesce the device 2998c2ecf20Sopenharmony_ci */ 3008c2ecf20Sopenharmony_cistruct mipi_dsi_driver { 3018c2ecf20Sopenharmony_ci struct device_driver driver; 3028c2ecf20Sopenharmony_ci int(*probe)(struct mipi_dsi_device *dsi); 3038c2ecf20Sopenharmony_ci int(*remove)(struct mipi_dsi_device *dsi); 3048c2ecf20Sopenharmony_ci void (*shutdown)(struct mipi_dsi_device *dsi); 3058c2ecf20Sopenharmony_ci}; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cistatic inline struct mipi_dsi_driver * 3088c2ecf20Sopenharmony_cito_mipi_dsi_driver(struct device_driver *driver) 3098c2ecf20Sopenharmony_ci{ 3108c2ecf20Sopenharmony_ci return container_of(driver, struct mipi_dsi_driver, driver); 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistatic inline void *mipi_dsi_get_drvdata(const struct mipi_dsi_device *dsi) 3148c2ecf20Sopenharmony_ci{ 3158c2ecf20Sopenharmony_ci return dev_get_drvdata(&dsi->dev); 3168c2ecf20Sopenharmony_ci} 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_cistatic inline void mipi_dsi_set_drvdata(struct mipi_dsi_device *dsi, void *data) 3198c2ecf20Sopenharmony_ci{ 3208c2ecf20Sopenharmony_ci dev_set_drvdata(&dsi->dev, data); 3218c2ecf20Sopenharmony_ci} 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ciint mipi_dsi_driver_register_full(struct mipi_dsi_driver *driver, 3248c2ecf20Sopenharmony_ci struct module *owner); 3258c2ecf20Sopenharmony_civoid mipi_dsi_driver_unregister(struct mipi_dsi_driver *driver); 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#define mipi_dsi_driver_register(driver) \ 3288c2ecf20Sopenharmony_ci mipi_dsi_driver_register_full(driver, THIS_MODULE) 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci#define module_mipi_dsi_driver(__mipi_dsi_driver) \ 3318c2ecf20Sopenharmony_ci module_driver(__mipi_dsi_driver, mipi_dsi_driver_register, \ 3328c2ecf20Sopenharmony_ci mipi_dsi_driver_unregister) 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci#endif /* __DRM_MIPI_DSI__ */ 335