summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@nxp.com>2017-06-15 18:41:58 +0300
committerDaniel Baluta <daniel.baluta@nxp.com>2017-06-20 10:30:40 +0300
commitc79a82aec8ccf11fd9eae7776b8172bb20f1e595 (patch)
tree38fd685bde717f803f7828b9ea060163202aa3d9
parent89869792e2f59c81354f9a53280c4eb6e95f4a9a (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 c82134e19c2a..58f0bedcd429 100644
--- a/sound/soc/fsl/imx-wm8960.c
+++ b/sound/soc/fsl/imx-wm8960.c
@@ -421,6 +421,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;
@@ -430,7 +456,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;
@@ -480,19 +505,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);