Commit 6789b5d0 authored by Alexey Mednyy's avatar Alexey Mednyy 🆖

fix freescale IPUV3 suspend/wakeup logic

parent 7717246b
......@@ -544,6 +544,8 @@ int ipu_idmac_enable_channel(struct ipuv3_channel *channel)
val |= idma_mask(channel->num);
ipu_idmac_write(ipu, val, IDMAC_CHA_EN(channel->num));
channel->enabled = true;
spin_unlock_irqrestore(&ipu->lock, flags);
return 0;
......@@ -626,6 +628,8 @@ int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
val &= ~idma_mask(channel->num);
ipu_cm_write(ipu, val, IPU_CHA_DB_MODE_SEL(channel->num));
channel->enabled = false;
spin_unlock_irqrestore(&ipu->lock, flags);
return 0;
......@@ -1344,10 +1348,54 @@ static int ipu_remove(struct platform_device *pdev)
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int ipu_suspend(struct device *dev)
{
struct ipu_soc *ipu = dev_get_drvdata(dev);
struct ipuv3_channel *channel;
int i;
channel = ipu->channel;
for (i = 0; i < ARRAY_SIZE(ipu->channel); i++, channel++) {
channel->suspended = false;
if (channel->enabled) {
if (ipu_idmac_wait_busy(channel, 50))
dev_warn(dev,
"%s: Timeout channel %d idle\n",
__func__, i);
ipu_idmac_disable_channel(channel);
channel->suspended = true;
}
}
return 0;
}
static int ipu_resume(struct device *dev)
{
struct ipu_soc *ipu = dev_get_drvdata(dev);
struct ipuv3_channel *channel;
int i;
channel = ipu->channel;
for (i = 0; i < ARRAY_SIZE(ipu->channel); i++, channel++) {
if (channel->suspended) {
ipu_idmac_enable_channel(channel);
channel->suspended = false;
}
}
return 0;
}
#endif
static SIMPLE_DEV_PM_OPS(ipu_pm_ops, ipu_suspend, ipu_resume);
static struct platform_driver imx_ipu_driver = {
.driver = {
.name = "imx-ipuv3",
.of_match_table = imx_ipu_dt_ids,
.pm = &ipu_pm_ops,
},
.probe = ipu_probe,
.remove = ipu_remove,
......
......@@ -128,6 +128,7 @@ struct ipuv3_channel {
bool enabled;
bool busy;
bool suspended;
struct ipu_soc *ipu;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment