Skip to content

Commit 25892d6

Browse files
fgasnier63Jonathan Cameron
authored andcommitted
iio: trigger: stm32-timer: add output compare triggers
Add output compare trigger sources available on some instances. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 45fff14 commit 25892d6

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

‎drivers/iio/trigger/stm32-timer-trigger.c‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ static const void *triggers_table[][MAX_TRIGGERS] = {
2929
{ TIM7_TRGO,},
3030
{ TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,},
3131
{ TIM9_TRGO, TIM9_CH1, TIM9_CH2,},
32-
{ }, /* timer 10 */
33-
{ }, /* timer 11 */
32+
{ TIM10_OC1,},
33+
{ TIM11_OC1,},
3434
{ TIM12_TRGO, TIM12_CH1, TIM12_CH2,},
35-
{ }, /* timer 13 */
36-
{ }, /* timer 14 */
35+
{ TIM13_OC1,},
36+
{ TIM14_OC1,},
3737
{ TIM15_TRGO,},
38+
{ TIM16_OC1,},
39+
{ TIM17_OC1,},
3840
};
3941

4042
/* List the triggers accepted by each timer */
@@ -47,10 +49,10 @@ static const void *valids_table[][MAX_VALIDS] = {
4749
{ }, /* timer 6 */
4850
{ }, /* timer 7 */
4951
{ TIM1_TRGO, TIM2_TRGO, TIM4_TRGO, TIM5_TRGO,},
50-
{ TIM2_TRGO, TIM3_TRGO,},
52+
{ TIM2_TRGO, TIM3_TRGO, TIM10_OC1, TIM11_OC1,},
5153
{ }, /* timer 10 */
5254
{ }, /* timer 11 */
53-
{ TIM4_TRGO, TIM5_TRGO,},
55+
{ TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
5456
};
5557

5658
static const void *stm32h7_valids_table[][MAX_VALIDS] = {
@@ -65,10 +67,12 @@ static const void *stm32h7_valids_table[][MAX_VALIDS] = {
6567
{ }, /* timer 9 */
6668
{ }, /* timer 10 */
6769
{ }, /* timer 11 */
68-
{ TIM4_TRGO, TIM5_TRGO,},
70+
{ TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
6971
{ }, /* timer 13 */
7072
{ }, /* timer 14 */
71-
{ TIM1_TRGO, TIM3_TRGO,},
73+
{ TIM1_TRGO, TIM3_TRGO, TIM16_OC1, TIM17_OC1,},
74+
{ }, /* timer 16 */
75+
{ }, /* timer 17 */
7276
};
7377

7478
struct stm32_timer_trigger {
@@ -91,6 +95,11 @@ static bool stm32_timer_is_trgo2_name(const char *name)
9195
return !!strstr(name, "trgo2");
9296
}
9397

98+
static bool stm32_timer_is_trgo_name(const char *name)
99+
{
100+
return (!!strstr(name, "trgo") && !strstr(name, "trgo2"));
101+
}
102+
94103
static int stm32_timer_start(struct stm32_timer_trigger *priv,
95104
struct iio_trigger *trig,
96105
unsigned int frequency)
@@ -355,6 +364,7 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
355364

356365
while (cur && *cur) {
357366
struct iio_trigger *trig;
367+
bool cur_is_trgo = stm32_timer_is_trgo_name(*cur);
358368
bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur);
359369

360370
if (cur_is_trgo2 && !priv->has_trgo2) {
@@ -371,10 +381,9 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
371381

372382
/*
373383
* sampling frequency and master mode attributes
374-
* should only be available on trgo trigger which
375-
* is always the first in the list.
384+
* should only be available on trgo/trgo2 triggers
376385
*/
377-
if (cur == priv->triggers || cur_is_trgo2)
386+
if (cur_is_trgo || cur_is_trgo2)
378387
trig->dev.groups = stm32_trigger_attr_groups;
379388

380389
iio_trigger_set_drvdata(trig, priv);

‎include/linux/iio/timer/stm32-timer-trigger.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,24 @@
5555
#define TIM9_CH1 "tim9_ch1"
5656
#define TIM9_CH2 "tim9_ch2"
5757

58+
#define TIM10_OC1 "tim10_oc1"
59+
60+
#define TIM11_OC1 "tim11_oc1"
61+
5862
#define TIM12_TRGO "tim12_trgo"
5963
#define TIM12_CH1 "tim12_ch1"
6064
#define TIM12_CH2 "tim12_ch2"
6165

66+
#define TIM13_OC1 "tim13_oc1"
67+
68+
#define TIM14_OC1 "tim14_oc1"
69+
6270
#define TIM15_TRGO "tim15_trgo"
6371

72+
#define TIM16_OC1 "tim16_oc1"
73+
74+
#define TIM17_OC1 "tim17_oc1"
75+
6476
bool is_stm32_timer_trigger(struct iio_trigger *trig);
6577

6678
#endif

0 commit comments

Comments
 (0)