From patchwork Tue Oct 19 16:07:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhui Zhao X-Patchwork-Id: 12570521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 858E6C433EF for ; Tue, 19 Oct 2021 16:09:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5335C60F02 for ; Tue, 19 Oct 2021 16:09:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5335C60F02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-ID:Mime-Version:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8i0JDBuYbuaJvFKBUR2e5d6333Lx5OpoYAkM/V6uuzE=; b=xqjv0ZIVZsO7+e BfPLWdObgBZe47HrYK0voysHV58ujW4ZRaW7773+cbftQL/kxcHpkJNxLm2rWZMoKRzuo2tcycK3O 7noyINcMN8FENzmktLya3nXQx5TE9zTwa/+uTfGJ5mv678jOj+l2/tQuec+NhT9QXVfsQGPYUbdWo 29kg6xUArFRfW5Yr2iK3B6crq07MwpArrNZUtOar//EmvmGw0YY9j3Po8BACfLFXn4MbbzOnlk1nq TCMtnl9krDFjShIotejGFqGrNbH5swlAyTRMLE1C3RZ7IEbvsv9fZCbFEb5KF/ry8NSchdHI6ITi9 5gen/X+oBz1BGdWzd9gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcrgM-001r6H-Fb; Tue, 19 Oct 2021 16:09:42 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcre5-001puS-Jm; Tue, 19 Oct 2021 16:07:23 +0000 Received: by mail-pl1-x634.google.com with SMTP id 21so13969635plo.13; Tue, 19 Oct 2021 09:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:mime-version:message-id :content-transfer-encoding; bh=9nKO5MBR4+kd0HJ32kWDjjupmN6pRGPGsMDzDplVOvc=; b=OR/bROCSq3bOlD4iij6cTHHxAZvsqvk1aiDeAhj0vVDqc+JYbPlhG4b5aLnKjO9M0F UbJG4CIGlf/EWCDZ0awppV7uGbToiV8/4DS4jRifHiOZScqZjthv3dvaDOgKke04eNwu NwDzcCJm6Ayqk2V+KvG/LiBNbsIWOMy6k33JLPko8+bfxUMc+0EfLU7MARKxCxwnmlwv lvINqNnQeEhvR02vkeApn+KnWtK7khduVgbohP2Q+Qmud1y+0j+OP0LUyIuVw96Nxir8 MdXh93/rSeIrlrDxN54xIVIGXH2ApHrxWr3PEHuA1i6mTzqU3Wg+KvMqg1/ugjDvOcki 1SfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:mime-version:message-id :content-transfer-encoding; bh=9nKO5MBR4+kd0HJ32kWDjjupmN6pRGPGsMDzDplVOvc=; b=NmnXodDFZPh32CHAKwiQP/vuO54cUuPglK7ofIDBLPV5+A/sqjYcgj1Z05fF7OQTHW rPNMBS2zH4sCI11DQwcLE2cPX952UAp1aDrhn5NJHy2dTHSrHlic0eTBPio7CMq67u9F hu/AA9puioS6wpGB+3Kv/sdvBSfY9aGoFPYU0VX/meFDESNcKTYK4Iwat4UEsEVau6Ot zAjEZNHP22IqBKYawc68LMZJePdoiwi9BeCyp14B925Nu4gA9QC20y0g1kU8LgNJcPhD mbEv/BqEHiNgSoRPPYAplPC4WsqrUuCEzafZvd/ry36BkPY9oVh1tWJ4TncYzrCGLNhN ydXw== X-Gm-Message-State: AOAM53174mlw2KZPzi6WMwH5Z0io/7B2qeQmDexZI1b+sO9MOYFuccgp 7qMNJKNmVa/lysWq3/RPIdQdQClzBhBPqA== X-Google-Smtp-Source: ABdhPJznPURueeiRev5x7DrHOelLkHIzxaJ23QRRfr/hyvKHWpOaeYT/A0GkEMuK6vKysLb2eGSpXg== X-Received: by 2002:a17:902:6ac4:b0:13f:52e1:8840 with SMTP id i4-20020a1709026ac400b0013f52e18840mr33719062plt.15.1634659638362; Tue, 19 Oct 2021 09:07:18 -0700 (PDT) Received: from DESKTOP-O1J7GSD (211-21-92-117.hinet-ip.hinet.net. [211.21.92.117]) by smtp.gmail.com with ESMTPSA id t14sm16062502pga.62.2021.10.19.09.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Oct 2021 09:07:17 -0700 (PDT) Date: Wed, 20 Oct 2021 00:07:16 +0800 From: "zhaojh329@gmail.com" To: sr Cc: matthias.bgg , linux-i2c , linux-arm-kernel , linux-mediatek , linux-kernel Subject: [PATCH] i2c: mt76xx: add I2C_FUNC_NOSTART and I2C_M_REV_DIR_ADDR X-Priority: 3 X-GUID: 4D9ECA36-F416-4365-8968-CACAFDFE0424 X-Has-Attach: no X-Mailer: Foxmail 7.2.21.453[cn] Mime-Version: 1.0 Message-ID: <202110200007146639874@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_090721_734708_8D8B1CBB X-CRM114-Status: GOOD ( 14.00 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This patch adds I2C_FUNC_NOSTART and I2C_M_REV_DIR_ADDR support for MediaTek MT7621/7628/7688. This is useful for some I2C slave chips, such as 'drivers/input/joystick/as5011.c'. Signed-off-by: Jianhui Zhao Reviewed-by: Stefan Roese --- drivers/i2c/busses/i2c-mt7621.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c index 45fe4a7fe0c0..3d2763d9c090 100644 --- a/drivers/i2c/busses/i2c-mt7621.c +++ b/drivers/i2c/busses/i2c-mt7621.c @@ -150,6 +150,9 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, for (i = 0; i < num; i++) { pmsg = &msgs[i]; + if (pmsg->flags & I2C_M_NOSTART) + goto nostart; + /* wait hardware idle */ ret = mtk_i2c_wait_idle(i2c); if (ret) @@ -174,6 +177,8 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } else { /* 7 bits address */ addr = i2c_8bit_addr_from_msg(pmsg); + if (pmsg->flags & I2C_M_REV_DIR_ADDR) + addr ^= 1; iowrite32(addr, i2c->base + REG_SM0D0_REG); ret = mtk_i2c_master_cmd(i2c, SM0CTL1_WRITE, 1); if (ret) @@ -187,6 +192,7 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, goto err_ack; } +nostart: /* transfer data */ for (len = pmsg->len, j = 0; len > 0; len -= 8, j += 8) { page_len = (len >= 8) ? 8 : len; @@ -242,7 +248,8 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, static u32 mtk_i2c_func(struct i2c_adapter *a) { - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR + | I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_NOSTART; } static const struct i2c_algorithm mtk_i2c_algo = {