Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp491330pxj; Thu, 20 May 2021 14:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEGsu3Rodl1UBbSVS/2ofV2P6oSR//KF7jyfpvOuXO0nWXLNOXH9fUxaTB2QlWxAouqw3k X-Received: by 2002:a17:906:90c9:: with SMTP id v9mr6570465ejw.102.1621545531930; Thu, 20 May 2021 14:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621545531; cv=none; d=google.com; s=arc-20160816; b=BmZxgBWyHmpl5BA+xJudx0pY5GHSEJxFWSt/v7CbScs63g7kJHPJYmwa4f00iRYVuT bkHKP+uG4akRVOQCtAAUsa6W8knIksbuCqsd65vDDXBOYabLUg3eAaFHq/CzZzSDvkVG D6uMXxLfdDy2lyOzt4ZXllrh4NHXMOV4uUGrYhJTnMlebsUTsD4CSJEIjbCmmVu6HfAx KGIiYlYVzZsFuqKfCwMZ+Ycm1wUHxFnsf5uiHwIMcxpoN+hK/PU1kcWq5dqyu8daWET8 AvMiMFlq6hjJiaB/9D9UPU7b/o5cqyHok974yM0qlGNUTXOdC4DOynxok5ua+k3W368D oh0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GEHpdtI5zEacI+Av8QO1tN9f3rdgpvWxzTQLlT66C8A=; b=x269hq1yXmRTgGUEx+uat+mi/6DLGHLGzGTBUEbJ3DUc5KdmD+RvxDlDPB+DnNcg8p hHUn3EcLmkUKlY+7uDkMnHyMGbZHTHV6ciERnyn/WNhLBFOn5v6S6IZnaTkQGiSbuuuf gq6SXxqeC+UG73v3b7Iz2lefRXQcm17Hg/eq7ld9/YPquF8tiW37hqDPqcGspsbZBeGo 6SynDaGPuW6/ecwL07GFVKMTYglyjl+A+k8JNY+C/lgEx9e00wv729LjpATEOg1ZtCZa Z+VVTCI5VMIDu8yiHpYaHqDFzHPOEsg+8Goi/GDd+51q7nD+0qiQWVaSbLlFidMgG7AX 9FFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="SsgRMq2/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zg9si4077854ejb.436.2021.05.20.14.18.28; Thu, 20 May 2021 14:18:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="SsgRMq2/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238428AbhETLC5 (ORCPT + 99 others); Thu, 20 May 2021 07:02:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:43872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238121AbhETKoW (ORCPT ); Thu, 20 May 2021 06:44:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4CC3F61C9D; Thu, 20 May 2021 09:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504626; bh=dh175F8KQU04S24NUHvgMK/FkX88h9zpiRWP3KuMN+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SsgRMq2/JeLtTJFVXuiuJVudduMdXNaI8Pv6R/m+YRIbpfCRcqdyC1Hw9vZJL9uL1 W4oE3z+oMB74MKd2qG2LAaa9zCaDnKqHTMV79tNiWw5x747ZGC6RwUVQvHfLI7zRmE PNthGikh82r80NTSoSdTuZbMsq9wekDLA7yTuVHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 4.14 312/323] Input: silead - add workaround for x86 BIOS-es which bring the chip up in a stuck state Date: Thu, 20 May 2021 11:23:24 +0200 Message-Id: <20210520092130.940427193@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit e479187748a8f151a85116a7091c599b121fdea5 ] Some buggy BIOS-es bring up the touchscreen-controller in a stuck state where it blocks the I2C bus. Specifically this happens on the Jumper EZpad 7 tablet model. After much poking at this problem I have found that the following steps are necessary to unstuck the chip / bus: 1. Turn off the Silead chip. 2. Try to do an I2C transfer with the chip, this will fail in response to which the I2C-bus-driver will call: i2c_recover_bus() which will unstuck the I2C-bus. Note the unstuck-ing of the I2C bus only works if we first drop the chip of the bus by turning it off. 3. Turn the chip back on. On the x86/ACPI systems were this problem is seen, step 1. and 3. require making ACPI calls and dealing with ACPI Power Resources. This commit adds a workaround which runtime-suspends the chip to turn it off, leaving it up to the ACPI subsystem to deal with all the ACPI specific details. There is no good way to detect this bug, so the workaround gets activated by a new "silead,stuck-controller-bug" boolean device-property. Since this is only used on x86/ACPI, this will be set by model specific device-props set by drivers/platform/x86/touchscreen_dmi.c. Therefor this new device-property is not documented in the DT-bindings. Dmesg will contain the following messages on systems where the workaround is activated: [ 54.309029] silead_ts i2c-MSSL1680:00: [Firmware Bug]: Stuck I2C bus: please ignore the next 'controller timed out' error [ 55.373593] i2c_designware 808622C1:04: controller timed out [ 55.582186] silead_ts i2c-MSSL1680:00: Silead chip ID: 0x80360000 Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210405202745.16777-1-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/silead.c | 44 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index 7c0eeef29b3c..18c866129845 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -319,10 +320,8 @@ static int silead_ts_get_id(struct i2c_client *client) error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID, sizeof(chip_id), (u8 *)&chip_id); - if (error < 0) { - dev_err(&client->dev, "Chip ID read error %d\n", error); + if (error < 0) return error; - } data->chip_id = le32_to_cpu(chip_id); dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id); @@ -335,12 +334,49 @@ static int silead_ts_setup(struct i2c_client *client) int error; u32 status; + /* + * Some buggy BIOS-es bring up the chip in a stuck state where it + * blocks the I2C bus. The following steps are necessary to + * unstuck the chip / bus: + * 1. Turn off the Silead chip. + * 2. Try to do an I2C transfer with the chip, this will fail in + * response to which the I2C-bus-driver will call: + * i2c_recover_bus() which will unstuck the I2C-bus. Note the + * unstuck-ing of the I2C bus only works if we first drop the + * chip off the bus by turning it off. + * 3. Turn the chip back on. + * + * On the x86/ACPI systems were this problem is seen, step 1. and + * 3. require making ACPI calls and dealing with ACPI Power + * Resources. The workaround below runtime-suspends the chip to + * turn it off, leaving it up to the ACPI subsystem to deal with + * this. + */ + + if (device_property_read_bool(&client->dev, + "silead,stuck-controller-bug")) { + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + pm_runtime_allow(&client->dev); + + pm_runtime_suspend(&client->dev); + + dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\n"); + silead_ts_get_id(client); + + /* The forbid will also resume the device */ + pm_runtime_forbid(&client->dev); + pm_runtime_disable(&client->dev); + } + silead_ts_set_power(client, SILEAD_POWER_OFF); silead_ts_set_power(client, SILEAD_POWER_ON); error = silead_ts_get_id(client); - if (error) + if (error) { + dev_err(&client->dev, "Chip ID read error %d\n", error); return error; + } error = silead_ts_init(client); if (error) -- 2.30.2