From patchwork Tue Jan 24 05:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E66FC25B4E for ; Tue, 24 Jan 2023 05:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PbQQpqOzZVcKi2DoUZiIaUa0VEYC3wb8y44HMjtZmeA=; b=ZoPvfODsZB9S8i dbRPMrUF+XiVnv3r1e/iDhz+pbifW2sznZqDqhdFSnlCoUOhcYcbsdbfT/ta8Ze6yOiY6SThxVqEE E5x5Vq+r/G2zMqJI0K80zct6FZVeb5+0o9sWnY+gZK1+YmGCqD+6VK1WDF/hhJoKD/PzUHNaKN1fv dCZMIrMU3xqNLRzgjjZIlmnYpDWtpkTbG5udorgzsM9jbZaW3JmzgMFrkb4sF1lEKbXJW+zZmrMTy qLRmTl60QtCUDkXNFmu5FRFoycHQnta1NkEdTTTQCL2Txbyte0eXwforNFZuN98vavF3j0olWB45/ p+orswrCRj36XScgRVNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBUc-002Hdg-6v; Tue, 24 Jan 2023 05:05:10 +0000 Received: from mail-co1nam11on2082.outbound.protection.outlook.com ([40.107.220.82] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBUY-002HcT-Em for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:05:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hkAz1yaRa+KYrTLC62Ris5QDuSxHkX91ZhESEcqZWLFnWyc4dW7AEXiAl4DZnBznLLdTfEtA5rmasXaozFWKeL9Wg04RMnUCyuIB2GaBX5zlNiR4dnjZR+NnHC6eMzlVMg8AvGLKLAgJICIB2skSOVDmG7SEBKVNji26Le7oS/fx7vxUr/qjSdSOLkNem+8L3moy1pneQeE1hotPneWe+n+chUa1nLTlHti6u4stptAphLn1pXk4kK7kcWTvp4UoX/5yns4q5Fl+Aibh87HhaTox95236Ul3NCaxTMVU5cJsRWInSt7mHLdlwy4iOHFl7uRIBPuOWMhRPdcs7wOfog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9CDCtUY/Xlt4AAaJ94S7dea83SzgaWliGOFTqsANIgY=; b=Xity4SVWuIWsmsGD3YCNY6L/qSm1vyHbj+sGh0zuB40+iilVcWnpYoeLM9lXx/ZBozsnP1qn0Jjtu7zuPtKs0xTPk0TJGMKi7jQiQKPUk0mhj4PmAtBcipoiZcVQv0vhYNB4+8rKacxO6Tt1M5hN7iGscGp9KGb/6tLCcwrBXYxssYqFzHKdyNH/NW2T9NF11xovr3ll5UbANqoO9+FhC70mEe5vMy5iCU8HF1FO7n/ZFe4/ZMhXwchKWAdGcAMOsVQi6FjcRV02XJA5ACJHfRXLnBVmOApeGkIs9DC7kyAX4NtHWVsUgJkUHm9cjaPvEvpBZtCMLCTY8lLM8Pw5AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9CDCtUY/Xlt4AAaJ94S7dea83SzgaWliGOFTqsANIgY=; b=aFGOlwRRUHkC/3Up90CTemJuRyF2BZ4VKjQBA+dehMJW3/SEhcyqNcBE3wkkt5gfea2J4dCvSdvq2T0RrsTZ4IzH4X5/GG3WrYxnu2a7Yy/yExwZthqvqv/fp9FhbEsxfnz7kXAPSeHGjCjFP/RvqkNRDM+Lzk6Lxyz+mQZuwms= Received: from DM6PR01CA0006.prod.exchangelabs.com (2603:10b6:5:296::11) by CH0PR02MB7979.namprd02.prod.outlook.com (2603:10b6:610:104::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:05:02 +0000 Received: from DM3NAM02FT027.eop-nam02.prod.protection.outlook.com (2603:10b6:5:296:cafe::b6) by DM6PR01CA0006.outlook.office365.com (2603:10b6:5:296::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:05: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=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT027.mail.protection.outlook.com (10.13.5.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:05: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.28; Mon, 23 Jan 2023 21:04:59 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:04:59 -0800 Received: from [172.23.64.3] (port=57519 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBUR-0002eX-7l; Mon, 23 Jan 2023 21:04:59 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 8112E105510; Tue, 24 Jan 2023 10:34:46 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 1/9] i2c: xiic: Add standard mode support for > 255 byte Date: Tue, 24 Jan 2023 10:34:34 +0530 Message-ID: <1674536682-25278-2-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT027:EE_|CH0PR02MB7979:EE_ X-MS-Office365-Filtering-Correlation-Id: 39ab4aad-f5da-4867-bc27-08dafdc88cc5 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRPMtA/2nrgXKP4WdbZh9o/u6xDlixN5nf0k86shwTyWDr6v2ktc/9I2N4OSEKU+WxxR8KSJcynn+6ns2eTwjHRYJUEbgj77TEI8SjWXSFaZdcQZBk6GsirnPkJuod6l0K14ZGBB3AOXFS5GTwAEZbHOzLdjmDEBgLNTo4p6oAYCJ1iSnvVOjanbWYqNfQPXfa873Vr2Thp6/MRu82F2kgd9SAXnkadW2NRkqdx9cau5t7gCrOqqn6B38+dNuYeWRUdb7k0XCra3FRSWhhTNzXhDE5ZcqDjvXMk94VxFIYdFCbeder7wdIlL1zjF5VNToP6qEgXSCgKtjxBYPJVQL/pXv7D4IfiPmGPJLeAHkN4b7kmWDOa5BsdbBXD0GWs5g/IWlSlrfB2TrFib9vx679fyJ7s3OkjrzHUpVxuIWDsjNHZy5tODmi8zlWLmCxrVbetFsWAd8UQWzGrb20LEKaNiiZBV29TQjx5bIKLpFSRfIOTBFRsVj2Sa81BgsZQosmRHe+gsYgFwFxdAewekX8CuuiL2pWD4nakAZ+PgjxyaoP/aV5u2PLSbwKR3im949GDmHipOYJ30fkc4brVE1C/8gTkU87a728PjlhrVSHuVF6ql7jdZ1PkeE8s9dxkXEdcSUCF6V5dasjH0MF0mo5F31UNcmmK7xKJaKNTvTKxWyqt6TRiZAh5KYGJP9RotBMqdOIk/QE0XSArduXU13vTgQK0BNzte9ebZuhPQpKqSJWzOVRPPMvHYyanWYfu5 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)(376002)(39860400002)(346002)(396003)(136003)(451199015)(36840700001)(46966006)(40470700004)(8676002)(4326008)(70206006)(70586007)(2616005)(47076005)(83380400001)(6666004)(107886003)(41300700001)(26005)(8936002)(30864003)(36860700001)(44832011)(186003)(6266002)(2906002)(42186006)(5660300002)(110136005)(82740400003)(83170400001)(7636003)(356005)(82310400005)(316002)(336012)(478600001)(42882007)(54906003)(40460700003)(36756003)(40480700001)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:05:02.2464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39ab4aad-f5da-4867-bc27-08dafdc88cc5 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: DM3NAM02FT027.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB7979 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210506_567102_56D189BE X-CRM114-Status: GOOD ( 32.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam read transfers Added standard mode for AXI I2C controller to enable read transfers of size more than 255 bytes. The driver selects standard mode in the following scenarios. 1. If a single message request comes from user space, requesting a read of more than 255 bytes 2. If a message set request comes from user space consisting of many messages and if any one of them is a read operation, irrespective of the size of transfer. (This is done because it is observed that repeated start operation is not happening in dynamic mode read as expected in a message set request from user space.) Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- Changes for v2: Merged the logic of xiic_std_fill_tx_fifo into xiic_fill_tx_fifo to remove duplicate code. Handled i2c msg->len == 0 case. Squashed "Use 'nmsgs' variable instead of repeated_start" patch. Squashed "Correct the BNB interrupt enable sequence" patch. Squashed "remove unsupported flag I2C_M_NOSTART code" patch. --- drivers/i2c/busses/i2c-xiic.c | 266 ++++++++++++++++++++++++++++------ 1 file changed, 225 insertions(+), 41 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index bee5a2ef1f22..839564054501 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -60,6 +60,7 @@ enum xiic_endian { * @clk: Pointer to AXI4-lite input clock * @state: See STATE_ * @singlemaster: Indicates bus is single master + * @dynamic: Mode of controller */ struct xiic_i2c { struct device *dev; @@ -76,6 +77,7 @@ struct xiic_i2c { struct clk *clk; enum xilinx_i2c_state state; bool singlemaster; + bool dynamic; }; #define XIIC_MSB_OFFSET 0 @@ -143,6 +145,9 @@ struct xiic_i2c { #define XIIC_TX_DYN_START_MASK 0x0100 /* 1 = Set dynamic start */ #define XIIC_TX_DYN_STOP_MASK 0x0200 /* 1 = Set dynamic stop */ +/* Dynamic mode constants */ +#define MAX_READ_LENGTH_DYNAMIC 255 /* Max length for dynamic read */ + /* * The following constants define the register offsets for the Interrupt * registers. There are some holes in the memory map for reserved addresses @@ -316,13 +321,14 @@ static void xiic_deinit(struct xiic_i2c *i2c) static void xiic_read_rx(struct xiic_i2c *i2c) { - u8 bytes_in_fifo; + u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; + u32 bytes_rem = 0; int i; bytes_in_fifo = xiic_getreg8(i2c, XIIC_RFO_REG_OFFSET) + 1; dev_dbg(i2c->adap.dev.parent, - "%s entry, bytes in fifo: %d, msg: %d, SR: 0x%x, CR: 0x%x\n", + "%s entry, bytes in fifo: %d, rem: %d, SR: 0x%x, CR: 0x%x\n", __func__, bytes_in_fifo, xiic_rx_space(i2c), xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); @@ -330,13 +336,52 @@ static void xiic_read_rx(struct xiic_i2c *i2c) if (bytes_in_fifo > xiic_rx_space(i2c)) bytes_in_fifo = xiic_rx_space(i2c); - for (i = 0; i < bytes_in_fifo; i++) + bytes_to_read = bytes_in_fifo; + + if (!i2c->dynamic) { + bytes_rem = xiic_rx_space(i2c) - bytes_in_fifo; + + if (bytes_rem > IIC_RX_FIFO_DEPTH) { + bytes_to_read = bytes_in_fifo; + } else if (bytes_rem > 1) { + bytes_to_read = bytes_rem - 1; + } else if (bytes_rem == 1) { + bytes_to_read = 1; + /* Set NACK in CR to indicate slave transmitter */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr | + XIIC_CR_NO_ACK_MASK); + } else if (bytes_rem == 0) { + bytes_to_read = bytes_in_fifo; + + /* Generate stop on the bus if it is last message */ + if (i2c->nmsgs == 1) { + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_MSMS_MASK); + } + + /* Make TXACK=0, clean up for next transaction */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_NO_ACK_MASK); + } + } + + /* Read the fifo */ + for (i = 0; i < bytes_to_read; i++) { i2c->rx_msg->buf[i2c->rx_pos++] = xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); + } - xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, - (xiic_rx_space(i2c) > IIC_RX_FIFO_DEPTH) ? - IIC_RX_FIFO_DEPTH - 1 : xiic_rx_space(i2c) - 1); + if (i2c->dynamic) { + u8 bytes; + + /* Receive remaining bytes if less than fifo depth */ + bytes = min_t(u8, xiic_rx_space(i2c), IIC_RX_FIFO_DEPTH); + bytes--; + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); + } } static int xiic_tx_fifo_space(struct xiic_i2c *i2c) @@ -360,7 +405,15 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c) if (!xiic_tx_space(i2c) && i2c->nmsgs == 1) { /* last message in transfer -> STOP */ - data |= XIIC_TX_DYN_STOP_MASK; + if (i2c->dynamic) { + data |= XIIC_TX_DYN_STOP_MASK; + } else { + u8 cr; + /* Write to CR to stop */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & + ~XIIC_CR_MSMS_MASK); + } dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__); } xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); @@ -401,7 +454,9 @@ static irqreturn_t xiic_process(int irq, void *dev_id) dev_dbg(i2c->adap.dev.parent, "%s: SR: 0x%x, msg: %p, nmsgs: %d\n", __func__, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), i2c->tx_msg, i2c->nmsgs); - + dev_dbg(i2c->adap.dev.parent, "%s, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); /* Service requesting interrupt */ if ((pend & XIIC_INTR_ARB_LOST_MASK) || @@ -579,31 +634,101 @@ static int xiic_busy(struct xiic_i2c *i2c) static void xiic_start_recv(struct xiic_i2c *i2c) { u16 rx_watermark; + u8 cr = 0, rfd_set = 0; struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; + unsigned long flags; - /* Clear and enable Rx full interrupt. */ - xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); + dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); - /* we want to get all but last byte, because the TX_ERROR IRQ is used - * to inidicate error ACK on the address, and negative ack on the last - * received byte, so to not mix them receive all but last. - * In the case where there is only one byte to receive - * we can check if ERROR and RX full is set at the same time - */ - rx_watermark = msg->len; - if (rx_watermark > IIC_RX_FIFO_DEPTH) - rx_watermark = IIC_RX_FIFO_DEPTH; - xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, (u8)(rx_watermark - 1)); + /* Disable Tx interrupts */ + xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK | XIIC_INTR_TX_EMPTY_MASK); + + if (i2c->dynamic) { + u8 bytes; + u16 val; + + /* Clear and enable Rx full interrupt. */ + xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | + XIIC_INTR_TX_ERROR_MASK); + + /* + * We want to get all but last byte, because the TX_ERROR IRQ + * is used to indicate error ACK on the address, and + * negative ack on the last received byte, so to not mix + * them receive all but last. + * In the case where there is only one byte to receive + * we can check if ERROR and RX full is set at the same time + */ + rx_watermark = msg->len; + bytes = min_t(u8, rx_watermark, IIC_RX_FIFO_DEPTH); + + if (rx_watermark > 0) + bytes--; + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); + + local_irq_save(flags); - if (!(msg->flags & I2C_M_NOSTART)) /* write the address */ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, - i2c_8bit_addr_from_msg(msg) | XIIC_TX_DYN_START_MASK); + i2c_8bit_addr_from_msg(msg) | + XIIC_TX_DYN_START_MASK); + + /* If last message, include dynamic stop bit with length */ + val = (i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0; + val |= msg->len; + + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, val); + + xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); + + local_irq_restore(flags); + } else { + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + + /* Set Receive fifo depth */ + rx_watermark = msg->len; + if (rx_watermark > IIC_RX_FIFO_DEPTH) { + rfd_set = IIC_RX_FIFO_DEPTH - 1; + } else if (rx_watermark == 1) { + rfd_set = rx_watermark - 1; + /* Handle single byte transfer separately */ + cr |= XIIC_CR_NO_ACK_MASK; + } else if (rx_watermark == 0) { + rfd_set = rx_watermark; + cr |= XIIC_CR_NO_ACK_MASK; + } else { + rfd_set = rx_watermark - 2; + } + /* Check if RSTA should be set */ + if (cr & XIIC_CR_MSMS_MASK) { + /* Already a master, RSTA should be set */ + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_REPEATED_START_MASK) & + ~(XIIC_CR_DIR_IS_TX_MASK)); + } - xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); - xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, - msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); + /* Clear and enable Rx full and transmit complete interrupts */ + xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | + XIIC_INTR_TX_ERROR_MASK); + + /* Write the address */ + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, + i2c_8bit_addr_from_msg(msg)); + + /* Write to Control Register,to start transaction in Rx mode */ + if ((cr & XIIC_CR_MSMS_MASK) == 0) { + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_MSMS_MASK) + & ~(XIIC_CR_DIR_IS_TX_MASK)); + } + dev_dbg(i2c->adap.dev.parent, "%s end, ISR: 0x%x, CR: 0x%x\n", + __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), + xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); + } if (i2c->nmsgs == 1) /* very last, enable bus not busy as well */ @@ -611,10 +736,15 @@ static void xiic_start_recv(struct xiic_i2c *i2c) /* the message is tx:ed */ i2c->tx_pos = msg->len; + + /* Enable interrupts */ + xiic_setreg32(i2c, XIIC_DGIER_OFFSET, XIIC_GINTR_ENABLE_MASK); } static void xiic_start_send(struct xiic_i2c *i2c) { + u8 cr = 0; + u16 data; struct i2c_msg *msg = i2c->tx_msg; dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, len: %d", @@ -623,24 +753,56 @@ static void xiic_start_send(struct xiic_i2c *i2c) __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); - if (!(msg->flags & I2C_M_NOSTART)) { + if (i2c->dynamic) { /* write the address */ - u16 data = i2c_8bit_addr_from_msg(msg) | - XIIC_TX_DYN_START_MASK; - if ((i2c->nmsgs == 1) && msg->len == 0) + data = i2c_8bit_addr_from_msg(msg) | + XIIC_TX_DYN_START_MASK; + + if (i2c->nmsgs == 1 && msg->len == 0) /* no data and last message -> add STOP */ data |= XIIC_TX_DYN_STOP_MASK; xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); - } - /* Clear any pending Tx empty, Tx Error and then enable them. */ - xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_ERROR_MASK | - XIIC_INTR_BNB_MASK | - ((i2c->nmsgs > 1 || xiic_tx_space(i2c)) ? - XIIC_INTR_TX_HALF_MASK : 0)); + /* Clear any pending Tx empty, Tx Error and then enable them */ + xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | + XIIC_INTR_TX_ERROR_MASK | + XIIC_INTR_BNB_MASK | + ((i2c->nmsgs > 1 || xiic_tx_space(i2c)) ? + XIIC_INTR_TX_HALF_MASK : 0)); + + xiic_fill_tx_fifo(i2c); + } else { + /* Check if RSTA should be set */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + if (cr & XIIC_CR_MSMS_MASK) { + /* Already a master, RSTA should be set */ + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr | + XIIC_CR_REPEATED_START_MASK | + XIIC_CR_DIR_IS_TX_MASK) & + ~(XIIC_CR_NO_ACK_MASK)); + } + + /* Write address to FIFO */ + data = i2c_8bit_addr_from_msg(msg); + xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); - xiic_fill_tx_fifo(i2c); + /* Fill fifo */ + xiic_fill_tx_fifo(i2c); + + if ((cr & XIIC_CR_MSMS_MASK) == 0) { + /* Start Tx by writing to CR */ + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); + xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr | + XIIC_CR_MSMS_MASK | + XIIC_CR_DIR_IS_TX_MASK); + } + + /* Clear any pending Tx empty, Tx Error and then enable them */ + xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | + XIIC_INTR_TX_ERROR_MASK | + XIIC_INTR_BNB_MASK); + } } static void __xiic_start_xfer(struct xiic_i2c *i2c) @@ -701,6 +863,33 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (err < 0) return err; + /* Decide standard mode or Dynamic mode */ + i2c->dynamic = true; + + /* + * If number of messages is 1 and read length is > 255 bytes, + * enter standard mode + */ + + if (i2c->nmsgs == 1 && (i2c->tx_msg->flags & I2C_M_RD) && + i2c->tx_msg->len > MAX_READ_LENGTH_DYNAMIC) { + i2c->dynamic = false; + } else if (i2c->nmsgs > 1) { + int count; + + /* + * If number of messages is more than 1 and one of them is + * a read message, enter standard mode. Since repeated start + * operation in dynamic mode read is not happenning + */ + for (count = 0; count < i2c->nmsgs; count++) { + if (i2c->tx_msg[count].flags & I2C_M_RD) { + i2c->dynamic = false; + break; + } + } + } + err = xiic_start_xfer(i2c, msgs, num); if (err < 0) { dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); @@ -737,15 +926,10 @@ static const struct i2c_algorithm xiic_algorithm = { .functionality = xiic_func, }; -static const struct i2c_adapter_quirks xiic_quirks = { - .max_read_len = 255, -}; - static const struct i2c_adapter xiic_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_DEPRECATED, .algo = &xiic_algorithm, - .quirks = &xiic_quirks, }; static int xiic_i2c_probe(struct platform_device *pdev) From patchwork Tue Jan 24 05:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D577CC38142 for ; Tue, 24 Jan 2023 05:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aHze/ABTtBeGR3TmeYnKmjOq12BFjBgon6ALhFTEiUk=; b=vNlJcLhMfqIuXM 7Tac01UiMySgqW5/XBRjM5t/F+xLxxAy8Q5NkHBMrxKaCiG+iufgb5qyClCBQLCZTvxTfDtrjQGnA qCcBHyHncCkScxVom162C+4KwVuyEnZF9C7bk/Sm1N+OGJ3hAOkNkZ1YGlDNOMiGX9D3TF7hcmCMo XqE5crCy+VXYkS9sVuBQYBmNnOEq+hnOaW4xtnDpKeC10VzPofJlqiLx8uo9pdy//W4kW/gvaaB2v bUtpFcDJrVoc1L0ZIR+XppuuxG1XDlbI5OKZFTSj9oFwBK2uHKQrFykgBXHz78r0l51KCZmWlWM1j KrQeNYJUayi+je+RWE7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBUv-002Hj4-Cq; Tue, 24 Jan 2023 05:05:29 +0000 Received: from mail-bn8nam04on2088.outbound.protection.outlook.com ([40.107.100.88] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBUr-002HhV-TU for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:05:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ieqj25BbTxmZyLd4E4xAipKm3U4MDPTtDQaoW4MNAOuv+WTTfSSraUxdlwmbizgxUyM7hsefTfMSNRUXOtoOcZyK0UzJQMHK/D1Y0nH/H++zw9+t0JsELHJBphhqriunbF4NePhVGtT6L/axy6TKWDCGSqYR4jvbCcrDBACrRjeMqS78H9xKbs23unYPCkMXd6ix7agB6M+BY4J0GRiXyt0dnjGsIHxFMCNLfFrYVZMd/UG0E6OnSnassKsnm64cgYeYU2A2OlR4huHHCCWQJXKuwY2fIMMvFsmjkLzrjtw7O5doW+X99vqty5nuexRuEIhS+/Jb7pfzQjmcse2SQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mgPu9PptTkSQgoFmVCTn+1fmcrugJCaP+yBakgmxo7I=; b=S9Z+VBGc+Xvl1/rc2Bg1/kSfKt/nhxVQkid9HBj5XlcViUSGyT7sObem40mOZuNlGBD6e/0zNkc+ZK0hXyOWmy2/ltT/THmUdOx+Ee2uYvbvH/pQWU4NPr5zPN9yDr23epxKT+xuO2DVBz6141wMGQPMh6yNtsC1Ff33MrQ5IkPSH/+jG163WnXN+RNMk7B48pmaSVwGu3MohPit6/sjAgZVPFM9Frr8xwpDtU0sAF9B4s2TfAix6l+ub4vxlLKAQCRlfjZl0OsM6+Jy6HyQhTLkcFUK+eeBOwOCIfTTvhPtW7kfAowLw1D56EbzUcvWK8rBG6R29KNY5EKX42rQXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mgPu9PptTkSQgoFmVCTn+1fmcrugJCaP+yBakgmxo7I=; b=EUnBVbahe9rs5FqfRRXUTuyNcxDJT8zJd1pm8vlG58kqjMaTJBUqS2Va/ith64OrQATbQ26ECPhs/rTzAs5/HQ6UR5i2TctOzI49S3kZ7H4KMaSpCpyMLPwMgIjiLG0sPKM5KeaLVgcLkgGGYZaI+Jg4t3upN/24hLzXIi1RBB0= Received: from DS7PR03CA0315.namprd03.prod.outlook.com (2603:10b6:8:2b::10) by SA3PR02MB9345.namprd02.prod.outlook.com (2603:10b6:806:31a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:05:22 +0000 Received: from DM3NAM02FT014.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::88) by DS7PR03CA0315.outlook.office365.com (2603:10b6:8:2b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:05:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT014.mail.protection.outlook.com (10.13.5.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:05:22 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:05:18 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:05:18 -0800 Received: from [172.23.64.3] (port=57526 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBUe-0000Ys-Nh; Mon, 23 Jan 2023 21:05:13 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 674B61055AE; Tue, 24 Jan 2023 10:34:47 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 2/9] i2c: xiic: Fix Rx and Tx paths in standard mode Date: Tue, 24 Jan 2023 10:34:35 +0530 Message-ID: <1674536682-25278-3-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT014:EE_|SA3PR02MB9345:EE_ X-MS-Office365-Filtering-Correlation-Id: ddea5e47-6a87-4bff-ffe1-08dafdc8988a X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sGfGX5j4OV6+0RwITuxKQ4LZfa931RYLUcoMK0bqr/YoeKXcnSr1Tzwb/dN651kNQJtrLNzbjdIFldeDbRj2AZRG1lLGNxdynfTYiHt037t/HM/mpYVLfoFV73hqbGgRdCQihkY0AfvInwmjVv/WVGJnn5FLJV3B50/nbyaxIh3bjqKvQ2ihW+BxrBRch03scnzrh4MWpJLkFKoOfbVmNVgOWln/17mVTzDr+i1D54T6NrjOXLQz0+/8MEFbdTX+V2YGM+Khz6kCU4bwAYv+SFAA/HgSq60qPmO5HTbmj5Vm/O7/WfmoO8BftwwmTS4LnXn6scc+AHKy6a+9wyL+rAFra2CMraYK3d2AyGTlSYEqUDWOoyQMH0jOszBRkyFA5CUNzdgfaEk79soh1HwwnkpHe7mhlkd7WXCLFX86SUuROqERt3WD/JFZwclrY5VK5XbN0NpCudRS4CUdZ3kSy71ZNyQe2CWIeJ7rmivm7SQbQXG7PnS4Q7OBW/DB8vXhMdh1ZBt90DLuqUOGlvjYfs7m6HLw/GEMIys5sWAEN40/1PdvhgA+lCQZpX/ZDUwqGcNV93i6Jd0+VTu4Lkb0Hp1tmyldS9Cf6yN15SA/ptMJ+wxxZsao6FmpBFEaB/6wyzOpXl3Juaopifxi0h13MXXWhOycTRAqAAhyQ7qfpHxGqYNBdpDbf9JQr0L9iumxDLk2r9K4y8XNJfNKp6nzH0E16ejSMHp7bk9T9MYkyLRSc41SyK8fxDl3rKTqOdS9 X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199015)(46966006)(36840700001)(40470700004)(36756003)(7636003)(82740400003)(356005)(5660300002)(83170400001)(82310400005)(8936002)(2906002)(44832011)(4326008)(41300700001)(83380400001)(36860700001)(478600001)(110136005)(186003)(26005)(40480700001)(8676002)(40460700003)(6266002)(70206006)(316002)(70586007)(54906003)(42186006)(2616005)(47076005)(42882007)(6666004)(107886003)(336012)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:05:22.0098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddea5e47-6a87-4bff-ffe1-08dafdc8988a X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT014.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR02MB9345 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210525_988281_70311880 X-CRM114-Status: GOOD ( 18.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam repeated start When a combined message request comes from user space, the controller has to initiate repeated start sequence. In standard mode, this repeated start sequence is corrupted if there is still data in the Tx FIFO. So, always make sure that all the bytes are completely transmitted out of the FIFO by waiting for TXEMPTY, if the previous message is of Tx type. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 839564054501..86da622e060c 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -61,6 +61,7 @@ enum xiic_endian { * @state: See STATE_ * @singlemaster: Indicates bus is single master * @dynamic: Mode of controller + * @prev_msg_tx: Previous message is Tx */ struct xiic_i2c { struct device *dev; @@ -78,6 +79,7 @@ struct xiic_i2c { enum xilinx_i2c_state state; bool singlemaster; bool dynamic; + bool prev_msg_tx; }; #define XIIC_MSB_OFFSET 0 @@ -280,6 +282,24 @@ static int xiic_clear_rx_fifo(struct xiic_i2c *i2c) return 0; } +static int xiic_wait_tx_empty(struct xiic_i2c *i2c) +{ + u8 isr; + unsigned long timeout; + + timeout = jiffies + XIIC_I2C_TIMEOUT; + for (isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET); + !(isr & XIIC_INTR_TX_EMPTY_MASK); + isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET)) { + if (time_after(jiffies, timeout)) { + dev_err(i2c->dev, "Timeout waiting at Tx empty\n"); + return -ETIMEDOUT; + } + } + + return 0; +} + static int xiic_reinit(struct xiic_i2c *i2c) { int ret; @@ -685,6 +705,20 @@ static void xiic_start_recv(struct xiic_i2c *i2c) local_irq_restore(flags); } else { + /* + * If previous message is Tx, make sure that Tx FIFO is empty + * before starting a new transfer as the repeated start in + * standard mode can corrupt the transaction if there are + * still bytes to be transmitted in FIFO + */ + if (i2c->prev_msg_tx) { + int status; + + status = xiic_wait_tx_empty(i2c); + if (status) + return; + } + cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); /* Set Receive fifo depth */ @@ -739,6 +773,8 @@ static void xiic_start_recv(struct xiic_i2c *i2c) /* Enable interrupts */ xiic_setreg32(i2c, XIIC_DGIER_OFFSET, XIIC_GINTR_ENABLE_MASK); + + i2c->prev_msg_tx = false; } static void xiic_start_send(struct xiic_i2c *i2c) @@ -773,6 +809,19 @@ static void xiic_start_send(struct xiic_i2c *i2c) xiic_fill_tx_fifo(i2c); } else { + /* + * If previous message is Tx, make sure that Tx FIFO is empty + * before starting a new transfer as the repeated start in + * standard mode can corrupt the transaction if there are + * still bytes to be transmitted in FIFO + */ + if (i2c->prev_msg_tx) { + int status; + + status = xiic_wait_tx_empty(i2c); + if (status) + return; + } /* Check if RSTA should be set */ cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); if (cr & XIIC_CR_MSMS_MASK) { @@ -803,6 +852,7 @@ static void xiic_start_send(struct xiic_i2c *i2c) XIIC_INTR_TX_ERROR_MASK | XIIC_INTR_BNB_MASK); } + i2c->prev_msg_tx = true; } static void __xiic_start_xfer(struct xiic_i2c *i2c) @@ -866,6 +916,9 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) /* Decide standard mode or Dynamic mode */ i2c->dynamic = true; + /* Initialize prev message type */ + i2c->prev_msg_tx = false; + /* * If number of messages is 1 and read length is > 255 bytes, * enter standard mode From patchwork Tue Jan 24 05:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9368C54E94 for ; Tue, 24 Jan 2023 05:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RiG79fYqfJXQV6X59Y2bcHSuRInGN7jK4Aqy+ssiKQ0=; b=rT3EOO4R3FjIxO yfIdMye6kjt3T4wg4IoO5bjOCponxi6Jaylkbgnlqd8q7a5fVFVzbIbyGdQzHwoC2A33LvOYb0Y2P mEs5ShXR2Q8MVbjwtpYGTdz4brRqAa5oJpyE5MBscg6XQEEKZVKCArT7xj9V2aKxzl8eDVu71XbaP I20WwRrIh0NdyxwM4p11p/CGd/9/vP7QiGSI1b6yZ72Lj5lKI7tQ+PxSYr6+vv4tKNn/du36qiyXR RGVYb8njhUUr43qLRW+6mla/0O63mpwW+SgsQnmGAdVWZ1Rfgc8a3LqXSiQ6m1bf3sTb0yMw+FZi9 TosMYeSMuEJRWujH1atg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVA-002HnQ-Dy; Tue, 24 Jan 2023 05:05:45 +0000 Received: from mail-dm6nam11on2047.outbound.protection.outlook.com ([40.107.223.47] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBUz-002HkL-Rk for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:05:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G4EmV8/7gyZ+EDu649eSibef8qM6t2oQRoQwbjA3p4D9V1wzOTTuo9zxS9089Fj0AVBbgTeF1WAFrMuDABH26CWkdwDVKVLYA1yq2vZ/YHSFtXWVXSZTUEkYkYRCBj4eycdmzyIQM3UCIjkJ9rFFcnhslUG4yPWyQk0Di+Bri/1wZqR+Jep5O9WFM4SBQ0n28NlbqoWuX/Qax9GdzOHPF/Za4q2zhn8eI19Ahy/T9Y8c0JFkCp0cFFnXjdXmdZi1s92lhn/zcMex/309u5XMDriOj+COZjm7LhN3g5CTY9RGuHbyaCrX8dJtV7U8AfPvUmaSBUQBGVYhf2f4GP0QYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SsyUwEc5NXppls5c9t0BMvF/KAxjebhTOEd9VuxXDJE=; b=P3AfdtiYPvj/FzCJc3iIb1QAeGoSwdW5OdRtvsU+c5QMHiPyGLqafND5pQjaf9jLE8ByuYrHxYmrZI0iMa7qibYU5A3+R+IM7Kchice1JOxuE0Lgm6CqCN0kq5MYbB+c/hjUCLNJMrYETWueBp1gBKHpWCIh4n0cl6SGYriS7XrWeuJ+AzEMANYQh/aw5Kw9xA/65TsgxH5FtsUsJs7oYd1C3kG+BhnZ3513hrOecqbt++YFAHE/bxFDhn0oAtMQLQ1Pb9kMFzaGhku3kpMcrI8SHof9jk+UqA9w5RlAwznwIvqnllBd3Zv3kqruat6i4akNWAuAMqhqBX59yLivNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SsyUwEc5NXppls5c9t0BMvF/KAxjebhTOEd9VuxXDJE=; b=DHCcgvhlMoPo8k9pEpcrwoxlGEJ3sSj2tUU+JStc2n05FS1e6mbGl5Ovz2LbdDpUo9s6kCmBXD7LV2QTLA16NcHlS4koOWulKAt37qTPMRgwvkdIxYlU38HbC4cwxapnJSi9dIByyEuiSepX5r6tXYYZgfn9Ngs2b9REqamzfyA= Received: from DS7PR03CA0329.namprd03.prod.outlook.com (2603:10b6:8:2b::33) by SN7PR02MB9303.namprd02.prod.outlook.com (2603:10b6:806:328::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:05:30 +0000 Received: from DM3NAM02FT058.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::78) by DS7PR03CA0329.outlook.office365.com (2603:10b6:8:2b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:05:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT058.mail.protection.outlook.com (10.13.5.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:05:30 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:05:26 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:05:26 -0800 Received: from [172.23.64.3] (port=57528 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBUs-0003CS-0y; Mon, 23 Jan 2023 21:05:26 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id CBEF91055AF; Tue, 24 Jan 2023 10:34:48 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 3/9] i2c: xiic: Switch to Xiic standard mode for i2c-read Date: Tue, 24 Jan 2023 10:34:36 +0530 Message-ID: <1674536682-25278-4-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT058:EE_|SN7PR02MB9303:EE_ X-MS-Office365-Filtering-Correlation-Id: 49d17aaf-9d00-4d87-7fe5-08dafdc89d82 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LU79PWL+/bAjatp+bxPWuomMTv4XbhFfHN4dYaNRoaslyR9PVyW2uBVtsjM9hQ1hD/WKMqldBoFmVTMp3dSyD+3ghXomS+R3dyIU5aQkN7LHHDPnuc65SyCOHj2sWZFug3miSaomEJj6qL0IKu4LS4Ib9eTbHmEMlrYX/0Quhu/xQJwA0ENPOeqYkDu+CYJoegJNxe5sKFR4PELtFuuyLgxtZVqlXyWEWQxtngfPxFAQYb0lKn74sOFukkvDu0E+yWIwRm26gKNUSrjB9Sqbhgk2VISMMH5ssUrn0ZvjXOZKnPZzhrenoXlKoDrVZGC/olQkXw3l46ZB7Hlh+iJjh+9K/8Dmxp2/GZkXMD8kpgH8QSuvNoQ2zlm/Sw7P0G0dDdmsx5p9GK9OT2xKCblnimnsbogL7Wxfg7zpb2IBnxqKkmOaCq8oD5Xbt/Magt1YLQ8uyBKPZvznSF8rRL9bqiv9oczT0HjvPd+Vt2ExN8PoFFTcC9EYmWwfyJdpjCDR/sZLRO28mGhtDW6eBqbaN4O5Og3FHT4NGxYPEdxlDPNu/VjvXmqfCVJsQMGkx23omjAsqQZhe46/JMXrvAJ/Z9Yhq56eg3OtXIE6p80OUoCdDYp68hMd4zgCxnX8oVWyo7avUEWhUioYl3PuzlYzIe/nPWskP0mN6+IltNjZtJ446czCQfZ76GLyqY+zmxR0c53K3UegFegUuu/aewP62S4zKH5ikVFn40j+Z+9Ut28jR8Jf3kd5lxsnhOor4rII X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(83380400001)(36860700001)(83170400001)(82740400003)(41300700001)(356005)(7636003)(82310400005)(44832011)(2906002)(5660300002)(8936002)(4326008)(40460700003)(40480700001)(26005)(6266002)(186003)(8676002)(316002)(6666004)(42882007)(107886003)(47076005)(336012)(70586007)(70206006)(54906003)(2616005)(42186006)(110136005)(478600001)(36756003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:05:30.3270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49d17aaf-9d00-4d87-7fe5-08dafdc89d82 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT058.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR02MB9303 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210533_971413_1620DA4A X-CRM114-Status: GOOD ( 23.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam Xilinx I2C IP has two modes of operation, both of which implement I2C transactions. The only difference from sw perspective is the programming sequence for these modes. Dynamic mode -> Simple to program, less number of steps in sequence. Standard mode -> Gives flexibility, more number of steps in sequence. In dynamic mode, during the i2c-read transactions, if there is a delay(> 200us) between the register writes (address & byte count), read transaction fails. On a system with load, this scenario is occurring frequently. To avoid this, switch to standard mode if there is a read request. Added a quirk to identify the IP version effected by this and follow the standard mode. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 96 +++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 86da622e060c..edc64b79e293 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -32,6 +32,7 @@ #include #define DRIVER_NAME "xiic-i2c" +#define DYNAMIC_MODE_READ_BROKEN_BIT BIT(0) enum xilinx_i2c_state { STATE_DONE, @@ -62,6 +63,7 @@ enum xiic_endian { * @singlemaster: Indicates bus is single master * @dynamic: Mode of controller * @prev_msg_tx: Previous message is Tx + * @quirks: To hold platform specific bug info */ struct xiic_i2c { struct device *dev; @@ -80,6 +82,11 @@ struct xiic_i2c { bool singlemaster; bool dynamic; bool prev_msg_tx; + u32 quirks; +}; + +struct xiic_version_data { + u32 quirks; }; #define XIIC_MSB_OFFSET 0 @@ -878,7 +885,8 @@ static void __xiic_start_xfer(struct xiic_i2c *i2c) static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num) { - int ret; + bool broken_read, max_read_len, smbus_blk_read; + int ret, count; mutex_lock(&i2c->lock); @@ -891,6 +899,34 @@ static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num) i2c->nmsgs = num; init_completion(&i2c->completion); + /* Decide standard mode or Dynamic mode */ + i2c->dynamic = true; + + /* Initialize prev message type */ + i2c->prev_msg_tx = false; + + /* + * Scan through nmsgs, use dynamic mode when none of the below three + * conditions occur. We need standard mode even if one condition holds + * true in the entire array of messages in a single transfer. + * If read transaction as dynamic mode is broken for delayed reads + * in xlnx,axi-iic-2.0 / xlnx,xps-iic-2.00.a IP versions. + * If read length is > 255 bytes. + * If smbus_block_read transaction. + */ + for (count = 0; count < i2c->nmsgs; count++) { + broken_read = (i2c->quirks & DYNAMIC_MODE_READ_BROKEN_BIT) && + (i2c->tx_msg[count].flags & I2C_M_RD); + max_read_len = (i2c->tx_msg[count].flags & I2C_M_RD) && + (i2c->tx_msg[count].len > MAX_READ_LENGTH_DYNAMIC); + smbus_blk_read = (i2c->tx_msg[count].flags & I2C_M_RECV_LEN); + + if (broken_read || max_read_len || smbus_blk_read) { + i2c->dynamic = false; + break; + } + } + ret = xiic_reinit(i2c); if (!ret) __xiic_start_xfer(i2c); @@ -913,36 +949,6 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (err < 0) return err; - /* Decide standard mode or Dynamic mode */ - i2c->dynamic = true; - - /* Initialize prev message type */ - i2c->prev_msg_tx = false; - - /* - * If number of messages is 1 and read length is > 255 bytes, - * enter standard mode - */ - - if (i2c->nmsgs == 1 && (i2c->tx_msg->flags & I2C_M_RD) && - i2c->tx_msg->len > MAX_READ_LENGTH_DYNAMIC) { - i2c->dynamic = false; - } else if (i2c->nmsgs > 1) { - int count; - - /* - * If number of messages is more than 1 and one of them is - * a read message, enter standard mode. Since repeated start - * operation in dynamic mode read is not happenning - */ - for (count = 0; count < i2c->nmsgs; count++) { - if (i2c->tx_msg[count].flags & I2C_M_RD) { - i2c->dynamic = false; - break; - } - } - } - err = xiic_start_xfer(i2c, msgs, num); if (err < 0) { dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); @@ -985,10 +991,23 @@ static const struct i2c_adapter xiic_adapter = { .algo = &xiic_algorithm, }; +static const struct xiic_version_data xiic_2_00 = { + .quirks = DYNAMIC_MODE_READ_BROKEN_BIT, +}; + +#if defined(CONFIG_OF) +static const struct of_device_id xiic_of_match[] = { + { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, + {}, +}; +MODULE_DEVICE_TABLE(of, xiic_of_match); +#endif + static int xiic_i2c_probe(struct platform_device *pdev) { struct xiic_i2c *i2c; struct xiic_i2c_platform_data *pdata; + const struct of_device_id *match; struct resource *res; int ret, irq; u8 i; @@ -998,6 +1017,13 @@ static int xiic_i2c_probe(struct platform_device *pdev) if (!i2c) return -ENOMEM; + match = of_match_node(xiic_of_match, pdev->dev.of_node); + if (match && match->data) { + const struct xiic_version_data *data = match->data; + + i2c->quirks = data->quirks; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); i2c->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(i2c->base)) @@ -1112,14 +1138,6 @@ static int xiic_i2c_remove(struct platform_device *pdev) return 0; } -#if defined(CONFIG_OF) -static const struct of_device_id xiic_of_match[] = { - { .compatible = "xlnx,xps-iic-2.00.a", }, - {}, -}; -MODULE_DEVICE_TABLE(of, xiic_of_match); -#endif - static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev) { struct xiic_i2c *i2c = dev_get_drvdata(dev); From patchwork Tue Jan 24 05:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32095C25B4E for ; Tue, 24 Jan 2023 05:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p67S3QWZ4MgIKEk4AioH9dm3q4uGQLYpLEzTZZdwbUY=; b=rQIWMPBioFpkPs QsJUnTibwCqNmtG70dhoVAkZ0bsZUbd81XoD7Xr4gJyD5IjIPdEgZnIrIk/nWaxGh5xjDaFJ6qzlU o6E7EzbKDyWY9H/EJ+eRYjhbDQeyAp7OcgL5/Ohj1+mhY7W6TjpxmbIXdhaq2HreyPi6Nu+ywAh3p jym3ehaN1dn4AXjPokd2QdVeC0XrbJI91Topl4yWf3IHb4Sgb1MOhCbNSeYCfV+Lmf+yDxZBWn841 W2fGcTPh6Bjnc0jZS5YJ4ELDCLtbRP/CHLRZaP0Pr8qnK7ByyC5MtlFiBI+x9kaZXJn5ydmD7/lsn vVpMj8+6kMo3wsOEROXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVu-002I40-Dc; Tue, 24 Jan 2023 05:06:30 +0000 Received: from mail-dm6nam04on2087.outbound.protection.outlook.com ([40.107.102.87] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVP-002Hq9-8e for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XE068E1av3zOx/EXSVTqh44W7VIvhB19xJizrC0R2YpaXJlQG9emDjRqLiD7zqBbhUgjkDooDRrzZcsK1XhcThOYSnPVAL70pjtc9PmYWPqgvuzdHBWPSgcsIghlRvDeL7sO73NA5npdzsyuLZc8zT23F02OM2RNt6ifD3mz3L00KjVK5L08tIup0+yrsOD8TNa20lXlRhlC4P31HwmvxywE4EI6WmWYDnYYk3zgT/DlohRT7xRnU6aoUQ0+Ydb31BW/QGxSCAktWx7TF8acX1748SRJA2dU+m25iA8WyZZ6ZcNNZpchdHtLBVB9KMlEBKTHJ6vgQCHNxgApHiy50g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ExBzXmoeQqQy6SJXii/rVwQPDE7JZKxm7zug/cBRlr0=; b=mVUlgf3rextF+afwbUSxjdZGTiO0KIxcYqrX+Hz1+JFWeRZprZeR156GSrY1IRylg7yDuB3VQu2xDoyiWr9GFof8YFdpqcspW/t/vjJCpFXw/ilZRVr1geyrmkJD8ghwR8ADbO2S4KbRz64zhtJz7Qd27CVn+OpkVveRh9B6/i7oNgdfH1C+yAeGbVvAMAcQV1LfQQ9XGtkZwj5axK30JJ5XwzxH+QIy6R21QwzrmnfYvJavmRjtaLV13PABsOS9wemcuuxADdHzkYMuu3bOeTIZpC4hsEaVTXJe+DsyJ70tVvluIFuT5pb85Z/2oT5DI0myexuVKnJHuAIAg7gxWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ExBzXmoeQqQy6SJXii/rVwQPDE7JZKxm7zug/cBRlr0=; b=HdRhFcQzEP4tN7D+Hc894D+OBhYkb6pJSU3rRQ9b8td0i9XIiv0ILakwR/jtn/lkgKKgsPx5dp2CHBYBPAM4fYsVTaCLc4N4KA4VPA1X914ASurCn9vi/ZKlIbcD86Je8MdGMKXf2M9s9MF2wF8bndonuqMw8RfGPyS6DzGDhHc= Received: from DM6PR03CA0094.namprd03.prod.outlook.com (2603:10b6:5:333::27) by PH7PR02MB9290.namprd02.prod.outlook.com (2603:10b6:510:276::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:05:48 +0000 Received: from DM3NAM02FT063.eop-nam02.prod.protection.outlook.com (2603:10b6:5:333:cafe::42) by DM6PR03CA0094.outlook.office365.com (2603:10b6:5:333::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:05:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT063.mail.protection.outlook.com (10.13.5.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:05:47 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 23 Jan 2023 21:05:39 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:05:39 -0800 Received: from [172.23.64.3] (port=57529 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBV5-0000ob-A0; Mon, 23 Jan 2023 21:05:39 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id D4ADA1055B0; Tue, 24 Jan 2023 10:34:49 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 4/9] i2c: xiic: Add wait for FIFO empty in send_tx Date: Tue, 24 Jan 2023 10:34:37 +0530 Message-ID: <1674536682-25278-5-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT063:EE_|PH7PR02MB9290:EE_ X-MS-Office365-Filtering-Correlation-Id: 414b0937-788a-4b42-1d31-08dafdc8a814 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nTBvsJqkZdViryXs5sFGq+4HUwjAfyjKhtNMv5NBrr9YnfLUoCx37vZhWHyu2ZXYPJlKmQj8D84V95p0GvRMkpZz5QN/qDNDH6OD1jeP/FDUWDbOWvWXZO0VMFnLeLEnQswnrFXGU3/+tXyd2hhNc40JjcE9/40JC9KiO63JDPpCODjGMsbK4nFVA0SDlItmnKlNCeIocCaEwGIGBNr7giT4q1ypl1b9+evX3hcCbax3wJ2zOSso/KBcVEyhOVsMOztvP2Jj2Dff4L8TrqOGmj1oSrKGYzxky7hFuZAjVBbsjbttw8lhCLZbcTtve1HBE+X5IBzT1w0w8//PE8hNFUWXkzCgJCR75sZx9sRaacc54vkXZ9HzWyicb7stBy9rOI0dOqou2DzOHlgJaz7SHkysH8zWobQ7BpOCMMlnOuhnYYnWNW9g/CKuz5j3IIpIXmpiOfo0YUzlsCipCiMqKcaHHObNDD0YH3+wKKR+UbZWgE8FBhlnrFDJy442P9GADQrgN4qoE98ZvitketrsvJASvhbDqFa2VCz+PUhjcZwpWZHvpMHg6m73v/ZQoCufhAr+q9j2soKoSZCiDo1Fahy9qZvBOWkMk197pxjj66Si28B1t1tGQrDIrHnSi8JaOIUoGUXsblQ4yySbTOhwZ5LJL4BgZUTUBqOAhcAZWF1pdad5nVqvv+yz23UKkIMyA8ZzSpdhcP1onaxvxmgH5VJdOHDmSzq7TuYmqLLM0ob6gwEpNU+vkRKGC1p31IGv 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)(396003)(136003)(376002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(26005)(6266002)(186003)(6666004)(107886003)(2616005)(4326008)(8676002)(54906003)(110136005)(47076005)(70586007)(70206006)(42882007)(5660300002)(44832011)(41300700001)(8936002)(2906002)(36860700001)(356005)(40480700001)(82740400003)(83170400001)(7636003)(42186006)(336012)(316002)(40460700003)(36756003)(82310400005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:05:47.9648 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 414b0937-788a-4b42-1d31-08dafdc8a814 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: DM3NAM02FT063.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR02MB9290 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210559_364945_10DD4062 X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam If the tx_half_empty interrupt comes first instead of tx_empty, STOP bit is generated even before all the bytes are transmitted out on the bus. STOP bit should be sent only after all the bytes in the FIFO are transmitted out of the FIFO. So wait until FIFO is empty before sending the STOP bit. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index edc64b79e293..57084696429c 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -436,6 +436,13 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c) data |= XIIC_TX_DYN_STOP_MASK; } else { u8 cr; + int status; + + /* Wait till FIFO is empty so STOP is sent last */ + status = xiic_wait_tx_empty(i2c); + if (status) + return; + /* Write to CR to stop */ cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & From patchwork Tue Jan 24 05:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC77CC25B4E for ; Tue, 24 Jan 2023 05:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TsktyGv3NOVaIF+49HHwZ/Vi6i0KPeti/qXzGBBiLn0=; b=r9XzKU5hUv4TR1 M+1m+qMJZOlKu/T2m+jvckRKQ/NoGTBjcH4iyu0+Lr6g6kkzlwmuamOWpRx2WSwfS0X8HAZ1aU0x9 saX/naIN7m/stFjxbXKXFLfl/nU+aoJOQJ707Tyhb7WXd9+RH0SwcX89s2l36yXNaBn27a6KgxYsV 5sPLZFNlyvIbiYpuDzdBZnnPUn+TVH6ea0fD6wOKnT8Y9qfVRaER+GJDWosmOSoLjvc4DyUUsViZZ 9RD/oa2VHHOFuAJyKpJ+P7TCa3tUFjPcGVkbLPwAbRduqkeoJAYTRU/XwARv+CFeh2d6A4Chx6Hrq FsGQMlIpxZdoi266IlTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBWJ-002IEH-WA; Tue, 24 Jan 2023 05:06:56 +0000 Received: from mail-dm6nam10on2079.outbound.protection.outlook.com ([40.107.93.79] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVT-002HtB-Lm for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MTaJp0aQzPoitLxVzET4MmzRwTLAqoWuvlkDUR+mOhkhvmIB4w9zlwb/cMt+P2M81H2sBUywFEqm9pXXSXf3F4C+e7/H3p7ZniarZxgAVyVZMJhR0vg2ccEgOg9H8JJqDr1bYoIwVUZeZcWsyiVsrLbU0rf9+GbBroKTE4/y6hOXF0RluTiAOepQqZKumC6d8S60ZorHXDGvnY+DUVsTgpVhILUFdrzOy72DEkPVeIv0gczynZRoC5fqV6vCdiYai/g0t2RNo8S8m61mVliIJfuklETyyPBDHCjfSrb2O/wDVjhaNRn87Zc/gX1FhlIr4GyRBYH2mf8wgL7ZRo168g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rCZLKqSFYYHdOKQrTutofbhVjZsqbIE+qYtqLXWGyPo=; b=EKL7OiSq1U3+oIe0E0YUirsaeqFavCLjcGPtwd6UQVgxppmMfN9ZR2g5g9maI/GGp6EUExlEAanY8wPqjiyr0Qb8mByWrp8OSyeE0Zv7BYgaxtUqcCFEN/5euPtM6d6wjeEvgDLXUEzE8l1RDEt+KcSvT+FBBfYWjgJHBGp0DVzbqgqruz8McOHA+/yrBHHgxNEdu6E9YbH6Gfm+dtLF1ZdIFOQH7FJ8URWMyYFgfXVaCWUcHNQOK6oPx1EjDkvh/A2ZtH+kvfff3e2wcOjXZdTRQ16kYP/0FLeS5kfpTJgQBRtlC0R9D9mpPEFO3E/xpBu2AJo6P3usAt7xDciziA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rCZLKqSFYYHdOKQrTutofbhVjZsqbIE+qYtqLXWGyPo=; b=WrB9ocl39giUMqLkCPTrhS23d2NepSOXpRxR8FjrBd0SIhK7s9RK6BDcBjt0TBkMyV30QJlB2EoAXgZyr32h4fTOG2n9kkoKXIPT9KPwQkr/v+aig/jymAcLMewGpUspwibeXZzJZZ91uSpu/rNv9z0YSCwfE8QAf2oYyR3JQTU= Received: from DS7PR03CA0211.namprd03.prod.outlook.com (2603:10b6:5:3ba::6) by BY5PR02MB6929.namprd02.prod.outlook.com (2603:10b6:a03:230::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:05:56 +0000 Received: from DM3NAM02FT053.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::73) by DS7PR03CA0211.outlook.office365.com (2603:10b6:5:3ba::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:05:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT053.mail.protection.outlook.com (10.13.5.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:05:56 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:05:52 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:05:52 -0800 Received: from [172.23.64.3] (port=57531 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBVI-0000r8-DB; Mon, 23 Jan 2023 21:05:52 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 20C0B1055B1; Tue, 24 Jan 2023 10:34:51 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 5/9] i2c: xiic: Add smbus_block_read functionality Date: Tue, 24 Jan 2023 10:34:38 +0530 Message-ID: <1674536682-25278-6-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT053:EE_|BY5PR02MB6929:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cc327b8-1fc5-48b9-3dba-08dafdc8acdf X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hj7x0FL2K1vgrx4LjnS03ELz4mMK7fQJUcjsKyVMcEo6Tc1khdH8Ni9UMxCxYR4dLVjt0q3IBpCVUSzrR0gJefav7X+iIW+zqSLpA40mGKPplOrq6r/nnAjBVflPsMC3Z2EHPzYoRS4T79f8CKtfk/E/E6qI/9I0cH52JtOdy6AHZsYxY2rB7DYeBax5NGtIg4gDfT0gedEcm9VuzkVJeFn8XwU0l+WdNhzBszQ54SFYevLCiEUbDcy9bEi8hq1Jlwo7Nqs5nKPQRSNi2oNHhQXj6cRO7xDZbr1bmMgP4zz/pcI2vR7+eaqBK8TuL29gHdRc7ZtQ+xcqMnd0Zr0/rDwtk7feUDbVLDNDXEmslBwNYR55iPLdxH8msAO3f+XM7ktLIA0Gr6HJZMAcNYGWC+FdMu7mM6IEhsVXcaSAzIbuU7FXJafAd4YwzZHJNHAfmpA+bIhlDsRs2pIXDLWuFP0YqiC+PMCCjCEVxIxFCIBjnZ3nBs1IqLGs34pUI1swKQ7QHd6hRNEYp46mcmelFudEl0AjuzRKJk7XyQQoWFFt7LMs72NCSCE1FVtZ8uYbx+5Qq5KKkP4ancepq5nduOJ+PnEVQV+HjZa65gw/7QOPvhCY5QSFSfliHD6dxQdrJnJdFMwvaK1Owtjfz24mObYk22U8u9K2cjFNJU99N8lFzZJ1vTDsF/VQOAngbW7YsipzY6/nwSZETDDxeqDkl0KpTtB3AvxnIGriXwMFyXdQGeNb92MFP4ggwpWsFadhYSUpiWfKPS0Q5BM7qEk8eKDxNFkqqPwmOkUqaYUzidE= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(4326008)(83380400001)(41300700001)(5660300002)(82740400003)(8936002)(7636003)(83170400001)(356005)(2906002)(44832011)(82310400005)(40480700001)(40460700003)(6266002)(8676002)(26005)(316002)(6666004)(47076005)(336012)(107886003)(42882007)(70206006)(70586007)(54906003)(2616005)(42186006)(43170500006)(186003)(110136005)(478600001)(36756003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:05:56.1007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cc327b8-1fc5-48b9-3dba-08dafdc8acdf X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT053.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR02MB6929 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210603_768908_D5343440 X-CRM114-Status: GOOD ( 23.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam smbus_block_read is added to xiic driver to read from few sensors which support this command. Since the number of bytes to read is not known prior to transfer, xiic standard mode is being used for low level control of IP. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 82 +++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 57084696429c..554f83e34a2a 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -33,6 +33,7 @@ #define DRIVER_NAME "xiic-i2c" #define DYNAMIC_MODE_READ_BROKEN_BIT BIT(0) +#define SMBUS_BLOCK_READ_MIN_LEN 3 enum xilinx_i2c_state { STATE_DONE, @@ -64,6 +65,7 @@ enum xiic_endian { * @dynamic: Mode of controller * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info + * @smbus_block_read: Flag to handle block read */ struct xiic_i2c { struct device *dev; @@ -83,6 +85,7 @@ struct xiic_i2c { bool dynamic; bool prev_msg_tx; u32 quirks; + bool smbus_block_read; }; struct xiic_version_data { @@ -346,6 +349,62 @@ static void xiic_deinit(struct xiic_i2c *i2c) xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & ~XIIC_CR_ENABLE_DEVICE_MASK); } +static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) +{ + u8 rxmsg_len, rfd_set = 0; + + /* + * Clear the I2C_M_RECV_LEN flag to avoid setting + * message length again + */ + i2c->rx_msg->flags &= ~I2C_M_RECV_LEN; + + /* Set smbus_block_read flag to identify in isr */ + i2c->smbus_block_read = true; + + /* Read byte from rx fifo and set message length */ + rxmsg_len = xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); + + i2c->rx_msg->buf[i2c->rx_pos++] = rxmsg_len; + + /* Check if received length is valid */ + if (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) { + /* Set Receive fifo depth */ + if (rxmsg_len > IIC_RX_FIFO_DEPTH) { + /* + * When Rx msg len greater than or equal to Rx fifo capacity + * Receive fifo depth should set to Rx fifo capacity minus 1 + */ + rfd_set = IIC_RX_FIFO_DEPTH - 1; + i2c->rx_msg->len = rxmsg_len + 1; + } else if ((rxmsg_len == 1) || + (rxmsg_len == 0)) { + /* + * Minimum of 3 bytes required to exit cleanly. 1 byte + * already received, Second byte is being received. Have + * to set NACK in read_rx before receiving the last byte + */ + rfd_set = 0; + i2c->rx_msg->len = SMBUS_BLOCK_READ_MIN_LEN; + } else { + /* + * When Rx msg len less than Rx fifo capacity + * Receive fifo depth should set to Rx msg len minus 2 + */ + rfd_set = rxmsg_len - 2; + i2c->rx_msg->len = rxmsg_len + 1; + } + xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); + + return; + } + + /* Invalid message length, trigger STATE_ERROR with tx_msg_len in ISR */ + i2c->tx_msg->len = 3; + i2c->smbus_block_read = false; + dev_err(i2c->adap.dev.parent, "smbus_block_read Invalid msg length\n"); +} + static void xiic_read_rx(struct xiic_i2c *i2c) { u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; @@ -368,6 +427,12 @@ static void xiic_read_rx(struct xiic_i2c *i2c) if (!i2c->dynamic) { bytes_rem = xiic_rx_space(i2c) - bytes_in_fifo; + /* Set msg length if smbus_block_read */ + if (i2c->rx_msg->flags & I2C_M_RECV_LEN) { + xiic_smbus_block_read_setup(i2c); + return; + } + if (bytes_rem > IIC_RX_FIFO_DEPTH) { bytes_to_read = bytes_in_fifo; } else if (bytes_rem > 1) { @@ -601,6 +666,12 @@ static irqreturn_t xiic_process(int irq, void *dev_id) /* The bus is not busy, disable BusNotBusy interrupt */ xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK); + if (i2c->tx_msg && i2c->smbus_block_read) { + i2c->smbus_block_read = false; + /* Set requested message len=1 to indicate STATE_DONE */ + i2c->tx_msg->len = 1; + } + if (!i2c->tx_msg) goto out; @@ -741,11 +812,14 @@ static void xiic_start_recv(struct xiic_i2c *i2c) rfd_set = IIC_RX_FIFO_DEPTH - 1; } else if (rx_watermark == 1) { rfd_set = rx_watermark - 1; - /* Handle single byte transfer separately */ - cr |= XIIC_CR_NO_ACK_MASK; + + /* Set No_ACK, except for smbus_block_read */ + if (!(i2c->rx_msg->flags & I2C_M_RECV_LEN)) { + /* Handle single byte transfer separately */ + cr |= XIIC_CR_NO_ACK_MASK; + } } else if (rx_watermark == 0) { rfd_set = rx_watermark; - cr |= XIIC_CR_NO_ACK_MASK; } else { rfd_set = rx_watermark - 2; } @@ -984,7 +1058,7 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) static u32 xiic_func(struct i2c_adapter *adap) { - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; } static const struct i2c_algorithm xiic_algorithm = { From patchwork Tue Jan 24 05:04:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BCD1C38142 for ; Tue, 24 Jan 2023 05:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BIgHTsex4Z/LlcqBPhKrCIaItMRMWPBch/lfDYadzkM=; b=PWJ3/lAkq/4TBT 0aT+zlr7MX+ssS5mAb4wLN/GrlQfYz3uGoDwGdvOU0bCY2nIr89q4INsIRnPxYRfKhGCpJsSmbsZ3 i/7IYQS/d/9KoSvwzg1te1CjX68Ue/fXurGJ1RvkGVvwg7fF509ccWn1KtrrVHHD390MgPW/r3M6l 5T2YAIZgYARHHttZKqPP+/P0QjsCKc0SV+Oi/E48iYnbUNNT/VBtadOsruqiQE8UhdVvhDSbxv/dm 6jkE8lziX3hxSjOXIs0Fd1YcdpvvPkE0TkxMr1Au+triFxn80CDzFHOYevZpAT0qCsD5/0OeXLOAN zdRD8DRozNGS2vGslGIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBWh-002INs-Jz; Tue, 24 Jan 2023 05:07:20 +0000 Received: from mail-bn7nam10on2081.outbound.protection.outlook.com ([40.107.92.81] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVh-002Hyz-Jd for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IdDTTt++/KNyeTdCNAH89OxVS/5fjw1UW6C4lKdOckV3thyunb74rxPAout/rDx/BqQOLQ4VgKiO4Af8+wdVGMEOnEMHVJUoDSaB3rmFAwsL4ZRFnX4hz1NZw7gX81P3q3OGZALtRPaPSgqnRLuutsp0RvHA1sT6UdUCTn/xM4TBir4Z9ELYj+OcxnQH7cy7NQuN4Sp4gs14RTSXAKqjJ1uV29tbf0GRgJo4OlgyyynCZWY0NUMfkhWWgufq1dxMSsx2b8GSgz8oBPUdTAqq2kka4GYekWFHvzSwKS/PgHS3n2BM6ikpxhuvQCG1Yw72arzcd5ucO/iBx8Y3DdQVDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BZZnzs0iQxqKdtxkP8yCrlEW1QCuOzMXhrAK1oATYzQ=; b=kpGIthnQF+NuLLllMt15B9oDeluwjN2MBSQHGC5N1f3Anxhe0WCInk/40SBKV+MSws/bz/jKBMKkLmjOG0757VoW6cTmXtbJsEd9y0YHtEWZ+pV+BOzOblISQVzjOZxO0SxWoYjKr7FKTovFo95E3N3pBNnNg1o0vUqUD3RgTCOYodNFnxHKljElCCVGL0GSZCoYG8rUhXVkUbUyLQ8H89Wrqcj+NuYCXP70n1LjCxdrlmR4UkkrygWPM6b2UhyWBDvh4rapQEN74nrZEAjxVTsQXUz3a707ChHn4uzW9ggNTZPTllmpem4VvcRgQsn0bWyFddMcnGFRe8GJgGTMNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BZZnzs0iQxqKdtxkP8yCrlEW1QCuOzMXhrAK1oATYzQ=; b=UBzBYMgb0Xz3q9q5fz1uKZtmCnrHR57Zqry3SD4S6/ivf1sy36L6GnvhmngbiW+txRSLyN9wWBjYETxoUpOcTxmcPo5jifd3Xh/L5KHFSIdeO9+nv2Pd3W8oJOX39JVQgFYQspl4Wp1B5kJyQEmQ43nPbsH70UmbZdkYd7z9mRs= Received: from DS7PR05CA0039.namprd05.prod.outlook.com (2603:10b6:8:2f::16) by PH0PR02MB7445.namprd02.prod.outlook.com (2603:10b6:510:14::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:06:12 +0000 Received: from DM3NAM02FT026.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2f:cafe::8f) by DS7PR05CA0039.outlook.office365.com (2603:10b6:8:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.16 via Frontend Transport; Tue, 24 Jan 2023 05:06:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT026.mail.protection.outlook.com (10.13.5.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:06:12 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:06:08 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:06:08 -0800 Received: from [172.23.64.3] (port=57533 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBVV-0001GX-NT; Mon, 23 Jan 2023 21:06:05 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id B16EA1055B2; Tue, 24 Jan 2023 10:34:52 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 6/9] i2c: xiic: Remove interrupt enable/disable in Rx path Date: Tue, 24 Jan 2023 10:34:39 +0530 Message-ID: <1674536682-25278-7-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT026:EE_|PH0PR02MB7445:EE_ X-MS-Office365-Filtering-Correlation-Id: f216c642-d369-4abf-301b-08dafdc8b6a2 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3JAvDuWcRJ0RHIzmusuvr2mKHtIJvKZ64zTdEPmAsp30cgKtwze/FmhqiwZ00jrj5dfPDKElaabgfvxZcdXcnOlZx1UDXtDlgCyrFnM+Qh79QCpC+0mJWlSJRBPN0wWgBgCYGhc/cIl7Nu4yAKUCLXBAt3QZ/mNFcPlGZxkP/qzgNSBJMOv2zcrHgQomSWX8nb38OQFW1d+BqjFogADxZIhLsLiKtRaOjVWNR4BLjEWA3GFBOXN1t83VEUxVKGN14cHATaDfI8EzA0bS3M//y+g5S41P80sNU2GKdN0mz2giRL/fr9LF3pJX3Cl/DxUAGIUmsNWDC+YhYQfZop/Ct22f0myiL8YsIigfsvsGWW+kUtHxhtmtaDTNHNsZho0jcOpcKPC5gjwexIgiMCkuCfw3wJ53RlCjUKbCvNpwdnWRnNhMPlu0kU4VyBkGGrYGBCtN7aoph0QVoEfW+5D/Jif/Z2PbTkfJY2ixBp+KBj2sfmYxPyAX/FhFWHN75cTTj1eFH04oNNFe7B9Yfm3Dkcsa0pZ9XGuweSvJiLiStI5MxDSkX2tYiiTzeTSA328CezZmQu992ZNKOeb81Tn2qM+4HuEQ1Au2HO/WP9lpuGp0ibyvraxW1jySuD4ykRGXWpiVnEKkO96w6KFXNIA4FFPt9be+WgZ3awXOddTDEgocADiu1VORr4T67Gt9/ef4ob6oMbvzMY0DbcqCLhyyhxEVC7022abCytrCAb4KLLHLmJ//pTc/vjT3aE20gaW7 X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(83380400001)(36860700001)(83170400001)(82740400003)(41300700001)(356005)(7636003)(82310400005)(44832011)(2906002)(5660300002)(8936002)(4326008)(40460700003)(40480700001)(26005)(6266002)(186003)(8676002)(316002)(6666004)(42882007)(107886003)(47076005)(336012)(70586007)(70206006)(54906003)(2616005)(42186006)(110136005)(478600001)(36756003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:06:12.4621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f216c642-d369-4abf-301b-08dafdc8b6a2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT026.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB7445 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210617_695469_3701E664 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam 'DYNAMIC_MODE_READ_BROKEN_BIT' quirk added in the driver, effected IP versions no longer enter dynamic mode. So, remove local_irq_save/local_irq_restore APIs from driver. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 554f83e34a2a..8503b5016aaf 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -741,7 +741,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) u16 rx_watermark; u8 cr = 0, rfd_set = 0; struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; - unsigned long flags; dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), @@ -773,8 +772,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) bytes--; xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes); - local_irq_save(flags); - /* write the address */ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, i2c_8bit_addr_from_msg(msg) | @@ -787,8 +784,6 @@ static void xiic_start_recv(struct xiic_i2c *i2c) xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, val); xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); - - local_irq_restore(flags); } else { /* * If previous message is Tx, make sure that Tx FIFO is empty From patchwork Tue Jan 24 05:04:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29F07C25B4E for ; Tue, 24 Jan 2023 05:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v1BXBQjghmvx6djCIV/bG8TQ8flEdua4fPbdbN5INAE=; b=BSQyB1FjZ+KANA OyuJs6U7kQmkR+x8SvRFNeAWRnqzEV59DAfZlArjfMLMlGHxY5g2S9sGQ1w6hU6zlhVPn09jA5CnC ozV8Ua/KT5jLWgBO5A+IEjpIb2yvbP6SINMHBmOovTHZVt/bBArxcm4y1G7zI9igQnwR64TUFQv7t CW4IsZPvUPlSeSoQYhQ8f442KyNRqDdnS/hTgqPA9cTXZIYhNtKTN0y/6/9Hv7DqIGPKcPjVPNJE8 db1inSePKXdmcNRjha1XzuOpdKX7M3Eur14/LihJnEiBsDN9Zo4A8QYmbu2ky2z3RCfLrg19ZGPyZ Q+9xQDDmgSULWnL7Pb9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBX9-002IZ8-5F; Tue, 24 Jan 2023 05:07:47 +0000 Received: from mail-dm6nam04on2047.outbound.protection.outlook.com ([40.107.102.47] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBVt-002I3V-Sc for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D9yTXvpYBIET1ggvjDe9xBf5I7GZohRiavONjUsYoQKk+ma8yz43ncKcKutZbWRlrLfu+d03btygVHRhWaXmCi7MSEkhMhASr8L1Ki30XVSUrGy8IxXTF+UbITHL0XhicrpAdqJTjDCHTpbnZ/pN0UALTdODtZ/fr//tl/7WJAVMhJr4k5YISZwijaPb7O36ML69uoQBEhXqPY2aA9yK4wKZ7Vt89IxwaV2EKuGeYF2WFfFLIqruYBLKJx/MOw+hN0XeKGIJS29zbAlIBqwGftc1+WTbnvb7VEr+3++DER7OmSXh0MtV8FhR6Tr+IZ28SJD82llbc4GfgopL3l8GcA== 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=vYwt7cMrZtbnDYBwuC4rSPWfWTckzOwSS3KipnVDL90=; b=ht+tSbr6DcZmwzdPH8qW+8pKDMD2PENzq2GmlJxe4Q9UUxy9s0hLwBvFQVFnq96BHWsqZ76FSLTn/bTbwBNcvbr2fpGCE4FYx1C2nXqheGym7ZnGWBUFFaNo+L+8rzpkzBIhoL0Id5DOQ3tu8iFVCgR9yf7BUbnH1p+97Wx+1+ATm626HzkZWw1Rdt3ntQXlTWSGNvZjFuOP/2g4wHggPZpJx/7nSu2Jkh8Z5WFYlqKa6IQnVfu3BOim7jEvk5MNx4mAkmPiBOP+jlqIdd3mM+3qzpIJFMfStbuaokKvmr0Nqd9OPJRDwc/0QvNEedFcmkuTz742TfWoA8DqktKalw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vYwt7cMrZtbnDYBwuC4rSPWfWTckzOwSS3KipnVDL90=; b=qwbh5yUTBKB8ytkEPdzOKJvE4qowbmJJ8Zj3vorh7bC5bZj5o561S7iXqByRnEAupVl8oQ64oDg3RFtqQfdA3xdLUNAPN7odTvGSmFtb+/NTdDqTDpAtKHa4BQk6n86VsNxy3HxelK+97HbZtXRo0VOApO5AToLbt/1VFk78OxI= Received: from DM6PR02CA0113.namprd02.prod.outlook.com (2603:10b6:5:1b4::15) by DM6PR02MB6972.namprd02.prod.outlook.com (2603:10b6:5:250::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:06:25 +0000 Received: from DM3NAM02FT036.eop-nam02.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::67) by DM6PR02CA0113.outlook.office365.com (2603:10b6:5:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:06:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT036.mail.protection.outlook.com (10.13.5.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:06:25 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:06:19 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:06:19 -0800 Received: from [172.23.64.3] (port=57535 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBVi-00041w-QL; Mon, 23 Jan 2023 21:06:19 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 1F4981055B3; Tue, 24 Jan 2023 10:34:54 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 7/9] dt-bindings: i2c: xiic: Add 'xlnx,axi-iic-2.1' to Date: Tue, 24 Jan 2023 10:34:40 +0530 Message-ID: <1674536682-25278-8-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT036:EE_|DM6PR02MB6972:EE_ X-MS-Office365-Filtering-Correlation-Id: 54b3fd3c-df83-4059-402d-08dafdc8be50 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IM+EZdywaiXvL3umzMSa+GF4sRozoKnLKfhJFipWSYpTGOipJ6SZUPXMI4HCsgwDQyIPvMMxe6xqUJtQtnkPpk+7LqZa8cMHriRUx20ue64WX0iFdQtN6iE1EP+f/yDdbVMtuNkZ55u3ZI4HN+dlVx7lb217ZGM/iuR7CERrSAKPIFbKafwRhvsaVjyrQ35g/1/TJL4nzPxtr2pSMjvlajlRziSPWib4W9Uguib0zA2YMe3ERWzMA9JkHB8a03xZwLK5TBlL4KwYDwkxQfy5eOVRD71inTClKqaR2AaURUs0gqYMKtlkXxjZYXiZ0Z52XCxFHxBgvqitDfyMueyOmHN0Cdl00ENCov1fNLX1l1QLC6FsXBokAOJ5I/IBJ7KTc6R1GdiayAKrggKaNJyw/1vQHiyu64z+LF22VUiSwDCmAqdeSJNiEYleIQkbkLdak5bRuj0VF+7P084oipLaR81KDATqNklBDZ5QNS4lW4Hkn+Y45gYYUZ2M/0enWcwq4c3Z9vDB+9B0030AEFqHaH6YIVHjOAM+7xScBo4aP+3v+1cdpXOYqszUhUiwITXeeCLanC6vJGGpv6Cb4XLYRF6wMYOv8c4MU8hj4CDUlY9vLyTpORr489TVSeQnW5kWsPftKEUF/vJzOVxf8nBvTSJ74jlyHEmugvVglE0oUnd8lN+5OzpX7xtbFnHsqLSJihIbZScXkWLriqAscavhPo5V8MPH5k20Mnqd/hdfLV/VNx/S8aAjVg6WMkJe1D/P X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(83380400001)(36860700001)(83170400001)(82740400003)(41300700001)(356005)(7636003)(82310400005)(44832011)(2906002)(5660300002)(8936002)(4326008)(40460700003)(40480700001)(26005)(6266002)(186003)(8676002)(316002)(6666004)(42882007)(107886003)(47076005)(336012)(70586007)(70206006)(54906003)(2616005)(42186006)(110136005)(478600001)(36756003)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:06:25.3625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54b3fd3c-df83-4059-402d-08dafdc8be50 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT036.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6972 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210629_970069_52386A2F X-CRM114-Status: UNSURE ( 8.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam compatible Added the xilinx I2C new version 'xlnx,axi-iic-2.1' string to compatible Added clock-frequency as optional property. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- .../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 8d241a703d85..42488a67260c 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 Tue Jan 24 05:04:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93F7DC25B4E for ; Tue, 24 Jan 2023 05:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h9vaLMAwakW4ZwSfWx1ou40wqQzTtYE7XzqhbZIEFQY=; b=JpN3524fhWKWmw 4sDhX1097VUV0QBXSqednITMTCH491qGKjby0yyvuzJNZToEd4Y5gBKA9wvIjPMwRbziszfkly2zu V06ZwhGIVJFGlfMFlNPt3keAVmSB7vluBc3JKNGABw45VTRmHrxWry2AI9XO3cb8rQ7kMy1h/qb9B oydIS25o3vQHd4EMdhR+5UGLq+nOMQeG0P0kKK+7mjtfGRBi05r308aSv5CHAx+IwwlhFZPkdLKRL Ogyt5yRZB8BX0qAp5jy3QoAKCb689mQkdyGF3T+U4Eh+ydBTtpx/XyUyRbPqvBX3E1Du+8qRyiChI uRBrg0a0+YhjhVnibClA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBXb-002Ikl-IX; Tue, 24 Jan 2023 05:08:15 +0000 Received: from mail-bn7nam10on2075.outbound.protection.outlook.com ([40.107.92.75] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBW2-002I7C-Mq for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4QCFhHJU+oYxjtLIFRQ9pqW8RGyfWRDXJbAKcRPLrqq8ZQCH1S1WUEq7Jzu0bsF8O2tq2TUekW3zsPJv41ruqnfBENLPicNpoNDTMJeaLS8ewBub6p9NnG+pvcnVF+A38HPU+2RnHCf33DcLkqkPYnyIMFg5H1nqDgiZgL2u0C24gfvp+pSBCMq8UQ0VrbXrOWz6eRUcxAnAETHjNulxenAA3dT2Uxm8gT5HnnYFxhro0BL8xzpyoCdJiulefoKBFiAZCA5R66BpS/Ky95ucvexIGL/eC/DEKM8ux9EMVirZsHMNTE1/Bf7ZH8tcNFAd9lMMMJG1uxwm59Ak/SDvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ZLZrM4GSYMzhyzC2nQYtiApVF+lzGSXoOy5Fbym7iA=; b=kgkLbu7dNdeP2iDqoMkQBuCcLlDNvzYYl05JAyYzYfbXMAURJKRsdnt1yJompavhngvSpYNQPbaY6uZkmz4GsHAfIPLG90MDb54i1J4YYzSVjMLLvbb+U3AeW+ft+Xx4o64JlJTgUAaahGXaCaR1hLQ0mauxYhFg/5igYcWi5VWwrMn5nvKQdQGSgiXKME1HwarxQL1c8Zm51/b5M1PS/wSmbDmPrA/869AFeylp0lINfCXu5gDPw58HJsK4tQniGPElY4cAR6rD9RzfYc22q1YIrUwuk+IZUbrSFLCYnBT87MHsysSfIIIU3V+7hUoyn7B5Ijlyo/zqSsYX8M2NzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ZLZrM4GSYMzhyzC2nQYtiApVF+lzGSXoOy5Fbym7iA=; b=Rd4Wd3dBjH2z5ie1wn6UxeTnHcKL3aBmPZLV+2D0zqlokmCr3YMuVgQTU76lHtctAUYJ49nRntoFF8dy+6VwXfY/adjbmRPuE435jcJqgdPJZUAcJTqbr+2BNnZEFawf+PePLu1MC37hLjXcI9lupMkCjgAioJqHHBtAsSCMsDY= Received: from DS7PR03CA0359.namprd03.prod.outlook.com (2603:10b6:8:55::35) by DS0PR02MB9080.namprd02.prod.outlook.com (2603:10b6:8:13a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:06:34 +0000 Received: from DM3NAM02FT015.eop-nam02.prod.protection.outlook.com (2603:10b6:8:55:cafe::50) by DS7PR03CA0359.outlook.office365.com (2603:10b6:8:55::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:06:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT015.mail.protection.outlook.com (10.13.5.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:06:34 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:06:32 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:06:32 -0800 Received: from [172.23.64.3] (port=57541 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBVv-0001S2-TP; Mon, 23 Jan 2023 21:06:32 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id E5F861055B4; Tue, 24 Jan 2023 10:34:55 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 8/9] i2c: xiic: Update compatible with new IP version Date: Tue, 24 Jan 2023 10:34:41 +0530 Message-ID: <1674536682-25278-9-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT015:EE_|DS0PR02MB9080:EE_ X-MS-Office365-Filtering-Correlation-Id: 49cad61f-6b2d-4e7f-81d1-08dafdc8c3a5 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AxdsaSC140B4h1ZBVtLV52ENc5oKfE+9Vc6CR1sgIy0zW7epaYxrAOC9GL6hPWnsZBdUX/S5e9QH6ySmT4hS+sN/JEzAM5UKvr63BXOgAHfuIyZl0aXJUmdAvRJXrMMkwMJTkorH36K47oKuKiQA3WKundy8Pv5Ku1yeezz3UdjzuDwVboSNAuF07lfw6AqdNxMnM/qOye+pJdaVPhbOU8l8cYBZV/+veBQD0oJ2fw9HQAAmWdu8EKdrDT6OmiJ20vtIZ6roBCuQERZf22P2Zq4Gtew9C4MA5HRpVKbPnAlmQQZmy8gjrr6Y0R77Gkzlxj59IWAInrsc/h4cJz9om4EEjQeq2ay/c1YUnPnlQqBrmmpz3t9kS8JvcmEvam4Eox4ba8LOJ1mDwUyW6ugsy8NxxgS9i8ya2yEQViSIqqVsgtIyRr1wXonE6js7IvHFi21SpbZsPwd5V3ZDA5dbTvxN/cp9YvxxGVqM9X4LU8YwnyDfe/g+IlT+S+yIo27CV1ERS+SlgUjSfe+P4mCQUoW5miu0D2AAMHwygEEVLOcBP5iPpHJxjQXfuePOoLVrW8wGQCEl+SzkgVDpxPpQrVzk46b7kogYvniwpQFSDlwIRKgo3vG06f0BmPzKTk5JfSyOePK5WRflGiAXSUVlHfnI6G4FWTuLpaa/yUymaHXB5eRSi1hMZfR6kieS1vKCW0NEn9H71N8UmNcqRrd0FGu36K/PDJMOmdnIPgxDjgR7nXr6RFzz4ho/xaakQP5Y X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(46966006)(36840700001)(40470700004)(40460700003)(40480700001)(36756003)(54906003)(110136005)(478600001)(42186006)(316002)(107886003)(6666004)(44832011)(5660300002)(15650500001)(2906002)(4326008)(8676002)(8936002)(70586007)(70206006)(41300700001)(83170400001)(36860700001)(7636003)(356005)(82740400003)(82310400005)(2616005)(26005)(186003)(6266002)(83380400001)(42882007)(336012)(47076005)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:06:34.3099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49cad61f-6b2d-4e7f-81d1-08dafdc8c3a5 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT015.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR02MB9080 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210638_802784_5E5185C7 X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam Xilinx AXI I2C IP is updated with a bug fix for dynamic mode reads. Older IPs are handled with a workaround in which they are using xiic standard mode for all these effected use cases. Added the new IP version to compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 8503b5016aaf..682b3567e83e 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -1074,6 +1074,7 @@ static const struct xiic_version_data xiic_2_00 = { #if defined(CONFIG_OF) static const struct of_device_id xiic_of_match[] = { { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, + { .compatible = "xlnx,axi-iic-2.1", }, {}, }; MODULE_DEVICE_TABLE(of, xiic_of_match); From patchwork Tue Jan 24 05:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 13113458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54544C38142 for ; Tue, 24 Jan 2023 05:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HlVHKNeUxPToGDPn141NRK0QLcorsCkG+bqp0hsmCLQ=; b=XY7AAu+mK1lMIE BjmCcMFIl8hpnmGIXjmfJlVA+9qK6LKl5sOxPYv0Oa+22hdVbLkg3Y3/YdlzcSKn1X/M18JZchneO 0bQidIK3npBb6JSIHZuB9IRMtrkLLNVp5E1ZQRiAl0HZzKrgQ4qMcFmjD8zNqmv3ahOpSpDFzCoBv sIle8SC3+zpyW1DMLOSsDuYYlnXv+DtmSyci1zKd+ehVCSntLBxMJ5Snu3vnfO1KSp7TrNlnL1chZ oSMVETZCz1XCBBpstNoaTAsd2suEB6hgnFkno3YTLNyFb/Fyo5x03A34zyJExeOZikrX2XkXHXd/1 izGXu7zmNHED1DrRIF1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBYA-002Ixu-Aq; Tue, 24 Jan 2023 05:08:50 +0000 Received: from mail-co1nam11on2042.outbound.protection.outlook.com ([40.107.220.42] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKBWI-002IDI-UR for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 05:06:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oP77QmJXZRl80WfwnteEVi/BygRros+YPx7ld9l/ZnUNZA5JX9L4RR8AKzcRKHWj80QI4esYUXynkspb4/uJ6LKqOLLLxcMiiuBMACdew7TN4z0xExl4ZXy4erz7kdVBYyqxLvVSFMq0/JZjTOPxeW/KDbH4SNpjYngBFdYsxPoLnjJBpNjI9zfJxM5ZUEctAEvB1mT0C/F19oIobngvUMOcI8prqPjowky7mpc6CGdn8E42Xxbewjex3fjH/SIXdNv2Cjca0k4v3YBXYl8DDcOX5W3rXgMxjYxqf2xTJX+juT3TraFBdaMGoOepC4wCckISwKehF5rIp1usnYsOew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zBsX1+pRlI42Vjnyt7QG1jZNA26/1AjE4ooPk5i3+qE=; b=F1ppQux9ePhRqoyTWs9XEt8sjUYW8lDJCaoKAuKILPuK9Q/buxhW2mTH5dZTUwcKg0VMA/MwJy/ngI77mP+gpamKKXRnqOG03s131P4LminuCsMR5wUfxQ99aBx0bchBqGwSe01fDT28i5BPpeLfp/WE7EyBHTuvb4bVAgd0ZqDux992oqDMFIqpiK1qfkJ6tgCQ2JDp3c/UpWKq+nTt0RxXfT0WbLG8xqBEjJzD/vbuCcXgkzDwryQMWIf1gyQTwWkGfIUnEgu6Xiz8el31BeudWqteQTzRVa2VMnfSsJhDZED7ZdKTGEGOfUylaUmfPspvWAZT9Z+cJmUyPbqxyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zBsX1+pRlI42Vjnyt7QG1jZNA26/1AjE4ooPk5i3+qE=; b=FG7/IH/quTI6aayP6Dihgk8uO/H0Rhmy3fz97XV9g9aNJxkz6U8xKaXkhkgLx3XtFJPeX5dHu2vAkag0peR41P8xzATR4HZNXYX58PKmBLXkzSZKB3P3kXxQr+0Jr7u/LHN5ka8aVFj6h8AkXY49t1uB1lIzbZ54QuFImTajP9E= Received: from DS7PR03CA0225.namprd03.prod.outlook.com (2603:10b6:5:3ba::20) by PH0PR02MB7639.namprd02.prod.outlook.com (2603:10b6:510:5c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 05:06:48 +0000 Received: from DM3NAM02FT030.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::20) by DS7PR03CA0225.outlook.office365.com (2603:10b6:5:3ba::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Tue, 24 Jan 2023 05:06:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT030.mail.protection.outlook.com (10.13.4.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Tue, 24 Jan 2023 05:06:48 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 23 Jan 2023 21:06:45 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 23 Jan 2023 21:06:45 -0800 Received: from [172.23.64.3] (port=57542 helo=xhdvnc103.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1pKBW8-0001V6-WC; Mon, 23 Jan 2023 21:06:45 -0800 Received: by xhdvnc103.xilinx.com (Postfix, from userid 90444) id 7791A1055B5; Tue, 24 Jan 2023 10:34:57 +0530 (IST) From: Manikanta Guntupalli To: , , , , CC: , , , , , Raviteja Narayanam Subject: [PATCH V3 9/9] i2c: xiic: Add SCL frequency configuration support Date: Tue, 24 Jan 2023 10:34:42 +0530 Message-ID: <1674536682-25278-10-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> References: <1674536682-25278-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT030:EE_|PH0PR02MB7639:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a25e2a2-1d42-4eb6-9185-08dafdc8cbfe X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aZxAOtt6F42gfHwSP3JwLGRpiXOvq1/rjYXFHuuieLlVVp+yhHZsob5MNMBNLH5rBCCaorSCjbLEQ1KyML5E7RcYhds9wKXWgB7dlpwuvL7t94jjzL16PpqPsqMzGtoYgOsWcXVebHe3TeqCnONBVsZuP9K1fno1nTeyQglnNIWcDqwo/Pti/9tiOZcD9VsaAFjE8H0h4lZ69fJ35MgOTqoDbqBZIDDHuUQXvQ5ObKxLYUqaEIMSY5sU8AlSY4/eVlLexiKYJzOt+5kVZsFchG7dCo04/9EoO6qOUtfz1ruO5ZrOi32SEknggPZk1wc92aXqS+nCWJeTLWWrf9UBrY+u39LutucO3IBOTU/+Jq18LU74kdrOpdwr676onLJ+17vf8QXL24WS23RGae+dXTrBIJ1sKEP5wlIMEv7iamTyWh6PCZyz8WgAD9G0Z/Izu/k3rTDFpc87G3SnHW0AvUSzRkyBI2RbqtzdPvHW7VVG1fKteocFv3BEyPnQB/WrieIbve/VRQcvRgymHCyOUDVXJ2Vpx+SW3mNZpEkdFkAwfIJPohSQ9FLFbOGpqwmD7tUxB6QBnMe83Dnbb+yh1g0NPzJJntyPq6D3iyI0mf8LFS5CgxQlaeQoQi/B4Ou3Ghucsr3fPW4fnB7WuEir2s52tFL/NBKwS5wZv474P+rsBStbE1q9Cde/Vva2SHv93jpZHCrlpw0Syvsd6rpD8BAsptO5WxzwJuxYV+HeXHod2wn0Ddc9rRTu9qthhjE3 X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(7636003)(83170400001)(82740400003)(40460700003)(40140700001)(36756003)(40480700001)(356005)(82310400005)(316002)(336012)(42882007)(478600001)(110136005)(54906003)(42186006)(8676002)(70206006)(70586007)(4326008)(47076005)(2616005)(2906002)(44832011)(83380400001)(36860700001)(26005)(6666004)(5660300002)(6266002)(41300700001)(107886003)(186003)(8936002)(102446001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 05:06:48.3153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a25e2a2-1d42-4eb6-9185-08dafdc8cbfe X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT030.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB7639 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_210655_065634_9525410E X-CRM114-Status: GOOD ( 23.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Raviteja Narayanam From 'clock-frequency' device tree property, configure I2C SCL frequency by calculating the timing register values according to input clock. After soft reset in reinit function, the timing registers are set to default values (configured in design tool). So, setting SCL frequency is done inside reinit function after the soft reset. This allows configuration of SCL frequency exclusively through software via device tree property, overriding the design. If the clock-frequency parameter is not specified in DT, driver doesn't configure frequency, making it backward compatible. Signed-off-by: Raviteja Narayanam Signed-off-by: Manikanta Guntupalli Acked-by: Michal Simek --- drivers/i2c/busses/i2c-xiic.c | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 682b3567e83e..1e89e8270749 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -46,6 +46,12 @@ enum xiic_endian { BIG }; +enum i2c_scl_freq { + REG_VALUES_100KHZ = 0, + REG_VALUES_400KHZ = 1, + REG_VALUES_1MHZ = 2 +}; + /** * struct xiic_i2c - Internal representation of the XIIC I2C bus * @dev: Pointer to device structure @@ -66,6 +72,8 @@ enum xiic_endian { * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info * @smbus_block_read: Flag to handle block read + * @input_clk: Input clock to I2C controller + * @i2c_clk: I2C SCL frequency */ struct xiic_i2c { struct device *dev; @@ -86,12 +94,37 @@ struct xiic_i2c { bool prev_msg_tx; u32 quirks; bool smbus_block_read; + unsigned long input_clk; + unsigned int i2c_clk; }; struct xiic_version_data { u32 quirks; }; +/** + * struct timing_regs - AXI I2C timing registers that depend on I2C spec + * @tsusta: setup time for a repeated START condition + * @tsusto: setup time for a STOP condition + * @thdsta: hold time for a repeated START condition + * @tsudat: setup time for data + * @tbuf: bus free time between STOP and START + */ +struct timing_regs { + unsigned int tsusta; + unsigned int tsusto; + unsigned int thdsta; + unsigned int tsudat; + unsigned int tbuf; +}; + +/* Reg values in ns derived from I2C spec and AXI I2C PG for different frequencies */ +static const struct timing_regs timing_reg_values[] = { + { 5700, 5000, 4300, 550, 5000 }, /* Reg values for 100KHz */ + { 900, 900, 900, 400, 1600 }, /* Reg values for 400KHz */ + { 380, 380, 380, 170, 620 }, /* Reg values for 1MHz */ +}; + #define XIIC_MSB_OFFSET 0 #define XIIC_REG_OFFSET (0x100 + XIIC_MSB_OFFSET) @@ -110,6 +143,19 @@ struct xiic_version_data { #define XIIC_RFD_REG_OFFSET (0x20 + XIIC_REG_OFFSET) /* Rx FIFO Depth reg */ #define XIIC_GPO_REG_OFFSET (0x24 + XIIC_REG_OFFSET) /* Output Register */ +/* + * Timing register offsets from RegisterBase. These are used only for + * setting i2c clock frequency for the line. + */ +#define XIIC_TSUSTA_REG_OFFSET (0x28 + XIIC_REG_OFFSET) /* TSUSTA Register */ +#define XIIC_TSUSTO_REG_OFFSET (0x2C + XIIC_REG_OFFSET) /* TSUSTO Register */ +#define XIIC_THDSTA_REG_OFFSET (0x30 + XIIC_REG_OFFSET) /* THDSTA Register */ +#define XIIC_TSUDAT_REG_OFFSET (0x34 + XIIC_REG_OFFSET) /* TSUDAT Register */ +#define XIIC_TBUF_REG_OFFSET (0x38 + XIIC_REG_OFFSET) /* TBUF Register */ +#define XIIC_THIGH_REG_OFFSET (0x3C + XIIC_REG_OFFSET) /* THIGH Register */ +#define XIIC_TLOW_REG_OFFSET (0x40 + XIIC_REG_OFFSET) /* TLOW Register */ +#define XIIC_THDDAT_REG_OFFSET (0x44 + XIIC_REG_OFFSET) /* THDDAT Register */ + /* Control Register masks */ #define XIIC_CR_ENABLE_DEVICE_MASK 0x01 /* Device enable = 1 */ #define XIIC_CR_TX_FIFO_RESET_MASK 0x02 /* Transmit FIFO reset=1 */ @@ -310,12 +356,102 @@ static int xiic_wait_tx_empty(struct xiic_i2c *i2c) return 0; } +/** + * xiic_setclk - Sets the configured clock rate + * @i2c: Pointer to the xiic device structure + * + * The timing register values are calculated according to the input clock + * frequency and configured scl frequency. For details, please refer the + * AXI I2C PG and NXP I2C Spec. + * Supported frequencies are 100KHz, 400KHz and 1MHz. + * + * Return: 0 on success (Supported frequency selected or not configurable in SW) + * -EINVAL on failure (scl frequency not supported or THIGH is 0) + */ +static int xiic_setclk(struct xiic_i2c *i2c) +{ + unsigned int clk_in_mhz; + unsigned int index = 0; + u32 reg_val; + + dev_dbg(i2c->adap.dev.parent, + "%s entry, i2c->input_clk: %ld, i2c->i2c_clk: %d\n", + __func__, i2c->input_clk, i2c->i2c_clk); + + /* If not specified in DT, do not configure in SW. Rely only on Vivado design */ + if (!i2c->i2c_clk || !i2c->input_clk) + return 0; + + clk_in_mhz = DIV_ROUND_UP(i2c->input_clk, 1000000); + + switch (i2c->i2c_clk) { + case I2C_MAX_FAST_MODE_PLUS_FREQ: + index = REG_VALUES_1MHZ; + break; + case I2C_MAX_FAST_MODE_FREQ: + index = REG_VALUES_400KHZ; + break; + case I2C_MAX_STANDARD_MODE_FREQ: + index = REG_VALUES_100KHZ; + break; + default: + dev_warn(i2c->adap.dev.parent, "Unsupported scl frequency\n"); + return -EINVAL; + } + + /* + * Value to be stored in a register is the number of clock cycles required + * for the time duration. So the time is divided by the input clock time + * period to get the number of clock cycles required. Refer Xilinx AXI I2C + * PG document and I2C specification for further details. + */ + + /* THIGH - Depends on SCL clock frequency(i2c_clk) as below */ + reg_val = (DIV_ROUND_UP(i2c->input_clk, 2 * i2c->i2c_clk)) - 7; + if (reg_val == 0) + return -EINVAL; + + xiic_setreg32(i2c, XIIC_THIGH_REG_OFFSET, reg_val - 1); + + /* TLOW - Value same as THIGH */ + xiic_setreg32(i2c, XIIC_TLOW_REG_OFFSET, reg_val - 1); + + /* TSUSTA */ + reg_val = (timing_reg_values[index].tsusta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTA_REG_OFFSET, reg_val - 1); + + /* TSUSTO */ + reg_val = (timing_reg_values[index].tsusto * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUSTO_REG_OFFSET, reg_val - 1); + + /* THDSTA */ + reg_val = (timing_reg_values[index].thdsta * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_THDSTA_REG_OFFSET, reg_val - 1); + + /* TSUDAT */ + reg_val = (timing_reg_values[index].tsudat * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TSUDAT_REG_OFFSET, reg_val - 1); + + /* TBUF */ + reg_val = (timing_reg_values[index].tbuf * clk_in_mhz) / 1000; + xiic_setreg32(i2c, XIIC_TBUF_REG_OFFSET, reg_val - 1); + + /* THDDAT */ + xiic_setreg32(i2c, XIIC_THDDAT_REG_OFFSET, 1); + + return 0; +} + static int xiic_reinit(struct xiic_i2c *i2c) { int ret; xiic_setreg32(i2c, XIIC_RESETR_OFFSET, XIIC_RESET_MASK); + ret = xiic_setclk(i2c); + if (ret) + return ret; + /* Set receive Fifo depth to maximum (zero based). */ xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, IIC_RX_FIFO_DEPTH - 1); @@ -1138,6 +1274,15 @@ static int xiic_i2c_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(i2c->dev); pm_runtime_set_active(i2c->dev); pm_runtime_enable(i2c->dev); + + /* SCL frequency configuration */ + i2c->input_clk = clk_get_rate(i2c->clk); + ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &i2c->i2c_clk); + /* If clock-frequency not specified in DT, do not configure in SW */ + if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ) + i2c->i2c_clk = 0; + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, xiic_process, IRQF_ONESHOT, pdev->name, i2c); @@ -1181,6 +1326,9 @@ static int xiic_i2c_probe(struct platform_device *pdev) i2c_new_client_device(&i2c->adap, pdata->devices + i); } + dev_dbg(&pdev->dev, "mmio %08lx irq %d scl clock frequency %d\n", + (unsigned long)res->start, irq, i2c->i2c_clk); + return 0; err_clk_dis: