1 /*
2 * MIPI DSI Bus
3 *
4 * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd.
5 * Andrzej Hajda <a.hajda@samsung.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28 #include <drm/drm_mipi_dsi.h>
29
30 #include <linux/device.h>
31 #include <linux/module.h>
32 #include <linux/of_device.h>
33 #include <linux/pm_runtime.h>
34 #include <linux/slab.h>
35
36 #include <drm/drm_dsc.h>
37 #include <drm/drm_print.h>
38 #include <video/mipi_display.h>
39
40 /**
41 * DOC: dsi helpers
42 *
43 * These functions contain some common logic and helpers to deal with MIPI DSI
44 * peripherals.
45 *
46 * Helpers are provided for a number of standard MIPI DSI command as well as a
47 * subset of the MIPI DCS command set.
48 */
49
mipi_dsi_device_match(struct device * dev,struct device_driver * drv)50 static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
51 {
52 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
53
54 /* attempt OF style match */
55 if (of_driver_match_device(dev, drv))
56 return 1;
57
58 /* compare DSI device and driver names */
59 if (!strcmp(dsi->name, drv->name))
60 return 1;
61
62 return 0;
63 }
64
mipi_dsi_uevent(struct device * dev,struct kobj_uevent_env * env)65 static int mipi_dsi_uevent(struct device *dev, struct kobj_uevent_env *env)
66 {
67 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
68 int err;
69
70 err = of_device_uevent_modalias(dev, env);
71 if (err != -ENODEV)
72 return err;
73
74 add_uevent_var(env, "MODALIAS=%s%s", MIPI_DSI_MODULE_PREFIX,
75 dsi->name);
76
77 return 0;
78 }
79
80 static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
81 .runtime_suspend = pm_generic_runtime_suspend,
82 .runtime_resume = pm_generic_runtime_resume,
83 .suspend = pm_generic_suspend,
84 .resume = pm_generic_resume,
85 .freeze = pm_generic_freeze,
86 .thaw = pm_generic_thaw,
87 .poweroff = pm_generic_poweroff,
88 .restore = pm_generic_restore,
89 };
90
91 static struct bus_type mipi_dsi_bus_type = {
92 .name = "mipi-dsi",
93 .match = mipi_dsi_device_match,
94 .uevent = mipi_dsi_uevent,
95 .pm = &mipi_dsi_device_pm_ops,
96 };
97
98 /**
99 * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
100 * device tree node
101 * @np: device tree node
102 *
103 * Return: A pointer to the MIPI DSI device corresponding to @np or NULL if no
104 * such device exists (or has not been registered yet).
105 */
of_find_mipi_dsi_device_by_node(struct device_node * np)106 struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np)
107 {
108 struct device *dev;
109
110 dev = bus_find_device_by_of_node(&mipi_dsi_bus_type, np);
111
112 return dev ? to_mipi_dsi_device(dev) : NULL;
113 }
114 EXPORT_SYMBOL(of_find_mipi_dsi_device_by_node);
115
mipi_dsi_dev_release(struct device * dev)116 static void mipi_dsi_dev_release(struct device *dev)
117 {
118 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
119
120 of_node_put(dev->of_node);
121 kfree(dsi);
122 }
123
124 static const struct device_type mipi_dsi_device_type = {
125 .release = mipi_dsi_dev_release,
126 };
127
mipi_dsi_device_alloc(struct mipi_dsi_host * host)128 static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host *host)
129 {
130 struct mipi_dsi_device *dsi;
131
132 dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
133 if (!dsi)
134 return ERR_PTR(-ENOMEM);
135
136 dsi->host = host;
137 dsi->dev.bus = &mipi_dsi_bus_type;
138 dsi->dev.parent = host->dev;
139 dsi->dev.type = &mipi_dsi_device_type;
140
141 device_initialize(&dsi->dev);
142
143 return dsi;
144 }
145
mipi_dsi_device_add(struct mipi_dsi_device * dsi)146 static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
147 {
148 struct mipi_dsi_host *host = dsi->host;
149
150 dev_set_name(&dsi->dev, "%s.%d", dev_name(host->dev), dsi->channel);
151
152 return device_add(&dsi->dev);
153 }
154
155 #if IS_ENABLED(CONFIG_OF)
156 static struct mipi_dsi_device *
of_mipi_dsi_device_add(struct mipi_dsi_host * host,struct device_node * node)157 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
158 {
159 struct mipi_dsi_device_info info = { };
160 int ret;
161 u32 reg;
162
163 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
164 drm_err(host, "modalias failure on %pOF\n", node);
165 return ERR_PTR(-EINVAL);
166 }
167
168 ret = of_property_read_u32(node, "reg", ®);
169 if (ret) {
170 drm_err(host, "device node %pOF has no valid reg property: %d\n",
171 node, ret);
172 return ERR_PTR(-EINVAL);
173 }
174
175 info.channel = reg;
176 info.node = of_node_get(node);
177
178 return mipi_dsi_device_register_full(host, &info);
179 }
180 #else
181 static struct mipi_dsi_device *
of_mipi_dsi_device_add(struct mipi_dsi_host * host,struct device_node * node)182 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
183 {
184 return ERR_PTR(-ENODEV);
185 }
186 #endif
187
188 /**
189 * mipi_dsi_device_register_full - create a MIPI DSI device
190 * @host: DSI host to which this device is connected
191 * @info: pointer to template containing DSI device information
192 *
193 * Create a MIPI DSI device by using the device information provided by
194 * mipi_dsi_device_info template
195 *
196 * Returns:
197 * A pointer to the newly created MIPI DSI device, or, a pointer encoded
198 * with an error
199 */
200 struct mipi_dsi_device *
mipi_dsi_device_register_full(struct mipi_dsi_host * host,const struct mipi_dsi_device_info * info)201 mipi_dsi_device_register_full(struct mipi_dsi_host *host,
202 const struct mipi_dsi_device_info *info)
203 {
204 struct mipi_dsi_device *dsi;
205 int ret;
206
207 if (!info) {
208 drm_err(host, "invalid mipi_dsi_device_info pointer\n");
209 return ERR_PTR(-EINVAL);
210 }
211
212 if (info->channel > 3) {
213 drm_err(host, "invalid virtual channel: %u\n", info->channel);
214 return ERR_PTR(-EINVAL);
215 }
216
217 dsi = mipi_dsi_device_alloc(host);
218 if (IS_ERR(dsi)) {
219 drm_err(host, "failed to allocate DSI device %ld\n",
220 PTR_ERR(dsi));
221 return dsi;
222 }
223
224 device_set_node(&dsi->dev, of_fwnode_handle(info->node));
225 dsi->channel = info->channel;
226 strlcpy(dsi->name, info->type, sizeof(dsi->name));
227
228 ret = mipi_dsi_device_add(dsi);
229 if (ret) {
230 drm_err(host, "failed to add DSI device %d\n", ret);
231 kfree(dsi);
232 return ERR_PTR(ret);
233 }
234
235 return dsi;
236 }
237 EXPORT_SYMBOL(mipi_dsi_device_register_full);
238
239 /**
240 * mipi_dsi_device_unregister - unregister MIPI DSI device
241 * @dsi: DSI peripheral device
242 */
mipi_dsi_device_unregister(struct mipi_dsi_device * dsi)243 void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi)
244 {
245 device_unregister(&dsi->dev);
246 }
247 EXPORT_SYMBOL(mipi_dsi_device_unregister);
248
249 static DEFINE_MUTEX(host_lock);
250 static LIST_HEAD(host_list);
251
252 /**
253 * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a
254 * device tree node
255 * @node: device tree node
256 *
257 * Returns:
258 * A pointer to the MIPI DSI host corresponding to @node or NULL if no
259 * such device exists (or has not been registered yet).
260 */
of_find_mipi_dsi_host_by_node(struct device_node * node)261 struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
262 {
263 struct mipi_dsi_host *host;
264
265 mutex_lock(&host_lock);
266
267 list_for_each_entry(host, &host_list, list) {
268 if (host->dev->of_node == node) {
269 mutex_unlock(&host_lock);
270 return host;
271 }
272 }
273
274 mutex_unlock(&host_lock);
275
276 return NULL;
277 }
278 EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
279
mipi_dsi_host_register(struct mipi_dsi_host * host)280 int mipi_dsi_host_register(struct mipi_dsi_host *host)
281 {
282 struct device_node *node;
283
284 for_each_available_child_of_node(host->dev->of_node, node) {
285 /* skip nodes without reg property */
286 if (!of_find_property(node, "reg", NULL))
287 continue;
288 of_mipi_dsi_device_add(host, node);
289 }
290
291 mutex_lock(&host_lock);
292 list_add_tail(&host->list, &host_list);
293 mutex_unlock(&host_lock);
294
295 return 0;
296 }
297 EXPORT_SYMBOL(mipi_dsi_host_register);
298
mipi_dsi_remove_device_fn(struct device * dev,void * priv)299 static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
300 {
301 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
302
303 mipi_dsi_detach(dsi);
304 mipi_dsi_device_unregister(dsi);
305
306 return 0;
307 }
308
mipi_dsi_host_unregister(struct mipi_dsi_host * host)309 void mipi_dsi_host_unregister(struct mipi_dsi_host *host)
310 {
311 device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn);
312
313 mutex_lock(&host_lock);
314 list_del_init(&host->list);
315 mutex_unlock(&host_lock);
316 }
317 EXPORT_SYMBOL(mipi_dsi_host_unregister);
318
319 /**
320 * mipi_dsi_attach - attach a DSI device to its DSI host
321 * @dsi: DSI peripheral
322 */
mipi_dsi_attach(struct mipi_dsi_device * dsi)323 int mipi_dsi_attach(struct mipi_dsi_device *dsi)
324 {
325 const struct mipi_dsi_host_ops *ops = dsi->host->ops;
326
327 if (!ops || !ops->attach)
328 return -ENOSYS;
329
330 return ops->attach(dsi->host, dsi);
331 }
332 EXPORT_SYMBOL(mipi_dsi_attach);
333
334 /**
335 * mipi_dsi_detach - detach a DSI device from its DSI host
336 * @dsi: DSI peripheral
337 */
mipi_dsi_detach(struct mipi_dsi_device * dsi)338 int mipi_dsi_detach(struct mipi_dsi_device *dsi)
339 {
340 const struct mipi_dsi_host_ops *ops = dsi->host->ops;
341
342 if (!ops || !ops->detach)
343 return -ENOSYS;
344
345 return ops->detach(dsi->host, dsi);
346 }
347 EXPORT_SYMBOL(mipi_dsi_detach);
348
mipi_dsi_device_transfer(struct mipi_dsi_device * dsi,struct mipi_dsi_msg * msg)349 static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi,
350 struct mipi_dsi_msg *msg)
351 {
352 const struct mipi_dsi_host_ops *ops = dsi->host->ops;
353
354 if (!ops || !ops->transfer)
355 return -ENOSYS;
356
357 if (dsi->mode_flags & MIPI_DSI_MODE_LPM)
358 msg->flags |= MIPI_DSI_MSG_USE_LPM;
359 msg->flags |= MIPI_DSI_MSG_LASTCOMMAND;
360
361 return ops->transfer(dsi->host, msg);
362 }
363
364 /**
365 * mipi_dsi_packet_format_is_short - check if a packet is of the short format
366 * @type: MIPI DSI data type of the packet
367 *
368 * Return: true if the packet for the given data type is a short packet, false
369 * otherwise.
370 */
mipi_dsi_packet_format_is_short(u8 type)371 bool mipi_dsi_packet_format_is_short(u8 type)
372 {
373 switch (type) {
374 case MIPI_DSI_V_SYNC_START:
375 case MIPI_DSI_V_SYNC_END:
376 case MIPI_DSI_H_SYNC_START:
377 case MIPI_DSI_H_SYNC_END:
378 case MIPI_DSI_COMPRESSION_MODE:
379 case MIPI_DSI_END_OF_TRANSMISSION:
380 case MIPI_DSI_COLOR_MODE_OFF:
381 case MIPI_DSI_COLOR_MODE_ON:
382 case MIPI_DSI_SHUTDOWN_PERIPHERAL:
383 case MIPI_DSI_TURN_ON_PERIPHERAL:
384 case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
385 case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
386 case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
387 case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
388 case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
389 case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
390 case MIPI_DSI_DCS_SHORT_WRITE:
391 case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
392 case MIPI_DSI_DCS_READ:
393 case MIPI_DSI_EXECUTE_QUEUE:
394 case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
395 return true;
396 }
397
398 return false;
399 }
400 EXPORT_SYMBOL(mipi_dsi_packet_format_is_short);
401
402 /**
403 * mipi_dsi_packet_format_is_long - check if a packet is of the long format
404 * @type: MIPI DSI data type of the packet
405 *
406 * Return: true if the packet for the given data type is a long packet, false
407 * otherwise.
408 */
mipi_dsi_packet_format_is_long(u8 type)409 bool mipi_dsi_packet_format_is_long(u8 type)
410 {
411 switch (type) {
412 case MIPI_DSI_NULL_PACKET:
413 case MIPI_DSI_BLANKING_PACKET:
414 case MIPI_DSI_GENERIC_LONG_WRITE:
415 case MIPI_DSI_DCS_LONG_WRITE:
416 case MIPI_DSI_PICTURE_PARAMETER_SET:
417 case MIPI_DSI_COMPRESSED_PIXEL_STREAM:
418 case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20:
419 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24:
420 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16:
421 case MIPI_DSI_PACKED_PIXEL_STREAM_30:
422 case MIPI_DSI_PACKED_PIXEL_STREAM_36:
423 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12:
424 case MIPI_DSI_PACKED_PIXEL_STREAM_16:
425 case MIPI_DSI_PACKED_PIXEL_STREAM_18:
426 case MIPI_DSI_PIXEL_STREAM_3BYTE_18:
427 case MIPI_DSI_PACKED_PIXEL_STREAM_24:
428 return true;
429 }
430
431 return false;
432 }
433 EXPORT_SYMBOL(mipi_dsi_packet_format_is_long);
434
435 /**
436 * mipi_dsi_create_packet - create a packet from a message according to the
437 * DSI protocol
438 * @packet: pointer to a DSI packet structure
439 * @msg: message to translate into a packet
440 *
441 * Return: 0 on success or a negative error code on failure.
442 */
mipi_dsi_create_packet(struct mipi_dsi_packet * packet,const struct mipi_dsi_msg * msg)443 int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
444 const struct mipi_dsi_msg *msg)
445 {
446 if (!packet || !msg)
447 return -EINVAL;
448
449 /* do some minimum sanity checking */
450 if (!mipi_dsi_packet_format_is_short(msg->type) &&
451 !mipi_dsi_packet_format_is_long(msg->type))
452 return -EINVAL;
453
454 if (msg->channel > 3)
455 return -EINVAL;
456
457 memset(packet, 0, sizeof(*packet));
458 packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f);
459
460 /* TODO: compute ECC if hardware support is not available */
461
462 /*
463 * Long write packets contain the word count in header bytes 1 and 2.
464 * The payload follows the header and is word count bytes long.
465 *
466 * Short write packets encode up to two parameters in header bytes 1
467 * and 2.
468 */
469 if (mipi_dsi_packet_format_is_long(msg->type)) {
470 packet->header[1] = (msg->tx_len >> 0) & 0xff;
471 packet->header[2] = (msg->tx_len >> 8) & 0xff;
472
473 packet->payload_length = msg->tx_len;
474 packet->payload = msg->tx_buf;
475 } else {
476 const u8 *tx = msg->tx_buf;
477
478 packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0;
479 packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0;
480 }
481
482 packet->size = sizeof(packet->header) + packet->payload_length;
483
484 return 0;
485 }
486 EXPORT_SYMBOL(mipi_dsi_create_packet);
487
488 /**
489 * mipi_dsi_shutdown_peripheral() - sends a Shutdown Peripheral command
490 * @dsi: DSI peripheral device
491 *
492 * Return: 0 on success or a negative error code on failure.
493 */
mipi_dsi_shutdown_peripheral(struct mipi_dsi_device * dsi)494 int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi)
495 {
496 struct mipi_dsi_msg msg = {
497 .channel = dsi->channel,
498 .type = MIPI_DSI_SHUTDOWN_PERIPHERAL,
499 .tx_buf = (u8 [2]) { 0, 0 },
500 .tx_len = 2,
501 };
502 int ret = mipi_dsi_device_transfer(dsi, &msg);
503
504 return (ret < 0) ? ret : 0;
505 }
506 EXPORT_SYMBOL(mipi_dsi_shutdown_peripheral);
507
508 /**
509 * mipi_dsi_turn_on_peripheral() - sends a Turn On Peripheral command
510 * @dsi: DSI peripheral device
511 *
512 * Return: 0 on success or a negative error code on failure.
513 */
mipi_dsi_turn_on_peripheral(struct mipi_dsi_device * dsi)514 int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi)
515 {
516 struct mipi_dsi_msg msg = {
517 .channel = dsi->channel,
518 .type = MIPI_DSI_TURN_ON_PERIPHERAL,
519 .tx_buf = (u8 [2]) { 0, 0 },
520 .tx_len = 2,
521 };
522 int ret = mipi_dsi_device_transfer(dsi, &msg);
523
524 return (ret < 0) ? ret : 0;
525 }
526 EXPORT_SYMBOL(mipi_dsi_turn_on_peripheral);
527
528 /*
529 * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the
530 * the payload in a long packet transmitted from the peripheral back to the
531 * host processor
532 * @dsi: DSI peripheral device
533 * @value: the maximum size of the payload
534 *
535 * Return: 0 on success or a negative error code on failure.
536 */
mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device * dsi,u16 value)537 int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
538 u16 value)
539 {
540 u8 tx[2] = { value & 0xff, value >> 8 };
541 struct mipi_dsi_msg msg = {
542 .channel = dsi->channel,
543 .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
544 .tx_len = sizeof(tx),
545 .tx_buf = tx,
546 };
547 int ret = mipi_dsi_device_transfer(dsi, &msg);
548
549 return (ret < 0) ? ret : 0;
550 }
551 EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size);
552
553 /**
554 * mipi_dsi_compression_mode() - enable/disable DSC on the peripheral
555 * @dsi: DSI peripheral device
556 * @enable: Whether to enable or disable the DSC
557 *
558 * Enable or disable Display Stream Compression on the peripheral using the
559 * default Picture Parameter Set and VESA DSC 1.1 algorithm.
560 *
561 * Return: 0 on success or a negative error code on failure.
562 */
mipi_dsi_compression_mode(struct mipi_dsi_device * dsi,bool enable)563 ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable)
564 {
565 /* Note: Needs updating for non-default PPS or algorithm */
566 u8 tx[2] = { enable << 0, 0 };
567 struct mipi_dsi_msg msg = {
568 .channel = dsi->channel,
569 .type = MIPI_DSI_COMPRESSION_MODE,
570 .tx_len = sizeof(tx),
571 .tx_buf = tx,
572 };
573 int ret = mipi_dsi_device_transfer(dsi, &msg);
574
575 return (ret < 0) ? ret : 0;
576 }
577 EXPORT_SYMBOL(mipi_dsi_compression_mode);
578
579 /**
580 * mipi_dsi_picture_parameter_set() - transmit the DSC PPS to the peripheral
581 * @dsi: DSI peripheral device
582 * @pps: VESA DSC 1.1 Picture Parameter Set
583 *
584 * Transmit the VESA DSC 1.1 Picture Parameter Set to the peripheral.
585 *
586 * Return: 0 on success or a negative error code on failure.
587 */
mipi_dsi_picture_parameter_set(struct mipi_dsi_device * dsi,const struct drm_dsc_picture_parameter_set * pps)588 ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi,
589 const struct drm_dsc_picture_parameter_set *pps)
590 {
591 struct mipi_dsi_msg msg = {
592 .channel = dsi->channel,
593 .type = MIPI_DSI_PICTURE_PARAMETER_SET,
594 .tx_len = sizeof(*pps),
595 .tx_buf = pps,
596 };
597 int ret = mipi_dsi_device_transfer(dsi, &msg);
598
599 return (ret < 0) ? ret : 0;
600 }
601 EXPORT_SYMBOL(mipi_dsi_picture_parameter_set);
602
603 /**
604 * mipi_dsi_generic_write() - transmit data using a generic write packet
605 * @dsi: DSI peripheral device
606 * @payload: buffer containing the payload
607 * @size: size of payload buffer
608 *
609 * This function will automatically choose the right data type depending on
610 * the payload length.
611 *
612 * Return: The number of bytes transmitted on success or a negative error code
613 * on failure.
614 */
mipi_dsi_generic_write(struct mipi_dsi_device * dsi,const void * payload,size_t size)615 ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
616 size_t size)
617 {
618 struct mipi_dsi_msg msg = {
619 .channel = dsi->channel,
620 .tx_buf = payload,
621 .tx_len = size
622 };
623
624 switch (size) {
625 case 0:
626 msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
627 break;
628
629 case 1:
630 msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
631 break;
632
633 case 2:
634 msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
635 break;
636
637 default:
638 msg.type = MIPI_DSI_GENERIC_LONG_WRITE;
639 break;
640 }
641
642 return mipi_dsi_device_transfer(dsi, &msg);
643 }
644 EXPORT_SYMBOL(mipi_dsi_generic_write);
645
646 /**
647 * mipi_dsi_generic_read() - receive data using a generic read packet
648 * @dsi: DSI peripheral device
649 * @params: buffer containing the request parameters
650 * @num_params: number of request parameters
651 * @data: buffer in which to return the received data
652 * @size: size of receive buffer
653 *
654 * This function will automatically choose the right data type depending on
655 * the number of parameters passed in.
656 *
657 * Return: The number of bytes successfully read or a negative error code on
658 * failure.
659 */
mipi_dsi_generic_read(struct mipi_dsi_device * dsi,const void * params,size_t num_params,void * data,size_t size)660 ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
661 size_t num_params, void *data, size_t size)
662 {
663 struct mipi_dsi_msg msg = {
664 .channel = dsi->channel,
665 .tx_len = num_params,
666 .tx_buf = params,
667 .rx_len = size,
668 .rx_buf = data
669 };
670
671 switch (num_params) {
672 case 0:
673 msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
674 break;
675
676 case 1:
677 msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
678 break;
679
680 case 2:
681 msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
682 break;
683
684 default:
685 return -EINVAL;
686 }
687
688 return mipi_dsi_device_transfer(dsi, &msg);
689 }
690 EXPORT_SYMBOL(mipi_dsi_generic_read);
691
692 /**
693 * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload
694 * @dsi: DSI peripheral device
695 * @data: buffer containing data to be transmitted
696 * @len: size of transmission buffer
697 *
698 * This function will automatically choose the right data type depending on
699 * the command payload length.
700 *
701 * Return: The number of bytes successfully transmitted or a negative error
702 * code on failure.
703 */
mipi_dsi_dcs_write_buffer(struct mipi_dsi_device * dsi,const void * data,size_t len)704 ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
705 const void *data, size_t len)
706 {
707 struct mipi_dsi_msg msg = {
708 .channel = dsi->channel,
709 .tx_buf = data,
710 .tx_len = len
711 };
712
713 switch (len) {
714 case 0:
715 return -EINVAL;
716
717 case 1:
718 msg.type = MIPI_DSI_DCS_SHORT_WRITE;
719 break;
720
721 case 2:
722 msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
723 break;
724
725 default:
726 msg.type = MIPI_DSI_DCS_LONG_WRITE;
727 break;
728 }
729
730 return mipi_dsi_device_transfer(dsi, &msg);
731 }
732 EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer);
733
734 /**
735 * mipi_dsi_dcs_write() - send DCS write command
736 * @dsi: DSI peripheral device
737 * @cmd: DCS command
738 * @data: buffer containing the command payload
739 * @len: command payload length
740 *
741 * This function will automatically choose the right data type depending on
742 * the command payload length.
743 *
744 * Return: The number of bytes successfully transmitted or a negative error
745 * code on failure.
746 */
mipi_dsi_dcs_write(struct mipi_dsi_device * dsi,u8 cmd,const void * data,size_t len)747 ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
748 const void *data, size_t len)
749 {
750 ssize_t err;
751 size_t size;
752 u8 stack_tx[8];
753 u8 *tx;
754
755 size = 1 + len;
756 if (len > ARRAY_SIZE(stack_tx) - 1) {
757 tx = kmalloc(size, GFP_KERNEL);
758 if (!tx)
759 return -ENOMEM;
760 } else {
761 tx = stack_tx;
762 }
763
764 /* concatenate the DCS command byte and the payload */
765 tx[0] = cmd;
766 if (data)
767 memcpy(&tx[1], data, len);
768
769 err = mipi_dsi_dcs_write_buffer(dsi, tx, size);
770
771 if (tx != stack_tx)
772 kfree(tx);
773
774 return err;
775 }
776 EXPORT_SYMBOL(mipi_dsi_dcs_write);
777
778 /**
779 * mipi_dsi_dcs_read() - send DCS read request command
780 * @dsi: DSI peripheral device
781 * @cmd: DCS command
782 * @data: buffer in which to receive data
783 * @len: size of receive buffer
784 *
785 * Return: The number of bytes read or a negative error code on failure.
786 */
mipi_dsi_dcs_read(struct mipi_dsi_device * dsi,u8 cmd,void * data,size_t len)787 ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
788 size_t len)
789 {
790 struct mipi_dsi_msg msg = {
791 .channel = dsi->channel,
792 .type = MIPI_DSI_DCS_READ,
793 .tx_buf = &cmd,
794 .tx_len = 1,
795 .rx_buf = data,
796 .rx_len = len
797 };
798
799 return mipi_dsi_device_transfer(dsi, &msg);
800 }
801 EXPORT_SYMBOL(mipi_dsi_dcs_read);
802
803 /**
804 * mipi_dsi_dcs_nop() - send DCS nop packet
805 * @dsi: DSI peripheral device
806 *
807 * Return: 0 on success or a negative error code on failure.
808 */
mipi_dsi_dcs_nop(struct mipi_dsi_device * dsi)809 int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi)
810 {
811 ssize_t err;
812
813 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0);
814 if (err < 0)
815 return err;
816
817 return 0;
818 }
819 EXPORT_SYMBOL(mipi_dsi_dcs_nop);
820
821 /**
822 * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module
823 * @dsi: DSI peripheral device
824 *
825 * Return: 0 on success or a negative error code on failure.
826 */
mipi_dsi_dcs_soft_reset(struct mipi_dsi_device * dsi)827 int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi)
828 {
829 ssize_t err;
830
831 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0);
832 if (err < 0)
833 return err;
834
835 return 0;
836 }
837 EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset);
838
839 /**
840 * mipi_dsi_dcs_get_power_mode() - query the display module's current power
841 * mode
842 * @dsi: DSI peripheral device
843 * @mode: return location for the current power mode
844 *
845 * Return: 0 on success or a negative error code on failure.
846 */
mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device * dsi,u8 * mode)847 int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode)
848 {
849 ssize_t err;
850
851 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode,
852 sizeof(*mode));
853 if (err <= 0) {
854 if (err == 0)
855 err = -ENODATA;
856
857 return err;
858 }
859
860 return 0;
861 }
862 EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);
863
864 /**
865 * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
866 * data used by the interface
867 * @dsi: DSI peripheral device
868 * @format: return location for the pixel format
869 *
870 * Return: 0 on success or a negative error code on failure.
871 */
mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device * dsi,u8 * format)872 int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format)
873 {
874 ssize_t err;
875
876 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format,
877 sizeof(*format));
878 if (err <= 0) {
879 if (err == 0)
880 err = -ENODATA;
881
882 return err;
883 }
884
885 return 0;
886 }
887 EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format);
888
889 /**
890 * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the
891 * display module except interface communication
892 * @dsi: DSI peripheral device
893 *
894 * Return: 0 on success or a negative error code on failure.
895 */
mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device * dsi)896 int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi)
897 {
898 ssize_t err;
899
900 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0);
901 if (err < 0)
902 return err;
903
904 return 0;
905 }
906 EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode);
907
908 /**
909 * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display
910 * module
911 * @dsi: DSI peripheral device
912 *
913 * Return: 0 on success or a negative error code on failure.
914 */
mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device * dsi)915 int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi)
916 {
917 ssize_t err;
918
919 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
920 if (err < 0)
921 return err;
922
923 return 0;
924 }
925 EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode);
926
927 /**
928 * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the
929 * display device
930 * @dsi: DSI peripheral device
931 *
932 * Return: 0 on success or a negative error code on failure.
933 */
mipi_dsi_dcs_set_display_off(struct mipi_dsi_device * dsi)934 int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi)
935 {
936 ssize_t err;
937
938 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0);
939 if (err < 0)
940 return err;
941
942 return 0;
943 }
944 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off);
945
946 /**
947 * mipi_dsi_dcs_set_display_on() - start displaying the image data on the
948 * display device
949 * @dsi: DSI peripheral device
950 *
951 * Return: 0 on success or a negative error code on failure
952 */
mipi_dsi_dcs_set_display_on(struct mipi_dsi_device * dsi)953 int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi)
954 {
955 ssize_t err;
956
957 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0);
958 if (err < 0)
959 return err;
960
961 return 0;
962 }
963 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on);
964
965 /**
966 * mipi_dsi_dcs_set_column_address() - define the column extent of the frame
967 * memory accessed by the host processor
968 * @dsi: DSI peripheral device
969 * @start: first column of frame memory
970 * @end: last column of frame memory
971 *
972 * Return: 0 on success or a negative error code on failure.
973 */
mipi_dsi_dcs_set_column_address(struct mipi_dsi_device * dsi,u16 start,u16 end)974 int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start,
975 u16 end)
976 {
977 u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff };
978 ssize_t err;
979
980 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload,
981 sizeof(payload));
982 if (err < 0)
983 return err;
984
985 return 0;
986 }
987 EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address);
988
989 /**
990 * mipi_dsi_dcs_set_page_address() - define the page extent of the frame
991 * memory accessed by the host processor
992 * @dsi: DSI peripheral device
993 * @start: first page of frame memory
994 * @end: last page of frame memory
995 *
996 * Return: 0 on success or a negative error code on failure.
997 */
mipi_dsi_dcs_set_page_address(struct mipi_dsi_device * dsi,u16 start,u16 end)998 int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
999 u16 end)
1000 {
1001 u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff };
1002 ssize_t err;
1003
1004 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload,
1005 sizeof(payload));
1006 if (err < 0)
1007 return err;
1008
1009 return 0;
1010 }
1011 EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address);
1012
1013 /**
1014 * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect
1015 * output signal on the TE signal line
1016 * @dsi: DSI peripheral device
1017 *
1018 * Return: 0 on success or a negative error code on failure
1019 */
mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device * dsi)1020 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi)
1021 {
1022 ssize_t err;
1023
1024 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0);
1025 if (err < 0)
1026 return err;
1027
1028 return 0;
1029 }
1030 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off);
1031
1032 /**
1033 * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect
1034 * output signal on the TE signal line.
1035 * @dsi: DSI peripheral device
1036 * @mode: the Tearing Effect Output Line mode
1037 *
1038 * Return: 0 on success or a negative error code on failure
1039 */
mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device * dsi,enum mipi_dsi_dcs_tear_mode mode)1040 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
1041 enum mipi_dsi_dcs_tear_mode mode)
1042 {
1043 u8 value = mode;
1044 ssize_t err;
1045
1046 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value,
1047 sizeof(value));
1048 if (err < 0)
1049 return err;
1050
1051 return 0;
1052 }
1053 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);
1054
1055 /**
1056 * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
1057 * data used by the interface
1058 * @dsi: DSI peripheral device
1059 * @format: pixel format
1060 *
1061 * Return: 0 on success or a negative error code on failure.
1062 */
mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device * dsi,u8 format)1063 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format)
1064 {
1065 ssize_t err;
1066
1067 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format,
1068 sizeof(format));
1069 if (err < 0)
1070 return err;
1071
1072 return 0;
1073 }
1074 EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
1075
1076 /**
1077 * mipi_dsi_dcs_set_tear_scanline() - set the scanline to use as trigger for
1078 * the Tearing Effect output signal of the display module
1079 * @dsi: DSI peripheral device
1080 * @scanline: scanline to use as trigger
1081 *
1082 * Return: 0 on success or a negative error code on failure
1083 */
mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device * dsi,u16 scanline)1084 int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline)
1085 {
1086 u8 payload[2] = { scanline >> 8, scanline & 0xff };
1087 ssize_t err;
1088
1089 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_SCANLINE, payload,
1090 sizeof(payload));
1091 if (err < 0)
1092 return err;
1093
1094 return 0;
1095 }
1096 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);
1097
1098 /**
1099 * mipi_dsi_dcs_set_display_brightness() - sets the brightness value of the
1100 * display
1101 * @dsi: DSI peripheral device
1102 * @brightness: brightness value
1103 *
1104 * Return: 0 on success or a negative error code on failure.
1105 */
mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device * dsi,u16 brightness)1106 int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
1107 u16 brightness)
1108 {
1109 u8 payload[2] = { brightness & 0xff, brightness >> 8 };
1110 ssize_t err;
1111
1112 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
1113 payload, sizeof(payload));
1114 if (err < 0)
1115 return err;
1116
1117 return 0;
1118 }
1119 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);
1120
1121 /**
1122 * mipi_dsi_dcs_get_display_brightness() - gets the current brightness value
1123 * of the display
1124 * @dsi: DSI peripheral device
1125 * @brightness: brightness value
1126 *
1127 * Return: 0 on success or a negative error code on failure.
1128 */
mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device * dsi,u16 * brightness)1129 int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
1130 u16 *brightness)
1131 {
1132 ssize_t err;
1133
1134 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
1135 brightness, sizeof(*brightness));
1136 if (err <= 0) {
1137 if (err == 0)
1138 err = -ENODATA;
1139
1140 return err;
1141 }
1142
1143 return 0;
1144 }
1145 EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness);
1146
1147 /**
1148 * mipi_dsi_dcs_set_display_brightness_large() - sets the 16-bit brightness value
1149 * of the display
1150 * @dsi: DSI peripheral device
1151 * @brightness: brightness value
1152 *
1153 * Return: 0 on success or a negative error code on failure.
1154 */
mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device * dsi,u16 brightness)1155 int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi,
1156 u16 brightness)
1157 {
1158 u8 payload[2] = { brightness >> 8, brightness & 0xff };
1159 ssize_t err;
1160
1161 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
1162 payload, sizeof(payload));
1163 if (err < 0)
1164 return err;
1165
1166 return 0;
1167 }
1168 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness_large);
1169
1170 /**
1171 * mipi_dsi_dcs_get_display_brightness_large() - gets the current 16-bit
1172 * brightness value of the display
1173 * @dsi: DSI peripheral device
1174 * @brightness: brightness value
1175 *
1176 * Return: 0 on success or a negative error code on failure.
1177 */
mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device * dsi,u16 * brightness)1178 int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi,
1179 u16 *brightness)
1180 {
1181 u8 brightness_be[2];
1182 ssize_t err;
1183
1184 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
1185 brightness_be, sizeof(brightness_be));
1186 if (err <= 0) {
1187 if (err == 0)
1188 err = -ENODATA;
1189
1190 return err;
1191 }
1192
1193 *brightness = (brightness_be[0] << 8) | brightness_be[1];
1194
1195 return 0;
1196 }
1197 EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness_large);
1198
mipi_dsi_drv_probe(struct device * dev)1199 static int mipi_dsi_drv_probe(struct device *dev)
1200 {
1201 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
1202 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
1203
1204 return drv->probe(dsi);
1205 }
1206
mipi_dsi_drv_remove(struct device * dev)1207 static int mipi_dsi_drv_remove(struct device *dev)
1208 {
1209 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
1210 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
1211
1212 return drv->remove(dsi);
1213 }
1214
mipi_dsi_drv_shutdown(struct device * dev)1215 static void mipi_dsi_drv_shutdown(struct device *dev)
1216 {
1217 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
1218 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
1219
1220 drv->shutdown(dsi);
1221 }
1222
1223 /**
1224 * mipi_dsi_driver_register_full() - register a driver for DSI devices
1225 * @drv: DSI driver structure
1226 * @owner: owner module
1227 *
1228 * Return: 0 on success or a negative error code on failure.
1229 */
mipi_dsi_driver_register_full(struct mipi_dsi_driver * drv,struct module * owner)1230 int mipi_dsi_driver_register_full(struct mipi_dsi_driver *drv,
1231 struct module *owner)
1232 {
1233 drv->driver.bus = &mipi_dsi_bus_type;
1234 drv->driver.owner = owner;
1235
1236 if (drv->probe)
1237 drv->driver.probe = mipi_dsi_drv_probe;
1238 if (drv->remove)
1239 drv->driver.remove = mipi_dsi_drv_remove;
1240 if (drv->shutdown)
1241 drv->driver.shutdown = mipi_dsi_drv_shutdown;
1242
1243 return driver_register(&drv->driver);
1244 }
1245 EXPORT_SYMBOL(mipi_dsi_driver_register_full);
1246
1247 /**
1248 * mipi_dsi_driver_unregister() - unregister a driver for DSI devices
1249 * @drv: DSI driver structure
1250 *
1251 * Return: 0 on success or a negative error code on failure.
1252 */
mipi_dsi_driver_unregister(struct mipi_dsi_driver * drv)1253 void mipi_dsi_driver_unregister(struct mipi_dsi_driver *drv)
1254 {
1255 driver_unregister(&drv->driver);
1256 }
1257 EXPORT_SYMBOL(mipi_dsi_driver_unregister);
1258
mipi_dsi_bus_init(void)1259 static int __init mipi_dsi_bus_init(void)
1260 {
1261 return bus_register(&mipi_dsi_bus_type);
1262 }
1263 postcore_initcall(mipi_dsi_bus_init);
1264
1265 MODULE_AUTHOR("Andrzej Hajda <a.hajda@samsung.com>");
1266 MODULE_DESCRIPTION("MIPI DSI Bus");
1267 MODULE_LICENSE("GPL and additional rights");
1268