This source file includes following definitions.
- stm32_timers_dma_burst_read
1
2
3
4
5
6
7 #ifndef _LINUX_STM32_GPTIMER_H_
8 #define _LINUX_STM32_GPTIMER_H_
9
10 #include <linux/clk.h>
11 #include <linux/dmaengine.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/regmap.h>
14
15 #define TIM_CR1 0x00
16 #define TIM_CR2 0x04
17 #define TIM_SMCR 0x08
18 #define TIM_DIER 0x0C
19 #define TIM_SR 0x10
20 #define TIM_EGR 0x14
21 #define TIM_CCMR1 0x18
22 #define TIM_CCMR2 0x1C
23 #define TIM_CCER 0x20
24 #define TIM_CNT 0x24
25 #define TIM_PSC 0x28
26 #define TIM_ARR 0x2c
27 #define TIM_CCR1 0x34
28 #define TIM_CCR2 0x38
29 #define TIM_CCR3 0x3C
30 #define TIM_CCR4 0x40
31 #define TIM_BDTR 0x44
32 #define TIM_DCR 0x48
33 #define TIM_DMAR 0x4C
34
35 #define TIM_CR1_CEN BIT(0)
36 #define TIM_CR1_DIR BIT(4)
37 #define TIM_CR1_ARPE BIT(7)
38 #define TIM_CR2_MMS (BIT(4) | BIT(5) | BIT(6))
39 #define TIM_CR2_MMS2 GENMASK(23, 20)
40 #define TIM_SMCR_SMS (BIT(0) | BIT(1) | BIT(2))
41 #define TIM_SMCR_TS (BIT(4) | BIT(5) | BIT(6))
42 #define TIM_DIER_UIE BIT(0)
43 #define TIM_DIER_UDE BIT(8)
44 #define TIM_DIER_CC1DE BIT(9)
45 #define TIM_DIER_CC2DE BIT(10)
46 #define TIM_DIER_CC3DE BIT(11)
47 #define TIM_DIER_CC4DE BIT(12)
48 #define TIM_DIER_COMDE BIT(13)
49 #define TIM_DIER_TDE BIT(14)
50 #define TIM_SR_UIF BIT(0)
51 #define TIM_EGR_UG BIT(0)
52 #define TIM_CCMR_PE BIT(3)
53 #define TIM_CCMR_M1 (BIT(6) | BIT(5))
54 #define TIM_CCMR_CC1S (BIT(0) | BIT(1))
55 #define TIM_CCMR_IC1PSC GENMASK(3, 2)
56 #define TIM_CCMR_CC2S (BIT(8) | BIT(9))
57 #define TIM_CCMR_IC2PSC GENMASK(11, 10)
58 #define TIM_CCMR_CC1S_TI1 BIT(0)
59 #define TIM_CCMR_CC1S_TI2 BIT(1)
60 #define TIM_CCMR_CC2S_TI2 BIT(8)
61 #define TIM_CCMR_CC2S_TI1 BIT(9)
62 #define TIM_CCER_CC1E BIT(0)
63 #define TIM_CCER_CC1P BIT(1)
64 #define TIM_CCER_CC1NE BIT(2)
65 #define TIM_CCER_CC1NP BIT(3)
66 #define TIM_CCER_CC2E BIT(4)
67 #define TIM_CCER_CC2P BIT(5)
68 #define TIM_CCER_CC3E BIT(8)
69 #define TIM_CCER_CC3P BIT(9)
70 #define TIM_CCER_CC4E BIT(12)
71 #define TIM_CCER_CC4P BIT(13)
72 #define TIM_CCER_CCXE (BIT(0) | BIT(4) | BIT(8) | BIT(12))
73 #define TIM_BDTR_BKE BIT(12)
74 #define TIM_BDTR_BKP BIT(13)
75 #define TIM_BDTR_AOE BIT(14)
76 #define TIM_BDTR_MOE BIT(15)
77 #define TIM_BDTR_BKF (BIT(16) | BIT(17) | BIT(18) | BIT(19))
78 #define TIM_BDTR_BK2F (BIT(20) | BIT(21) | BIT(22) | BIT(23))
79 #define TIM_BDTR_BK2E BIT(24)
80 #define TIM_BDTR_BK2P BIT(25)
81 #define TIM_DCR_DBA GENMASK(4, 0)
82 #define TIM_DCR_DBL GENMASK(12, 8)
83
84 #define MAX_TIM_PSC 0xFFFF
85 #define MAX_TIM_ICPSC 0x3
86 #define TIM_CR2_MMS_SHIFT 4
87 #define TIM_CR2_MMS2_SHIFT 20
88 #define TIM_SMCR_TS_SHIFT 4
89 #define TIM_BDTR_BKF_MASK 0xF
90 #define TIM_BDTR_BKF_SHIFT 16
91 #define TIM_BDTR_BK2F_SHIFT 20
92
93 enum stm32_timers_dmas {
94 STM32_TIMERS_DMA_CH1,
95 STM32_TIMERS_DMA_CH2,
96 STM32_TIMERS_DMA_CH3,
97 STM32_TIMERS_DMA_CH4,
98 STM32_TIMERS_DMA_UP,
99 STM32_TIMERS_DMA_TRIG,
100 STM32_TIMERS_DMA_COM,
101 STM32_TIMERS_MAX_DMAS,
102 };
103
104
105
106
107
108
109
110
111
112 struct stm32_timers_dma {
113 struct completion completion;
114 phys_addr_t phys_base;
115 struct mutex lock;
116 struct dma_chan *chan;
117 struct dma_chan *chans[STM32_TIMERS_MAX_DMAS];
118 };
119
120 struct stm32_timers {
121 struct clk *clk;
122 struct regmap *regmap;
123 u32 max_arr;
124 struct stm32_timers_dma dma;
125 };
126
127 #if IS_REACHABLE(CONFIG_MFD_STM32_TIMERS)
128 int stm32_timers_dma_burst_read(struct device *dev, u32 *buf,
129 enum stm32_timers_dmas id, u32 reg,
130 unsigned int num_reg, unsigned int bursts,
131 unsigned long tmo_ms);
132 #else
133 static inline int stm32_timers_dma_burst_read(struct device *dev, u32 *buf,
134 enum stm32_timers_dmas id,
135 u32 reg,
136 unsigned int num_reg,
137 unsigned int bursts,
138 unsigned long tmo_ms)
139 {
140 return -ENODEV;
141 }
142 #endif
143 #endif