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