From patchwork Wed Oct 14 14:54:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 1382198 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=gxZOPXc8; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CBFnb2KH8z9sTK for ; Thu, 15 Oct 2020 01:54:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729782AbgJNOyv (ORCPT ); Wed, 14 Oct 2020 10:54:51 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:32428 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728965AbgJNOyv (ORCPT ); Wed, 14 Oct 2020 10:54:51 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 09EEpi80023902; Wed, 14 Oct 2020 09:54:35 -0500 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=bBy5LfwwfVhr4zvv5l4NPCrI6nTVQPaTkMub+rmgFxk=; b=gxZOPXc8QwDEzQqDTGtZbO5DfO6DSKg+wjfE1X9m3Bqe5hzADmst5JyK5K0XYS6fhCaU SmlanPYY1A7gJC5tKEzR5BUK3vZMf+f1njexcHG2YBsrOplWcxFaJDcditMVeEXIfZBg 6IjOTvyJ4agKeJjeLJyeSFI8nnkx1PCFtsetW9LZS9jnYmBQMCAClQu2eHBfIGmnMs5b 4+IBphedy5ZKDiPnnhWozco20jY7YdJKrJFmEMy4SsPD7pDGMGTdl9NgLp6ZLh8FvGK9 AmueFfVuC7HQj+hDMOTmCbrC4fjQd7AzBV2WGrLWMQOTFC0KGJkA75TzW/sDCbp90MPi Dg== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 343ac1wbwc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 14 Oct 2020 09:54:35 -0500 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.1913.5; Wed, 14 Oct 2020 15:54:33 +0100 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.1913.5 via Frontend Transport; Wed, 14 Oct 2020 15:54:33 +0100 Received: from AUSNPC0LSNW1-debian.ad.cirrus.com (ausnpc0lsnw1.ad.cirrus.com [198.61.64.143]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id A86102AA; Wed, 14 Oct 2020 14:54:32 +0000 (UTC) From: Richard Fitzgerald To: , , CC: , , , , , , Richard Fitzgerald Subject: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args() Date: Wed, 14 Oct 2020 15:54:12 +0100 Message-ID: <20201014145418.31838-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201014145418.31838-1-rf@opensource.cirrus.com> References: <20201014145418.31838-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010140108 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add an equivalent of of_count_phandle_with_args() for fixed argument sets, to pair with of_parse_phandle_with_fixed_args(). Signed-off-by: Richard Fitzgerald --- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index ea44fea99813..45d8b0e65345 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na } EXPORT_SYMBOL(of_count_phandle_with_args); +/** + * of_count_phandle_with_fixed_args() - Find the number of phandles references in a property + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cell_count: number of argument cells following the phandle + * + * Returns the number of phandle + argument tuples within a property. It + * is a typical pattern to encode a list of phandle and variable + * arguments into a single property. + */ +int of_count_phandle_with_fixed_args(const struct device_node *np, + const char *list_name, + int cells_count) +{ + struct of_phandle_iterator it; + int rc, cur_index = 0; + + if (!cells_count) { + const __be32 *list; + int size; + + list = of_get_property(np, list_name, &size); + if (!list) + return -ENOENT; + + return size / sizeof(*list); + } + + rc = of_phandle_iterator_init(&it, np, list_name, NULL, cells_count); + if (rc) + return rc; + + while ((rc = of_phandle_iterator_next(&it)) == 0) + cur_index += 1; + + if (rc != -ENOENT) + return rc; + + return cur_index; +} +EXPORT_SYMBOL(of_count_phandle_with_fixed_args); + /** * __of_add_property - Add a property to a node without lock operations */ diff --git a/include/linux/of.h b/include/linux/of.h index 5cf7ae0465d1..9f315da4e9da 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -377,6 +377,8 @@ extern int of_parse_phandle_with_fixed_args(const struct device_node *np, struct of_phandle_args *out_args); extern int of_count_phandle_with_args(const struct device_node *np, const char *list_name, const char *cells_name); +extern int of_count_phandle_with_fixed_args(const struct device_node *np, + const char *list_name, int cells_count); /* phandle iterator functions */ extern int of_phandle_iterator_init(struct of_phandle_iterator *it, @@ -886,6 +888,13 @@ static inline int of_count_phandle_with_args(struct device_node *np, return -ENOSYS; } +static inline int of_count_phandle_with_fixed_args(const struct device_node *np, + const char *list_name, + int cells_count) +{ + return -ENOSYS; +} + static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, const struct device_node *np, const char *list_name, From patchwork Wed Oct 14 14:54:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 1382200 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=eabBocoK; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CBFp15Lljz9sTK for ; Thu, 15 Oct 2020 01:55:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731512AbgJNOzG (ORCPT ); Wed, 14 Oct 2020 10:55:06 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:20382 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729019AbgJNOyv (ORCPT ); Wed, 14 Oct 2020 10:54:51 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 09EEpi81023902; Wed, 14 Oct 2020 09:54:36 -0500 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=9XWilk56wxWCD+dN2HKKYxzBT3c3C3CzLDThlC0mYw4=; b=eabBocoKBbHpL8CBnl6EQsJ3xicnEwn4bHygmuM5SMyZaLd4gkz1FlRkjur/diDqQzPm xFvLPz4nSXxiyOAXV8704aG5rbXHkEng26U5nli7d3VNwgdd1OJVaNHw8OtlJNLM+dOT MzhYomqOEVKz4s5PBFaiKJOjxmr4qCPrAXtOVUeGybdaOvrV+lKNHNtEzyx7aMyamdkN o0ddqs0fwzY4drDsmgP08hyeTbgeZO0g3VvJ5yIps+fjaFNhHWk3rJJXgWOSNJBwU0ya bbzem/M9rAIk7K3IuIQIoEHnTlUmpX9C6pd7jkx6MBWO8G1Adeektg7hsfdwZpsh54nN JQ== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 343ac1wbwc-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 14 Oct 2020 09:54:35 -0500 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.1913.5; Wed, 14 Oct 2020 15:54:33 +0100 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.1913.5 via Frontend Transport; Wed, 14 Oct 2020 15:54:33 +0100 Received: from AUSNPC0LSNW1-debian.ad.cirrus.com (ausnpc0lsnw1.ad.cirrus.com [198.61.64.143]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2DC7A2C1; Wed, 14 Oct 2020 14:54:33 +0000 (UTC) From: Richard Fitzgerald To: , , CC: , , , , , , Richard Fitzgerald Subject: [PATCH 2/7] ASoC: simple-card: Add plls and sysclks DT schema Date: Wed, 14 Oct 2020 15:54:13 +0100 Message-ID: <20201014145418.31838-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201014145418.31838-1-rf@opensource.cirrus.com> References: <20201014145418.31838-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=706 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010140108 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This adds the two new properties 'plls' and 'sysclks' to the dt bindings schema document. These add the ability to set values that will be passed to snd_soc_component_set_sysclk() and snd_soc_component_set_pll(). Signed-off-by: Richard Fitzgerald --- .../bindings/sound/simple-card.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml index 35e669020296..48c9a4313d58 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.yaml +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml @@ -92,6 +92,25 @@ definitions: description: the widget names for which pin switches must be created. $ref: /schemas/types.yaml#/definitions/string-array + plls: + description: | + A list of component pll settings that will be applied with + snd_soc_component_set_pll. Each entry is a phandle to the node of the + codec or cpu component, followed by the four arguments id, source, + frequency_in, frequency_out. Multiple entries can have the same phandle + so that several plls can be set in the same component. + $ref: /schemas/types.yaml#/definitions/phandle-array + + sysclks: + description: | + A list of component sysclk settings that will be applied with + snd_soc_component_set_sysclk. Each entry is a phandle to the node of + the codec or cpu component, followed by the four arguments id, source, + frequency, direction. Direction is 0 if the clock is an input, 1 if it + is an output. Multiple entries can have the same phandle so that several + clocks can be set in the same component. + $ref: /schemas/types.yaml#/definitions/phandle-array + format: description: audio format. items: @@ -192,6 +211,10 @@ patternProperties: $ref: "#/definitions/prefix" "^simple-audio-card,pin-switches$": $ref: "#/definitions/pin-switches" + "^simple-audio-card,plls$": + $ref: "#/definitions/plls" + "^simple-audio-card,sysclks$": + $ref: "#/definitions/sysclks" "^simple-audio-card,hp-det-gpio$": maxItems: 1 "^simple-audio-card,mic-det-gpio$": @@ -489,3 +512,36 @@ examples: }; }; }; + +#-------------------- +# Codec with component PLL and SYSCLK settings +#-------------------- + - | + sound { + compatible = "simple-audio-card"; + + simple-audio-card,plls = < + &cs47l15 1 1 32768 98304000 + >; + + simple-audio-card,sysclks = < + &cs47l15 1 4 98304000 0 + &cs47l15 8 4 147456000 0 + >; + + simple-audio-card,format = "i2s"; + simple-audio-card,bitclock-master = <&cs47l15_codec_dai>; + simple-audio-card,frame-master = <&cs47l15_codec_dai>; + + simple-audio-card,cpu { + sound-dai = <&axi_i2s0 0>; + }; + + cs47l15_codec_dai: simple-audio-card,codec { + sound-dai = <&cs47l15 0>; + + /* Disable dai_set_sysclk() */ + system-clock-frequency = <0>; + mclk-fs = <0>; + }; + };