Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp34152imw; Thu, 14 Jul 2022 19:52:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sStV7s61gPK7tKhjhkE5aMzZQ8xCzJPO9nqxim38tNQ7CZ2+WxKkQq33J1ppjrgq8rz7VE X-Received: by 2002:a17:907:d18:b0:726:3172:2266 with SMTP id gn24-20020a1709070d1800b0072631722266mr11566583ejc.476.1657853541395; Thu, 14 Jul 2022 19:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657853541; cv=none; d=google.com; s=arc-20160816; b=thvqTET1xs/4IxLWNdSCO9On4vsPOX5WAU8fMaitx7wy3+6VngzShY4QQrSGu0gy+y Oq7zoZJinn8to0WbwKexy8kj0YPHY9yQj5FC935cieLT2BYx6jBdrSAr5CjuepZnNI1Q niJ44pCf/s/iUIrOkdzIkbJ/tH4FuWYcbbUx7s2OPdG5HPtsVg9aU9ILHbN12lsGbNrm pUmfmJbWiNw/5aoVdRgIi2+MJB36snHh/f8vDvIDKkh2b/lApfl47T5YQGOifWgDNatY bF57VXTUVFaPNkw4UW4e7e5uL0NZxCUEQsymDD0jWT0icUlwglja1QRtx+YiTFVpQgC8 SU4A== 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=LQYNu74f3ZK+5EiUFwiKgJfx/Mdq/39rYiIssuEIkrA=; b=zZ8P1dJrYRfia0RPCfFcs1/B0T1R/Wggzz6rBa1l+8p18obBgOkD9PtN3A/terQ8ZJ 1jgGt3BGAeTWNBXE7n2wkXjykY6DQsRkCa4zzMP4wQncz8Ju5Dbe3WCLmYZwC6RQ4uv2 nK7+AHHQCMoXLVHhLWypHrRcE1FYvRqJeyZFK3Uqb0keaRtnHfTHn69ihpDBiaZLrzlW uZgUfPuvciGPYnnlzttdd6Ch4kye8jpCFm3pCyc4Ca2oyG8wiDxvDRpKGfLOpi9RXENQ FYaRUrXrFLvN+E4g4RzK9ln5AROynk9SrQw8l7RMGP6CoZGt51RpwdqJFnpDK+MOc661 j/1Q== 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 sc36-20020a1709078a2400b0072ef491cc0dsi1695208ejc.113.2022.07.14.19.51.55; Thu, 14 Jul 2022 19:52: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; 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 S229481AbiGOCtg (ORCPT + 99 others); Thu, 14 Jul 2022 22:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbiGOCte (ORCPT ); Thu, 14 Jul 2022 22:49:34 -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 DCD5424F36 for ; Thu, 14 Jul 2022 19:49:31 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 15 Jul 2022 10:49:31 +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 26F2nQ63032753; Fri, 15 Jul 2022 10:49:26 +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; Fri, 15 Jul 2022 10:49:25 +0800 From: allen CC: Allen Chen , Pin-yen Lin , Jau-Chih Tseng , Kenneth Hung , Hermes Wu , Pin-Yen Lin , Robert Foss , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH v2 2/3] drm/bridge: it6505: Add i2c api power on check Date: Fri, 15 Jul 2022 10:49:06 +0800 Message-ID: <20220715024910.12578-3-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220715024910.12578-1-allen.chen@ite.com.tw> References: <20220715024910.12578-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: FE342235D5D606FBFE9926252360C7124313D0D4AF438AF7B04E58DB1883D1CD2002:8 X-MAIL: mse.ite.com.tw 26F2nQ63032753 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 occur i2c error. Add this check will prevent i2c error when it6505 power off. Signed-off-by: Pin-Yen Lin Signed-off-by: Allen Chen Reviewed-by: Robert Foss --- 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