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>
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user