Skip to content

Commit b2f0887

Browse files
tlaudalgirdwood
authored andcommitted
dw-dma: enable channel linear link position
Enables DW-DMA channel linear link position counter based on the selected peripheral connection. It can be used to retrieve timestamping information on platforms supporting it. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
1 parent d343039 commit b2f0887

File tree

4 files changed

+67
-0
lines changed
  • src

4 files changed

+67
-0
lines changed

src/drivers/dw/dma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ static int dw_dma_start(struct dma_chan_data *channel)
267267
/* assign core */
268268
channel->core = cpu_get_id();
269269

270+
/* enable linear link position */
271+
platform_dw_dma_llp_enable(dma, channel);
272+
270273
/* enable the channel */
271274
channel->status = COMP_STATE_ACTIVE;
272275
dma_reg_write(dma, DW_DMA_CHAN_EN, DW_CHAN_UNMASK(channel->index));
@@ -393,6 +396,9 @@ static int dw_dma_stop(struct dma_chan_data *channel)
393396
sizeof(struct dw_lli) * channel->desc_count);
394397
#endif
395398

399+
/* disable linear link position */
400+
platform_dw_dma_llp_disable(dma, channel);
401+
396402
channel->status = COMP_STATE_PREPARE;
397403

398404
out:
@@ -633,6 +639,8 @@ static int dw_dma_set_config(struct dma_chan_data *channel,
633639
dw_chan->cfg_lo |= DW_CFG_RELOAD_DST;
634640
#endif
635641
dw_chan->cfg_hi |= DW_CFGH_DST(config->dest_dev);
642+
platform_dw_dma_llp_config(channel->dma, channel,
643+
config->dest_dev);
636644
break;
637645
case DMA_DIR_DEV_TO_MEM:
638646
lli_desc->ctrl_lo |= DW_CTLL_FC_P2M | DW_CTLL_SRC_FIX |
@@ -648,6 +656,8 @@ static int dw_dma_set_config(struct dma_chan_data *channel,
648656
dw_chan->cfg_lo |= DW_CFG_RELOAD_SRC;
649657
#endif
650658
dw_chan->cfg_hi |= DW_CFGH_SRC(config->src_dev);
659+
platform_dw_dma_llp_config(channel->dma, channel,
660+
config->src_dev);
651661
break;
652662
case DMA_DIR_DEV_TO_DEV:
653663
lli_desc->ctrl_lo |= DW_CTLL_FC_P2P | DW_CTLL_SRC_FIX |

src/platform/baytrail/include/platform/drivers/dw-dma.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
#include <sof/bit.h>
1414
#include <config.h>
15+
#include <stdint.h>
16+
17+
struct dma;
18+
struct dma_chan_data;
19+
1520

1621
/* number of supported DW-DMACs */
1722
#if CONFIG_CHERRYTRAIL_EXTRA_DW_DMA
@@ -48,6 +53,16 @@
4853
#define platform_dw_dma_set_transfer_size(chan, lli, size) \
4954
(lli->ctrl_hi |= (size & DW_CTLH_BLOCK_TS_MASK))
5055

56+
static inline void platform_dw_dma_llp_config(struct dma *dma,
57+
struct dma_chan_data *chan,
58+
uint32_t config) { }
59+
60+
static inline void platform_dw_dma_llp_enable(struct dma *dma,
61+
struct dma_chan_data *chan) { }
62+
63+
static inline void platform_dw_dma_llp_disable(struct dma *dma,
64+
struct dma_chan_data *chan) { }
65+
5166
#endif /* __PLATFORM_DRIVERS_DW_DMA_H__ */
5267

5368
#else

src/platform/haswell/include/platform/drivers/dw-dma.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#define __PLATFORM_DRIVERS_DW_DMA_H__
1212

1313
#include <sof/bit.h>
14+
#include <stdint.h>
15+
16+
struct dma;
17+
struct dma_chan_data;
1418

1519
/* number of supported DW-DMACs */
1620
#define PLATFORM_NUM_DW_DMACS 2
@@ -46,6 +50,16 @@
4650
DW_CTLL_SRC_WIDTH_MASK) >> DW_CTLL_SRC_WIDTH_SHIFT))) & \
4751
DW_CTLH_BLOCK_TS_MASK))
4852

53+
static inline void platform_dw_dma_llp_config(struct dma *dma,
54+
struct dma_chan_data *chan,
55+
uint32_t config) { }
56+
57+
static inline void platform_dw_dma_llp_enable(struct dma *dma,
58+
struct dma_chan_data *chan) { }
59+
60+
static inline void platform_dw_dma_llp_disable(struct dma *dma,
61+
struct dma_chan_data *chan) { }
62+
4963
#endif /* __PLATFORM_DRIVERS_DW_DMA_H__ */
5064

5165
#else

src/platform/intel/cavs/include/cavs/drivers/dw-dma.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
#define __CAVS_LIB_DW_DMA_H__
1212

1313
#include <sof/bit.h>
14+
#include <sof/lib/dma.h>
15+
#include <sof/lib/shim.h>
1416
#include <config.h>
17+
#include <stdint.h>
1518

1619
/* number of supported DW-DMACs */
1720
#if CONFIG_SUECREEK
@@ -51,12 +54,37 @@
5154
#define DW_CFG_LOW_DEF 0x3
5255
#define DW_CFG_HIGH_DEF 0x0
5356

57+
/* LLPC address */
58+
#define DW_CHLLPC(dma, chan) \
59+
SHIM_GPDMA_CHLLPC((dma)->plat_data.id, (chan)->index)
60+
5461
#define platform_dw_dma_set_class(chan, lli, class) \
5562
(lli->ctrl_hi |= DW_CTLH_CLASS(class))
5663

5764
#define platform_dw_dma_set_transfer_size(chan, lli, size) \
5865
(lli->ctrl_hi |= (size & DW_CTLH_BLOCK_TS_MASK))
5966

67+
static inline void platform_dw_dma_llp_config(struct dma *dma,
68+
struct dma_chan_data *chan,
69+
uint32_t config)
70+
{
71+
shim_write(DW_CHLLPC(dma, chan), SHIM_GPDMA_CHLLPC_DHRS(config));
72+
}
73+
74+
static inline void platform_dw_dma_llp_enable(struct dma *dma,
75+
struct dma_chan_data *chan)
76+
{
77+
shim_write(DW_CHLLPC(dma, chan),
78+
shim_read(DW_CHLLPC(dma, chan)) | SHIM_GPDMA_CHLLPC_EN);
79+
}
80+
81+
static inline void platform_dw_dma_llp_disable(struct dma *dma,
82+
struct dma_chan_data *chan)
83+
{
84+
shim_write(DW_CHLLPC(dma, chan),
85+
shim_read(DW_CHLLPC(dma, chan)) & ~SHIM_GPDMA_CHLLPC_EN);
86+
}
87+
6088
#endif /* __CAVS_LIB_DW_DMA_H__ */
6189

6290
#else

0 commit comments

Comments
 (0)