From patchwork Thu Sep 22 08:44:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 608471 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55F1FC6FA8B for ; Thu, 22 Sep 2022 08:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230466AbiIVIqC (ORCPT ); Thu, 22 Sep 2022 04:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiIVIpW (ORCPT ); Thu, 22 Sep 2022 04:45:22 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5203491F9; Thu, 22 Sep 2022 01:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJQj+Hb5u38Dwl0NKZBBBG5AjsG2f6N8Y8g89HPHaB61e+5QhQCoJ2f2yYBlq24bD9V4xiwDdJlrT4u4RwRtagaTve8GweGxfbAmdpwryajoJc+4ZYWpPbbxzWWFsWhfdaCoty8yZMuODfhUcppPXZw788P6frswRX7sKKpujiPW+278CkIWnqNRIZDPrEg6j0CM0eciM9SPcjlTChmChVJ9YA49opUYGnGIt2bW3jnKiA0VtUPE7Etoq3hMPI+su76/GNx93zvGxP/vSwtDqbSR0nJQ0RpyGSAPfrzwkfH2UpKxUCJ4A1D86txu574wXo/FscYPHxCYVZ7ww8FbVg== 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=Twx+yANZBCAUgMAHomeKX+mS0EE/ZsMCfq5NwTQOBcg=; b=MG1ARI7eo9R1hqYKmqI/hQTCtGYPFcKg78POieBm0EjFn+dr50ppC5lsjHxVzhDSZlhii++i1UCKyyPOLVl/zrn6Dbo4k78wNU2YqujIwerIGu8FqamQGJ0eSlwp4MnZ04G8O3x5UHkIERsfTwsxtPDuEmXxinIu25WEwIl+040WdwYt1Ch+ZpJknNZPLEafyevGVGg61bwX3YG5TyOtA9mr+QnuJ9OUCGSWncsXfDHroxY2CgI405PHpqcp47NJRUQruuwVU/EsjvIuS/BEmRrJb4neVikjjb8fK5YfSqiWnRb4yMRClUlSQ0tWf4N4XFnrNq1v4fXrrawcttrqsQ== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=Twx+yANZBCAUgMAHomeKX+mS0EE/ZsMCfq5NwTQOBcg=; b=i+0Zoi42K7ftMvSL/sgVhSPUEeVOYX2AsWTgAyr+HT41V2s763834P3bKW3Y8bPsMEBw5hFUbMThN1VgXqjWf/jhdC07qv0EoZqwAITZXbHVHJ7Br69OhMYhKioYxrOz85JEQkg45OxpJZwHZzYBZIytZqWbgolJ0HReBEmjh6w= Received: from BN9PR03CA0083.namprd03.prod.outlook.com (2603:10b6:408:fc::28) by CH3PR02MB9066.namprd02.prod.outlook.com (2603:10b6:610:143::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17; Thu, 22 Sep 2022 08:45:17 +0000 Received: from BN1NAM02FT060.eop-nam02.prod.protection.outlook.com (2603:10b6:408:fc:cafe::8f) by BN9PR03CA0083.outlook.office365.com (2603:10b6:408:fc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18 via Frontend Transport; Thu, 22 Sep 2022 08:45: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=pass action=none header.from=xilinx.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 BN1NAM02FT060.mail.protection.outlook.com (10.13.3.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:45: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.24; Thu, 22 Sep 2022 01:45:17 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:45:17 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54839 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHpc-00016A-Ds; Thu, 22 Sep 2022 01:45:17 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id A689B6102B; Thu, 22 Sep 2022 14:15:03 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 1/9] i2c: xiic: Add standard mode support for > 255 byte Date: Thu, 22 Sep 2022 14:14:46 +0530 Message-ID: <1663836294-5698-2-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT060:EE_|CH3PR02MB9066:EE_ X-MS-Office365-Filtering-Correlation-Id: f52aaafa-f116-4c67-fe93-08da9c76c67a X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tybJIGVGwzufNyqEBWnGCOQ7piXzlO4qtdgliS6tU7bX24pFzNDuAUdf8IUb4duLMQKdIO+dMEeBMIPgKGEVXn06BGmIQVecuszxUVSz5PqwFb0Ma0NNnEN9J9NjS7XD/XhLiL5gJlgneaTFmd9BREvJsxpHFgSXqJ0ZD7mpXlFD5fSm3I5pbcCuxbeYFJ33EhPAn9VQuGc0AWXhVzMfbgbMBL20HzMRxIkgjhL9F3ZB9nX9ePke23ObifwqbVwDRUXuHC3MrmTZAPBnqIDDEgh/U2ehfV9SufSyt0o00oU+RLMfKXeVlsTUaIzoI02GqAwzrZXz080dkQcXwm1ZxnqZst1W5NZTb+iParTEEtD9dWPgp/zXZUXoBPsX6Cc34jcQ0B8PclYBj+zAJMnEgG9/+e1wL2vdzV8R8yjITdNY/TaifAddk8z6aJ0OFAhrbcRSzMNMHHVpsMx6jnjICiygsGszUsy6gzdQJ0aC6IGuhogPAMhjF/Z3B2m3RjPPN5tkHxLGPa6FrqompZhigJjmPTqa4ZyBGaEV07TLzlb0Np6cAJNGxXhDfbJg/FI9TJE2U3mOq7HIaxnSE8ClNJPRbITbZFeZSjajVjyDSYV28Kz02++Ks08Vt0gcDXGCM/leLhXdBBjzOnKFGZReXgB+zQlx3JLjOn5pskYCGuHVazaEtn2RZ62F6diAuTtRgrQqWE7VDSFV/d9wMhCPgY4tu5f2thruA1o0B2ECqsuEn2L9mB4fzjiy9C21tWE0HUfcHPfjYyEWgSKIxy+oLnCfZAYMxJ0jBcYO3GiYsYrRkwI1N5n+JP17SboJ1Jyp 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:(13230022)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(2616005)(426003)(336012)(83380400001)(6266002)(107886003)(47076005)(6666004)(44832011)(41300700001)(70586007)(36860700001)(26005)(70206006)(7636003)(2906002)(30864003)(4326008)(82310400005)(5660300002)(316002)(36756003)(54906003)(42186006)(356005)(40460700003)(82740400003)(186003)(478600001)(110136005)(40480700001)(8936002)(8676002)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:45:17.4963 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f52aaafa-f116-4c67-fe93-08da9c76c67a 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: BN1NAM02FT060.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR02MB9066 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam 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 --- 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 b3fe6b2aa3ca..2aa43e067fee 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 Sep 22 08:44:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 608470 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBA1CC6FA82 for ; Thu, 22 Sep 2022 08:46:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbiIVIqW (ORCPT ); Thu, 22 Sep 2022 04:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbiIVIp4 (ORCPT ); Thu, 22 Sep 2022 04:45:56 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805C8D01CF; Thu, 22 Sep 2022 01:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlefxGqz/cBe7SNntuxXqjnwdTXVkwXd0YrmCNEhsO9+l/4kl9lp8//8eTxHz23+3Azt2qvMF23kP/OKQeEPhY+BbimtgK7PMDobYvA/RqKzqe1QKk7jiBIbw0EZ60fgQVAVGHQrtm04F4K7/UNmyro73Z6dtXuN1MYh+xT8jsZtvX9M9Tf8b7jxqOr+myh5jHK3x0SlRoW9uI4zUjZ3qAegfIzdvuGzoN29KHAbYeSA1HbjyejsvpGl4iEhA4lQ6KpKehx5S3gg3Pg3BIBjWKeMMxwfgI1CqHr33ecI7PPAjS3c7XiQVt8F2rvBtnZrj8B7dFXKMhpWZdZXu/Gx9g== 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=BZPuqdLeH6l6xiuJnevEqGvcSJhif0VPJcF9aXANIx4=; b=PdSHXBMvpeTqWIgQOWQy7exp4/oiBh6B7UnjX+xLcz3aLEz8IQ6qLe3VXdG5YU1UehtRW0ZgWhHRZVDLYCpbx0KAiDHhyCYl7Ypyg212cfexP4CjOIPFzIL7Kolb44UdijuEJIHmlLsImcrsYXBxWs60nExT53VgEL0dbZjMyDxxbh4FjAAf26xO0zWLuzejpJ4Aurdw+VLZqxAkLsDQkRfuN1ldetmlcvJcuACb9CjBaCFZMG5WfhOkLUb4z9VLQNpTBaBvMrxrwclRNKkwPX7d0slIQ2b1omX6K3sef98qJMVrcCZjZIRyc3aZ5cpSp53Oh3xJiQ9W6ytHdBv1gw== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=BZPuqdLeH6l6xiuJnevEqGvcSJhif0VPJcF9aXANIx4=; b=qgm0n53KSfLmwZpw/N4rvDdajrX2Eig6D30nFlow/Pdj1bB54PQUqh3bu9QJAP5+Pij44Ank/p/q9T/lHqXluznyNBazqf9e6wyPYuMNjkVzWB2vC/MRa/sHdIRHkc2NjY6GMU2AgoFPiRdt42XWX6MEV03RNCglgvGfXjCNKRw= Received: from BN9PR03CA0951.namprd03.prod.outlook.com (2603:10b6:408:108::26) by BL3PR02MB7906.namprd02.prod.outlook.com (2603:10b6:208:351::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.16; Thu, 22 Sep 2022 08:45:51 +0000 Received: from BN1NAM02FT050.eop-nam02.prod.protection.outlook.com (2603:10b6:408:108:cafe::38) by BN9PR03CA0951.outlook.office365.com (2603:10b6:408:108::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17 via Frontend Transport; Thu, 22 Sep 2022 08:45:51 +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=pass action=none header.from=xilinx.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 BN1NAM02FT050.mail.protection.outlook.com (10.13.2.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:45:51 +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.24; Thu, 22 Sep 2022 01:45:30 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:45:30 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54840 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHpp-0005X3-TM; Thu, 22 Sep 2022 01:45:30 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id EA82D610BE; Thu, 22 Sep 2022 14:15:05 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 2/9] i2c: xiic: Fix Rx and Tx paths in standard mode Date: Thu, 22 Sep 2022 14:14:47 +0530 Message-ID: <1663836294-5698-3-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT050:EE_|BL3PR02MB7906:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d69a598-3254-4a9b-461f-08da9c76dab5 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uMw2VZjg9V0YOfhdRnnPgwuGhorI5lSyStnW4o3xArVSr1RUHlBdw0N2f2OzVSqAFKtVtw7EPTdLrLO3oAhYgjD+0dHmMKaNWeRLqXU83KQzfmVs7udhXe4b/mVlPD2LTA9BJNIVPtEyjvHpeDtPvGfBQ9Ic/CQTadve15IEsodSKPDlPzvNCnI2Tp9JsD/eWzJ0NEDw9U11tmb3DXf53uHOdPcqmMY13tM+cUypfncJSHbLzmusTYHduCTCmu6K8Zm/AjsEG8CRUs4jWKHAkOJhlhoHKnkocDmm108MhxOBKIFl3r9DPCx5GTONLHFmvcCm4ry9HkujiCg5QULqY++TsrJcyhtQVREJKEqQjdP+u8lcw9PIFASc38Qp75oL+/qdLvux+6qAGmWPPxTZvVC6WijQ3u7blWtukrXnZYSozzg0fMvGI7B8nXCybQXPlCU3WanliNtRH+jEnyN8+x75II9jAdOS4ZAKzjLWg6KAw9nhZ+wPbopGi2gOpZXh3VyYrdIHKk9SMwGUo0nea5E/4k2C6hIlrVBgl9cXDp7SjYYs79B1IcMssfFjvGwQu6EjhwAJ08JSkPWolc2Mcldr6VLjkJEG+tDANtfL6Bn59GSA126ANfVZgCJzcf3C0YegV/xByiVT93PHl2IFJWqpnti/QRvOjQQ07etlYEhQL3ZQD8VrA9Oaqsgxdk8FN89kQ2ZPVVXw0tLCQIxnSj0Xv/83v8EoWlyKEihhSMqoYWbSS9OlWt7y79oxyELgiy0l+vLGrVfgoU/RUI260jy4O26pjMTENbNiDTISx4/Po1yXW7p9nzyUiOd7xqkd 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:(13230022)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(6266002)(26005)(82740400003)(40460700003)(70586007)(316002)(42186006)(70206006)(2906002)(7636003)(40480700001)(356005)(110136005)(36860700001)(36756003)(2616005)(336012)(54906003)(82310400005)(6666004)(478600001)(83380400001)(107886003)(44832011)(186003)(8936002)(5660300002)(426003)(4326008)(41300700001)(8676002)(47076005)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:45:51.4171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d69a598-3254-4a9b-461f-08da9c76dab5 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: BN1NAM02FT050.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB7906 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam 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 --- 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 2aa43e067fee..79802fffa26c 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 Sep 22 08:44:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 609285 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B6B9C6FA8B for ; Thu, 22 Sep 2022 08:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbiIVIqZ (ORCPT ); Thu, 22 Sep 2022 04:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbiIVIqL (ORCPT ); Thu, 22 Sep 2022 04:46:11 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2064.outbound.protection.outlook.com [40.107.223.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFBAB4EB7; Thu, 22 Sep 2022 01:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9COJqNHTwUYUGchW93X/Fl/d+WHhMXfPeuBEtNJQOMQ+NOgSAHKEfnY1mv4kAh/WgYzhszY7XYaQ5zXP/oMKYfWuT1nymtsDtDYau3QzMdHz/9zvb2SHeS14OFX1NheSC0cFpuvL8BYzjkKCzxm1lYvNT69xQLBPe4OZ2h2dZiNPExNC9byyWqZFACcyeKoufqatquGCLzkh4FqCkmAEFQARshFzx61szzufVKn2vPNHmoa0IYwAZaTdIWUk4N/H4VPoD9WMejFulAubgD2JPPT3AOin/mRy7A5GuyQsr9xF0gwgX7itM29Tx0mL2bYnZZhBGGSSiAIJEQdN04aXg== 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=gsHUS3C1n7T3b+RL+BYY69eanxK8oXIrB2rvQchod08=; b=ls0YSZfR28X4ic4WIcaXXwxHnT/ahbEQg4kzikR8ZUAO4xSMsPt6w5K0k3h1unDD0QYD2bGiwVZT2h77N3eHct4evoClzQ4QIkOlz1DGgut7G6aQB6+MLOcy3sZyVKt7Wr2oLW/Ha9IM32LX8187zKW2AzSGebrhoFGeMfJBvSgDFbKRXHagziMeQlMdYkrkulJDfgjIMpQcMsTsqad0Q29QU8zQ7BY0GVERln2HzrqQPICYybCubCYzvf532dECBanAOZf18qdWU6XDUf/W8t1v7J4SghP0Lpk8s3whl3Dc6TSpmcH6KwhfH8qI5iMd7eXPS2U4B1GQ5snpTKsBhA== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=gsHUS3C1n7T3b+RL+BYY69eanxK8oXIrB2rvQchod08=; b=c4Xw2booZ2MT0HI4O6cqUnpR6YWoHB2nbBDWKOW7Nn8LEjPlSsyWRDnLYAeTVsnytQncrI+Gc+8ZFqhAIu1XEOMG68PxwRiRihQjY9FfvGVNKpzLhzNvIMLqcd6VYbfAvaYnErn77ayAtOy5ccId6E+yOxxB9H4dZmI9Q+A9NtI= Received: from BN8PR12CA0031.namprd12.prod.outlook.com (2603:10b6:408:60::44) by BL0PR02MB6513.namprd02.prod.outlook.com (2603:10b6:208:1c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Thu, 22 Sep 2022 08:46:02 +0000 Received: from BN1NAM02FT033.eop-nam02.prod.protection.outlook.com (2603:10b6:408:60:cafe::46) by BN8PR12CA0031.outlook.office365.com (2603:10b6:408:60::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18 via Frontend Transport; Thu, 22 Sep 2022 08:46:02 +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=pass action=none header.from=xilinx.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 BN1NAM02FT033.mail.protection.outlook.com (10.13.3.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:46:02 +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.24; Thu, 22 Sep 2022 01:45:43 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:45:43 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54841 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHq3-0005Xy-6z; Thu, 22 Sep 2022 01:45:43 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id E007C610BF; Thu, 22 Sep 2022 14:15:07 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 3/9] i2c: xiic: Switch to Xiic standard mode for i2c-read Date: Thu, 22 Sep 2022 14:14:48 +0530 Message-ID: <1663836294-5698-4-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT033:EE_|BL0PR02MB6513:EE_ X-MS-Office365-Filtering-Correlation-Id: f45eeda3-6450-4a71-e7d2-08da9c76e156 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GZ1aUBe2kaFr00fZYLms5QTa3xtz1xIE0A0cVN+LdANzoG/zU7pzmrXMhZLMPTot7NS9yKTe8l+If0GQ3LcHz5tLMsi5r5h5c1KvjCur6PQku18p5KOxYbRu0HgFFS65kno5W8IEbbl3/ErB/SxAGyecgmajVUbygaK5hoSPowNQ6vHPfAdbS4hn1H8u33TSbwwJVoplJ/I9RJ6pImwyFKsEMmyoZ+BPjT3Gr/POEEfdl31BWz8o32x32AGQ7irG+mXbYKxe2I4ADlzBJWNOu4CD6o3hwg8clnvQ/UEv46VWCy1QupbI3upV+L0amk0Fjo7hhXByyL7QBSIVHf/00NhuT1bbfYptNBRapUKSL9dQHEXQy9i3pGtiThCsBJMyInFv91rrShdCd+lXm5GC5PmrctDCT4CqwX4vZN2e9n5oI2Avdos2oBjL9Vvl9Iy+PepE8oPALvhYFZKO5z92c1dntrsyiGS7lIy5pUQRpw20ayPn8V+r58863fQFoXT3XIeh7FxzgW+IkATk9NUZhxTwYdCM4ctGudg1CLMp/LhQbVAyVKeKLGRKtqLPwzj0PDn35UeZBcYGO1Aao7rmuLTighXVcIepq/A/ojAzaz5E5IAih7YBu7PDCpIilGlKig7YtLPRL3GqOY00kIWmJmTJK3QhC27ntCOaL4uuaamj1s2oW4ZRQ/kS7+VnOcdyPcibImfsA1NbcIFJIarsC22v0TEOXeS8/s/YkKa1H8Vu4ojgdBNdBDwpuY1vK84/oX6luGb/5Rl4N2eYjvLok3ENrzT9FbHGI3EV/Ec+vD9QL9EXZZrnktibkAbotno/ 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:(13230022)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(40460700003)(336012)(5660300002)(8936002)(40480700001)(54906003)(2906002)(316002)(6266002)(83380400001)(42186006)(426003)(47076005)(110136005)(26005)(356005)(7636003)(6666004)(107886003)(41300700001)(2616005)(186003)(44832011)(36860700001)(478600001)(82740400003)(82310400005)(70206006)(70586007)(4326008)(8676002)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:46:02.5270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f45eeda3-6450-4a71-e7d2-08da9c76e156 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: BN1NAM02FT033.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB6513 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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 --- 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 79802fffa26c..10e0fafb25f1 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)) @@ -1109,14 +1135,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 Sep 22 08:44:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 608469 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ABADC6FA8B for ; Thu, 22 Sep 2022 08:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbiIVIqw (ORCPT ); Thu, 22 Sep 2022 04:46:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbiIVIqa (ORCPT ); Thu, 22 Sep 2022 04:46:30 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14348B6565; Thu, 22 Sep 2022 01:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gga7+V4El/7Bi2ZrSw+b9R5HeDQvEPjxw4PgRx8AFRTzuJS4wOTxtAhDEHpQGj3mKREx1zKLFrEhZHGfZLpbr6oChsnsyKe1QU4j8zga0inXwurFboqKQzxJGAI5iNHILxgsDwXmnl08gEq6NJ/54nt4zCFN9nxSrpktki4iTOcehzPpzM2DG3+x5P4tSyh1SEurm/M8HjJCAElxTLYZ7KFvsuqciTnO6VbEFmfI5F0sSSasybOsdzH6NxYYE4Pg/LoNp1tbkvQXC/7GjbkuZGumdbpLqINPErJTYz/f3lJIFO/9R8KdCJMtID6MQW5prsls+apsaGqTUUTiJG0nOw== 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=5KJwMFuuDmz5apsIasDs37iISZynxtGyatMYsHtHn9k=; b=WC3yAA/5KQVaBkeOeemdCGGBXFylfp5zEd2uEQ5Qcr3QZt2fYJ0ALCpP9QPWWbMDxn79v9MfgY7GXY1pCw2M33mw0LExBq11Dmn5CPSgvoCVr2tMhnypxBjtxm9rY0itlKxCbD7eF6S0+zsbG7hd8BJqx/6+X8V5YRBO5oK+Q2Pm+XuKJF6u3EK9RknR9Laqhnah3XSgj5Dwg+9s+2m5uVR1jciFIHqI/jCr+tlhKXnKXKrV06ypdV8ESgKeyCwwxHhwUndTrKzGYFayvwcHD7Jna+jPo543uzxlukQYdBr70rleZFGTXYqJtxcnXoYAX1lvneHYnrpLk2g55EjzQA== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=5KJwMFuuDmz5apsIasDs37iISZynxtGyatMYsHtHn9k=; b=Ip4i3HHnaa9AEAmQJqgZOkxuec7uViC/eZFP4P1Ac/pAbbwB4iUS+3E2KLuUAk/d63jbkEk8IluyHzkLwAYRO5cB7ok7sSFZhdiaKp0zQF8oUDdkaaCHLGw7WERGb0zv3vG7rrxLkVizzT/d+eYBmOWF2CGGZKeuQRr6+EhgCKM= Received: from BN9PR03CA0943.namprd03.prod.outlook.com (2603:10b6:408:108::18) by SJ0PR02MB7232.namprd02.prod.outlook.com (2603:10b6:a03:2a2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17; Thu, 22 Sep 2022 08:46:13 +0000 Received: from BN1NAM02FT050.eop-nam02.prod.protection.outlook.com (2603:10b6:408:108:cafe::c1) by BN9PR03CA0943.outlook.office365.com (2603:10b6:408:108::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.19 via Frontend Transport; Thu, 22 Sep 2022 08:46:13 +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=pass action=none header.from=xilinx.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 BN1NAM02FT050.mail.protection.outlook.com (10.13.2.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:46:12 +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.24; Thu, 22 Sep 2022 01:45:56 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:45:56 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54842 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHqG-0005Yh-HM; Thu, 22 Sep 2022 01:45:56 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id 349BF61050; Thu, 22 Sep 2022 14:15:10 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 4/9] i2c: xiic: Add wait for FIFO empty in send_tx Date: Thu, 22 Sep 2022 14:14:49 +0530 Message-ID: <1663836294-5698-5-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT050:EE_|SJ0PR02MB7232:EE_ X-MS-Office365-Filtering-Correlation-Id: 4efbda05-ef01-4860-a43f-08da9c76e785 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4lZosBZ+aZnJb/uX2AxMfVoTfxpqddMIsQAmA1hlHsrW0CSWgkosaZ0xN5y7FsDKqqKaQw8gIY/yanRkiqmqMu7WciDGEgvCjdXwG3E9cP+kOVdajw8Ch/8Yupmn9hh5qs5IPi6jE/wTM8SztfRf+8jjgzv7U+XUySF6DQq7HY7n1Onm9Fm1O1QwRu96PaGuz51zooU2PFgYAl6YOiNuIfCX0dw5wqe8OacQLCd9V0DavhWhTzd/VUHJr3OxpAFLomT8soAdZ6gYZIBx2zQ2qjmZ3xvaMa+Fr9b7HbVOZkVbTKJlP/PBVTFaDBnKAOS6PZZ+V/uktSBn45or9aafJ3ZvU49IEiJ9lYlDpF6Yctf3o60LAT9NSItKdzVQdE1vPS3MezC5GwjnuaXOV3/YcAR+wUSBDC0P2Unnwu7CV9eIxAMgs3WZimyeVanpEGoEu8/axEJV2pSb77vmhOLL/io9eKIwXSCwaDm/5X3ifeEiSiyqb2/vveOl4boYOUjlDnWDFGavBjp4uQWBCJiiQNhQvMsaxZfKpQG+cwrZAHB80gmwiJ7T0jcKqjlh7y4730Bj/kDfYcSFrC8fpsHUa0m0P0c8tHdFSjV8w5rUk+ctzFtP2Wjvz3I/nxHQsBGOPrW8A5tgMocSpJwr1wuLYYpvST79AIuXpm+ZU1h9596/MJPhoB1xzoPQZd5Ku6XZDVlOI+WZF3WD1Z1Ir42SdQkW8vF1fH1sUbKGl9UI2+WmPYz4dz0ZQn3YQ3pDnGJs/Np6wYPlpuZIyoaIZNIOfnDndGLAc3kpQBclxxPhF/nnDcWMJBJ3FNH4gu4IAfRY 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(40470700004)(46966006)(36840700001)(70206006)(47076005)(336012)(356005)(7636003)(4326008)(70586007)(40480700001)(5660300002)(2906002)(44832011)(82740400003)(36756003)(8936002)(40460700003)(36860700001)(478600001)(426003)(82310400005)(26005)(186003)(2616005)(8676002)(6266002)(107886003)(54906003)(41300700001)(6666004)(110136005)(316002)(42186006)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:46:12.9153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4efbda05-ef01-4860-a43f-08da9c76e785 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: BN1NAM02FT050.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB7232 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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 --- 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 10e0fafb25f1..1149104074a7 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 Sep 22 08:44:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 609284 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5258C6FA82 for ; Thu, 22 Sep 2022 08:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbiIVIrF (ORCPT ); Thu, 22 Sep 2022 04:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiIVIql (ORCPT ); Thu, 22 Sep 2022 04:46:41 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F84BD0784; Thu, 22 Sep 2022 01:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WYJ0A5O/vRSCXaNHx7jBmeCxxAtTyaHFadaQ9k2hBWJrHB7OffsjFCzVtv45ZZnJdn0+vR8CE4v/fJXDtZy3n4mWOgNNK6xgwcHtxNQnxcs/+dmYRcmcEABrgTJR9LJxot2Zl9CVMBXJnqYecWjd1VoNflwEDTkXjqt/LJTrQqmt3htrPpgArBUiYkuF17nR+UO9EUs1KknpbZS3htsHces2t8Xu466ttQc9+aEIm6wD9z3xf47/Jp45Dc7taTKXlx4cOIu7FDJ/11MNIPBN6vI2o+ftJeQ7M166G7W0FXidTczHEXEPRl+H8TMpA9dj7dqtV47J7145T5FeZw4sLQ== 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=w5EIQEq/Tx7ZHLxSepp76JSAB0cjGhHVe142jzVakJs=; b=k+3g/0Cx34SWLYMbVVz2RCJJDpWB8YoRGyJPwuBnyRFnDCOfY0GM5O+FaDdSl7nYldO3TSFtL8KTTeVj3ETtimaOyzzU7eM9eQs4Tv2Y+mgshULvXgQPBuKJlMMxg7UoC2oUyQ7P9YOs4d2U8eylvp6sZ/kipH0/7YeDdi5bJlOfltKsC2d5qVdf4QLDtjYdzptyvdeaslfIzmtEhikGRmfDS2TVNpYT59M+Ep88ZJ9e3GVUcQyBkOhqnXIoFj2po97+GtxoihVepWZH+H+N+HTBo8s7KRs4rdJatsY7tpE9Kw2EAuKaX3P97kbW4WHBjy/0jJuW1QxLXdwDmqSu0Q== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=w5EIQEq/Tx7ZHLxSepp76JSAB0cjGhHVe142jzVakJs=; b=GMqmsliEYxPwx2MnEjZbypSDz4QHc/eEIwwXFkZtSAqrJ72nRVFpo5FlDrDwBTuxg7FaD34dEzmgOn6BGClB5u9rjnYP2Bl8nNVV4Ous+JObSn6Bo4XueElnxZcn9ULVEpymsXw4fUlqHIURTaDrdIrtHQs3tFW5OA2U9JEOr4s= Received: from BN8PR12CA0002.namprd12.prod.outlook.com (2603:10b6:408:60::15) by SA0PR02MB7274.namprd02.prod.outlook.com (2603:10b6:806:e8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18; Thu, 22 Sep 2022 08:46:27 +0000 Received: from BN1NAM02FT033.eop-nam02.prod.protection.outlook.com (2603:10b6:408:60:cafe::17) by BN8PR12CA0002.outlook.office365.com (2603:10b6:408:60::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18 via Frontend Transport; Thu, 22 Sep 2022 08:46:26 +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=pass action=none header.from=xilinx.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 BN1NAM02FT033.mail.protection.outlook.com (10.13.3.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:46:26 +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.24; Thu, 22 Sep 2022 01:46:10 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:46:10 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54843 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHqT-0001o1-L9; Thu, 22 Sep 2022 01:46:10 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id 5786761053; Thu, 22 Sep 2022 14:15:12 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 5/9] i2c: xiic: Add smbus_block_read functionality Date: Thu, 22 Sep 2022 14:14:50 +0530 Message-ID: <1663836294-5698-6-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT033:EE_|SA0PR02MB7274:EE_ X-MS-Office365-Filtering-Correlation-Id: ee6b69e9-ce3e-49cc-5a19-08da9c76efc1 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MJGUuYZZ6AKOQwPGPEyKKSWdcrX+82OZc5bMHnQK0T7I2uccO0O+76EInTD8ggVfMebNnKqyXr8S338R/MT/ZxxjYnHyKlca3SwbKxRtEl+o/AhveEG3XefJJbQTpI4gtH6jfPuLJtxC/+xhj3Fth/jg8uSokSI5bxLkiIrfUpymTYHKBvUL70RjF2EBR+VdIOuK81scfEuzMAkrdWS2iTA4RoNM37EgcGAGR7TrNN0wKvUxMEWcAtlAuVyq5d4YGmHUxtYzPvPPutl8rO8G0wNES64eDzQGeskLSSxxbsSVDupIy+fNYlQzE7/OGnsoGbugDFk5dN2U9KsRBfuWJ5vqpNWibSXEUYJpQZNIw5ZfM+EvvlcPQiaYIaIdokDFhiToXIthBCBGt4ToNqHUqmZFkVgtnepyGMMNIqLBMi7vntU5HGLAmMVKTy262+SohJ8H2MYI2M22A+xidP3AAnbsJcOv4uEjzKHFl4emzIKzrQGS/n3R2mwDO/G9oefVuXEd7WVv5bzzEcbY7Mqq+hGAi8XfUB2UfezaHZjXg6mm5epFlnlsOZyUuUIjAYiS8G5ipdIpX2ra8nQ2hcC40ScXWS7vJ2nfaKdPgKyz5ENB+uTYQNXWaUncdCpaSM9QGniti7ko3fbPbPx1qG+akiuc/6wKPoV7g9q+tB+PzHSHg5uJFIOSEzZNAIqVv9QwhZYCKI5cBEr29ry+oMF4WJEgzFYYo12HOUgt+zvqgZjKxCWONsdQ+7N9nAek3LmVVE6nfFbBXjrY2GS/fSPxMhAF3M2XaetJ7At5qyz5ZjVtEsLW7P8Mrj5118h8neDGCXqIRKxFy/ZcztCFTU7lbdlmMDexvw43hNX7mtjEHJc= 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:(13230022)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(8936002)(5660300002)(44832011)(316002)(70206006)(110136005)(42186006)(54906003)(70586007)(8676002)(336012)(4326008)(82740400003)(83380400001)(426003)(43170500006)(41300700001)(47076005)(6666004)(107886003)(40460700003)(36860700001)(478600001)(40480700001)(2616005)(186003)(7636003)(26005)(6266002)(82310400005)(356005)(36756003)(2906002)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:46:26.7284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee6b69e9-ce3e-49cc-5a19-08da9c76efc1 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: BN1NAM02FT033.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR02MB7274 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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 --- 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 1149104074a7..8bd33dfdff91 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 Sep 22 08:44:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 608468 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC3EDC6FA82 for ; Thu, 22 Sep 2022 08:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbiIVIrW (ORCPT ); Thu, 22 Sep 2022 04:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbiIVIrA (ORCPT ); Thu, 22 Sep 2022 04:47:00 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 412A86AE93; Thu, 22 Sep 2022 01:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ge0ghQ74EQYRWPa6RObwOQ4zo5/FBpMEl9ET7M3EsQO/RmybyIbV/GargsgWgqNPmtdyhIDzCKUrlYnOxCyTPLM4l6FC9ahlMMdxzTLiNSM2gfi1CgdfyfHOUJZQUTF4iImeY4fMROljD7S0VU5xqu7qMud6djNd2y9LvPbgrrQPmhdpwerMCdSUzgvBxccJi9semF6PvBHOuo8oKvigf5HaFHFqBtCP9FCIa2uJfauu83NFo6Lyu/bJd6hDV0O6PLKnaitUuoVxRCO647HPHxaWpb6+7wdsKMZNySThjovLfgwhEAIdlcjA9R+jLqkkftnKCkKjrTba+mPv7zjD4g== 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=hnTYSsVAd6/RmHTREkppQ/vRl/sJDn4n/3fjpNh/Azs=; b=nzMMy4zvNupnnWDLYhy1UIh9oGL4I85O7ZEd82M6xD/MwadMITf9AtZjn7y4BHeZ6BLIcpEwVc6W4YMje5EdhPQ4/M6b9OIzt9jPpaxihVpRGSHS/IC0SxR/XD7yiE6W4yt08FDutELkJQRhNkqQpeoYHBsAwfpjzPsd1OQivfQYZ5mfoFradErFzG8g5mFcQUJswNdvf+vaLdr7P5086kD+J8Gl731khsulfQ5Hf0h0XyVSs1/Sh+/f2dEfZKEEewl2jh96t9Csh7phoM9wO0wIf/QhE2ISSLYZebHoAjcVQ8kjOf3oILal5p2iyJgJTJvnpUWTN07V2sXFFCBGTA== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=hnTYSsVAd6/RmHTREkppQ/vRl/sJDn4n/3fjpNh/Azs=; b=GhqpYESJlBfRGNj/OjIVAyXpYxqkVn9fzDyYPlZ50FusmQ4dMIiVWLQZT6dd0YbJSIxwCkd67hjY9ISpAXZ44aOU6+5hMMrNlkTdxFcc0TisFIYvZsopTi2OHwJy1wsBYr16x84w9GHIa6HXNhkKueVFUJDFpm4OW+UUTCws/V8= Received: from BN9PR03CA0368.namprd03.prod.outlook.com (2603:10b6:408:f7::13) by SN4PR0201MB8712.namprd02.prod.outlook.com (2603:10b6:806:1eb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17; Thu, 22 Sep 2022 08:46:37 +0000 Received: from BN1NAM02FT058.eop-nam02.prod.protection.outlook.com (2603:10b6:408:f7:cafe::7f) by BN9PR03CA0368.outlook.office365.com (2603:10b6:408:f7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18 via Frontend Transport; Thu, 22 Sep 2022 08:46:37 +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=pass action=none header.from=xilinx.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 BN1NAM02FT058.mail.protection.outlook.com (10.13.2.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:46:37 +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.24; Thu, 22 Sep 2022 01:46:23 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:46:23 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54844 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHqg-00061B-Vx; Thu, 22 Sep 2022 01:46:23 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id 9C01B610B0; Thu, 22 Sep 2022 14:15:14 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 6/9] i2c: xiic: Remove interrupt enable/disable in Rx path Date: Thu, 22 Sep 2022 14:14:51 +0530 Message-ID: <1663836294-5698-7-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT058:EE_|SN4PR0201MB8712:EE_ X-MS-Office365-Filtering-Correlation-Id: 28796093-bc21-4c53-6016-08da9c76f60e X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nzmVttu6dOXZzzYPCeVq3Ha6E3tEOqpA2GIDbA3a/n2qGYXlAgSyJ5Ch9ETKXnGYBKUlISD4WOFgy3jOl+xWzifU35ZhGu8KgwnCOgRxn812rW4QD1NxomkzWr8DK7RzsXJdhuoIoQSJMLPy4obxsOpOy/GURtMj7dx33b+TH4YfzsW0B+E44G4BVFQUo7XhjWwuTBQM2o/05T/9YHBewwqwrshl35gXAJdt9ABiGP9hNSre/OLNfI5qbo7qoNgBSDdGW00vkpiH8K6ptNVnourIhyBhbgbPzF/uHZKYduLY37sB9+8TtZYRTDPo5YL7TABwt5+G9ZWaJZhXUF5uNEtfk//i91cIEHD0GZ7jshFBbPkTLVf7MG7gEfQBloGOSZ+3HIJf9dfoChY4kTIFyaDVgOoxK3PKvQiSFXMfRgoZjZLneU4spQHQDA2JCnT8ketHJMI6b8zmRWfTfepBPM7DH5yIPrk8AwXd8Nbr6YW/TKqlHG6yskSUpKpeMAymOnk/m+Qc5cQafQ2S+xR+iVGyVFg4DqFB3aLMvoqTHBR8sQjO+ye/NVaxcIDQXQAqCAjCYxLgXgq9tvwXNkVCy98fdKcmF2y9YB8kCySi4A6iiVdIIlTGTJm/pgFkUR++fTFo1+xTXvZfdd7DfPzwOcLcaTmrKNc0So6GKiPdXGnar2HXnmYN20ZSPZGk5JYVH+tVsnbf/p2OADJZXWeY3oivO7BPES28O1sWKoGIlS5Vlm60VLHIVBRxMxZ8xaY/kH6pot8/8uMiGhelisF3ZKTC95D+JQ948DU9CovpAqgoHJys79LIJzU9puykgHZNrZjKgNY5r3Kx/vyiyeYn4/vknVjKcMHxct4UfRO0GB15FtGuivejpjgcPc4ap3JG 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:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(44832011)(110136005)(5660300002)(70206006)(42186006)(70586007)(4326008)(8936002)(40480700001)(54906003)(316002)(8676002)(41300700001)(82740400003)(83380400001)(47076005)(36860700001)(7636003)(6666004)(6266002)(478600001)(2616005)(40460700003)(336012)(426003)(186003)(356005)(107886003)(26005)(82310400005)(36756003)(2906002)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:46:37.3151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28796093-bc21-4c53-6016-08da9c76f60e 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: BN1NAM02FT058.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8712 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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 --- 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 8bd33dfdff91..31296e252279 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 Sep 22 08:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 609283 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EDADC6FA8B for ; Thu, 22 Sep 2022 08:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbiIVIrn (ORCPT ); Thu, 22 Sep 2022 04:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbiIVIrK (ORCPT ); Thu, 22 Sep 2022 04:47:10 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061.outbound.protection.outlook.com [40.107.94.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63A52D07B8; Thu, 22 Sep 2022 01:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaO+XLFr5RTXlF2bCQ2mwkZ/qlxeu6zQuVEd9va8UJZn6f43eyuEEfcX+b7gwPwzw4Cf43VxnC95UdU4g1agB+YO+2a+B6U+H1RE/Gb4VspyVLbaZj2ASumDYck9YnwePBdqbi6GnoWYPzhQg/PvkAZpB2SIFc//4XcyfiiCP1nD2XmddiMuHk6uffwPMaNtJ0it922+lXPF45yPvvJv2prjr7lOJv9SxQHGQPNGwEIlaEhNMniXYfKYn8oICy+yV0Zpxi1rviYENkq4OgvmtfUrTjYDL9ibTMJi4jCPw128jjP15AW+i4ql9tnGOHcYzS5TJoPStp9T9ZRCeYreMA== 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=okSr+iEQcgcGyO4EBQbjCiN3vuvsMIawcM/mOV2h7JI=; b=UtCnVZGhzy397WGTRbI9hfBdJaoKRnB3UjuI5y936RtMoFaMvUNoHur8QMvpUANIDdswhFk59kMmLSWAaWgdKZ2RLGRZmi/4h3HAuNbwr/eSaQg9wlXKzzs9feUXAXNROJm4OdVCOPsS+0F/u69ghrf3aapWzR49iuxEwed7EohkemHWWHYv75d7ikprtJ1xfU2y09gWeFKnaLNphAIsUfdpl8gDSLYyr4MRSBtZzz4mTq6fYu8L5sJ5dYPD9vmy+XO3CmAQQA6gt2MlqykTbfTk8XpCgzYBsa/zv9v4qIKl3NxU1nh5sC9/A1qIUH5FMC2YY+cOC4Rs7Y1jpeWwoA== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=okSr+iEQcgcGyO4EBQbjCiN3vuvsMIawcM/mOV2h7JI=; b=pM0+dRKf/EtE4h1y2EdMYkZsS/usfYHN8OtGGZN2n65KC4sBBz5zaWcoVKaY9URuGwzRAfp5w2xL6Tp3kaVATj3dwhddIq+bAxiVzQOOrW6bngPpcnQYA171t6IJj5qsGF7qC+3tswJ7M9BAtuyvzdW5rUX9nRLRu7A+oanauAo= Received: from BN9PR03CA0031.namprd03.prod.outlook.com (2603:10b6:408:fb::6) by CO6PR02MB8706.namprd02.prod.outlook.com (2603:10b6:303:135::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.19; Thu, 22 Sep 2022 08:46:57 +0000 Received: from BN1NAM02FT043.eop-nam02.prod.protection.outlook.com (2603:10b6:408:fb:cafe::cc) by BN9PR03CA0031.outlook.office365.com (2603:10b6:408:fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.18 via Frontend Transport; Thu, 22 Sep 2022 08:46: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=pass action=none header.from=xilinx.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 BN1NAM02FT043.mail.protection.outlook.com (10.13.2.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:46:56 +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.24; Thu, 22 Sep 2022 01:46:36 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:46:36 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54845 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHqu-0001u2-3u; Thu, 22 Sep 2022 01:46:36 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id C67FE610BB; Thu, 22 Sep 2022 14:15:16 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 7/9] dt-bindings: i2c: xiic: Add 'xlnx,axi-iic-2.1' to Date: Thu, 22 Sep 2022 14:14:52 +0530 Message-ID: <1663836294-5698-8-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT043:EE_|CO6PR02MB8706:EE_ X-MS-Office365-Filtering-Correlation-Id: 03060c63-1d27-4651-9b7f-08da9c7701ab X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ZZFK1okCiL2LZ09pmIFZbdyesRPNLNtZ1Sg2mnYYaJq3eVnm+ROHd8f6/MgG3wKlZQhi97PTBT6FHUyqhIT4rcQ1lVqPlb89ktXLtqsEcGV/fGeDVdImJ6XL/siiCnLbSSSeqt+aSI5g0AuXjYzAP6KntHsWw7gNyeWxEHSOgyp1oYyHf3sTL8K0bO8i2HZvTjFwzBqQfiW1KYhQfNXGuG7K2l7kNyiJM1aBniYScIVwMDFyrBWE7x78dPI2Bl/VBtIsEThh0nGhj46NdDOWCIFwpoMVFTUFvA0Ov0CzbmVQbQmaKpqQ8y+IRvQ8r7eYMuVSnM1hZrsYUiLIDk2pfdGWSwwHxpT5+AWb8DazczKRUgPiyCmJ2k+HO5UDP91ea+u4rhWG/7qAglMtZ0FAAeUvPZjOzmiRrIFQPbLiy1Rzat6mw08GzrkZ1YtOur33WIlXlwcgrisxrAxRxqC/JO4AXFthWEYqNYeO+KjppQLbcjYJuseEfAc/I6W3NTXLeziuWwhUFqU74EA5b+9z4dLR03GVQe7+D/caie0cMjQFRJM9V43vhug6XMu2yLG9A9gumMNapEBAWFFsVLRQ65yP98OD65b7PXxxRSR8gIh4ApClXUz4wkcd4CShSvsyeGfhx8smx3+yADiEv9Z9JPj4HRkAOiK1jN3BMfBz4Ufdc+jI4yBdH+3LvEzpHUmTDQIZ+UFCs2GHKoxgiVIARBlHti7ippNqbW1MHDulb5wl6Hr3aHpD7wdeBsGwvj4FswDKBDu80YlXTBKBhS4u1dMTw2rXAibKv09YTGaswIsnEJLBDSymlHesd2j+5HR 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:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(7636003)(82310400005)(356005)(82740400003)(478600001)(6666004)(41300700001)(4326008)(8676002)(316002)(70586007)(70206006)(42186006)(40480700001)(83380400001)(186003)(44832011)(107886003)(110136005)(54906003)(36860700001)(2906002)(26005)(6266002)(5660300002)(40460700003)(47076005)(8936002)(2616005)(336012)(426003)(36756003)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:46:56.7849 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03060c63-1d27-4651-9b7f-08da9c7701ab 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: BN1NAM02FT043.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR02MB8706 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Raviteja Narayanam 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 --- .../devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml | 7 ++++++- 1 file changed, 6 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 715dcfa5a922..be6c18b2c19e 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 @@ -36,6 +38,9 @@ required: - interrupts - clocks +optional: + - clock-frequency + unevaluatedProperties: false examples: From patchwork Thu Sep 22 08:44:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 608467 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B6EFC6FA82 for ; Thu, 22 Sep 2022 08:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbiIVIsC (ORCPT ); Thu, 22 Sep 2022 04:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbiIVIrb (ORCPT ); Thu, 22 Sep 2022 04:47:31 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2073.outbound.protection.outlook.com [40.107.95.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108B96AE99; Thu, 22 Sep 2022 01:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJWJSPBN1Ypx4lbTy1mPvjfs5BXCPXFLDgIZUMkaSi0IUzqDUMIk1Lj0qf+hlHqr5r1X0oAsxujkVdL/+QkJdD9avBgEwh4d0GT5eG7RAl4cNZNXd/wn9fnRNhAk9Gzft7Vo8yD3qP/fgQl8/9n2zKTH19dG/c9+iEYge3cBCyCZMCJw6URmYYRWoj3/DnobXW4fh/BBwktGgqo5m+aGNd6u0CKBDXXJjz7M0NE4m2jMWpHXnT4T2vvgGf5OvOxoUHBT7tJoJM4l2seXELZIDy9ycmSoStLB9PXYrNqCm25RK7lceRvyHyshQ/0OYHXgEHrYuyEh/JMhe7+2KRyENg== 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=oyrjM/Yq/n8vsXiBYPaAl2C8mb0/MmXLz5PbcnDq/SI=; b=mw/kCCiFXXfdMEL4L6lgdWvryd2X9zFxxMQGZQmoP4hb6mOsDMgMW1bN6VIF9Z4ljS0BULdiY1NYVa8t7OPtKN9PWhxyfP/DDsH4ACleta1cWXxY6VrYPI0eaio3L63XiB0DD+/fYu51jJYVVNb9jvHHiS4dFuFmpZa89mxIlQc40Kph8qzdtwQFdV6f3yfdj0j8Ntf4jtpkR36sh226CcqLgLmN29T1NgxVMs9631wag03VW7HdzKhBbeNMQgO7PDe4luxGOPbNpNfXg7YF9X6EeWaDHw1Ippb9Vo8H4clmEPHmvPe/loY/N+Gz/sAM4BBXccBgdkDUAXUJjjGidA== 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=pass (p=none sp=none pct=100) action=none header.from=xilinx.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=oyrjM/Yq/n8vsXiBYPaAl2C8mb0/MmXLz5PbcnDq/SI=; b=O/iP19kaje3bzmXTNQFlZIBSUN9lhh3xFp82TdN4jdHv1TRn3ECh2mhCVFCyz5X3ZeY7PlRignc9jidfJOUTw+H5XClUftJU//n04oR9N2VqCJRICOWOkUCx2eEi4pOCWKh/m5AHKjMgtuY3m101sYmcNDOpT2lsV4sxC+tQgKk= Received: from BN9PR03CA0856.namprd03.prod.outlook.com (2603:10b6:408:13d::21) by SJ0PR02MB8577.namprd02.prod.outlook.com (2603:10b6:a03:3f4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17; Thu, 22 Sep 2022 08:47:10 +0000 Received: from BN1NAM02FT053.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13d:cafe::93) by BN9PR03CA0856.outlook.office365.com (2603:10b6:408:13d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17 via Frontend Transport; Thu, 22 Sep 2022 08:47:10 +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=pass action=none header.from=xilinx.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 BN1NAM02FT053.mail.protection.outlook.com (10.13.2.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 08:47:10 +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.24; Thu, 22 Sep 2022 01:46:49 -0700 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.9 via Frontend Transport; Thu, 22 Sep 2022 01:46:49 -0700 Envelope-to: michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Received: from [172.23.64.6] (port=54846 helo=xhdvnc106.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1obHr7-00062c-8i; Thu, 22 Sep 2022 01:46:49 -0700 Received: by xhdvnc106.xilinx.com (Postfix, from userid 90444) id DBBED6102B; Thu, 22 Sep 2022 14:15:18 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , Raviteja Narayanam , Manikanta Guntupalli Subject: [PATCH V2 8/9] i2c: xiic: Update compatible with new IP version Date: Thu, 22 Sep 2022 14:14:53 +0530 Message-ID: <1663836294-5698-9-git-send-email-manikanta.guntupalli@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> References: <1663836294-5698-1-git-send-email-manikanta.guntupalli@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1NAM02FT053:EE_|SJ0PR02MB8577:EE_ X-MS-Office365-Filtering-Correlation-Id: 1714b3fd-76a6-4561-aa2a-08da9c7709aa X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWzC7yYVUk6oqVM+ws1xRdrd1L6EfAXoMWz5T1G9bsm0o3teKyoMC+C6WEA9pRltJeDVmA4auYdH+oMlGk/9uUk5G6DLUNO5iSbmvG2TOiTYTKvvejxHNYgC8j+ckOJHLdcQHlWMNOtIO9I17NHrUHbpRXndJx9fc3DRIuiTFcZk7wJX2Wygp0KB0u9Bbol84lFMN4KIg5PYkUNgUn1wE7ckPu4S+SzyrXR6ZVNX7l6m10w6HhpOI1cSRC8u8jMIh1ygWkVDpMtbH+GNJtBC73lsoh8JQKRs36SKZ5ROxLQLX05AcrXWyqJJB+6yGjphfqxV5wOfnQfRwnhq7/3rEwAZacDrxl3EixJ5A9xct6N8B0f+KP9YFG1GHVgvU9RgCYde1TMNwo4dSv974Np+3IHe+YzKGbbbIuNQ7p/6eqMYY1D5ytOsHUQuVeMgxA4nqtHWAvopjChJYJ49bBsRoGtjp2IFJuzgUxG7F+Br7AN9kBfJIOf474/1fguTxsPvmYPLvogtNwa7YO6GDER/JrI7ij2qOeLqUp8VopGovIeP1TZhuYUybtAfEQbMubMfxB2vw4NxchTj+4s5FSls1ij37C7NybLKwI0+zrTrJ73q/dHD+X5oWjaKkZhLwAC4mUwIzzVFgVoQVAbBmXKdrQ4bDrEMBpzT8z6jETX7LdOucoRAABoU3L4NlFkrtzednWRkecUPTvaB9Q2O+6ZCnEgmlW7TpKSmXc4pd3E4OAtvFm3DlUwDqyTj/hXgnsoE2czHWuZUV/OrnzToKhodq0FDp0i0FDLdL2US+FvHAgYPW/LXiii1oe5jzntcqLhQ 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:(13230022)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199015)(46966006)(40470700004)(36840700001)(426003)(83380400001)(40480700001)(336012)(40460700003)(47076005)(2906002)(82310400005)(186003)(6266002)(2616005)(82740400003)(7636003)(5660300002)(41300700001)(36756003)(8936002)(107886003)(6666004)(15650500001)(26005)(4744005)(44832011)(356005)(8676002)(4326008)(70206006)(70586007)(316002)(36860700001)(54906003)(110136005)(42186006)(478600001)(102446001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 08:47:10.2161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1714b3fd-76a6-4561-aa2a-08da9c7709aa 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: BN1NAM02FT053.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8577 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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 --- 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 31296e252279..0f03feb2ff78 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);