Using bulk clocks and referencing them individually using array index is
not great for readers.
So move them to individual clocks handling and also remove some unnecessary
error handling in the code.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
int dec_mode[VA_MACRO_NUM_DECIMATORS];
struct regmap *regmap;
int dec_mode[VA_MACRO_NUM_DECIMATORS];
struct regmap *regmap;
- struct clk_bulk_data clks[VA_NUM_CLKS_MAX];
+ struct clk *mclk;
+ struct clk *macro;
+ struct clk *dcodec;
struct clk_hw hw;
s32 dmic_0_1_clk_cnt;
struct clk_hw hw;
s32 dmic_0_1_clk_cnt;
static int va_macro_register_fsgen_output(struct va_macro *va)
{
static int va_macro_register_fsgen_output(struct va_macro *va)
{
- struct clk *parent = va->clks[2].clk;
+ struct clk *parent = va->mclk;
struct device *dev = va->dev;
struct device_node *np = dev->of_node;
const char *parent_clk_name;
struct device *dev = va->dev;
struct device_node *np = dev->of_node;
const char *parent_clk_name;
return -ENOMEM;
va->dev = dev;
return -ENOMEM;
va->dev = dev;
- va->clks[0].id = "macro";
- va->clks[1].id = "dcodec";
- va->clks[2].id = "mclk";
- ret = devm_clk_bulk_get_optional(dev, VA_NUM_CLKS_MAX, va->clks);
- if (ret) {
- dev_err(dev, "Error getting VA Clocks (%d)\n", ret);
- return ret;
- }
+ va->macro = devm_clk_get_optional(dev, "macro");
+ if (IS_ERR(va->macro))
+ return PTR_ERR(va->macro);
+
+ va->dcodec = devm_clk_get_optional(dev, "dcodec");
+ if (IS_ERR(va->dcodec))
+ return PTR_ERR(va->dcodec);
+
+ va->mclk = devm_clk_get(dev, "mclk");
+ if (IS_ERR(va->mclk))
+ return PTR_ERR(va->mclk);
ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate",
&sample_rate);
ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate",
&sample_rate);
- /* mclk rate */
- clk_set_rate(va->clks[1].clk, VA_MACRO_MCLK_FREQ);
- ret = clk_bulk_prepare_enable(VA_NUM_CLKS_MAX, va->clks);
- if (ret)
- return ret;
-
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) {
ret = PTR_ERR(base);
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) {
ret = PTR_ERR(base);
}
dev_set_drvdata(dev, va);
}
dev_set_drvdata(dev, va);
- ret = va_macro_register_fsgen_output(va);
+
+ /* mclk rate */
+ clk_set_rate(va->mclk, 2 * VA_MACRO_MCLK_FREQ);
+
+ ret = clk_prepare_enable(va->macro);
+ ret = clk_prepare_enable(va->dcodec);
+ if (ret)
+ goto err_dcodec;
+
+ ret = clk_prepare_enable(va->mclk);
+ if (ret)
+ goto err_mclk;
+
+ ret = va_macro_register_fsgen_output(va);
+ if (ret)
+ goto err_clkout;
+
ret = devm_snd_soc_register_component(dev, &va_macro_component_drv,
va_macro_dais,
ARRAY_SIZE(va_macro_dais));
if (ret)
ret = devm_snd_soc_register_component(dev, &va_macro_component_drv,
va_macro_dais,
ARRAY_SIZE(va_macro_dais));
if (ret)
+err_clkout:
+ clk_disable_unprepare(va->mclk);
+err_mclk:
+ clk_disable_unprepare(va->dcodec);
+err_dcodec:
+ clk_disable_unprepare(va->macro);
- clk_bulk_disable_unprepare(VA_NUM_CLKS_MAX, va->clks);
-
{
struct va_macro *va = dev_get_drvdata(&pdev->dev);
{
struct va_macro *va = dev_get_drvdata(&pdev->dev);
- clk_bulk_disable_unprepare(VA_NUM_CLKS_MAX, va->clks);
+ clk_disable_unprepare(va->mclk);
+ clk_disable_unprepare(va->dcodec);
+ clk_disable_unprepare(va->macro);