]> Git Repo - J-u-boot.git/blob - drivers/video/sandbox_dsi_host.c
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh
[J-u-boot.git] / drivers / video / sandbox_dsi_host.c
1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
4  */
5
6 #include <display.h>
7 #include <dm.h>
8 #include <dsi_host.h>
9
10 /**
11  * struct sandbox_dsi_host_priv - private data for driver
12  * @device: DSI peripheral device
13  * @timing: Display timings
14  * @max_data_lanes: maximum number of data lines
15  * @phy_ops: set of function pointers for performing physical operations
16  */
17 struct sandbox_dsi_host_priv {
18         struct mipi_dsi_device *device;
19         struct display_timing *timings;
20         unsigned int max_data_lanes;
21         const struct mipi_dsi_phy_ops *phy_ops;
22 };
23
24 static int sandbox_dsi_host_init(struct udevice *dev,
25                                  struct mipi_dsi_device *device,
26                                  struct display_timing *timings,
27                                  unsigned int max_data_lanes,
28                                  const struct mipi_dsi_phy_ops *phy_ops)
29 {
30         struct sandbox_dsi_host_priv *priv = dev_get_priv(dev);
31
32         if (!device)
33                 return -1;
34
35         if (!timings)
36                 return -2;
37
38         if (max_data_lanes == 0)
39                 return -3;
40
41         if (!phy_ops)
42                 return -4;
43
44         if (!phy_ops->init || !phy_ops->get_lane_mbps ||
45             !phy_ops->post_set_mode)
46                 return -5;
47
48         priv->max_data_lanes = max_data_lanes;
49         priv->phy_ops = phy_ops;
50         priv->timings = timings;
51         priv->device = device;
52
53         return 0;
54 }
55
56 static int sandbox_dsi_host_enable(struct udevice *dev)
57 {
58         struct sandbox_dsi_host_priv *priv = dev_get_priv(dev);
59         unsigned int lane_mbps;
60         int ret;
61
62         priv->phy_ops->init(priv->device);
63         ret = priv->phy_ops->get_lane_mbps(priv->device, priv->timings, 2,
64                                            MIPI_DSI_FMT_RGB888, &lane_mbps);
65         if (ret)
66                 return -1;
67
68         priv->phy_ops->post_set_mode(priv->device, MIPI_DSI_MODE_VIDEO);
69
70         return 0;
71 }
72
73 struct dsi_host_ops sandbox_dsi_host_ops = {
74         .init = sandbox_dsi_host_init,
75         .enable = sandbox_dsi_host_enable,
76 };
77
78 static const struct udevice_id sandbox_dsi_host_ids[] = {
79         { .compatible = "sandbox,dsi-host"},
80         { }
81 };
82
83 U_BOOT_DRIVER(sandbox_dsi_host) = {
84         .name                 = "sandbox-dsi-host",
85         .id                   = UCLASS_DSI_HOST,
86         .of_match             = sandbox_dsi_host_ids,
87         .ops                  = &sandbox_dsi_host_ops,
88         .priv_auto      = sizeof(struct sandbox_dsi_host_priv),
89 };
This page took 0.044008 seconds and 4 git commands to generate.