Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17091
-gerrit
commit e730a9791352326ef8c14ce9b55c1f6b2662930e
Author: Furquan Shaikh <furquan(a)chromium.org>
Date: Fri Oct 21 16:40:17 2016 -0700
arch/x86/acpigen_dsm: Add support for DSM types
Currently, the only supported DSM type is I2C
HID(3CDFF6F7-4267-4555-AD05-B30A3D8938DE). This provides the required
callbacks for generating ACPI AML codes for different function
identifiers for I2C HID.
BUG=chrome-os-partner:57846
Change-Id: Ia403e11f7ce4824956e3c879547ec927478db7b1
Signed-off-by: Furquan Shaikh <furquan(a)chromium.org>
---
src/arch/x86/Makefile.inc | 1 +
src/arch/x86/acpigen_dsm.c | 65 +++++++++++++++++++++++++++++++++
src/arch/x86/include/arch/acpigen_dsm.h | 27 ++++++++++++++
3 files changed, 93 insertions(+)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 782ca63..c4bb1cc 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -313,6 +313,7 @@ ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
+ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen_dsm.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c
ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
ramstage-y += boot.c
diff --git a/src/arch/x86/acpigen_dsm.c b/src/arch/x86/acpigen_dsm.c
new file mode 100644
index 0000000..c6d614a
--- /dev/null
+++ b/src/arch/x86/acpigen_dsm.c
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/acpigen.h>
+#include <arch/acpigen_dsm.h>
+#include <stdlib.h>
+
+/* ------------------- I2C HID DSM ---------------------------- */
+
+#define ACPI_DSM_I2C_HID_UUID "3CDFF6F7-4267-4555-AD05-B30A3D8938DE"
+
+static void i2c_hid_func0_cb(void *arg)
+{
+ /* ToInteger (Arg1, Local2) */
+ acpigen_write_to_integer(ARG1_OP, LOCAL2_OP);
+ /* If (LEqual (Local2, 0x0)) */
+ acpigen_write_if_lequal(LOCAL2_OP, 0x0);
+ /* Return (Buffer (One) { 0x1f }) */
+ acpigen_write_return_singleton_buffer(0x1f);
+ acpigen_pop_len(); /* Pop : If */
+ /* Else */
+ acpigen_write_else();
+ /* If (LEqual (Local2, 0x1)) */
+ acpigen_write_if_lequal(LOCAL2_OP, 0x1);
+ /* Return (Buffer (One) { 0x3f }) */
+ acpigen_write_return_singleton_buffer(0x3f);
+ acpigen_pop_len(); /* Pop : If */
+ /* Else */
+ acpigen_write_else();
+ /* Return (Buffer (One) { 0x0 }) */
+ acpigen_write_return_singleton_buffer(0x0);
+ acpigen_pop_len(); /* Pop : Else */
+ acpigen_pop_len(); /* Pop : Else */
+}
+
+static void i2c_hid_func1_cb(void *arg)
+{
+ struct dsm_i2c_hid_config *config = arg;
+ acpigen_write_return_byte(config->hid_desc_reg_offset);
+}
+
+static void (*i2c_hid_callbacks[2])(void *) = {
+ i2c_hid_func0_cb,
+ i2c_hid_func1_cb,
+};
+
+void acpigen_write_dsm_i2c_hid(struct dsm_i2c_hid_config *config)
+{
+ acpigen_write_dsm(ACPI_DSM_I2C_HID_UUID, i2c_hid_callbacks,
+ ARRAY_SIZE(i2c_hid_callbacks), config);
+}
+
+/* ------------------- End: I2C HID DSM ------------------------- */
diff --git a/src/arch/x86/include/arch/acpigen_dsm.h b/src/arch/x86/include/arch/acpigen_dsm.h
new file mode 100644
index 0000000..2d8bb48
--- /dev/null
+++ b/src/arch/x86/include/arch/acpigen_dsm.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ARCH_ACPIGEN_DSM_H__
+#define __ARCH_ACPIGEN_DSM_H__
+
+#include <stdint.h>
+
+struct dsm_i2c_hid_config {
+ uint8_t hid_desc_reg_offset;
+};
+
+void acpigen_write_dsm_i2c_hid(struct dsm_i2c_hid_config *config);
+
+#endif /* __ARCH_ACPIGEN_DSM_H__ */
Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17089
-gerrit
commit cf3189511eefd1579066ed28d3fb68d7184d03b2
Author: Furquan Shaikh <furquan(a)chromium.org>
Date: Fri Oct 21 16:24:07 2016 -0700
drivers/i2c/generic: Re-factor SSDT generation code
1. Export i2c_generic_fill_ssdt to allow other device-specific i2c
drivers to share and re-use the same code for generating AML code for
SSDT. In order to achieve this, following changes are required:
a. Add macro I2C_GENERIC_CONFIG that defines a structure with all
generic i2c device-tree properties. This macro should be placed by the
using driver at the start of its config structure.
b. Accept a callback function to add any device specific information to
SSDT. If generic driver is used directly by a device, callback would be
NULL. Other devices using a separate i2c driver can provide a callback
to add any properties to SSDT.
2. Allow device to provide _CID.
BUG=chrome-os-partner:57846
Change-Id: I3a0054e22b81f9d6d407bef417eae5e9edc04ee4
Signed-off-by: Furquan Shaikh <furquan(a)chromium.org>
---
src/drivers/i2c/generic/chip.h | 33 +++++++++++++++++++++++++++++++++
src/drivers/i2c/generic/generic.c | 16 ++++++++++++++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/drivers/i2c/generic/chip.h b/src/drivers/i2c/generic/chip.h
index e84fc38..736de51 100644
--- a/src/drivers/i2c/generic/chip.h
+++ b/src/drivers/i2c/generic/chip.h
@@ -1,8 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __I2C_GENERIC_CHIP_H__
+#define __I2C_GENERIC_CHIP_H__
+
#include <arch/acpi_device.h>
#include <device/i2c.h>
struct drivers_i2c_generic_config {
const char *hid; /* ACPI _HID (required) */
+ const char *cid; /* ACPI _CID */
const char *name; /* ACPI Device Name */
const char *desc; /* Device Description */
unsigned uid; /* ACPI _UID */
@@ -32,3 +51,17 @@ struct drivers_i2c_generic_config {
/* Delay to be inserted after device is enabled. */
unsigned enable_delay_ms;
};
+
+/*
+ * Fills in generic information about i2c device from device-tree
+ * properties. Callback can be provided to fill in any
+ * device-specific information in SSDT.
+ *
+ * Drivers calling into this function to generate should place
+ * drivers_i2c_generic_config structure at the beginning of their device config
+ * structure.
+ */
+void i2c_generic_fill_ssdt(struct device *dev,
+ void (*callback)(struct device *dev));
+
+#endif /* __I2C_GENERIC_CHIP_H__ */
diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c
index 34fbf77..b8e5d86 100644
--- a/src/drivers/i2c/generic/generic.c
+++ b/src/drivers/i2c/generic/generic.c
@@ -65,7 +65,8 @@ static void i2c_generic_add_power_res(struct drivers_i2c_generic_config *config)
acpigen_pop_len(); /* PowerResource PRIC */
}
-static void i2c_generic_fill_ssdt(struct device *dev)
+void i2c_generic_fill_ssdt(struct device *dev,
+ void (*callback)(struct device *dev))
{
struct drivers_i2c_generic_config *config = dev->chip_info;
const char *scope = acpi_device_scope(dev);
@@ -89,6 +90,8 @@ static void i2c_generic_fill_ssdt(struct device *dev)
acpigen_write_scope(scope);
acpigen_write_device(acpi_device_name(dev));
acpigen_write_name_string("_HID", config->hid);
+ if (config->cid)
+ acpigen_write_name_string("_CID", config->cid);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", config->desc);
acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
@@ -115,6 +118,10 @@ static void i2c_generic_fill_ssdt(struct device *dev)
/* Power Resource */
i2c_generic_add_power_res(config);
+ /* Callback if any. */
+ if (callback)
+ callback(dev);
+
acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */
@@ -122,6 +129,11 @@ static void i2c_generic_fill_ssdt(struct device *dev)
config->desc ? : dev->chip_ops->name, dev_path(dev));
}
+static void i2c_generic_fill_ssdt_generator(struct device *dev)
+{
+ i2c_generic_fill_ssdt(dev, NULL);
+}
+
/* Use name specified in config or build one from I2C address */
static const char *i2c_generic_acpi_name(struct device *dev)
{
@@ -143,7 +155,7 @@ static struct device_operations i2c_generic_ops = {
.enable_resources = DEVICE_NOOP,
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
.acpi_name = &i2c_generic_acpi_name,
- .acpi_fill_ssdt_generator = &i2c_generic_fill_ssdt,
+ .acpi_fill_ssdt_generator = &i2c_generic_fill_ssdt_generator,
#endif
};
Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17092
-gerrit
commit 4986dd59e4d193153ebc59dd292f9a4dfbe71b27
Author: Furquan Shaikh <furquan(a)chromium.org>
Date: Fri Oct 21 16:42:45 2016 -0700
drivers/i2c/wacom_ts: Add support for WCOM touchscreen device driver
BUG=chrome-os-partner:57846
Change-Id: Id6bd91b3fd6420994ad5811d362618b1a38a8afa
Signed-off-by: Furquan Shaikh <furquan(a)chromium.org>
---
src/drivers/i2c/wacom_ts/Kconfig | 3 ++
src/drivers/i2c/wacom_ts/Makefile.inc | 1 +
src/drivers/i2c/wacom_ts/chip.h | 30 ++++++++++++++++++
src/drivers/i2c/wacom_ts/ts.c | 59 +++++++++++++++++++++++++++++++++++
4 files changed, 93 insertions(+)
diff --git a/src/drivers/i2c/wacom_ts/Kconfig b/src/drivers/i2c/wacom_ts/Kconfig
new file mode 100644
index 0000000..50da3f1
--- /dev/null
+++ b/src/drivers/i2c/wacom_ts/Kconfig
@@ -0,0 +1,3 @@
+config DRIVERS_I2C_WACOM_TS
+ bool
+ select DRIVERS_I2C_GENERIC
diff --git a/src/drivers/i2c/wacom_ts/Makefile.inc b/src/drivers/i2c/wacom_ts/Makefile.inc
new file mode 100644
index 0000000..9455099
--- /dev/null
+++ b/src/drivers/i2c/wacom_ts/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_I2C_WACOM_TS) += ts.c
diff --git a/src/drivers/i2c/wacom_ts/chip.h b/src/drivers/i2c/wacom_ts/chip.h
new file mode 100644
index 0000000..b59f630
--- /dev/null
+++ b/src/drivers/i2c/wacom_ts/chip.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __I2C_WACOM_TS_CHIP_H__
+#define __I2C_WACOM_TS_CHIP_H__
+
+#include <drivers/i2c/generic/chip.h>
+
+#define WCOM50C1_HID "WCOM50C1"
+#define PNP0C50_CID "PNP0C50"
+#define WCOM_TS_DESC "WCOM Touchscreen"
+
+struct drivers_i2c_wacom_ts_config {
+ struct drivers_i2c_generic_config generic;
+ uint8_t hid_desc_reg_offset;
+};
+
+#endif /* __I2C_WACOM_TS_CHIP_H__ */
diff --git a/src/drivers/i2c/wacom_ts/ts.c b/src/drivers/i2c/wacom_ts/ts.c
new file mode 100644
index 0000000..ebc8883
--- /dev/null
+++ b/src/drivers/i2c/wacom_ts/ts.c
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/acpigen_dsm.h>
+#include <device/device.h>
+#include <stdint.h>
+#include "chip.h"
+
+static void i2c_wacom_ts_fill_dsm(struct device *dev)
+{
+ struct drivers_i2c_wacom_ts_config *config = dev->chip_info;
+ struct dsm_i2c_hid_config dsm_config = {
+ .hid_desc_reg_offset = config->hid_desc_reg_offset,
+ };
+
+ acpigen_write_dsm_i2c_hid(&dsm_config);
+}
+
+static void i2c_wacom_ts_fill_ssdt_generator(struct device *dev)
+{
+ i2c_generic_fill_ssdt(dev, &i2c_wacom_ts_fill_dsm);
+}
+
+static const char *i2c_wacom_ts_acpi_name(struct device *dev)
+{
+ return "WCTS";
+}
+
+static struct device_operations i2c_wacom_ts_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+ .enable_resources = DEVICE_NOOP,
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+ .acpi_name = &i2c_wacom_ts_acpi_name,
+ .acpi_fill_ssdt_generator = &i2c_wacom_ts_fill_ssdt_generator,
+#endif
+};
+
+static void i2c_wacom_ts_enable(struct device *dev)
+{
+ dev->ops = &i2c_wacom_ts_ops;
+}
+
+struct chip_operations drivers_i2c_wacom_ts_ops = {
+ CHIP_NAME("Wacom Touchscreen Device")
+ .enable_dev = &i2c_wacom_ts_enable
+};
Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17083
-gerrit
commit e562ae20210c1866507bd552cd1aef2856efd17d
Author: Furquan Shaikh <furquan(a)chromium.org>
Date: Thu Oct 20 22:48:45 2016 -0700
mainboard/google/reef: Add PowerResource for ELAN touchscreen
Define reset_gpio and enable_gpio for touchscreen device so that when
kernel puts this device into D3, we put the device into
reset. PowerResource _ON and _OFF routines are used to put the device
into D0 and D3 states.
BUG=chrome-os-partner:55988
Change-Id: Ia905f9eb630cd96767b639aec74131dbd7952d0e
Signed-off-by: Furquan Shaikh <furquan(a)chromium.org>
---
src/mainboard/google/reef/variants/baseboard/devicetree.cb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/mainboard/google/reef/variants/baseboard/devicetree.cb b/src/mainboard/google/reef/variants/baseboard/devicetree.cb
index 00df9bd..30d61f6 100644
--- a/src/mainboard/google/reef/variants/baseboard/devicetree.cb
+++ b/src/mainboard/google/reef/variants/baseboard/devicetree.cb
@@ -142,6 +142,10 @@ chip soc/intel/apollolake
register "desc" = ""ELAN Touchscreen""
register "irq" = "IRQ_EDGE_LOW(GPIO_21_IRQ)"
register "probed" = "1"
+ register "reset_gpio" = "GPIO_36"
+ register "reset_delay_ms" = "20"
+ register "enable_gpio" = "GPIO_152"
+ register "enable_delay_ms" = "1"
device i2c 10 on end
end
end # - I2C 3