From patchwork Mon Mar 29 12:09:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12170889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14070C433C1 for ; Mon, 29 Mar 2021 19:35:17 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 770F261976 for ; Mon, 29 Mar 2021 19:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 770F261976 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=ThvCfCZIHYi/467FJbkhR4GCDJ27HJIYR2o0Wu8ITPg=; b=Sr5IYjXsPzqP80cWET6X2hvp8 AHNs70NMnUV4kqvqVaaIBTd+hTEpi4+rUN84cZ4vjjV6BHbGTxdqP1JGwckIDu8wNzSLl0WgWlAXs N3N10xPvEbAAz4AINqr7lcZm9SafQgDMOKHZZHqfnY/8DX5eQ1QOkBX4ZiHaK6OxSBjAfo/TMNMU6 GzmuDpiQfztYA3w1HDT8W/3XacxyQilzqFdfIIqgDbCNnrW2w0t5iqYdkNKGVx2WuFG0hX50PYAbi iYtHVrdPmb9nxLU/evF2QnxJ0luotjbfHAynXOFCP6h15iLar5W9KKtqlAusLisP8jv9PS+bXa0WQ hvZpAWRFA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lQxZx-001Fm8-QL; Mon, 29 Mar 2021 19:29:39 +0000 Received: from mail-dm6nam11on2100.outbound.protection.outlook.com ([40.107.223.100] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lQqiI-000dOA-PM for linux-arm-kernel@lists.infradead.org; Mon, 29 Mar 2021 12:09:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mlk5gNfX4FNJFq4sX+AYOCgQ/QgrmX9kSjn2Cf4+QhE2QTLU+M5xSzjPUy8ALKM85A+1NfzISa4H0g4dBzYnqYv6dha6Wd/HrWfuDP20uftZmLUU3zRA+7SbwXlFbWLzYmbMAMGj7O+RizL/K0ettkJGNzh6SjNYKOx8Z8MejSPwPVIZGXIb2SD+/Nq/zOPKNlXCIvVQDumDDumY0IeWYJ2FF29j8kqLP7d3WWQjk32p/4yygn7n9BTUUpL5bVUdcTeUz10tVqG3FrUuTwG5EGPhtCweiQwEBCye/2EjCDX3EIPpL01t7MIomyBPPAVoCQFv66Spj3BG4WHAhZR8aw== 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-SenderADCheck; bh=ObTdeZ8zsjlufq5/WNaeZ0cI2o4TsSWrRB99EetYum4=; b=Jo4UWpuB1lUCQGyD2HOuXYjnHrwxMP/36LgVYPsbKJysp1Bi0sJrFHngxRO/ez5T2m2/y1H2zi7BaT5voQ2fXkMnO+m+8a8Pgaj83xkk5Y7BbriAuCuGIK8BvB6baBpTkAj0MQE/JnqNYW6ReMhlgYxC4L/ckEF7xfA12fm9vpM6V95fEif22PbZ4ZvxsWM4Qvv4srYdjToB1gxcgjUeEQhZdPPW/XQaOSjbdk0uXN5ftslKy1Onq+ziGWpLf7zQJvTJX1Opt3BZukP/eAuZSpIldrYKbmmBOeaXEEXf5A0Lk1D99VGPlzXhNo47k4EnlkXtuXR/xajf0HL6pNvxGg== 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=ObTdeZ8zsjlufq5/WNaeZ0cI2o4TsSWrRB99EetYum4=; b=UEIHovCXLIEACOY+/gXPICPJI0GVy395v36w2xpUggbF1wti9AqChSNdafR8fZjh1vHv6Ar8y07bTnMgw1NX7xTk99B5GNnSdTm4qhzn/LI8iaZxDwf1LSPg9wIfgixNjLYjIN9VJ9ePR+I6eGbKDSHqL/hnfEzcPYLCSwnczis= Authentication-Results: acm.org; dkim=none (message not signed) header.d=none;acm.org; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) by MWHPR01MB2320.prod.exchangelabs.com (2603:10b6:300:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Mon, 29 Mar 2021 12:09:38 +0000 Received: from MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503]) by MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503%5]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 12:09:38 +0000 From: Quan Nguyen To: Corey Minyard , Rob Herring , Joel Stanley , Andrew Jeffery , Wolfram Sang , Philipp Zabel , 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 Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v1 1/3] i2c: i2c-core-smbus: Expose PEC calculate function for generic use Date: Mon, 29 Mar 2021 19:09:12 +0700 Message-Id: <20210329120914.4527-2-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210329120914.4527-1-quan@os.amperecomputing.com> References: <20210329120914.4527-1-quan@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) To MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hcm-sw-17.amperecomputing.com (118.69.219.201) by HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Mon, 29 Mar 2021 12:09:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 949c0cd8-75c8-4e4f-eb9a-08d8f2ab8693 X-MS-TrafficTypeDiagnostic: MWHPR01MB2320: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sxSlpUsQC6huYJVssWEmaOc2WwjeStJLh+mwQHaBvV64WU6OU6Uy/LZ+dAHgNPJDl/aqjbS70Owsd1alUWtoIqA8s/UFJFgsE0JKU4CWRoDMaL8EShsxxDQU5/2fc78575fcwlNK4p71aRkfpis/Yg/z0R/wWTLWUTHvRunVa38i9vrFW4QSfGd2t9P52EWKG8tRJhZYR1Gj2kay5Bsue8sPZI13P0mnUGG3CLhajzXN5hDThQlT0iFFXzMjmoXM060cVvGk2vuUmC+ANfunx2/iGFJrShwRPrRIhKBvPEkyqcpBv+5wJGravYJy2yRCe5q/LEidcXJpG93onM0phDtnhsaPb02F0+0dCYWoti+Fn6o8eT2HjeTfJslTVUZ3Oknv8aqHTUkxg0kw37BaqlUJJZHozHcm20ZMjxxmGrOiI/KFpNxq6/mGXjXFjupjq9ujSq8fVt9wh4VnQ9PNUipJhiZ5/qZDc//EMCYfsZ7EjbX5aZ890d+j7LKemuBqt1+D6mMDdqvEBhwyukYsjm+mHsxdnsmZQ4dJ/vw+OJoXfipF7s4WkNraSaEt5ykBCxBcVxOU1Xh9WAkADjyeuIowzbR/hWY/ZxIb1YiPEIAd9PIDummqHLId6lGA6DqbprmqHbfIhWEbVdCaNqb5JxcxNNDGx64nZM68gXJb7L/KuuE2ILDIDdd+Sh+nNOe0JgnXWlIwT1ZaCuCwq0B3GQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR0102MB3482.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(366004)(136003)(346002)(376002)(39840400004)(7416002)(107886003)(921005)(86362001)(110136005)(6486002)(8676002)(52116002)(4326008)(8936002)(6512007)(66946007)(2906002)(956004)(5660300002)(2616005)(478600001)(26005)(6506007)(1076003)(83380400001)(54906003)(186003)(16526019)(6666004)(316002)(66476007)(66556008)(38100700001)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9xn90ef8EuZvfsopt/ANvizu85vpVr7k7jDB4YHhxtZp2QIm7JhOkGezpEmZttaNO2L3dsoERpt7Mk00aAeFMvZgW/Hr0GK+FftVmMakZPEbLkULbviJsGqwTPqtgI/cNb8EG54BWnlApa/DEqmBPT5fJVSryr+1kXX3q3mPnXJvaxIAJQnCVxPOv4tIh2UxKWuC7F3tOOCa7Q0VMcxJ4Ry51NdxS/yLixmhy7SGwwqWKXB0AS8FgdxDUcxdQOXhCSJGaxmbVoqGTKaCl6d2E6zfff2Ee0JPlZTmfDjV7WoGnARnK6Raa+H2d8hsQxDmVlppz8vk30YxhRPmsifam1Tf4jlea/dZCephc7BS1JV2Wd420yS5vwasj/aXzyF6jauStQ/61Se/deUhsudlDniMP8fFn0tgN3H/KKdGWXTyR3Ic2eTVnCi3DhfSKz9zi7hnA9evhHmDOJ0VZcsd6PjDq4kwOHvh2ZOreWJXoFYofP1pVueYXm/UzKvT1s0PfdNykRlOwGlKxjPSyu4bOh2QPe/qmwr7+DwojcKtUGe6aZXscDETWYFc41i/mBghCd4mr3Rscsvlm/su1wa6TDMaZRYRvea3BOKVK0L46NrS7c9WXlX0gjGOCgYfElC7Dh9rhO/A9vqGiVLWs1QeRvhA286kAd+i06ETWW86FQbpoxNMUUaahHoxAXLu97Vq2XRU+LzeIWe6su+nAMgqHVRqqp3GZQ+baMr1hHkUDAU0jvsXzTpM312pFKQpEAsbnEqIcJtJKAeGSOQz5gz2g+s5+pOzT9AcE+DkJ2sWYEkzLmhTUajlS+tn++cQvqY6771vVCDs3UJ87+rfmZVo558eoG7PQNn6djzN12fyssNGV3mQt2yNqOAbrGAYrBYluAxWDmJm9trHF/GOp2MjjkdpaHsaLTT0zxxwlR1GruYr2/IFuSoxd9xVhXeR/zdstawqigOCv/ur5BzRQD89NPZH3w0iYBtAFsg+BvfbRexk4jZvTnPi4Na/4//hPvm/dD/RjdVZ9reJE7spj2XgZ9CgqhWwaENiR4SWOCtX1VV6oIXYHeuZZ2M2hmcJ+HnS/3TeK/ARDsx3yzWzzyZWrtvB+I8F37yPw1Q8E/B43VVF9wVSV9ofh7FmiAfiPEZ1TNiaGyZnhviSLgOGSiK1b7KL6aocPr/kafAtgRAaK+pqDmaoNVOkv2K8gxQ1UkI4g/IwBXomSVXy1tGc6YjGpgIlp4IumD9+QhkYtSDp9vnlAQKn9H22hOOGgC9h+rFV6Rym5ssCMDehWEKNjviNy/1WVgD/nOdEvtzyxfHLDzf9ZpqACh6vDBhXPEN/vDdv X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 949c0cd8-75c8-4e4f-eb9a-08d8f2ab8693 X-MS-Exchange-CrossTenant-AuthSource: MW2PR0102MB3482.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2021 12:09:38.7943 (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: 3pa7o7j7xMaw/nwUp0rQQxo6zefAuPG9jTPQNwlzfpPIw2u+0eeJTccwrlV9WWFprNDRNjqyMwoTP3a863Lgc6mvnRCE+NyF4RLNWtw/8HI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR01MB2320 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210329_130946_902573_CD6FEE47 X-CRM114-Status: GOOD ( 11.21 ) 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 Expose the PEC calculation i2c_smbus_pec() for generic use. Signed-off-by: Quan Nguyen --- drivers/i2c/i2c-core-smbus.c | 12 ++++++++++-- include/linux/i2c.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index d2d32c0fd8c3..e5b2d1465e7e 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c @@ -37,8 +37,15 @@ static u8 crc8(u16 data) return (u8)(data >> 8); } -/* Incremental CRC8 over count bytes in the array pointed to by p */ -static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) +/** + * i2c_smbus_pec - Incremental CRC8 over the given input data array + * @crc: previous return crc8 value + * @p: pointer to data buffer. + * @count: number of bytes in data buffer. + * + * Incremental CRC8 over count bytes in the array pointed to by p + */ +u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) { int i; @@ -46,6 +53,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) crc = crc8((crc ^ p[i]) << 8); return crc; } +EXPORT_SYMBOL(i2c_smbus_pec); /* Assume a 7-bit address, which is reasonable for SMBus */ static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 56622658b215..0d75e5bcdde6 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -144,6 +144,7 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, /* Now follow the 'nice' access routines. These also document the calling conventions of i2c_smbus_xfer. */ +u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count); s32 i2c_smbus_read_byte(const struct i2c_client *client); s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value); s32 i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command); From patchwork Mon Mar 29 12:09:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12170891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85BDFC433C1 for ; Mon, 29 Mar 2021 19:36:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18A846196E for ; Mon, 29 Mar 2021 19:36:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18A846196E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=gdXuz4sAgiB3hpazgqw6iPP1jUp672P4oG+jjUrJsOE=; b=KB611xN8DdGETEEDmfj0K8oRA +OCerw5hr1bswRVYBvYfZxMQZCnNOjdD0DyULePbFNCiLzcqvQ+Bphp8Ms/kATIg1Pb8+rM5UDgCk dahhRpbqsX2CVNWXdCojewXHzxRcQUB8h9iUGKYNEdVSFMGzINopeNDUfst8xeoCfd5bd8RyHSh1f A8C/utNHB4y8T5YM5U0EN+erdMdJK+R1RkxOYynjP74cNJHOgnKg6USTN/wo04qdWeCaAPr9Ydeyr 1brMZfe9D7lo6qRXN3Fgk3OKJrrLo1rczyOJvyy6liSip2lNwYRFvl1J/jNpqvKQP13A7XqoqWsLn Nm6g/jsKw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lQxaS-001Fx8-E3; Mon, 29 Mar 2021 19:30:09 +0000 Received: from mail-dm6nam11on2100.outbound.protection.outlook.com ([40.107.223.100] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lQqiL-000dOA-2l for linux-arm-kernel@lists.infradead.org; Mon, 29 Mar 2021 12:09:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HHOasz3ICNllG/VtkPbRy0dB72XFzEQY3OPp1aLUkRU/tlnn9zN0HCV0GI75Pj1f1DZKn7hbM+RNAf7qZ0lqCpm/Hgq6VGiIbL844qWLRDm1lYf56t7BhogVJsA161dZuIAJfffvbcxr+L9R9B1NiqGW1VfdhGzdxgkJkEQKGFB0eFLyePCIwmnwLYhyB3/8MeUC8kErdLb4332bHa0cTdZm6+hJkGOydFM6nX2/1W1TTyqSwTsCteKDOVWSDCq6IIRrheEYHOmPp/1xPEzRaOuuY9ES3ZfXscJLImTKIb19lOKTXs+DvFaEaMyRnwDA1HCu3Ug6HLak4YfTWPOXsg== 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-SenderADCheck; bh=vmTD/UAk6wbBkI+OBSheNaNjRlvzJADBqzqKzbZAtIk=; b=Gsj9cYImhzzk3J2CIEhGJIhyisAvPHLcPJlHVCd9r9NvctWjKzKcpZFbfSEGbhCRSaA0alVIPtG8DilatEq/Tl5ObKnQi1u98xfnHU0NEo3SyIctkMceRck8Q/BwQOA1KYMG1jdkzabiSFh9NSJKqO3bmXG4h7PeIJeFYyIcinxmIQ+RsRIZFHKZBIh49mYDiFaUM070ePbppQOSczV/7O80AfkkVJiKhhDtzBAg5kdFk1Ksa7QDP2drNrq7tsWeuo8oHEUf++rqKSSNvIZm7/JZ+vGzpW4Vlh4tGLX5zri0TYfHpXjoscA/SoRp8Gniq8vLFO9dKlKGuty+ix7kew== 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=vmTD/UAk6wbBkI+OBSheNaNjRlvzJADBqzqKzbZAtIk=; b=A+kENpt3fXFQHI9vKry/A5jWKPqmLIAiQ6V5ddHGf85QKApT7m/yHGwiMb3qX2btB8Js6Sg/OvhUSX+8ZhZ+ihg8xv1CUqzP4Zr2LGzBjPUmJNVHGjHNJ4pKEQ3hiiR57EspuMmrzzoOEGJsxdBRlXXdtSyK48QJC00XK37leaU= Authentication-Results: acm.org; dkim=none (message not signed) header.d=none;acm.org; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) by MWHPR01MB2320.prod.exchangelabs.com (2603:10b6:300:26::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Mon, 29 Mar 2021 12:09:43 +0000 Received: from MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503]) by MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503%5]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 12:09:43 +0000 From: Quan Nguyen To: Corey Minyard , Rob Herring , Joel Stanley , Andrew Jeffery , Wolfram Sang , Philipp Zabel , 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 Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v1 2/3] drivers: char: ipmi: Add Aspeed SSIF BMC driver Date: Mon, 29 Mar 2021 19:09:13 +0700 Message-Id: <20210329120914.4527-3-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210329120914.4527-1-quan@os.amperecomputing.com> References: <20210329120914.4527-1-quan@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) To MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hcm-sw-17.amperecomputing.com (118.69.219.201) by HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Mon, 29 Mar 2021 12:09:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89fdf95b-fa86-4f28-ee9a-08d8f2ab88fc X-MS-TrafficTypeDiagnostic: MWHPR01MB2320: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4KZmivTx093MwKapFknJCGIGF/Lqkskhar/m/vf6EmOEHCaZV5R+tPAPZ/lTWNkXN59RYTTKybavdSC4LJMaQNEYeM2mf4EdS3aApJ8Fsg165e9iCwGpktHcWQ4bAohfyYDLaK1BHZteFxdfYTfp56bTSq02WOqMiH3BdaBSnR/Rgdz5b/nRHEYEkZFmIyqSjg4sP6eaB/yMGyXu31grC009jwmfJl1/6o/9Wld7iSZauC/6hXSXbbcvRzAJs2ZfqrCb8SKvj7QMvVGfr9W0NufwXrQmHk6ftjdI5DWCDWh1fJDtyNuxNPBBvKArVcdtr11XuNRotstFD0Fr/luRbHD4XhWnWgZtEWba944ZYegY3mxUywNBbBvQe2OFlwXfLy0h0ZiKgm7NDJkyzr3KXp691QOGy4GQt2GCZfZJix+OQAvfm0r2N53X2z+j6lwOenBgXvYcfxmC30QI1XQJGZCJxuN6jgZRuxEu9/uBvmbIsl0CAlJbNin2UAdkeGezXl20UrIqKBR1q91i2OO2qI9ZP666OTSD5zakVG2H4wcThZekz+pwUqN+uYgRcd5fRKrZWZX6/SpzvsXCCd3Z2zJLWyrB/vNQ8qn10fVe217dk0oYBSGvBYfS8DqNYgHZKu8M9FUCPtzdgNNo1M86wTkC6ukYxL5Kxlxius4tMKoXbaP8c2rd1/qQRl9vWrCoX9XeWXD5PfrAG74z2wob/e/azw4kIvCbuK6/kv6l0uZWnpHng+9mNFM10+/CsQ1B5mRtKhjmS1ZeK3kInQYbAA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR0102MB3482.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(366004)(136003)(346002)(376002)(39840400004)(7416002)(107886003)(921005)(86362001)(110136005)(6486002)(8676002)(52116002)(4326008)(8936002)(6512007)(66946007)(2906002)(956004)(5660300002)(2616005)(478600001)(26005)(30864003)(6506007)(1076003)(83380400001)(54906003)(186003)(16526019)(6666004)(316002)(66476007)(66556008)(38100700001)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?wZ76lSwzhww/ydv+FQyGVKukG8hXt9?= =?utf-8?q?YyrBKADppxPS42o1I+gOfaFKCynQ+mYzUam101q2DaIGVD+vJzUvle4WWiuObFjP+?= =?utf-8?q?pLM3eLmcgOENlqGLNMn/XyDD5viXJbTzVbaIRRqB0zXmFXyIbWomQ5ae7z6JgXqxS?= =?utf-8?q?TkxmOcW9dZFM8qr1mrHEmtZty9Y9IqSQaYeZ9oUX18j8iv6fDtWM3SILCa1PNp9xu?= =?utf-8?q?7QOXkWUZGltX/LV3OEzBzGs6y/CB3Yrc0aNvgBr/cXAmbfBc51R/k9a49CufhdVml?= =?utf-8?q?zkVY94pTXJzezi97EMRWsOXsFgGkv1av6GdApax4vfMpbFlnhy2Hl0Z/+ZhSvUuv6?= =?utf-8?q?pBVURqjmosWIXoH+VMik8T6TZg7T5Nd2Ur3iMNkZrM52ttiX7ePkP8K04m4DzhVj9?= =?utf-8?q?xvuxRKlRT8Rcbw+B55JYSZ4T0M5R1UMEdP3fuwNFSA/Z8GcTXZn5jTOpwwbrzqL5d?= =?utf-8?q?PJ7s8rMX7YmXQCSyxbAbGC1eonjaaW0OASNdgY7b9KaZFhiGgtx2C+J4MXNUICORM?= =?utf-8?q?IwoD1QiBFlLCzB5wxARrDbbqq2v88LQCNcxu5c4FlnYile3RCXinnzGKluJRhKAOH?= =?utf-8?q?D46Ffd5DxZnc+5mszkE6YyMOZmSHzA1NWTvBA3Uq0WsL7OwF/5InAnoaEU5K9YT+C?= =?utf-8?q?Mj1JnYytLV9FVrBtCjvayEk4Wv6EJgazoGaCIvZF4tDXRm8JOteyuMGqn54Jq4Ahe?= =?utf-8?q?2Xj7vrAjUO9X9nLxviZvVnvNX1ZtTCFShI+kxj5u4YnYqbfQYUATdB2a8TeWss7sH?= =?utf-8?q?bdoiHd8ENjvqlXiZpak9J0PawoOKBUqzdzGRt6Bf8jIBl72Kkb1VeSGPBhIuurTjZ?= =?utf-8?q?Q6pSh+lScqeLalaRVnMsxAXql0FoCnWKcAVLFc2GfJlgze2NVCk1hJ5f+XR2A/y3F?= =?utf-8?q?QIGGk/0XWAYo4Yk0tq8XtreXKBSJrrTRvLjXXM7VD7KtGzz6X6WL1TfynQ/kvPRXM?= =?utf-8?q?klJjkKuzYhULe10kV/86ZkXnJDRzvvzx7ChebtmpyZMNzYUbQXRDuNc0tpDdAdMFE?= =?utf-8?q?g55GSFUcD4TXGF6TQfTwCA3aAoMtoIQzAqwOxQK/pMocqnxfhsv1Ty9vfXNR3Z9cq?= =?utf-8?q?9cIHtiEbDN8Q+ocribzc9mrtNI17GPEU7/9GwuKPvAQIv4tGn/yF1XKUeyrNqgfnQ?= =?utf-8?q?UusXgv0NYI6xdazIEA+2zrk60Dqjb5WXuuNSq6mfhZiZj4Uy22pQD4HFrKzRCx0pO?= =?utf-8?q?DnuMyhnJKXefKxKjjg0ez13JRbMMWvSP+jJFuEn7i7mIWMoBkiJSBzmeu/0i5SOhw?= =?utf-8?q?SyfUP0xTWGrY1V?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89fdf95b-fa86-4f28-ee9a-08d8f2ab88fc X-MS-Exchange-CrossTenant-AuthSource: MW2PR0102MB3482.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2021 12:09:42.9609 (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: lqzxFC/MkzT29kH0KMo2g6m0l7QkepFMYv6ol6OQNfyxkwog/dVV2QECU0AwoUMU6WBdsISL3lGx+7Bre4Yq/2ZwSwBVdyfMoIGNXLjFxN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR01MB2320 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210329_130949_463619_1DB3D446 X-CRM114-Status: GOOD ( 23.73 ) 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 The SMBus system interface (SSIF) IPMI BMC driver can be used to perform in-band IPMI communication with their host in management (BMC) side. This commits adds support specifically for Aspeed AST2500 which commonly used as Board Management Controllers. Signed-off-by: Quan Nguyen --- drivers/char/ipmi/Kconfig | 22 + drivers/char/ipmi/Makefile | 2 + drivers/char/ipmi/ssif_bmc.c | 645 ++++++++++++++++++++++++++++ drivers/char/ipmi/ssif_bmc.h | 92 ++++ drivers/char/ipmi/ssif_bmc_aspeed.c | 132 ++++++ 5 files changed, 893 insertions(+) create mode 100644 drivers/char/ipmi/ssif_bmc.c create mode 100644 drivers/char/ipmi/ssif_bmc.h create mode 100644 drivers/char/ipmi/ssif_bmc_aspeed.c diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig index 07847d9a459a..d67fd204409a 100644 --- a/drivers/char/ipmi/Kconfig +++ b/drivers/char/ipmi/Kconfig @@ -133,6 +133,28 @@ config ASPEED_BT_IPMI_BMC found on Aspeed SOCs (AST2400 and AST2500). The driver implements the BMC side of the BT interface. +config SSIF_IPMI_BMC + tristate "SSIF IPMI BMC driver" + help + This enables the IPMI SMBus system interface (SSIF) at the + management (BMC) side. + + The driver implements the BMC side of the SMBus system + interface (SSIF). + +config ASPEED_SSIF_IPMI_BMC + depends on ARCH_ASPEED || COMPILE_TEST + depends on I2C + select SSIF_IPMI_BMC + select I2C_SLAVE + tristate "Aspeed SSIF IPMI BMC driver" + help + Provides a driver for the SSIF IPMI interface found on + Aspeed AST2500 SoC. + + The driver implements the BMC side of the SMBus system + interface (SSIF), specific for Aspeed AST2500 SoC. + config IPMB_DEVICE_INTERFACE tristate 'IPMB Interface handler' depends on I2C diff --git a/drivers/char/ipmi/Makefile b/drivers/char/ipmi/Makefile index 0822adc2ec41..05b993f7335b 100644 --- a/drivers/char/ipmi/Makefile +++ b/drivers/char/ipmi/Makefile @@ -27,3 +27,5 @@ obj-$(CONFIG_ASPEED_BT_IPMI_BMC) += bt-bmc.o obj-$(CONFIG_ASPEED_KCS_IPMI_BMC) += kcs_bmc_aspeed.o obj-$(CONFIG_NPCM7XX_KCS_IPMI_BMC) += kcs_bmc_npcm7xx.o obj-$(CONFIG_IPMB_DEVICE_INTERFACE) += ipmb_dev_int.o +obj-$(CONFIG_SSIF_IPMI_BMC) += ssif_bmc.o +obj-$(CONFIG_ASPEED_SSIF_IPMI_BMC) += ssif_bmc_aspeed.o diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c new file mode 100644 index 000000000000..ae6e8750c795 --- /dev/null +++ b/drivers/char/ipmi/ssif_bmc.c @@ -0,0 +1,645 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * The driver for BMC side of SSIF interface + * + * Copyright (c) 2021, Ampere Computing LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ssif_bmc.h" + +/* + * Call in WRITE context + */ +static int send_ssif_bmc_response(struct ssif_bmc_ctx *ssif_bmc, bool non_blocking) +{ + unsigned long flags; + int ret; + + if (!non_blocking) { +retry: + ret = wait_event_interruptible(ssif_bmc->wait_queue, + !ssif_bmc->response_in_progress); + if (ret) + return ret; + } + + spin_lock_irqsave(&ssif_bmc->lock, flags); + if (ssif_bmc->response_in_progress) { + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + if (non_blocking) + return -EAGAIN; + + goto retry; + } + + /* + * Check the response data length from userspace to determine the type + * of the response message whether it is single-part or multi-part. + */ + ssif_bmc->is_singlepart_read = + (ssif_msg_len(&ssif_bmc->response) <= (MAX_PAYLOAD_PER_TRANSACTION + 1)) ? + true : false; /* 1: byte of length */ + + ssif_bmc->response_in_progress = true; + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + + return 0; +} + +/* + * Call in READ context + */ +static int receive_ssif_bmc_request(struct ssif_bmc_ctx *ssif_bmc, bool non_blocking) +{ + unsigned long flags; + int ret; + + if (!non_blocking) { +retry: + ret = wait_event_interruptible(ssif_bmc->wait_queue, + ssif_bmc->request_available); + if (ret) + return ret; + } + + spin_lock_irqsave(&ssif_bmc->lock, flags); + if (!ssif_bmc->request_available) { + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + if (non_blocking) + return -EAGAIN; + goto retry; + } + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + + return 0; +} + +/* Handle SSIF message that will be sent to user */ +static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) +{ + struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(file); + struct ssif_msg msg; + unsigned long flags; + ssize_t ret; + + mutex_lock(&ssif_bmc->file_mutex); + + ret = receive_ssif_bmc_request(ssif_bmc, file->f_flags & O_NONBLOCK); + if (ret < 0) + goto out; + + spin_lock_irqsave(&ssif_bmc->lock, flags); + count = min_t(ssize_t, count, ssif_msg_len(&ssif_bmc->request)); + memcpy(&msg, &ssif_bmc->request, count); + ssif_bmc->request_available = false; + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + + ret = copy_to_user(buf, &msg, count); +out: + mutex_unlock(&ssif_bmc->file_mutex); + + return (ret < 0) ? ret : count; +} + +/* Handle SSIF message that is written by user */ +static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t count, + loff_t *ppos) +{ + struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(file); + struct ssif_msg msg; + unsigned long flags; + ssize_t ret; + + if (count > sizeof(struct ssif_msg)) + return -EINVAL; + + mutex_lock(&ssif_bmc->file_mutex); + + ret = copy_from_user(&msg, buf, count); + if (ret) + goto out; + + spin_lock_irqsave(&ssif_bmc->lock, flags); + if (count >= ssif_msg_len(&ssif_bmc->response)) + memcpy(&ssif_bmc->response, &msg, count); + else + ret = -EINVAL; + spin_unlock_irqrestore(&ssif_bmc->lock, flags); + + if (ret) + goto out; + + ret = send_ssif_bmc_response(ssif_bmc, file->f_flags & O_NONBLOCK); + if (!ret && ssif_bmc->set_ssif_bmc_status) + ssif_bmc->set_ssif_bmc_status(ssif_bmc, SSIF_BMC_READY); +out: + mutex_unlock(&ssif_bmc->file_mutex); + + return (ret < 0) ? ret : count; +} + +static long ssif_bmc_ioctl(struct file *file, unsigned int cmd, unsigned long param) +{ + return 0; +} + +static unsigned int ssif_bmc_poll(struct file *file, poll_table *wait) +{ + struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(file); + unsigned int mask = 0; + + mutex_lock(&ssif_bmc->file_mutex); + poll_wait(file, &ssif_bmc->wait_queue, wait); + + /* + * The request message is now available so userspace application can + * get the request + */ + if (ssif_bmc->request_available) + mask |= POLLIN; + + mutex_unlock(&ssif_bmc->file_mutex); + return mask; +} + +/* + * System calls to device interface for user apps + */ +static const struct file_operations ssif_bmc_fops = { + .owner = THIS_MODULE, + .read = ssif_bmc_read, + .write = ssif_bmc_write, + .poll = ssif_bmc_poll, + .unlocked_ioctl = ssif_bmc_ioctl, +}; + +/* Called with ssif_bmc->lock held. */ +static int handle_request(struct ssif_bmc_ctx *ssif_bmc) +{ + if (ssif_bmc->set_ssif_bmc_status) + ssif_bmc->set_ssif_bmc_status(ssif_bmc, SSIF_BMC_BUSY); + + /* Request message is available to process */ + ssif_bmc->request_available = true; + /* + * This is the new READ request. + * Clear the response buffer of the previous transaction + */ + memset(&ssif_bmc->response, 0, sizeof(struct ssif_msg)); + wake_up_all(&ssif_bmc->wait_queue); + return 0; +} + +/* Called with ssif_bmc->lock held. */ +static int complete_response(struct ssif_bmc_ctx *ssif_bmc) +{ + /* Invalidate response in buffer to denote it having been sent. */ + ssif_bmc->response.len = 0; + ssif_bmc->response_in_progress = false; + ssif_bmc->nbytes_processed = 0; + ssif_bmc->remain_len = 0; + memset(&ssif_bmc->response_buf, 0, MAX_PAYLOAD_PER_TRANSACTION); + wake_up_all(&ssif_bmc->wait_queue); + return 0; +} + +static void set_multipart_response_buffer(struct ssif_bmc_ctx *ssif_bmc, u8 *val) +{ + u8 response_len = 0; + int idx = 0; + u8 data_len; + + data_len = ssif_bmc->response.len; + switch (ssif_bmc->smbus_cmd) { + case SSIF_IPMI_MULTIPART_READ_START: + /* + * Read Start length is 32 bytes. + * Read Start transfer first 30 bytes of IPMI response + * and 2 special code 0x00, 0x01. + */ + *val = MAX_PAYLOAD_PER_TRANSACTION; + ssif_bmc->remain_len = data_len - MAX_IPMI_DATA_PER_START_TRANSACTION; + ssif_bmc->block_num = 0; + + ssif_bmc->response_buf[idx++] = 0x00; /* Start Flag */ + ssif_bmc->response_buf[idx++] = 0x01; /* Start Flag */ + ssif_bmc->response_buf[idx++] = ssif_bmc->response.netfn_lun; + ssif_bmc->response_buf[idx++] = ssif_bmc->response.cmd; + ssif_bmc->response_buf[idx++] = ssif_bmc->response.payload[0]; + + response_len = MAX_PAYLOAD_PER_TRANSACTION - idx; + + memcpy(&ssif_bmc->response_buf[idx], &ssif_bmc->response.payload[1], + response_len); + break; + + case SSIF_IPMI_MULTIPART_READ_MIDDLE: + /* + * IPMI READ Middle or READ End messages can carry up to 31 bytes + * IPMI data plus block number byte. + */ + if (ssif_bmc->remain_len < MAX_IPMI_DATA_PER_MIDDLE_TRANSACTION) { + /* + * This is READ End message + * Return length is the remaining response data length + * plus block number + * Block number 0xFF is to indicate this is last message + * + * Return length is: remain response plus block number + */ + *val = ssif_bmc->remain_len + 1; + ssif_bmc->block_num = 0xFF; + ssif_bmc->response_buf[idx++] = ssif_bmc->block_num; + response_len = ssif_bmc->remain_len; + } else { + /* + * This is READ Middle message + * Response length is the maximum SMBUS transfer length + * Block number byte is incremented + * Return length is maximum SMBUS transfer length + */ + *val = MAX_PAYLOAD_PER_TRANSACTION; + ssif_bmc->remain_len -= MAX_IPMI_DATA_PER_MIDDLE_TRANSACTION; + response_len = MAX_IPMI_DATA_PER_MIDDLE_TRANSACTION; + ssif_bmc->response_buf[idx++] = ssif_bmc->block_num; + ssif_bmc->block_num++; + } + + memcpy(&ssif_bmc->response_buf[idx], + ssif_bmc->response.payload + 1 + ssif_bmc->nbytes_processed, + response_len); + break; + + default: + /* Do not expect to go to this case */ + pr_err("Error: Unexpected SMBus command received 0x%x\n", ssif_bmc->smbus_cmd); + break; + } + + ssif_bmc->nbytes_processed += response_len; +} + +static void set_singlepart_response_buffer(struct ssif_bmc_ctx *ssif_bmc, u8 *val) +{ + u8 *buf = (u8 *)&ssif_bmc->response; + + /* + * Do not expect the IPMI response has data length 0. + * With some I2C SMBus controllers (Aspeed I2C), return 0 for + * the SMBus Read Request callback might cause bad state for + * the bus. So return 1 byte length so that master will + * resend the Read Request because the length of response is + * less than a normal IPMI response. + * + * Otherwise, return the length of IPMI response + */ + *val = (buf[ssif_bmc->msg_idx]) ? buf[ssif_bmc->msg_idx] : 0x1; +} + +/* Process the IPMI response that will be read by master */ +static void handle_read_processed(struct ssif_bmc_ctx *ssif_bmc, u8 *val) +{ + u8 *buf; + u8 pec_len, addr, len; + u8 pec = 0; + + pec_len = ssif_bmc->pec_support ? 1 : 0; + /* PEC - Start Read Address */ + addr = GET_8BIT_ADDR(ssif_bmc->client->addr); + pec = i2c_smbus_pec(pec, &addr, 1); + /* PEC - SSIF Command */ + pec = i2c_smbus_pec(pec, &ssif_bmc->smbus_cmd, 1); + /* PEC - Restart Write Address */ + addr = addr | 0x01; + pec = i2c_smbus_pec(pec, &addr, 1); + + if (ssif_bmc->is_singlepart_read) { + /* Single-part Read processing */ + buf = (u8 *)&ssif_bmc->response; + + if (ssif_bmc->response.len && ssif_bmc->msg_idx < ssif_bmc->response.len) { + ssif_bmc->msg_idx++; + *val = buf[ssif_bmc->msg_idx]; + } else if (ssif_bmc->response.len && + (ssif_bmc->msg_idx == ssif_bmc->response.len)) { + ssif_bmc->msg_idx++; + *val = i2c_smbus_pec(pec, buf, ssif_msg_len(&ssif_bmc->response)); + } else { + *val = 0; + } + /* Invalidate response buffer to denote it is sent */ + if (ssif_bmc->msg_idx + 1 >= (ssif_msg_len(&ssif_bmc->response) + pec_len)) + complete_response(ssif_bmc); + } else { + /* Multi-part Read processing */ + switch (ssif_bmc->smbus_cmd) { + case SSIF_IPMI_MULTIPART_READ_START: + case SSIF_IPMI_MULTIPART_READ_MIDDLE: + buf = (u8 *)&ssif_bmc->response_buf; + *val = buf[ssif_bmc->msg_idx]; + ssif_bmc->msg_idx++; + break; + default: + /* Do not expect to go to this case */ + pr_err("Error: Unexpected SMBus command received 0x%x\n", + ssif_bmc->smbus_cmd); + break; + } + len = (ssif_bmc->block_num == 0xFF) ? + ssif_bmc->remain_len + 1 : MAX_PAYLOAD_PER_TRANSACTION; + if (ssif_bmc->msg_idx == (len + 1)) { + pec = i2c_smbus_pec(pec, &len, 1); + *val = i2c_smbus_pec(pec, ssif_bmc->response_buf, len); + } + /* Invalidate response buffer to denote last response is sent */ + if (ssif_bmc->block_num == 0xFF && + ssif_bmc->msg_idx > (ssif_bmc->remain_len + pec_len)) { + complete_response(ssif_bmc); + } + } +} + +static void handle_write_received(struct ssif_bmc_ctx *ssif_bmc, u8 *val) +{ + u8 *buf; + u8 smbus_cmd; + + buf = (u8 *)&ssif_bmc->request; + if (ssif_bmc->msg_idx >= sizeof(struct ssif_msg)) + return; + + smbus_cmd = ssif_bmc->smbus_cmd; + switch (smbus_cmd) { + case SSIF_IPMI_SINGLEPART_WRITE: + /* Single-part write */ + buf[ssif_bmc->msg_idx - 1] = *val; + ssif_bmc->msg_idx++; + + break; + case SSIF_IPMI_MULTIPART_WRITE_START: + /* Reset length to zero */ + if (ssif_bmc->msg_idx == 1) + ssif_bmc->request.len = 0; + + fallthrough; + case SSIF_IPMI_MULTIPART_WRITE_MIDDLE: + case SSIF_IPMI_MULTIPART_WRITE_END: + /* Multi-part write, 2nd byte received is length */ + if (ssif_bmc->msg_idx == 1) { + ssif_bmc->request.len += *val; + ssif_bmc->recv_len = *val; + } else { + buf[ssif_bmc->msg_idx - 1 + + ssif_bmc->request.len - ssif_bmc->recv_len] = *val; + } + + ssif_bmc->msg_idx++; + + break; + default: + /* Do not expect to go to this case */ + pr_err("Error: Unexpected SMBus command received 0x%x\n", ssif_bmc->smbus_cmd); + break; + } +} + +static bool validate_pec(struct ssif_bmc_ctx *ssif_bmc) +{ + u8 rpec = 0, cpec = 0; + bool ret = true; + u8 addr, index; + u8 *buf; + + buf = (u8 *)&ssif_bmc->request; + switch (ssif_bmc->smbus_cmd) { + case SSIF_IPMI_SINGLEPART_WRITE: + if ((ssif_bmc->msg_idx - 1) == ssif_msg_len(&ssif_bmc->request)) { + /* PEC is not included */ + ssif_bmc->pec_support = false; + return true; + } + + if ((ssif_bmc->msg_idx - 1) != (ssif_msg_len(&ssif_bmc->request) + 1)) + goto error; + + /* PEC is included */ + ssif_bmc->pec_support = true; + rpec = buf[ssif_bmc->msg_idx - 2]; + addr = GET_8BIT_ADDR(ssif_bmc->client->addr); + cpec = i2c_smbus_pec(cpec, &addr, 1); + cpec = i2c_smbus_pec(cpec, &ssif_bmc->smbus_cmd, 1); + cpec = i2c_smbus_pec(cpec, buf, ssif_msg_len(&ssif_bmc->request)); + if (rpec != cpec) { + pr_err("Bad PEC 0x%02x vs. 0x%02x\n", rpec, cpec); + ret = false; + } + + break; + case SSIF_IPMI_MULTIPART_WRITE_START: + case SSIF_IPMI_MULTIPART_WRITE_MIDDLE: + case SSIF_IPMI_MULTIPART_WRITE_END: + index = ssif_bmc->request.len - ssif_bmc->recv_len; + if ((ssif_bmc->msg_idx - 1 + index) == ssif_msg_len(&ssif_bmc->request)) { + /* PEC is not included */ + ssif_bmc->pec_support = false; + return true; + } + + if ((ssif_bmc->msg_idx - 1 + index) != (ssif_msg_len(&ssif_bmc->request) + 1)) + goto error; + + /* PEC is included */ + ssif_bmc->pec_support = true; + rpec = buf[ssif_bmc->msg_idx - 2 + index]; + addr = GET_8BIT_ADDR(ssif_bmc->client->addr); + cpec = i2c_smbus_pec(cpec, &addr, 1); + cpec = i2c_smbus_pec(cpec, &ssif_bmc->smbus_cmd, 1); + cpec = i2c_smbus_pec(cpec, &ssif_bmc->recv_len, 1); + /* As SMBus specification does not allow the length + * (byte count) in the Write-Block protocol to be zero. + * Therefore, it is illegal to have the last Middle + * transaction in the sequence carry 32-bytes and have + * a length of ‘0’ in the End transaction. + * But some users may try to use this way and we should + * prevent ssif_bmc driver broken in this case. + */ + if (ssif_bmc->recv_len != 0) + cpec = i2c_smbus_pec(cpec, buf + 1 + index, ssif_bmc->recv_len); + + if (rpec != cpec) { + pr_err("Bad PEC 0x%02x vs. 0x%02x\n", rpec, cpec); + ret = false; + } + + break; + default: + break; + } + + return ret; +error: + /* Do not expect to go to this case */ + pr_err("Error: Unexpected length received %d\n", ssif_msg_len(&ssif_bmc->request)); + + return false; +} + +static void complete_write_received(struct ssif_bmc_ctx *ssif_bmc) +{ + u8 cmd = ssif_bmc->smbus_cmd; + + /* A BMC that receives an invalid PEC shall drop the data for the write + * transaction and any further transactions (read or write) until + * the next valid read or write Start transaction is received + */ + if (!validate_pec(ssif_bmc)) { + pr_err("Received invalid PEC\n"); + return; + } + + if (cmd == SSIF_IPMI_SINGLEPART_WRITE || cmd == SSIF_IPMI_MULTIPART_WRITE_END) + handle_request(ssif_bmc); +} + +/* + * Callback function to handle I2C slave events + */ +static int ssif_bmc_cb(struct i2c_client *client, enum i2c_slave_event event, u8 *val) +{ + struct ssif_bmc_ctx *ssif_bmc = i2c_get_clientdata(client); + + spin_lock(&ssif_bmc->lock); + + /* I2C Event Handler: + * I2C_SLAVE_READ_REQUESTED 0x0 + * I2C_SLAVE_WRITE_REQUESTED 0x1 + * I2C_SLAVE_READ_PROCESSED 0x2 + * I2C_SLAVE_WRITE_RECEIVED 0x3 + * I2C_SLAVE_STOP 0x4 + */ + switch (event) { + case I2C_SLAVE_READ_REQUESTED: + ssif_bmc->msg_idx = 0; + if (ssif_bmc->is_singlepart_read) + set_singlepart_response_buffer(ssif_bmc, val); + else + set_multipart_response_buffer(ssif_bmc, val); + break; + + case I2C_SLAVE_WRITE_REQUESTED: + ssif_bmc->msg_idx = 0; + break; + + case I2C_SLAVE_READ_PROCESSED: + handle_read_processed(ssif_bmc, val); + break; + + case I2C_SLAVE_WRITE_RECEIVED: + /* + * First byte is SMBUS command, not a part of SSIF message. + * SSIF request buffer starts with msg_idx 1 for the first + * buffer byte. + */ + if (ssif_bmc->msg_idx == 0) { + /* SMBUS command can vary (single or multi-part) */ + ssif_bmc->smbus_cmd = *val; + ssif_bmc->msg_idx++; + } else { + handle_write_received(ssif_bmc, val); + } + + break; + + case I2C_SLAVE_STOP: + /* + * PEC byte is appended at the end of each transaction. + * Detect PEC is support or not after receiving write request + * completely. + */ + if (ssif_bmc->last_event == I2C_SLAVE_WRITE_RECEIVED) + complete_write_received(ssif_bmc); + /* Reset message index */ + ssif_bmc->msg_idx = 0; + break; + + default: + break; + } + ssif_bmc->last_event = event; + spin_unlock(&ssif_bmc->lock); + + return 0; +} + +struct ssif_bmc_ctx *ssif_bmc_alloc(struct i2c_client *client, int sizeof_priv) +{ + struct ssif_bmc_ctx *ssif_bmc; + int ret; + + ssif_bmc = devm_kzalloc(&client->dev, sizeof(*ssif_bmc) + sizeof_priv, GFP_KERNEL); + if (!ssif_bmc) + return ERR_PTR(-ENOMEM); + + spin_lock_init(&ssif_bmc->lock); + + init_waitqueue_head(&ssif_bmc->wait_queue); + ssif_bmc->request_available = false; + ssif_bmc->response_in_progress = false; + + mutex_init(&ssif_bmc->file_mutex); + + /* Register misc device interface */ + ssif_bmc->miscdev.minor = MISC_DYNAMIC_MINOR; + ssif_bmc->miscdev.name = DEVICE_NAME; + ssif_bmc->miscdev.fops = &ssif_bmc_fops; + ssif_bmc->miscdev.parent = &client->dev; + ret = misc_register(&ssif_bmc->miscdev); + if (ret) + goto out; + + ssif_bmc->client = client; + ssif_bmc->client->flags |= I2C_CLIENT_SLAVE; + + /* Register I2C slave */ + i2c_set_clientdata(client, ssif_bmc); + ret = i2c_slave_register(client, ssif_bmc_cb); + if (ret) { + misc_deregister(&ssif_bmc->miscdev); + goto out; + } + + return ssif_bmc; + +out: + devm_kfree(&client->dev, ssif_bmc); + return ERR_PTR(ret); +} +EXPORT_SYMBOL(ssif_bmc_alloc); + +MODULE_AUTHOR("Chuong Tran "); +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("Linux device driver of the BMC IPMI SSIF interface."); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/char/ipmi/ssif_bmc.h b/drivers/char/ipmi/ssif_bmc.h new file mode 100644 index 000000000000..a2ee090572db --- /dev/null +++ b/drivers/char/ipmi/ssif_bmc.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * The driver for BMC side of SSIF interface + * + * Copyright (c) 2021, Ampere Computing LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef __SSIF_BMC_H__ +#define __SSIF_BMC_H__ + +#define DEVICE_NAME "ipmi-ssif-host" + +#define GET_8BIT_ADDR(addr_7bit) (((addr_7bit) << 1) & 0xff) + +#define MSG_PAYLOAD_LEN_MAX 252 + +/* A standard SMBus Transaction is limited to 32 data bytes */ +#define MAX_PAYLOAD_PER_TRANSACTION 32 + +#define MAX_IPMI_DATA_PER_START_TRANSACTION 30 +#define MAX_IPMI_DATA_PER_MIDDLE_TRANSACTION 31 + +#define SSIF_IPMI_SINGLEPART_WRITE 0x2 +#define SSIF_IPMI_SINGLEPART_READ 0x3 +#define SSIF_IPMI_MULTIPART_WRITE_START 0x6 +#define SSIF_IPMI_MULTIPART_WRITE_MIDDLE 0x7 +#define SSIF_IPMI_MULTIPART_WRITE_END 0x8 +#define SSIF_IPMI_MULTIPART_READ_START 0x3 +#define SSIF_IPMI_MULTIPART_READ_MIDDLE 0x9 + +struct ssif_msg { + u8 len; + u8 netfn_lun; + u8 cmd; + u8 payload[MSG_PAYLOAD_LEN_MAX]; +} __packed; + +static inline u32 ssif_msg_len(struct ssif_msg *ssif_msg) +{ + return ssif_msg->len + 1; +} + +#define SSIF_BMC_BUSY 0x01 +#define SSIF_BMC_READY 0x02 + +struct ssif_bmc_ctx { + struct i2c_client *client; + struct miscdevice miscdev; + u8 smbus_cmd; + struct ssif_msg request; + bool request_available; + struct ssif_msg response; + bool response_in_progress; + /* Response buffer for Multi-part Read Transaction */ + u8 response_buf[MAX_PAYLOAD_PER_TRANSACTION]; + /* Flag to identify a Multi-part Read Transaction */ + bool is_singlepart_read; + u8 nbytes_processed; + u8 remain_len; + u8 recv_len; + /* Block Number of a Multi-part Read Transaction */ + u8 block_num; + size_t msg_idx; + enum i2c_slave_event last_event; + bool pec_support; + spinlock_t lock; + wait_queue_head_t wait_queue; + struct mutex file_mutex; + void (*set_ssif_bmc_status)(struct ssif_bmc_ctx *ssif_bmc, unsigned int flags); + void *priv; +}; + +static inline struct ssif_bmc_ctx *to_ssif_bmc(struct file *file) +{ + return container_of(file->private_data, struct ssif_bmc_ctx, miscdev); +} + +struct ssif_bmc_ctx *ssif_bmc_alloc(struct i2c_client *client, int sizeof_priv); + +#endif /* __SSIF_BMC_H__ */ diff --git a/drivers/char/ipmi/ssif_bmc_aspeed.c b/drivers/char/ipmi/ssif_bmc_aspeed.c new file mode 100644 index 000000000000..02abfca90986 --- /dev/null +++ b/drivers/char/ipmi/ssif_bmc_aspeed.c @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * The driver for BMC side of Aspeed SSIF interface + * + * Copyright (c) 2021, Ampere Computing LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include "ssif_bmc.h" + +struct aspeed_i2c_bus { + struct i2c_adapter adap; + struct device *dev; + void __iomem *base; + struct reset_control *rst; + /* Synchronizes I/O mem access to base. */ + spinlock_t lock; +}; + +#define ASPEED_I2C_INTR_CTRL_REG 0x0c +#define ASPEED_I2CD_INTR_SLAVE_MATCH BIT(7) +#define ASPEED_I2CD_INTR_RX_DONE BIT(2) +void aspeed_i2c_enable_interrupt(struct aspeed_i2c_bus *bus, unsigned long mask) +{ + unsigned long current_mask; + + current_mask = readl(bus->base + ASPEED_I2C_INTR_CTRL_REG); + writel(current_mask | mask, bus->base + ASPEED_I2C_INTR_CTRL_REG); +} + +void aspeed_i2c_disable_interrupt(struct aspeed_i2c_bus *bus, unsigned long mask) +{ + unsigned long current_mask; + + current_mask = readl(bus->base + ASPEED_I2C_INTR_CTRL_REG); + writel(current_mask & ~mask, bus->base + ASPEED_I2C_INTR_CTRL_REG); +} + +void aspeed_set_ssif_bmc_status(struct ssif_bmc_ctx *ssif_bmc, unsigned int status) +{ + struct aspeed_i2c_bus *bus; + unsigned long flags; + + bus = (struct aspeed_i2c_bus *)ssif_bmc->priv; + if (!bus) + return; + + spin_lock_irqsave(&bus->lock, flags); + + if (status & SSIF_BMC_BUSY) { + /* Ignore RX_DONE and SLAVE_MATCH when slave busy processing */ + aspeed_i2c_disable_interrupt(bus, ASPEED_I2CD_INTR_RX_DONE); + aspeed_i2c_disable_interrupt(bus, ASPEED_I2CD_INTR_SLAVE_MATCH); + } else if (status & SSIF_BMC_READY) { + /* Enable RX_DONE and SLAVE_MATCH when slave ready */ + aspeed_i2c_enable_interrupt(bus, ASPEED_I2CD_INTR_RX_DONE); + aspeed_i2c_enable_interrupt(bus, ASPEED_I2CD_INTR_SLAVE_MATCH); + } + + spin_unlock_irqrestore(&bus->lock, flags); +} + +static int ssif_bmc_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct ssif_bmc_ctx *ssif_bmc; + + ssif_bmc = ssif_bmc_alloc(client, sizeof(struct aspeed_i2c_bus)); + if (IS_ERR(ssif_bmc)) + return PTR_ERR(ssif_bmc); + + ssif_bmc->priv = i2c_get_adapdata(client->adapter); + ssif_bmc->set_ssif_bmc_status = aspeed_set_ssif_bmc_status; + + return 0; +} + +static int ssif_bmc_remove(struct i2c_client *client) +{ + struct ssif_bmc_ctx *ssif_bmc = i2c_get_clientdata(client); + + i2c_slave_unregister(client); + misc_deregister(&ssif_bmc->miscdev); + + return 0; +} + +static const struct of_device_id ssif_bmc_match[] = { + { .compatible = "aspeed,ast2500-ssif-bmc" }, + { }, +}; + +static const struct i2c_device_id ssif_bmc_id[] = { + { DEVICE_NAME, 0 }, + { }, +}; + +MODULE_DEVICE_TABLE(i2c, ssif_bmc_id); + +static struct i2c_driver ssif_bmc_driver = { + .driver = { + .name = DEVICE_NAME, + .of_match_table = ssif_bmc_match, + }, + .probe = ssif_bmc_probe, + .remove = ssif_bmc_remove, + .id_table = ssif_bmc_id, +}; + +module_i2c_driver(ssif_bmc_driver); + +MODULE_AUTHOR("Chuong Tran "); +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("Linux device driver of Aspeed BMC IPMI SSIF interface."); +MODULE_LICENSE("GPL v2"); From patchwork Mon Mar 29 12:09:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12170893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9259C433C1 for ; Mon, 29 Mar 2021 19:36:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2E816196E for ; Mon, 29 Mar 2021 19:36:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2E816196E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=W0U1xQ1WvBrpT2h4QgUyvi3iPWT0p8PMvFaG1P5I8+g=; b=WFA3UWdsNk1D3fatD/l9Qs2Lz XG2ZMBvsQXS8xYnd3sC49csd8plZarWL1x8rF9Ay5ZLaEPddQGWLqwaUDylI3PaKggzlCQ1aFRB9O jlPKVFVALDn1n8dkvdqfdXYKVMlQ5kkSxh4MNwZ1CK4uvVFDOYWBd6dZZZzjX1IiFaz39WaD+qaX2 DqAkliewVhnMLwSyLcT20MkU/vGGObn6/xFIt0gyAxpxDqUD86ICpob/UAh+u6z9sYxsdOubKMWn2 EDb2P4OG9kVBDyylPsR0vJqYdzGsSlb31W/qhqJmvv3xQPC1MIMuv19OTiSm9lxmZspwhhH7bHjK5 yr8YlCc8A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lQxal-001G4j-Ga; Mon, 29 Mar 2021 19:30:28 +0000 Received: from mail-bn8nam11on2115.outbound.protection.outlook.com ([40.107.236.115] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lQqiO-000dP3-6I for linux-arm-kernel@lists.infradead.org; Mon, 29 Mar 2021 12:09:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NRCkJta+hhH7Olc/YGEt5ixWCDZh2eJS+cM0FsZb57F//W68N1k2hjyGCq6tiCuONFbF9BbFA7FGx6h/zpKwHXSEFe1W7qFu0LRUz5wc+N7fSdD7IAwB/5w5MG2MJXy1BxqYgKb7OktlmKOr4rV+7qR0lc0wKRbO7rIru0Ua3H4D0x2BJaU11QMAGTTY3fbEEotyH9ldnEWzU959DCN72XBIhcV0I9PGC4uV9aOAx/C8gmpRdQJbLFpKiqZc0I+SqQwhVVw+2EvCSqPSFsJfjPDLjFv26UKzy4m0x/CGb9ics0RtLaL7tKOgSJUs86VEHP97BsG5pTrTXp/xnoRJSA== 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-SenderADCheck; bh=gDKOwdplJFsue3nynYNcN8vpg88fsI9i8TnpdlofzgA=; b=gtjwKCMrZMkZBrGlu2YNiA/HFn+eKkp8o3ZSxcdAkxnghP3jp+BjdTFDnbBUwgz4oaU/JOpxj97wNLtC2i4TM/+g3+fLB63PBFtiutJqWRyznS0swzSgJbOUvpMVcYylXAUTr8GY20eJDuVMGcuMvajEAZmjN9tWtOn+YRBjBlnEd+48dzL/zmk1rmfNUdQh0fK2XFmf0j+OQTE5v75zDG9W6J6LZvTM8oZ37tV0Fq/ObYq0hvukbt67adpEKmRdGsZUcTJSiRJOw8AG0O/L9r8cNbxsemhVqi8t1avcOGQqBMsBXl4ul75OrEmMcbK0uKjMO4cAlUeMJfPg++9ojw== 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=gDKOwdplJFsue3nynYNcN8vpg88fsI9i8TnpdlofzgA=; b=JnNAnRTSRlMX8Yo8ls403qKK7hlNvtgCxlG/yDsDRAsIXYIr91BYb4rYjdS9m7CC9tgqLIIAyHFLG6K9rp5G6pLf0rLSzsN6Mq2y6tRx2ly5rnQCehlpQkyKoMlt3YP0oTjLK9vUNWTAkXh6r5VZ/BwzKcv0H5FwfOueRtThCqA= Authentication-Results: acm.org; dkim=none (message not signed) header.d=none;acm.org; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) by MWHPR01MB2384.prod.exchangelabs.com (2603:10b6:300:3d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.33; Mon, 29 Mar 2021 12:09:47 +0000 Received: from MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503]) by MW2PR0102MB3482.prod.exchangelabs.com ([fe80::d840:7aa7:58d4:b503%5]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 12:09:47 +0000 From: Quan Nguyen To: Corey Minyard , Rob Herring , Joel Stanley , Andrew Jeffery , Wolfram Sang , Philipp Zabel , 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 Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v1 3/3] bindings: ipmi: Add binding for Aspeed SSIF BMC driver Date: Mon, 29 Mar 2021 19:09:14 +0700 Message-Id: <20210329120914.4527-4-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210329120914.4527-1-quan@os.amperecomputing.com> References: <20210329120914.4527-1-quan@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) To MW2PR0102MB3482.prod.exchangelabs.com (2603:10b6:302:c::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hcm-sw-17.amperecomputing.com (118.69.219.201) by HKAPR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:d0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Mon, 29 Mar 2021 12:09:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b8ab646-294f-4122-aa89-08d8f2ab8b7c X-MS-TrafficTypeDiagnostic: MWHPR01MB2384: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 40QN6w3mMJ+IG4jQzyvSsbc+oy3Qqgbg1YB2sJCEUp099i5X5l8Seqk2nbXAI5+zNbrpLroddLHtM+evhcB7msrAwOYJ2zwTen9HZqsGlZRq9VY+lYNH6IJ87TAtyGBX8fHSbSR/Qwv0jrARS/oVqmk8ESM3sCtYG0KOMpN+UhWqdqGp3wMt0/76PGTaAzE9ESmXTS5WA6J9I8OG10OQRVDDJ78suhRcCnluWInz2PS8s6FHugOnN3hSq1vPgmslEMEC9IQVb8KwOOb3gjgIxjcSiGz0oviVzyvc6Z50zHgYjpQa7smpMyRRieTdLMe3ThkM0/Ia+W/0PjHXS/WM9jyEAGSzdnnXVCK9cS8+YV/ms/xpgbgnC5OIfosZ9B8JwOmDu8PrIh+FR+rtEUTY38bQ5HqpU6myMxCIWGWptKwdPjrHFsOvOBdL+EvWGY4IEEmPZzBG7FiAsU/oI5yBKVL/FVBzPaC1ELdQ77bfd6G2QanHtlIot/cYbE1mKz0yVMLgR/O87PNs6jvS3S6IBAAI6B0I3FjwU/CNf3JoR4JdZHDTAARRxr5YbiWGzzNxnVMO2EPeFKjGpNMcrL7STQ0t9c4atB/15vdI9IY3NvPRmZ5sUnc1emnmz4EMXKFUtwu8GCcc2c4JVBA8eMb7AGY5CL/KyM9TWPHV4cU62wQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR0102MB3482.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(39840400004)(396003)(376002)(366004)(52116002)(16526019)(478600001)(26005)(186003)(6486002)(5660300002)(6506007)(110136005)(66556008)(2616005)(54906003)(316002)(1076003)(86362001)(7416002)(38100700001)(956004)(2906002)(6512007)(921005)(4326008)(66946007)(66476007)(8676002)(8936002)(6666004)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: SC82B9xkqUbwLNiz1uklPRkMzDcQDJAdwMNwh1jj3nzne5KoRPwGQ2BnaNLVtQNgX5Sy8/jKNfDcqsEkrFpxQqjEzka0F8DNJP4FC/OrViauGYSSH2lXOgYmRfyGDnLK6/4MBqSOhvsQrTl96axg2i2NBDPk8wW1PLafC+iyLxofw5B3Ss0XCNOqrnxuMgP9Aj4llqGf5HM0HkWbqteFJol2sAlJoP613ORb1CfOgSnFq9qT9baiQgWQ/NVKEaRbP9rQYiRd0JLWjMi8BQKjnr4c5df+poyCl+roI45tetbeHlTwdULKZddXo5yBJlardM3JkvdCTYTZpe/kdheU3wiiSlvpJD43oSYmB3AAjHkW9X57p/ky/omxuuGf5UgGxgrROa+0pfoN0uokqzngZ0u9gpoo5/R7HzepRWDITzeuv7Tzfszn3m4Rpf1DXLdpjkSg721QCnyUNO0FnQ7m+9NE9GGjIOrlF+/5sdO9bTGL9lOSAmSLXsE5KwvyOFdSbelf2X0dA8MFV6YRzk9tQhWrrRmEUrjpQNkaKHNGugSfEIXENvfdg6mtKSRTo0/N12hMWmFMuoKa00ChKO9ytQibc0VKENwGXLOa1GcNzOs4P1YvGYqAygUcYU733QmNtkzQq3P5IdORSefYUZybpnqG8oGX2uWYjpDwip7oU/6Qw+fPP8wI5b5ybAC6IbcILczKP8URfP+E5okytoSgayFAjVg3cuzlM33Dpr1rRUi4O0GbKgSG6JdyBDP8lB4NTBitek4O69NTCGk+jYIEAXII+glisJ1rGHkfkfYLip0ko8Rst6GQfcx9gHOt4uQtQ2TehJBrjlS73ayUMR8KX5vuI2eO5y8lF3G7iZPYSOt9FsHk8TcuOdmIyjH9CT3Q7m+2rfu1wJUkpV7+o3Eq86bfktWORyjfg2q+sNuytm0G3qIxkFc/9JUqH6FvtstYIn8FOaI7N8v/B1aE8DeRGVxBYqwtUoGxUtfvm9ySltaA3sCoSSEO0bRJe6pHRakEF90rDkhDYe53v+6hiR6X9Bl9AQ1AQ9Z5X8nlHsx5EFNWpKvqnA2qWlM3Cj9hLlyZOf+SFLDgFxrO91ZxnDbSQtaTI+y8jdztpHDwePp2NyYhzIQKIXilLrT8gK9tUdiC0LqK10mNJwW4bNwmwEMImma9pHZSfC+V2WVYXUfiCAOjZEtG7fKerXXwtrUjYASaki+fngkrucWjqQPeyoeDFSJeqYVYtbh2B+8Nmpkvl3iIWEc02WeUTKaB3R62jFBrTuyFwHzAhzxan4ePPS19CKv0ElkKsGhOvBmWPGx6ML/L7y/6r3qLwUjBU1IMiqPj X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b8ab646-294f-4122-aa89-08d8f2ab8b7c X-MS-Exchange-CrossTenant-AuthSource: MW2PR0102MB3482.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2021 12:09:47.1095 (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: jq0Sgy47aBRSpYQHXifGrIQ48D/Oe6jRQ1mk+PjEO9l6Sxm2cr9e5h/EqGU4cQrqJ3aVArJUBekahbXg3uC+T//fyQ4+D3ign7BuuX4e4rY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR01MB2384 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210329_130952_297913_30102344 X-CRM114-Status: GOOD ( 10.78 ) 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 Add device tree binding document for the Aspeed SSIF BMC driver. Signed-off-by: Quan Nguyen --- .../bindings/ipmi/aspeed-ssif-bmc.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/ipmi/aspeed-ssif-bmc.txt diff --git a/Documentation/devicetree/bindings/ipmi/aspeed-ssif-bmc.txt b/Documentation/devicetree/bindings/ipmi/aspeed-ssif-bmc.txt new file mode 100644 index 000000000000..1616f0188db9 --- /dev/null +++ b/Documentation/devicetree/bindings/ipmi/aspeed-ssif-bmc.txt @@ -0,0 +1,18 @@ +# Aspeed SSIF (SMBus system interface) IPMI BMC interface + +The Aspeed AST2500 are commonly used as BMCs (Baseboard Management Controllers) +and the SSIF slave interface can be used to perform in-band IPMI communication +with their host. + +Required properties: + +- compatible : should be + "aspeed,ast2500-ssif-bmc" +- reg: I2C address the registers + +Example: + + ssif-bmc@10 { + compatible = "aspeed,ast2500-ssif-bmc"; + reg = <0x10>; + };