blob: 8e13ffc7bb8580eca44987e80fee253d5bef359c [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 */
Matt DeVillier2ca55f22023-01-18 18:14:09 -060014 const char *sub; /* ACPI _SUB */
Duncan Laurie21a097a2016-05-11 09:50:59 -070015 const char *name; /* ACPI Device Name */
16 const char *desc; /* Device Description */
Martin Roth38ddbfb2019-10-23 21:41:00 -060017 unsigned int uid; /* ACPI _UID */
Duncan Laurie21a097a2016-05-11 09:50:59 -070018 enum i2c_speed speed; /* Bus speed in Hz, default is I2C_SPEED_FAST */
Furquan Shaikh8ce36ac2019-08-09 07:59:06 -070019 const char *compat_string; /* Compatible string for _HID=PRP0001 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060020 unsigned int wake; /* Wake GPE */
Duncan Laurie21a097a2016-05-11 09:50:59 -070021 struct acpi_irq irq; /* Interrupt */
22
Duncan Laurieb94e9352017-03-15 11:25:31 -070023 /* Use GPIO based interrupt instead of PIRQ */
24 struct acpi_gpio irq_gpio;
25
Duncan Lauriefbf2c79b2016-09-26 10:31:22 -070026 /*
Elyes HAOUAS18958382018-08-07 12:23:16 +020027 * This flag will add a device property which will indicate
Duncan Lauriefbf2c79b2016-09-26 10:31:22 -070028 * 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 DeVillierc6361422022-03-28 22:35:42 -050035 /*
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 Laurie21a097a2016-05-11 09:50:59 -070046 /* GPIO used to indicate if this device is present */
Martin Roth38ddbfb2019-10-23 21:41:00 -060047 unsigned int device_present_gpio;
48 unsigned int device_present_gpio_invert;
Furquan Shaikh626ad202016-10-20 16:01:04 -070049
Furquan Shaikh71d830f2017-01-25 17:53:01 -080050 /* Does the device have a power resource? */
51 bool has_power_resource;
Furquan Shaikh98915bb2016-12-12 09:23:01 -080052
Furquan Shaikh626ad202016-10-20 16:01:04 -070053 /* GPIO used to take device out of reset or to put it into reset. */
Furquan Shaikh98915bb2016-12-12 09:23:01 -080054 struct acpi_gpio reset_gpio;
Furquan Shaikh626ad202016-10-20 16:01:04 -070055 /* Delay to be inserted after device is taken out of reset. */
Shelley Chena0603392018-04-26 13:52:30 -070056 unsigned int reset_delay_ms;
57 /* Delay to be inserted after device is put into reset. */
58 unsigned int reset_off_delay_ms;
Furquan Shaikh626ad202016-10-20 16:01:04 -070059 /* GPIO used to enable device. */
Furquan Shaikh98915bb2016-12-12 09:23:01 -080060 struct acpi_gpio enable_gpio;
Furquan Shaikh626ad202016-10-20 16:01:04 -070061 /* Delay to be inserted after device is enabled. */
Shelley Chena0603392018-04-26 13:52:30 -070062 unsigned int enable_delay_ms;
63 /* Delay to be inserted after device is disabled. */
64 unsigned int enable_off_delay_ms;
Furquan Shaikhedf459f2017-08-28 17:20:49 -070065 /* GPIO used to stop operation of device. */
66 struct acpi_gpio stop_gpio;
67 /* Delay to be inserted after disabling stop. */
Shelley Chena0603392018-04-26 13:52:30 -070068 unsigned int stop_delay_ms;
69 /* Delay to be inserted after enabling stop. */
70 unsigned int stop_off_delay_ms;
Duncan Laurie1533a3c2017-08-29 08:28:58 -070071
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 Laurie21a097a2016-05-11 09:50:59 -070075};
Furquan Shaikh1d334882016-10-21 16:24:07 -070076
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 Shaikhfdc1b2e2016-12-13 21:50:32 -080082 * 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 Shaikh1d334882016-10-21 16:24:07 -070086 */
Furquan Shaikh7536a392020-04-24 21:59:21 -070087void i2c_generic_fill_ssdt(const struct device *dev,
Furquan Shaikh8220c4b2020-04-24 21:44:27 -070088 void (*callback)(const struct device *dev),
Furquan Shaikhfdc1b2e2016-12-13 21:50:32 -080089 struct drivers_i2c_generic_config *config);
Furquan Shaikh1d334882016-10-21 16:24:07 -070090
91#endif /* __I2C_GENERIC_CHIP_H__ */