From 4ccd4b4e747245c379c817ef7da2de254ff02c8b Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Tue, 27 Aug 2019 14:38:20 +0530 Subject: [PATCH] soc: pinctrl-lpi: Add support for audio HM voting for bengal On bengal target, audio core voting is not applicable. Add support for audio HM voting in pinctrl-lpi driver. Change-Id: I8661c981896c14899ca4d85f77507b417700b987 Signed-off-by: Laxminath Kasam --- soc/pinctrl-lpi.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/soc/pinctrl-lpi.c b/soc/pinctrl-lpi.c index 3aff320cee..4fc4cee6ea 100644 --- a/soc/pinctrl-lpi.c +++ b/soc/pinctrl-lpi.c @@ -110,6 +110,7 @@ struct lpi_gpio_state { struct gpio_chip chip; char __iomem *base; struct clk *lpass_core_hw_vote; + struct clk *lpass_audio_hw_vote; struct mutex slew_access_lock; bool core_hw_vote_status; struct mutex core_hw_vote_lock; @@ -616,6 +617,7 @@ static int lpi_pinctrl_probe(struct platform_device *pdev) char __iomem *slew_base; u32 reg, slew_reg; struct clk *lpass_core_hw_vote = NULL; + struct clk *lpass_audio_hw_vote = NULL; ret = of_property_read_u32(dev->of_node, "reg", ®); if (ret < 0) { @@ -771,6 +773,17 @@ static int lpi_pinctrl_probe(struct platform_device *pdev) } state->lpass_core_hw_vote = lpass_core_hw_vote; + /* Register LPASS audio hw vote */ + lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote"); + if (IS_ERR(lpass_audio_hw_vote)) { + ret = PTR_ERR(lpass_audio_hw_vote); + dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n", + __func__, "lpass_audio_hw_vote", ret); + lpass_audio_hw_vote = NULL; + ret = 0; + } + state->lpass_audio_hw_vote = lpass_audio_hw_vote; + state->core_hw_vote_status = false; pm_runtime_set_autosuspend_delay(&pdev->dev, LPI_AUTO_SUSPEND_DELAY); pm_runtime_use_autosuspend(&pdev->dev); @@ -817,14 +830,19 @@ int lpi_pinctrl_runtime_resume(struct device *dev) { struct lpi_gpio_state *state = dev_get_drvdata(dev); int ret = 0; + struct clk *hw_vote = state->lpass_core_hw_vote; if (state->lpass_core_hw_vote == NULL) { dev_dbg(dev, "%s: Invalid core hw node\n", __func__); - return 0; + if (state->lpass_audio_hw_vote == NULL) { + dev_dbg(dev, "%s: Invalid audio hw node\n", __func__); + return 0; + } + hw_vote = state->lpass_audio_hw_vote; } mutex_lock(&state->core_hw_vote_lock); - ret = clk_prepare_enable(state->lpass_core_hw_vote); + ret = clk_prepare_enable(hw_vote); if (ret < 0) { pm_runtime_set_autosuspend_delay(dev, LPI_AUTO_SUSPEND_DELAY_ERROR); @@ -845,15 +863,20 @@ exit: int lpi_pinctrl_runtime_suspend(struct device *dev) { struct lpi_gpio_state *state = dev_get_drvdata(dev); + struct clk *hw_vote = state->lpass_core_hw_vote; if (state->lpass_core_hw_vote == NULL) { dev_dbg(dev, "%s: Invalid core hw node\n", __func__); - return 0; + if (state->lpass_audio_hw_vote == NULL) { + dev_dbg(dev, "%s: Invalid audio hw node\n", __func__); + return 0; + } + hw_vote = state->lpass_audio_hw_vote; } mutex_lock(&state->core_hw_vote_lock); if (state->core_hw_vote_status) { - clk_disable_unprepare(state->lpass_core_hw_vote); + clk_disable_unprepare(hw_vote); state->core_hw_vote_status = false; } mutex_unlock(&state->core_hw_vote_lock);