xref: /OK3568_Linux_fs/kernel/include/drm/drm_mipi_dsi.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * MIPI DSI Bus
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd.
6*4882a593Smuzhiyun  * Andrzej Hajda <a.hajda@samsung.com>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef __DRM_MIPI_DSI_H__
10*4882a593Smuzhiyun #define __DRM_MIPI_DSI_H__
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <linux/device.h>
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun struct mipi_dsi_host;
15*4882a593Smuzhiyun struct mipi_dsi_device;
16*4882a593Smuzhiyun struct drm_dsc_picture_parameter_set;
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* request ACK from peripheral */
19*4882a593Smuzhiyun #define MIPI_DSI_MSG_REQ_ACK	BIT(0)
20*4882a593Smuzhiyun /* use Low Power Mode to transmit message */
21*4882a593Smuzhiyun #define MIPI_DSI_MSG_USE_LPM	BIT(1)
22*4882a593Smuzhiyun /* read mipi_dsi_msg.ctrl and unicast to only that ctrls */
23*4882a593Smuzhiyun #define MIPI_DSI_MSG_UNICAST	BIT(2)
24*4882a593Smuzhiyun /* Stack all commands until lastcommand bit and trigger all in one go */
25*4882a593Smuzhiyun #define MIPI_DSI_MSG_LASTCOMMAND BIT(3)
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /**
28*4882a593Smuzhiyun  * struct mipi_dsi_msg - read/write DSI buffer
29*4882a593Smuzhiyun  * @channel: virtual channel id
30*4882a593Smuzhiyun  * @type: payload data type
31*4882a593Smuzhiyun  * @flags: flags controlling this message transmission
32*4882a593Smuzhiyun  * @ctrl: ctrl index to transmit on
33*4882a593Smuzhiyun  * @wait_ms: duration in ms to wait after message transmission
34*4882a593Smuzhiyun  * @tx_len: length of @tx_buf
35*4882a593Smuzhiyun  * @tx_buf: data to be written
36*4882a593Smuzhiyun  * @rx_len: length of @rx_buf
37*4882a593Smuzhiyun  * @rx_buf: data to be read, or NULL
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun struct mipi_dsi_msg {
40*4882a593Smuzhiyun 	u8 channel;
41*4882a593Smuzhiyun 	u8 type;
42*4882a593Smuzhiyun 	u16 flags;
43*4882a593Smuzhiyun 	u32 ctrl;
44*4882a593Smuzhiyun 	u32 wait_ms;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	size_t tx_len;
47*4882a593Smuzhiyun 	const void *tx_buf;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun 	size_t rx_len;
50*4882a593Smuzhiyun 	void *rx_buf;
51*4882a593Smuzhiyun };
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun bool mipi_dsi_packet_format_is_short(u8 type);
54*4882a593Smuzhiyun bool mipi_dsi_packet_format_is_long(u8 type);
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /**
57*4882a593Smuzhiyun  * struct mipi_dsi_packet - represents a MIPI DSI packet in protocol format
58*4882a593Smuzhiyun  * @size: size (in bytes) of the packet
59*4882a593Smuzhiyun  * @header: the four bytes that make up the header (Data ID, Word Count or
60*4882a593Smuzhiyun  *     Packet Data, and ECC)
61*4882a593Smuzhiyun  * @payload_length: number of bytes in the payload
62*4882a593Smuzhiyun  * @payload: a pointer to a buffer containing the payload, if any
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun struct mipi_dsi_packet {
65*4882a593Smuzhiyun 	size_t size;
66*4882a593Smuzhiyun 	u8 header[4];
67*4882a593Smuzhiyun 	size_t payload_length;
68*4882a593Smuzhiyun 	const u8 *payload;
69*4882a593Smuzhiyun };
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
72*4882a593Smuzhiyun 			   const struct mipi_dsi_msg *msg);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * struct mipi_dsi_host_ops - DSI bus operations
76*4882a593Smuzhiyun  * @attach: attach DSI device to DSI host
77*4882a593Smuzhiyun  * @detach: detach DSI device from DSI host
78*4882a593Smuzhiyun  * @transfer: transmit a DSI packet
79*4882a593Smuzhiyun  *
80*4882a593Smuzhiyun  * DSI packets transmitted by .transfer() are passed in as mipi_dsi_msg
81*4882a593Smuzhiyun  * structures. This structure contains information about the type of packet
82*4882a593Smuzhiyun  * being transmitted as well as the transmit and receive buffers. When an
83*4882a593Smuzhiyun  * error is encountered during transmission, this function will return a
84*4882a593Smuzhiyun  * negative error code. On success it shall return the number of bytes
85*4882a593Smuzhiyun  * transmitted for write packets or the number of bytes received for read
86*4882a593Smuzhiyun  * packets.
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * Note that typically DSI packet transmission is atomic, so the .transfer()
89*4882a593Smuzhiyun  * function will seldomly return anything other than the number of bytes
90*4882a593Smuzhiyun  * contained in the transmit buffer on success.
91*4882a593Smuzhiyun  */
92*4882a593Smuzhiyun struct mipi_dsi_host_ops {
93*4882a593Smuzhiyun 	int (*attach)(struct mipi_dsi_host *host,
94*4882a593Smuzhiyun 		      struct mipi_dsi_device *dsi);
95*4882a593Smuzhiyun 	int (*detach)(struct mipi_dsi_host *host,
96*4882a593Smuzhiyun 		      struct mipi_dsi_device *dsi);
97*4882a593Smuzhiyun 	ssize_t (*transfer)(struct mipi_dsi_host *host,
98*4882a593Smuzhiyun 			    const struct mipi_dsi_msg *msg);
99*4882a593Smuzhiyun };
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun /**
102*4882a593Smuzhiyun  * struct mipi_dsi_host - DSI host device
103*4882a593Smuzhiyun  * @dev: driver model device node for this DSI host
104*4882a593Smuzhiyun  * @ops: DSI host operations
105*4882a593Smuzhiyun  * @list: list management
106*4882a593Smuzhiyun  */
107*4882a593Smuzhiyun struct mipi_dsi_host {
108*4882a593Smuzhiyun 	struct device *dev;
109*4882a593Smuzhiyun 	const struct mipi_dsi_host_ops *ops;
110*4882a593Smuzhiyun 	struct list_head list;
111*4882a593Smuzhiyun };
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun int mipi_dsi_host_register(struct mipi_dsi_host *host);
114*4882a593Smuzhiyun void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
115*4882a593Smuzhiyun struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun /* DSI mode flags */
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun /* video mode */
120*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO		BIT(0)
121*4882a593Smuzhiyun /* video burst mode */
122*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_BURST	BIT(1)
123*4882a593Smuzhiyun /* video pulse mode */
124*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_SYNC_PULSE	BIT(2)
125*4882a593Smuzhiyun /* enable auto vertical count mode */
126*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_AUTO_VERT	BIT(3)
127*4882a593Smuzhiyun /* enable hsync-end packets in vsync-pulse and v-porch area */
128*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_HSE		BIT(4)
129*4882a593Smuzhiyun /* disable hfront-porch area */
130*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_HFP		BIT(5)
131*4882a593Smuzhiyun /* disable hback-porch area */
132*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_HBP		BIT(6)
133*4882a593Smuzhiyun /* disable hsync-active area */
134*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_HSA		BIT(7)
135*4882a593Smuzhiyun /* flush display FIFO on vsync pulse */
136*4882a593Smuzhiyun #define MIPI_DSI_MODE_VSYNC_FLUSH	BIT(8)
137*4882a593Smuzhiyun /* disable EoT packets in HS mode */
138*4882a593Smuzhiyun #define MIPI_DSI_MODE_EOT_PACKET	BIT(9)
139*4882a593Smuzhiyun /* device supports non-continuous clock behavior (DSI spec 5.6.1) */
140*4882a593Smuzhiyun #define MIPI_DSI_CLOCK_NON_CONTINUOUS	BIT(10)
141*4882a593Smuzhiyun /* transmit data in low power */
142*4882a593Smuzhiyun #define MIPI_DSI_MODE_LPM		BIT(11)
143*4882a593Smuzhiyun /* disable BLLP area */
144*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_BLLP	BIT(12)
145*4882a593Smuzhiyun /* disable EOF BLLP area */
146*4882a593Smuzhiyun #define MIPI_DSI_MODE_VIDEO_EOF_BLLP	BIT(13)
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun enum mipi_dsi_pixel_format {
149*4882a593Smuzhiyun 	MIPI_DSI_FMT_RGB888,
150*4882a593Smuzhiyun 	MIPI_DSI_FMT_RGB666,
151*4882a593Smuzhiyun 	MIPI_DSI_FMT_RGB666_PACKED,
152*4882a593Smuzhiyun 	MIPI_DSI_FMT_RGB565,
153*4882a593Smuzhiyun };
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun #define DSI_DEV_NAME_SIZE		20
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /**
158*4882a593Smuzhiyun  * struct mipi_dsi_device_info - template for creating a mipi_dsi_device
159*4882a593Smuzhiyun  * @type: DSI peripheral chip type
160*4882a593Smuzhiyun  * @channel: DSI virtual channel assigned to peripheral
161*4882a593Smuzhiyun  * @node: pointer to OF device node or NULL
162*4882a593Smuzhiyun  *
163*4882a593Smuzhiyun  * This is populated and passed to mipi_dsi_device_new to create a new
164*4882a593Smuzhiyun  * DSI device
165*4882a593Smuzhiyun  */
166*4882a593Smuzhiyun struct mipi_dsi_device_info {
167*4882a593Smuzhiyun 	char type[DSI_DEV_NAME_SIZE];
168*4882a593Smuzhiyun 	u32 channel;
169*4882a593Smuzhiyun 	struct device_node *node;
170*4882a593Smuzhiyun };
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun /**
173*4882a593Smuzhiyun  * struct mipi_dsi_device - DSI peripheral device
174*4882a593Smuzhiyun  * @host: DSI host for this peripheral
175*4882a593Smuzhiyun  * @dev: driver model device node for this peripheral
176*4882a593Smuzhiyun  * @name: DSI peripheral chip type
177*4882a593Smuzhiyun  * @channel: virtual channel assigned to the peripheral
178*4882a593Smuzhiyun  * @format: pixel format for video mode
179*4882a593Smuzhiyun  * @lanes: number of active data lanes
180*4882a593Smuzhiyun  * @mode_flags: DSI operation mode related flags
181*4882a593Smuzhiyun  * @hs_rate: maximum lane frequency for high speed mode in hertz, this should
182*4882a593Smuzhiyun  * be set to the real limits of the hardware, zero is only accepted for
183*4882a593Smuzhiyun  * legacy drivers
184*4882a593Smuzhiyun  * @lp_rate: maximum lane frequency for low power mode in hertz, this should
185*4882a593Smuzhiyun  * be set to the real limits of the hardware, zero is only accepted for
186*4882a593Smuzhiyun  * legacy drivers
187*4882a593Smuzhiyun  */
188*4882a593Smuzhiyun struct mipi_dsi_device {
189*4882a593Smuzhiyun 	struct mipi_dsi_host *host;
190*4882a593Smuzhiyun 	struct device dev;
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 	char name[DSI_DEV_NAME_SIZE];
193*4882a593Smuzhiyun 	unsigned int channel;
194*4882a593Smuzhiyun 	unsigned int lanes;
195*4882a593Smuzhiyun 	enum mipi_dsi_pixel_format format;
196*4882a593Smuzhiyun 	unsigned long mode_flags;
197*4882a593Smuzhiyun 	unsigned long hs_rate;
198*4882a593Smuzhiyun 	unsigned long lp_rate;
199*4882a593Smuzhiyun };
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun #define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
202*4882a593Smuzhiyun 
to_mipi_dsi_device(struct device * dev)203*4882a593Smuzhiyun static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev)
204*4882a593Smuzhiyun {
205*4882a593Smuzhiyun 	return container_of(dev, struct mipi_dsi_device, dev);
206*4882a593Smuzhiyun }
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun /**
209*4882a593Smuzhiyun  * mipi_dsi_pixel_format_to_bpp - obtain the number of bits per pixel for any
210*4882a593Smuzhiyun  *                                given pixel format defined by the MIPI DSI
211*4882a593Smuzhiyun  *                                specification
212*4882a593Smuzhiyun  * @fmt: MIPI DSI pixel format
213*4882a593Smuzhiyun  *
214*4882a593Smuzhiyun  * Returns: The number of bits per pixel of the given pixel format.
215*4882a593Smuzhiyun  */
mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)216*4882a593Smuzhiyun static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)
217*4882a593Smuzhiyun {
218*4882a593Smuzhiyun 	switch (fmt) {
219*4882a593Smuzhiyun 	case MIPI_DSI_FMT_RGB888:
220*4882a593Smuzhiyun 	case MIPI_DSI_FMT_RGB666:
221*4882a593Smuzhiyun 		return 24;
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun 	case MIPI_DSI_FMT_RGB666_PACKED:
224*4882a593Smuzhiyun 		return 18;
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun 	case MIPI_DSI_FMT_RGB565:
227*4882a593Smuzhiyun 		return 16;
228*4882a593Smuzhiyun 	}
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun 	return -EINVAL;
231*4882a593Smuzhiyun }
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun struct mipi_dsi_device *
234*4882a593Smuzhiyun mipi_dsi_device_register_full(struct mipi_dsi_host *host,
235*4882a593Smuzhiyun 			      const struct mipi_dsi_device_info *info);
236*4882a593Smuzhiyun void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi);
237*4882a593Smuzhiyun struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
238*4882a593Smuzhiyun int mipi_dsi_attach(struct mipi_dsi_device *dsi);
239*4882a593Smuzhiyun int mipi_dsi_detach(struct mipi_dsi_device *dsi);
240*4882a593Smuzhiyun int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi);
241*4882a593Smuzhiyun int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi);
242*4882a593Smuzhiyun int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
243*4882a593Smuzhiyun 					    u16 value);
244*4882a593Smuzhiyun ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable);
245*4882a593Smuzhiyun ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi,
246*4882a593Smuzhiyun 				       const struct drm_dsc_picture_parameter_set *pps);
247*4882a593Smuzhiyun 
248*4882a593Smuzhiyun ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
249*4882a593Smuzhiyun 			       size_t size);
250*4882a593Smuzhiyun ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
251*4882a593Smuzhiyun 			      size_t num_params, void *data, size_t size);
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun /**
254*4882a593Smuzhiyun  * enum mipi_dsi_dcs_tear_mode - Tearing Effect Output Line mode
255*4882a593Smuzhiyun  * @MIPI_DSI_DCS_TEAR_MODE_VBLANK: the TE output line consists of V-Blanking
256*4882a593Smuzhiyun  *    information only
257*4882a593Smuzhiyun  * @MIPI_DSI_DCS_TEAR_MODE_VHBLANK : the TE output line consists of both
258*4882a593Smuzhiyun  *    V-Blanking and H-Blanking information
259*4882a593Smuzhiyun  */
260*4882a593Smuzhiyun enum mipi_dsi_dcs_tear_mode {
261*4882a593Smuzhiyun 	MIPI_DSI_DCS_TEAR_MODE_VBLANK,
262*4882a593Smuzhiyun 	MIPI_DSI_DCS_TEAR_MODE_VHBLANK,
263*4882a593Smuzhiyun };
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun #define MIPI_DSI_DCS_POWER_MODE_DISPLAY (1 << 2)
266*4882a593Smuzhiyun #define MIPI_DSI_DCS_POWER_MODE_NORMAL  (1 << 3)
267*4882a593Smuzhiyun #define MIPI_DSI_DCS_POWER_MODE_SLEEP   (1 << 4)
268*4882a593Smuzhiyun #define MIPI_DSI_DCS_POWER_MODE_PARTIAL (1 << 5)
269*4882a593Smuzhiyun #define MIPI_DSI_DCS_POWER_MODE_IDLE    (1 << 6)
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
272*4882a593Smuzhiyun 				  const void *data, size_t len);
273*4882a593Smuzhiyun ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
274*4882a593Smuzhiyun 			   const void *data, size_t len);
275*4882a593Smuzhiyun ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
276*4882a593Smuzhiyun 			  size_t len);
277*4882a593Smuzhiyun int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
278*4882a593Smuzhiyun int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
279*4882a593Smuzhiyun int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
280*4882a593Smuzhiyun int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
281*4882a593Smuzhiyun int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
282*4882a593Smuzhiyun int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
283*4882a593Smuzhiyun int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi);
284*4882a593Smuzhiyun int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi);
285*4882a593Smuzhiyun int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start,
286*4882a593Smuzhiyun 				    u16 end);
287*4882a593Smuzhiyun int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
288*4882a593Smuzhiyun 				  u16 end);
289*4882a593Smuzhiyun int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
290*4882a593Smuzhiyun int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
291*4882a593Smuzhiyun 			     enum mipi_dsi_dcs_tear_mode mode);
292*4882a593Smuzhiyun int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
293*4882a593Smuzhiyun int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline);
294*4882a593Smuzhiyun int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
295*4882a593Smuzhiyun 					u16 brightness);
296*4882a593Smuzhiyun int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
297*4882a593Smuzhiyun 					u16 *brightness);
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun /**
300*4882a593Smuzhiyun  * struct mipi_dsi_driver - DSI driver
301*4882a593Smuzhiyun  * @driver: device driver model driver
302*4882a593Smuzhiyun  * @probe: callback for device binding
303*4882a593Smuzhiyun  * @remove: callback for device unbinding
304*4882a593Smuzhiyun  * @shutdown: called at shutdown time to quiesce the device
305*4882a593Smuzhiyun  */
306*4882a593Smuzhiyun struct mipi_dsi_driver {
307*4882a593Smuzhiyun 	struct device_driver driver;
308*4882a593Smuzhiyun 	int(*probe)(struct mipi_dsi_device *dsi);
309*4882a593Smuzhiyun 	int(*remove)(struct mipi_dsi_device *dsi);
310*4882a593Smuzhiyun 	void (*shutdown)(struct mipi_dsi_device *dsi);
311*4882a593Smuzhiyun };
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun static inline struct mipi_dsi_driver *
to_mipi_dsi_driver(struct device_driver * driver)314*4882a593Smuzhiyun to_mipi_dsi_driver(struct device_driver *driver)
315*4882a593Smuzhiyun {
316*4882a593Smuzhiyun 	return container_of(driver, struct mipi_dsi_driver, driver);
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun 
mipi_dsi_get_drvdata(const struct mipi_dsi_device * dsi)319*4882a593Smuzhiyun static inline void *mipi_dsi_get_drvdata(const struct mipi_dsi_device *dsi)
320*4882a593Smuzhiyun {
321*4882a593Smuzhiyun 	return dev_get_drvdata(&dsi->dev);
322*4882a593Smuzhiyun }
323*4882a593Smuzhiyun 
mipi_dsi_set_drvdata(struct mipi_dsi_device * dsi,void * data)324*4882a593Smuzhiyun static inline void mipi_dsi_set_drvdata(struct mipi_dsi_device *dsi, void *data)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun 	dev_set_drvdata(&dsi->dev, data);
327*4882a593Smuzhiyun }
328*4882a593Smuzhiyun 
329*4882a593Smuzhiyun int mipi_dsi_driver_register_full(struct mipi_dsi_driver *driver,
330*4882a593Smuzhiyun 				  struct module *owner);
331*4882a593Smuzhiyun void mipi_dsi_driver_unregister(struct mipi_dsi_driver *driver);
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun #define mipi_dsi_driver_register(driver) \
334*4882a593Smuzhiyun 	mipi_dsi_driver_register_full(driver, THIS_MODULE)
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun #define module_mipi_dsi_driver(__mipi_dsi_driver) \
337*4882a593Smuzhiyun 	module_driver(__mipi_dsi_driver, mipi_dsi_driver_register, \
338*4882a593Smuzhiyun 			mipi_dsi_driver_unregister)
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun #endif /* __DRM_MIPI_DSI__ */
341