1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef __I2C_GENERIC_CHIP_H__ 4 #define __I2C_GENERIC_CHIP_H__ 5 6 #include <acpi/acpi_device.h> 7 #include <device/i2c_simple.h> 8 9 #define MAX_GENERIC_PROPERTY_LIST 10 10 11 struct drivers_i2c_generic_config { 12 const char *hid; /* ACPI _HID (required) */ 13 const char *cid; /* ACPI _CID */ 14 const char *sub; /* ACPI _SUB */ 15 const char *name; /* ACPI Device Name */ 16 const char *desc; /* Device Description */ 17 unsigned int uid; /* ACPI _UID */ 18 enum i2c_speed speed; /* Bus speed in Hz, default is I2C_SPEED_FAST */ 19 const char *compat_string; /* Compatible string for _HID=PRP0001 */ 20 unsigned int wake; /* Wake GPE */ 21 struct acpi_irq irq; /* Interrupt */ 22 23 /* Use GPIO based interrupt instead of PIRQ */ 24 struct acpi_gpio irq_gpio; 25 26 /* 27 * This flag will add a device property which will indicate 28 * to the OS that it should probe this device before adding it. 29 * 30 * This can be used to declare a device that may not exist on 31 * the board, for example to support multiple trackpad vendors. 32 */ 33 int probed; 34 35 /* 36 * This flag will add a device property which will indicate 37 * that coreboot should attempt to detect the device on the i2c 38 * bus before generating a device entry in the SSDT. 39 * 40 * This can be used to declare a device that may not exist on 41 * the board, for example to support multiple touchpads and/or 42 * touchscreens. 43 */ 44 int detect; 45 46 /* GPIO used to indicate if this device is present */ 47 unsigned int device_present_gpio; 48 unsigned int device_present_gpio_invert; 49 50 /* Does the device have a power resource? */ 51 bool has_power_resource; 52 53 /* GPIO used to take device out of reset or to put it into reset. */ 54 struct acpi_gpio reset_gpio; 55 /* Delay to be inserted after device is taken out of reset. */ 56 unsigned int reset_delay_ms; 57 /* Delay to be inserted after device is put into reset. */ 58 unsigned int reset_off_delay_ms; 59 /* GPIO used to enable device. */ 60 struct acpi_gpio enable_gpio; 61 /* Delay to be inserted after device is enabled. */ 62 unsigned int enable_delay_ms; 63 /* Delay to be inserted after device is disabled. */ 64 unsigned int enable_off_delay_ms; 65 /* GPIO used to stop operation of device. */ 66 struct acpi_gpio stop_gpio; 67 /* Delay to be inserted after disabling stop. */ 68 unsigned int stop_delay_ms; 69 /* Delay to be inserted after enabling stop. */ 70 unsigned int stop_off_delay_ms; 71 72 /* 73 * The Rotation Matrix' allows specifying a 3x3 matrix representing 74 * the orientation of devices, such as accelerometers. Each value in 75 * the matrix can be one of -1, 0, or 1, indicating the transformation 76 * applied to the device's axes. 77 * 78 * It is expected by linux and required for the OS to correctly interpret 79 * the data from the device. 80 */ 81 bool has_rotation_matrix; 82 int rotation_matrix[9]; 83 84 85 /* Generic properties for exporting device-specific data to the OS */ 86 struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST]; 87 int property_count; 88 }; 89 90 /* 91 * Fills in generic information about i2c device from device-tree 92 * properties. Callback can be provided to fill in any 93 * device-specific information in SSDT. 94 * 95 * Parameters: 96 * dev: Device requesting i2c generic information to be filled 97 * callback: Callback to fill in device-specific information 98 * config: Pointer to drivers_i2c_generic_config structure 99 */ 100 void i2c_generic_fill_ssdt(const struct device *dev, 101 void (*callback)(const struct device *dev), 102 struct drivers_i2c_generic_config *config); 103 104 #endif /* __I2C_GENERIC_CHIP_H__ */ 105