From patchwork Tue Jun 11 13:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 803432 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 4876217C9F9; Tue, 11 Jun 2024 13:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; cv=none; b=QVHjidh6Embrw5ftKtZDJ7M+02JvGaYmu1kDPMlb/BMTlwvl/ofykRYMrIK8kI73r7UoxvS3RJennaaEoRtMCY4Nj5rRzbYaUhHymvJRf+U68iUT6kP+uvRj631ETRfn7XOPzHkqU7ggQKVJqNtxReGE3H9bQ2NsJni8rTAZJAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; c=relaxed/simple; bh=xsUIs1Kt5mpQP6+VuDxqZD5NRvHeR1YK4OYtm7Chvk0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Cr+X9QKjDZkjWHoDUY6BpdG1VGE4lEg51hTI384I68G3tKW/UZGqOr8KF2ogZKyAksVItRci95gYLbl1OQmbc0HXdZ6JUAgdntDVBJVwSXABfL1Lw+BCl9T0PmqvlNQ83cr9wzcSJWGCBcqcsD3J2jIH7ypCYp25rp5CHV48tME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=lybl2cGR; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="lybl2cGR" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45B4c4Kv010402; Tue, 11 Jun 2024 08:25:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=PODMain02222019; bh=T4zM91sFnNYIgYO3 pQDLwJ7ZrWumJOlcKaLpF6K+kHA=; b=lybl2cGR4J0+/ktWFPOcUvBGZynyg4jv qhetaj5NuYGCqzX4DxNKB5zPnJwkve5hwwQ1U+Fg3OPD0egfrlzRehz5NxgQEzh9 M/HQf9Ec2OBt+1zC/wzAs3Vpqkh3lpJSwOjKYT4VCqjLvEgHa3aUQTX/cQ8YU2ja SRs/w6dvmUlPpQXkWYew1/oUooAW17LCr8L0YhgF+omPRVmXyz5wIIQw6RKCgeeX UqgYLiAN2jg30PnM7zRvF5Zf3sw2vU9bQi0PEv8zWx6hVkAVqXIoH68v2MIR45nO 2cOo2wsx1ExG9MVTuoyYrGyEJ+Y4Sun3T7Ox0Ju97+UlqVV1I8B5Tg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3ymkqhtuvb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 08:25:59 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id B4FB6820244; Tue, 11 Jun 2024 13:25:56 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH 1/3] spi: cs42l43: Refactor accessing the SDCA extension properties Date: Tue, 11 Jun 2024 14:25:54 +0100 Message-ID: <20240611132556.1557075-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: RlxZDK-G1HOQKD9cYSixedcmOG006PmH X-Proofpoint-ORIG-GUID: RlxZDK-G1HOQKD9cYSixedcmOG006PmH X-Proofpoint-Spam-Reason: safe Refactor accessing the SDCA extension properties to make it easier to access multiple properties to assist with future features. Return the node itself and allow the caller to read the actual properties. Signed-off-by: Charles Keepax --- drivers/spi/spi-cs42l43.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c index 8b618ef0f711..0a4475ae931b 100644 --- a/drivers/spi/spi-cs42l43.c +++ b/drivers/spi/spi-cs42l43.c @@ -246,11 +246,10 @@ static size_t cs42l43_spi_max_length(struct spi_device *spi) return CS42L43_SPI_MAX_LENGTH; } -static bool cs42l43_has_sidecar(struct fwnode_handle *fwnode) +static struct fwnode_handle *cs42l43_find_xu_node(struct fwnode_handle *fwnode) { static const u32 func_smart_amp = 0x1; struct fwnode_handle *child_fwnode, *ext_fwnode; - unsigned int val; u32 function; int ret; @@ -266,21 +265,12 @@ static bool cs42l43_has_sidecar(struct fwnode_handle *fwnode) if (!ext_fwnode) continue; - ret = fwnode_property_read_u32(ext_fwnode, - "01fa-sidecar-instances", - &val); - - fwnode_handle_put(ext_fwnode); - - if (ret) - continue; - fwnode_handle_put(child_fwnode); - return !!val; + return ext_fwnode; } - return false; + return NULL; } static void cs42l43_release_of_node(void *data) @@ -298,7 +288,8 @@ static int cs42l43_spi_probe(struct platform_device *pdev) struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent); struct cs42l43_spi *priv; struct fwnode_handle *fwnode = dev_fwnode(cs42l43->dev); - bool has_sidecar = cs42l43_has_sidecar(fwnode); + struct fwnode_handle *xu_fwnode __free(fwnode_handle) = cs42l43_find_xu_node(fwnode); + int nsidecars = 0; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); @@ -350,7 +341,9 @@ static int cs42l43_spi_probe(struct platform_device *pdev) return ret; } - if (has_sidecar) { + fwnode_property_read_u32(xu_fwnode, "01fa-sidecar-instances", &nsidecars); + + if (nsidecars) { ret = software_node_register(&cs42l43_gpiochip_swnode); if (ret) return dev_err_probe(priv->dev, ret, @@ -373,7 +366,7 @@ static int cs42l43_spi_probe(struct platform_device *pdev) return dev_err_probe(priv->dev, ret, "Failed to register SPI controller\n"); - if (has_sidecar) { + if (nsidecars) { if (!spi_new_device(priv->ctlr, &l_info)) return dev_err_probe(priv->dev, -ENODEV, "Failed to create left amp slave\n"); From patchwork Tue Jun 11 13:25:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 804767 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id E65B817D8A0; Tue, 11 Jun 2024 13:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; cv=none; b=HcpmPT2+clRtx01/WNVJWX+CO4V2o1fzZ6OyvrF0tZn6Z2vSy5S3yTSr6xT6ocwu4WtXXL31yMZJUk9UVFgQLaiDHnQKo11AhnQeckywyioyCLNfKjd11JJusbdLYdzQYZQmvbOlURlS8a94TuEJfv5NOhqIuzcGS7IDoVtAsak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; c=relaxed/simple; bh=LMY+etQsozLuXx9o40Dtn0k1umd+GpgYM37h1yNZL3Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=put453OSc2R85/XcFJlfG9lLPsX4SDJXh/JxwSLf4EPh3dHQF8MVuo0hWe5PmXW2QqDWzLt3xb1QTmUsYdmq0bWbY9GBYQR9YjBlRP8K9UOAfO07EfyfGXN1zqqIokV5gMtkMpB444cZOQxcHbxITA2+wXj2LcK9I33Kl3TPZrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=B0Jd/mCw; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="B0Jd/mCw" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45B4c4Ku010402; Tue, 11 Jun 2024 08:25:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=DuurR0jE2iRLqiYyaQ5KjwGN5hMIK7uHSdNWCwP6haw=; b= B0Jd/mCwO4rGADGvFtWhqqB5mAK0T0LI786BA+KqbE59Cqwqgg52PZrIZsiwqQy2 WhXecr5Xsfot8Ybm9pDqVULO2CF96pko4ToZv9v+/HgP1IcN9B1bxGtma6XG3EvG Ztr7vW4yYijHi0r89ON/QDsWQ/x4ylwmFRHeS8tTChhfQ0e6Xw8BasuRljAy2C4+ b5NWoxPFzI+Bgj+eSx2v4pwyldbUmWJaYBP6x/LC5vkmfwt7mh64cNuPt31RmeEp 4U/W3bYPnB2BqiE7gq0f13CCMC/FALuZmRoDqBTTn0ssMi34ThkRQKjVdBNlEGPQ N3G3McmoE1M1wOxmmmnzVA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3ymkqhtuvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 08:25:58 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id B9312820249; Tue, 11 Jun 2024 13:25:56 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH 2/3] spi: cs42l43: Add speaker id support to the bridge configuration Date: Tue, 11 Jun 2024 14:25:55 +0100 Message-ID: <20240611132556.1557075-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240611132556.1557075-1-ckeepax@opensource.cirrus.com> References: <20240611132556.1557075-1-ckeepax@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: L_K7qD8R29fjxR3D-OoIjBIErxXYBm2b X-Proofpoint-ORIG-GUID: L_K7qD8R29fjxR3D-OoIjBIErxXYBm2b X-Proofpoint-Spam-Reason: safe From: Simon Trimmer OEMs can connect a number of types of speakers to the sidecar cs35l56 amplifiers and a different speaker requires a different firmware configuration. When the cs42l43 ACPI includes a property indicating a particular type of speaker has been installed this should be passed to the cs35l56 driver instances as a device property. Signed-off-by: Simon Trimmer Signed-off-by: Charles Keepax --- drivers/spi/spi-cs42l43.c | 74 ++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c index 0a4475ae931b..5b8ed65f8094 100644 --- a/drivers/spi/spi-cs42l43.c +++ b/drivers/spi/spi-cs42l43.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -44,28 +45,10 @@ static const unsigned int cs42l43_clock_divs[] = { 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 }; -static const struct software_node ampl = { - .name = "cs35l56-left", -}; - -static const struct software_node ampr = { - .name = "cs35l56-right", -}; - -static struct spi_board_info ampl_info = { +static struct spi_board_info amp_info_template = { .modalias = "cs35l56", .max_speed_hz = 11 * HZ_PER_MHZ, - .chip_select = 0, .mode = SPI_MODE_0, - .swnode = &l, -}; - -static struct spi_board_info ampr_info = { - .modalias = "cs35l56", - .max_speed_hz = 11 * HZ_PER_MHZ, - .chip_select = 1, - .mode = SPI_MODE_0, - .swnode = &r, }; static const struct software_node cs42l43_gpiochip_swnode = { @@ -273,6 +256,39 @@ static struct fwnode_handle *cs42l43_find_xu_node(struct fwnode_handle *fwnode) return NULL; } +static struct spi_board_info *cs42l43_create_bridge_amp(struct cs42l43_spi *priv, + const char * const name, + int cs, int spkid) +{ + struct property_entry *props = NULL; + struct software_node *swnode; + struct spi_board_info *info; + + if (spkid >= 0) { + props = devm_kmalloc(priv->dev, sizeof(*props), GFP_KERNEL); + if (!props) + return NULL; + + *props = PROPERTY_ENTRY_U32("cirrus,speaker-id", spkid); + } + + swnode = devm_kmalloc(priv->dev, sizeof(*swnode), GFP_KERNEL); + if (!swnode) + return NULL; + + *swnode = SOFTWARE_NODE(name, props, NULL); + + info = devm_kmemdup(priv->dev, &_info_template, + sizeof(amp_info_template), GFP_KERNEL); + if (!info) + return NULL; + + info->chip_select = cs; + info->swnode = swnode; + + return info; +} + static void cs42l43_release_of_node(void *data) { fwnode_handle_put(data); @@ -367,11 +383,27 @@ static int cs42l43_spi_probe(struct platform_device *pdev) "Failed to register SPI controller\n"); if (nsidecars) { - if (!spi_new_device(priv->ctlr, &l_info)) + struct spi_board_info *ampl_info; + struct spi_board_info *ampr_info; + int spkid = -EINVAL; + + fwnode_property_read_u32(xu_fwnode, "01fa-spk-id-val", &spkid); + + dev_dbg(priv->dev, "Found speaker ID %d\n", spkid); + + ampl_info = cs42l43_create_bridge_amp(priv, "cs35l56-left", 0, spkid); + if (!ampl_info) + return -ENOMEM; + + ampr_info = cs42l43_create_bridge_amp(priv, "cs35l56-right", 1, spkid); + if (!ampr_info) + return -ENOMEM; + + if (!spi_new_device(priv->ctlr, ampl_info)) return dev_err_probe(priv->dev, -ENODEV, "Failed to create left amp slave\n"); - if (!spi_new_device(priv->ctlr, &r_info)) + if (!spi_new_device(priv->ctlr, ampr_info)) return dev_err_probe(priv->dev, -ENODEV, "Failed to create right amp slave\n"); } From patchwork Tue Jun 11 13:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 803433 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 8238C17D358; Tue, 11 Jun 2024 13:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; cv=none; b=htS6RKCEormN41BVYecSf7or3Fqe/QW//M7eWKreBDXk2Lh8APUwnEt8XkVK9jmG05W/2cZIjya2n3Tp2bH0NyT9pE1Rzbx1j8bMgRhlTs6+pbkKZETn1xrpJTlMOZ4AHiazq2WrTaJ7AzjOBfFwwcep5h3Kl4atdZhOl1eFqV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112364; c=relaxed/simple; bh=08k+wAcbql/lsu9rymmUxtWIFDkESLOMHf5F/uImiHc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d83Bp7SwmCyJykqqDb1+7nnINRZEk0KiU6SRkwzucp+GM36hmj7oT6yfW95hCTfn0ZJ1Wm1Ys6uZq0RV9kqUGvLiT193HvDbysqO0ltWjdj7g0ZX7glOlRXbsPkkyeEDJSTtDF9p8Z0XoSM8/SqZQbL1SKoiPOIWl5uXcexO0Uc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=WwcsRWRV; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="WwcsRWRV" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45B5xVav021424; Tue, 11 Jun 2024 08:25:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=bY/YYO0JK9L565n9PzZjzHjTXNAAU0kC6wTI1GzcH0w=; b= WwcsRWRVwd8rPsDNmuSn+0cKb/iwfkFujmPNQUteJrI2iANNucTetADPI8eRGdyS WZlVnzpITd+2ttg+pWzkT/Q3+nFOZ3EC7BrHkbJK/TJFZ0Qvn6E0Og4sIda2QSVd E6NEe2lhDzrPlsOH9VB8gAf9i9PazdTWllcrZLuU9Z13bUiuk8OYfGjL52jCB713 2ptSPUJYHyaGpVDQE3tKzWGLVYSmVULsanv2SzHyjT2UNcHaKCZdQJFSbG3IL6vq JzCRLJ3N92o0CzLYLGW+fj96TNuorC8gnX95QlE8FxCDuJu82xZaCJolvKWk85Ni RmQT9NmV0CtCiO9+8PT7vQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3ymkqhtuva-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 08:25:58 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Tue, 11 Jun 2024 14:25:56 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id BDC9D82024A; Tue, 11 Jun 2024 13:25:56 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH 3/3] ASoC: cs35l56: Attempt to read from cirrus,speaker-id device property first Date: Tue, 11 Jun 2024 14:25:56 +0100 Message-ID: <20240611132556.1557075-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240611132556.1557075-1-ckeepax@opensource.cirrus.com> References: <20240611132556.1557075-1-ckeepax@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: cOWaB2ODgemJ1AfYcaeFaYYJTdZ059-H X-Proofpoint-ORIG-GUID: cOWaB2ODgemJ1AfYcaeFaYYJTdZ059-H X-Proofpoint-Spam-Reason: safe From: Simon Trimmer When cs35l56 is connected via cs42l43 there isn't an ACPI node for the cs35l56 so all properties are under the cs42l43 ACPI node. We're adding a property as a way for the cs42l43 driver to pass this info in via a software node. Signed-off-by: Simon Trimmer Signed-off-by: Charles Keepax --- sound/soc/codecs/cs35l56-shared.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 8af89a263594..e89027cd40d1 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -853,9 +853,16 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_hw_init, SND_SOC_CS35L56_SHARED); int cs35l56_get_speaker_id(struct cs35l56_base *cs35l56_base) { struct gpio_descs *descs; - int speaker_id; + u32 speaker_id; int i, ret; + /* Attempt to read the speaker type from a device property first */ + ret = device_property_read_u32(cs35l56_base->dev, "cirrus,speaker-id", &speaker_id); + if (!ret) { + dev_dbg(cs35l56_base->dev, "Speaker ID = %d\n", speaker_id); + return speaker_id; + } + /* Read the speaker type qualifier from the motherboard GPIOs */ descs = gpiod_get_array_optional(cs35l56_base->dev, "spk-id", GPIOD_IN); if (!descs) {