Commit 25892d6e authored by Fabrice Gasnier's avatar Fabrice Gasnier Committed by Jonathan Cameron

iio: trigger: stm32-timer: add output compare triggers

Add output compare trigger sources available on some instances.
Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 45fff14b
...@@ -29,12 +29,14 @@ static const void *triggers_table[][MAX_TRIGGERS] = { ...@@ -29,12 +29,14 @@ static const void *triggers_table[][MAX_TRIGGERS] = {
{ TIM7_TRGO,}, { TIM7_TRGO,},
{ TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,}, { TIM8_TRGO, TIM8_TRGO2, TIM8_CH1, TIM8_CH2, TIM8_CH3, TIM8_CH4,},
{ TIM9_TRGO, TIM9_CH1, TIM9_CH2,}, { TIM9_TRGO, TIM9_CH1, TIM9_CH2,},
{ }, /* timer 10 */ { TIM10_OC1,},
{ }, /* timer 11 */ { TIM11_OC1,},
{ TIM12_TRGO, TIM12_CH1, TIM12_CH2,}, { TIM12_TRGO, TIM12_CH1, TIM12_CH2,},
{ }, /* timer 13 */ { TIM13_OC1,},
{ }, /* timer 14 */ { TIM14_OC1,},
{ TIM15_TRGO,}, { TIM15_TRGO,},
{ TIM16_OC1,},
{ TIM17_OC1,},
}; };
/* List the triggers accepted by each timer */ /* List the triggers accepted by each timer */
...@@ -47,10 +49,10 @@ static const void *valids_table[][MAX_VALIDS] = { ...@@ -47,10 +49,10 @@ static const void *valids_table[][MAX_VALIDS] = {
{ }, /* timer 6 */ { }, /* timer 6 */
{ }, /* timer 7 */ { }, /* timer 7 */
{ TIM1_TRGO, TIM2_TRGO, TIM4_TRGO, TIM5_TRGO,}, { TIM1_TRGO, TIM2_TRGO, TIM4_TRGO, TIM5_TRGO,},
{ TIM2_TRGO, TIM3_TRGO,}, { TIM2_TRGO, TIM3_TRGO, TIM10_OC1, TIM11_OC1,},
{ }, /* timer 10 */ { }, /* timer 10 */
{ }, /* timer 11 */ { }, /* timer 11 */
{ TIM4_TRGO, TIM5_TRGO,}, { TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
}; };
static const void *stm32h7_valids_table[][MAX_VALIDS] = { static const void *stm32h7_valids_table[][MAX_VALIDS] = {
...@@ -65,10 +67,12 @@ static const void *stm32h7_valids_table[][MAX_VALIDS] = { ...@@ -65,10 +67,12 @@ static const void *stm32h7_valids_table[][MAX_VALIDS] = {
{ }, /* timer 9 */ { }, /* timer 9 */
{ }, /* timer 10 */ { }, /* timer 10 */
{ }, /* timer 11 */ { }, /* timer 11 */
{ TIM4_TRGO, TIM5_TRGO,}, { TIM4_TRGO, TIM5_TRGO, TIM13_OC1, TIM14_OC1,},
{ }, /* timer 13 */ { }, /* timer 13 */
{ }, /* timer 14 */ { }, /* timer 14 */
{ TIM1_TRGO, TIM3_TRGO,}, { TIM1_TRGO, TIM3_TRGO, TIM16_OC1, TIM17_OC1,},
{ }, /* timer 16 */
{ }, /* timer 17 */
}; };
struct stm32_timer_trigger { struct stm32_timer_trigger {
...@@ -91,6 +95,11 @@ static bool stm32_timer_is_trgo2_name(const char *name) ...@@ -91,6 +95,11 @@ static bool stm32_timer_is_trgo2_name(const char *name)
return !!strstr(name, "trgo2"); return !!strstr(name, "trgo2");
} }
static bool stm32_timer_is_trgo_name(const char *name)
{
return (!!strstr(name, "trgo") && !strstr(name, "trgo2"));
}
static int stm32_timer_start(struct stm32_timer_trigger *priv, static int stm32_timer_start(struct stm32_timer_trigger *priv,
struct iio_trigger *trig, struct iio_trigger *trig,
unsigned int frequency) unsigned int frequency)
...@@ -355,6 +364,7 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv) ...@@ -355,6 +364,7 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
while (cur && *cur) { while (cur && *cur) {
struct iio_trigger *trig; struct iio_trigger *trig;
bool cur_is_trgo = stm32_timer_is_trgo_name(*cur);
bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur); bool cur_is_trgo2 = stm32_timer_is_trgo2_name(*cur);
if (cur_is_trgo2 && !priv->has_trgo2) { if (cur_is_trgo2 && !priv->has_trgo2) {
...@@ -371,10 +381,9 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv) ...@@ -371,10 +381,9 @@ static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv)
/* /*
* sampling frequency and master mode attributes * sampling frequency and master mode attributes
* should only be available on trgo trigger which * should only be available on trgo/trgo2 triggers
* is always the first in the list.
*/ */
if (cur == priv->triggers || cur_is_trgo2) if (cur_is_trgo || cur_is_trgo2)
trig->dev.groups = stm32_trigger_attr_groups; trig->dev.groups = stm32_trigger_attr_groups;
iio_trigger_set_drvdata(trig, priv); iio_trigger_set_drvdata(trig, priv);
......
...@@ -55,12 +55,24 @@ ...@@ -55,12 +55,24 @@
#define TIM9_CH1 "tim9_ch1" #define TIM9_CH1 "tim9_ch1"
#define TIM9_CH2 "tim9_ch2" #define TIM9_CH2 "tim9_ch2"
#define TIM10_OC1 "tim10_oc1"
#define TIM11_OC1 "tim11_oc1"
#define TIM12_TRGO "tim12_trgo" #define TIM12_TRGO "tim12_trgo"
#define TIM12_CH1 "tim12_ch1" #define TIM12_CH1 "tim12_ch1"
#define TIM12_CH2 "tim12_ch2" #define TIM12_CH2 "tim12_ch2"
#define TIM13_OC1 "tim13_oc1"
#define TIM14_OC1 "tim14_oc1"
#define TIM15_TRGO "tim15_trgo" #define TIM15_TRGO "tim15_trgo"
#define TIM16_OC1 "tim16_oc1"
#define TIM17_OC1 "tim17_oc1"
bool is_stm32_timer_trigger(struct iio_trigger *trig); bool is_stm32_timer_trigger(struct iio_trigger *trig);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment