From patchwork Thu Sep 22 11:39:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binbin Zhou X-Patchwork-Id: 609281 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 C721DC6FA92 for ; Thu, 22 Sep 2022 11:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231411AbiIVLlg (ORCPT ); Thu, 22 Sep 2022 07:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiIVLlc (ORCPT ); Thu, 22 Sep 2022 07:41:32 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEE56D690E; Thu, 22 Sep 2022 04:41:29 -0700 (PDT) Received: from localhost.localdomain (unknown [112.20.112.163]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxFeLhSSxjyhYgAA--.56317S3; Thu, 22 Sep 2022 19:41:22 +0800 (CST) From: Binbin Zhou To: Wolfram Sang , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org Cc: loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, WANG Xuerui , Jianmin Lv , Binbin Zhou , Huacai Chen Subject: [PATCH 1/5] i2c: core: Pick i2c bus number from ACPI if present Date: Thu, 22 Sep 2022 19:39:54 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxFeLhSSxjyhYgAA--.56317S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw45GrWfGr1rZw1rZr4ktFb_yoW8Gr48pF ZIkFsIkr4YvF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ex0o6or00hjvr0hdfq/ Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Under LoongARCH based on ACPI(such as Loongson-3A + LS7A), the ls2x i2c driver obtains the i2c bus number from ACPI table. Similar to the DT-base system, this is also a static bus number. Signed-off-by: Huacai Chen Signed-off-by: Binbin Zhou --- drivers/i2c/i2c-core-base.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 91007558bcb2..ffab4cc2c6ba 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1559,7 +1559,8 @@ static int __i2c_add_numbered_adapter(struct i2c_adapter *adap) int i2c_add_adapter(struct i2c_adapter *adapter) { struct device *dev = &adapter->dev; - int id; + acpi_status status; + unsigned long long id; if (dev->of_node) { id = of_alias_get_id(dev->of_node, "i2c"); @@ -1567,6 +1568,13 @@ int i2c_add_adapter(struct i2c_adapter *adapter) adapter->nr = id; return __i2c_add_numbered_adapter(adapter); } + } else if (dev->parent->fwnode) { + status = acpi_evaluate_integer(ACPI_HANDLE(dev->parent), + "_UID", NULL, &id); + if (ACPI_SUCCESS(status) && (id >= 0)) { + adapter->nr = id; + return __i2c_add_numbered_adapter(adapter); + } } mutex_lock(&core_lock);