From patchwork Fri Apr 22 04:08:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 565920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11A6FC433EF for ; Fri, 22 Apr 2022 04:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443866AbiDVELx (ORCPT ); Fri, 22 Apr 2022 00:11:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443855AbiDVELe (ORCPT ); Fri, 22 Apr 2022 00:11:34 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2124.outbound.protection.outlook.com [40.107.93.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E466E4EA03; Thu, 21 Apr 2022 21:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ed/QCTJpAz3at2DSg6J3yAnqlB6ngWmun+ztXFgApwgToSigydjHZx3G5lLByVnxqandYskQIE65SSMYcMa24G1dyf2UVYDtek8b5G8XEDLKxQMM6TvIHPmt4R0xYhuhr78x+ir5MQ1ljl7EC/mYshNT9P63ZC1EJlxt4Art6ypAa1eFhv1xoabRF8U065r51t3q9KKXNrBAurW6tROQHwKCLNsndUr2pV+g0Q3Y6MScW9g+JCtIOeUFwKcmjhLxYs7xbRNy+eAyBnCiRLI0e93DQHiJjVkFsH/zui8goLQPPN04iRPQQjVEI0LPJllP1/hLwaJYn3gWCFZgAQW3UQ== 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=4AB4z21GlH5BDnsO4LeD2v6rjcUQffsM9T/vlXad6F0=; b=LebJD+XmLEzc0t4HOWrtE4ygtsroqANZcwrLjhfuzIaiLXzyVDVJ+QJx+oUc/XJCM7n18Lj/uRsJmCMHfPjrlsEW/g3eXztOcv/KczRqlqNntXAWqtUTl+WSD3kadMEfgWbSLzE2jx/jfoMW0UvQ870I3OjUohn/e2HeqUzBwEYO0u1I/BAlsCch/x06yJ8ZLcMrIaqVSGURg+nEhFZ0IvxZnmxeT/9GCLFvA8Tmg/8k2Fiz4E4sDFBcFIWXQGc/+TFDjCle0t+R2YAyQjOTtALeEAfEo9g8uhNWQmLd4dCAwwfEDZfkrd1VHJFB9JE+lPXru9xjOiGwbVJVABTN6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4AB4z21GlH5BDnsO4LeD2v6rjcUQffsM9T/vlXad6F0=; b=nmD2Ec5HyyON48DxrVpWYaMsigmiSn61rX6UuRDD8Qx6QjuiSWQEWDIb4VtnwgPutnI4TUhrcBMBT7gFrirhEFtWnR/+0IUU8I9e4W5sorEqDULkxpaoB3+oPcoiW9V/zL32J9rN+eAAiRvxBYw3FxML6Y6W2jkPg3kk39k7tfM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BL0PR0102MB3587.prod.exchangelabs.com (2603:10b6:207:38::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.25; Fri, 22 Apr 2022 04:08:39 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::319b:4612:e6f4:f22c]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::319b:4612:e6f4:f22c%3]) with mapi id 15.20.5186.015; Fri, 22 Apr 2022 04:08:39 +0000 From: Quan Nguyen To: Corey Minyard , Rob Herring , Krzysztof Kozlowski , Joel Stanley , Andrew Jeffery , Brendan Higgins , Benjamin Herrenschmidt , Wolfram Sang , openipmi-developer@lists.sourceforge.net, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 3/3] i2c: aspeed: Assert NAK when slave is busy Date: Fri, 22 Apr 2022 11:08:03 +0700 Message-Id: <20220422040803.2524940-4-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422040803.2524940-1-quan@os.amperecomputing.com> References: <20220422040803.2524940-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SI2PR04CA0005.apcprd04.prod.outlook.com (2603:1096:4:197::16) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a60d5fe5-25f4-49dc-418c-08da2415c7cd X-MS-TrafficTypeDiagnostic: BL0PR0102MB3587:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NgOVPwN+GX4MSQ6RCE7mAdfhWIaixBiaOfOCfaJNheMs0GIDdTt6BdsvfeIxL7WaX5KViA5DlY6axGEwf/6Fos2Ke8uNLu6Igg0hXWcYWMS3hlbo2dDjTgQIl0NwcqblMJjORqCPJ/Ux9u2SUg6xzpNTHJkysDUG9B5XRSQgb1V+DAUBWgNVnSDNFGYa5DPyvIMkiaw4fqqZrjEnxROOB0VGopzqBPU77HkZQRdBOctSSIB7M39BPo5sQJODxciNe3rsNyL/HUDOCRbay0D9Pnmc/WVtI3X8oTgDLIxA+CWA5cGb0brdJ9Em4pL3x4jKffI9nXYi+Hv8DN2f2NiLT2iasnXv78WAUiY+eRQqJUkt6gQ70FE8newFD841m24eYl4WzpyyjcgF8kR0+24gv/isvYqCVLO4/ade5H/sfS81K+QPtS+t9IdeGZl1ec6wGjoGP/ptRS/vt4ZSvkvuAc+PUfRhN16QOF3QW+YxrDPaWK39acdmKmlwpdFEgD1AEwASuwpqAObPIdQRE1t/qjojTKpNiQbvGgFUeS/E6V1qEkuJ968GrXD7YEUCNx/HzA09TbAmj/Pwbgbi2VjGYu5nlNIFHuBNGeYwEoWOl4I6Ufgiyjd32YtVuhl/T6WEk/gJaH/+lPQ53DU4cFDa8tgY4pK0E5CXFObRXD7I3SICOzIsVr1lb+MaSZwhNBGae+0okpz7n6BjFnwFPWZvmv2IEOSg3oKrE4xm1Vz3MWA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR01MB7282.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(316002)(186003)(4326008)(921005)(38100700002)(54906003)(66946007)(7416002)(86362001)(110136005)(8676002)(6486002)(38350700002)(8936002)(83380400001)(52116002)(2906002)(66476007)(66556008)(5660300002)(508600001)(1076003)(6512007)(6506007)(2616005)(26005)(6666004)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KpbXOBUBjGfvhS9V6fFYD48P34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CZPu9oJnySYz4A3ap+05jKxZrZ8yIpap+In3NgzJV4kcpB8dfm98xezhxOerD+82rgrGv04ISwt2YAEmGnuRcL8yMcnYkSMbxMsFmQX/6njOq/8BXt9Jg37nIcdbnaeKNgDJoOHAClYuOWZdnXqWbqfjfwpRys5SccL8ggDm8SQtvBQsyadRpFpV8VXBpuK1WJizGHFTc82YAt2WKUDqwZUt1fEpLRKkYVDJTNrdIMWFz34U3m+fuaFe2p+ZqJBQ/CA3bc4B1DmDKVdL+NIIVbzOyOAeiEAkznY0P+9AuUfgi4tTIpu+4ubjZgpLPlo83PtJVBcUBlA9WlN8qpTXMfYV0XgUxR6zslo5IyZPa99B3STvlE0EeSoRjUlGDlpg9InFjkhV18Y4y/Q1+WpFHFWVfl4mcHHYIz3daKJpR+Ik0y/7hds/BOo+/6r+1px4L4NzReN2v1szMXA0R6g8uJlDd723HFqz9CFFZUpwwzuGAJXYVezJrdxY+3b359RHbawJnJ49yld+i9aVIvkKpe+ztiEqS1lSvP8xiTVTR6l4wu4f7viEWhklTa8Xs0za9XREof/8jyCTgCi8jWJz0EeOQyU1SdrnH2u8Yp1+SPGI4JC9TWJ2yL51YudshGX1g5NG8DXfsyVqOJSpX+A1aVVwBmFH X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: a60d5fe5-25f4-49dc-418c-08da2415c7cd X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 04:08:39.6532 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ndM1NHlCx66lE1qKY0ozIaQaKWFIn7Sr5LNHBC5+f4apwk1DTXYx30MdmjQ9ju0FOJa0iPqsk0IB15ny7VchImhoRVoYqv6ITrbk5SPaCpE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR0102MB3587 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org When processing I2C_SLAVE_WRITE_REQUESTED event, if slave returns -EBUSY, i2c controller should issue RxCmdLast command to assert NAK on the bus. Signed-off-by: Quan Nguyen --- v7: + None v6: + New introduced in v6 [Quan] drivers/i2c/busses/i2c-aspeed.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 771e53d3d197..ebc2b92656c8 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -244,6 +244,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) u32 command, irq_handled = 0; struct i2c_client *slave = bus->slave; u8 value; + int ret; if (!slave) return 0; @@ -311,7 +312,9 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) break; case ASPEED_I2C_SLAVE_WRITE_REQUESTED: bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED; - i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value); + ret = i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value); + if (ret == -EBUSY) + writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG); break; case ASPEED_I2C_SLAVE_WRITE_RECEIVED: i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value);