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 /* Must be last because it is optional / maybe empty */
61 /* Data representation as it is in ACPI SSDB buffer */
62 struct ipu_sensor_ssdb {
74 u8 sensorcalibfileidx;
75 u8 sensorcalibfileidxInMBZ[3];
91 struct ipu_property_names {
92 char clock_frequency[16];
97 char remote_endpoint[16];
98 char link_frequencies[17];
101 struct ipu_node_names {
108 struct ipu_sensor_config {
110 const u8 nr_link_freqs;
111 const u64 link_freqs[MAX_NUM_LINK_FREQS];
115 /* append ssdb.link(u8) in "-%u" format as suffix of HID */
116 char name[ACPI_ID_LEN + 4];
117 struct acpi_device *adev;
119 /* SWNODE_COUNT + 1 for terminating NULL */
120 const struct software_node *group[SWNODE_COUNT + 1];
121 struct software_node swnodes[SWNODE_COUNT];
122 struct ipu_node_names node_names;
128 enum v4l2_fwnode_orientation orientation;
129 const char *vcm_type;
131 struct ipu_property_names prop_names;
132 struct property_entry ep_properties[5];
133 struct property_entry dev_properties[5];
134 struct property_entry ipu_properties[3];
135 struct software_node_ref_args local_ref[1];
136 struct software_node_ref_args remote_ref[1];
137 struct software_node_ref_args vcm_ref[1];
140 typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev,
141 struct ipu_sensor *sensor);
145 ipu_parse_sensor_fwnode_t parse_sensor_fwnode;
146 char ipu_node_name[ACPI_ID_LEN];
147 struct software_node ipu_hid_node;
149 unsigned int n_sensors;
150 struct ipu_sensor sensors[IPU_MAX_PORTS];
153 #if IS_ENABLED(CONFIG_IPU_BRIDGE)
154 int ipu_bridge_init(struct device *dev,
155 ipu_parse_sensor_fwnode_t parse_sensor_fwnode);
156 int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor);
157 int ipu_bridge_instantiate_vcm(struct device *sensor);
159 /* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */
160 #define ipu_bridge_init(dev, parse_sensor_fwnode) (0)
161 static inline int ipu_bridge_instantiate_vcm(struct device *s) { return 0; }