Skip to content

Commit b299d00

Browse files
Benjamin GaignardJonathan Cameron
authored andcommitted
IIO: stm32: Remove quadrature related functions from trigger driver
Quadrature feature is now hosted on it own framework. Remove quadrature related code from stm32-trigger driver to avoid code duplication and simplify the ABI. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 0eec1f3 commit b299d00

2 files changed

Lines changed: 0 additions & 107 deletions

File tree

‎Documentation/ABI/testing/sysfs-bus-iio-timer-stm32‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,6 @@ Description:
9191
When counting down the counter start from preset value
9292
and fire event when reach 0.
9393

94-
What: /sys/bus/iio/devices/iio:deviceX/in_count_quadrature_mode_available
95-
KernelVersion: 4.12
96-
Contact: benjamin.gaignard@st.com
97-
Description:
98-
Reading returns the list possible quadrature modes.
99-
100-
What: /sys/bus/iio/devices/iio:deviceX/in_count0_quadrature_mode
101-
KernelVersion: 4.12
102-
Contact: benjamin.gaignard@st.com
103-
Description:
104-
Configure the device counter quadrature modes:
105-
channel_A:
106-
Encoder A input servers as the count input and B as
107-
the UP/DOWN direction control input.
108-
109-
channel_B:
110-
Encoder B input serves as the count input and A as
111-
the UP/DOWN direction control input.
112-
113-
quadrature:
114-
Encoder A and B inputs are mixed to get direction
115-
and count with a scale of 0.25.
116-
11794
What: /sys/bus/iio/devices/iio:deviceX/in_count_enable_mode_available
11895
KernelVersion: 4.12
11996
Contact: benjamin.gaignard@st.com

‎drivers/iio/trigger/stm32-timer-trigger.c‎

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -608,86 +608,6 @@ static const struct iio_enum stm32_enable_mode_enum = {
608608
.get = stm32_get_enable_mode
609609
};
610610

611-
static const char *const stm32_quadrature_modes[] = {
612-
"channel_A",
613-
"channel_B",
614-
"quadrature",
615-
};
616-
617-
static int stm32_set_quadrature_mode(struct iio_dev *indio_dev,
618-
const struct iio_chan_spec *chan,
619-
unsigned int mode)
620-
{
621-
struct stm32_timer_trigger *priv = iio_priv(indio_dev);
622-
623-
regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, mode + 1);
624-
625-
return 0;
626-
}
627-
628-
static int stm32_get_quadrature_mode(struct iio_dev *indio_dev,
629-
const struct iio_chan_spec *chan)
630-
{
631-
struct stm32_timer_trigger *priv = iio_priv(indio_dev);
632-
u32 smcr;
633-
int mode;
634-
635-
regmap_read(priv->regmap, TIM_SMCR, &smcr);
636-
mode = (smcr & TIM_SMCR_SMS) - 1;
637-
if ((mode < 0) || (mode > ARRAY_SIZE(stm32_quadrature_modes)))
638-
return -EINVAL;
639-
640-
return mode;
641-
}
642-
643-
static const struct iio_enum stm32_quadrature_mode_enum = {
644-
.items = stm32_quadrature_modes,
645-
.num_items = ARRAY_SIZE(stm32_quadrature_modes),
646-
.set = stm32_set_quadrature_mode,
647-
.get = stm32_get_quadrature_mode
648-
};
649-
650-
static const char *const stm32_count_direction_states[] = {
651-
"up",
652-
"down"
653-
};
654-
655-
static int stm32_set_count_direction(struct iio_dev *indio_dev,
656-
const struct iio_chan_spec *chan,
657-
unsigned int dir)
658-
{
659-
struct stm32_timer_trigger *priv = iio_priv(indio_dev);
660-
u32 val;
661-
int mode;
662-
663-
/* In encoder mode, direction is RO (given by TI1/TI2 signals) */
664-
regmap_read(priv->regmap, TIM_SMCR, &val);
665-
mode = (val & TIM_SMCR_SMS) - 1;
666-
if ((mode >= 0) || (mode < ARRAY_SIZE(stm32_quadrature_modes)))
667-
return -EBUSY;
668-
669-
return regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_DIR,
670-
dir ? TIM_CR1_DIR : 0);
671-
}
672-
673-
static int stm32_get_count_direction(struct iio_dev *indio_dev,
674-
const struct iio_chan_spec *chan)
675-
{
676-
struct stm32_timer_trigger *priv = iio_priv(indio_dev);
677-
u32 cr1;
678-
679-
regmap_read(priv->regmap, TIM_CR1, &cr1);
680-
681-
return ((cr1 & TIM_CR1_DIR) ? 1 : 0);
682-
}
683-
684-
static const struct iio_enum stm32_count_direction_enum = {
685-
.items = stm32_count_direction_states,
686-
.num_items = ARRAY_SIZE(stm32_count_direction_states),
687-
.set = stm32_set_count_direction,
688-
.get = stm32_get_count_direction
689-
};
690-
691611
static ssize_t stm32_count_get_preset(struct iio_dev *indio_dev,
692612
uintptr_t private,
693613
const struct iio_chan_spec *chan,
@@ -728,10 +648,6 @@ static const struct iio_chan_spec_ext_info stm32_trigger_count_info[] = {
728648
.read = stm32_count_get_preset,
729649
.write = stm32_count_set_preset
730650
},
731-
IIO_ENUM("count_direction", IIO_SEPARATE, &stm32_count_direction_enum),
732-
IIO_ENUM_AVAILABLE("count_direction", &stm32_count_direction_enum),
733-
IIO_ENUM("quadrature_mode", IIO_SEPARATE, &stm32_quadrature_mode_enum),
734-
IIO_ENUM_AVAILABLE("quadrature_mode", &stm32_quadrature_mode_enum),
735651
IIO_ENUM("enable_mode", IIO_SEPARATE, &stm32_enable_mode_enum),
736652
IIO_ENUM_AVAILABLE("enable_mode", &stm32_enable_mode_enum),
737653
IIO_ENUM("trigger_mode", IIO_SEPARATE, &stm32_trigger_mode_enum),

0 commit comments

Comments
 (0)