Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp670256pxb; Tue, 5 Apr 2022 18:06:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzqrxW4J2IMM8JfFMhM2GoMwbf+O1De3QpawzsUVgkcCFWESOZzKg1YQY/mrtE6mr3clj9 X-Received: by 2002:a17:907:2daa:b0:6da:924e:955 with SMTP id gt42-20020a1709072daa00b006da924e0955mr6070887ejc.1.1649207181390; Tue, 05 Apr 2022 18:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207181; cv=none; d=google.com; s=arc-20160816; b=IIz/EaTScPldU0bO/fo3dbE1aQXw0G5bvqxoSeAEGeag5K+4IA+moG4TWiVthXjtU5 3YsnnamyKc/CRx8Fy0FBsmFLuMlRJS5bGtZh7pJ4CRAbNu28YOkNrrBDXyjYC9xqSl0z LSTSb42IO1RH9MYG6hn+C60pNXI7tSFZQEagxFiypPvZtpY801SoNimOtsoS/5VKIWP8 CEPpyRZx01odIb2THYv8kQdaVU89DhU5/fB/a7oOAftxbGS4pqM6R0CBSZYjT0GGY/7G S0NcJZgo2re8mff2iEFXzvBO+07ulUQdkZdzM+BT8WtSTWSPzVvJBtJ3tsuJCKxepAC8 XZwQ== 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=q8P03D/8wmL4dTaKoJ5N+irMkgerJM81/owtScPGR90=; b=CKLgEnQC/EkfTj8LDlwoWXvxoG6fvHfliqkTACLqtPG0aKGFwnTmCL0iGgaAkGexwc 5v9A+YjHhAzAraP7U+5yhm2lqd2KOfyHIjrpPiP0p+vEGCGkM1em0P6mRx8sgLSxDAR5 2eFUs8XY2T13qpOJsn/HWmnbXAbk2Y3sL0NRG9MJvmXA2XMIxv2KlR5usNwLItrdZ7yr svXjcidL+jl3M3aCDtZUUvmpltGfFdeMlqHI/nO+FY6xWkAU+8bDKGo7OnZnm58hqaHD 39/KuexcnBGDML8APjAYk/hZ19uiBmH4ygYvjkZJcqqf3QguuYowVurUfVt1PoMENVrc stkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V1zU3BOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tl12-20020a170907c30c00b006e8007492a4si4001643ejc.488.2022.04.05.18.05.56; Tue, 05 Apr 2022 18:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V1zU3BOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1381697AbiDENOn (ORCPT + 99 others); Tue, 5 Apr 2022 09:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344236AbiDEJSy (ORCPT ); Tue, 5 Apr 2022 05:18:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9731D47545; Tue, 5 Apr 2022 02:06:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2773161572; Tue, 5 Apr 2022 09:06:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3526AC385A0; Tue, 5 Apr 2022 09:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149560; bh=PaGBNH3IO+vHhfj5CQrJJiXJVdx0NKXBLXt6WjCBSr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1zU3BOnugZmeyj1XKtOxk5XuJ2WZm7AHF87oAEAQEzqsasYqAcZppHcssQt1JbiW k6Z7d449V/uGkw5rrFiBIWt3ai8aTSzGYWdCRx9aoZDb6VSNkQKjt2T4lQ7cj12ZKY lVGcJiWdyC+KaAOKhNTHryXIdkq9n5HF7lwLuJYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Detlev Casanova , Mark Brown , Sasha Levin Subject: [PATCH 5.16 0752/1017] regulator: rpi-panel: Handle I2C errors/timing to the Atmel Date: Tue, 5 Apr 2022 09:27:45 +0200 Message-Id: <20220405070416.582403822@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Stevenson [ Upstream commit 5665eee7a3800430e7dc3ef6f25722476b603186 ] The Atmel is doing some things in the I2C ISR, during which period it will not respond to further commands. This is particularly true of the POWERON command. Increase delays appropriately, and retry should I2C errors be reported. Signed-off-by: Dave Stevenson Signed-off-by: Detlev Casanova Link: https://lore.kernel.org/r/20220124220129.158891-3-detlev.casanova@collabora.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- .../regulator/rpi-panel-attiny-regulator.c | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/rpi-panel-attiny-regulator.c b/drivers/regulator/rpi-panel-attiny-regulator.c index ee46bfbf5eee..991b4730d768 100644 --- a/drivers/regulator/rpi-panel-attiny-regulator.c +++ b/drivers/regulator/rpi-panel-attiny-regulator.c @@ -37,11 +37,24 @@ static const struct regmap_config attiny_regmap_config = { static int attiny_lcd_power_enable(struct regulator_dev *rdev) { unsigned int data; + int ret, i; regmap_write(rdev->regmap, REG_POWERON, 1); + msleep(80); + /* Wait for nPWRDWN to go low to indicate poweron is done. */ - regmap_read_poll_timeout(rdev->regmap, REG_PORTB, data, - data & BIT(0), 10, 1000000); + for (i = 0; i < 20; i++) { + ret = regmap_read(rdev->regmap, REG_PORTB, &data); + if (!ret) { + if (data & BIT(0)) + break; + } + usleep_range(10000, 12000); + } + usleep_range(10000, 12000); + + if (ret) + pr_err("%s: regmap_read_poll_timeout failed %d\n", __func__, ret); /* Default to the same orientation as the closed source * firmware used for the panel. Runtime rotation @@ -57,23 +70,34 @@ static int attiny_lcd_power_disable(struct regulator_dev *rdev) { regmap_write(rdev->regmap, REG_PWM, 0); regmap_write(rdev->regmap, REG_POWERON, 0); - udelay(1); + msleep(30); return 0; } static int attiny_lcd_power_is_enabled(struct regulator_dev *rdev) { unsigned int data; - int ret; + int ret, i; - ret = regmap_read(rdev->regmap, REG_POWERON, &data); + for (i = 0; i < 10; i++) { + ret = regmap_read(rdev->regmap, REG_POWERON, &data); + if (!ret) + break; + usleep_range(10000, 12000); + } if (ret < 0) return ret; if (!(data & BIT(0))) return 0; - ret = regmap_read(rdev->regmap, REG_PORTB, &data); + for (i = 0; i < 10; i++) { + ret = regmap_read(rdev->regmap, REG_PORTB, &data); + if (!ret) + break; + usleep_range(10000, 12000); + } + if (ret < 0) return ret; @@ -103,20 +127,32 @@ static int attiny_update_status(struct backlight_device *bl) { struct regmap *regmap = bl_get_data(bl); int brightness = bl->props.brightness; + int ret, i; if (bl->props.power != FB_BLANK_UNBLANK || bl->props.fb_blank != FB_BLANK_UNBLANK) brightness = 0; - return regmap_write(regmap, REG_PWM, brightness); + for (i = 0; i < 10; i++) { + ret = regmap_write(regmap, REG_PWM, brightness); + if (!ret) + break; + } + + return ret; } static int attiny_get_brightness(struct backlight_device *bl) { struct regmap *regmap = bl_get_data(bl); - int ret, brightness; + int ret, brightness, i; + + for (i = 0; i < 10; i++) { + ret = regmap_read(regmap, REG_PWM, &brightness); + if (!ret) + break; + } - ret = regmap_read(regmap, REG_PWM, &brightness); if (ret) return ret; @@ -166,7 +202,7 @@ static int attiny_i2c_probe(struct i2c_client *i2c, } regmap_write(regmap, REG_POWERON, 0); - mdelay(1); + msleep(30); config.dev = &i2c->dev; config.regmap = regmap; -- 2.34.1