1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __CIO2_BRIDGE_H
4 #define __CIO2_BRIDGE_H
6 #include <linux/property.h>
7 #include <linux/types.h>
13 #define CIO2_HID "INT343E"
14 #define CIO2_MAX_LANES 4
15 #define MAX_NUM_LINK_FREQS 3
17 /* Values are educated guesses as we don't have a spec */
18 #define CIO2_SENSOR_ROTATION_NORMAL 0
19 #define CIO2_SENSOR_ROTATION_INVERTED 1
21 #define CIO2_SENSOR_CONFIG(_HID, _NR, ...) \
22 (const struct cio2_sensor_config) { \
24 .nr_link_freqs = _NR, \
25 .link_freqs = { __VA_ARGS__ } \
28 #define NODE_SENSOR(_HID, _PROPS) \
29 (const struct software_node) { \
31 .properties = _PROPS, \
34 #define NODE_PORT(_PORT, _SENSOR_NODE) \
35 (const struct software_node) { \
37 .parent = _SENSOR_NODE, \
40 #define NODE_ENDPOINT(_EP, _PORT, _PROPS) \
41 (const struct software_node) { \
44 .properties = _PROPS, \
47 #define NODE_VCM(_TYPE) \
48 (const struct software_node) { \
52 enum cio2_sensor_swnodes {
55 SWNODE_SENSOR_ENDPOINT,
58 /* Must be last because it is optional / maybe empty */
63 /* Data representation as it is in ACPI SSDB buffer */
64 struct cio2_sensor_ssdb {
76 u8 sensorcalibfileidx;
77 u8 sensorcalibfileidxInMBZ[3];
93 struct cio2_property_names {
94 char clock_frequency[16];
99 char remote_endpoint[16];
100 char link_frequencies[17];
103 struct cio2_node_names {
109 struct cio2_sensor_config {
111 const u8 nr_link_freqs;
112 const u64 link_freqs[MAX_NUM_LINK_FREQS];
116 /* append ssdb.link(u8) in "-%u" format as suffix of HID */
117 char name[ACPI_ID_LEN + 4];
118 struct acpi_device *adev;
119 struct i2c_client *vcm_i2c_client;
121 /* SWNODE_COUNT + 1 for terminating NULL */
122 const struct software_node *group[SWNODE_COUNT + 1];
123 struct software_node swnodes[SWNODE_COUNT];
124 struct cio2_node_names node_names;
126 struct cio2_sensor_ssdb ssdb;
127 struct acpi_pld_info *pld;
129 struct cio2_property_names prop_names;
130 struct property_entry ep_properties[5];
131 struct property_entry dev_properties[5];
132 struct property_entry cio2_properties[3];
133 struct software_node_ref_args local_ref[1];
134 struct software_node_ref_args remote_ref[1];
135 struct software_node_ref_args vcm_ref[1];
139 char cio2_node_name[ACPI_ID_LEN];
140 struct software_node cio2_hid_node;
142 unsigned int n_sensors;
143 struct cio2_sensor sensors[CIO2_NUM_PORTS];