blob: a99b09536e1cc78391b2069642a2f8ee0d9cd790 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Furquan Shaikh1d334882016-10-21 16:24:07 -07002
3#ifndef __I2C_GENERIC_CHIP_H__
4#define __I2C_GENERIC_CHIP_H__
5
Furquan Shaikh76cedd22020-05-02 10:24:23 -07006#include <acpi/acpi_device.h>
Nico Huber0f2dd1e2017-08-01 14:02:40 +02007#include <device/i2c_simple.h>
Duncan Laurie21a097a2016-05-11 09:50:59 -07008
Duncan Laurie1533a3c2017-08-29 08:28:58 -07009#define MAX_GENERIC_PROPERTY_LIST 10
10
Duncan Laurie21a097a2016-05-11 09:50:59 -070011struct drivers_i2c_generic_config {
12 const char *hid; /* ACPI _HID (required) */
Furquan Shaikh1d334882016-10-21 16:24:07 -070013 const char *cid; /* ACPI _CID */
Duncan Laurie21a097a2016-05-11 09:50:59 -070014 const char *name; /* ACPI Device Name */
15 const char *desc; /* Device Description */
Martin Roth38ddbfb2019-10-23 21:41:00 -060016 unsigned int uid; /* ACPI _UID */
Duncan Laurie21a097a2016-05-11 09:50:59 -070017 enum i2c_speed speed; /* Bus speed in Hz, default is I2C_SPEED_FAST */
Furquan Shaikh8ce36ac2019-08-09 07:59:06 -070018 const char *compat_string; /* Compatible string for _HID=PRP0001 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060019 unsigned int wake; /* Wake GPE */
Duncan Laurie21a097a2016-05-11 09:50:59 -070020 struct acpi_irq irq; /* Interrupt */
21
Duncan Laurieb94e9352017-03-15 11:25:31 -070022 /* Use GPIO based interrupt instead of PIRQ */
23 struct acpi_gpio irq_gpio;
24
Duncan Lauriefbf2c79b2016-09-26 10:31:22 -070025 /*
Elyes HAOUAS18958382018-08-07 12:23:16 +020026 * This flag will add a device property which will indicate
Duncan Lauriefbf2c79b2016-09-26 10:31:22 -070027 * 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 DeVillierc6361422022-03-28 22:35:42 -050034 /*
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 Laurie21a097a2016-05-11 09:50:59 -070045 /* GPIO used to indicate if this device is present */
Martin Roth38ddbfb2019-10-23 21:41:00 -060046 unsigned int device_present_gpio;
47 unsigned int device_present_gpio_invert;
Furquan Shaikh626ad202016-10-20 16:01:04 -070048
Furquan Shaikh71d830f2017-01-25 17:53:01 -080049 /* 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 Shaikh98915bb2016-12-12 09:23:01 -080054
Furquan Shaikh626ad202016-10-20 16:01:04 -070055 /* GPIO used to take device out of reset or to put it into reset. */
Furquan Shaikh98915bb2016-12-12 09:23:01 -080056 struct acpi_gpio reset_gpio;
Furquan Shaikh626ad202016-10-20 16:01:04 -070057 /* Delay to be inserted after device is taken out of reset. */
Shelley Chena0603392018-04-26 13:52:30 -070058 unsigned int reset_delay_ms;
59 /* Delay to be inserted after device is put into reset. */
60 unsigned int reset_off_delay_ms;
Furquan Shaikh626ad202016-10-20 16:01:04 -070061 /* GPIO used to enable device. */
Furquan Shaikh98915bb2016-12-12 09:23:01 -080062 struct acpi_gpio enable_gpio;
Furquan Shaikh626ad202016-10-20 16:01:04 -070063 /* Delay to be inserted after device is enabled. */
Shelley Chena0603392018-04-26 13:52:30 -070064 unsigned int enable_delay_ms;
65 /* Delay to be inserted after device is disabled. */
66 unsigned int enable_off_delay_ms;
Furquan Shaikhedf459f2017-08-28 17:20:49 -070067 /* GPIO used to stop operation of device. */
68 struct acpi_gpio stop_gpio;
69 /* Delay to be inserted after disabling stop. */
Shelley Chena0603392018-04-26 13:52:30 -070070 unsigned int stop_delay_ms;
71 /* Delay to be inserted after enabling stop. */
72 unsigned int stop_off_delay_ms;
Duncan Laurie1533a3c2017-08-29 08:28:58 -070073
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 Laurie21a097a2016-05-11 09:50:59 -070077};
Furquan Shaikh1d334882016-10-21 16:24:07 -070078
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 Shaikhfdc1b2e2016-12-13 21:50:32 -080084 * 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 Shaikh1d334882016-10-21 16:24:07 -070088 */
Furquan Shaikh7536a392020-04-24 21:59:21 -070089void i2c_generic_fill_ssdt(const struct device *dev,
Furquan Shaikh8220c4b2020-04-24 21:44:27 -070090 void (*callback)(const struct device *dev),
Furquan Shaikhfdc1b2e2016-12-13 21:50:32 -080091 struct drivers_i2c_generic_config *config);
Furquan Shaikh1d334882016-10-21 16:24:07 -070092
93#endif /* __I2C_GENERIC_CHIP_H__ */