1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Author: Dan Scally <djrscally@gmail.com> */
6 #include <linux/property.h>
7 #include <linux/types.h>
8 #include <media/v4l2-fwnode.h>
10 #define IPU_HID "INT343E"
11 #define IPU_MAX_LANES 4
12 #define IPU_MAX_PORTS 4
13 #define MAX_NUM_LINK_FREQS 3
15 /* Values are educated guesses as we don't have a spec */
16 #define IPU_SENSOR_ROTATION_NORMAL 0
17 #define IPU_SENSOR_ROTATION_INVERTED 1
19 #define IPU_SENSOR_CONFIG(_HID, _NR, ...) \
20 (const struct ipu_sensor_config) { \
22 .nr_link_freqs = _NR, \
23 .link_freqs = { __VA_ARGS__ } \
26 #define NODE_SENSOR(_HID, _PROPS) \
27 (const struct software_node) { \
29 .properties = _PROPS, \
32 #define NODE_PORT(_PORT, _SENSOR_NODE) \
33 (const struct software_node) { \
35 .parent = _SENSOR_NODE, \
38 #define NODE_ENDPOINT(_EP, _PORT, _PROPS) \
39 (const struct software_node) { \
42 .properties = _PROPS, \
45 #define NODE_VCM(_TYPE) \
46 (const struct software_node) { \
50 enum ipu_sensor_swnodes {
53 SWNODE_SENSOR_ENDPOINT,
56 /* below are optional / maybe empty */
58 SWNODE_IVSC_SENSOR_PORT,
59 SWNODE_IVSC_SENSOR_ENDPOINT,
61 SWNODE_IVSC_IPU_ENDPOINT,
66 /* Data representation as it is in ACPI SSDB buffer */
67 struct ipu_sensor_ssdb {
79 u8 sensorcalibfileidx;
80 u8 sensorcalibfileidxInMBZ[3];
96 struct ipu_property_names {
97 char clock_frequency[16];
102 char remote_endpoint[16];
103 char link_frequencies[17];
106 struct ipu_node_names {
108 char ivsc_sensor_port[7];
109 char ivsc_ipu_port[7];
115 struct ipu_sensor_config {
117 const u8 nr_link_freqs;
118 const u64 link_freqs[MAX_NUM_LINK_FREQS];
122 /* append ssdb.link(u8) in "-%u" format as suffix of HID */
123 char name[ACPI_ID_LEN + 4];
124 struct acpi_device *adev;
126 struct device *csi_dev;
127 struct acpi_device *ivsc_adev;
128 char ivsc_name[ACPI_ID_LEN + 4];
130 /* SWNODE_COUNT + 1 for terminating NULL */
131 const struct software_node *group[SWNODE_COUNT + 1];
132 struct software_node swnodes[SWNODE_COUNT];
133 struct ipu_node_names node_names;
139 enum v4l2_fwnode_orientation orientation;
140 const char *vcm_type;
142 struct ipu_property_names prop_names;
143 struct property_entry ep_properties[5];
144 struct property_entry dev_properties[5];
145 struct property_entry ipu_properties[3];
146 struct property_entry ivsc_properties[1];
147 struct property_entry ivsc_sensor_ep_properties[4];
148 struct property_entry ivsc_ipu_ep_properties[4];
150 struct software_node_ref_args local_ref[1];
151 struct software_node_ref_args remote_ref[1];
152 struct software_node_ref_args vcm_ref[1];
153 struct software_node_ref_args ivsc_sensor_ref[1];
154 struct software_node_ref_args ivsc_ipu_ref[1];
157 typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev,
158 struct ipu_sensor *sensor);
162 ipu_parse_sensor_fwnode_t parse_sensor_fwnode;
163 char ipu_node_name[ACPI_ID_LEN];
164 struct software_node ipu_hid_node;
166 unsigned int n_sensors;
167 struct ipu_sensor sensors[IPU_MAX_PORTS];
170 #if IS_ENABLED(CONFIG_IPU_BRIDGE)
171 int ipu_bridge_init(struct device *dev,
172 ipu_parse_sensor_fwnode_t parse_sensor_fwnode);
173 int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor);
174 int ipu_bridge_instantiate_vcm(struct device *sensor);
176 /* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */
177 #define ipu_bridge_init(dev, parse_sensor_fwnode) (0)
178 static inline int ipu_bridge_instantiate_vcm(struct device *s) { return 0; }