Skip to content

Commit 8b1935e

Browse files
lyakhpmundt
authored andcommitted
dmaengine: shdma: separate DMA headers.
Separate SH DMA headers into ones, commonly used by both drivers, and ones, specific to each of them. This will make the future development of the dmaengine driver easier. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 027811b commit 8b1935e

17 files changed

Lines changed: 415 additions & 258 deletions

File tree

‎arch/sh/include/asm/dma-register.h‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Common header for the legacy SH DMA driver and the new dmaengine driver
3+
*
4+
* extracted from arch/sh/include/asm/dma-sh.h:
5+
*
6+
* Copyright (C) 2000 Takashi YOSHII
7+
* Copyright (C) 2003 Paul Mundt
8+
*
9+
* This file is subject to the terms and conditions of the GNU General Public
10+
* License. See the file "COPYING" in the main directory of this archive
11+
* for more details.
12+
*/
13+
#ifndef DMA_REGISTER_H
14+
#define DMA_REGISTER_H
15+
16+
/* DMA register */
17+
#define SAR 0x00
18+
#define DAR 0x04
19+
#define TCR 0x08
20+
#define CHCR 0x0C
21+
#define DMAOR 0x40
22+
23+
/* DMAOR definitions */
24+
#define DMAOR_AE 0x00000004
25+
#define DMAOR_NMIF 0x00000002
26+
#define DMAOR_DME 0x00000001
27+
28+
/* Definitions for the SuperH DMAC */
29+
#define REQ_L 0x00000000
30+
#define REQ_E 0x00080000
31+
#define RACK_H 0x00000000
32+
#define RACK_L 0x00040000
33+
#define ACK_R 0x00000000
34+
#define ACK_W 0x00020000
35+
#define ACK_H 0x00000000
36+
#define ACK_L 0x00010000
37+
#define DM_INC 0x00004000
38+
#define DM_DEC 0x00008000
39+
#define DM_FIX 0x0000c000
40+
#define SM_INC 0x00001000
41+
#define SM_DEC 0x00002000
42+
#define SM_FIX 0x00003000
43+
#define RS_IN 0x00000200
44+
#define RS_OUT 0x00000300
45+
#define TS_BLK 0x00000040
46+
#define TM_BUR 0x00000020
47+
#define CHCR_DE 0x00000001
48+
#define CHCR_TE 0x00000002
49+
#define CHCR_IE 0x00000004
50+
51+
#endif

‎arch/sh/include/asm/dma-sh.h‎

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#ifndef __DMA_SH_H
1212
#define __DMA_SH_H
1313

14-
#include <asm/dma.h>
14+
#include <asm/dma-register.h>
15+
#include <cpu/dma-register.h>
1516
#include <cpu/dma.h>
1617

1718
/* DMAOR contorl: The DMAOR access size is different by CPU.*/
@@ -53,34 +54,6 @@ static int dmte_irq_map[] __maybe_unused = {
5354
#endif
5455
};
5556

56-
/* Definitions for the SuperH DMAC */
57-
#define REQ_L 0x00000000
58-
#define REQ_E 0x00080000
59-
#define RACK_H 0x00000000
60-
#define RACK_L 0x00040000
61-
#define ACK_R 0x00000000
62-
#define ACK_W 0x00020000
63-
#define ACK_H 0x00000000
64-
#define ACK_L 0x00010000
65-
#define DM_INC 0x00004000
66-
#define DM_DEC 0x00008000
67-
#define DM_FIX 0x0000c000
68-
#define SM_INC 0x00001000
69-
#define SM_DEC 0x00002000
70-
#define SM_FIX 0x00003000
71-
#define RS_IN 0x00000200
72-
#define RS_OUT 0x00000300
73-
#define TS_BLK 0x00000040
74-
#define TM_BUR 0x00000020
75-
#define CHCR_DE 0x00000001
76-
#define CHCR_TE 0x00000002
77-
#define CHCR_IE 0x00000004
78-
79-
/* DMAOR definitions */
80-
#define DMAOR_AE 0x00000004
81-
#define DMAOR_NMIF 0x00000002
82-
#define DMAOR_DME 0x00000001
83-
8457
/*
8558
* Define the default configuration for dual address memory-memory transfer.
8659
* The 0x400 value represents auto-request, external->external.
@@ -111,68 +84,4 @@ static u32 dma_base_addr[] __maybe_unused = {
11184
#endif
11285
};
11386

114-
/* DMA register */
115-
#define SAR 0x00
116-
#define DAR 0x04
117-
#define TCR 0x08
118-
#define CHCR 0x0C
119-
#define DMAOR 0x40
120-
121-
/*
122-
* for dma engine
123-
*
124-
* SuperH DMA mode
125-
*/
126-
#define SHDMA_MIX_IRQ (1 << 1)
127-
#define SHDMA_DMAOR1 (1 << 2)
128-
#define SHDMA_DMAE1 (1 << 3)
129-
130-
enum sh_dmae_slave_chan_id {
131-
SHDMA_SLAVE_SCIF0_TX,
132-
SHDMA_SLAVE_SCIF0_RX,
133-
SHDMA_SLAVE_SCIF1_TX,
134-
SHDMA_SLAVE_SCIF1_RX,
135-
SHDMA_SLAVE_SCIF2_TX,
136-
SHDMA_SLAVE_SCIF2_RX,
137-
SHDMA_SLAVE_SCIF3_TX,
138-
SHDMA_SLAVE_SCIF3_RX,
139-
SHDMA_SLAVE_SCIF4_TX,
140-
SHDMA_SLAVE_SCIF4_RX,
141-
SHDMA_SLAVE_SCIF5_TX,
142-
SHDMA_SLAVE_SCIF5_RX,
143-
SHDMA_SLAVE_SIUA_TX,
144-
SHDMA_SLAVE_SIUA_RX,
145-
SHDMA_SLAVE_SIUB_TX,
146-
SHDMA_SLAVE_SIUB_RX,
147-
SHDMA_SLAVE_NUMBER, /* Must stay last */
148-
};
149-
150-
struct sh_dmae_slave_config {
151-
enum sh_dmae_slave_chan_id slave_id;
152-
dma_addr_t addr;
153-
u32 chcr;
154-
char mid_rid;
155-
};
156-
157-
struct sh_dmae_channel {
158-
unsigned int offset;
159-
unsigned int dmars;
160-
unsigned int dmars_bit;
161-
};
162-
163-
struct sh_dmae_pdata {
164-
struct sh_dmae_slave_config *slave;
165-
int slave_num;
166-
struct sh_dmae_channel *channel;
167-
int channel_num;
168-
};
169-
170-
struct device;
171-
172-
struct sh_dmae_slave {
173-
enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
174-
struct device *dma_dev; /* Set by the platform */
175-
struct sh_dmae_slave_config *config; /* Set by the driver */
176-
};
177-
17887
#endif /* __DMA_SH_H */

‎arch/sh/include/asm/dmaengine.h‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Header for the new SH dmaengine driver
3+
*
4+
* Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
#ifndef ASM_DMAENGINE_H
11+
#define ASM_DMAENGINE_H
12+
13+
#include <asm/dma-register.h>
14+
15+
#define SH_DMAC_MAX_CHANNELS 6
16+
17+
enum sh_dmae_slave_chan_id {
18+
SHDMA_SLAVE_SCIF0_TX,
19+
SHDMA_SLAVE_SCIF0_RX,
20+
SHDMA_SLAVE_SCIF1_TX,
21+
SHDMA_SLAVE_SCIF1_RX,
22+
SHDMA_SLAVE_SCIF2_TX,
23+
SHDMA_SLAVE_SCIF2_RX,
24+
SHDMA_SLAVE_SCIF3_TX,
25+
SHDMA_SLAVE_SCIF3_RX,
26+
SHDMA_SLAVE_SCIF4_TX,
27+
SHDMA_SLAVE_SCIF4_RX,
28+
SHDMA_SLAVE_SCIF5_TX,
29+
SHDMA_SLAVE_SCIF5_RX,
30+
SHDMA_SLAVE_SIUA_TX,
31+
SHDMA_SLAVE_SIUA_RX,
32+
SHDMA_SLAVE_SIUB_TX,
33+
SHDMA_SLAVE_SIUB_RX,
34+
SHDMA_SLAVE_NUMBER, /* Must stay last */
35+
};
36+
37+
struct sh_dmae_slave_config {
38+
enum sh_dmae_slave_chan_id slave_id;
39+
dma_addr_t addr;
40+
u32 chcr;
41+
char mid_rid;
42+
};
43+
44+
struct sh_dmae_channel {
45+
unsigned int offset;
46+
unsigned int dmars;
47+
unsigned int dmars_bit;
48+
};
49+
50+
struct sh_dmae_pdata {
51+
struct sh_dmae_slave_config *slave;
52+
int slave_num;
53+
struct sh_dmae_channel *channel;
54+
int channel_num;
55+
unsigned int ts_low_shift;
56+
unsigned int ts_low_mask;
57+
unsigned int ts_high_shift;
58+
unsigned int ts_high_mask;
59+
unsigned int *ts_shift;
60+
int ts_shift_num;
61+
u16 dmaor_init;
62+
};
63+
64+
struct device;
65+
66+
/* Used by slave DMA clients to request DMA to/from a specific peripheral */
67+
struct sh_dmae_slave {
68+
enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
69+
struct device *dma_dev; /* Set by the platform */
70+
struct sh_dmae_slave_config *config; /* Set by the driver */
71+
};
72+
73+
#endif

‎arch/sh/include/asm/siu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef ASM_SIU_H
1212
#define ASM_SIU_H
1313

14-
#include <asm/dma-sh.h>
14+
#include <asm/dmaengine.h>
1515

1616
struct device;
1717

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SH3 CPU-specific DMA definitions, used by both DMA drivers
3+
*
4+
* Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
#ifndef CPU_DMA_REGISTER_H
11+
#define CPU_DMA_REGISTER_H
12+
13+
#define CHCR_TS_LOW_MASK 0x18
14+
#define CHCR_TS_LOW_SHIFT 3
15+
#define CHCR_TS_HIGH_MASK 0
16+
#define CHCR_TS_HIGH_SHIFT 0
17+
18+
#define DMAOR_INIT DMAOR_DME
19+
20+
/*
21+
* The SuperH DMAC supports a number of transmit sizes, we list them here,
22+
* with their respective values as they appear in the CHCR registers.
23+
*/
24+
enum {
25+
XMIT_SZ_8BIT,
26+
XMIT_SZ_16BIT,
27+
XMIT_SZ_32BIT,
28+
XMIT_SZ_128BIT,
29+
};
30+
31+
/* log2(size / 8) - used to calculate number of transfers */
32+
#define TS_SHIFT { \
33+
[XMIT_SZ_8BIT] = 0, \
34+
[XMIT_SZ_16BIT] = 1, \
35+
[XMIT_SZ_32BIT] = 2, \
36+
[XMIT_SZ_128BIT] = 4, \
37+
}
38+
39+
#define TS_INDEX2VAL(i) (((i) & 3) << CHCR_TS_LOW_SHIFT)
40+
41+
#endif

‎arch/sh/include/cpu-sh3/cpu/dma.h‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,4 @@
2020
#define TS_32 0x00000010
2121
#define TS_128 0x00000018
2222

23-
#define CHCR_TS_LOW_MASK 0x18
24-
#define CHCR_TS_LOW_SHIFT 3
25-
#define CHCR_TS_HIGH_MASK 0
26-
#define CHCR_TS_HIGH_SHIFT 0
27-
28-
#define DMAOR_INIT DMAOR_DME
29-
30-
/*
31-
* The SuperH DMAC supports a number of transmit sizes, we list them here,
32-
* with their respective values as they appear in the CHCR registers.
33-
*/
34-
enum {
35-
XMIT_SZ_8BIT,
36-
XMIT_SZ_16BIT,
37-
XMIT_SZ_32BIT,
38-
XMIT_SZ_128BIT,
39-
};
40-
41-
#define TS_SHIFT { \
42-
[XMIT_SZ_8BIT] = 0, \
43-
[XMIT_SZ_16BIT] = 1, \
44-
[XMIT_SZ_32BIT] = 2, \
45-
[XMIT_SZ_128BIT] = 4, \
46-
}
47-
48-
#define TS_INDEX2VAL(i) (((i) & 3) << CHCR_TS_LOW_SHIFT)
49-
5023
#endif /* __ASM_CPU_SH3_DMA_H */

0 commit comments

Comments
 (0)