From patchwork Tue Jan 18 14:52:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716534 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 9B80FC433F5 for ; Tue, 18 Jan 2022 14:55:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C13A6180F; Tue, 18 Jan 2022 15:54:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C13A6180F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517699; bh=80zbMjjnXAvz3FyrKf0cnQriHuUWwJ+3hqtIucoR7lE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=p0Yc1NSj/u1Nptaa/bYyVCFNNPk8/lb+6PwWFmVpEkNOh+1Gsgd+Ma2pB/7JyH9Zm TsKhdW9z2tD3qaZem+TQ/zroAHlJBNOuj4qfyCyxKJihK0+cDgpSlj0HlRBJK5mIvh hH3VVueaIO+3y9wYsrmM1/8JQr+EIPUjMlRzrO00= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0FF73F804A9; Tue, 18 Jan 2022 15:53:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04029F80507; Tue, 18 Jan 2022 15:53:40 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E6B5BF8023B for ; Tue, 18 Jan 2022 15:53:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E6B5BF8023B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="iQaAmvzK" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20IA16xu003923; Tue, 18 Jan 2022 08:53:33 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=LqwQlGSPZbY4FUWN/PCbYAVSFcGSRCshh6dVtPJgmMk=; b=iQaAmvzKfAgl75NgBpFsVWVWgaE2U8YrKGScu3h6dP8o0BPwFxOG1SemejwN+08Qxv6F KpzUDAenQPLDRVRaM90+iAcpn/MubiFvkJYwE76l5NMcMJlC6g4gl9g5Iq4D0S50/vz8 Mcz9FUOaOkNvVqiNAUkSxh/hNxNHGb7XiIlouuMrfcyVoCLahKczxOQIIF4Cv8xv9KJ0 wuHBkxOzGGPQgTNGtBuZ2fGyaPoVqi3BuwGsZx4dHsVDvQwOmEq7FoIOZTmF47yfJ5gc B1Gvn11d08xdooOHpjdwPby3eMTNGTiP7loR/y01N/FNjjaZFRWKZU7n09gRj2wiJ4pP bg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3dn8k2s8sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:33 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:31 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:31 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 967297C; Tue, 18 Jan 2022 14:53:27 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 01/10] spi: Make spi_alloc_device and spi_add_device public again Date: Tue, 18 Jan 2022 14:52:42 +0000 Message-ID: <20220118145251.1548-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: UPN5TjpL9fMhPkZPYfJJDsAVS_c8EwjC X-Proofpoint-ORIG-GUID: UPN5TjpL9fMhPkZPYfJJDsAVS_c8EwjC X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This functions were previously made private since they were not used. However, these functions will be needed again. Partial revert of commit da21fde0fdb3 ("spi: Make several public functions private to spi.c") Signed-off-by: Stefan Binding --- drivers/spi/spi.c | 6 ++++-- include/linux/spi/spi.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 4599b121d744..1eb84101c4ad 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -532,7 +532,7 @@ static DEFINE_MUTEX(board_lock); * * Return: a pointer to the new device, or NULL. */ -static struct spi_device *spi_alloc_device(struct spi_controller *ctlr) +struct spi_device *spi_alloc_device(struct spi_controller *ctlr) { struct spi_device *spi; @@ -557,6 +557,7 @@ static struct spi_device *spi_alloc_device(struct spi_controller *ctlr) device_initialize(&spi->dev); return spi; } +EXPORT_SYMBOL_GPL(spi_alloc_device); static void spi_dev_set_name(struct spi_device *spi) { @@ -652,7 +653,7 @@ static int __spi_add_device(struct spi_device *spi) * * Return: 0 on success; negative errno on failure */ -static int spi_add_device(struct spi_device *spi) +int spi_add_device(struct spi_device *spi) { struct spi_controller *ctlr = spi->controller; struct device *dev = ctlr->dev.parent; @@ -673,6 +674,7 @@ static int spi_add_device(struct spi_device *spi) mutex_unlock(&ctlr->add_lock); return status; } +EXPORT_SYMBOL_GPL(spi_add_device); static int spi_add_device_locked(struct spi_device *spi) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 7ab3fed7b804..0346a3ff27fd 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1452,7 +1452,19 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n) * use spi_new_device() to describe each device. You can also call * spi_unregister_device() to start making that device vanish, but * normally that would be handled by spi_unregister_controller(). + * + * You can also use spi_alloc_device() and spi_add_device() to use a two + * stage registration sequence for each spi_device. This gives the caller + * some more control over the spi_device structure before it is registered, + * but requires that caller to initialize fields that would otherwise + * be defined using the board info. */ +extern struct spi_device * +spi_alloc_device(struct spi_controller *ctlr); + +extern int +spi_add_device(struct spi_device *spi); + extern struct spi_device * spi_new_device(struct spi_controller *, struct spi_board_info *); From patchwork Tue Jan 18 14:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716535 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 A98CFC433F5 for ; Tue, 18 Jan 2022 14:55:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BC154184E; Tue, 18 Jan 2022 15:54:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC154184E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517716; bh=q5vjI8aPGLCOTcBAFpnMkKx7cJXdE+9pe0Z2g9hlgsg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pYfC+zL052Q/xt4kD/cPAtFzEgdFdkDPy+RioJS7lAq+rGUBz8xxIaXsKFjBYnCwk Viz8sihMP3SkudiQyrYoC7vq2RveE0qZ+0YjZzi86ngx4ARqb0CBAAPVav7IHUIKEA qKASX465wR09uXNgdhrXoJEqO9kevOqUY6Eih1y8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DA9FFF80100; Tue, 18 Jan 2022 15:53:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B29CF80517; Tue, 18 Jan 2022 15:53:45 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 03A22F80100 for ; Tue, 18 Jan 2022 15:53:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 03A22F80100 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="IzP1oJPW" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I1MV5q021792; Tue, 18 Jan 2022 08:53:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=bpNY1rgvcIc2XyOVlH7EyAFUPxkKV43qVorDVN33PHg=; b=IzP1oJPW01aHahnCFagtaAyvkQVMMZHfO1KZMqQktlgY5i2kxVp1qSH3yveAa0qF3rH9 MKT3yTqHNEBpitTKVAtNbP7bQheKn+ILPsU2t6EjTIK62mgRG5AQ6Bv7qRMxfcl9nC70 ML+fSn3fwIXAYMoYVcQdn0Jq/q+2AS1RlOMkFMsjy+bXwfhcL+A5phtx3jC2vfZMW5eh 0h/zzxDNXcXlrSJNh1x0xYSCPF14zayNPQY7Nu7o09MPRUcjnkcmcswkRZrmplv4+PAr iMJpnI/zO8lOCNP/Mi5D2/OdMWOEB5WSfb2y5eU36T9XP7TOp68yP+IabE9RLMBb+KM/ gw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9na-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:35 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:33 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:33 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id D8394B13; Tue, 18 Jan 2022 14:53:31 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 02/10] spi: Create helper API to lookup ACPI info for spi device Date: Tue, 18 Jan 2022 14:52:43 +0000 Message-ID: <20220118145251.1548-3-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: SDa8XjxyX_GS-t3AubMg9_R-OjMcQgAE X-Proofpoint-ORIG-GUID: SDa8XjxyX_GS-t3AubMg9_R-OjMcQgAE X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This can then be used to find a spi resource inside an ACPI node, and allocate a spi device. Signed-off-by: Stefan Binding --- drivers/spi/spi.c | 46 ++++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 12 +++++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1eb84101c4ad..13f4701f0694 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2410,8 +2410,18 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) return 1; } -static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, - struct acpi_device *adev) +/** + * acpi_spi_device_alloc - Allocate a spi device, and fill it in with ACPI information + * @ctlr: controller to which the spi device belongs + * @adev: ACPI Device for the spi device + * + * This should be used to allocate a new spi device from and ACPI Node. + * The caller is responsible for calling spi_add_device to register the spi device. + * + * Return: a pointer to the new device, or ERR_PTR on error. + */ +struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, + struct acpi_device *adev) { acpi_handle parent_handle = NULL; struct list_head resource_list; @@ -2419,10 +2429,6 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, struct spi_device *spi; int ret; - if (acpi_bus_get_status(adev) || !adev->status.present || - acpi_device_enumerated(adev)) - return AE_OK; - lookup.ctlr = ctlr; lookup.irq = -1; @@ -2433,7 +2439,7 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, if (ret < 0) /* found SPI in _CRS but it points to another controller */ - return AE_OK; + return ERR_PTR(-ENODEV); if (!lookup.max_speed_hz && ACPI_SUCCESS(acpi_get_parent(adev->handle, &parent_handle)) && @@ -2443,16 +2449,15 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, } if (!lookup.max_speed_hz) - return AE_OK; + return ERR_PTR(-ENODEV); spi = spi_alloc_device(ctlr); if (!spi) { dev_err(&ctlr->dev, "failed to allocate SPI device for %s\n", dev_name(&adev->dev)); - return AE_NO_MEMORY; + return ERR_PTR(-ENOMEM); } - ACPI_COMPANION_SET(&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode; @@ -2460,6 +2465,27 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, spi->bits_per_word = lookup.bits_per_word; spi->chip_select = lookup.chip_select; + return spi; +} +EXPORT_SYMBOL_GPL(acpi_spi_device_alloc); + +static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, + struct acpi_device *adev) +{ + struct spi_device *spi; + + if (acpi_bus_get_status(adev) || !adev->status.present || + acpi_device_enumerated(adev)) + return AE_OK; + + spi = acpi_spi_device_alloc(ctlr, adev); + if (IS_ERR(spi)) { + if (PTR_ERR(spi) == -ENOMEM) + return AE_NO_MEMORY; + else + return AE_OK; + } + acpi_set_modalias(adev, acpi_device_hid(adev), spi->modalias, sizeof(spi->modalias)); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 0346a3ff27fd..200725692b93 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -16,6 +16,7 @@ #include #include +#include struct dma_chan; struct software_node; @@ -759,6 +760,17 @@ extern int devm_spi_register_controller(struct device *dev, struct spi_controller *ctlr); extern void spi_unregister_controller(struct spi_controller *ctlr); +#if IS_ENABLED(CONFIG_ACPI) +extern struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, + struct acpi_device *adev); +#else +static inline struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, + struct acpi_device *adev); +{ + return ERR_PTR(-EOPNOTSUPP); +} +#endif + /* * SPI resource management while processing a SPI message */ From patchwork Tue Jan 18 14:52:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716538 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E117BC433EF for ; Tue, 18 Jan 2022 14:56:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EF3941813; Tue, 18 Jan 2022 15:55:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF3941813 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517765; bh=00q2HMPDb5q9DlQps6CALb/V00i3AoRLrBwce+tZ8OE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Pq8uWZz3T3prRkJlRjtLClFl9JedxpGmw85hX/CJyLHYzmogZO6onIgSTxuceTgUc wP1K2eXt4MF7YQ4EjqcHkLVoT46zVulAitX9td4vtDT8IGUvGPNG4gLnxEbwYiU6Ug FboXGwjXnqXWVjZn8yzQsKMtfRCMzId1lbycFadk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 15AD6F80528; Tue, 18 Jan 2022 15:53:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E5495F8051F; Tue, 18 Jan 2022 15:53:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 445B4F80515 for ; Tue, 18 Jan 2022 15:53:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 445B4F80515 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="qDkFadmL" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I1MV5r021792; Tue, 18 Jan 2022 08:53:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=0TVxBDOiUr12OuPIFyA5/1w1LgYsgtcjV4mdb8rtSok=; b=qDkFadmL0/AgDz3iGm2PqcfT5jD93kZENaZ1VVlhLsHu0YaP2weGHS3ZAvfR2ZjK91/t 3i8U8OxjkWprjVkbrpwcMwmljHNKlT7kH0WMC2mi4nzgxJArpJxaxFJnl7lyG3BJNhCU b/qt5F/YgCVh6Xt02jVguJ3i6wCUKnEfMkf3npLrCYdIGFbQtwvqagRasm9zgmOrLx4E TythIy33G/ka07Dnks9uiDmsZG2tnhGPt49cerOHGaYm4SvjHtRZ1YV6Bi/dF3rT7MxV f+dYcWpqOnV0Iwm29gV0lKLKQ3l5DKvZP/8g5t6FyAf1MVPBSaY9N01Glz5FTFrB88vR WQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9na-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:36 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:35 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:35 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id F055A7C; Tue, 18 Jan 2022 14:53:33 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 03/10] spi: Support selection of the index of the ACPI Spi Resource before alloc Date: Tue, 18 Jan 2022 14:52:44 +0000 Message-ID: <20220118145251.1548-4-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: UVvcDV_Co8DZNT7JBlCqRXOznYoUWqtl X-Proofpoint-ORIG-GUID: UVvcDV_Co8DZNT7JBlCqRXOznYoUWqtl X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" If a node contains more than one Spi Resources, it may be necessary to use an index to select which one you want to allocate a spi device for. Signed-off-by: Stefan Binding --- drivers/spi/spi.c | 56 +++++++++++++++++++++++++++++++++++------ include/linux/spi/spi.h | 6 +++-- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 13f4701f0694..898cc9931490 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2320,6 +2320,9 @@ struct acpi_spi_lookup { int irq; u8 bits_per_word; u8 chip_select; + int n; + int index; + int irq_index; }; static void acpi_spi_parse_apple_properties(struct acpi_device *dev, @@ -2351,6 +2354,8 @@ static void acpi_spi_parse_apple_properties(struct acpi_device *dev, lookup->mode |= SPI_CPHA; } +static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev); + static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) { struct acpi_spi_lookup *lookup = data; @@ -2364,14 +2369,35 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) sb = &ares->data.spi_serial_bus; if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_SPI) { + if (lookup->index != -1 && lookup->n++ != lookup->index) + return 1; + + if (lookup->index == -1 && !ctlr) + return -ENODEV; + status = acpi_get_handle(NULL, sb->resource_source.string_ptr, &parent_handle); - if (ACPI_FAILURE(status) || - ACPI_HANDLE(ctlr->dev.parent) != parent_handle) + if (ACPI_FAILURE(status)) return -ENODEV; + if (ctlr) { + if (ACPI_HANDLE(ctlr->dev.parent) != parent_handle) + return -ENODEV; + } else { + struct acpi_device *adev; + + if (acpi_bus_get_device(parent_handle, &adev)) + return -ENODEV; + + ctlr = acpi_spi_find_controller_by_adev(adev); + if (!ctlr) + return -ENODEV; + + lookup->ctlr = ctlr; + } + /* * ACPI DeviceSelection numbering is handled by the * host controller driver in Windows and can vary @@ -2402,7 +2428,7 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) } else if (lookup->irq < 0) { struct resource r; - if (acpi_dev_resource_interrupt(ares, 0, &r)) + if (acpi_dev_resource_interrupt(ares, lookup->irq_index, &r)) lookup->irq = r.start; } @@ -2414,14 +2440,22 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data) * acpi_spi_device_alloc - Allocate a spi device, and fill it in with ACPI information * @ctlr: controller to which the spi device belongs * @adev: ACPI Device for the spi device + * @index: Index of the spi resource inside the ACPI Node + * @irq_index: Index of the GPIO resource for the IRQ inside the ACPI Node * * This should be used to allocate a new spi device from and ACPI Node. * The caller is responsible for calling spi_add_device to register the spi device. * + * If ctlr is set to NULL, the Controller for the spi device will be looked up + * using the resource. + * If index is set to -1, index is not used. + * Note: If index is -1, ctlr must be set. + * * Return: a pointer to the new device, or ERR_PTR on error. */ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, - struct acpi_device *adev) + struct acpi_device *adev, + int index, int irq_index) { acpi_handle parent_handle = NULL; struct list_head resource_list; @@ -2429,8 +2463,14 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, struct spi_device *spi; int ret; + if (!ctlr && index == -1) + return ERR_PTR(-EINVAL); + lookup.ctlr = ctlr; lookup.irq = -1; + lookup.index = index; + lookup.n = 0; + lookup.irq_index = irq_index; INIT_LIST_HEAD(&resource_list); ret = acpi_dev_get_resources(adev, &resource_list, @@ -2443,7 +2483,7 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, if (!lookup.max_speed_hz && ACPI_SUCCESS(acpi_get_parent(adev->handle, &parent_handle)) && - ACPI_HANDLE(ctlr->dev.parent) == parent_handle) { + ACPI_HANDLE(lookup.ctlr->dev.parent) == parent_handle) { /* Apple does not use _CRS but nested devices for SPI slaves */ acpi_spi_parse_apple_properties(adev, &lookup); } @@ -2451,9 +2491,9 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, if (!lookup.max_speed_hz) return ERR_PTR(-ENODEV); - spi = spi_alloc_device(ctlr); + spi = spi_alloc_device(lookup.ctlr); if (!spi) { - dev_err(&ctlr->dev, "failed to allocate SPI device for %s\n", + dev_err(&lookup.ctlr->dev, "failed to allocate SPI device for %s\n", dev_name(&adev->dev)); return ERR_PTR(-ENOMEM); } @@ -2478,7 +2518,7 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, acpi_device_enumerated(adev)) return AE_OK; - spi = acpi_spi_device_alloc(ctlr, adev); + spi = acpi_spi_device_alloc(ctlr, adev, -1, 0); if (IS_ERR(spi)) { if (PTR_ERR(spi) == -ENOMEM) return AE_NO_MEMORY; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 200725692b93..1a34fd0f6ca2 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -762,10 +762,12 @@ extern void spi_unregister_controller(struct spi_controller *ctlr); #if IS_ENABLED(CONFIG_ACPI) extern struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, - struct acpi_device *adev); + struct acpi_device *adev, + int index, int irq_index); #else static inline struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, - struct acpi_device *adev); + struct acpi_device *adev, + int index, int irq_index); { return ERR_PTR(-EOPNOTSUPP); } From patchwork Tue Jan 18 14:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716536 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 7B8A4C433EF for ; Tue, 18 Jan 2022 14:55:21 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4CDF4189E; Tue, 18 Jan 2022 15:54:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4CDF4189E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517719; bh=k+cLqB+K16HLJiN34z7fmOvnrGYLlx+3txWUub9sZy0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NM5Jw0JEJewnf/QxlC7wmo3a7m/VwHZEy9ImF7xcokDRn7x0pZxgtiy/z0Uf2eV0S fXvbKMO0AFxkzWFOMIGLPlm0XAvmMIMBmjZoB6yUA2amyxeis5Vuf7Xt4bDncfm8w+ eCOLyZ6rw3HrNog2nNpd/OelISSuyvdyMIsPL5a8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D2ED1F80515; Tue, 18 Jan 2022 15:53:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4D6A3F8051E; Tue, 18 Jan 2022 15:53:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 39F6CF80511 for ; Tue, 18 Jan 2022 15:53:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 39F6CF80511 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="PRFKAvcV" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I1MV5s021792; Tue, 18 Jan 2022 08:53:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=pcJyyOGpZnRiEY9dUyz6ABiZtDZzkse/rMAEdl2+rng=; b=PRFKAvcV2Vl2pABiy3lB16mkHTidFSZZJDlSFLeGXhnI2lCzKNa989YKxfNqeQ97sARW utQhkXzP07Jw/MGIwH2vFvHzSq7oirqA8rT5q0kvmlG4lXRDeEihT61YbJ+s9jrPUDSn JAbDYF4ELFnZbqC4t4oP8owp2tcRptjRB2oX+kceqxf6nxQHl1550kYtwQgBB1jixetu PILo1zLdDGV0rHojDP5lHzAomZ0K+Dg8mEfOzzDAeeNk5y+9WDgyf/hVlhXsWGop46Gt qP7/45xHknGB9f9WqU58lXv+zI4Tcsj1dHXzsCPXF9o2rYkoyg2gSE3UbSek8z3BCOLg EA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9nc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:39 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:37 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:37 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id CAAF5B13; Tue, 18 Jan 2022 14:53:35 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 04/10] spi: Add API to count spi acpi resources Date: Tue, 18 Jan 2022 14:52:45 +0000 Message-ID: <20220118145251.1548-5-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: GC3p0QYSidBdkh6pznA6re4R5HfRV112 X-Proofpoint-ORIG-GUID: GC3p0QYSidBdkh6pznA6re4R5HfRV112 X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Some ACPI nodes may have more than one Spi Resource. To be able to handle these case, its necessary to have a way of counting these resources. Signed-off-by: Stefan Binding --- drivers/spi/spi.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/spi/spi.h | 6 ++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 898cc9931490..8c0c2e26609a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2325,6 +2325,46 @@ struct acpi_spi_lookup { int irq_index; }; +static int acpi_spi_count(struct acpi_resource *ares, void *data) +{ + struct acpi_resource_spi_serialbus *sb; + int *count = data; + + if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) + return 1; + + sb = &ares->data.spi_serial_bus; + if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_SPI) + return 1; + + *count = *count + 1; + + return 1; +} + +/** + * acpi_spi_count_resources - Count the number of SpiSerialBus resources + * @adev: ACPI device + * + * Returns the number of SpiSerialBus resources in the ACPI-device's + * resource-list; or a negative error code. + */ +int acpi_spi_count_resources(struct acpi_device *adev) +{ + LIST_HEAD(r); + int count = 0; + int ret; + + ret = acpi_dev_get_resources(adev, &r, acpi_spi_count, &count); + if (ret < 0) + return ret; + + acpi_dev_free_resource_list(&r); + + return count; +} +EXPORT_SYMBOL_GPL(acpi_spi_count_resources); + static void acpi_spi_parse_apple_properties(struct acpi_device *dev, struct acpi_spi_lookup *lookup) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 1a34fd0f6ca2..25a82729f8da 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -764,6 +764,7 @@ extern void spi_unregister_controller(struct spi_controller *ctlr); extern struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, struct acpi_device *adev, int index, int irq_index); +int acpi_spi_count_resources(struct acpi_device *adev); #else static inline struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, struct acpi_device *adev, @@ -771,6 +772,11 @@ static inline struct spi_device *acpi_spi_device_alloc(struct spi_controller *ct { return ERR_PTR(-EOPNOTSUPP); } + +int acpi_spi_count_resources(struct acpi_device *adev) +{ + return -EOPNOTSUPP; +} #endif /* From patchwork Tue Jan 18 14:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716537 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 8D044C433EF for ; Tue, 18 Jan 2022 14:55:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A92E218B2; Tue, 18 Jan 2022 15:54:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A92E218B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517747; bh=6yF65A4oQrEc0H47giYEJ6MskbXxkE2mtj2L1+cvFrg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pO4sekehpdjZQDcNuA621+7YzwAxHDYhGM23EVf0anw5GURmZsAKPRmFrhuPdsgGv XJJredSq+HBC0c3DJTjZ2gq7dIPfgbwWBMgoJmb+fXnqyznGfutkUal/h0UcPENIfI mmUrhnuPL0OQNYZGXBlcUnK21f3g+b5oidCTvzvU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 29D86F8051F; Tue, 18 Jan 2022 15:53:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C21A0F8051E; Tue, 18 Jan 2022 15:53:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 83F24F80510 for ; Tue, 18 Jan 2022 15:53:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 83F24F80510 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="HUVtNz0i" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I1MV5t021792; Tue, 18 Jan 2022 08:53:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=YkKWuYqHlYN+uhZ693dYf8OMpvb2YiGDbgFVPAVglcA=; b=HUVtNz0iCMLrdAuhwgzakdXSUDuRRe+G5mI8CFuy42g1DM51Xr8+FvrZyRrWHvYlBEa5 GOU/pXC+RwXfml/IdUk7to9XE90GQmR4XCcOLyohSONhW6PHCS6ATFJXiz70rKvKcxU1 n2VRjmzxnA2hZSHFgBk098KxeDO1c6Qe4HtopmlaeoK0L7AISiRYFoxOcmpyLBUbwRXL sGpXyESmBYcngKyBxH7fMnHSJmrqzUk7/+Z8qJMZI9S9+jrT2uEvuKg5XFVhIoQJuW2P 3jMwaJ+lw1MF9l9il3GcrFh+bDD/qCrCqOdLR+Y+Zzg2WNpYRZFhQa5Q5jbu6fZ/bbTs FQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9nc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:40 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:39 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:39 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 9109AB13; Tue, 18 Jan 2022 14:53:37 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 05/10] platform/x86: i2c-multi-instantiate: Move it to drivers/acpi folder Date: Tue, 18 Jan 2022 14:52:46 +0000 Message-ID: <20220118145251.1548-6-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: h4wy_AJ5f5ZEYElDJVqkuKqZaNfd4b8X X-Proofpoint-ORIG-GUID: h4wy_AJ5f5ZEYElDJVqkuKqZaNfd4b8X X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, Lucas Tanure , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Lucas Tanure Moving I2C multi instantiate driver to drivers/acpi folder for upcoming conversion into a generic bus multi instantiate driver for SPI and I2C Signed-off-by: Lucas Tanure Signed-off-by: Stefan Binding --- MAINTAINERS | 2 +- drivers/acpi/Kconfig | 11 +++++++++++ drivers/acpi/Makefile | 1 + .../{platform/x86 => acpi}/i2c-multi-instantiate.c | 0 drivers/acpi/scan.c | 2 +- drivers/platform/x86/Kconfig | 11 ----------- drivers/platform/x86/Makefile | 1 - 7 files changed, 14 insertions(+), 14 deletions(-) rename drivers/{platform/x86 => acpi}/i2c-multi-instantiate.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 4e828542b089..546f9e149d28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -392,7 +392,7 @@ ACPI I2C MULTI INSTANTIATE DRIVER M: Hans de Goede L: platform-driver-x86@vger.kernel.org S: Maintained -F: drivers/platform/x86/i2c-multi-instantiate.c +F: drivers/acpi/i2c-multi-instantiate.c ACPI PCC(Platform Communication Channel) MAILBOX DRIVER M: Sudeep Holla diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ba45541b1f1f..2fd78366af6f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -295,6 +295,17 @@ config ACPI_PROCESSOR To compile this driver as a module, choose M here: the module will be called processor. +config ACPI_I2C_MULTI_INST + tristate "I2C multi instantiate pseudo device driver" + depends on I2C + help + Some ACPI-based systems list multiple i2c-devices in a single ACPI + firmware-node. This driver will instantiate separate i2c-clients + for each device in the firmware-node. + + To compile this driver as a module, choose M here: the module + will be called i2c-multi-instantiate. + config ACPI_IPMI tristate "IPMI" depends on IPMI_HANDLER diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index bb757148e7ba..d4db7fb0baf0 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -104,6 +104,7 @@ obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o +obj-$(CONFIG_ACPI_I2C_MULTI_INST) += i2c-multi-instantiate.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/acpi/i2c-multi-instantiate.c similarity index 100% rename from drivers/platform/x86/i2c-multi-instantiate.c rename to drivers/acpi/i2c-multi-instantiate.c diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 1331756d4cfc..3e85a02f6ba2 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1738,7 +1738,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) * must be instantiated for each, each with its own i2c_device_id. * Normally we only instantiate an i2c-client for the first resource, * using the ACPI HID as id. These special cases are handled by the - * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows + * drivers/acpi/i2c-multi-instantiate.c driver, which knows * which i2c_device_id to use for each resource. */ {"BSG1160", }, diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 24deeeb29af2..37c1c150508d 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -990,17 +990,6 @@ config TOPSTAR_LAPTOP If you have a Topstar laptop, say Y or M here. -config I2C_MULTI_INSTANTIATE - tristate "I2C multi instantiate pseudo device driver" - depends on I2C && ACPI - help - Some ACPI-based systems list multiple i2c-devices in a single ACPI - firmware-node. This driver will instantiate separate i2c-clients - for each device in the firmware-node. - - To compile this driver as a module, choose M here: the module - will be called i2c-multi-instantiate. - config MLX_PLATFORM tristate "Mellanox Technologies platform support" depends on I2C && REGMAP diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index c12a9b044fd8..6c7870190564 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -110,7 +110,6 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o # Platform drivers obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o -obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o obj-$(CONFIG_WIRELESS_HOTKEY) += wireless-hotkey.o From patchwork Tue Jan 18 14:52:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716540 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C9EB7C433F5 for ; Tue, 18 Jan 2022 14:56:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ED67318D7; Tue, 18 Jan 2022 15:55:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ED67318D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517796; bh=Nm2yye1TprZFr3U5FAoYFh2HhcTLrNrOsEtxRkKyEPc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Y9vL3IImTZdKWZuJbWVCwDCgPu+v52he1XcvedhyCJQzWu+RackCHSLILRHau/lQv 4SM/5Pom5mxz9Ln2B42jTxLh7eAaoZ2GXiHhvSqH7UV0uc22ZMVZIYlBIRw/hCqITb r4ktGdwob7jxNYA26WppvMheFfH0xZmNJWMR0g5s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ECB25F80533; Tue, 18 Jan 2022 15:53:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7771DF80525; Tue, 18 Jan 2022 15:53:53 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1B0E1F80518 for ; Tue, 18 Jan 2022 15:53:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1B0E1F80518 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Lvy7W7iq" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20IBxOsE014314; Tue, 18 Jan 2022 08:53:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=cHG2T95GkMFg9HkotdNEAkG+vNASe6V+mLIIky/93Iw=; b=Lvy7W7iq9C1PnwjQYRllggnwQPxanVVWF/Bh+RjlNk1KBIaIyAosr9qHUqWu0XIYERce MpX82FeU2DYpcDbnumQyPScwUwJuScivYFy8/BSvRvr0Y6yQdjGYXJ9ik5b01kRfwy23 Em34T9X9+gqK1I1xxsTpxU5wDrjLLbHTvXymxJRFaLCJNZRzGeLEDKpTRzUtKEg2AHWB mvZ5puMLoK3FBgIr9IS2DtKeXjRTS/6d+vRcLDKDDHiQOMcQ1Dzh9RvQDcpQ+zomwelf NFUhuxygaOM/TtqK2Cp4XJbcW3S1AyTl1/T3+XJbYSuClqQObTjSapN8K6Fsxr5qS4gD uw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3dn8k2s8t4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:42 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:41 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:41 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 74ED17C; Tue, 18 Jan 2022 14:53:39 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 06/10] ACPI: i2c-multi-instantiate: Rename it for a generic bus driver name Date: Tue, 18 Jan 2022 14:52:47 +0000 Message-ID: <20220118145251.1548-7-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: Wm9lIOa2RMv5RJeFSUXSxflsKpfspxx1 X-Proofpoint-ORIG-GUID: Wm9lIOa2RMv5RJeFSUXSxflsKpfspxx1 X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, Lucas Tanure , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Lucas Tanure Rename I2C multi instantiate driver to bus-multi-instantiate for upcoming addition of SPI support Signed-off-by: Lucas Tanure Signed-off-by: Stefan Binding --- MAINTAINERS | 4 +- drivers/acpi/Kconfig | 4 +- drivers/acpi/Makefile | 2 +- ...-instantiate.c => bus-multi-instantiate.c} | 89 +++++++++---------- drivers/acpi/scan.c | 2 +- 5 files changed, 50 insertions(+), 51 deletions(-) rename drivers/acpi/{i2c-multi-instantiate.c => bus-multi-instantiate.c} (53%) diff --git a/MAINTAINERS b/MAINTAINERS index 546f9e149d28..df2d7b43b133 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -388,11 +388,11 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained F: drivers/acpi/arm64 -ACPI I2C MULTI INSTANTIATE DRIVER +ACPI BUS MULTI INSTANTIATE DRIVER M: Hans de Goede L: platform-driver-x86@vger.kernel.org S: Maintained -F: drivers/acpi/i2c-multi-instantiate.c +F: drivers/acpi/bus-multi-instantiate.c ACPI PCC(Platform Communication Channel) MAILBOX DRIVER M: Sudeep Holla diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 2fd78366af6f..cb414113c238 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -295,7 +295,7 @@ config ACPI_PROCESSOR To compile this driver as a module, choose M here: the module will be called processor. -config ACPI_I2C_MULTI_INST +config ACPI_BUS_MULTI_INST tristate "I2C multi instantiate pseudo device driver" depends on I2C help @@ -304,7 +304,7 @@ config ACPI_I2C_MULTI_INST for each device in the firmware-node. To compile this driver as a module, choose M here: the module - will be called i2c-multi-instantiate. + will be called bus-multi-instantiate. config ACPI_IPMI tristate "IPMI" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index d4db7fb0baf0..2bb3b5c40019 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -104,7 +104,7 @@ obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o obj-$(CONFIG_ACPI_PPTT) += pptt.o obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o -obj-$(CONFIG_ACPI_I2C_MULTI_INST) += i2c-multi-instantiate.o +obj-$(CONFIG_ACPI_BUS_MULTI_INST) += bus-multi-instantiate.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o diff --git a/drivers/acpi/i2c-multi-instantiate.c b/drivers/acpi/bus-multi-instantiate.c similarity index 53% rename from drivers/acpi/i2c-multi-instantiate.c rename to drivers/acpi/bus-multi-instantiate.c index 4956a1df5b90..982dfecfd27c 100644 --- a/drivers/acpi/i2c-multi-instantiate.c +++ b/drivers/acpi/bus-multi-instantiate.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * I2C multi-instantiate driver, pseudo driver to instantiate multiple + * Bus multi-instantiate driver, pseudo driver to instantiate multiple * i2c-clients from a single fwnode. * * Copyright 2018 Hans de Goede @@ -21,29 +21,29 @@ #define IRQ_RESOURCE_GPIO 1 #define IRQ_RESOURCE_APIC 2 -struct i2c_inst_data { +struct bmi_instance { const char *type; unsigned int flags; int irq_idx; }; -struct i2c_multi_inst_data { - int num_clients; - struct i2c_client *clients[]; +struct bmi { + int i2c_num; + struct i2c_client *i2c_devs[]; }; -static int i2c_multi_inst_probe(struct platform_device *pdev) +static int bmi_probe(struct platform_device *pdev) { - struct i2c_multi_inst_data *multi; - const struct i2c_inst_data *inst_data; struct i2c_board_info board_info = {}; + const struct bmi_instance *inst; struct device *dev = &pdev->dev; struct acpi_device *adev; + struct bmi *bmi; char name[32]; int i, ret; - inst_data = device_get_match_data(dev); - if (!inst_data) { + inst = device_get_match_data(dev); + if (!inst) { dev_err(dev, "Error ACPI match data is missing\n"); return -ENODEV; } @@ -55,33 +55,32 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) if (ret < 0) return ret; - multi = devm_kmalloc(dev, struct_size(multi, clients, ret), GFP_KERNEL); - if (!multi) + bmi = devm_kmalloc(dev, struct_size(bmi, i2c_devs, ret), GFP_KERNEL); + if (!bmi) return -ENOMEM; - multi->num_clients = ret; + bmi->i2c_num = ret; - for (i = 0; i < multi->num_clients && inst_data[i].type; i++) { + for (i = 0; i < bmi->i2c_num && inst[i].type; i++) { memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE); - snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), - inst_data[i].type, i); + strlcpy(board_info.type, inst[i].type, I2C_NAME_SIZE); + snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), inst[i].type, i); board_info.dev_name = name; - switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) { + switch (inst[i].flags & IRQ_RESOURCE_TYPE) { case IRQ_RESOURCE_GPIO: - ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx); + ret = acpi_dev_gpio_irq_get(adev, inst[i].irq_idx); if (ret < 0) { dev_err(dev, "Error requesting irq at index %d: %d\n", - inst_data[i].irq_idx, ret); + inst[i].irq_idx, ret); goto error; } board_info.irq = ret; break; case IRQ_RESOURCE_APIC: - ret = platform_get_irq(pdev, inst_data[i].irq_idx); + ret = platform_get_irq(pdev, inst[i].irq_idx); if (ret < 0) { dev_dbg(dev, "Error requesting irq at index %d: %d\n", - inst_data[i].irq_idx, ret); + inst[i].irq_idx, ret); goto error; } board_info.irq = ret; @@ -90,48 +89,48 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) board_info.irq = 0; break; } - multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info); - if (IS_ERR(multi->clients[i])) { - ret = dev_err_probe(dev, PTR_ERR(multi->clients[i]), + bmi->i2c_devs[i] = i2c_acpi_new_device(dev, i, &board_info); + if (IS_ERR(bmi->i2c_devs[i])) { + ret = dev_err_probe(dev, PTR_ERR(bmi->i2c_devs[i]), "Error creating i2c-client, idx %d\n", i); goto error; } } - if (i < multi->num_clients) { + if (i < bmi->i2c_num) { dev_err(dev, "Error finding driver, idx %d\n", i); ret = -ENODEV; goto error; } - platform_set_drvdata(pdev, multi); + platform_set_drvdata(pdev, bmi); return 0; error: while (--i >= 0) - i2c_unregister_device(multi->clients[i]); + i2c_unregister_device(bmi->i2c_devs[i]); return ret; } -static int i2c_multi_inst_remove(struct platform_device *pdev) +static int bmi_remove(struct platform_device *pdev) { - struct i2c_multi_inst_data *multi = platform_get_drvdata(pdev); + struct bmi *bmi = platform_get_drvdata(pdev); int i; - for (i = 0; i < multi->num_clients; i++) - i2c_unregister_device(multi->clients[i]); + for (i = 0; i < bmi->i2c_num; i++) + i2c_unregister_device(bmi->i2c_devs[i]); return 0; } -static const struct i2c_inst_data bsg1160_data[] = { +static const struct bmi_instance bsg1160_data[] = { { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, { "bmc150_magn" }, { "bmg160" }, {} }; -static const struct i2c_inst_data bsg2150_data[] = { +static const struct bmi_instance bsg2150_data[] = { { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, { "bmc150_magn" }, /* The resources describe a 3th client, but it is not really there. */ @@ -139,7 +138,7 @@ static const struct i2c_inst_data bsg2150_data[] = { {} }; -static const struct i2c_inst_data int3515_data[] = { +static const struct bmi_instance int3515_data[] = { { "tps6598x", IRQ_RESOURCE_APIC, 0 }, { "tps6598x", IRQ_RESOURCE_APIC, 1 }, { "tps6598x", IRQ_RESOURCE_APIC, 2 }, @@ -148,27 +147,27 @@ static const struct i2c_inst_data int3515_data[] = { }; /* - * Note new device-ids must also be added to i2c_multi_instantiate_ids in + * Note new device-ids must also be added to bus_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). */ -static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { +static const struct acpi_device_id bmi_acpi_ids[] = { { "BSG1160", (unsigned long)bsg1160_data }, { "BSG2150", (unsigned long)bsg2150_data }, { "INT3515", (unsigned long)int3515_data }, { } }; -MODULE_DEVICE_TABLE(acpi, i2c_multi_inst_acpi_ids); +MODULE_DEVICE_TABLE(acpi, bmi_acpi_ids); -static struct platform_driver i2c_multi_inst_driver = { +static struct platform_driver bmi_driver = { .driver = { - .name = "I2C multi instantiate pseudo device driver", - .acpi_match_table = i2c_multi_inst_acpi_ids, + .name = "Bus multi instantiate pseudo device driver", + .acpi_match_table = bmi_acpi_ids, }, - .probe = i2c_multi_inst_probe, - .remove = i2c_multi_inst_remove, + .probe = bmi_probe, + .remove = bmi_remove, }; -module_platform_driver(i2c_multi_inst_driver); +module_platform_driver(bmi_driver); -MODULE_DESCRIPTION("I2C multi instantiate pseudo device driver"); +MODULE_DESCRIPTION("Bus multi instantiate pseudo device driver"); MODULE_AUTHOR("Hans de Goede "); MODULE_LICENSE("GPL"); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 3e85a02f6ba2..a015a3b1d6f2 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1738,7 +1738,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) * must be instantiated for each, each with its own i2c_device_id. * Normally we only instantiate an i2c-client for the first resource, * using the ACPI HID as id. These special cases are handled by the - * drivers/acpi/i2c-multi-instantiate.c driver, which knows + * drivers/acpi/bus-multi-instantiate.c driver, which knows * which i2c_device_id to use for each resource. */ {"BSG1160", }, From patchwork Tue Jan 18 14:52:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716539 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 2B27CC433F5 for ; Tue, 18 Jan 2022 14:56:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 58F6118D4; Tue, 18 Jan 2022 15:55:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 58F6118D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517771; bh=urDIsXUZL4M2wAnIJtrKOQJaFCcqfXvxzM4qGrANCNo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=k2qo52+5JX/lyBPaz7E4pVktm3ytfbIOekxUM8oihDCAgk+kXhCEZe8pda+4kHcPu MAJNtsJ3U7jhZgv3/h3S4y3fRDdBXN5PdgKWtZwP+YCely1wevpeUgSOav9yfZR9kU P7SepTaM9vh2lSIuiPNNLYcn9tx61BxCGcKz5utc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 466FEF8052D; Tue, 18 Jan 2022 15:53:55 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EDA37F80511; Tue, 18 Jan 2022 15:53:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4DF56F80519 for ; Tue, 18 Jan 2022 15:53:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4DF56F80519 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="TqsmurpJ" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I3r9SM009450; Tue, 18 Jan 2022 08:53:45 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=R5uyFqfTfrDD7G+2dbwaFrqTm251w9zGshUntVK6xUE=; b=TqsmurpJ96J573so/AigeUs/iwXO3OtGTGq545Js5kTwlXla2oh47TEnGTJrZ73AhzPl FyCXHHF9EfERvh+3P9MKsq8a+F0g06bNOVDwW8SNduLbj8LzcuebeyUoKsoM5ssQPpCb G1YFfLZ5itWskweie1aX5psB+90n4mVPLWwms9LFRkv1vrLGfLIyI4RSz9wm9UFZM5KK SKqVMCqskrj3cn31QAz5FjTSnRr79UAM7bfjr5VFdOOTjEXmAuaQVDYAdDHdn7cpgh0u 0zRvliPgNjkA7o4evyn16FfAOz1E5SjPMotEJZfg1nq0KKqvgtIrLh3Wmw6DGFce4h4h cA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3dn8k2s8t5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:44 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:43 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:43 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 55C2CB13; Tue, 18 Jan 2022 14:53:41 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 07/10] ACPI: bus-multi-instantiate: Reorganize I2C functions Date: Tue, 18 Jan 2022 14:52:48 +0000 Message-ID: <20220118145251.1548-8-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: _zsWiuqrCBNFeq-TObDtrcfBgjwXJM8K X-Proofpoint-ORIG-GUID: _zsWiuqrCBNFeq-TObDtrcfBgjwXJM8K X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, Lucas Tanure , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Lucas Tanure Reorganize I2C functions to accommodate SPI support Split the probe and factor out parts of the code that will be used in the SPI support Signed-off-by: Lucas Tanure Signed-off-by: Stefan Binding --- drivers/acpi/bus-multi-instantiate.c | 150 +++++++++++++++++---------- 1 file changed, 96 insertions(+), 54 deletions(-) diff --git a/drivers/acpi/bus-multi-instantiate.c b/drivers/acpi/bus-multi-instantiate.c index 982dfecfd27c..50f1540762e9 100644 --- a/drivers/acpi/bus-multi-instantiate.c +++ b/drivers/acpi/bus-multi-instantiate.c @@ -29,85 +29,129 @@ struct bmi_instance { struct bmi { int i2c_num; - struct i2c_client *i2c_devs[]; + struct i2c_client **i2c_devs; }; -static int bmi_probe(struct platform_device *pdev) +static int bmi_get_irq(struct platform_device *pdev, struct acpi_device *adev, + const struct bmi_instance *inst) +{ + int ret; + + switch (inst->flags & IRQ_RESOURCE_TYPE) { + case IRQ_RESOURCE_GPIO: + ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx); + break; + case IRQ_RESOURCE_APIC: + ret = platform_get_irq(pdev, inst->irq_idx); + break; + default: + ret = 0; + break; + } + + if (ret < 0) + dev_err_probe(&pdev->dev, ret, "Error requesting irq at index %d: %d\n", + inst->irq_idx, ret); + + return ret; +} + +static void bmi_devs_unregister(struct bmi *bmi) +{ + while (bmi->i2c_num > 0) + i2c_unregister_device(bmi->i2c_devs[--bmi->i2c_num]); +} + +/** + * bmi_i2c_probe - Instantiate multiple I2C devices from inst array + * @pdev: Platform device + * @adev: ACPI device + * @bmi: Internal struct for Bus multi instantiate driver + * @inst: Array of instances to probe + * + * Returns the number of I2C devices instantiate, Zero if none is found or a negative error code. + */ +static int bmi_i2c_probe(struct platform_device *pdev, struct acpi_device *adev, struct bmi *bmi, + const struct bmi_instance *inst_array) { struct i2c_board_info board_info = {}; - const struct bmi_instance *inst; struct device *dev = &pdev->dev; - struct acpi_device *adev; - struct bmi *bmi; char name[32]; - int i, ret; + int i, ret = 0, count; - inst = device_get_match_data(dev); - if (!inst) { - dev_err(dev, "Error ACPI match data is missing\n"); - return -ENODEV; - } - - adev = ACPI_COMPANION(dev); - - /* Count number of clients to instantiate */ ret = i2c_acpi_client_count(adev); - if (ret < 0) + if (ret <= 0) return ret; + count = ret; - bmi = devm_kmalloc(dev, struct_size(bmi, i2c_devs, ret), GFP_KERNEL); - if (!bmi) + bmi->i2c_devs = devm_kcalloc(dev, count, sizeof(*bmi->i2c_devs), GFP_KERNEL); + if (!bmi->i2c_devs) return -ENOMEM; - bmi->i2c_num = ret; - - for (i = 0; i < bmi->i2c_num && inst[i].type; i++) { + for (i = 0; i < count && inst_array[i].type; i++) { memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, inst[i].type, I2C_NAME_SIZE); - snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), inst[i].type, i); + strscpy(board_info.type, inst_array[i].type, I2C_NAME_SIZE); + snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), inst_array[i].type, i); board_info.dev_name = name; - switch (inst[i].flags & IRQ_RESOURCE_TYPE) { - case IRQ_RESOURCE_GPIO: - ret = acpi_dev_gpio_irq_get(adev, inst[i].irq_idx); - if (ret < 0) { - dev_err(dev, "Error requesting irq at index %d: %d\n", - inst[i].irq_idx, ret); - goto error; - } - board_info.irq = ret; - break; - case IRQ_RESOURCE_APIC: - ret = platform_get_irq(pdev, inst[i].irq_idx); - if (ret < 0) { - dev_dbg(dev, "Error requesting irq at index %d: %d\n", - inst[i].irq_idx, ret); - goto error; - } - board_info.irq = ret; - break; - default: - board_info.irq = 0; - break; - } + + ret = bmi_get_irq(pdev, adev, &inst_array[i]); + if (ret < 0) + goto error; + board_info.irq = ret; + bmi->i2c_devs[i] = i2c_acpi_new_device(dev, i, &board_info); if (IS_ERR(bmi->i2c_devs[i])) { ret = dev_err_probe(dev, PTR_ERR(bmi->i2c_devs[i]), "Error creating i2c-client, idx %d\n", i); goto error; } + bmi->i2c_num++; } - if (i < bmi->i2c_num) { + if (bmi->i2c_num < count) { dev_err(dev, "Error finding driver, idx %d\n", i); ret = -ENODEV; goto error; } - platform_set_drvdata(pdev, bmi); - return 0; + dev_info(dev, "Instantiate %d I2C devices.\n", bmi->i2c_num); + return bmi->i2c_num; error: - while (--i >= 0) - i2c_unregister_device(bmi->i2c_devs[i]); + dev_err_probe(dev, ret, "I2C error %d\n", ret); + bmi_devs_unregister(bmi); + + return ret; +} + +static int bmi_probe(struct platform_device *pdev) +{ + const struct bmi_instance *inst_array; + struct device *dev = &pdev->dev; + struct acpi_device *adev; + struct bmi *bmi; + int ret; + + inst_array = device_get_match_data(dev); + if (!inst_array) { + dev_err(dev, "Error ACPI match data is missing\n"); + return -ENODEV; + } + + adev = ACPI_COMPANION(dev); + if (!adev) + return -ENODEV; + + bmi = devm_kzalloc(dev, sizeof(*bmi), GFP_KERNEL); + if (!bmi) + return -ENOMEM; + + platform_set_drvdata(pdev, bmi); + + ret = bmi_i2c_probe(pdev, adev, bmi, inst_array); + if (ret > 0) + return 0; + if (ret == 0) + ret = -ENODEV; return ret; } @@ -115,10 +159,8 @@ static int bmi_probe(struct platform_device *pdev) static int bmi_remove(struct platform_device *pdev) { struct bmi *bmi = platform_get_drvdata(pdev); - int i; - for (i = 0; i < bmi->i2c_num; i++) - i2c_unregister_device(bmi->i2c_devs[i]); + bmi_devs_unregister(bmi); return 0; } From patchwork Tue Jan 18 14:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716541 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 45002C433F5 for ; Tue, 18 Jan 2022 14:56:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7DE981EC; Tue, 18 Jan 2022 15:56:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7DE981EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517813; bh=yipakij7RopUX4TLkU4j/WoZy2gIqhzYUpovC5x+MAM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=i867PQDHG+kxna0BaePCH/Fy2K3M7cEFFk7u4KRIcMFmZmzreZEnuKESHZkTDwdMG FYKVy14K485kEJjVOx047nAZiPNke7FBpjjl4OipFDO5N8KOoXebm5Ghyn8LXQVzN6 kXIRgW0BIrL/xq5uoor3VwVOWCFQcEGdNfnUR1Ew= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8DA18F80537; Tue, 18 Jan 2022 15:53:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DFF42F8052E; Tue, 18 Jan 2022 15:53:54 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2457CF8051B for ; Tue, 18 Jan 2022 15:53:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2457CF8051B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="lKgoHchX" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I3r9SN009450; Tue, 18 Jan 2022 08:53:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=+aIWqVLj1vDO8KKjD7Ahk8o53BxpDaMkVk6Yj9vwUSY=; b=lKgoHchXjezITGAhz/2S6sSY9JMRhtbkGxHl4igS/bdF+pf6iGajYYN49yjFftL7KLa+ l64EDNrnU7LSGkmXjfAuEnWkvbAFFi1ciBcaCfV9qZ6iZd/q8Pk1hLyyEH1HqoqE7YIw uD+RNw1cTyfsMu4IiWXwCR/TwISKQi/JQLRdKaGb0clSaWc7Len8+e+e24Ib0m+5yc9g KsKeuukhxYrw1z/GOqEsTMILEfky7Pj/b85eJPYJ2TW3x1ks7ErXzQ2SsBOjVuxWfK1W UmXyi+EJzJvMsyNjTEKFrzHzvnnEiuJcf8aBLK8URL0UMVkuAqRqCXmPkh/sYCngvx1v Hw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3dn8k2s8t5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:45 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:44 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:44 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 333B37C; Tue, 18 Jan 2022 14:53:43 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 08/10] ACPI: bus-multi-instantiate: Add SPI support Date: Tue, 18 Jan 2022 14:52:49 +0000 Message-ID: <20220118145251.1548-9-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: j4Uni6o4ElVZnSWW4eBt5JLoMYzfTi7E X-Proofpoint-ORIG-GUID: j4Uni6o4ElVZnSWW4eBt5JLoMYzfTi7E X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for spi bus in bus-multi-instantiate driver Some peripherals can have either a I2C or a SPI connection to the host (but not both) but use the same HID for both types. So it is not possible to use the HID to determine whether it is I2C or SPI. The driver must check the node to see if it contains I2cSerialBus or SpiSerialBus entries. For backwards-compatibility with the existing nodes I2C is checked first and if such entries are found ONLY I2C devices are created. Since some existing nodes that were already handled by this driver could also contain unrelated SpiSerialBus nodes that were previously ignored, and this preserves that behavior. If there is ever a need to handle a node where both I2C and SPI devices must be instantiated this can be added in future. Signed-off-by: Stefan Binding --- drivers/acpi/Kconfig | 10 +- drivers/acpi/bus-multi-instantiate.c | 200 +++++++++++++++++++++++---- drivers/acpi/scan.c | 13 +- 3 files changed, 182 insertions(+), 41 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index cb414113c238..3550e0efeb16 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -296,12 +296,12 @@ config ACPI_PROCESSOR the module will be called processor. config ACPI_BUS_MULTI_INST - tristate "I2C multi instantiate pseudo device driver" - depends on I2C + tristate "I2C and SPI multi instantiate pseudo device driver" + depends on I2C && SPI help - Some ACPI-based systems list multiple i2c-devices in a single ACPI - firmware-node. This driver will instantiate separate i2c-clients - for each device in the firmware-node. + Some ACPI-based systems list multiple i2c/spi devices in a + single ACPI firmware-node. This driver will instantiate separate + i2c-clients or spi-devices for each device in the firmware-node. To compile this driver as a module, choose M here: the module will be called bus-multi-instantiate. diff --git a/drivers/acpi/bus-multi-instantiate.c b/drivers/acpi/bus-multi-instantiate.c index 50f1540762e9..05bc941a38fd 100644 --- a/drivers/acpi/bus-multi-instantiate.c +++ b/drivers/acpi/bus-multi-instantiate.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Bus multi-instantiate driver, pseudo driver to instantiate multiple - * i2c-clients from a single fwnode. + * i2c-clients or spi-devices from a single fwnode. * * Copyright 2018 Hans de Goede */ @@ -14,6 +14,7 @@ #include #include #include +#include #include #define IRQ_RESOURCE_TYPE GENMASK(1, 0) @@ -21,15 +22,28 @@ #define IRQ_RESOURCE_GPIO 1 #define IRQ_RESOURCE_APIC 2 +enum bmi_bus_type { + BMI_I2C, + BMI_SPI, + BMI_AUTO_DETECT, +}; + struct bmi_instance { const char *type; unsigned int flags; int irq_idx; }; +struct bmi_node { + enum bmi_bus_type bus_type; + struct bmi_instance instances[]; +}; + struct bmi { int i2c_num; + int spi_num; struct i2c_client **i2c_devs; + struct spi_device **spi_devs; }; static int bmi_get_irq(struct platform_device *pdev, struct acpi_device *adev, @@ -60,6 +74,92 @@ static void bmi_devs_unregister(struct bmi *bmi) { while (bmi->i2c_num > 0) i2c_unregister_device(bmi->i2c_devs[--bmi->i2c_num]); + + while (bmi->spi_num > 0) + spi_unregister_device(bmi->spi_devs[--bmi->spi_num]); +} + +/** + * bmi_spi_probe - Instantiate multiple SPI devices from inst array + * @pdev: Platform device + * @adev: ACPI device + * @bmi: Internal struct for Bus multi instantiate driver + * @inst: Array of instances to probe + * + * Returns the number of SPI devices instantiate, Zero if none is found or a negative error code. + */ +static int bmi_spi_probe(struct platform_device *pdev, struct acpi_device *adev, struct bmi *bmi, + const struct bmi_instance *inst_array) +{ + struct device *dev = &pdev->dev; + struct spi_controller *ctlr; + struct spi_device *spi_dev; + char name[50]; + int i, ret, count; + + ret = acpi_spi_count_resources(adev); + if (ret <= 0) + return ret; + count = ret; + + bmi->spi_devs = devm_kcalloc(dev, count, sizeof(*bmi->spi_devs), GFP_KERNEL); + if (!bmi->spi_devs) + return -ENOMEM; + + for (i = 0; i < count && inst_array[i].type; i++) { + + spi_dev = acpi_spi_device_alloc(NULL, adev, i, inst_array[i].irq_idx); + if (IS_ERR(spi_dev)) { + ret = PTR_ERR(spi_dev); + goto error; + } + + ctlr = spi_dev->controller; + + strscpy(spi_dev->modalias, inst_array[i].type, sizeof(spi_dev->modalias)); + + if (spi_dev->irq < 0) { + ret = bmi_get_irq(pdev, adev, &inst_array[i]); + if (ret < 0) { + spi_dev_put(spi_dev); + goto error; + } + spi_dev->irq = ret; + } + + snprintf(name, sizeof(name), "%s-%s-%s.%d", dev_name(&ctlr->dev), dev_name(dev), + inst_array[i].type, i); + spi_dev->dev.init_name = name; + + ret = spi_add_device(spi_dev); + if (ret) { + dev_err(&ctlr->dev, "failed to add SPI device %s from ACPI: %d\n", + dev_name(&adev->dev), ret); + spi_dev_put(spi_dev); + goto error; + } + + dev_dbg(dev, "SPI device %s using chip select %u", name, spi_dev->chip_select); + + bmi->spi_devs[i] = spi_dev; + bmi->spi_num++; + } + + if (bmi->spi_num < count) { + dev_err(dev, "Error finding driver, idx %d\n", i); + ret = -ENODEV; + goto error; + } + + dev_info(dev, "Instantiate %d SPI devices.\n", bmi->spi_num); + + return bmi->spi_num; +error: + bmi_devs_unregister(bmi); + dev_err_probe(dev, ret, "SPI error %d\n", ret); + + return ret; + } /** @@ -125,14 +225,14 @@ static int bmi_i2c_probe(struct platform_device *pdev, struct acpi_device *adev, static int bmi_probe(struct platform_device *pdev) { - const struct bmi_instance *inst_array; struct device *dev = &pdev->dev; + const struct bmi_node *node; struct acpi_device *adev; struct bmi *bmi; - int ret; + int i2c_ret = 0, spi_ret = 0; - inst_array = device_get_match_data(dev); - if (!inst_array) { + node = device_get_match_data(dev); + if (!node) { dev_err(dev, "Error ACPI match data is missing\n"); return -ENODEV; } @@ -147,13 +247,44 @@ static int bmi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, bmi); - ret = bmi_i2c_probe(pdev, adev, bmi, inst_array); - if (ret > 0) + /* Each time this driver probes only one type of bus will be chosen. + * And I2C has preference, which means that if find a I2cSerialBus it assumes + * that all following devices will also be I2C. + * In case there are zero I2C devices, it assumes that all following devices are SPI. + */ + if (node->bus_type != BMI_SPI) { + i2c_ret = bmi_i2c_probe(pdev, adev, bmi, node->instances); + if (i2c_ret > 0) + return 0; + else if (i2c_ret == -EPROBE_DEFER) + return i2c_ret; + if (node->bus_type == BMI_I2C) { + if (i2c_ret == 0) + return -ENODEV; + else + return i2c_ret; + } + } + /* BMI_SPI or BMI_AUTO_DETECT */ + spi_ret = bmi_spi_probe(pdev, adev, bmi, node->instances); + if (spi_ret > 0) return 0; - if (ret == 0) - ret = -ENODEV; + else if (spi_ret == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (node->bus_type == BMI_SPI) { + if (spi_ret == 0) + return -ENODEV; + else + return spi_ret; + } - return ret; + /* The only way to get here is BMI_AUTO_DETECT and i2c_ret <= 0 and spi_ret <= 0 */ + if (i2c_ret == 0 && spi_ret == 0) + return -ENODEV; + else if (i2c_ret == 0 && spi_ret) + return spi_ret; + + return i2c_ret; } static int bmi_remove(struct platform_device *pdev) @@ -165,27 +296,36 @@ static int bmi_remove(struct platform_device *pdev) return 0; } -static const struct bmi_instance bsg1160_data[] = { - { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, - { "bmc150_magn" }, - { "bmg160" }, - {} +static const struct bmi_node bsg1160_data = { + .instances = { + { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, + { "bmc150_magn" }, + { "bmg160" }, + {} + }, + .bus_type = BMI_I2C, }; -static const struct bmi_instance bsg2150_data[] = { - { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, - { "bmc150_magn" }, - /* The resources describe a 3th client, but it is not really there. */ - { "bsg2150_dummy_dev" }, - {} +static const struct bmi_node bsg2150_data = { + .instances = { + { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, + { "bmc150_magn" }, + /* The resources describe a 3th client, but it is not really there. */ + { "bsg2150_dummy_dev" }, + {} + }, + .bus_type = BMI_I2C, }; -static const struct bmi_instance int3515_data[] = { - { "tps6598x", IRQ_RESOURCE_APIC, 0 }, - { "tps6598x", IRQ_RESOURCE_APIC, 1 }, - { "tps6598x", IRQ_RESOURCE_APIC, 2 }, - { "tps6598x", IRQ_RESOURCE_APIC, 3 }, - {} +static const struct bmi_node int3515_data = { + .instances = { + { "tps6598x", IRQ_RESOURCE_APIC, 0 }, + { "tps6598x", IRQ_RESOURCE_APIC, 1 }, + { "tps6598x", IRQ_RESOURCE_APIC, 2 }, + { "tps6598x", IRQ_RESOURCE_APIC, 3 }, + {} + }, + .bus_type = BMI_I2C, }; /* @@ -193,9 +333,9 @@ static const struct bmi_instance int3515_data[] = { * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). */ static const struct acpi_device_id bmi_acpi_ids[] = { - { "BSG1160", (unsigned long)bsg1160_data }, - { "BSG2150", (unsigned long)bsg2150_data }, - { "INT3515", (unsigned long)int3515_data }, + { "BSG1160", (unsigned long)&bsg1160_data }, + { "BSG2150", (unsigned long)&bsg2150_data }, + { "INT3515", (unsigned long)&int3515_data }, { } }; MODULE_DEVICE_TABLE(acpi, bmi_acpi_ids); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a015a3b1d6f2..3a92b7bdb91d 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1734,12 +1734,13 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) bool is_serial_bus_slave = false; static const struct acpi_device_id ignore_serial_bus_ids[] = { /* - * These devices have multiple I2cSerialBus resources and an i2c-client - * must be instantiated for each, each with its own i2c_device_id. - * Normally we only instantiate an i2c-client for the first resource, - * using the ACPI HID as id. These special cases are handled by the - * drivers/acpi/bus-multi-instantiate.c driver, which knows - * which i2c_device_id to use for each resource. + * These devices have multiple I2cSerialBus/SpiSerialBus resources + * and an (i2c/spi)-client must be instantiated for each, each with + * its own i2c_device_id/spi_device_id. + * Normally we only instantiate an (i2c/spi)-client for the first + * resource, using the ACPI HID as id. These special cases are handled + * by the drivers/acpi/bus-multi-instantiate.c driver, which + * knows which i2c_device_id or spi_device_id to use for each resource. */ {"BSG1160", }, {"BSG2150", }, From patchwork Tue Jan 18 14:52:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716543 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 34679C433F5 for ; Tue, 18 Jan 2022 14:57:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7762518BC; Tue, 18 Jan 2022 15:56:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7762518BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517854; bh=jg0i98pi8Y0Q4ra/PZIfym9fBHfgkORJWfQ+otNp/xQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EnO1WBXezOES5P8peZKlrx6HcfjdvwomF6ODQidLH52iTfHVTun5EVZhxM6t1Ji5e YqgHtIn7LAJQNuMffJXrKmBsn8eL1OxdOLVV1CEbkSDriCMfJUH71wvGrdT0bCRAfH BZa3md5Ukk0QY5BV+WADZBOmMUiRhsV6/jevRnT8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 50766F80557; Tue, 18 Jan 2022 15:54:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CCF78F8053A; Tue, 18 Jan 2022 15:53:59 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2FC77F80510 for ; Tue, 18 Jan 2022 15:53:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2FC77F80510 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Or3QNWj2" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I1MV5v021792; Tue, 18 Jan 2022 08:53:49 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=NnT76tFDTsJKnRu3BbxkL9dyW+2s7WfbF9csCDbyTxM=; b=Or3QNWj2tZ1aCCNnVmiFgggYQiTPIQungUAX+WtaxXBWN2vNENv74/SQ+nQRCz3dzxSS dIZ3hjmTMiwV/0tBFBYnd7laQu2YTx+oql/qpWYi1/uW7K2KYfTWzq/zC172ZNqTUUCZ xTEkld6+1I7QGO30XyLM7cDhVULYOsFRwA6Ks+Ok0O+zjLwPgYlZhdMcqhf+omR7IkBN 5Co+aw7JBrWHLG/liwqZkH2pgCVeBnQqUwdi5k+QFVhFsM2KuvvTbmJ49h9K4LqxWELs Sj9N1qgeiHbHhK4Attrx6RL9p0Hx+8zfUpQPgKerh41Y/zVrtbcjUkOl0tfph5HHX3vc Pg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:48 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:46 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:46 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 044177C; Tue, 18 Jan 2022 14:53:44 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 09/10] ALSA: hda/realtek: Add support for HP Laptops Date: Tue, 18 Jan 2022 14:52:50 +0000 Message-ID: <20220118145251.1548-10-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: jtkmTnWrOPhTDt2ozKGtHFSeZItnLKIQ X-Proofpoint-ORIG-GUID: jtkmTnWrOPhTDt2ozKGtHFSeZItnLKIQ X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, Lucas Tanure , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Lucas Tanure Add support for two and four CS35L41 using the component binding method Signed-off-by: Lucas Tanure Signed-off-by: Stefan Binding --- sound/pci/hda/patch_realtek.c | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 668274e52674..956515aa4ec3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6611,6 +6611,16 @@ static void cs35l41_fixup_i2c_two(struct hda_codec *cdc, const struct hda_fixup cs35l41_generic_fixup(cdc, action, "i2c", "CSC3551", 2); } +static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action) +{ + cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 2); +} + +static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action) +{ + cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 4); +} + static void alc287_legion_16achg6_playback_hook(struct hda_pcm_stream *hinfo, struct hda_codec *cdc, struct snd_pcm_substream *sub, int action) { @@ -6948,6 +6958,9 @@ enum { ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE, ALC287_FIXUP_LEGION_16ACHG6, ALC287_FIXUP_CS35L41_I2C_2, + ALC245_FIXUP_CS35L41_SPI_2, + ALC245_FIXUP_CS35L41_SPI_4, + ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED, ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED, }; @@ -8699,6 +8712,20 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = cs35l41_fixup_i2c_two, }, + [ALC245_FIXUP_CS35L41_SPI_2] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_spi_two, + }, + [ALC245_FIXUP_CS35L41_SPI_4] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_spi_four, + }, + [ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc245_fixup_hp_gpio_led, + .chained = true, + .chain_id = ALC245_FIXUP_CS35L41_SPI_4, + }, [ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb[]) { @@ -8926,8 +8953,22 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED), - SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), + SND_PCI_QUIRK(0x103c, 0x896E, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8971, "HP EliteBook 830 G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8972, "HP EliteBook 840 G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8973, "HP EliteBook 860 G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8974, "HP EliteBook 840 Aero G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8975, "HP EliteBook x360 840 Aero G9", ALC245_FIXUP_CS35L41_SPI_2), + SND_PCI_QUIRK(0x103c, 0x8981, "HP Elite Dragonfly G3", ALC245_FIXUP_CS35L41_SPI_4), + SND_PCI_QUIRK(0x103c, 0x898E, "HP EliteBook 835 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x898F, "HP EliteBook 835 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x8991, "HP EliteBook 845 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x8992, "HP EliteBook 845 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x8994, "HP EliteBook 855 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x8995, "HP EliteBook 855 G9", ALC287_FIXUP_CS35L41_I2C_2), + SND_PCI_QUIRK(0x103c, 0x89C3, "Zbook Studio G9", ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x89C6, "Zbook Fury 17 G9", ALC245_FIXUP_CS35L41_SPI_2), SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), From patchwork Tue Jan 18 14:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 12716542 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 EFFEDC433EF for ; Tue, 18 Jan 2022 14:57:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3900118FB; Tue, 18 Jan 2022 15:56:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3900118FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642517823; bh=XdEmsyrkQ6TYYClvWfs91eyvLy3IgK9UvUTj1n6RDdM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=omIvndcOlT5tqy1PAbUoWd4oMRBqyAnCm9Sz8gR2Rprfmstlyz6YAFeGWt74lgC0t yHrdK+U0ovhE0iYlVJFmJ6dvAFiIct5+9I8/zZeGAsGohnIJfddXeoeKV8SENUUs93 a5pcj7t6OL3HegDHPuS4JZHnThAtjE0PTRfjnjTc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 47F56F80510; Tue, 18 Jan 2022 15:54:00 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5A017F80534; Tue, 18 Jan 2022 15:53:57 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ACCF1F80524 for ; Tue, 18 Jan 2022 15:53:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ACCF1F80524 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="awgKG5Yw" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20I6SNEE013849; Tue, 18 Jan 2022 08:53:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=6+/rANZdRrEfJUZ4alDuEZX8fBBnd5Scc+NJ3tIuJJc=; b=awgKG5YwMnl+EnZ4Kcqo0ouhel6wo81CXmHGXha1esHm2ZY6DMzL8YRvblG4HXFkA/JL hCN0JgJ7+HFU/QWFSVaNKlkG2+xirMLYY4R5+yFGJ8Nnd4Q3JGIndUW5yavt20Luzr1D Kd7mK0qLwDuCMZUfd5laJgdQya4ZNIrdzd4ZUIW7AcTuVamHNimN6kqGLflapBOckO6e a4yWc3kyJWIyQOVbIUam+JhfVCGI8udgpEn86h65ynwLO7sfePOM6QmEV1PB16TqrKoB aPN0VHw71tQ8iE0iPh/qYmtOntfWR/KWV8WB6MTpq1VwLUzWDqpKng53Or6L5pnroXHi 6g== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3dnaxhs9nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 18 Jan 2022 08:53:50 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 14:53:48 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 18 Jan 2022 14:53:48 +0000 Received: from LONN2DGDQ73.ad.cirrus.com (unknown [198.90.238.138]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id D4E50B13; Tue, 18 Jan 2022 14:53:46 +0000 (UTC) From: Stefan Binding To: Mark Brown , "Rafael J . Wysocki" , Len Brown , Hans de Goede , Mark Gross , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v3 10/10] ACPI / scan: Create platform device for CS35L41 Date: Tue, 18 Jan 2022 14:52:51 +0000 Message-ID: <20220118145251.1548-11-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118145251.1548-1-sbinding@opensource.cirrus.com> References: <20220118145251.1548-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: kwBsGPyxvH_suD7jNMUkws3PVo4gMDXu X-Proofpoint-ORIG-GUID: kwBsGPyxvH_suD7jNMUkws3PVo4gMDXu X-Proofpoint-Spam-Reason: safe Cc: alsa-devel@alsa-project.org, Lucas Tanure , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, Stefan Binding , linux-spi@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Lucas Tanure The ACPI device with CSC3551 or CLSA0100 are sound cards with multiple instances of CS35L41 connectec by I2C or SPI to the main CPU. We add an ID to the ignore_serial_bus_ids list to enumerate all I2C or SPI devices correctly. Signed-off-by: Lucas Tanure Signed-off-by: Stefan Binding --- drivers/acpi/bus-multi-instantiate.c | 14 ++++++++++++++ drivers/acpi/scan.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/acpi/bus-multi-instantiate.c b/drivers/acpi/bus-multi-instantiate.c index 05bc941a38fd..7a394b671f5a 100644 --- a/drivers/acpi/bus-multi-instantiate.c +++ b/drivers/acpi/bus-multi-instantiate.c @@ -328,6 +328,17 @@ static const struct bmi_node int3515_data = { .bus_type = BMI_I2C, }; +static const struct bmi_node cs35l41_hda = { + .instances = { + { "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 }, + { "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 }, + { "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 }, + { "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 }, + {} + }, + .bus_type = BMI_AUTO_DETECT, +}; + /* * Note new device-ids must also be added to bus_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). @@ -336,6 +347,9 @@ static const struct acpi_device_id bmi_acpi_ids[] = { { "BSG1160", (unsigned long)&bsg1160_data }, { "BSG2150", (unsigned long)&bsg2150_data }, { "INT3515", (unsigned long)&int3515_data }, + { "CSC3551", (unsigned long)&cs35l41_hda }, + /* Non-conforming _HID for Cirrus Logic already released */ + { "CLSA0100", (unsigned long)&cs35l41_hda }, { } }; MODULE_DEVICE_TABLE(acpi, bmi_acpi_ids); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 3a92b7bdb91d..6cab6465558d 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1744,8 +1744,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) */ {"BSG1160", }, {"BSG2150", }, + {"CSC3551", }, {"INT33FE", }, {"INT3515", }, + /* Non-conforming _HID for Cirrus Logic already released */ + {"CLSA0100", }, /* * HIDs of device with an UartSerialBusV2 resource for which userspace * expects a regular tty cdev to be created (instead of the in kernel