Skip to content

Commit 3f3fdf7

Browse files
author
Marcin Maka
committed
plat: apl: clocks gated back on topology free
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
1 parent ccaff5c commit 3f3fdf7

18 files changed

Lines changed: 233 additions & 33 deletions

File tree

src/audio/dai.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
186186

187187
comp_set_drvdata(dev, dd);
188188

189-
dd->dai = dai_get(dai->type, dai->dai_index);
189+
dd->dai = dai_get(dai->type, dai->dai_index, DAI_CREAT);
190190
if (dd->dai == NULL) {
191191
trace_dai_error("eDg");
192192
goto error;
@@ -237,6 +237,9 @@ static void dai_free(struct comp_dev *dev)
237237
struct dai_data *dd = comp_get_drvdata(dev);
238238

239239
dma_channel_put(dd->dma, dd->chan);
240+
dma_put(dd->dma);
241+
242+
dai_put(dd->dai);
240243

241244
rfree(dd);
242245
rfree(dev);

src/audio/host.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ static void host_free(struct comp_dev *dev)
398398
#if !defined CONFIG_DMA_GW
399399
dma_channel_put(hd->dma, hd->chan);
400400
#endif
401+
dma_put(hd->dma);
401402

402403
dma_sg_free(&hd->config.elem_array);
403404
rfree(hd);

src/drivers/intel/cavs/dmic.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,19 +1475,34 @@ static int dmic_probe(struct dai *dai)
14751475
return 0;
14761476
}
14771477

1478+
static int dmic_remove(struct dai *dai)
1479+
{
1480+
interrupt_disable(dmic_irq(dai));
1481+
platform_interrupt_mask(dmic_irq(dai), 0);
1482+
interrupt_unregister(dmic_irq(dai));
1483+
1484+
pm_runtime_put_sync(DMIC_CLK, dai->index);
1485+
1486+
rfree(dma_get_drvdata(dai));
1487+
dai_set_drvdata(dai, NULL);
1488+
1489+
return 0;
1490+
}
1491+
14781492
/* DMIC has no loopback support */
14791493
static inline int dmic_set_loopback_mode(struct dai *dai, uint32_t lbm)
14801494
{
14811495
return -EINVAL;
14821496
}
14831497

14841498
const struct dai_ops dmic_ops = {
1485-
.trigger = dmic_trigger,
1486-
.set_config = dmic_set_config,
1487-
.pm_context_store = dmic_context_store,
1488-
.pm_context_restore = dmic_context_restore,
1489-
.probe = dmic_probe,
1490-
.set_loopback_mode = dmic_set_loopback_mode,
1499+
.trigger = dmic_trigger,
1500+
.set_config = dmic_set_config,
1501+
.pm_context_store = dmic_context_store,
1502+
.pm_context_restore = dmic_context_restore,
1503+
.probe = dmic_probe,
1504+
.remove = dmic_remove,
1505+
.set_loopback_mode = dmic_set_loopback_mode,
14911506
};
14921507

14931508
#endif

src/drivers/intel/cavs/hda-dma.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,13 @@ static int hda_dma_probe(struct dma *dma)
633633
return 0;
634634
}
635635

636+
static int hda_dma_remove(struct dma *dma)
637+
{
638+
rfree(dma_get_drvdata(dma));
639+
dma_set_drvdata(dma, NULL);
640+
return 0;
641+
}
642+
636643
const struct dma_ops hda_host_dma_ops = {
637644
.channel_get = hda_dma_channel_get,
638645
.channel_put = hda_dma_channel_put,
@@ -647,6 +654,7 @@ const struct dma_ops hda_host_dma_ops = {
647654
.pm_context_restore = hda_dma_pm_context_restore,
648655
.pm_context_store = hda_dma_pm_context_store,
649656
.probe = hda_dma_probe,
657+
.remove = hda_dma_remove,
650658
};
651659

652660
const struct dma_ops hda_link_dma_ops = {
@@ -663,5 +671,6 @@ const struct dma_ops hda_link_dma_ops = {
663671
.pm_context_restore = hda_dma_pm_context_restore,
664672
.pm_context_store = hda_dma_pm_context_store,
665673
.probe = hda_dma_probe,
674+
.remove = hda_dma_remove,
666675
};
667676

src/drivers/intel/cavs/hda.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ const struct dai_ops hda_ops = {
5858
.pm_context_store = hda_dummy,
5959
.pm_context_restore = hda_dummy,
6060
.probe = hda_dummy,
61+
.remove = hda_dummy,
6162
.set_loopback_mode = hda_set_loopback_mode
6263
};

src/drivers/intel/cavs/ssp.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,26 @@ static int ssp_probe(struct dai *dai)
893893
return 0;
894894
}
895895

896+
static int ssp_remove(struct dai *dai)
897+
{
898+
interrupt_disable(ssp_irq(dai));
899+
platform_interrupt_mask(ssp_irq(dai), 0);
900+
interrupt_unregister(ssp_irq(dai));
901+
902+
pm_runtime_put_sync(SSP_CLK, dai->index);
903+
904+
rfree(dma_get_drvdata(dai));
905+
dai_set_drvdata(dai, NULL);
906+
907+
return 0;
908+
}
909+
896910
const struct dai_ops ssp_ops = {
897911
.trigger = ssp_trigger,
898912
.set_config = ssp_set_config,
899913
.pm_context_store = ssp_context_store,
900914
.pm_context_restore = ssp_context_restore,
901915
.probe = ssp_probe,
916+
.remove = ssp_remove,
902917
.set_loopback_mode = ssp_set_loopback_mode,
903918
};

src/drivers/intel/dw-dma.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,14 @@ static int dw_dma_probe(struct dma *dma)
12991299
return 0;
13001300
}
13011301

1302+
static int dw_dma_remove(struct dma *dma)
1303+
{
1304+
pm_runtime_put_sync(DW_DMAC_CLK, dma->plat_data.id);
1305+
rfree(dma_get_drvdata(dma));
1306+
dma_set_drvdata(dma, NULL);
1307+
return 0;
1308+
}
1309+
13021310
const struct dma_ops dw_dma_ops = {
13031311
.channel_get = dw_dma_channel_get,
13041312
.channel_put = dw_dma_channel_put,
@@ -1312,4 +1320,5 @@ const struct dma_ops dw_dma_ops = {
13121320
.pm_context_restore = dw_dma_pm_context_restore,
13131321
.pm_context_store = dw_dma_pm_context_store,
13141322
.probe = dw_dma_probe,
1323+
.remove = dw_dma_remove,
13151324
};

src/host/common_test.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,24 @@ int get_index_by_type(uint32_t comp_type,
223223

224224
/* The following definitions are to satisfy libsof linker errors */
225225

226-
struct dai *dai_get(uint32_t type, uint32_t index)
226+
struct dai *dai_get(uint32_t type, uint32_t index, uint32_t flags)
227227
{
228228
return NULL;
229229
}
230230

231+
void dai_put(struct dai *dai)
232+
{
233+
}
234+
231235
struct dma *dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags)
232236
{
233237
return NULL;
234238
}
235239

240+
void dma_put(struct dma *dma)
241+
{
242+
}
243+
236244
int dma_sg_alloc(struct dma_sg_elem_array *elem_array,
237245
int zone,
238246
uint32_t direction,

src/include/sof/dai.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@
6363
#define DAI_NUM_SLOT_MAPS 8
6464

6565
/* DAI flags */
66-
#define DAI_FLAGS_IRQ_CB (1 << 0) /* irq used for copy() timer */
6766

67+
/** \brief IRQ used for copy() timer */
68+
#define DAI_FLAGS_IRQ_CB BIT(0)
69+
70+
/* DAI get() flags */
71+
72+
/** \brief If the device does not exist it will be created */
73+
#define DAI_CREAT BIT(0)
6874

6975
struct dai;
7076

@@ -77,6 +83,7 @@ struct dai_ops {
7783
int (*pm_context_restore)(struct dai *dai);
7884
int (*pm_context_store)(struct dai *dai);
7985
int (*probe)(struct dai *dai);
86+
int (*remove)(struct dai *dai);
8087
int (*set_loopback_mode)(struct dai *dai, uint32_t lbm);
8188
};
8289

@@ -140,8 +147,16 @@ void dai_install(struct dai_type_info *dai_type_array, size_t num_dai_types);
140147
*
141148
* \param[in] type Type of requested DAI.
142149
* \param[in] index Index of requested DAI.
150+
* \param[in] flags Flags (CREATE)
151+
*/
152+
struct dai *dai_get(uint32_t type, uint32_t index, uint32_t flags);
153+
154+
/**
155+
* \brief API to release a platform DAI.
156+
*
157+
* @param[in] dai DAI to relese.
143158
*/
144-
struct dai *dai_get(uint32_t type, uint32_t index);
159+
void dai_put(struct dai *dai);
145160

146161
#define dai_set_drvdata(dai, data) \
147162
dai->private = data;
@@ -203,6 +218,14 @@ static inline int dai_probe(struct dai *dai)
203218
return dai->ops->probe(dai);
204219
}
205220

221+
/**
222+
* \brief Digital Audio interface Remove
223+
*/
224+
static inline int dai_remove(struct dai *dai)
225+
{
226+
return dai->ops->remove(dai);
227+
}
228+
206229
/** @}*/
207230

208231
#endif

src/include/sof/dma.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct dma_ops {
154154
int (*pm_context_store)(struct dma *dma);
155155

156156
int (*probe)(struct dma *dma);
157+
int (*remove)(struct dma *dma);
157158
};
158159

159160
/* DMA platform data */
@@ -198,6 +199,13 @@ void dma_install(struct dma *dma_array, size_t num_dmas);
198199
*/
199200
struct dma *dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags);
200201

202+
/**
203+
* \brief API to release a platform DMAC.
204+
*
205+
* @param[in] dma DMAC to relese.
206+
*/
207+
void dma_put(struct dma *dma);
208+
201209
#define dma_set_drvdata(dma, data) \
202210
dma->private = data;
203211
#define dma_get_drvdata(dma) \
@@ -292,6 +300,11 @@ static inline int dma_probe(struct dma *dma)
292300
return dma->ops->probe(dma);
293301
}
294302

303+
static inline int dma_remove(struct dma *dma)
304+
{
305+
return dma->ops->remove(dma);
306+
}
307+
295308
static inline void dma_sg_init(struct dma_sg_elem_array *ea)
296309
{
297310
ea->count = 0;

0 commit comments

Comments
 (0)