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 */ |
Matt DeVillier | 2ca55f2 | 2023-01-18 18:14:09 -0600 | [diff] [blame^] | 14 | const char *sub; /* ACPI _SUB */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 15 | const char *name; /* ACPI Device Name */ |
| 16 | const char *desc; /* Device Description */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 17 | unsigned int uid; /* ACPI _UID */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 18 | 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] | 19 | const char *compat_string; /* Compatible string for _HID=PRP0001 */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 20 | unsigned int wake; /* Wake GPE */ |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 21 | struct acpi_irq irq; /* Interrupt */ |
| 22 | |
Duncan Laurie | b94e935 | 2017-03-15 11:25:31 -0700 | [diff] [blame] | 23 | /* Use GPIO based interrupt instead of PIRQ */ |
| 24 | struct acpi_gpio irq_gpio; |
| 25 | |
Duncan Laurie | fbf2c79b | 2016-09-26 10:31:22 -0700 | [diff] [blame] | 26 | /* |
Elyes HAOUAS | 1895838 | 2018-08-07 12:23:16 +0200 | [diff] [blame] | 27 | * This flag will add a device property which will indicate |
Duncan Laurie | fbf2c79b | 2016-09-26 10:31:22 -0700 | [diff] [blame] | 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 | |
Matt DeVillier | c636142 | 2022-03-28 22:35:42 -0500 | [diff] [blame] | 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 | |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 46 | /* GPIO used to indicate if this device is present */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 47 | unsigned int device_present_gpio; |
| 48 | unsigned int device_present_gpio_invert; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 49 | |
Furquan Shaikh | 71d830f | 2017-01-25 17:53:01 -0800 | [diff] [blame] | 50 | /* Does the device have a power resource? */ |
| 51 | bool has_power_resource; |
Furquan Shaikh | 98915bb | 2016-12-12 09:23:01 -0800 | [diff] [blame] | 52 | |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 53 | /* 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] | 54 | struct acpi_gpio reset_gpio; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 55 | /* Delay to be inserted after device is taken out of reset. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 56 | unsigned int reset_delay_ms; |
| 57 | /* Delay to be inserted after device is put into reset. */ |
| 58 | unsigned int reset_off_delay_ms; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 59 | /* GPIO used to enable device. */ |
Furquan Shaikh | 98915bb | 2016-12-12 09:23:01 -0800 | [diff] [blame] | 60 | struct acpi_gpio enable_gpio; |
Furquan Shaikh | 626ad20 | 2016-10-20 16:01:04 -0700 | [diff] [blame] | 61 | /* Delay to be inserted after device is enabled. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 62 | unsigned int enable_delay_ms; |
| 63 | /* Delay to be inserted after device is disabled. */ |
| 64 | unsigned int enable_off_delay_ms; |
Furquan Shaikh | edf459f | 2017-08-28 17:20:49 -0700 | [diff] [blame] | 65 | /* GPIO used to stop operation of device. */ |
| 66 | struct acpi_gpio stop_gpio; |
| 67 | /* Delay to be inserted after disabling stop. */ |
Shelley Chen | a060339 | 2018-04-26 13:52:30 -0700 | [diff] [blame] | 68 | unsigned int stop_delay_ms; |
| 69 | /* Delay to be inserted after enabling stop. */ |
| 70 | unsigned int stop_off_delay_ms; |
Duncan Laurie | 1533a3c | 2017-08-29 08:28:58 -0700 | [diff] [blame] | 71 | |
| 72 | /* Generic properties for exporting device-specific data to the OS */ |
| 73 | struct acpi_dp property_list[MAX_GENERIC_PROPERTY_LIST]; |
| 74 | int property_count; |
Duncan Laurie | 21a097a | 2016-05-11 09:50:59 -0700 | [diff] [blame] | 75 | }; |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Fills in generic information about i2c device from device-tree |
| 79 | * properties. Callback can be provided to fill in any |
| 80 | * device-specific information in SSDT. |
| 81 | * |
Furquan Shaikh | fdc1b2e | 2016-12-13 21:50:32 -0800 | [diff] [blame] | 82 | * Parameters: |
| 83 | * dev: Device requesting i2c generic information to be filled |
| 84 | * callback: Callback to fill in device-specific information |
| 85 | * config: Pointer to drivers_i2c_generic_config structure |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 86 | */ |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 87 | void i2c_generic_fill_ssdt(const struct device *dev, |
Furquan Shaikh | 8220c4b | 2020-04-24 21:44:27 -0700 | [diff] [blame] | 88 | void (*callback)(const struct device *dev), |
Furquan Shaikh | fdc1b2e | 2016-12-13 21:50:32 -0800 | [diff] [blame] | 89 | struct drivers_i2c_generic_config *config); |
Furquan Shaikh | 1d33488 | 2016-10-21 16:24:07 -0700 | [diff] [blame] | 90 | |
| 91 | #endif /* __I2C_GENERIC_CHIP_H__ */ |