1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3 * Copyright (C) 2019 STMicroelectronics - All Rights Reserved
4 * Author(s): Yannick Fertre <yannick.fertre@st.com> for STMicroelectronics.
5 */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <dsi_host.h>
10 #include <asm/state.h>
11 #include <asm/test.h>
12 #include <dm/test.h>
13 #include <test/test.h>
14 #include <test/ut.h>
15
dm_test_dsi_host_phy_init(void * priv_data)16 static int dm_test_dsi_host_phy_init(void *priv_data)
17 {
18 return 0;
19 }
20
dm_test_dsi_host_phy_post_set_mode(void * priv_data,unsigned long mode_flags)21 static void dm_test_dsi_host_phy_post_set_mode(void *priv_data,
22 unsigned long mode_flags)
23 {
24 }
25
dm_test_dsi_host_phy_get_lane_mbps(void * priv_data,struct display_timing * timings,u32 lanes,u32 format,unsigned int * lane_mbps)26 static int dm_test_dsi_host_phy_get_lane_mbps(void *priv_data,
27 struct display_timing *timings,
28 u32 lanes,
29 u32 format,
30 unsigned int *lane_mbps)
31 {
32 return 0;
33 }
34
35 static const struct mipi_dsi_phy_ops dm_test_dsi_host_phy_ops = {
36 .init = dm_test_dsi_host_phy_init,
37 .get_lane_mbps = dm_test_dsi_host_phy_get_lane_mbps,
38 .post_set_mode = dm_test_dsi_host_phy_post_set_mode,
39 };
40
41 /* Test that dsi_host driver functions are called */
dm_test_dsi_host(struct unit_test_state * uts)42 static int dm_test_dsi_host(struct unit_test_state *uts)
43 {
44 struct udevice *dev;
45 struct mipi_dsi_device device;
46 struct display_timing timings;
47 unsigned int max_data_lanes = 4;
48
49 ut_assertok(uclass_first_device_err(UCLASS_DSI_HOST, &dev));
50
51 ut_assertok(dsi_host_init(dev, &device, &timings, max_data_lanes,
52 &dm_test_dsi_host_phy_ops));
53
54 ut_assertok(dsi_host_enable(dev));
55
56 return 0;
57 }
58
59 DM_TEST(dm_test_dsi_host, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
60