Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef __I2C_GENERIC_CHIP_H__ |
| 4 | #define __I2C_GENERIC_CHIP_H__ |
| 5 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 6 | #include <acpi/acpi_device.h> |
Nico Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 7 | #include <device/i2c_simple.h> |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 8 | |
Duncan Laurie | 1533a3c | 2017-08-29 08:28:58 -0700 | [diff] [blame] | 9 | #define MAX_GENERIC_PROPERTY_LIST 10 |
| 10 | |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 11 | struct drivers_i2c_generic_config { |
| 12 | const char *hid; /* ACPI _HID (required) */ |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 13 | const char *cid; /* ACPI _CID */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 14 | const char *name; /* ACPI Device Name */ |
| 15 | const char *desc; /* Device Description */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 16 | unsigned int uid; /* ACPI _UID */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 17 | enum i2c_speed speed; /* Bus speed in Hz, default is I2C_SPEED_FAST */ |
Furquan Shaikh | 8ce36ac | 2019-08-09 07:59:06 -0700 | [diff] [blame] | 18 | const char *compat_string; /* Compatible string for _HID=PRP0001 */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 19 | unsigned int wake; /* Wake GPE */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 20 | struct acpi_irq irq; /* Interrupt */ |
| 21 | |
Duncan Laurie | b94e935 | 2017-03-15 11:25:31 -0700 | [diff] [blame] | 22 | /* Use GPIO based interrupt instead of PIRQ */ |
| 23 | struct acpi_gpio irq_gpio; |
| 24 | |
Duncan Laurie | fbf2c79b | 2016-09-26 10:31:22 -0700 | [diff] [blame] | 25 | /* |
Elyes HAOUAS | 1895838 | 2018-08-07 12:23:16 +0200 | [diff] [blame] | 26 | * This flag will add a device property which will indicate |
Duncan Laurie | fbf2c79b | 2016-09-26 10:31:22 -0700 | [diff] [blame] | 27 | * to the OS that it should probe this device before adding it. |
| 28 | * |
| 29 | * This can be used to declare a device that may not exist on |
| 30 | * the board, for example to support multiple trackpad vendors. |
| 31 | */ |
| 32 | int probed; |
| 33 | |
Matt DeVillier | c636142 | 2022-03-28 22:35:42 -0500 | [diff] [blame^] | 34 | /* |
| 35 | * This flag will add a device property which will indicate |
| 36 | * that coreboot should attempt to detect the device on the i2c |
| 37 | * bus before generating a device entry in the SSDT. |
| 38 | * |
| 39 | * This can be used to declare a device that may not exist on |
| 40 | * the board, for example to support multiple touchpads and/or |
| 41 | * touchscreens. |
| 42 | */ |
| 43 | int detect; |
| 44 | |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 45 | /* GPIO used to indicate if this device is present */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 46 | unsigned int device_present_gpio; |
| 47 | unsigned int device_present_gpio_invert; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 48 | |
Furquan Shaikh | 71d830f | 2017-01-25 17:53:01 -0800 | [diff] [blame] | 49 | /* Disable reset and enable GPIO export in _CRS */ |
| 50 | bool disable_gpio_export_in_crs; |
| 51 | |
| 52 | /* Does the device have a power resource? */ |
| 53 | bool has_power_resource; |
Furquan Shaikh | 98915bb | 2016-12-12 09:23:01 -0800 | [diff] [blame] | 54 | |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 55 | /* GPIO used to take device out of reset or to put it into reset. */ |
Furquan Shaikh | 98915bb | 2016-12-12 09:23:01 -0800 | [diff] [blame] | 56 | struct acpi_gpio reset_gpio; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 57 | /* Delay to be inserted after device is taken out of reset. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 58 | unsigned int reset_delay_ms; |
| 59 | /* Delay to be inserted after device is put into reset. */ |
| 60 | unsigned int reset_off_delay_ms; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 61 | /* GPIO used to enable device. */ |
Furquan Shaikh | 98915bb | 2016-12-12 09:23:01 -0800 | [diff] [blame] | 62 | struct acpi_gpio enable_gpio; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 63 | /* Delay to be inserted after device is enabled. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 64 | unsigned int enable_delay_ms; |
| 65 | /* Delay to be inserted after device is disabled. */ |
| 66 | unsigned int enable_off_delay_ms; |
Furquan Shaikh | edf459f | 2017-08-28 17:20:49 -0700 | [diff] [blame] | 67 | /* GPIO used to stop operation of device. */ |
| 68 | struct acpi_gpio stop_gpio; |
| 69 | /* Delay to be inserted after disabling stop. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 70 | unsigned int stop_delay_ms; |
| 71 | /* Delay to be inserted after enabling stop. */ |
| 72 | unsigned int stop_off_delay_ms; |
Duncan Laurie | 1533a3c | 2017-08-29 08:28:58 -0700 | [diff] [blame] | 73 | |
| 74 | /* Generic properties for exporting device-specific data to the OS */ |
| 75 | struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST]; |
| 76 | int property_count; |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 77 | }; |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Fills in generic information about i2c device from device-tree |
| 81 | * properties. Callback can be provided to fill in any |
| 82 | * device-specific information in SSDT. |
| 83 | * |
Furquan Shaikh | fdc1b2e | 2016-12-13 21:50:32 -0800 | [diff] [blame] | 84 | * Parameters: |
| 85 | * dev: Device requesting i2c generic information to be filled |
| 86 | * callback: Callback to fill in device-specific information |
| 87 | * config: Pointer to drivers_i2c_generic_config structure |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 88 | */ |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 89 | void i2c_generic_fill_ssdt(const struct device *dev, |
Furquan Shaikh | 8220c4b | 2020-04-24 21:44:27 -0700 | [diff] [blame] | 90 | void (*callback)(const struct device *dev), |
Furquan Shaikh | fdc1b2e | 2016-12-13 21:50:32 -0800 | [diff] [blame] | 91 | struct drivers_i2c_generic_config *config); |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 92 | |
| 93 | #endif /* __I2C_GENERIC_CHIP_H__ */ |