Skip to content

Commit 42e5573

Browse files
committed
Merge branch 'dma40' into dmaengine
2 parents 9cb047d + 5c37209 commit 42e5573

5 files changed

Lines changed: 72 additions & 71 deletions

File tree

‎arch/arm/mach-ux500/devices-db8500.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,25 @@ static struct resource dma40_resources[] = {
132132

133133
/* Default configuration for physcial memcpy */
134134
struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
135-
.channel_type = (STEDMA40_CHANNEL_IN_PHY_MODE |
136-
STEDMA40_LOW_PRIORITY_CHANNEL |
137-
STEDMA40_PCHAN_BASIC_MODE),
135+
.mode = STEDMA40_MODE_PHYSICAL,
138136
.dir = STEDMA40_MEM_TO_MEM,
139137

140-
.src_info.endianess = STEDMA40_LITTLE_ENDIAN,
141138
.src_info.data_width = STEDMA40_BYTE_WIDTH,
142139
.src_info.psize = STEDMA40_PSIZE_PHY_1,
143140
.src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
144141

145-
.dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
146142
.dst_info.data_width = STEDMA40_BYTE_WIDTH,
147143
.dst_info.psize = STEDMA40_PSIZE_PHY_1,
148144
.dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
149145
};
150146
/* Default configuration for logical memcpy */
151147
struct stedma40_chan_cfg dma40_memcpy_conf_log = {
152-
.channel_type = (STEDMA40_CHANNEL_IN_LOG_MODE |
153-
STEDMA40_LOW_PRIORITY_CHANNEL |
154-
STEDMA40_LCHAN_SRC_LOG_DST_LOG |
155-
STEDMA40_NO_TIM_FOR_LINK),
156148
.dir = STEDMA40_MEM_TO_MEM,
157149

158-
.src_info.endianess = STEDMA40_LITTLE_ENDIAN,
159150
.src_info.data_width = STEDMA40_BYTE_WIDTH,
160151
.src_info.psize = STEDMA40_PSIZE_LOG_1,
161152
.src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
162153

163-
.dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
164154
.dst_info.data_width = STEDMA40_BYTE_WIDTH,
165155
.dst_info.psize = STEDMA40_PSIZE_LOG_1,
166156
.dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,

‎arch/arm/plat-nomadik/include/plat/ste_dma40.h‎

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,20 @@
1818
#define STEDMA40_DEV_DST_MEMORY (-1)
1919
#define STEDMA40_DEV_SRC_MEMORY (-1)
2020

21-
/*
22-
* Description of bitfields of channel_type variable is available in
23-
* the info structure.
24-
*/
21+
enum stedma40_mode {
22+
STEDMA40_MODE_LOGICAL = 0,
23+
STEDMA40_MODE_PHYSICAL,
24+
STEDMA40_MODE_OPERATION,
25+
};
2526

26-
/* Priority */
27-
#define STEDMA40_INFO_PRIO_TYPE_POS 2
28-
#define STEDMA40_HIGH_PRIORITY_CHANNEL (0x1 << STEDMA40_INFO_PRIO_TYPE_POS)
29-
#define STEDMA40_LOW_PRIORITY_CHANNEL (0x2 << STEDMA40_INFO_PRIO_TYPE_POS)
30-
31-
/* Mode */
32-
#define STEDMA40_INFO_CH_MODE_TYPE_POS 6
33-
#define STEDMA40_CHANNEL_IN_PHY_MODE (0x1 << STEDMA40_INFO_CH_MODE_TYPE_POS)
34-
#define STEDMA40_CHANNEL_IN_LOG_MODE (0x2 << STEDMA40_INFO_CH_MODE_TYPE_POS)
35-
#define STEDMA40_CHANNEL_IN_OPER_MODE (0x3 << STEDMA40_INFO_CH_MODE_TYPE_POS)
36-
37-
/* Mode options */
38-
#define STEDMA40_INFO_CH_MODE_OPT_POS 8
39-
#define STEDMA40_PCHAN_BASIC_MODE (0x1 << STEDMA40_INFO_CH_MODE_OPT_POS)
40-
#define STEDMA40_PCHAN_MODULO_MODE (0x2 << STEDMA40_INFO_CH_MODE_OPT_POS)
41-
#define STEDMA40_PCHAN_DOUBLE_DST_MODE (0x3 << STEDMA40_INFO_CH_MODE_OPT_POS)
42-
#define STEDMA40_LCHAN_SRC_PHY_DST_LOG (0x1 << STEDMA40_INFO_CH_MODE_OPT_POS)
43-
#define STEDMA40_LCHAN_SRC_LOG_DST_PHS (0x2 << STEDMA40_INFO_CH_MODE_OPT_POS)
44-
#define STEDMA40_LCHAN_SRC_LOG_DST_LOG (0x3 << STEDMA40_INFO_CH_MODE_OPT_POS)
45-
46-
/* Interrupt */
47-
#define STEDMA40_INFO_TIM_POS 10
48-
#define STEDMA40_NO_TIM_FOR_LINK (0x0 << STEDMA40_INFO_TIM_POS)
49-
#define STEDMA40_TIM_FOR_LINK (0x1 << STEDMA40_INFO_TIM_POS)
50-
51-
/* End of channel_type configuration */
27+
enum stedma40_mode_opt {
28+
STEDMA40_PCHAN_BASIC_MODE = 0,
29+
STEDMA40_LCHAN_SRC_LOG_DST_LOG = 0,
30+
STEDMA40_PCHAN_MODULO_MODE,
31+
STEDMA40_PCHAN_DOUBLE_DST_MODE,
32+
STEDMA40_LCHAN_SRC_PHY_DST_LOG,
33+
STEDMA40_LCHAN_SRC_LOG_DST_PHY,
34+
};
5235

5336
#define STEDMA40_ESIZE_8_BIT 0x0
5437
#define STEDMA40_ESIZE_16_BIT 0x1
@@ -79,11 +62,6 @@ enum stedma40_flow_ctrl {
7962
STEDMA40_FLOW_CTRL,
8063
};
8164

82-
enum stedma40_endianess {
83-
STEDMA40_LITTLE_ENDIAN,
84-
STEDMA40_BIG_ENDIAN
85-
};
86-
8765
enum stedma40_periph_data_width {
8866
STEDMA40_BYTE_WIDTH = STEDMA40_ESIZE_8_BIT,
8967
STEDMA40_HALFWORD_WIDTH = STEDMA40_ESIZE_16_BIT,
@@ -102,13 +80,13 @@ enum stedma40_xfer_dir {
10280
/**
10381
* struct stedma40_chan_cfg - dst/src channel configuration
10482
*
105-
* @endianess: Endianess of the src/dst hardware
83+
* @big_endian: true if the src/dst should be read as big endian
10684
* @data_width: Data width of the src/dst hardware
10785
* @p_size: Burst size
10886
* @flow_ctrl: Flow control on/off.
10987
*/
11088
struct stedma40_half_channel_info {
111-
enum stedma40_endianess endianess;
89+
bool big_endian;
11290
enum stedma40_periph_data_width data_width;
11391
int psize;
11492
enum stedma40_flow_ctrl flow_ctrl;
@@ -118,7 +96,9 @@ struct stedma40_half_channel_info {
11896
* struct stedma40_chan_cfg - Structure to be filled by client drivers.
11997
*
12098
* @dir: MEM 2 MEM, PERIPH 2 MEM , MEM 2 PERIPH, PERIPH 2 PERIPH
121-
* @channel_type: priority, mode, mode options and interrupt configuration.
99+
* @high_priority: true if high-priority
100+
* @mode: channel mode: physical, logical, or operation
101+
* @mode_opt: options for the chosen channel mode
122102
* @src_dev_type: Src device type
123103
* @dst_dev_type: Dst device type
124104
* @src_info: Parameters for dst half channel
@@ -131,7 +111,9 @@ struct stedma40_half_channel_info {
131111
*/
132112
struct stedma40_chan_cfg {
133113
enum stedma40_xfer_dir dir;
134-
unsigned int channel_type;
114+
bool high_priority;
115+
enum stedma40_mode mode;
116+
enum stedma40_mode_opt mode_opt;
135117
int src_dev_type;
136118
int dst_dev_type;
137119
struct stedma40_half_channel_info src_info;

‎drivers/dma/ste_dma40.c‎

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ struct d40_base;
175175
* @active: Active descriptor.
176176
* @queue: Queued jobs.
177177
* @dma_cfg: The client configuration of this dma channel.
178+
* @configured: whether the dma_cfg configuration is valid
178179
* @base: Pointer to the device instance struct.
179180
* @src_def_cfg: Default cfg register setting for src.
180181
* @dst_def_cfg: Default cfg register setting for dst.
@@ -198,6 +199,7 @@ struct d40_chan {
198199
struct list_head active;
199200
struct list_head queue;
200201
struct stedma40_chan_cfg dma_cfg;
202+
bool configured;
201203
struct d40_base *base;
202204
/* Default register configurations */
203205
u32 src_def_cfg;
@@ -691,6 +693,31 @@ static u32 d40_chan_has_events(struct d40_chan *d40c)
691693
return val;
692694
}
693695

696+
static u32 d40_get_prmo(struct d40_chan *d40c)
697+
{
698+
static const unsigned int phy_map[] = {
699+
[STEDMA40_PCHAN_BASIC_MODE]
700+
= D40_DREG_PRMO_PCHAN_BASIC,
701+
[STEDMA40_PCHAN_MODULO_MODE]
702+
= D40_DREG_PRMO_PCHAN_MODULO,
703+
[STEDMA40_PCHAN_DOUBLE_DST_MODE]
704+
= D40_DREG_PRMO_PCHAN_DOUBLE_DST,
705+
};
706+
static const unsigned int log_map[] = {
707+
[STEDMA40_LCHAN_SRC_PHY_DST_LOG]
708+
= D40_DREG_PRMO_LCHAN_SRC_PHY_DST_LOG,
709+
[STEDMA40_LCHAN_SRC_LOG_DST_PHY]
710+
= D40_DREG_PRMO_LCHAN_SRC_LOG_DST_PHY,
711+
[STEDMA40_LCHAN_SRC_LOG_DST_LOG]
712+
= D40_DREG_PRMO_LCHAN_SRC_LOG_DST_LOG,
713+
};
714+
715+
if (d40c->log_num == D40_PHY_CHAN)
716+
return phy_map[d40c->dma_cfg.mode_opt];
717+
else
718+
return log_map[d40c->dma_cfg.mode_opt];
719+
}
720+
694721
static void d40_config_write(struct d40_chan *d40c)
695722
{
696723
u32 addr_base;
@@ -704,8 +731,7 @@ static void d40_config_write(struct d40_chan *d40c)
704731
writel(var, d40c->base->virtbase + D40_DREG_PRMSE + addr_base);
705732

706733
/* Setup operational mode option register */
707-
var = ((d40c->dma_cfg.channel_type >> STEDMA40_INFO_CH_MODE_OPT_POS) &
708-
0x3) << D40_CHAN_POS(d40c->phy_chan->num);
734+
var = d40_get_prmo(d40c) << D40_CHAN_POS(d40c->phy_chan->num);
709735

710736
writel(var, d40c->base->virtbase + D40_DREG_PRMOE + addr_base);
711737

@@ -1149,8 +1175,7 @@ static int d40_validate_conf(struct d40_chan *d40c,
11491175
int res = 0;
11501176
u32 dst_event_group = D40_TYPE_TO_GROUP(conf->dst_dev_type);
11511177
u32 src_event_group = D40_TYPE_TO_GROUP(conf->src_dev_type);
1152-
bool is_log = (conf->channel_type & STEDMA40_CHANNEL_IN_OPER_MODE)
1153-
== STEDMA40_CHANNEL_IN_LOG_MODE;
1178+
bool is_log = conf->mode == STEDMA40_MODE_LOGICAL;
11541179

11551180
if (!conf->dir) {
11561181
dev_err(&d40c->chan.dev->device, "[%s] Invalid direction.\n",
@@ -1314,10 +1339,7 @@ static int d40_allocate_channel(struct d40_chan *d40c)
13141339
int j;
13151340
int log_num;
13161341
bool is_src;
1317-
bool is_log = (d40c->dma_cfg.channel_type &
1318-
STEDMA40_CHANNEL_IN_OPER_MODE)
1319-
== STEDMA40_CHANNEL_IN_LOG_MODE;
1320-
1342+
bool is_log = d40c->dma_cfg.mode == STEDMA40_MODE_LOGICAL;
13211343

13221344
phys = d40c->base->phy_res;
13231345

@@ -1518,8 +1540,7 @@ static int d40_free_dma(struct d40_chan *d40c)
15181540
return res;
15191541
}
15201542
d40c->phy_chan = NULL;
1521-
/* Invalidate channel type */
1522-
d40c->dma_cfg.channel_type = 0;
1543+
d40c->configured = false;
15231544
d40c->base->lookup_phy_chans[phy->num] = NULL;
15241545

15251546
return 0;
@@ -1704,6 +1725,9 @@ bool stedma40_filter(struct dma_chan *chan, void *data)
17041725
} else
17051726
err = d40_config_memcpy(d40c);
17061727

1728+
if (!err)
1729+
d40c->configured = true;
1730+
17071731
return err == 0;
17081732
}
17091733
EXPORT_SYMBOL(stedma40_filter);
@@ -1720,12 +1744,8 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
17201744

17211745
d40c->completed = chan->cookie = 1;
17221746

1723-
/*
1724-
* If no dma configuration is set (channel_type == 0)
1725-
* use default configuration (memcpy)
1726-
*/
1727-
if (d40c->dma_cfg.channel_type == 0) {
1728-
1747+
/* If no dma configuration is set use default configuration (memcpy) */
1748+
if (!d40c->configured) {
17291749
err = d40_config_memcpy(d40c);
17301750
if (err) {
17311751
dev_err(&d40c->chan.dev->device,
@@ -2231,11 +2251,11 @@ static void d40_set_runtime_config(struct dma_chan *chan,
22312251
/* Set up all the endpoint configs */
22322252
cfg->src_info.data_width = addr_width;
22332253
cfg->src_info.psize = psize;
2234-
cfg->src_info.endianess = STEDMA40_LITTLE_ENDIAN;
2254+
cfg->src_info.big_endian = false;
22352255
cfg->src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL;
22362256
cfg->dst_info.data_width = addr_width;
22372257
cfg->dst_info.psize = psize;
2238-
cfg->dst_info.endianess = STEDMA40_LITTLE_ENDIAN;
2258+
cfg->dst_info.big_endian = false;
22392259
cfg->dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL;
22402260

22412261
/* Fill in register values */

‎drivers/dma/ste_dma40_ll.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ void d40_phy_cfg(struct stedma40_chan_cfg *cfg,
108108
src |= 1 << D40_SREG_CFG_LOG_GIM_POS;
109109
}
110110

111-
if (cfg->channel_type & STEDMA40_HIGH_PRIORITY_CHANNEL) {
111+
if (cfg->high_priority) {
112112
src |= 1 << D40_SREG_CFG_PRI_POS;
113113
dst |= 1 << D40_SREG_CFG_PRI_POS;
114114
}
115115

116-
src |= cfg->src_info.endianess << D40_SREG_CFG_LBE_POS;
117-
dst |= cfg->dst_info.endianess << D40_SREG_CFG_LBE_POS;
116+
if (cfg->src_info.big_endian)
117+
src |= 1 << D40_SREG_CFG_LBE_POS;
118+
if (cfg->dst_info.big_endian)
119+
dst |= 1 << D40_SREG_CFG_LBE_POS;
118120

119121
*src_cfg = src;
120122
*dst_cfg = dst;

‎drivers/dma/ste_dma40_ll.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@
130130
#define D40_DREG_PRMSO 0x014
131131
#define D40_DREG_PRMOE 0x018
132132
#define D40_DREG_PRMOO 0x01C
133+
#define D40_DREG_PRMO_PCHAN_BASIC 0x1
134+
#define D40_DREG_PRMO_PCHAN_MODULO 0x2
135+
#define D40_DREG_PRMO_PCHAN_DOUBLE_DST 0x3
136+
#define D40_DREG_PRMO_LCHAN_SRC_PHY_DST_LOG 0x1
137+
#define D40_DREG_PRMO_LCHAN_SRC_LOG_DST_PHY 0x2
138+
#define D40_DREG_PRMO_LCHAN_SRC_LOG_DST_LOG 0x3
139+
133140
#define D40_DREG_LCPA 0x020
134141
#define D40_DREG_LCLA 0x024
135142
#define D40_DREG_ACTIVE 0x050

0 commit comments

Comments
 (0)