1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Author: Dan Scally <djrscally@gmail.com> */ 3 #ifndef __CIO2_BRIDGE_H 4 #define __CIO2_BRIDGE_H 5 6 #include <linux/property.h> 7 #include <linux/types.h> 8 9 #include "ipu3-cio2.h" 10 11 #define CIO2_HID "INT343E" 12 #define CIO2_MAX_LANES 4 13 #define MAX_NUM_LINK_FREQS 3 14 15 /* Values are educated guesses as we don't have a spec */ 16 #define CIO2_SENSOR_ROTATION_NORMAL 0 17 #define CIO2_SENSOR_ROTATION_INVERTED 1 18 19 #define CIO2_SENSOR_CONFIG(_HID, _NR, ...) \ 20 (const struct cio2_sensor_config) { \ 21 .hid = _HID, \ 22 .nr_link_freqs = _NR, \ 23 .link_freqs = { __VA_ARGS__ } \ 24 } 25 26 #define NODE_SENSOR(_HID, _PROPS) \ 27 (const struct software_node) { \ 28 .name = _HID, \ 29 .properties = _PROPS, \ 30 } 31 32 #define NODE_PORT(_PORT, _SENSOR_NODE) \ 33 (const struct software_node) { \ 34 .name = _PORT, \ 35 .parent = _SENSOR_NODE, \ 36 } 37 38 #define NODE_ENDPOINT(_EP, _PORT, _PROPS) \ 39 (const struct software_node) { \ 40 .name = _EP, \ 41 .parent = _PORT, \ 42 .properties = _PROPS, \ 43 } 44 45 enum cio2_sensor_swnodes { 46 SWNODE_SENSOR_HID, 47 SWNODE_SENSOR_PORT, 48 SWNODE_SENSOR_ENDPOINT, 49 SWNODE_CIO2_PORT, 50 SWNODE_CIO2_ENDPOINT, 51 SWNODE_COUNT 52 }; 53 54 /* Data representation as it is in ACPI SSDB buffer */ 55 struct cio2_sensor_ssdb { 56 u8 version; 57 u8 sku; 58 u8 guid_csi2[16]; 59 u8 devfunction; 60 u8 bus; 61 u32 dphylinkenfuses; 62 u32 clockdiv; 63 u8 link; 64 u8 lanes; 65 u32 csiparams[10]; 66 u32 maxlanespeed; 67 u8 sensorcalibfileidx; 68 u8 sensorcalibfileidxInMBZ[3]; 69 u8 romtype; 70 u8 vcmtype; 71 u8 platforminfo; 72 u8 platformsubinfo; 73 u8 flash; 74 u8 privacyled; 75 u8 degree; 76 u8 mipilinkdefined; 77 u32 mclkspeed; 78 u8 controllogicid; 79 u8 reserved1[3]; 80 u8 mclkport; 81 u8 reserved2[13]; 82 } __packed; 83 84 struct cio2_property_names { 85 char clock_frequency[16]; 86 char rotation[9]; 87 char orientation[12]; 88 char bus_type[9]; 89 char data_lanes[11]; 90 char remote_endpoint[16]; 91 char link_frequencies[17]; 92 }; 93 94 struct cio2_node_names { 95 char port[7]; 96 char endpoint[11]; 97 char remote_port[7]; 98 }; 99 100 struct cio2_sensor_config { 101 const char *hid; 102 const u8 nr_link_freqs; 103 const u64 link_freqs[MAX_NUM_LINK_FREQS]; 104 }; 105 106 struct cio2_sensor { 107 char name[ACPI_ID_LEN]; 108 struct acpi_device *adev; 109 110 struct software_node swnodes[6]; 111 struct cio2_node_names node_names; 112 113 struct cio2_sensor_ssdb ssdb; 114 struct acpi_pld_info *pld; 115 116 struct cio2_property_names prop_names; 117 struct property_entry ep_properties[5]; 118 struct property_entry dev_properties[4]; 119 struct property_entry cio2_properties[3]; 120 struct software_node_ref_args local_ref[1]; 121 struct software_node_ref_args remote_ref[1]; 122 }; 123 124 struct cio2_bridge { 125 char cio2_node_name[ACPI_ID_LEN]; 126 struct software_node cio2_hid_node; 127 u32 data_lanes[4]; 128 unsigned int n_sensors; 129 struct cio2_sensor sensors[CIO2_NUM_PORTS]; 130 }; 131 132 #endif 133