Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: trigger: stm32-timer: add support for stm32mp25

Add support for STM32MP25 SoC. Use newly introduced compatible to handle
this new HW variant. Add TIM20 trigger definitions that can be used by
the stm32 analog-to-digital converter. Use compatible data to identify
it.
As the counter framework is now superseding the deprecated IIO counter
interface (IIO_COUNT), don't support it. Only register IIO trigger
devices for ADC usage. So, make the valids_table a cfg option.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://patch.msgid.link/20241220095927.1122782-4-fabrice.gasnier@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Fabrice Gasnier and committed by
Jonathan Cameron
e2f9d754 e9ed97be

+25 -2
+19 -2
drivers/iio/trigger/stm32-timer-trigger.c
··· 38 38 { TIM15_TRGO,}, 39 39 { TIM16_OC1,}, 40 40 { TIM17_OC1,}, 41 + { }, /* timer 18 */ 42 + { }, /* timer 19 */ 43 + { TIM20_TRGO, TIM20_TRGO2, TIM20_OC1, TIM20_OC2, TIM20_OC3, }, 41 44 }; 42 45 43 46 /* List the triggers accepted by each timer */ ··· 794 791 return -EINVAL; 795 792 796 793 /* Create an IIO device only if we have triggers to be validated */ 797 - if (*cfg->valids_table[index]) 794 + if (cfg->valids_table && *cfg->valids_table[index]) 798 795 priv = stm32_setup_counter_device(dev); 799 796 else 800 797 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ··· 807 804 priv->clk = ddata->clk; 808 805 priv->max_arr = ddata->max_arr; 809 806 priv->triggers = triggers_table[index]; 810 - priv->valids = cfg->valids_table[index]; 807 + if (cfg->valids_table && *cfg->valids_table[index]) 808 + priv->valids = cfg->valids_table[index]; 811 809 stm32_timer_detect_trgo2(priv); 812 810 mutex_init(&priv->lock); 813 811 ··· 900 896 .num_valids_table = ARRAY_SIZE(stm32h7_valids_table), 901 897 }; 902 898 899 + static const struct stm32_timer_trigger_cfg stm32mp25_timer_trg_cfg = { 900 + /* 901 + * valids_table not used: counter framework is now superseding the deprecated IIO 902 + * counter interface (IIO_COUNT), so don't support it. num_valids_table is only 903 + * kept here to register the IIO HW triggers. valids_table should be moved at some 904 + * point to the stm32-timer-cnt driver instead. 905 + */ 906 + .num_valids_table = ARRAY_SIZE(triggers_table), 907 + }; 908 + 903 909 static const struct of_device_id stm32_trig_of_match[] = { 904 910 { 905 911 .compatible = "st,stm32-timer-trigger", ··· 917 903 }, { 918 904 .compatible = "st,stm32h7-timer-trigger", 919 905 .data = (void *)&stm32h7_timer_trg_cfg, 906 + }, { 907 + .compatible = "st,stm32mp25-timer-trigger", 908 + .data = (void *)&stm32mp25_timer_trg_cfg, 920 909 }, 921 910 { /* end node */ }, 922 911 };
+6
include/linux/iio/timer/stm32-timer-trigger.h
··· 72 72 73 73 #define TIM17_OC1 "tim17_oc1" 74 74 75 + #define TIM20_OC1 "tim20_oc1" 76 + #define TIM20_OC2 "tim20_oc2" 77 + #define TIM20_OC3 "tim20_oc3" 78 + #define TIM20_TRGO "tim20_trgo" 79 + #define TIM20_TRGO2 "tim20_trgo2" 80 + 75 81 #if IS_REACHABLE(CONFIG_IIO_STM32_TIMER_TRIGGER) 76 82 bool is_stm32_timer_trigger(struct iio_trigger *trig); 77 83 #else