Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ccd4b4e authored by Laxminath Kasam's avatar Laxminath Kasam
Browse files

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: default avatarLaxminath Kasam <lkasam@codeaurora.org>
parent 3c19b495
Loading
Loading
Loading
Loading
+27 −4
Original line number Original line Diff line number Diff line
@@ -110,6 +110,7 @@ struct lpi_gpio_state {
	struct gpio_chip     chip;
	struct gpio_chip     chip;
	char __iomem        *base;
	char __iomem        *base;
	struct clk          *lpass_core_hw_vote;
	struct clk          *lpass_core_hw_vote;
	struct clk          *lpass_audio_hw_vote;
	struct mutex         slew_access_lock;
	struct mutex         slew_access_lock;
	bool core_hw_vote_status;
	bool core_hw_vote_status;
	struct mutex        core_hw_vote_lock;
	struct mutex        core_hw_vote_lock;
@@ -616,6 +617,7 @@ static int lpi_pinctrl_probe(struct platform_device *pdev)
	char __iomem *slew_base;
	char __iomem *slew_base;
	u32 reg, slew_reg;
	u32 reg, slew_reg;
	struct clk *lpass_core_hw_vote = NULL;
	struct clk *lpass_core_hw_vote = NULL;
	struct clk *lpass_audio_hw_vote = NULL;


	ret = of_property_read_u32(dev->of_node, "reg", &reg);
	ret = of_property_read_u32(dev->of_node, "reg", &reg);
	if (ret < 0) {
	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;
	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;
	state->core_hw_vote_status = false;
	pm_runtime_set_autosuspend_delay(&pdev->dev, LPI_AUTO_SUSPEND_DELAY);
	pm_runtime_set_autosuspend_delay(&pdev->dev, LPI_AUTO_SUSPEND_DELAY);
	pm_runtime_use_autosuspend(&pdev->dev);
	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);
	struct lpi_gpio_state *state = dev_get_drvdata(dev);
	int ret = 0;
	int ret = 0;
	struct clk *hw_vote = state->lpass_core_hw_vote;


	if (state->lpass_core_hw_vote == NULL) {
	if (state->lpass_core_hw_vote == NULL) {
		dev_dbg(dev, "%s: Invalid core hw node\n", __func__);
		dev_dbg(dev, "%s: Invalid core hw node\n", __func__);
		if (state->lpass_audio_hw_vote == NULL) {
			dev_dbg(dev, "%s: Invalid audio hw node\n", __func__);
			return 0;
			return 0;
		}
		}
		hw_vote = state->lpass_audio_hw_vote;
	}


	mutex_lock(&state->core_hw_vote_lock);
	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) {
	if (ret < 0) {
		pm_runtime_set_autosuspend_delay(dev,
		pm_runtime_set_autosuspend_delay(dev,
						 LPI_AUTO_SUSPEND_DELAY_ERROR);
						 LPI_AUTO_SUSPEND_DELAY_ERROR);
@@ -845,15 +863,20 @@ int lpi_pinctrl_runtime_resume(struct device *dev)
int lpi_pinctrl_runtime_suspend(struct device *dev)
int lpi_pinctrl_runtime_suspend(struct device *dev)
{
{
	struct lpi_gpio_state *state = dev_get_drvdata(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) {
	if (state->lpass_core_hw_vote == NULL) {
		dev_dbg(dev, "%s: Invalid core hw node\n", __func__);
		dev_dbg(dev, "%s: Invalid core hw node\n", __func__);
		if (state->lpass_audio_hw_vote == NULL) {
			dev_dbg(dev, "%s: Invalid audio hw node\n", __func__);
			return 0;
			return 0;
		}
		}
		hw_vote = state->lpass_audio_hw_vote;
	}


	mutex_lock(&state->core_hw_vote_lock);
	mutex_lock(&state->core_hw_vote_lock);
	if (state->core_hw_vote_status) {
	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;
		state->core_hw_vote_status = false;
	}
	}
	mutex_unlock(&state->core_hw_vote_lock);
	mutex_unlock(&state->core_hw_vote_lock);