summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@nxp.com>2017-06-15 18:41:58 +0300
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:50:11 +0800
commit84b1aee36e7774268d5361eb611650f59602ba46 (patch)
tree295f7f99c9bca36c449e9d629811579e720562b0
parent1a88b02e51696210d8019a341eb2f7ea09e826b7 (diff)
MLK-14663-1: ASoC: fsl: imx-wm8960: Refactor GPR parsing
Refactor GPR handling into a function for easier adding support for non-gpr boards. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
-rw-r--r--sound/soc/fsl/imx-wm8960.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/sound/soc/fsl/imx-wm8960.c b/sound/soc/fsl/imx-wm8960.c
index 2594d256dfc6..f0e057761295 100644
--- a/sound/soc/fsl/imx-wm8960.c
+++ b/sound/soc/fsl/imx-wm8960.c
@@ -419,6 +419,32 @@ static struct snd_soc_dai_link imx_wm8960_dai[] = {
},
};
+static int of_parse_gpr(struct platform_device *pdev,
+ struct imx_wm8960_data *data)
+{
+ int ret;
+ struct of_phandle_args args;
+
+ ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
+ "gpr", 3, 0, &args);
+ if (ret) {
+ dev_warn(&pdev->dev, "failed to get gpr property\n");
+ return ret;
+ }
+
+ data->gpr = syscon_node_to_regmap(args.np);
+ if (IS_ERR(data->gpr)) {
+ ret = PTR_ERR(data->gpr);
+ dev_err(&pdev->dev, "failed to get gpr regmap\n");
+ return ret;
+ }
+
+ regmap_update_bits(data->gpr, args.args[0], args.args[1],
+ args.args[2]);
+
+ return 0;
+}
+
static int imx_wm8960_probe(struct platform_device *pdev)
{
struct device_node *cpu_np, *codec_np = NULL;
@@ -428,7 +454,6 @@ static int imx_wm8960_probe(struct platform_device *pdev)
struct imx_wm8960_data *data;
struct platform_device *asrc_pdev = NULL;
struct device_node *asrc_np;
- struct of_phandle_args args;
u32 width;
int ret;
@@ -478,19 +503,9 @@ static int imx_wm8960_probe(struct platform_device *pdev)
goto fail;
}
- ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node, "gpr", 3,
- 0, &args);
- if (ret) {
- dev_warn(&pdev->dev, "failed to get gpr property\n");
- } else {
- data->gpr = syscon_node_to_regmap(args.np);
- if (IS_ERR(data->gpr)) {
- ret = PTR_ERR(data->gpr);
- dev_err(&pdev->dev, "failed to get gpr regmap\n");
- goto fail;
- }
- regmap_update_bits(data->gpr, args.args[0], args.args[1], args.args[2]);
- }
+ ret = of_parse_gpr(pdev, data);
+ if (ret)
+ goto fail;
of_property_read_u32_array(pdev->dev.of_node, "hp-det", data->hp_det, 2);