regmap_read(priv->regmap, TIM_SMCR, &smcr);
switch (smcr & TIM_SMCR_SMS) {
- case 0:
+ case TIM_SMCR_SMS_SLAVE_MODE_DISABLED:
*function = STM32_COUNT_SLAVE_MODE_DISABLED;
return 0;
- case 1:
+ case TIM_SMCR_SMS_ENCODER_MODE_1:
*function = STM32_COUNT_ENCODER_MODE_1;
return 0;
- case 2:
+ case TIM_SMCR_SMS_ENCODER_MODE_2:
*function = STM32_COUNT_ENCODER_MODE_2;
return 0;
- case 3:
+ case TIM_SMCR_SMS_ENCODER_MODE_3:
*function = STM32_COUNT_ENCODER_MODE_3;
return 0;
default:
switch (function) {
case STM32_COUNT_SLAVE_MODE_DISABLED:
- sms = 0;
+ sms = TIM_SMCR_SMS_SLAVE_MODE_DISABLED;
break;
case STM32_COUNT_ENCODER_MODE_1:
- sms = 1;
+ sms = TIM_SMCR_SMS_ENCODER_MODE_1;
break;
case STM32_COUNT_ENCODER_MODE_2:
- sms = 2;
+ sms = TIM_SMCR_SMS_ENCODER_MODE_2;
break;
case STM32_COUNT_ENCODER_MODE_3:
- sms = 3;
+ sms = TIM_SMCR_SMS_ENCODER_MODE_3;
break;
default:
return -EINVAL;
#define MAX_TIM_ICPSC 0x3
#define TIM_CR2_MMS_SHIFT 4
#define TIM_CR2_MMS2_SHIFT 20
+#define TIM_SMCR_SMS_SLAVE_MODE_DISABLED 0 /* counts on internal clock when CEN=1 */
+#define TIM_SMCR_SMS_ENCODER_MODE_1 1 /* counts TI1FP1 edges, depending on TI2FP2 level */
+#define TIM_SMCR_SMS_ENCODER_MODE_2 2 /* counts TI2FP2 edges, depending on TI1FP1 level */
+#define TIM_SMCR_SMS_ENCODER_MODE_3 3 /* counts on both TI1FP1 and TI2FP2 edges */
#define TIM_SMCR_TS_SHIFT 4
#define TIM_BDTR_BKF_MASK 0xF
#define TIM_BDTR_BKF_SHIFT(x) (16 + (x) * 4)