Skip to content

Commit 1b56e7d

Browse files
committed
Merge tag 'counter-updates-for-6.16b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter into char-misc-next
William writes: Second set of Counter updates for 6.16 Adds compatible for STM32MP25 SoC and enables respective encoder capability for stm32-timer-cnt. Implements watch_validate callback for microchip-tcb-capture. * tag 'counter-updates-for-6.16b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter: counter: microchip-tcb-capture: Add watch validation support counter: stm32-timer-cnt: add support for stm32mp25
2 parents 8b819af + ae3392c commit 1b56e7d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

drivers/counter/microchip-tcb-capture.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ static struct counter_comp mchp_tc_count_ext[] = {
337337
COUNTER_COMP_COMPARE(mchp_tc_count_compare_read, mchp_tc_count_compare_write),
338338
};
339339

340+
static int mchp_tc_watch_validate(struct counter_device *counter,
341+
const struct counter_watch *watch)
342+
{
343+
if (watch->channel == COUNTER_MCHP_EVCHN_CV || watch->channel == COUNTER_MCHP_EVCHN_RA)
344+
switch (watch->event) {
345+
case COUNTER_EVENT_CHANGE_OF_STATE:
346+
case COUNTER_EVENT_OVERFLOW:
347+
case COUNTER_EVENT_CAPTURE:
348+
return 0;
349+
default:
350+
return -EINVAL;
351+
}
352+
353+
if (watch->channel == COUNTER_MCHP_EVCHN_RB && watch->event == COUNTER_EVENT_CAPTURE)
354+
return 0;
355+
356+
if (watch->channel == COUNTER_MCHP_EVCHN_RC && watch->event == COUNTER_EVENT_THRESHOLD)
357+
return 0;
358+
359+
return -EINVAL;
360+
}
361+
340362
static struct counter_count mchp_tc_counts[] = {
341363
{
342364
.id = 0,
@@ -356,7 +378,8 @@ static const struct counter_ops mchp_tc_ops = {
356378
.function_read = mchp_tc_count_function_read,
357379
.function_write = mchp_tc_count_function_write,
358380
.action_read = mchp_tc_count_action_read,
359-
.action_write = mchp_tc_count_action_write
381+
.action_write = mchp_tc_count_action_write,
382+
.watch_validate = mchp_tc_watch_validate,
360383
};
361384

362385
static const struct atmel_tcb_config tcb_rm9200_config = {

drivers/counter/stm32-timer-cnt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,14 @@ static void stm32_timer_cnt_detect_channels(struct device *dev,
669669
dev_dbg(dev, "has %d cc channels\n", priv->nchannels);
670670
}
671671

672-
/* encoder supported on TIM1 TIM2 TIM3 TIM4 TIM5 TIM8 */
673-
#define STM32_TIM_ENCODER_SUPPORTED (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(7))
672+
/* encoder supported on TIM1 TIM2 TIM3 TIM4 TIM5 TIM8 TIM20 */
673+
#define STM32_TIM_ENCODER_SUPPORTED (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(7) | \
674+
BIT(19))
674675

675676
static const char * const stm32_timer_trigger_compat[] = {
676677
"st,stm32-timer-trigger",
677678
"st,stm32h7-timer-trigger",
679+
"st,stm32mp25-timer-trigger",
678680
};
679681

680682
static int stm32_timer_cnt_probe_encoder(struct device *dev,
@@ -846,6 +848,7 @@ static SIMPLE_DEV_PM_OPS(stm32_timer_cnt_pm_ops, stm32_timer_cnt_suspend,
846848

847849
static const struct of_device_id stm32_timer_cnt_of_match[] = {
848850
{ .compatible = "st,stm32-timer-counter", },
851+
{ .compatible = "st,stm32mp25-timer-counter", },
849852
{},
850853
};
851854
MODULE_DEVICE_TABLE(of, stm32_timer_cnt_of_match);

0 commit comments

Comments
 (0)