1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
4  */
5 
6 #ifndef __RK_HDMI_H__
7 #define __RK_HDMI_H__
8 
9 struct rkhdmi_driverdata {
10 	/* configuration */
11 	u8 i2c_clk_high;
12 	u8 i2c_clk_low;
13 	const char * const *regulator_names;
14 	u32 regulator_names_cnt;
15 	/* setters/getters */
16 	int (*set_input_vop)(struct udevice *dev);
17 	int (*clk_config)(struct udevice *dev);
18 };
19 
20 struct rk_hdmi_priv {
21 	struct dw_hdmi hdmi;
22 	void *grf;
23 };
24 
25 /**
26  * rk_hdmi_read_edid() - read the attached HDMI/DVI monitor's EDID
27  *
28  * N.B.: The buffer should be large enough to hold 2 EDID blocks, as
29  *       this function calls dw_hdmi_read_edid, which ignores buf_size
30  *       argument and assumes that there's always enough space for 2
31  *       EDID blocks.
32  *
33  * @dev:	device
34  * @buf:	output buffer for the EDID
35  * @buf_size:	number of bytes in the buffer
36  * @return number of bytes read if OK, -ve if something went wrong
37  */
38 int rk_hdmi_read_edid(struct udevice *dev, u8 *buf, int buf_size);
39 
40 /**
41  * rk_hdmi_probe_regulators() - probe (autoset + enable) regulators
42  *
43  * Probes a list of regulators by performing autoset and enable
44  * operations on them.  The list of regulators is an array of string
45  * pointers and any individual regulator-probe may fail without
46  * counting as an error.
47  *
48  * @dev:	device
49  * @names:	array of string-pointers to regulator names to probe
50  * @cnt:	number of elements in the 'names' array
51  */
52 void rk_hdmi_probe_regulators(struct udevice *dev,
53 			      const char * const *names, int cnt);
54 /**
55  * rk_hdmi_ofdata_to_platdata() - common ofdata_to_platdata implementation
56  *
57  * @dev:	device
58  * @return 0 if OK, -ve if something went wrong
59  */
60 int rk_hdmi_ofdata_to_platdata(struct udevice *dev);
61 
62 /**
63  * rk_hdmi_probe() - common probe implementation
64  *
65  * Performs the following, common initialisation steps:
66  * 1. checks for HPD (i.e. a HDMI monitor being attached)
67  * 2. initialises the Designware HDMI core
68  * 3. initialises the Designware HDMI PHY
69  *
70  * @dev:	device
71  * @return 0 if OK, -ve if something went wrong
72  */
73 int rk_hdmi_probe(struct udevice *dev);
74 
75 #endif
76