ASoC: codecs: lpass-wsa-macro: add support for SM8550
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Mon, 27 Mar 2023 13:22:54 +0000 (15:22 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 29 Mar 2023 11:31:46 +0000 (12:31 +0100)
Add support for the WSA macro codec on Qualcomm SM8550.  SM8550 does not
use NPL clock, thus add flags allowing to skip it.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230327132254.147975-11-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/lpass-wsa-macro.c

index 728f26d12ab0ea105b69a9468b5f1a1951c8b68e..3cbcbfc219b262a7a1b98513a88409b6b6b8b306 100644 (file)
@@ -14,6 +14,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/of_platform.h>
 #include <sound/tlv.h>
+
+#include "lpass-macro-common.h"
 #include "lpass-wsa-macro.h"
 
 #define CDC_WSA_CLK_RST_CTRL_MCLK_CONTROL      (0x0000)
@@ -2346,7 +2348,10 @@ static int wsa_macro_register_mclk_output(struct wsa_macro *wsa)
        struct clk_init_data init;
        int ret;
 
-       parent_clk_name = __clk_get_name(wsa->npl);
+       if (wsa->npl)
+               parent_clk_name = __clk_get_name(wsa->npl);
+       else
+               parent_clk_name = __clk_get_name(wsa->mclk);
 
        init.name = "mclk";
        of_property_read_string(dev_of_node(dev), "clock-output-names",
@@ -2379,9 +2384,12 @@ static int wsa_macro_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct wsa_macro *wsa;
+       kernel_ulong_t flags;
        void __iomem *base;
        int ret;
 
+       flags = (kernel_ulong_t)device_get_match_data(dev);
+
        wsa = devm_kzalloc(dev, sizeof(*wsa), GFP_KERNEL);
        if (!wsa)
                return -ENOMEM;
@@ -2398,9 +2406,11 @@ static int wsa_macro_probe(struct platform_device *pdev)
        if (IS_ERR(wsa->mclk))
                return PTR_ERR(wsa->mclk);
 
-       wsa->npl = devm_clk_get(dev, "npl");
-       if (IS_ERR(wsa->npl))
-               return PTR_ERR(wsa->npl);
+       if (flags & LPASS_MACRO_FLAG_HAS_NPL_CLOCK) {
+               wsa->npl = devm_clk_get(dev, "npl");
+               if (IS_ERR(wsa->npl))
+                       return PTR_ERR(wsa->npl);
+       }
 
        wsa->fsgen = devm_clk_get(dev, "fsgen");
        if (IS_ERR(wsa->fsgen))
@@ -2551,10 +2561,21 @@ static const struct dev_pm_ops wsa_macro_pm_ops = {
 };
 
 static const struct of_device_id wsa_macro_dt_match[] = {
-       {.compatible = "qcom,sc7280-lpass-wsa-macro"},
-       {.compatible = "qcom,sm8250-lpass-wsa-macro"},
-       {.compatible = "qcom,sm8450-lpass-wsa-macro"},
-       {.compatible = "qcom,sc8280xp-lpass-wsa-macro" },
+       {
+               .compatible = "qcom,sc7280-lpass-wsa-macro",
+               .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK,
+       }, {
+               .compatible = "qcom,sm8250-lpass-wsa-macro",
+               .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK,
+       }, {
+               .compatible = "qcom,sm8450-lpass-wsa-macro",
+               .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK,
+       }, {
+               .compatible = "qcom,sm8550-lpass-wsa-macro",
+       }, {
+               .compatible = "qcom,sc8280xp-lpass-wsa-macro",
+               .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK,
+       },
        {}
 };
 MODULE_DEVICE_TABLE(of, wsa_macro_dt_match);