xref: /openbmc/linux/drivers/dma/ste_dma40.h (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1*42ae6f16SLinus Walleij /* SPDX-License-Identifier: GPL-2.0-only */
2*42ae6f16SLinus Walleij 
3*42ae6f16SLinus Walleij #ifndef STE_DMA40_H
4*42ae6f16SLinus Walleij #define STE_DMA40_H
5*42ae6f16SLinus Walleij 
6*42ae6f16SLinus Walleij /*
7*42ae6f16SLinus Walleij  * Maxium size for a single dma descriptor
8*42ae6f16SLinus Walleij  * Size is limited to 16 bits.
9*42ae6f16SLinus Walleij  * Size is in the units of addr-widths (1,2,4,8 bytes)
10*42ae6f16SLinus Walleij  * Larger transfers will be split up to multiple linked desc
11*42ae6f16SLinus Walleij  */
12*42ae6f16SLinus Walleij #define STEDMA40_MAX_SEG_SIZE 0xFFFF
13*42ae6f16SLinus Walleij 
14*42ae6f16SLinus Walleij /* dev types for memcpy */
15*42ae6f16SLinus Walleij #define STEDMA40_DEV_DST_MEMORY (-1)
16*42ae6f16SLinus Walleij #define	STEDMA40_DEV_SRC_MEMORY (-1)
17*42ae6f16SLinus Walleij 
18*42ae6f16SLinus Walleij enum stedma40_mode {
19*42ae6f16SLinus Walleij 	STEDMA40_MODE_LOGICAL = 0,
20*42ae6f16SLinus Walleij 	STEDMA40_MODE_PHYSICAL,
21*42ae6f16SLinus Walleij 	STEDMA40_MODE_OPERATION,
22*42ae6f16SLinus Walleij };
23*42ae6f16SLinus Walleij 
24*42ae6f16SLinus Walleij enum stedma40_mode_opt {
25*42ae6f16SLinus Walleij 	STEDMA40_PCHAN_BASIC_MODE = 0,
26*42ae6f16SLinus Walleij 	STEDMA40_LCHAN_SRC_LOG_DST_LOG = 0,
27*42ae6f16SLinus Walleij 	STEDMA40_PCHAN_MODULO_MODE,
28*42ae6f16SLinus Walleij 	STEDMA40_PCHAN_DOUBLE_DST_MODE,
29*42ae6f16SLinus Walleij 	STEDMA40_LCHAN_SRC_PHY_DST_LOG,
30*42ae6f16SLinus Walleij 	STEDMA40_LCHAN_SRC_LOG_DST_PHY,
31*42ae6f16SLinus Walleij };
32*42ae6f16SLinus Walleij 
33*42ae6f16SLinus Walleij #define STEDMA40_ESIZE_8_BIT  0x0
34*42ae6f16SLinus Walleij #define STEDMA40_ESIZE_16_BIT 0x1
35*42ae6f16SLinus Walleij #define STEDMA40_ESIZE_32_BIT 0x2
36*42ae6f16SLinus Walleij #define STEDMA40_ESIZE_64_BIT 0x3
37*42ae6f16SLinus Walleij 
38*42ae6f16SLinus Walleij /* The value 4 indicates that PEN-reg shall be set to 0 */
39*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_PHY_1  0x4
40*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_PHY_2  0x0
41*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_PHY_4  0x1
42*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_PHY_8  0x2
43*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_PHY_16 0x3
44*42ae6f16SLinus Walleij 
45*42ae6f16SLinus Walleij /*
46*42ae6f16SLinus Walleij  * The number of elements differ in logical and
47*42ae6f16SLinus Walleij  * physical mode
48*42ae6f16SLinus Walleij  */
49*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_LOG_1  STEDMA40_PSIZE_PHY_2
50*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_LOG_4  STEDMA40_PSIZE_PHY_4
51*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_LOG_8  STEDMA40_PSIZE_PHY_8
52*42ae6f16SLinus Walleij #define STEDMA40_PSIZE_LOG_16 STEDMA40_PSIZE_PHY_16
53*42ae6f16SLinus Walleij 
54*42ae6f16SLinus Walleij /* Maximum number of possible physical channels */
55*42ae6f16SLinus Walleij #define STEDMA40_MAX_PHYS 32
56*42ae6f16SLinus Walleij 
57*42ae6f16SLinus Walleij enum stedma40_flow_ctrl {
58*42ae6f16SLinus Walleij 	STEDMA40_NO_FLOW_CTRL,
59*42ae6f16SLinus Walleij 	STEDMA40_FLOW_CTRL,
60*42ae6f16SLinus Walleij };
61*42ae6f16SLinus Walleij 
62*42ae6f16SLinus Walleij /**
63*42ae6f16SLinus Walleij  * struct stedma40_half_channel_info - dst/src channel configuration
64*42ae6f16SLinus Walleij  *
65*42ae6f16SLinus Walleij  * @big_endian: true if the src/dst should be read as big endian
66*42ae6f16SLinus Walleij  * @data_width: Data width of the src/dst hardware
67*42ae6f16SLinus Walleij  * @p_size: Burst size
68*42ae6f16SLinus Walleij  * @flow_ctrl: Flow control on/off.
69*42ae6f16SLinus Walleij  */
70*42ae6f16SLinus Walleij struct stedma40_half_channel_info {
71*42ae6f16SLinus Walleij 	bool big_endian;
72*42ae6f16SLinus Walleij 	enum dma_slave_buswidth data_width;
73*42ae6f16SLinus Walleij 	int psize;
74*42ae6f16SLinus Walleij 	enum stedma40_flow_ctrl flow_ctrl;
75*42ae6f16SLinus Walleij };
76*42ae6f16SLinus Walleij 
77*42ae6f16SLinus Walleij /**
78*42ae6f16SLinus Walleij  * struct stedma40_chan_cfg - Structure to be filled by client drivers.
79*42ae6f16SLinus Walleij  *
80*42ae6f16SLinus Walleij  * @dir: MEM 2 MEM, PERIPH 2 MEM , MEM 2 PERIPH, PERIPH 2 PERIPH
81*42ae6f16SLinus Walleij  * @high_priority: true if high-priority
82*42ae6f16SLinus Walleij  * @realtime: true if realtime mode is to be enabled.  Only available on DMA40
83*42ae6f16SLinus Walleij  * version 3+, i.e DB8500v2+
84*42ae6f16SLinus Walleij  * @mode: channel mode: physical, logical, or operation
85*42ae6f16SLinus Walleij  * @mode_opt: options for the chosen channel mode
86*42ae6f16SLinus Walleij  * @dev_type: src/dst device type (driver uses dir to figure out which)
87*42ae6f16SLinus Walleij  * @src_info: Parameters for dst half channel
88*42ae6f16SLinus Walleij  * @dst_info: Parameters for dst half channel
89*42ae6f16SLinus Walleij  * @use_fixed_channel: if true, use physical channel specified by phy_channel
90*42ae6f16SLinus Walleij  * @phy_channel: physical channel to use, only if use_fixed_channel is true
91*42ae6f16SLinus Walleij  *
92*42ae6f16SLinus Walleij  * This structure has to be filled by the client drivers.
93*42ae6f16SLinus Walleij  * It is recommended to do all dma configurations for clients in the machine.
94*42ae6f16SLinus Walleij  *
95*42ae6f16SLinus Walleij  */
96*42ae6f16SLinus Walleij struct stedma40_chan_cfg {
97*42ae6f16SLinus Walleij 	enum dma_transfer_direction		 dir;
98*42ae6f16SLinus Walleij 	bool					 high_priority;
99*42ae6f16SLinus Walleij 	bool					 realtime;
100*42ae6f16SLinus Walleij 	enum stedma40_mode			 mode;
101*42ae6f16SLinus Walleij 	enum stedma40_mode_opt			 mode_opt;
102*42ae6f16SLinus Walleij 	int					 dev_type;
103*42ae6f16SLinus Walleij 	struct stedma40_half_channel_info	 src_info;
104*42ae6f16SLinus Walleij 	struct stedma40_half_channel_info	 dst_info;
105*42ae6f16SLinus Walleij 
106*42ae6f16SLinus Walleij 	bool					 use_fixed_channel;
107*42ae6f16SLinus Walleij 	int					 phy_channel;
108*42ae6f16SLinus Walleij };
109*42ae6f16SLinus Walleij 
110*42ae6f16SLinus Walleij #endif /* STE_DMA40_H */
111