From patchwork Mon Nov 11 10:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11236759 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67DDA1515 for ; Mon, 11 Nov 2019 10:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4652D21783 for ; Mon, 11 Nov 2019 10:48:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DuFmbBUe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfKKKse (ORCPT ); Mon, 11 Nov 2019 05:48:34 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:35603 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726823AbfKKKse (ORCPT ); Mon, 11 Nov 2019 05:48:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573469313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YdIT962GCAwcSC7fh9K24svsozd9yyf+AStxNGzz8/A=; b=DuFmbBUergyFajpewz3/YN29/EALp+o+S7UI9hkpf9wF6f6aQfBeM+V+3EZFuNDyVSUeAU iCSrGWFOodR6EW0e8Xi4ueB23ncYz1yTjtEGvNxhwp8a7p+lfspkzlA8YXt4VCBkHVLZ9S 4YYays3yZHsGQNACTM18mrzlhH7SV9g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-sm4QEhkBPvyrxkE1fso8HA-1; Mon, 11 Nov 2019 05:48:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A30A8017E0; Mon, 11 Nov 2019 10:48:31 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-121.ams2.redhat.com [10.36.117.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id D216A5DD73; Mon, 11 Nov 2019 10:48:29 +0000 (UTC) From: Hans de Goede To: Wolfram Sang , Mika Westerberg Cc: Hans de Goede , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, youling 257 Subject: [PATCH] i2c: acpi: Force bus speed to 400KHz if a Silead touchscreen is present Date: Mon, 11 Nov 2019 11:48:27 +0100 Message-Id: <20191111104827.3713-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: sm4QEhkBPvyrxkE1fso8HA-1 X-Mimecast-Spam-Score: 0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Many cheap devices use Silead touchscreen controllers. Testing has shown repeatedly that these touchscreen controllers work fine at 400KHz, but for unknown reasons do not work properly at 100KHz. This has been seen on both ARM and x86 devices using totally different i2c controllers. On some devices the ACPI tables list another device at the same I2C-bus as only being capable of 100KHz, testing has shown that these other devices work fine at 400KHz (as can be expected of any recent I2C hw). This commit makes i2c_acpi_find_bus_speed() always return 400KHz if a Silead touchscreen controller is present, fixing the touchscreen not working on devices which ACPI tables' wrongly list another device on the same bus as only being capable of 100KHz. Specifically this fixes the touchscreen on the Jumper EZpad 6 m4 not working. Reported-and-tested-by: youling 257 Signed-off-by: Hans de Goede --- drivers/i2c/i2c-core-acpi.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 9cb2aa1e20ef..420c356eba06 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -39,6 +39,7 @@ struct i2c_acpi_lookup { int index; u32 speed; u32 min_speed; + u32 force_speed; }; /** @@ -285,6 +286,19 @@ i2c_acpi_match_device(const struct acpi_device_id *matches, return acpi_match_device(matches, &client->dev); } +static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = { + /* + * These Silead touchscreen controllers only work at 400KHz, for + * some reason they do not work at 100KHz. On some devices the ACPI + * tables list another device at their bus as only being capable + * of 100KHz, testing has shown that these other devices work fine + * at 400KHz (as can be expected of any recent i2c hw) so we force + * the speed of the bus to 400 KHz if a Silead device is present. + */ + { "MSSL1680", 0 }, + {} +}; + static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level, void *data, void **return_value) { @@ -303,6 +317,9 @@ static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level, if (lookup->speed <= lookup->min_speed) lookup->min_speed = lookup->speed; + if (acpi_match_device_ids(adev, i2c_acpi_force_400khz_device_ids) == 0) + lookup->force_speed = 400000; + return AE_OK; } @@ -340,7 +357,12 @@ u32 i2c_acpi_find_bus_speed(struct device *dev) return 0; } - return lookup.min_speed != UINT_MAX ? lookup.min_speed : 0; + if (lookup.force_speed) + return lookup.force_speed; + else if (lookup.min_speed != UINT_MAX) + return lookup.min_speed; + else + return 0; } EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);