Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp889919ybl; Thu, 22 Aug 2019 06:29:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy14n/uX5YJLnEbj5xFuQ6bjloIOm6CgNKv02FlvSZqIgbjN3g27qmJmhL4nyjl0RwYursP X-Received: by 2002:a63:9e54:: with SMTP id r20mr34761229pgo.64.1566480546205; Thu, 22 Aug 2019 06:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566480546; cv=none; d=google.com; s=arc-20160816; b=GdiqbyYrnZoLDvX6PFe3sN6bUylGxqevEa3LO9odapwKzuUioDVyklU6miovQakFpd A9rysOIY4lq4+11bnZS2QQJajGY1tx+A4DL4xipc524ZaLQBs4DwbzWGYElfIMMUL+9x MwUXO9k3+kFUpE6frwvS90SWJQYcnfFQMbP6YHbYFHK8L03NjZ9VpKc2ZxNlgLBj4uMU xDTa9MANYJYLaxxpVPSR96B8Axj4HZ/vc9msZ7MHRgPApF/Vt8w2RBnKxl18hOixJut0 Z+QiAhE0x2nJOS/GnGZsfRNBUMEAF+X4UwRvQxmOodp9TLV6QvZ1+A8i0wdwuDL6JB8c qMCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sgHEzZrPt9EteY2/QiFiyeYlRXQlrmCLZpXRsbYVLMM=; b=cX2aELdKIsA6Rxuk5md2bzanhAKf84LzpwAAXwhskkRUm9x8Unp6tCRsK9Kx7e6cgC V8q/idFzIKihuzKRKFZxZlRR5LN6/RRmAaAzwWgAVDA3z181yn+JifmGHsokwERZEDN5 mQ+OBlcMcwPrfcsmQ4W3XzxdwtnrZN/ZWRAup+7ZtE3wvmcInuhd7cAie+XSFXN9GXj5 ApbvRbnKFF3QavNvl1IIsCMaC7X23+yEysIKzTUDSb79ESFHrWMe/d2yTHpyT7dXVrK2 VPSz4MXMCHADKDjJCkLFpDU6vfqdWZq4cdODDCUNlVpjBJuS+FsyYz2+eY0oPymKhJwd 2Wzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="a9yy/07U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20si17081594plp.335.2019.08.22.06.28.51; Thu, 22 Aug 2019 06:29:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="a9yy/07U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731879AbfHVJpj (ORCPT + 99 others); Thu, 22 Aug 2019 05:45:39 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34657 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbfHVJpj (ORCPT ); Thu, 22 Aug 2019 05:45:39 -0400 Received: by mail-pf1-f195.google.com with SMTP id b24so3598727pfp.1 for ; Thu, 22 Aug 2019 02:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sgHEzZrPt9EteY2/QiFiyeYlRXQlrmCLZpXRsbYVLMM=; b=a9yy/07U4q9DkIrWE+1S1A5qGfmGOHr2Iah/Cwu7XTniDeBQidLmwEdnkTDXQM31RX HhXAwzTUtfbL7o0VP7LGkI+cz+lIG1ARIpBt7uaEM+lvwDLuY2LuYf4zfjpbXOzaKx1h ZskFoEcfaOXTiPrX0jOZiLZ1+rX1vte6oawec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sgHEzZrPt9EteY2/QiFiyeYlRXQlrmCLZpXRsbYVLMM=; b=ob8MJSegQVSDeaHBAQlyYDbxr7LaqacfUEp5Na+jSbafKTGqSzkzY7221fGnDNyzSZ 8XQBJXartKDoNPS5AmwOZ9WftKXs1NAQ4EDm0LnL8EGJPQdGASfU00KJr379d+LufaZt kgv4nqiPqKx2Vl791dFeBjM21I4Tm3Wqw1dHLwgEd730CMd8SKVMP0OYEVi0T5tNqeC1 TtN742nhix+quAO2wnaF+5jeXpH9PJJNdpP6w5ltwvNVTcAQ6/X0+BiqldTn4eKc3DLa Cd9GPQonnBF9851jxHpcUarOERB4C2F4moxtfOpMGMnlRe4wHmiShUogZ+RsRMUpqB7z decg== X-Gm-Message-State: APjAAAVOsBcjGWLLynGQXc9OgGYL73KIknd7W6mbx04iUQvLJ+VvKuB9 x/FflfQl5ez+2YBQjDydTA+2HQ== X-Received: by 2002:a65:6281:: with SMTP id f1mr31045994pgv.400.1566467138859; Thu, 22 Aug 2019 02:45:38 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id 4sm26154645pfn.118.2019.08.22.02.45.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Aug 2019 02:45:37 -0700 (PDT) From: Hsin-Yi Wang To: Wolfram Sang , Yingjoe Chen Cc: Matthias Brugger , Qii Wang , Nicolas Boichat , Jun Gao , Thomas Gleixner , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandru M Stan Subject: [PATCH v2] i2c: mediatek: disable zero-length transfers for mt8183 Date: Thu, 22 Aug 2019 17:45:17 +0800 Message-Id: <20190822094516.55130-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When doing i2cdetect quick write mode, we would get transfer error ENOMEM, and i2cdetect shows there's no device at the address. Quoting from mt8183 datasheet, the number of transfers to be transferred in one transaction should be set to bigger than 1, so we should forbid zero-length transfer and update functionality. Incorrect return: localhost ~ # i2cdetect -q -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- After this patch: localhost ~ # i2cdetect -q -y 0 Error: Can't use SMBus Quick Write command on this bus localhost ~ # i2cdetect -y 0 Warning: Can't use SMBus Quick Write command, will skip some addresses 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: 10: 20: 30: -- -- -- -- -- -- -- -- 40: 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: 70: Reported-by: Alexandru M Stan Signed-off-by: Hsin-Yi Wang --- Change from v1: * restore the order of algo and quirks --- drivers/i2c/busses/i2c-mt65xx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 252edb433fdf..29eae1bf4f86 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -234,6 +234,10 @@ static const struct i2c_adapter_quirks mt7622_i2c_quirks = { .max_num_msgs = 255, }; +static const struct i2c_adapter_quirks mt8183_i2c_quirks = { + .flags = I2C_AQ_NO_ZERO_LEN, +}; + static const struct mtk_i2c_compatible mt2712_compat = { .regs = mt_i2c_regs_v1, .pmic_i2c = 0, @@ -298,6 +302,7 @@ static const struct mtk_i2c_compatible mt8173_compat = { }; static const struct mtk_i2c_compatible mt8183_compat = { + .quirks = &mt8183_i2c_quirks, .regs = mt_i2c_regs_v2, .pmic_i2c = 0, .dcm = 0, @@ -870,7 +875,11 @@ static irqreturn_t mtk_i2c_irq(int irqno, void *dev_id) static u32 mtk_i2c_functionality(struct i2c_adapter *adap) { - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; + if (adap->quirks->flags & I2C_AQ_NO_ZERO_LEN) + return I2C_FUNC_I2C | + (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); + else + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } static const struct i2c_algorithm mtk_i2c_algorithm = { -- 2.20.1