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

Commit d9e3661c authored by Banajit Goswami's avatar Banajit Goswami
Browse files

soundwire: turn soundwire device off if device is down



When Soundwire master device down callback is called, rather
than calling device suspend, call device down and turn off
clock.

Change-Id: I0c9b2b5cd3b816a6bb840309c588e02cf5ebb7c8
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent 77813844
Loading
Loading
Loading
Loading
+28 −1
Original line number Original line Diff line number Diff line
@@ -1224,6 +1224,33 @@ exit:
}
}
#endif /* CONFIG_PM_RUNTIME */
#endif /* CONFIG_PM_RUNTIME */


static int swrm_device_down(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct swr_mstr_ctrl *swrm = platform_get_drvdata(pdev);
	int ret = 0;
	struct swr_master *mstr = &swrm->master;
	struct swr_device *swr_dev;

	dev_dbg(dev, "%s: swrm state: %d\n", __func__, swrm->state);
	mutex_lock(&swrm->reslock);
	if ((swrm->state == SWR_MSTR_RESUME) ||
	    (swrm->state == SWR_MSTR_UP)) {
		list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
			ret = swr_device_down(swr_dev);
			if (ret)
				dev_err(dev,
					"%s: failed to shutdown swr dev %d\n",
					__func__, swr_dev->dev_num);
		}
		dev_dbg(dev, "%s: Shutting down SWRM\n", __func__);
		pm_runtime_set_suspended(dev);
		swrm_clk_request(swrm, false);
	}
	mutex_unlock(&swrm->reslock);
	return ret;
}

/**
/**
 * swrm_wcd_notify - parent device can notify to soundwire master through
 * swrm_wcd_notify - parent device can notify to soundwire master through
 * this function
 * this function
@@ -1266,7 +1293,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
			dev_dbg(swrm->dev, "%s: SWR master is already Down: %d\n",
			dev_dbg(swrm->dev, "%s: SWR master is already Down: %d\n",
				__func__, swrm->state);
				__func__, swrm->state);
		else
		else
			swrm_runtime_suspend(&pdev->dev);
			swrm_device_down(&pdev->dev);
		mutex_unlock(&swrm->mlock);
		mutex_unlock(&swrm->mlock);
		break;
		break;
	case SWR_DEVICE_UP:
	case SWR_DEVICE_UP: