From a2b1175131ccb5d4a15456f4f31836356abbce09 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 26 Aug 2014 10:52:53 +0200 Subject: ARM: common: edma: add suspend resume hook This patch makes the edma driver resume correctly after suspend. Tested on an AM33xx platform with cyclic audio streams and omap_hsmmc. All information can be reconstructed by already known runtime information. As we now use some functions that were previously only used from __init context, annotations had to be dropped. [nm@ti.com: added error handling for runtime + suspend_late/early_resume] Signed-off-by: Nishanth Menon Signed-off-by: Daniel Mack Tested-by: Joel Fernandes Acked-by: Joel Fernandes [nsekhar@ti.com: remove unneeded pm_runtime_get_sync() from resume] Signed-off-by: Sekhar Nori --- arch/arm/common/edma.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index d86771abbf57..79de6a23047b 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -244,6 +244,8 @@ struct edma { /* list of channels with no even trigger; terminated by "-1" */ const s8 *noevent; + struct edma_soc_info *info; + /* The edma_inuse bit for each PaRAM slot is clear unless the * channel is in use ... by ARM or DSP, for QDMA, or whatever. */ @@ -295,7 +297,7 @@ static void map_dmach_queue(unsigned ctlr, unsigned ch_no, ~(0x7 << bit), queue_no << bit); } -static void __init assign_priority_to_queue(unsigned ctlr, int queue_no, +static void assign_priority_to_queue(unsigned ctlr, int queue_no, int priority) { int bit = queue_no * 4; @@ -314,7 +316,7 @@ static void __init assign_priority_to_queue(unsigned ctlr, int queue_no, * included in that particular EDMA variant (Eg : dm646x) * */ -static void __init map_dmach_param(unsigned ctlr) +static void map_dmach_param(unsigned ctlr) { int i; for (i = 0; i < EDMA_MAX_DMACH; i++) @@ -1792,15 +1794,61 @@ static int edma_probe(struct platform_device *pdev) edma_write_array2(j, EDMA_DRAE, i, 1, 0x0); edma_write_array(j, EDMA_QRAE, i, 0x0); } + edma_cc[j]->info = info[j]; arch_num_cc++; } return 0; } +static int edma_pm_resume(struct device *dev) +{ + int i, j; + + for (j = 0; j < arch_num_cc; j++) { + struct edma *cc = edma_cc[j]; + + s8 (*queue_priority_mapping)[2]; + + queue_priority_mapping = cc->info->queue_priority_mapping; + + /* Event queue priority mapping */ + for (i = 0; queue_priority_mapping[i][0] != -1; i++) + assign_priority_to_queue(j, + queue_priority_mapping[i][0], + queue_priority_mapping[i][1]); + + /* + * Map the channel to param entry if channel mapping logic + * exist + */ + if (edma_read(j, EDMA_CCCFG) & CHMAP_EXIST) + map_dmach_param(j); + + for (i = 0; i < cc->num_channels; i++) { + if (test_bit(i, cc->edma_inuse)) { + /* ensure access through shadow region 0 */ + edma_or_array2(j, EDMA_DRAE, 0, i >> 5, + BIT(i & 0x1f)); + + setup_dma_interrupt(i, + cc->intr_data[i].callback, + cc->intr_data[i].data); + } + } + } + + return 0; +} + +static const struct dev_pm_ops edma_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(NULL, edma_pm_resume) +}; + static struct platform_driver edma_driver = { .driver = { .name = "edma", + .pm = &edma_pm_ops, .of_match_table = edma_of_ids, }, .probe = edma_probe, -- cgit v1.2.3 From a850c427029e5b9953fe4d4fe4fef10a61ee165a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 21 Nov 2014 11:48:54 +0100 Subject: ARM: common: edma: edma_pm_resume may be unused The recently introduced resume hook in the edma driver is not referenced when CONFIG_PM_SLEEP is not set, which results in a compile warning in keystone builds. This adds an appropriate #ifdef. Cc: Nishanth Menon Cc: Daniel Mack Cc: Joel Fernandes Acked-by: Sekhar Nori Fixes: a2b1175131: ("ARM: common: edma: add suspend resume hook") Signed-off-by: Arnd Bergmann --- arch/arm/common/edma.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/arm/common') diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 79de6a23047b..e093f2fcee7a 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -1801,6 +1801,7 @@ static int edma_probe(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP static int edma_pm_resume(struct device *dev) { int i, j; @@ -1840,6 +1841,7 @@ static int edma_pm_resume(struct device *dev) return 0; } +#endif static const struct dev_pm_ops edma_pm_ops = { SET_LATE_SYSTEM_SLEEP_PM_OPS(NULL, edma_pm_resume) -- cgit v1.2.3