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