Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3417910imw; Thu, 7 Jul 2022 01:09:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2+0i2QbgGEiMzxmPqgmgVgByTbWEv2CB09cJ0YcVP+ZyEvbjOOu1kS1tL6UGtXoROYH4J X-Received: by 2002:a17:907:c0f:b0:726:3172:5eea with SMTP id ga15-20020a1709070c0f00b0072631725eeamr43546387ejc.110.1657181368215; Thu, 07 Jul 2022 01:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657181368; cv=none; d=google.com; s=arc-20160816; b=tROdPMF/0gNN9nzzZNlqixLB6rfdFjwEj9VaOZMTPzy+BQGxnbu9esCk04ShJ5fis9 mIPLQwmc1UWZ0xJ9j14eiipnvsi22fcUNajkaXEyUibNMA6jrGo5MHuqizZMYfojLlkN SNxGf06UuL34X1+K9ZW3hbZQ8mm9yUjcbWQX2a2t61sg7fhNE+FeGlzLs4gQLqzXAc0p ywfwiyziaR1czDIJbjVqXiPZLcwdMY3ola3ASop4XN5A/z7ykiusf1o6MLJyltANHJct SsT3UxghrYrpU3lF22WVBmgjeP7kGMQgrK8OF9h2qFSBubWJ2gRFV150H/TV+sfHryPG Gc0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=FhbVHTGQwlxqzRY/3kOH4SwPu880xp63qBjGrOiBzes=; b=Okl3CUTNVN1Bt5ma2C9cPcrX79mValUiY66X1RhGgZISvNL+GBpBGZlb9905Tg8csq l6rrOfDwibNQO5RF56qFGdZcuqX6VHi9zeVmrjAPvjqFfzzLaQ3JdhBzF78Wp1X4LfNB nTpjAjhyVh4u/Ru4kuY2TX2uqqVO5eDdaONoRzYsFG5mHO/eks4gF3WkropxT1AqpGA1 /i75xFrfkG7QbbTkD5uWCUK9fxts1uTiziPJEM9MfK6yYDvMcKxRz7Mkke8IMOIxh9FX AbZxcNJ/LwdlL4j5DxZTvfzp8BsxtEejQjU0IGqYRd4F4ml8gu44mOcquByCZPDSpRX5 sZgg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a0564021e8800b00437a34192cbsi490927edf.283.2022.07.07.01.09.03; Thu, 07 Jul 2022 01:09:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235180AbiGGIGe (ORCPT + 99 others); Thu, 7 Jul 2022 04:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235169AbiGGIG3 (ORCPT ); Thu, 7 Jul 2022 04:06:29 -0400 Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5630133E19 for ; Thu, 7 Jul 2022 01:06:28 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 07 Jul 2022 16:06:27 +0800 Received: from CSBMAIL1.internal.ite.com.tw (CSBMAIL1.internal.ite.com.tw [192.168.65.58]) by mse.ite.com.tw with ESMTP id 26786Klf042546; Thu, 7 Jul 2022 16:06:20 +0800 (GMT-8) (envelope-from allen.chen@ite.com.tw) Received: from VirtualBox.internal.ite.com.tw (192.168.70.46) by CSBMAIL1.internal.ite.com.tw (192.168.65.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Thu, 7 Jul 2022 16:06:20 +0800 From: allen CC: Allen Chen , Pin-yen Lin , Jau-Chih Tseng , Kenneth Hung , Hermes Wu , Pin-Yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH 2/3] drm/bridge: it6505: Add i2c api power on check Date: Thu, 7 Jul 2022 16:05:58 +0800 Message-ID: <20220707080600.49041-3-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707080600.49041-1-allen.chen@ite.com.tw> References: <20220707080600.49041-1-allen.chen@ite.com.tw> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.70.46] X-ClientProxiedBy: CSBMAIL1.internal.ite.com.tw (192.168.65.58) To CSBMAIL1.internal.ite.com.tw (192.168.65.58) X-TM-SNTS-SMTP: 65C89C8E9758456EEA011C9066CF6AC2432360222AE917257AC02F0206FA3DCD2002:8 X-MAIL: mse.ite.com.tw 26786Klf042546 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: allen chen Use i2c bus to read/write when it6505 power off will occure i2c error. Add this check will prevent i2c error when it6505 power off. Signed-off-by: Pin-Yen Lin Signed-off-by: Allen Chen --- drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index aa5e0aa1af85..cfd2c3275dc5 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -518,6 +518,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr) int err; struct device *dev = &it6505->client->dev; + if (!it6505->powered) + return -ENODEV; + err = regmap_read(it6505->regmap, reg_addr, &value); if (err < 0) { dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err); @@ -533,6 +536,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr, int err; struct device *dev = &it6505->client->dev; + if (!it6505->powered) + return -ENODEV; + err = regmap_write(it6505->regmap, reg_addr, reg_val); if (err < 0) { @@ -550,6 +556,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg, int err; struct device *dev = &it6505->client->dev; + if (!it6505->powered) + return -ENODEV; + err = regmap_update_bits(it6505->regmap, reg, mask, value); if (err < 0) { dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d", @@ -2553,13 +2562,12 @@ static int it6505_poweron(struct it6505 *it6505) usleep_range(10000, 20000); } + it6505->powered = true; it6505_reset_logic(it6505); it6505_int_mask_enable(it6505); it6505_init(it6505); it6505_lane_off(it6505); - it6505->powered = true; - return 0; } -- 2.25.1