aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/trigger/stm32-timer-trigger.c
diff options
context:
space:
mode:
authorFabrice Gasnier <fabrice.gasnier@st.com>2017-08-03 05:14:14 -0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2017-08-12 08:05:27 -0400
commit25892d6eac9cb752af95bcd539ed5e1158eba760 (patch)
treebb0eef4fda17456c52eabff44cbd6ae8eeddcf6e /drivers/iio/trigger/stm32-timer-trigger.c
parent45fff14bab00eea97e0f60a2a5ba3eca97bd476a (diff)
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>
Diffstat (limited to 'drivers/iio/trigger/stm32-timer-trigger.c')
-rw-r--r--drivers/iio/trigger/stm32-timer-trigger.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
index 33890f9ad11b..a9bc5b603b86 100644
--- a/drivers/iio/trigger/stm32-timer-trigger.c
+++ b/drivers/iio/trigger/stm32-timer-trigger.c
@@ -29,12 +29,14 @@ static const void *triggers_table[][MAX_TRIGGERS] = {
29 { TIM7_TRGO,}, 29 { TIM7_TRGO,},
30 { TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,}, 30 { TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,},
31 { TIM9_TRGO, TIM9_CH1, TIM9_CH2,}, 31 { TIM9_TRGO, TIM9_CH1, TIM9_CH2,},
32 { }, /* timer 10 */ 32 { TIM10_OC1,},
33 { }, /* timer 11 */ 33 { TIM11_OC1,},
34 { TIM12_TRGO, TIM12_CH1, TIM12_CH2,}, 34 { TIM12_TRGO, TIM12_CH1, TIM12_CH2,},
35 { }, /* timer 13 */ 35 { TIM13_OC1,},
36 { }, /* timer 14 */ 36 { TIM14_OC1,},
37 { TIM15_TRGO,}, 37 { TIM15_TRGO,},
38 { TIM16_OC1,},
39 { TIM17_OC1,},
38}; 40};
39 41
40/* List the triggers accepted by each timer */ 42/* List the triggers accepted by each timer */
@@ -47,10 +49,10 @@ static const void *valids_table[][MAX_VALIDS] = {
47 { }, /* timer 6 */ 49 { }, /* timer 6 */
48 { }, /* timer 7 */ 50 { }, /* timer 7 */
49 { TIM1_TRGO, TIM2_TRGO, TIM4_TRGO, TIM5_TRGO,}, 51 { TIM1_TRGO, TIM2_TRGO, TIM4_TRGO, TIM5_TRGO,},
50 { TIM2_TRGO, TIM3_TRGO,}, 52 { TIM2_TRGO, TIM3_TRGO, TIM10_OC1, TIM11_OC1,},
51 { }, /* timer 10 */ 53 { }, /* timer 10 */
52 { }, /* timer 11 */ 54 { }, /* timer 11 */
53 { TIM4_TRGO, TIM5_TRGO,}, 55 { TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
54}; 56};
55 57
56static const void *stm32h7_valids_table[][MAX_VALIDS] = { 58static const void *stm32h7_valids_table[][MAX_VALIDS] = {
@@ -65,10 +67,12 @@ static const void *stm32h7_valids_table[][MAX_VALIDS] = {
65 { }, /* timer 9 */ 67 { }, /* timer 9 */
66 { }, /* timer 10 */ 68 { }, /* timer 10 */
67 { }, /* timer 11 */ 69 { }, /* timer 11 */
68 { TIM4_TRGO, TIM5_TRGO,}, 70 { TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
69 { }, /* timer 13 */ 71 { }, /* timer 13 */
70 { }, /* timer 14 */ 72 { }, /* timer 14 */
71 { TIM1_TRGO, TIM3_TRGO,}, 73 { TIM1_TRGO, TIM3_TRGO, TIM16_OC1, TIM17_OC1,},
74 { }, /* timer 16 */
75 { }, /* timer 17 */
72}; 76};
73 77
74struct stm32_timer_trigger { 78struct stm32_timer_trigger {
@@ -91,6 +95,11 @@ static bool stm32_timer_is_trgo2_name(const char *name)
91 return !!strstr(name, "trgo2"); 95 return !!strstr(name, "trgo2");
92} 96}
93 97
98static bool stm32_timer_is_trgo_name(const char *name)
99{
100 return (!!strstr(name, "trgo") && !strstr(name, "trgo2"));
101}
102
94static int stm32_timer_start(struct stm32_timer_trigger *priv, 103static int stm32_timer_start(struct stm32_timer_trigger *priv,
95 struct iio_trigger *trig, 104 struct iio_trigger *trig,
96 unsigned int frequency) 105 unsigned int frequency)
@@ -355,6 +364,7 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
355 364
356 while (cur && *cur) { 365 while (cur && *cur) {
357 struct iio_trigger *trig; 366 struct iio_trigger *trig;
367 bool cur_is_trgo = stm32_timer_is_trgo_name(*cur);
358 bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur); 368 bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur);
359 369
360 if (cur_is_trgo2 && !priv->has_trgo2) { 370 if (cur_is_trgo2 && !priv->has_trgo2) {
@@ -371,10 +381,9 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
371 381
372 /* 382 /*
373 * sampling frequency and master mode attributes 383 * sampling frequency and master mode attributes
374 * should only be available on trgo trigger which 384 * should only be available on trgo/trgo2 triggers
375 * is always the first in the list.
376 */ 385 */
377 if (cur == priv->triggers || cur_is_trgo2) 386 if (cur_is_trgo || cur_is_trgo2)
378 trig->dev.groups = stm32_trigger_attr_groups; 387 trig->dev.groups = stm32_trigger_attr_groups;
379 388
380 iio_trigger_set_drvdata(trig, priv); 389 iio_trigger_set_drvdata(trig, priv);