Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp302656imw; Tue, 12 Jul 2022 20:45:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vPopsTstFJug+GCZy/cYqKciAPjEy9b34i99AcuI6+aS/yunEoBCylVdTWXlZ392Aa+lrb X-Received: by 2002:a17:907:b590:b0:72b:949c:c737 with SMTP id qx16-20020a170907b59000b0072b949cc737mr1363008ejc.155.1657683939602; Tue, 12 Jul 2022 20:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657683939; cv=none; d=google.com; s=arc-20160816; b=05KJ/ZFNiUfRvXKsYwhzMGzTLobc7/CpKcdaLSe9yO8mWS+Rszx+xCaoq4/D/hMtdt 7kN5P5F0ccUzHfvftkpxLPAy4wp2UBdPzr/zYCeXlgfMzU6OwFtljiqjePcnZFlFeR5y dueHsKd0vLimPEDk+roJpgDu53Chs9oCisF4s9zQKIc85LV/7Iszs9S+MlU3QV6ysc7+ Dpuw9Y0rYNw+GDAH0mPugcXOj83QnVnVaiw2ArH6m0kH0HGiaBJ5c7mvLg828M+8K2Yy LeaAH1H0KsskWCbywJIiW5CHPrbJLupJLsIeETz3N7nCl6mujr6ZGLjeFQ0Or+bKCLkK MJaw== 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 :message-id:date:subject:cc:from; bh=LQYNu74f3ZK+5EiUFwiKgJfx/Mdq/39rYiIssuEIkrA=; b=qEAOMiGXxQPBS4dlqfqGKlHqYmjN4G9hVH8AqeX3zwaAr5G03OLG1NeHV7DpzfdlI5 YL4rBf9jGk3QBforzh/zhCWh/IqAjECBF4thpsMOuIqfQE9dulNQvIPoMQWu48tLhKRf s20ByRyjYzJWF5ZYlta584yHW3Y04JQ6gE+NxNlckP+E0uweQlOqmUzguNGpCHgnJMxy HPfHON6R3VnPRJS1RTVniD14cSRL9L7GNCbgtY6y/cQUYr1Alq+EQsnF/6Bv/lTPaw9h KaWOcoXHnSprDikQE32bzlpl7p55FAZg/5VS2PkDNbOoxhdtg7cKRkb6BCTzV6go9GFU SBWQ== 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 b14-20020a056402350e00b0043ac55ccf10si18042810edd.620.2022.07.12.20.44.42; Tue, 12 Jul 2022 20:45:39 -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 S230368AbiGMDQN (ORCPT + 99 others); Tue, 12 Jul 2022 23:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbiGMDQK (ORCPT ); Tue, 12 Jul 2022 23:16:10 -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 8834CD7A4D for ; Tue, 12 Jul 2022 20:16:07 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 13 Jul 2022 11:16:06 +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 26D3G1r5010517; Wed, 13 Jul 2022 11:16:01 +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; Wed, 13 Jul 2022 11:16:00 +0800 From: allen CC: Allen Chen , Jau-Chih Tseng , Kenneth Hung , Hermes Wu , Pin-yen Lin , 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] drm/bridge: it6505: Add i2c api power on check Date: Wed, 13 Jul 2022 11:15:47 +0800 Message-ID: <20220713031547.11641-1-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 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: 24D321129413D9267E4F3E545413DC97FAB72075DC9AC9B6D9DBCF0786A3E6E42002:8 X-MAIL: mse.ite.com.tw 26D3G1r5010517 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