From patchwork Thu Feb 2 09:41:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125631 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AE2D3C05027 for ; Thu, 2 Feb 2023 09:43:57 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PbQQpqOzZVcKi2DoUZiIaUa0VEYC3wb8y44HMjtZmeA=; b=0MlFvY8DEqkIN3 x8Dl0GyZ9t7kHC9eXG5EVRpg/7erNAJsR403L68IIEdPFlRHM6uk5eihE+Gh/yYUp0ULbigKr+rwE uMjVnicq2Nt+nCn0WikL1dxMKdscKhJq4A7MRKDM7F46rBs5E0o2AWX3QQtWn/wYX5Nv7ad4bj0Ex su94klxSNLIXyyB9AnlD1M/atXvuuxidriwf0NAB6CTOPV+/iemUx2xiMUCay8D/uhFtTSLxc8e/I Jd3kCDFd9MZl0W1QDhZA/2AK0whKDPW69Q1vTkXi4jRfCRProHyeQ2W0gpf2aQj2Ru9hNm4hI2PCP Dt77njbUILVNXviKYsWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7J-00FCpN-05; Thu, 02 Feb 2023 09:42:53 +0000 Received: from mail-mw2nam04on20608.outbound.protection.outlook.com ([2a01:111:f400:7e8c::608] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7F-00FCoJ-A4 for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:42:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bcELjFkHJKoDWEitUVjVgBPRlP09WpgGxkIJncpan/s1zbRo1bWcjpNoZT/4FxMm5jtmFtCFZ9uIWkQgrWzSgNsdpwjtWSRw3N3PadFfJ+/sg7MZ5RZbqaGfFfYoKLpSs8d9wleYrTbTjARUYrCiCOD6OzYU9ZjGKvEQzhWBge0UnnY37g1DmGek2u1icOju5R5ZmLu0enFa+RxdT+yz4xSIfGnWOeK0bGYPLRtPmR+57mlqbIaypKvgyGpCBG3r2Io8DA/s3lEUA1YsWae8DjZC6Yub2J/Caw4HtleWhhHESl4L1nX/089WbtE0SOLPAxhLtsoIMcGH7pw9WLV+6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9CDCtUY/Xlt4AAaJ94S7dea83SzgaWliGOFTqsANIgY=; b=edESK0oiZb2dxgyR2/4p10XcpJPXWj0u12g7NMfhwGIDpJqw5A92lHbNsNNeyODuCgXIgmMv42vcBTfgR5hupZdXy+Pxvvd5DEl9NH85M0MiqlQ4id/ExSBa6fIueRN8Mwq0Fe/Oo/a9cbb+pZwj36BPAAKLZCdasxZUzVtrMx7Q674mdRiz7u7XBkAuDzq9yjwMairkXeN5c3qJtrHvBrw9PfDoq5esDvDPrZ9gkD+hvBCOrpbehi/0p//Rk3XySL0gyq4Ow0na6L8WkKGHXeff/izYRHRM1oeVjVNqP3rUTfTt4wAaFXHCSxUk9z74+bl72grMF+sgihE52efZ4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9CDCtUY/Xlt4AAaJ94S7dea83SzgaWliGOFTqsANIgY=; b=P67cjxaZ1J3TTNP8//pvUU3rlJvthUF3KBq0gGkv+MCIvpwjaMFc+dp4tABJG6mQIuv+Z3pTmMx1zJCrVxQxW1q4lorMzRqJrOsMMg0SPoaPyL1VzMOGma53tR5oN96jvWQsK97fyDs0Onz9Lc6S9kXytghf3CBhimPI4dXzuMM= Received: from BN9PR03CA0160.namprd03.prod.outlook.com (2603:10b6:408:f4::15) by DM6PR02MB6923.namprd02.prod.outlook.com (2603:10b6:5:25e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Thu, 2 Feb 2023 09:42:44 +0000 Received: from BN1NAM02FT009.eop-nam02.prod.protection.outlook.com (2603:10b6:408:f4:cafe::4a) by BN9PR03CA0160.outlook.office365.com (2603:10b6:408:f4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:42:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT009.mail.protection.outlook.com (10.13.2.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.25 via Frontend Transport; Thu, 2 Feb 2023 09:42:43 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 01:42:33 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:42:33 -0800 Received: from [172.23.64.3] (port=36992 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW6y-0003IP-PV; Thu, 02 Feb 2023 01:42:33 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id AC1581055BA; Thu, 2 Feb 2023 15:12:21 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 1/9] i2c: xiic: Add standard mode support for > 255 byte Date: Thu, 2 Feb 2023 15:11:30 +0530 Message-ID: <1675330898-563-2-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT009:EE_|DM6PR02MB6923:EE_ X-MS-Office365-Filtering-Correlation-Id: a47abc7e-9097-475f-c729-08db0501d5ab X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I5c1Nu/j+JsFQF2F6nFSqrPNEyplXo0XNvqsr0NQpzjmAHBlks0gdfji+jYr3Cqdo4F7ro9XD0zhRLH+ujXZl9v8mkMK5ItgyoNvrZfD7n0Mxd5Xn6avEWD+7NMOqoXFMndhphGbgS4qx+h2Ql4CONdmQ/xkGCcKSIWYQBk9q82fN/U3DdL3d+92rVQRPpJdpHEtqD5naGj+Mw31r9PeifT6U9P4xoZ58yaNocVAgX7A4QAKxpv0c9DHFx2oQRfdNBYDwqPuQtSFw6AzSPIH2wSbMeB8FNln3Slanj0tVVhXOd6nkbVHJ7GiUjg1qreuDo2VdjYo0KY4mm5uCBmB6XFuT7PQ2thMwpm78laMa50noa5t1mo3V9hOEgGCrCCh5rjpL6vnldzo29RkKQWl1taOvpK1eNRqSg/bj7/PNWoUsALmt3piP8AG45RFXTfZ0vwM7Z9QGqnqp5tNC4ZGQeuNFNkiowyZdfaJthbN1etUHE7O6gA0nRRBwo3617OGoYRC1YigSjZJxnyfU9uxpuXeDlMjv81jCiuXTMDl3rOJKD7oby1FIJDG7DwUJUe8QIgrJeNpSFr/IR1JJUM9RJRkdRJs18TCa/GgWVh19HvU12RVL9md/VNX2mTCL4wxFa+smpws8kIBGtNhApPj6kEwB9ghOocbcPbTpkQbNjyjzFyw15BTrnmBcqchcPRg7OIzxQAUECDYznG+kVvRJaZoAtamJS4wA+VIfdxI5o0Mk90vU3XzvsKofqGhvgme X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(396003)(39860400002)(376002)(136003)(346002)(451199018)(36840700001)(40470700004)(46966006)(7416002)(5660300002)(6266002)(36756003)(40460700003)(30864003)(356005)(44832011)(26005)(186003)(83170400001)(82740400003)(107886003)(6666004)(2616005)(82310400005)(42186006)(316002)(54906003)(110136005)(7636003)(40480700001)(478600001)(70206006)(336012)(83380400001)(2906002)(42882007)(4326008)(8936002)(8676002)(36860700001)(70586007)(47076005)(41300700001)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:42:43.9405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a47abc7e-9097-475f-c729-08db0501d5ab X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT009.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6923 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014249_413540_FEB5A9B8 X-CRM114-Status: GOOD ( 31.18 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam read transfers Added standard mode for AXI I2C controller to enable read transfers of size more than 255 bytes. The driver selects standard mode in the following scenarios. 1. If a single message request comes from user space, requesting a read of more than 255 bytes 2. If a message set request comes from user space consisting of many messages and if any one of them is a read operation, irrespective of the size of transfer. (This is done because it is observed that repeated start operation is not happening in dynamic mode read as expected in a message set request from user space.) Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- Changes for v2: Merged the logic of xiic_std_fill_tx_fifo into xiic_fill_tx_fifo to remove duplicate code. Handled i2c msg->len == 0 case. Squashed "Use 'nmsgs' variable instead of repeated_start" patch. Squashed "Correct the BNB interrupt enable sequence" patch. Squashed "remove unsupported flag I2C_M_NOSTART code" patch. --- drivers/i2c/busses/i2c-xiic.c | 266 ++++++++++++++++++++++++++++------ 1 file changed, 225 insertions(+), 41 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index bee5a2ef1f22..839564054501 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -60,6 +60,7 @@ enum xiic_endian { * @clk: Pointer to AXI4-lite input clock * @state: See STATE_ * @singlemaster: Indicates bus is single master + * @dynamic: Mode of controller */ struct xiic_i2c { struct device *dev; @@ -76,6 +77,7 @@ struct xiic_i2c { struct clk *clk; enum xilinx_i2c_state state; bool singlemaster; + bool dynamic; }; #define XIIC_MSB_OFFSET 0 @@ -143,6 +145,9 @@ struct xiic_i2c { #define XIIC_TX_DYN_START_MASK 0x0100 /* 1 = Set dynamic start */ #define XIIC_TX_DYN_STOP_MASK 0x0200 /* 1 = Set dynamic stop */ +/* Dynamic mode constants */ +#define MAX_READ_LENGTH_DYNAMIC 255 /* Max length for dynamic read */ + /* * The following constants define the register offsets for the Interrupt * registers. There are some holes in the memory map for reserved addresses @@ -316,13 +321,14 @@ static void xiic_deinit(struct xiic_i2c *i2c) static void xiic_read_rx(struct xiic_i2c *i2c) { - u8 bytes_in_fifo; + u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; + u32 bytes_rem = 0; int i; bytes_in_fifo = xiic_getreg8(i2c, XIIC_RFO_REG_OFFSET) + 1; dev_dbg(i2c->adap.dev.parent, - "%s entry, bytes in fifo: %d, msg: %d, SR: 0x%x, CR: 0x%x\n", + "%s entry, bytes in fifo: %d, rem: %d, SR: 0x%x, CR: 0x%x\n", __func__, bytes_in_fifo, xiic_rx_space(i2c), xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); @@ -330,13 +336,52 @@ static void xiic_read_rx(struct xiic_i2c *i2c) if (bytes_in_fifo > xiic_rx_space(i2c)) bytes_in_fifo = xiic_rx_space(i2c); - for (i = 0; i < bytes_in_fifo; i++) + bytes_to_read = bytes_in_fifo; + + if (!i2c->dynamic) { + bytes_rem = xiic_rx_space(i2c) - bytes_in_fifo; + + if (bytes_rem > IIC_RX_FIFO_DEPTH) { + bytes_to_read = bytes_in_fifo; + } else if (bytes_rem > 1) { + bytes_to_read = bytes_rem - 1; + } else if (bytes_rem == 1) { + bytes_to_read = 1; + /* Set NACK in CR to indicate slave transmitter */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr | + XIIC_CR_NO_ACK_MASK); + } else if (bytes_rem == 0) { + bytes_to_read = bytes_in_fifo; + + /* Generate stop on the bus if it is last message */ + if (i2c->nmsgs == 1) { + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_MSMS_MASK); + } + + /* Make TXACK=0, clean up for next transaction */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_NO_ACK_MASK); + } + } + + /* Read the fifo */ + for (i = 0; i < bytes_to_read; i++) { i2c->rx_msg->buf[i2c->rx_pos++] = xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); + } - xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, - (xiic_rx_space(i2c) > IIC_RX_FIFO_DEPTH) ? - IIC_RX_FIFO_DEPTH - 1 : xiic_rx_space(i2c) - 1); + if (i2c->dynamic) { + u8 bytes; + + /* Receive remaining bytes if less than fifo depth */ + bytes = min_t(u8, xiic_rx_space(i2c), IIC_RX_FIFO_DEPTH); + bytes--; + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); + } } static int xiic_tx_fifo_space(struct xiic_i2c *i2c) @@ -360,7 +405,15 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c) if (!xiic_tx_space(i2c) && i2c->nmsgs == 1) { /* last message in transfer -> STOP */ - data |= XIIC_TX_DYN_STOP_MASK; + if (i2c->dynamic) { + data |= XIIC_TX_DYN_STOP_MASK; + } else { + u8 cr; + /* Write to CR to stop */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_MSMS_MASK); + } dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__); } xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); @@ -401,7 +454,9 @@ static irqreturn_t xiic_process(int irq, void *dev_id) dev_dbg(i2c->adap.dev.parent, "%s: SR: 0x%x, msg: %p, nmsgs: %d\n", __func__, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), i2c->tx_msg, i2c->nmsgs); - + dev_dbg(i2c->adap.dev.parent, "%s, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); /* Service requesting interrupt */ if ((pend & XIIC_INTR_ARB_LOST_MASK) || @@ -579,31 +634,101 @@ static int xiic_busy(struct xiic_i2c *i2c) static void xiic_start_recv(struct xiic_i2c *i2c) { u16 rx_watermark; + u8 cr = 0, rfd_set = 0; struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; + unsigned long flags; - /* Clear and enable Rx full interrupt. */ - xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); + dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); - /* we want to get all but last byte, because the TX_ERROR IRQ is used - * to inidicate error ACK on the address, and negative ack on the last - * received byte, so to not mix them receive all but last. - * In the case where there is only one byte to receive - * we can check if ERROR and RX full is set at the same time - */ - rx_watermark = msg->len; - if (rx_watermark > IIC_RX_FIFO_DEPTH) - rx_watermark = IIC_RX_FIFO_DEPTH; - xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, (u8)(rx_watermark - 1)); + /* Disable Tx interrupts */ + xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK | XIIC_INTR_TX_EMPTY_MASK); + + if (i2c->dynamic) { + u8 bytes; + u16 val; + + /* Clear and enable Rx full interrupt. */ + xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | + XIIC_INTR_TX_ERROR_MASK); + + /* + * We want to get all but last byte, because the TX_ERROR IRQ + * is used to indicate error ACK on the address, and + * negative ack on the last received byte, so to not mix + * them receive all but last. + * In the case where there is only one byte to receive + * we can check if ERROR and RX full is set at the same time + */ + rx_watermark = msg->len; + bytes = min_t(u8, rx_watermark, IIC_RX_FIFO_DEPTH); + + if (rx_watermark > 0) + bytes--; + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); + + local_irq_save(flags); - if (!(msg->flags & I2C_M_NOSTART)) /* write the address */ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, - i2c_8bit_addr_from_msg(msg) | XIIC_TX_DYN_START_MASK); + i2c_8bit_addr_from_msg(msg) | + XIIC_TX_DYN_START_MASK); + + /* If last message, include dynamic stop bit with length */ + val = (i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0; + val |= msg->len; + + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, val); + + xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); + + local_irq_restore(flags); + } else { + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + + /* Set Receive fifo depth */ + rx_watermark = msg->len; + if (rx_watermark > IIC_RX_FIFO_DEPTH) { + rfd_set = IIC_RX_FIFO_DEPTH - 1; + } else if (rx_watermark == 1) { + rfd_set = rx_watermark - 1; + /* Handle single byte transfer separately */ + cr |= XIIC_CR_NO_ACK_MASK; + } else if (rx_watermark == 0) { + rfd_set = rx_watermark; + cr |= XIIC_CR_NO_ACK_MASK; + } else { + rfd_set = rx_watermark - 2; + } + /* Check if RSTA should be set */ + if (cr & XIIC_CR_MSMS_MASK) { + /* Already a master, RSTA should be set */ + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_REPEATED_START_MASK) & + ~(XIIC_CR_DIR_IS_TX_MASK)); + } - xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); - xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, - msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); + /* Clear and enable Rx full and transmit complete interrupts */ + xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | + XIIC_INTR_TX_ERROR_MASK); + + /* Write the address */ + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, + i2c_8bit_addr_from_msg(msg)); + + /* Write to Control Register,to start transaction in Rx mode */ + if ((cr & XIIC_CR_MSMS_MASK) == 0) { + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_MSMS_MASK) + & ~(XIIC_CR_DIR_IS_TX_MASK)); + } + dev_dbg(i2c->adap.dev.parent, "%s end, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); + } if (i2c->nmsgs == 1) /* very last, enable bus not busy as well */ @@ -611,10 +736,15 @@ static void xiic_start_recv(struct xiic_i2c *i2c) /* the message is tx:ed */ i2c->tx_pos = msg->len; + + /* Enable interrupts */ + xiic_setreg32(i2c, XIIC_DGIER_OFFSET, XIIC_GINTR_ENABLE_MASK); } static void xiic_start_send(struct xiic_i2c *i2c) { + u8 cr = 0; + u16 data; struct i2c_msg *msg = i2c->tx_msg; dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, len: %d", @@ -623,24 +753,56 @@ static void xiic_start_send(struct xiic_i2c *i2c) __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); - if (!(msg->flags & I2C_M_NOSTART)) { + if (i2c->dynamic) { /* write the address */ - u16 data = i2c_8bit_addr_from_msg(msg) | - XIIC_TX_DYN_START_MASK; - if ((i2c->nmsgs == 1) && msg->len == 0) + data = i2c_8bit_addr_from_msg(msg) | + XIIC_TX_DYN_START_MASK; + + if (i2c->nmsgs == 1 && msg->len == 0) /* no data and last message -> add STOP */ data |= XIIC_TX_DYN_STOP_MASK; xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); - } - /* Clear any pending Tx empty, Tx Error and then enable them. */ - xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_ERROR_MASK | - XIIC_INTR_BNB_MASK | - ((i2c->nmsgs > 1 || xiic_tx_space(i2c)) ? - XIIC_INTR_TX_HALF_MASK : 0)); + /* Clear any pending Tx empty, Tx Error and then enable them */ + xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | + XIIC_INTR_TX_ERROR_MASK | + XIIC_INTR_BNB_MASK | + ((i2c->nmsgs > 1 || xiic_tx_space(i2c)) ? + XIIC_INTR_TX_HALF_MASK : 0)); + + xiic_fill_tx_fifo(i2c); + } else { + /* Check if RSTA should be set */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + if (cr & XIIC_CR_MSMS_MASK) { + /* Already a master, RSTA should be set */ + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_REPEATED_START_MASK | + XIIC_CR_DIR_IS_TX_MASK) & + ~(XIIC_CR_NO_ACK_MASK)); + } + + /* Write address to FIFO */ + data = i2c_8bit_addr_from_msg(msg); + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); - xiic_fill_tx_fifo(i2c); + /* Fill fifo */ + xiic_fill_tx_fifo(i2c); + + if ((cr & XIIC_CR_MSMS_MASK) == 0) { + /* Start Tx by writing to CR */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr | + XIIC_CR_MSMS_MASK | + XIIC_CR_DIR_IS_TX_MASK); + } + + /* Clear any pending Tx empty, Tx Error and then enable them */ + xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | + XIIC_INTR_TX_ERROR_MASK | + XIIC_INTR_BNB_MASK); + } } static void __xiic_start_xfer(struct xiic_i2c *i2c) @@ -701,6 +863,33 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (err < 0) return err; + /* Decide standard mode or Dynamic mode */ + i2c->dynamic = true; + + /* + * If number of messages is 1 and read length is > 255 bytes, + * enter standard mode + */ + + if (i2c->nmsgs == 1 && (i2c->tx_msg->flags & I2C_M_RD) && + i2c->tx_msg->len > MAX_READ_LENGTH_DYNAMIC) { + i2c->dynamic = false; + } else if (i2c->nmsgs > 1) { + int count; + + /* + * If number of messages is more than 1 and one of them is + * a read message, enter standard mode. Since repeated start + * operation in dynamic mode read is not happenning + */ + for (count = 0; count < i2c->nmsgs; count++) { + if (i2c->tx_msg[count].flags & I2C_M_RD) { + i2c->dynamic = false; + break; + } + } + } + err = xiic_start_xfer(i2c, msgs, num); if (err < 0) { dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); @@ -737,15 +926,10 @@ static const struct i2c_algorithm xiic_algorithm = { .functionality = xiic_func, }; -static const struct i2c_adapter_quirks xiic_quirks = { - .max_read_len = 255, -}; - static const struct i2c_adapter xiic_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_DEPRECATED, .algo = &xiic_algorithm, - .quirks = &xiic_quirks, }; static int xiic_i2c_probe(struct platform_device *pdev) From patchwork Thu Feb 2 09:41:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125632 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 07904C61DA4 for ; Thu, 2 Feb 2023 09:44:01 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aHze/ABTtBeGR3TmeYnKmjOq12BFjBgon6ALhFTEiUk=; b=y99gqT0D9BkSKO l+5HfchZ4FzTeBtETTMZkthckL3vm+9RlIIBujc9e0QEq5DOqiXJsPuo/OnnaacqSCVo3olz3m324 xu98EZxSJBEbGdDLID6Ws45OXCtLec3PQ9ZvOWiznuRhqhXe8N9k97ZQLP353u2yuB2iaBSSXCvDE 1HTWJYiY0Ds7zKGrnj0DFDJmpGAVK0A3xBWyPtogdNIfqvXxgGQAT0lc30yFziIlKM5zJx5BboD+d GwqZ4oKkkAKvKsB2cBHYAyHZAts6FSDrByZSmna0GPozWZfaAWHTJxjIfwNZG2n+wJmp+LkBmA/QK EL1loFmm/0jOiwhWiMCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7Q-00FCqU-Qw; Thu, 02 Feb 2023 09:43:01 +0000 Received: from mail-dm6nam11on2062c.outbound.protection.outlook.com ([2a01:111:f400:7eaa::62c] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7J-00FCpG-30 for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:42:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoRL22VMlFZ3bbXU3UgaVQpSy4yGSFG+qzMe2FhVHNJCoOO8DquQwcVYpiEajeF6SWjzSvwH5wrL2Yg7AOitEonI65kB4UUFlq2Dl0E6Nv5sKPOko3plf+u6fcahnc/ymNOyfDLQkZZF69s6Pvb4MuKp/bxurPYjTRzE71nvTSHsMhqDUK8l6rzdo3rpqQBBT6j1d6mAqlb+IKuWv41VIdU8PDIygcHWpmNHtzb/fdqj8dx+DsB0Lr4CwJ+itDPDaFJ3rXKKDkzN+7Y86+0YlBa24BfNCqzcgC1GxcKLtqF0El0GdeZHUGuYq/9fKKXrCBFPoH1mXN4Vy91ukg722g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mgPu9PptTkSQgoFmVCTn+1fmcrugJCaP+yBakgmxo7I=; b=PSplxm/HH4JlQktaD3vsdtobkXiBpLloPUnNOKicFi8ZhgATML6M9PT6Gk+xuNef5qJZXmQP8FCilzkmRfVePNBp4H5At1aIHaRkNLrIrDBBJ3G12iM/kNKo/kqUE7NHTqNvNHuHeUwglwHs0k6tkDffpPeO3hWXUPy4vMgWXadYvcbS8SPytKmqhzo0+lW0uHwMkBtVRkLDZqsGUpAmEQwMoygsRaqR1arPgLyswVsxrYQzugxFIFU3d9CZAjeGgVvfSKbsg71YVxifY/UE20rVaP6BSd1/u3rWxLuQfmLc3WCxxMWtMskAbqTgw/iIJZlMiWV5jWYWT/MmtOgjow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mgPu9PptTkSQgoFmVCTn+1fmcrugJCaP+yBakgmxo7I=; b=R/2J82HF1Z4f3ZcNgnfj5IBwUoqIoqWB39RVJ0kzIxNtdyvb7WYNcrVL4fNBou+jxshPeDOFV/4NWSlCngN5vrubxlHPU5W57ySybfgMuYjiAcLOQhCBGeCbCPD+ls18oE4GohGJj3Qj0LdCicR9Zbj+LaTVsSa9ry+DjuGDtbo= Received: from BN0PR07CA0003.namprd07.prod.outlook.com (2603:10b6:408:141::15) by DS0PR02MB9430.namprd02.prod.outlook.com (2603:10b6:8:dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Thu, 2 Feb 2023 09:42:49 +0000 Received: from BN1NAM02FT062.eop-nam02.prod.protection.outlook.com (2603:10b6:408:141:cafe::be) by BN0PR07CA0003.outlook.office365.com (2603:10b6:408:141::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:42:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT062.mail.protection.outlook.com (10.13.2.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:42:49 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 01:42:46 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:42:46 -0800 Received: from [172.23.64.3] (port=36995 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW7C-000CLP-BR; Thu, 02 Feb 2023 01:42:46 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id A27021055BB; Thu, 2 Feb 2023 15:12:22 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 2/9] i2c: xiic: Fix Rx and Tx paths in standard mode Date: Thu, 2 Feb 2023 15:11:31 +0530 Message-ID: <1675330898-563-3-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT062:EE_|DS0PR02MB9430:EE_ X-MS-Office365-Filtering-Correlation-Id: 30ce2310-a55e-4d69-106a-08db0501d8b2 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RDi9+tndEMdaQ1b5xwcq6N/CBBzyLCJ3OdprsjfOSgAia4L7zTq2igOzv0RYpAIHtOQ2EKu1sJJnKmQvy3zCYwN3EFleJnEIUFClEtpPg5e1jpg9DelVq4jslbUtLvPmfMFclIlGgUBp/0UOmlk6kxoWjwL2Y/ZbFasi7hNQPnIBnSwETRkeX0bMjjlxrUBwCn8U8asyHcRt/Uv7rxlgm0DSZcprWGMCo6hvoMyy0Tc4cOkflIprJQ4MzMc4y/Zi33S9atWH1UG61X+Rp5DcC/kXOybOlvw6/TJuub8Lpc7NysUzTONLwKDmdvPotV8gn0EQSFaPTZx0aZKR01Rzya4INY/ZWS5prGTjF0QQ/txAW5IqfF1JHqpAnowmqlQ0VvVCXeFnl8nnRom7WeHDUo0sKGkxDVWDnVBDdvjFnOIdUNJBoDTfsF068FIG4tc1pQmFSu1tYNrSDbqZ82GS+7RARl9wc1XA8q/K/KUUTeaoJYPabXK9nZCSYEqHNU3UBEXd5x6iygbqnD/WBQi80o3bCAUii3PEACuMUG4NgmnN0iiXqvahGyyly8HdWDjNXTlaSr3qd5LB4elugw9h/9w91+MGISEfSOy8xEdXhBPaXEjKFw2aAPkWb0Pjolp0LkPDsbqcxA4DXRxhTWe1NyP7IjntXdiZxybyzsqqKfb7y6MPVy7XMp0ZVB1kF5070HaEvXmKXhDLLzhaAoxzkLDZG0Xv0uINuaVB/kruVQWn2Wk7jIOBZnYkIkj5kXWE X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(346002)(39860400002)(376002)(396003)(136003)(451199018)(36840700001)(46966006)(40470700004)(82740400003)(356005)(7636003)(36860700001)(83170400001)(40480700001)(70586007)(70206006)(4326008)(41300700001)(8936002)(6266002)(6666004)(40460700003)(83380400001)(2616005)(107886003)(186003)(478600001)(47076005)(82310400005)(36756003)(316002)(42186006)(54906003)(8676002)(110136005)(26005)(42882007)(336012)(2906002)(44832011)(5660300002)(7416002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:42:49.0305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30ce2310-a55e-4d69-106a-08db0501d8b2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT062.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR02MB9430 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014253_171492_8458F997 X-CRM114-Status: GOOD ( 18.00 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam repeated start When a combined message request comes from user space, the controller has to initiate repeated start sequence. In standard mode, this repeated start sequence is corrupted if there is still data in the Tx FIFO. So, always make sure that all the bytes are completely transmitted out of the FIFO by waiting for TXEMPTY, if the previous message is of Tx type. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 839564054501..86da622e060c 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -61,6 +61,7 @@ enum xiic_endian { * @state: See STATE_ * @singlemaster: Indicates bus is single master * @dynamic: Mode of controller + * @prev_msg_tx: Previous message is Tx */ struct xiic_i2c { struct device *dev; @@ -78,6 +79,7 @@ struct xiic_i2c { enum xilinx_i2c_state state; bool singlemaster; bool dynamic; + bool prev_msg_tx; }; #define XIIC_MSB_OFFSET 0 @@ -280,6 +282,24 @@ static int xiic_clear_rx_fifo(struct xiic_i2c *i2c) return 0; } +static int xiic_wait_tx_empty(struct xiic_i2c *i2c) +{ + u8 isr; + unsigned long timeout; + + timeout = jiffies + XIIC_I2C_TIMEOUT; + for (isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET); + !(isr & XIIC_INTR_TX_EMPTY_MASK); + isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET)) { + if (time_after(jiffies, timeout)) { + dev_err(i2c->dev, "Timeout waiting at Tx empty\n"); + return -ETIMEDOUT; + } + } + + return 0; +} + static int xiic_reinit(struct xiic_i2c *i2c) { int ret; @@ -685,6 +705,20 @@ static void xiic_start_recv(struct xiic_i2c *i2c) local_irq_restore(flags); } else { + /* + * If previous message is Tx, make sure that Tx FIFO is empty + * before starting a new transfer as the repeated start in + * standard mode can corrupt the transaction if there are + * still bytes to be transmitted in FIFO + */ + if (i2c->prev_msg_tx) { + int status; + + status = xiic_wait_tx_empty(i2c); + if (status) + return; + } + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); /* Set Receive fifo depth */ @@ -739,6 +773,8 @@ static void xiic_start_recv(struct xiic_i2c *i2c) /* Enable interrupts */ xiic_setreg32(i2c, XIIC_DGIER_OFFSET, XIIC_GINTR_ENABLE_MASK); + + i2c->prev_msg_tx = false; } static void xiic_start_send(struct xiic_i2c *i2c) @@ -773,6 +809,19 @@ static void xiic_start_send(struct xiic_i2c *i2c) xiic_fill_tx_fifo(i2c); } else { + /* + * If previous message is Tx, make sure that Tx FIFO is empty + * before starting a new transfer as the repeated start in + * standard mode can corrupt the transaction if there are + * still bytes to be transmitted in FIFO + */ + if (i2c->prev_msg_tx) { + int status; + + status = xiic_wait_tx_empty(i2c); + if (status) + return; + } /* Check if RSTA should be set */ cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); if (cr & XIIC_CR_MSMS_MASK) { @@ -803,6 +852,7 @@ static void xiic_start_send(struct xiic_i2c *i2c) XIIC_INTR_TX_ERROR_MASK | XIIC_INTR_BNB_MASK); } + i2c->prev_msg_tx = true; } static void __xiic_start_xfer(struct xiic_i2c *i2c) @@ -866,6 +916,9 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) /* Decide standard mode or Dynamic mode */ i2c->dynamic = true; + /* Initialize prev message type */ + i2c->prev_msg_tx = false; + /* * If number of messages is 1 and read length is > 255 bytes, * enter standard mode From patchwork Thu Feb 2 09:41:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125654 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A3C3CC05027 for ; Thu, 2 Feb 2023 09:44:19 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RiG79fYqfJXQV6X59Y2bcHSuRInGN7jK4Aqy+ssiKQ0=; b=L/edNqlJ1nWf3K Nbb+YaSuN5g9gccsa1CD6ye6aO0XKIzuAnobghgXQwp/S1DYkPrPjkAoySe/TpHwoqdNh1OD9EPHR bpMemu88ESw6RegWW0KABnsFpLxRs863ZytKXO3CNmQsZdMiE9D2sPTKF9Wt0AI49JxD11fJFAU8l ehqCRRaXaQkYyAgmbxhkLS/+wKMPD0xkIjeBVeDYFBJqGkc/JzVGNglsTcp7jfxu+nxUAfk27M+QY hYI7JJobC5kGoDGWbLPCyZDzde9CZpckRtCist4K9ccrwaGor8lpzh4LQnjuoj0d86Pm5gOlWCg6n 7CiBlPlcqKV+e0prTZxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7g-00FCuY-PO; Thu, 02 Feb 2023 09:43:16 +0000 Received: from mail-mw2nam04on20606.outbound.protection.outlook.com ([2a01:111:f400:7e8c::606] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7c-00FCtK-Cm for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:43:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Be21h2HQM7NjvUWIeApEWrOBR8YLGMQIUc/r+zxC1wFa1AsljX5NOrP0gjUYvdPAH4Jjgm6sYbwjy98OaxgZI5+uk+uz588omUITkd7MztQ95maK/WxUm5OgOA3WTPhHbXzx3KKwhw8Wj66bB2aXxtMPftlPqkqowtJudvFd10WemJSY0nzcK8LwLS0LywhWl3jGi8HdP14HBDy+rp46BDOE9EryUNkq2cC9B8+QuFp76w70XkM92a6wxEY+pFlizaDfXGvqqAkVEQbjwCpcvddiYNL4pFZJr2V2nz59Dos0Tc0fHthvgMpg5DaAuI55DheevZ/JO0qr/n1LcjAj9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SsyUwEc5NXppls5c9t0BMvF/KAxjebhTOEd9VuxXDJE=; b=C6uINQA85qXnwWH4HqKCucBRgWYbSg+p4iVpOXeAeP+rj0AO+DAHemHhfTZbThPkxYgMv40u10YEHuK2TGfwsJnfpuS6CkiuOCoZTR8P0EYUA1m79mTpPZfeeGZ4cayIP+r6lDWCcThlPBsIwRoI0ySLSEkJnMx74fO09PC7P29hyO+4STSb7+Nfu8nO9QWodykQNfHo3RyTQi2YNJXWYoxe+RCdXs69fsu/RdmV2jXZxmpWpYLcF1ZOy3f8KKRh1uQZBkSgyUx4iHHdMm7nP2r99Hcgw53O3LDu2TpTVrGLS64YvtPgHsiNnfO+cy4CcggYS9Ue5zyOEB3oRXCFbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SsyUwEc5NXppls5c9t0BMvF/KAxjebhTOEd9VuxXDJE=; b=N5jgJMS4xoC/ppQFUQBlg61NWO6kR6c3HJPwm9JitNenbhA3Er91XDPqOyLdo6putvHSO9Aih0nP0prBT4ESa1RpAiRTY/XIH/fYWsxXKCthTgBxGvGc6I81wIXclOcvE8wJmZ4YAjHvd38jlUO9toMTaqvhHD4aH25xZ95qCcs= Received: from BN8PR07CA0012.namprd07.prod.outlook.com (2603:10b6:408:ac::25) by MW4PR02MB7364.namprd02.prod.outlook.com (2603:10b6:303:64::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Thu, 2 Feb 2023 09:43:09 +0000 Received: from BN1NAM02FT045.eop-nam02.prod.protection.outlook.com (2603:10b6:408:ac:cafe::43) by BN8PR07CA0012.outlook.office365.com (2603:10b6:408:ac::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT045.mail.protection.outlook.com (10.13.2.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:09 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 01:43:00 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:43:00 -0800 Received: from [172.23.64.3] (port=36996 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW7P-0003Nt-M3; Thu, 02 Feb 2023 01:43:00 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 7158A1055BC; Thu, 2 Feb 2023 15:12:23 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 3/9] i2c: xiic: Switch to Xiic standard mode for i2c-read Date: Thu, 2 Feb 2023 15:11:32 +0530 Message-ID: <1675330898-563-4-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT045:EE_|MW4PR02MB7364:EE_ X-MS-Office365-Filtering-Correlation-Id: eafe6e2c-80ba-46dd-872c-08db0501e49d X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WFJP+ia65MQJFali6Wsp0jkk5tTzBBAoTa37jbnk34plvASlgqJGW9h1naJg7Ow/Ngd7dn7oAhJ0vkczQ9HSqB84N3tW1upzP/x9FVBTa4b5eCnvh/Y3Rnu+ZmeKpoHWTZUOtGntM7Jsa3z7XwqwBvSoOrUIgqH1WYmBP30/HK2SGBYAY/RTsTpCXROt4Mgz9NJKk9wQTZaaVTRwzYNXS5dcLjKC7azIdHTFwnQTY9jYuahXe2TX3/FWIc1B0QEowH8Gb6AtId7nijE7xgWALTk0J7hgu8XbfSosUhCHgH3oBLAXiJCkTfFe8XekCABqTrsTUogsTXxf2IN7jZe111ReGLEzy95qXhijbaetT3KJge116A6PEMkLFkx2EVAjUMis8NrFSIaQVJS1oJBMZtItUe84JYLs0a/ySPSs6o2cU5JDti+RskFPmU7eN/J1cdryasr1M+lkccT75GeQmWAVCikduqDTmOMEr/p/kwiqMjUYZxpBgzO6kgsrglp4gI+78iuiOBYkoYd/ueKvO0hobQxNyGHtksbHgEWCSVafVFSykB8urSh0nGq9gdf1gj0b+fuxxVWEWZo7SAvouR+yfoS/nnKifLgcYujQ4JTDpDZSc2KGg2iJ/VAM8XwLnPaPj+dHYuIKvr7UcFp3n/JujauA+MKy5VpUkLPGnHklG5gQO6RJyuNwNOMOk2lXXK1zt5Jvg46lJGCN0WsIvFOE/HCvzUjyzXntxtoI5DmoJ2h3lv/gjvIGxJV63Y4d X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(39860400002)(396003)(451199018)(36840700001)(40470700004)(46966006)(42882007)(36860700001)(7636003)(82310400005)(82740400003)(316002)(5660300002)(54906003)(110136005)(42186006)(7416002)(83380400001)(336012)(2616005)(47076005)(40460700003)(36756003)(83170400001)(40480700001)(356005)(6266002)(26005)(2906002)(186003)(478600001)(44832011)(4326008)(70586007)(70206006)(107886003)(6666004)(8936002)(8676002)(41300700001)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:43:09.0129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eafe6e2c-80ba-46dd-872c-08db0501e49d X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT045.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7364 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014312_470047_9E0CEFEF X-CRM114-Status: GOOD ( 22.35 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam Xilinx I2C IP has two modes of operation, both of which implement I2C transactions. The only difference from sw perspective is the programming sequence for these modes. Dynamic mode -> Simple to program, less number of steps in sequence. Standard mode -> Gives flexibility, more number of steps in sequence. In dynamic mode, during the i2c-read transactions, if there is a delay(> 200us) between the register writes (address & byte count), read transaction fails. On a system with load, this scenario is occurring frequently. To avoid this, switch to standard mode if there is a read request. Added a quirk to identify the IP version effected by this and follow the standard mode. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 96 +++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 86da622e060c..edc64b79e293 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -32,6 +32,7 @@ #include #define DRIVER_NAME "xiic-i2c" +#define DYNAMIC_MODE_READ_BROKEN_BIT BIT(0) enum xilinx_i2c_state { STATE_DONE, @@ -62,6 +63,7 @@ enum xiic_endian { * @singlemaster: Indicates bus is single master * @dynamic: Mode of controller * @prev_msg_tx: Previous message is Tx + * @quirks: To hold platform specific bug info */ struct xiic_i2c { struct device *dev; @@ -80,6 +82,11 @@ struct xiic_i2c { bool singlemaster; bool dynamic; bool prev_msg_tx; + u32 quirks; +}; + +struct xiic_version_data { + u32 quirks; }; #define XIIC_MSB_OFFSET 0 @@ -878,7 +885,8 @@ static void __xiic_start_xfer(struct xiic_i2c *i2c) static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num) { - int ret; + bool broken_read, max_read_len, smbus_blk_read; + int ret, count; mutex_lock(&i2c->lock); @@ -891,6 +899,34 @@ static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num) i2c->nmsgs = num; init_completion(&i2c->completion); + /* Decide standard mode or Dynamic mode */ + i2c->dynamic = true; + + /* Initialize prev message type */ + i2c->prev_msg_tx = false; + + /* + * Scan through nmsgs, use dynamic mode when none of the below three + * conditions occur. We need standard mode even if one condition holds + * true in the entire array of messages in a single transfer. + * If read transaction as dynamic mode is broken for delayed reads + * in xlnx,axi-iic-2.0 / xlnx,xps-iic-2.00.a IP versions. + * If read length is > 255 bytes. + * If smbus_block_read transaction. + */ + for (count = 0; count < i2c->nmsgs; count++) { + broken_read = (i2c->quirks & DYNAMIC_MODE_READ_BROKEN_BIT) && + (i2c->tx_msg[count].flags & I2C_M_RD); + max_read_len = (i2c->tx_msg[count].flags & I2C_M_RD) && + (i2c->tx_msg[count].len > MAX_READ_LENGTH_DYNAMIC); + smbus_blk_read = (i2c->tx_msg[count].flags & I2C_M_RECV_LEN); + + if (broken_read || max_read_len || smbus_blk_read) { + i2c->dynamic = false; + break; + } + } + ret = xiic_reinit(i2c); if (!ret) __xiic_start_xfer(i2c); @@ -913,36 +949,6 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (err < 0) return err; - /* Decide standard mode or Dynamic mode */ - i2c->dynamic = true; - - /* Initialize prev message type */ - i2c->prev_msg_tx = false; - - /* - * If number of messages is 1 and read length is > 255 bytes, - * enter standard mode - */ - - if (i2c->nmsgs == 1 && (i2c->tx_msg->flags & I2C_M_RD) && - i2c->tx_msg->len > MAX_READ_LENGTH_DYNAMIC) { - i2c->dynamic = false; - } else if (i2c->nmsgs > 1) { - int count; - - /* - * If number of messages is more than 1 and one of them is - * a read message, enter standard mode. Since repeated start - * operation in dynamic mode read is not happenning - */ - for (count = 0; count < i2c->nmsgs; count++) { - if (i2c->tx_msg[count].flags & I2C_M_RD) { - i2c->dynamic = false; - break; - } - } - } - err = xiic_start_xfer(i2c, msgs, num); if (err < 0) { dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); @@ -985,10 +991,23 @@ static const struct i2c_adapter xiic_adapter = { .algo = &xiic_algorithm, }; +static const struct xiic_version_data xiic_2_00 = { + .quirks = DYNAMIC_MODE_READ_BROKEN_BIT, +}; + +#if defined(CONFIG_OF) +static const struct of_device_id xiic_of_match[] = { + { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, + {}, +}; +MODULE_DEVICE_TABLE(of, xiic_of_match); +#endif + static int xiic_i2c_probe(struct platform_device *pdev) { struct xiic_i2c *i2c; struct xiic_i2c_platform_data *pdata; + const struct of_device_id *match; struct resource *res; int ret, irq; u8 i; @@ -998,6 +1017,13 @@ static int xiic_i2c_probe(struct platform_device *pdev) if (!i2c) return -ENOMEM; + match = of_match_node(xiic_of_match, pdev->dev.of_node); + if (match && match->data) { + const struct xiic_version_data *data = match->data; + + i2c->quirks = data->quirks; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); i2c->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(i2c->base)) @@ -1112,14 +1138,6 @@ static int xiic_i2c_remove(struct platform_device *pdev) return 0; } -#if defined(CONFIG_OF) -static const struct of_device_id xiic_of_match[] = { - { .compatible = "xlnx,xps-iic-2.00.a", }, - {}, -}; -MODULE_DEVICE_TABLE(of, xiic_of_match); -#endif - static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev) { struct xiic_i2c *i2c = dev_get_drvdata(dev); From patchwork Thu Feb 2 09:41:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125655 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 41E43C63797 for ; Thu, 2 Feb 2023 09:44:32 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p67S3QWZ4MgIKEk4AioH9dm3q4uGQLYpLEzTZZdwbUY=; b=ArZihS07FOKGKc iV2m532rQ0d3zSxFPysHm/NV+a/ON8ZxKu3jZj9CGX/UoLp1u/Sh8aui6zDzaQZF0OjF4BqCc0JoP 3RuIhWruyJKLz/1y89e4VmJ/gyz9eqIT+73ni0jxsish9KNohzYgOHRM6otRf4rcjZZyaq2x9UzK/ J5iKoV/l6XqjGe5KMTUHDw10L2GLHVM+vqwyDn6lyN05OfIFoOpwzrXSOJt0smqnufiCsEKJTNRop Q5Sa+fyYLLPTiUVSc+XavjEjGUGnKiWkyajrTtN8yFgRq0tzcypRCf7YN9ADVEhfNEbdfpJa5ub5n EQHq/GYWCGSSM+HVGn1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7q-00FCyH-Hr; Thu, 02 Feb 2023 09:43:26 +0000 Received: from mail-co1nam11on2061c.outbound.protection.outlook.com ([2a01:111:f400:7eab::61c] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7k-00FCw6-MP for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:43:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BauQr/6RcqkuneW2Mzl5GHs4to5Q+L/rneUx4R1EWbPx3G/SQFAsP1YI2GqKdlK3TLdUxR7s+FSJWYAQ0w/N9Cor0trA9TALbl0jmM1Qyrw8LGCc5J81jakYusq8LL1qG6ne0Yh9XfQORgXhZz78Elghntjsn2BipmRo03z0oKq8FVEIVNwCnXBJepQCe4bisIq/J10xt93Nxt2D1zVSwyvMCSxyddpUZCl8l0T0p7+F4j2+Ey9PQip7WIS2/iDzAQXZWjbUL3ubTiPRXIKDmDwZC+NRyrLdY2uhIKpbUv6xwwXU88icit+mSDMbgio38UuSg7mOgyj37ZG9HmRqng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ExBzXmoeQqQy6SJXii/rVwQPDE7JZKxm7zug/cBRlr0=; b=DwxIxOiMrB1MfEZuI5/GqqFKeI6kor6ENRTBDvnIjB2Fc9VQCac1gu4O/36VwCjtNQJ+AqOl7z3eKQRyDrkf9ZSbHfmXcaSp1i1bQQMNvmgo/kN9dmJdwGnAqmLxNgT7IMznwHsOKW3VV3EObYpGzy3lN/+NuiAq4ZPjluBBwSQH8nZPut2QCcQ3XBL72giNvtUmL2ki8b/zavd3axOQpeEUM+Yu5Zlt1Tw6cam3EiqTjU7gRiR7J3j2DMnoDT2nkAJM4CxYfOdvwHARUKl9Ooxoz7kc4yr9MmDcnLHocg+fKqu4PMrIQLe+w10RvXwEgr+5ZkwgPlHPLcd09hVblg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ExBzXmoeQqQy6SJXii/rVwQPDE7JZKxm7zug/cBRlr0=; b=SUpNAOPfdSCFHVvAPo5AVWEyMqIfRt+Z3KSIJWCgOFRiAeLJ5VBVh7xn0KkRqbAg7mbpUCKV45XRtxeBCWCnx1TMqiCUJAjqnZs3IwjNr9/NS6sxZFD4lVy/PXZk1d/oZeFzZjsjXU4iRydcg/lV/lxRObBTdlLHIfIySOLbi0k= Received: from SA0PR13CA0013.namprd13.prod.outlook.com (2603:10b6:806:130::18) by MW4PR02MB7347.namprd02.prod.outlook.com (2603:10b6:303:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Thu, 2 Feb 2023 09:43:18 +0000 Received: from SN1NAM02FT0043.eop-nam02.prod.protection.outlook.com (2603:10b6:806:130:cafe::d1) by SA0PR13CA0013.outlook.office365.com (2603:10b6:806:130::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.7 via Frontend Transport; Thu, 2 Feb 2023 09:43:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0043.mail.protection.outlook.com (10.97.5.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.25 via Frontend Transport; Thu, 2 Feb 2023 09:43:17 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 2 Feb 2023 01:43:13 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:43:13 -0800 Received: from [172.23.64.3] (port=36999 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW7d-0003R6-0N; Thu, 02 Feb 2023 01:43:13 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 554801055BD; Thu, 2 Feb 2023 15:12:24 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 4/9] i2c: xiic: Add wait for FIFO empty in send_tx Date: Thu, 2 Feb 2023 15:11:33 +0530 Message-ID: <1675330898-563-5-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0043:EE_|MW4PR02MB7347:EE_ X-MS-Office365-Filtering-Correlation-Id: d0847ade-83cc-4a36-202b-08db0501e9a1 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y/dbxxj4t5TAcKWONVEfhrbUDT56QVIMoOlFZMNGyF4Q64Rt5qSU7bvlQwP0VPRULlFzVvi1oCq/KAVjRL3j23dXFP3NmT/rHd2J/pcAFT6XWTB3WBdaDtc6ryhRBZB+SIfjkXkmDbzZlp/E1kNTnOyWsQpEldcgnjJHn9L01tgj6CdmEG7VKtqTF2n8wu6ZyjBBGv9cB8RXCfOf1X2Cyf7/oSKCSeKcwQSBsyIN3HueDowrY6xyxj/n1qsfj46t8V0eyqJaMyzlFIyesxFH4cGneoZ0taR6o3QpA1+B5i9/lYimfNJTan9B7OuR5Dy1zGGCOAjF6xGnNCuOux4W/m7GxqTV3TfLm7OW4uKPq950UWZSquAL7uog8ZBIMyWS5WDpWi0qtzX7Z54t+WzZoNaXBKK94hybdD0roOt+YMtc7oG6w8b9tEfumdPxt2Ehgh2TPryrsdWis7Lvgvb9dxCK6++DygMXeZoR/hvPGGAbJDAA9XB3CFOgr/Q2j96qZDezvXPULXKHIkdXDqCSUSHjn/1flc6nGyGFJJLcM3wANTMNrzh9WTd1bbM3azB5FmHtjatP68L0qIF5Gz9mwPu7kgskrapDcllJVm5JeuzJWolLLVEVRMo1wMWh9/ueWPmGSX8wqge3UQaVKT75G5B8CowCyLoSERoxDVdATSpV99osOvJ2ZYrqCUbtkluIr1BVa39N7F6mK5QKPA7MHXYm+0IH7nybPINc8exSA7kFtVJgFa3zqLDHwtBQZc8A X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(39860400002)(136003)(396003)(376002)(346002)(451199018)(40470700004)(46966006)(36840700001)(5660300002)(44832011)(7416002)(41300700001)(8936002)(478600001)(36860700001)(4326008)(47076005)(70206006)(70586007)(8676002)(107886003)(6666004)(36756003)(186003)(6266002)(42882007)(336012)(110136005)(2616005)(42186006)(26005)(2906002)(7636003)(82740400003)(40460700003)(356005)(83170400001)(54906003)(316002)(40480700001)(82310400005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:43:17.5033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0847ade-83cc-4a36-202b-08db0501e9a1 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0043.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7347 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014320_766480_1921D8EC X-CRM114-Status: GOOD ( 10.10 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam If the tx_half_empty interrupt comes first instead of tx_empty, STOP bit is generated even before all the bytes are transmitted out on the bus. STOP bit should be sent only after all the bytes in the FIFO are transmitted out of the FIFO. So wait until FIFO is empty before sending the STOP bit. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index edc64b79e293..57084696429c 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -436,6 +436,13 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c) data |= XIIC_TX_DYN_STOP_MASK; } else { u8 cr; + int status; + + /* Wait till FIFO is empty so STOP is sent last */ + status = xiic_wait_tx_empty(i2c); + if (status) + return; + /* Write to CR to stop */ cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & From patchwork Thu Feb 2 09:41:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125656 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 14F9BC61DA4 for ; Thu, 2 Feb 2023 09:44:51 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TsktyGv3NOVaIF+49HHwZ/Vi6i0KPeti/qXzGBBiLn0=; b=OlsCWAAkWAWP1H iSVCUfayCRbim7wiY+CiC5v57JPovbqM068Rkb/KEHIJSy087GkoPENbdYVW2lWq3POHIUF7BE5cw O3I53vX0kKpdUp0Y0SbW+qhZ98D14HqDp1NwjkqbeWt0+obSnBVNfa5IA+gEDfHIRP+7l6Jp+llQw zThdS7WoNEmEvPNqgKkhx+Y0bpg0c+3QdF4OL8+bQnbf1GD/29+fCplcaculngtTOrviF4ayi/uHy YXiPF5VyXQNNjYsImlhNa7hLhhXH0mQ8JjcTtr7vrc0/eOqS+5XyPR8i/mapG46Fr6lMFqk7GwzZm Nb/KqgFvXvpJoMSqK4Ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW89-00FD44-DV; Thu, 02 Feb 2023 09:43:45 +0000 Received: from mail-bn8nam11on20601.outbound.protection.outlook.com ([2a01:111:f400:7eae::601] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW7x-00FD03-Tk for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:43:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OWrHMKk34GfECyHv3FK7hUHgYe8ByL5a17RX2Hue/NZ6JLzb4xhCXRjYVR/U0p+kwm1zs7tQaRXr41JKotPXFqF5uw5s2G531bwUO8Flp2a9nSjn+SPCt7y5jrCiYMtTrRqAzuLuF537yiNtXQyEZOWJI1PVkK3xPukW5hzpz6EAgtRb6+JCO61zn9b/vaaCi8e/70huudF6psqpjaOI8WoVFaKf0ACgmrg1NBJLAwVrd8xziIRuB+FreWhMeybDtMctD550Vqfswd2+qLTNjcVzgwWR/xabamI/YJfXKS4Dp/8IFMKfS2ZZe4oOz5zjToJfv+vef7BfWQVrBm97yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rCZLKqSFYYHdOKQrTutofbhVjZsqbIE+qYtqLXWGyPo=; b=hRdH1Ick+aSADzUD5yaPDGy7+yfhWhbTo5I+AuFsMMbWUi0RYVL6y60qxGR2kNCYK+tQ5+q59iantC3Fjor64ZYrWHcsJUmwubde47H1P20TzBBTi0+cAqcxS87pR1qwtOtOtz41sbbMCTMhbdZqfRwFPGc9tvYp3b5XzMab4czat9qfBgMCMJ5pCbi9z+DaCHLfVSF3fGCoQuxuadeF11RK3ypyQAPWy3G6A4+Yq1RkMBFhdix0SHY6xPP4cocb/t4US9+xojBrAM4vQ7GGDgGrz5r3r52z7abTblDanqLyoLDHgaBf7c0jUgzxwpuxWKi21AoZo3gZfe7/jHaW9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rCZLKqSFYYHdOKQrTutofbhVjZsqbIE+qYtqLXWGyPo=; b=nR1UHb26uF9M5ePStiofOG8WiTO8usrH9a7mpXd5sNkdI487qQgtyMNpWulh6vM22kZFsryedOmEzCh5XyTq+W/Ys9yZtfn+LH1uyR8nw3z5pROQU8vs45rZm3znqugFrprme6EHLXJuLUobi3N2PeTwOS6Ek33NxnOP5v72Nec= Received: from SN7PR04CA0167.namprd04.prod.outlook.com (2603:10b6:806:125::22) by DM4PR02MB9240.namprd02.prod.outlook.com (2603:10b6:8:104::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Thu, 2 Feb 2023 09:43:29 +0000 Received: from SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com (2603:10b6:806:125:cafe::1c) by SN7PR04CA0167.outlook.office365.com (2603:10b6:806:125::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0060.mail.protection.outlook.com (10.97.4.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:29 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 2 Feb 2023 01:43:26 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:43:26 -0800 Received: from [172.23.64.3] (port=37000 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW7q-0003Sh-4J; Thu, 02 Feb 2023 01:43:26 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 3FFE91055BE; Thu, 2 Feb 2023 15:12:25 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 5/9] i2c: xiic: Add smbus_block_read functionality Date: Thu, 2 Feb 2023 15:11:34 +0530 Message-ID: <1675330898-563-6-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0060:EE_|DM4PR02MB9240:EE_ X-MS-Office365-Filtering-Correlation-Id: 67da98fd-bebb-4043-b7bb-08db0501f0b2 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EgFCxRhLh+htVKAWIjvjP8pJys9Wd+4R0QoHxzazBTqSIBgdnwApLwBE2Jb79Fph3xMTFj44OD07h5Qc/Yf086hZu8BbJFLuRoBEpWctEZCGzgrBaK/cQRFis9nwm8k2Qv9Ssl1WWnlw2X2Rz3Ao3eHYPIoxduSQFiUom7duYw+2C2OUz2hEmxcj0Jsy3Xv2IXHTavTKbHy2XDqApmO/Fv+SsYoF89LQF90bRROBo9pqVFV917TqC0/Z+CKMHhZRX42EZvo3Cn2Jjekn2O1MXUuredlpXcCRJEyZh1xZ9ST04B7ATC5Y6N6egXvA9qlqEb57+t+PChtuW+6VVz2BOz1ksEGh960nG5iRAmqeRnnbG2hefW7Z8mknG3LaI/a5+wFTp8yIqPjLBtF/U8CGosFkqQrzbSTAhz2W0hQQDsaXwXfacD11QzDjNTy/6VxYtE1KJ+IxUWqZbFQtQXk2Xow1yAHwmP/cNeIOuEtS4fIQE2oe2yRc3nb6JrYrHVHhDuC/5m6J7F4s0gqQIasqtMAwytuq4QkS0PvHJAjM6alXCH05VveSPhd1FRzcD//QwCwFGjSaC0aO5gAQb6YpFjeJbHUsTevIgXPZ4CkuPN/QkCK+cyQ967ZZ3SAD+3VNymCVbkBOe+CqbCSfO2Gu1CUU+qzcV7qAD0X/qbeqv7cYSuC+Do9ZRSypUqj5IxjMvx+yXZaaTeRtcoxSVuHvT6ZClcJeceGvox6U18+TAShQSz5L2nvUdTMcGB+dH+MualrkGaYPnzkwF+MzcUAICd2ofO+MtP3FkYzw5ttKobc= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(396003)(39860400002)(346002)(136003)(376002)(451199018)(36840700001)(40470700004)(46966006)(36756003)(70586007)(47076005)(70206006)(83170400001)(4326008)(82310400005)(83380400001)(8676002)(36860700001)(110136005)(54906003)(7636003)(42186006)(316002)(82740400003)(478600001)(26005)(186003)(6266002)(107886003)(40460700003)(44832011)(6666004)(7416002)(5660300002)(41300700001)(356005)(40480700001)(2616005)(8936002)(336012)(43170500006)(42882007)(2906002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:43:29.3470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67da98fd-bebb-4043-b7bb-08db0501f0b2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR02MB9240 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014334_012188_3C40A46E X-CRM114-Status: GOOD ( 22.37 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam smbus_block_read is added to xiic driver to read from few sensors which support this command. Since the number of bytes to read is not known prior to transfer, xiic standard mode is being used for low level control of IP. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 82 +++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 57084696429c..554f83e34a2a 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -33,6 +33,7 @@ #define DRIVER_NAME "xiic-i2c" #define DYNAMIC_MODE_READ_BROKEN_BIT BIT(0) +#define SMBUS_BLOCK_READ_MIN_LEN 3 enum xilinx_i2c_state { STATE_DONE, @@ -64,6 +65,7 @@ enum xiic_endian { * @dynamic: Mode of controller * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info + * @smbus_block_read: Flag to handle block read */ struct xiic_i2c { struct device *dev; @@ -83,6 +85,7 @@ struct xiic_i2c { bool dynamic; bool prev_msg_tx; u32 quirks; + bool smbus_block_read; }; struct xiic_version_data { @@ -346,6 +349,62 @@ static void xiic_deinit(struct xiic_i2c *i2c) xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & ~XIIC_CR_ENABLE_DEVICE_MASK); } +static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) +{ + u8 rxmsg_len, rfd_set = 0; + + /* + * Clear the I2C_M_RECV_LEN flag to avoid setting + * message length again + */ + i2c->rx_msg->flags &= ~I2C_M_RECV_LEN; + + /* Set smbus_block_read flag to identify in isr */ + i2c->smbus_block_read = true; + + /* Read byte from rx fifo and set message length */ + rxmsg_len = xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); + + i2c->rx_msg->buf[i2c->rx_pos++] = rxmsg_len; + + /* Check if received length is valid */ + if (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) { + /* Set Receive fifo depth */ + if (rxmsg_len > IIC_RX_FIFO_DEPTH) { + /* + * When Rx msg len greater than or equal to Rx fifo capacity + * Receive fifo depth should set to Rx fifo capacity minus 1 + */ + rfd_set = IIC_RX_FIFO_DEPTH - 1; + i2c->rx_msg->len = rxmsg_len + 1; + } else if ((rxmsg_len == 1) || + (rxmsg_len == 0)) { + /* + * Minimum of 3 bytes required to exit cleanly. 1 byte + * already received, Second byte is being received. Have + * to set NACK in read_rx before receiving the last byte + */ + rfd_set = 0; + i2c->rx_msg->len = SMBUS_BLOCK_READ_MIN_LEN; + } else { + /* + * When Rx msg len less than Rx fifo capacity + * Receive fifo depth should set to Rx msg len minus 2 + */ + rfd_set = rxmsg_len - 2; + i2c->rx_msg->len = rxmsg_len + 1; + } + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); + + return; + } + + /* Invalid message length, trigger STATE_ERROR with tx_msg_len in ISR */ + i2c->tx_msg->len = 3; + i2c->smbus_block_read = false; + dev_err(i2c->adap.dev.parent, "smbus_block_read Invalid msg length\n"); +} + static void xiic_read_rx(struct xiic_i2c *i2c) { u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; @@ -368,6 +427,12 @@ static void xiic_read_rx(struct xiic_i2c *i2c) if (!i2c->dynamic) { bytes_rem = xiic_rx_space(i2c) - bytes_in_fifo; + /* Set msg length if smbus_block_read */ + if (i2c->rx_msg->flags & I2C_M_RECV_LEN) { + xiic_smbus_block_read_setup(i2c); + return; + } + if (bytes_rem > IIC_RX_FIFO_DEPTH) { bytes_to_read = bytes_in_fifo; } else if (bytes_rem > 1) { @@ -601,6 +666,12 @@ static irqreturn_t xiic_process(int irq, void *dev_id) /* The bus is not busy, disable BusNotBusy interrupt */ xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK); + if (i2c->tx_msg && i2c->smbus_block_read) { + i2c->smbus_block_read = false; + /* Set requested message len=1 to indicate STATE_DONE */ + i2c->tx_msg->len = 1; + } + if (!i2c->tx_msg) goto out; @@ -741,11 +812,14 @@ static void xiic_start_recv(struct xiic_i2c *i2c) rfd_set = IIC_RX_FIFO_DEPTH - 1; } else if (rx_watermark == 1) { rfd_set = rx_watermark - 1; - /* Handle single byte transfer separately */ - cr |= XIIC_CR_NO_ACK_MASK; + + /* Set No_ACK, except for smbus_block_read */ + if (!(i2c->rx_msg->flags & I2C_M_RECV_LEN)) { + /* Handle single byte transfer separately */ + cr |= XIIC_CR_NO_ACK_MASK; + } } else if (rx_watermark == 0) { rfd_set = rx_watermark; - cr |= XIIC_CR_NO_ACK_MASK; } else { rfd_set = rx_watermark - 2; } @@ -984,7 +1058,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) static u32 xiic_func(struct i2c_adapter *adap) { - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; } static const struct i2c_algorithm xiic_algorithm = { From patchwork Thu Feb 2 09:41:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125657 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 417F6C05027 for ; Thu, 2 Feb 2023 09:45:17 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BIgHTsex4Z/LlcqBPhKrCIaItMRMWPBch/lfDYadzkM=; b=Melk5rqpRt9Qmo 4Fc5I5hPFz0iruAwnXq6sRVYVj1cyjdt5JaPT/+ZH7Qg3v5FBchhwRq4jD8Z9deKhiAGyahxzLaeJ TeDiK/jArDCMxt12q04ev/dhEsa9Z7X6qdQmB/wAxk4r7N1zRnVvhAvwbb5RSKvRIosXllljSAyA0 +BzTdJi7m1RGw7EtCioRIBgNWxyxOg5AHqqOaccJ/v/7QG0LIAGbZlL9KQRJf1f+NvsCusuMUunWu TsSKj8eRk5DTH/CjnZHEsn+jNpmyc13VF1l+YhgMjs9+QhMeonkoqwNtsmQEs8HpTW7Qrbjf8OPy+ /mzNSrXXxGZ9t/HY1c1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW8U-00FDCj-KB; Thu, 02 Feb 2023 09:44:07 +0000 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f400:7eae::600] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW8A-00FD4D-Ma for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:43:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KpodUzk6jIkSle0noJHm+rMH1esOyYrXTjU8vDPgavLU7ZXKToZGQpAxy1BDbwXNCJaNLUK92auN5M/6XYamvX28+RKjT4yoD4Ujc2aqFNgt4vaE0inqGP6S6wx00e8ONwsE6slo+ytV770ybWCC23sZGg86koUgIg6cDU76uxRTul89dDoKE5018DUpP+mVwJVVQp/Q4qMbBfRws1UvJb1Ra1FfIfhVirmVPo3QoyzWK1Dyc2oqcHnEnunX+qm3YtxdeNAnwf0cXrna6joYS8rshcpBYPKIHhvRTYjcicrd1U/sKPauhNgzQKJsDfzGDo7CnzRWtc6iKRJQqD9URA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BZZnzs0iQxqKdtxkP8yCrlEW1QCuOzMXhrAK1oATYzQ=; b=XfWSVmD2NQadHx7fqL51X8aOFz5aggosMo+R07SYR/+ihE+Lg5JdeC26qX6wf0NEQD1LCR+BC5p4EEFaQfc+63luMbf8yXl+c8z82/EWEUovyQgfVr7c64IKvJJ0qk3vBj0YKjm2USE7NQx6OaXKpvbvTTT1ixS8xxqmuejQ9YPGJzp9rzMufJ9J0CEjkTyCbe8JZpBWuo4Xfunwl6YIt62AzBhll8yBUAvr69U96egdTHMbXrq6qPdyx3trcJLaMXRa7i0s0G5GYkKRgsXbR7cN026Tcx/RypRJTkSCKIIt+tqCmi2SK+GfCCAATA3qvtUiSM9VyeXAErnMc4y5cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BZZnzs0iQxqKdtxkP8yCrlEW1QCuOzMXhrAK1oATYzQ=; b=LD9ZMPY2xr4fnuQMADX3Ci4cAturSDEh6LESH6jRcSapKd6W7XPp0xhN0rbMnBYCpTqgOgHeQBxfYaMTChpbhiQhdwWty9dSgvG030ffShNDGGsRMZ03r9g1ldzOyW3HUHuE92FMFpI/GX8qD1FRKDBAjcQmChGRxY45rFyF7hM= Received: from SA9PR13CA0175.namprd13.prod.outlook.com (2603:10b6:806:28::30) by MW4PR02MB7218.namprd02.prod.outlook.com (2603:10b6:303:65::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Thu, 2 Feb 2023 09:43:43 +0000 Received: from SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com (2603:10b6:806:28:cafe::c3) by SA9PR13CA0175.outlook.office365.com (2603:10b6:806:28::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.7 via Frontend Transport; Thu, 2 Feb 2023 09:43:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0060.mail.protection.outlook.com (10.97.4.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:42 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 2 Feb 2023 01:43:39 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:43:39 -0800 Received: from [172.23.64.3] (port=37002 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW83-000Cag-F4; Thu, 02 Feb 2023 01:43:39 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 52DA41055BF; Thu, 2 Feb 2023 15:12:26 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 6/9] i2c: xiic: Remove interrupt enable/disable in Rx path Date: Thu, 2 Feb 2023 15:11:35 +0530 Message-ID: <1675330898-563-7-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0060:EE_|MW4PR02MB7218:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d9ff7f6-d61d-496c-3292-08db0501f8b0 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Kij0Z8upDseQuE6PzRYu5x3rg666rOpHiesHDdE9cST3u23z0Z6JZjppCdmocKCI64+OfaSaOZsy3R0oYX7HxfHhh4btqZYXpf+eaPp7sjMTyiS2s9ValEXmRDD36MH0ES9AAd6JiIZIUTaHeAhmW0oQCawm+muEQbEKkElh2MqeAxO7yQJlpWIgZ8tmAtXNsII8icnxx6lOKZ97e8BDiT/OCZblaFoHbqtSr/W0tDoG7OA4wu5NsS50mY5pqWE2I7gtpfMvMJtMC7SPb39tExjcWceop9bvJ7lWcBvr0YE47Ua6uXLOOq7HimJDu/vBpiRFr3LfSq16QcC3ieCI0Rwd0KX30gLSV/xdi4FAia+PaJ9sPgbFeb/Lp6xkzj/Kw8ccSsTC7kihEejFJvA8hk4XCWpAOmPzx6wSwyCRiVW18klKq2fmb+stnxzlLb/cnKMS4hIip5xeRV/voXb8tXK6kY/tO0Clr+m5z2uyeU1EJ0+Acp4T9qcUUDh9G/B7Q1Xx5Ww8ATAU0YijNPLOoMk8OUy+Lm7zSN9fwdt17Vf3eFddHTqgmQxqSX+n+dnzRpWnq9p1M4b671S04OHYhvZWKGREC26IcP7wUuQJ5XjqtJ0w3aG6S4fAfP5Gh7Dbog3QTidiDlhJz2dsC+P9BvfmTLr7YvqX5mk2EBxbXQ+4LyYd328kNYTlNZwibflsK5+ALpQgIlHmsLSvd1CUxOtI1vo2e/3RM1xK2G4rc3I+aMWg1q2aeTet5DmMH6N X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(346002)(136003)(396003)(39860400002)(376002)(451199018)(46966006)(40470700004)(36840700001)(36756003)(42882007)(70586007)(478600001)(83170400001)(4326008)(83380400001)(82310400005)(8676002)(36860700001)(110136005)(54906003)(82740400003)(7636003)(70206006)(316002)(42186006)(107886003)(6666004)(26005)(186003)(6266002)(40460700003)(44832011)(7416002)(5660300002)(47076005)(40480700001)(41300700001)(356005)(2616005)(8936002)(336012)(2906002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:43:42.7522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d9ff7f6-d61d-496c-3292-08db0501f8b0 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7218 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014346_770941_88B69070 X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam 'DYNAMIC_MODE_READ_BROKEN_BIT' quirk added in the driver, effected IP versions no longer enter dynamic mode. So, remove local_irq_save/local_irq_restore APIs from driver. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 554f83e34a2a..8503b5016aaf 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -741,7 +741,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) u16 rx_watermark; u8 cr = 0, rfd_set = 0; struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; - unsigned long flags; dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), @@ -773,8 +772,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) bytes--; xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); - local_irq_save(flags); - /* write the address */ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, i2c_8bit_addr_from_msg(msg) | @@ -787,8 +784,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, val); xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); - - local_irq_restore(flags); } else { /* * If previous message is Tx, make sure that Tx FIFO is empty From patchwork Thu Feb 2 09:41:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125658 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2764BC61DA4 for ; Thu, 2 Feb 2023 09:45:49 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KC863C/veARHuYAg6Ncvb0Pbeg5lb4HpU1mgSvjqG2Y=; b=iTLdhItA27vX7N f91GhTGB0sNUlYx7RY2ttCvTnzE2nhGlhA8F35N6/IUPjV44lStv1kLU4iyJFdZha06hAq8M9DYqH JYj6btTVYlcKhNO2ckwZ9CepngIwbvmB/zjiF36S20XUR74UEGsbN08WCRsSc3XL8Nqx8EgEip22Z JZpwueJ9q5H7Sb+iUMWlh6Rml+fDZiBbuFDzCA1cNT8M2TbfxJiQxvA7kdakZuk14bWTY1MDSIi90 sOSy/f9okaHWDd23msQ4qdLIqZhU/wykiSldFl9LC8rgA7IYVVjhKs5BT2cnynXmdMS33ZrY3z3Ev NtkU1AWoLxqhVyGn2M9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW91-00FDUb-A6; Thu, 02 Feb 2023 09:44:39 +0000 Received: from mail-mw2nam12on20612.outbound.protection.outlook.com ([2a01:111:f400:fe5a::612] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW8N-00FDAI-R6 for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:44:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMQ7IfpcOflPyec4yX1uFu7FzYNlTotUiImHfrK6Mh2tXbBX2RSjiO3iCpOFsi9LY6z41pkpFyhsgbPXQKfZVCM/l4bnL75fZAhzrBNlGJHGN/Tw98D6Ad9TvklilA0yHBT8JDfARBi6L/4X7I1CEM/sBTLHUnmRQj5yF9USJ66hrrNgFvIfuY9LH7S0oKGZw+E0PJPW7eASWoT6sRH7CWNFbzOINfbkW9rd9rXPdvI+Ulc+dOWhsyBhm/GJFMVYRI5+tQCh3JThYgg70a0kCu3B96/nbow+rTT4PXY5q67k8kj8f+g8f74Om4Cp1WaQ51xQzypxDUZH0SkPvPMRXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MyPURJ7YvaIZHGY7TY89MiLtQD4FECT8iF9+IpjMrQ4=; b=AgbXTSZgVTOCS4HS6C2gXLdKX9Lrtbb20vp7qSSua2S4I2EgCsCpth9LE8dTb8IlkRhoMpSBZ2vu3go/hh1TwVwE1tnfTsKtmzFiDdU+VwU4/v60XX7XDZFmUboyt6786v/BHFxbnF6ICvUyoIAzgoKDWpJKFIR9QLgrqJ2SHJGkPqqBsiGXEaVHt2zWDOGB5m5F3bVh540zfKProdO8J5nOmqIDvO1KUSCaL7bjxMigL3C3KYxudRiKdaqGtJuJX211fM4RADMiHdBWBPEHGGzulDZjCzPfRV/u90H0YJtQQSTnWOegxEwWq/IZSNyXpKcmrw/8mcHxgGWMVO+oFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MyPURJ7YvaIZHGY7TY89MiLtQD4FECT8iF9+IpjMrQ4=; b=Ppoz9kctsdfPsFyzCKHRCoVvO97kKARm033kYJv+qc32FGKE+IIFiL9ZnoTfhtEapE3VoZYWEXrUeBPKf+TBTigtyVX+GIfNaylUzWRqdm86BZvmwKVykS7VM/LzprgulBi0KtFvkOwrj3DomuC/uIo8fRfgG7CXWuRXDRTBSBQ= Received: from BN9PR03CA0582.namprd03.prod.outlook.com (2603:10b6:408:10d::17) by DS0PR02MB9533.namprd02.prod.outlook.com (2603:10b6:8:f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Thu, 2 Feb 2023 09:43:56 +0000 Received: from BN1NAM02FT036.eop-nam02.prod.protection.outlook.com (2603:10b6:408:10d:cafe::ff) by BN9PR03CA0582.outlook.office365.com (2603:10b6:408:10d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:43:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT036.mail.protection.outlook.com (10.13.2.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.25 via Frontend Transport; Thu, 2 Feb 2023 09:43:56 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 01:43:52 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:43:52 -0800 Received: from [172.23.64.3] (port=37004 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW8G-000Cb0-JD; Thu, 02 Feb 2023 01:43:52 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 4AEA21055C0; Thu, 2 Feb 2023 15:12:27 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 7/9] dt-bindings: i2c: xiic: Add 'xlnx,axi-iic-2.1' to Date: Thu, 2 Feb 2023 15:11:36 +0530 Message-ID: <1675330898-563-8-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT036:EE_|DS0PR02MB9533:EE_ X-MS-Office365-Filtering-Correlation-Id: cbe263ae-9c8d-4e68-1255-08db050200c0 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wC9zdnK//5DR849Ah/jPAxjak0B9n6E9vx/318433zsShhivwdZLzvXgZTtnCIGDCHLjL5nbsc+CFsJ2lrCa/L93MZatHmrM9cEYcSkbrBgPeFBTAH+BY8pEb2aQe5lSlrATaXF3L0YhLaF4/C6Cn7nRcQkoYIfhIOhiP4ZdJgKxpp29AkhoUnIK30mGonB9bggiCz8yb/m3DhL3CglANLlQ7jh/MhOBxUDUtC5ePX0El+PYTiavc+z0BV5GHwD2Dt35eLIZBG0oRkIXDfUzRQDu4n/I8jaN4H4lrvw18dJurfx3DD/CkEWTD3CKCKqKI7LMURMrzALWUVCDwk5cbvdi6fXO8T5LrdtWQDNPEhrFmoHwA5tUZ3o+ltzndATv6riWg0bKaEidbNRiC8oWGXBAv410AczONS9m5+yyOR9Ot5s3CuVLO+danPzahOb963Mf24HytdYe9BJdcHqsk9DhtuoSYIX5KYF/ZZ25raZKkVVXhrlfbJod37hFnziQx82q5nLmyMzZEtj+KmexIuMclfhTZ4ycbBFEo6v2/X08cXuiYVuzdVu6UHwOaUe6jJ/TIrWO7JlBAwqLzmx/ae0VmLXUgHF5sIYbD0LSTEpXATAxXO3yb6XYNNbGbGf6FXwEvEtoU8RdieR7hDrGq42CeFgePK4YfBrkz2vSk2i9KSwOg54uEGDJX9zEbD/iY8YO2XSLW1C9mRfSxkXawYHfEkl3ZRER8iUp1bsE+FTfDQ1i0I5hKbYg0RvtDf/X X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(39860400002)(396003)(136003)(376002)(346002)(451199018)(46966006)(36840700001)(40470700004)(47076005)(40460700003)(36756003)(356005)(40480700001)(7636003)(82740400003)(36860700001)(83170400001)(82310400005)(6266002)(2616005)(26005)(186003)(83380400001)(336012)(42882007)(478600001)(44832011)(7416002)(110136005)(42186006)(316002)(54906003)(8676002)(6666004)(107886003)(70586007)(70206006)(4326008)(41300700001)(8936002)(5660300002)(2906002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:43:56.2312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbe263ae-9c8d-4e68-1255-08db050200c0 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT036.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR02MB9533 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014359_906912_D840F8FB X-CRM114-Status: UNSURE ( 8.36 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam compatible Added the xilinx I2C new version 'xlnx,axi-iic-2.1' string to compatible Added clock-frequency as optional property. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- Changes for v4: Added description for clock-frequency in xlnx,xps-iic-2.00.a.yaml --- .../devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml index 8d241a703d85..92cb9006e8b7 100644 --- a/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml +++ b/Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml @@ -14,7 +14,9 @@ allOf: properties: compatible: - const: xlnx,xps-iic-2.00.a + enum: + - xlnx,xps-iic-2.00.a + - xlnx,axi-iic-2.1 reg: maxItems: 1 @@ -30,6 +32,10 @@ properties: description: | Input clock name. + clock-frequency: + description: + Optional I2C SCL clock frequency. + required: - compatible - reg From patchwork Thu Feb 2 09:41:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125659 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52DA7C05027 for ; Thu, 2 Feb 2023 09:46:48 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h9vaLMAwakW4ZwSfWx1ou40wqQzTtYE7XzqhbZIEFQY=; b=ye5RaNstOwAnUX ApMdDYEmBWDcFDfowD2RiOvTK/8yuv25YOHLOZ3dKWRsdmfIjcLr2nfJ3eEn+j3Jy7a6X/hgp26qq iEO6ek/Q3lH0J6MDoArSsZ9iQd4yCofI6zItdBnEbsY7kzbBiurRNhTDD65hl9/FWnLYHEkXmoF22 ZLErMftGTC/0ednRIlD8AqQpr3lVw/6qe1zjDvLZ+c9ZOvTZ9+IeEAIHQ4iyiHwwg/Ne1UpXLz8TI JufIG8xheO2fZL8HwYjVUs8VUHZz1g0K7eEy8YIY1r6EePdEC7UzkdjHKCnxrMHxKCxSMfKVW4TTg fxb5bwyKSb3b8l8X95PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNWA0-00FDv6-Hm; Thu, 02 Feb 2023 09:45:41 +0000 Received: from mail-bn7nam10on20624.outbound.protection.outlook.com ([2a01:111:f400:7e8a::624] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW8d-00FDHL-Ty for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:44:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YZw+nOB7aD8ewf6acM9LVb80jPOnhqGhKDuN14Y0ED3JDjEnFzlhJaAU8yPs6DtxJsFBFhFEZrGVx62U5C0dM02s3lDk6UQJr+mIM/p7xLlYn+SasB3oANcjwRBZr9NGrb+rqE2a+6WVweqyUyHxdrYH0l8zyglUyIWYVZvDAmvQRqbYJYUZJnfRDfl8u/v72gg2dMDNJCJSeoI99miVM6okEwpj4b3P4vN+vpCmmMP4OmV/gWwFAxzTJ0gipA1hDHAI0lfx2gBydLXJVBQFWg8Pm9pjKPXEGYYWbOIj04J4uLyYlDKFiegcEPzCHP4LLMCg6n4vI/ahCeTegsq8bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ZLZrM4GSYMzhyzC2nQYtiApVF+lzGSXoOy5Fbym7iA=; b=XU2DyB3R/4WsYZpfZ63GaC7D4cHwYYbHLryOLWUsKkgKsk0XzNYHzaQQCkKzYTPwxTZ3HQfs15CeZMWcn7hS805/Xm0XLtsnhu/xIWNeSSR5NbDyvO+78juIqXZ7mK6NhpUohzzkeOymt1Y0xoza9Vk9P4VLbNFOHIR1notgIoMC//GWxEQgvo4r1meq5CKb6/Xjj88P1/jJ6rZxcpu44ijC2KLi9J9dQ5UG0DKy/0BKntekwUMa1lnQE7i+4lLKfdEc69Oc+aJ9WL+XiD+b6YVKurqAQywzP3tuwj35bpM4x2OVxxxNeCRLwccgPbcxkQapvpYDEUyivcPuD3eeOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ZLZrM4GSYMzhyzC2nQYtiApVF+lzGSXoOy5Fbym7iA=; b=JMuyMTTQ+uKsZAx/+zn2YvhJu3yBn1dd/E8LuVMBcNOGVzY+FV5VMTXxO+y/4TifBhP0CTKYqv6T4+2CkjJeLFJRwz5mLnBwDEOHND7oNK+bfbQ97qUFVUze3CXjdDuhrSrcdRBWhUoUAw3FLYCkwGwId75xNthD2N8TKAMok4E= Received: from SN7PR04CA0019.namprd04.prod.outlook.com (2603:10b6:806:f2::24) by DM6PR02MB6954.namprd02.prod.outlook.com (2603:10b6:5:22d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Thu, 2 Feb 2023 09:44:12 +0000 Received: from SN1NAM02FT0057.eop-nam02.prod.protection.outlook.com (2603:10b6:806:f2:cafe::10) by SN7PR04CA0019.outlook.office365.com (2603:10b6:806:f2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25 via Frontend Transport; Thu, 2 Feb 2023 09:44:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0057.mail.protection.outlook.com (10.97.4.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.25 via Frontend Transport; Thu, 2 Feb 2023 09:44:11 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 2 Feb 2023 01:44:06 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:44:05 -0800 Received: from [172.23.64.3] (port=37005 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW8T-000Ccs-N3; Thu, 02 Feb 2023 01:44:05 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 3876E1055C1; Thu, 2 Feb 2023 15:12:28 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 8/9] i2c: xiic: Update compatible with new IP version Date: Thu, 2 Feb 2023 15:11:37 +0530 Message-ID: <1675330898-563-9-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1NAM02FT0057:EE_|DM6PR02MB6954:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fc2f70b-ea0c-4693-2d32-08db05020a1a X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uplB1FBnyk9N7MZg+vp7yedB3NHBlGuW3skkhBPt74JMaIl7n2PDEgZBUx5GHbor/huSakxfboa9yF2GW9GUzKOtHr14fEoWzkg5UEyOKz5l6h8sODsJyMAbHxy/KRASlfEjn8a4Hjb4rzM2ILpxt5VB0xYTlC37A26xDb4MgsHDbeBcQipEQHUFKBnAUlyMsCpsxv1qOXrEhtm13Yiq3+2I6M2up94avI4pbnK+VLrXF67jRDEO8A8yPdKumcwrbjUihaumMowADgetQyOV9hGrkEbdmGqD9bfKopkfDvjiis5h7j0Gw3IS5XalsGjumwqsF9Z4TbM+7LwqGTX2wlLolpKjhWCjzeUClsEkU4UQnwmn2FhfwNvTr2Up2Fcq0c2v40KJULB0MsK6W/x+2r8LItOAvWWfayjZWqcLu6y3KblzRK+T/g+72XX8PMiz+PYrYAYkVHN1MED4NW09hUyjZ7Gtp5OgRvvPXrNfNu+wcx9TpcxUY+KqVACuCd34KwJXWipFIIdx4H0Rzd3vwCrfdA0c+rLxIP+rn1pU1i0+lSBeKCJUKOFwF+brl11tbxKdezQBnYzOUGdcBxAxYgNoM0m0jqlhy5ulTxxWYqvDlLGRKm1IP5T87d7GvpxvR+fR2rDAUmQcMfGHO1WSvMG8WaLLwp4cBlT/iVUugDaZeT4rNZ8k7EDlQW04//tVbjc1ZEQmdPY/0sxDj3JJFrZCa1KwRKz899tXi4RD3ZQEaA1fdarxgxjVsy2Yt4tt X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(136003)(396003)(346002)(39860400002)(376002)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(110136005)(42186006)(15650500001)(36756003)(107886003)(478600001)(40480700001)(2906002)(44832011)(7416002)(54906003)(5660300002)(6666004)(316002)(36860700001)(336012)(70586007)(83380400001)(4326008)(42882007)(70206006)(47076005)(83170400001)(6266002)(186003)(26005)(356005)(41300700001)(7636003)(8936002)(82740400003)(82310400005)(8676002)(2616005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:44:11.9837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fc2f70b-ea0c-4693-2d32-08db05020a1a X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0057.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6954 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014416_067634_318ECDCF X-CRM114-Status: GOOD ( 10.24 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam Xilinx AXI I2C IP is updated with a bug fix for dynamic mode reads. Older IPs are handled with a workaround in which they are using xiic standard mode for all these effected use cases. Added the new IP version to compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 8503b5016aaf..682b3567e83e 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -1074,6 +1074,7 @@ static const struct xiic_version_data xiic_2_00 = { #if defined(CONFIG_OF) static const struct of_device_id xiic_of_match[] = { { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, + { .compatible = "xlnx,axi-iic-2.1", }, {}, }; MODULE_DEVICE_TABLE(of, xiic_of_match); From patchwork Thu Feb 2 09:41:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13125660 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52ECFC61DA4 for ; Thu, 2 Feb 2023 09:47:30 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HlVHKNeUxPToGDPn141NRK0QLcorsCkG+bqp0hsmCLQ=; b=fOEiTsRyXNGH4Z fkdaEQhHdMjGtZyNWenagPMDnE9pRMa+cLB76bEJuGF2zNHPXXjrshCSjskD43cbShAG4PGgDql+B wNzHgRBxUi6l9a/AkVKK5O3hm5Fylv2L09EVvVrS7QspBf9gL/S+ahR7oQcBRjNEJX5xJrWwLJvo5 twC+Or5kaeOl0W5uGN0ni722TbVK8PmwEEoaaTwGyAbL6k9pH7Pz8eG7DQAsCHzeuzHzAsxmYtIkk mnceVptemoDBTtGkJGOCZCT+HqQXHDWrYsan6C5AqZcE7JBewGvE90s/i/aSxYsBvD9rR9MFY/X/i yD5mQuTqM5ur0yyEZCTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNWAY-00FE9N-6w; Thu, 02 Feb 2023 09:46:15 +0000 Received: from mail-co1nam11on2062c.outbound.protection.outlook.com ([2a01:111:f400:7eab::62c] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNW8o-00FDMx-LE for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 09:44:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KuVLr02hqG/a5MAVEWBgR7cRbI/xhiCIuUgBEoDdEnVIcj33NIPOjAl14ZZFmHyYYZMqDtJxYKAMcYU1owbIXRRU721Cjq/qdCpPylylH27u9PNPHw6dgj2icP5TqLCzGsh4Tf913cEN0ooGLm+ilYi+va5qaTfMfWjCvA0Vk6OzDo3NJW2cbNi6rUo7KdosblMnTQN02WqECbLlKjcYul/UFJpk9v3dCm4+nzVr36wJVUK1in6br3u6sRWclpRjYC2+SIQNw8seuLN68xpF+1GXwJmc5VcJq+FK4cxJl+iq0m7A2xyeRiUIBd8vUNXuWucqZ7D5+1lG4/Am2cCAqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zBsX1+pRlI42Vjnyt7QG1jZNA26/1AjE4ooPk5i3+qE=; b=KjxzLXJw65os5HyvFGQPTu9eVFwluWdD2yIJkfVvVs6AYbVHGxm4P0wcqHm0SUpOlCoqa3oxlbeHyv7VlP16bUR8b6wZpxYVBuRQdTgjJRrqPaOWODDk7buKKUFjeJTyXanCA8Pq/PrvggmjV7+4LrLaRgrt8gWAXXiPAYdGeUpBaTt2g+d5z6CsQUW5j1zP7ayvUkhJp86HKQFSlPv0jaNmv1KH7sKzTaCBpkP6WZGBsL6iLQdqtaRi280eZrXTx0UR8BkiwLBI5jrthbZbf75Qzuc2lA2IOSp65biuGU8jtk8FI6aIX3UXx4RGLrg85a3dCAIcakZuQ+TQqcOsng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zBsX1+pRlI42Vjnyt7QG1jZNA26/1AjE4ooPk5i3+qE=; b=iEYSXPaIs7anlDx3cwAcM53OyUHwIFvaYiiCZSFKIwwtrTP2rGNoeMKlOquo5xJr5b/VY9IJtcVeW/F0NvQnVsvgwU6ytZRVUoakA7fd6FUp0gx27wIZlSHaOhS7nE8M5h3+iRwVAuxDSRFrEpHg0WhHnOZJIPmPaVJOQqOFpqc= Received: from BN8PR16CA0033.namprd16.prod.outlook.com (2603:10b6:408:4c::46) by BL3PR02MB7905.namprd02.prod.outlook.com (2603:10b6:208:350::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27; Thu, 2 Feb 2023 09:44:22 +0000 Received: from BN1NAM02FT054.eop-nam02.prod.protection.outlook.com (2603:10b6:408:4c:cafe::a7) by BN8PR16CA0033.outlook.office365.com (2603:10b6:408:4c::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:44:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT054.mail.protection.outlook.com (10.13.2.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.27 via Frontend Transport; Thu, 2 Feb 2023 09:44:22 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Feb 2023 01:44:19 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Feb 2023 01:44:19 -0800 Received: from [172.23.64.3] (port=37007 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pNW8g-0003ds-RP; Thu, 02 Feb 2023 01:44:19 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 020091055C2; Thu, 2 Feb 2023 15:12:28 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V4 9/9] i2c: xiic: Add SCL frequency configuration support Date: Thu, 2 Feb 2023 15:11:38 +0530 Message-ID: <1675330898-563-10-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> References: <1675330898-563-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT054:EE_|BL3PR02MB7905:EE_ X-MS-Office365-Filtering-Correlation-Id: 076663b6-8f12-4983-5e9e-08db0502107b X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8kU8oUHguI1Du/ZYAU9sldcINyHDQKtOb3jIEJVgNpzSqA9rhRE1rZbLp2v07eBmqm/ggmXVJzbWBiZf3XlRTIkMfMVVgCqkCz2Vqw8oNg85DssrnIKvtGb7Ggr9UD1Ou+lnekblFvNoz+HNOd5jWEtMHr+WcLNteAYbygilGNEvb+0nIKndaHrW9TdrvF4L+VZNffdAAUYNWbKcpfM+cuswoNOaBpEFnHD2aeWHb2mS6Giowq+la1EKG/oevnPMa1yRFzZ7o9iU83nurtDtld1ZtxepzqXEwZlS9kc0XyyFvwW7KnodbnyWiKDaWpHpMJWyiIgIy/aUNYnGYsLEwhOUGzelYI3Ow2X6roM4W+qJTm4NK2FLR75pSzhn4WSoaTeYTAUYX94EkujsSIlX2LT8HCo84q5o6Y7qOXrY0obMXYGfk2xyEre1782lfqFt7/9ehrd6aFfXtwBlacyGm7qaKXW2c5VBNV+SCXWSBeRHt7igPNdwY1QFKj5ZKXKHlcL8HkTyXAZdbJRTeLZ7MoIQMtMXJ8LTu8Mz9MCb1LPAc6rKcwzPIExYj5YF1SOm8RceEsJGoxxy2rtdkQjOlKXsUOq0amCE9pwNp1ao+I0qB1gX9nMYHp1HHYTQyTP6fb08NFTw6tG/UmnGe1avDaPvL3C6rpMJSCt7gkYS32Asedvny86ZvlQMnv00+ddNfntJOZ1vwJ6Dd9H9VgUQHXvyPNyhDyEpW/gQKMeE7Hp4HnIhNS5rQvZLMyXzEFrG X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230025)(136003)(346002)(396003)(39860400002)(376002)(451199018)(40470700004)(36840700001)(46966006)(40460700003)(36860700001)(40140700001)(478600001)(316002)(42186006)(54906003)(110136005)(186003)(26005)(36756003)(6266002)(107886003)(6666004)(82310400005)(5660300002)(7416002)(2906002)(44832011)(4326008)(70586007)(70206006)(8676002)(8936002)(41300700001)(40480700001)(83380400001)(336012)(2616005)(7636003)(42882007)(47076005)(356005)(82740400003)(83170400001)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 09:44:22.6088 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 076663b6-8f12-4983-5e9e-08db0502107b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT054.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB7905 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_014426_796780_603DAA38 X-CRM114-Status: GOOD ( 23.13 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam From 'clock-frequency' device tree property, configure I2C SCL frequency by calculating the timing register values according to input clock. After soft reset in reinit function, the timing registers are set to default values (configured in design tool). So, setting SCL frequency is done inside reinit function after the soft reset. This allows configuration of SCL frequency exclusively through software via device tree property, overriding the design. If the clock-frequency parameter is not specified in DT, driver doesn't configure frequency, making it backward compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 682b3567e83e..1e89e8270749 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -46,6 +46,12 @@ enum xiic_endian { BIG }; +enum i2c_scl_freq { + REG_VALUES_100KHZ = 0, + REG_VALUES_400KHZ = 1, + REG_VALUES_1MHZ = 2 +}; + /** * struct xiic_i2c - Internal representation of the XIIC I2C bus * @dev: Pointer to device structure @@ -66,6 +72,8 @@ enum xiic_endian { * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info * @smbus_block_read: Flag to handle block read + * @input_clk: Input clock to I2C controller + * @i2c_clk: I2C SCL frequency */ struct xiic_i2c { struct device *dev; @@ -86,12 +94,37 @@ struct xiic_i2c { bool prev_msg_tx; u32 quirks; bool smbus_block_read; + unsigned long input_clk; + unsigned int i2c_clk; }; struct xiic_version_data { u32 quirks; }; +/** + * struct timing_regs - AXI I2C timing registers that depend on I2C spec + * @tsusta: setup time for a repeated START condition + * @tsusto: setup time for a STOP condition + * @thdsta: hold time for a repeated START condition + * @tsudat: setup time for data + * @tbuf: bus free time between STOP and START + */ +struct timing_regs { + unsigned int tsusta; + unsigned int tsusto; + unsigned int thdsta; + unsigned int tsudat; + unsigned int tbuf; +}; + +/* Reg values in ns derived from I2C spec and AXI I2C PG for different frequencies */ +static const struct timing_regs timing_reg_values[] = { + { 5700, 5000, 4300, 550, 5000 }, /* Reg values for 100KHz */ + { 900, 900, 900, 400, 1600 }, /* Reg values for 400KHz */ + { 380, 380, 380, 170, 620 }, /* Reg values for 1MHz */ +}; + #define XIIC_MSB_OFFSET 0 #define XIIC_REG_OFFSET (0x100 + XIIC_MSB_OFFSET) @@ -110,6 +143,19 @@ struct xiic_version_data { #define XIIC_RFD_REG_OFFSET (0x20 + XIIC_REG_OFFSET) /* Rx FIFO Depth reg */ #define XIIC_GPO_REG_OFFSET (0x24 + XIIC_REG_OFFSET) /* Output Register */ +/* + * Timing register offsets from RegisterBase. These are used only for + * setting i2c clock frequency for the line. + */ +#define XIIC_TSUSTA_REG_OFFSET (0x28 + XIIC_REG_OFFSET) /* TSUSTA Register */ +#define XIIC_TSUSTO_REG_OFFSET (0x2C + XIIC_REG_OFFSET) /* TSUSTO Register */ +#define XIIC_THDSTA_REG_OFFSET (0x30 + XIIC_REG_OFFSET) /* THDSTA Register */ +#define XIIC_TSUDAT_REG_OFFSET (0x34 + XIIC_REG_OFFSET) /* TSUDAT Register */ +#define XIIC_TBUF_REG_OFFSET (0x38 + XIIC_REG_OFFSET) /* TBUF Register */ +#define XIIC_THIGH_REG_OFFSET (0x3C + XIIC_REG_OFFSET) /* THIGH Register */ +#define XIIC_TLOW_REG_OFFSET (0x40 + XIIC_REG_OFFSET) /* TLOW Register */ +#define XIIC_THDDAT_REG_OFFSET (0x44 + XIIC_REG_OFFSET) /* THDDAT Register */ + /* Control Register masks */ #define XIIC_CR_ENABLE_DEVICE_MASK 0x01 /* Device enable = 1 */ #define XIIC_CR_TX_FIFO_RESET_MASK 0x02 /* Transmit FIFO reset=1 */ @@ -310,12 +356,102 @@ static int xiic_wait_tx_empty(struct xiic_i2c *i2c) return 0; } +/** + * xiic_setclk - Sets the configured clock rate + * @i2c: Pointer to the xiic device structure + * + * The timing register values are calculated according to the input clock + * frequency and configured scl frequency. For details, please refer the + * AXI I2C PG and NXP I2C Spec. + * Supported frequencies are 100KHz, 400KHz and 1MHz. + * + * Return: 0 on success (Supported frequency selected or not configurable in SW) + * -EINVAL on failure (scl frequency not supported or THIGH is 0) + */ +static int xiic_setclk(struct xiic_i2c *i2c) +{ + unsigned int clk_in_mhz; + unsigned int index = 0; + u32 reg_val; + + dev_dbg(i2c->adap.dev.parent, + "%s entry, i2c->input_clk: %ld, i2c->i2c_clk: %d\n", + __func__, i2c->input_clk, i2c->i2c_clk); + + /* If not specified in DT, do not configure in SW. Rely only on Vivado design */ + if (!i2c->i2c_clk || !i2c->input_clk) + return 0; + + clk_in_mhz = DIV_ROUND_UP(i2c->input_clk, 1000000); + + switch (i2c->i2c_clk) { + case I2C_MAX_FAST_MODE_PLUS_FREQ: + index = REG_VALUES_1MHZ; + break; + case I2C_MAX_FAST_MODE_FREQ: + index = REG_VALUES_400KHZ; + break; + case I2C_MAX_STANDARD_MODE_FREQ: + index = REG_VALUES_100KHZ; + break; + default: + dev_warn(i2c->adap.dev.parent, "Unsupported scl frequency\n"); + return -EINVAL; + } + + /* + * Value to be stored in a register is the number of clock cycles required + * for the time duration. So the time is divided by the input clock time + * period to get the number of clock cycles required. Refer Xilinx AXI I2C + * PG document and I2C specification for further details. + */ + + /* THIGH - Depends on SCL clock frequency(i2c_clk) as below */ + reg_val = (DIV_ROUND_UP(i2c->input_clk, 2 * i2c->i2c_clk)) - 7; + if (reg_val == 0) + return -EINVAL; + + xiic_setreg32(i2c, XIIC_THIGH_REG_OFFSET, reg_val - 1); + + /* TLOW - Value same as THIGH */ + xiic_setreg32(i2c, XIIC_TLOW_REG_OFFSET, reg_val - 1); + + /* TSUSTA */ + reg_val = (timing_reg_values[index].tsusta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTA_REG_OFFSET, reg_val - 1); + + /* TSUSTO */ + reg_val = (timing_reg_values[index].tsusto * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTO_REG_OFFSET, reg_val - 1); + + /* THDSTA */ + reg_val = (timing_reg_values[index].thdsta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_THDSTA_REG_OFFSET, reg_val - 1); + + /* TSUDAT */ + reg_val = (timing_reg_values[index].tsudat * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUDAT_REG_OFFSET, reg_val - 1); + + /* TBUF */ + reg_val = (timing_reg_values[index].tbuf * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TBUF_REG_OFFSET, reg_val - 1); + + /* THDDAT */ + xiic_setreg32(i2c, XIIC_THDDAT_REG_OFFSET, 1); + + return 0; +} + static int xiic_reinit(struct xiic_i2c *i2c) { int ret; xiic_setreg32(i2c, XIIC_RESETR_OFFSET, XIIC_RESET_MASK); + ret = xiic_setclk(i2c); + if (ret) + return ret; + /* Set receive Fifo depth to maximum (zero based). */ xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, IIC_RX_FIFO_DEPTH - 1); @@ -1138,6 +1274,15 @@ static int xiic_i2c_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(i2c->dev); pm_runtime_set_active(i2c->dev); pm_runtime_enable(i2c->dev); + + /* SCL frequency configuration */ + i2c->input_clk = clk_get_rate(i2c->clk); + ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &i2c->i2c_clk); + /* If clock-frequency not specified in DT, do not configure in SW */ + if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ) + i2c->i2c_clk = 0; + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, xiic_process, IRQF_ONESHOT, pdev->name, i2c); @@ -1181,6 +1326,9 @@ static int xiic_i2c_probe(struct platform_device *pdev) i2c_new_client_device(&i2c->adap, pdata->devices + i); } + dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", + (unsigned long)res->start, irq, i2c->i2c_clk); + return 0; err_clk_dis: