Skip to contentSkip to conversation

i2c-designware: configure SDA hold time from ACPI

PATCH In review Mika Westerberg 1 participant 2 messages Jul 3, 2013 – Jul 10, 2013

Subsystems (3)
lore
Share & tools
lore

Mika Westerberg

author maintainer
#0 lore raw

PATCH 1/1 i2c-designware: configure SDA hold time from ACPI

Some Intel LPSS I2C devices make the SDA hold time parameter available via SSCN (standard mode) and FMCN (fast mode) ACPI methods. If we find that such method exist, we evaluate it and pass the returned SDA hold value to the i2c-designware core analogous to Device Tree.

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +18 -1
index 8b9d3f1..c7cfdac 100644
@@ -57,13 +57,30 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
 static int dw_i2c_acpi_configure(struct platform_device *pdev)
 {
 	struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
+	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
+	acpi_handle handle = ACPI_HANDLE(&pdev->dev);
+	acpi_string name;
 
-	if (!ACPI_HANDLE(&pdev->dev))
+	if (!handle)
 		return -ENODEV;
 
 	dev->adapter.nr = -1;
 	dev->tx_fifo_depth = 32;
 	dev->rx_fifo_depth = 32;
+
+	name = dev->master_cfg & DW_IC_CON_SPEED_FAST ? "FMCN" : "SSCN";
+	if (ACPI_SUCCESS(acpi_evaluate_object(handle, name, NULL, &buf))) {
+		union acpi_object *obj = (union acpi_object *)buf.pointer;
+
+		if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 3) {
+			const union acpi_object *objs = obj->package.elements;
+
+			dev->sda_hold_time = (u32)objs[2].integer.value;
+		}
+
+		kfree(buf.pointer);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.8.3.2
author maintainer
#1 lore raw
Quoted 6 lines · Mika Westerberg

Some Intel LPSS I2C devices make the SDA hold time parameter available via SSCN (standard mode) and FMCN (fast mode) ACPI methods. If we find that such method exist, we evaluate it and pass the returned SDA hold value to the i2c-designware core analogous to Device Tree.

Please disregard this patch. I'll send a new one that combines both setting of SDA hold time and *CNT values from ACPI.