Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3982571pxb; Tue, 25 Jan 2022 00:37:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdWQ67qI32Wcdm6Cd90+hmjwN5av+bHN66I2nyZABzPR1Jikvp57qeLLNsq9hQnuUjSwXI X-Received: by 2002:a05:6402:524f:: with SMTP id t15mr5183769edd.276.1643099864347; Tue, 25 Jan 2022 00:37:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099864; cv=none; d=google.com; s=arc-20160816; b=tKej6wF5gxduIISyha2cerh4W/1o78N24TE2K5o0AxhEPd5NfehRxbNBtukphN4Ac/ UwN3jeiQjbokXS1p7BL0lDoxtw34hc+9rH+jljSxXyGRkWF3J9H96tPt9zO4o5Jw5B8o 5AxRM1mLrKrP2o+dEljXbuvTOIG3DtnZ2IP7IhxeT8VaDItx9FJsLT5Y1mLqjkPm1Hxu nVPdHVFypYicaYgK9s4Om2acsulh0cLPonu1p9Yrnbc+43OFk3xvp5KPpBUapXJZsYh1 dKF3We3zInUkqeW91wo3sn3dafeLY2Sp4QsVuIWV/lYq+DsGSVFLwo9k4R1nehj0E6EP K9EA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v0g5pomCaZ/Z8bQZ/6si1/uRaJAjxcn6n+EBLoakR+Q=; b=tascJ2j4kHJCA2+bR9zH0lYmYrJclFHOBXITXdoOTRUGMWa/I/zTO4biQWWxs0wgoc yDim0SAszBNHv6nNW4R2C7PsNMyV4FrQ7P5MDNb+6RRO4VDVmUjl61RZpjV771IjVQ/o dIHkHwJfsGs/0jh1KsJf06iYrFUsU1+xVvQJcchshpVIWO2HB1hBW3/jjXztC2o0YG9B SyQLBa/qX84egCuJZx2Y6kMW8cnSjbxslaQzyMy2tztWjPr0ZTpYvrrK5hL8G9bvaIvD nFhq4YykXtn50QghVGl8HcQRemJlRj5FBrkmO6MmcgpXZV2NEHnFOy+iM0zEYaxy3ajD zwjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=c0sPGnx5; 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw12si941885ejc.992.2022.01.25.00.37.19; Tue, 25 Jan 2022 00:37:44 -0800 (PST) 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=@collabora.com header.s=mail header.b=c0sPGnx5; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1315570AbiAYCxt (ORCPT + 99 others); Mon, 24 Jan 2022 21:53:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2374224AbiAYAQc (ORCPT ); Mon, 24 Jan 2022 19:16:32 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0DFDC038AF1 for ; Mon, 24 Jan 2022 14:01:41 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: detlev) with ESMTPSA id E1DB41F438F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1643061700; bh=Aho1tR4hmf+9rCfrJot4fBHsOTXqSf7FX4Duswh2g2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c0sPGnx59UbDM0j9YK830cyRBXWpZpelPvzc/PkIkz0U9CLcoLwmedLjofkTecKRC nzDyqZ3CONtZEveFqKq3F22m5OC0TJctHgC2T7JBmHtzv4NA2aDwGU3GmWAWKjY6uh KBDk0hTeN8l0sac1F0Wk8KX+TP5Hoi1epLwDiBrGdu0kSNk0BIsjnYAgPUamfBuTmI g1bQ6PMM+0pKnqiyBiqXAKmk0okbn7cNyfsQtkRNS+THApXH+Qa+qnZD+wfLAbaOR+ DhibbQ8yelG8n8j8P9jaSnf5Ye/6yDgxFA45R3viE+yPPPODP2nrdR6HPoN0CGHiNK THTRQ8w1KdCQQ== From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Dave Stevenson , Liam Girdwood , Mark Brown , Detlev Casanova Subject: [PATCH v3 2/9] regulator: rpi-panel: Handle I2C errors/timing to the Atmel Date: Mon, 24 Jan 2022 17:01:22 -0500 Message-Id: <20220124220129.158891-3-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124220129.158891-1-detlev.casanova@collabora.com> References: <20220124220129.158891-1-detlev.casanova@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Stevenson 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 --- .../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 370b9ae363dd..00fb69efcfa2 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