Skip to content

Commit 9830288

Browse files
William Breathitt Graygregkh
authored andcommitted
counter: 104-quad-8: Add Signal polarity component
The 104-quad-8 driver provides support for Index signal polarity modes via the "index_polarity" Signal component. This patch exposes the same functionality through the more standard "polarity" Signal component. Link: https://lore.kernel.org/r/01d00c21873159833035cb6775d0d0e8ad55f2ef.1664204990.git.william.gray@linaro.org/ Signed-off-by: William Breathitt Gray <[email protected]> Link: https://lore.kernel.org/r/0bf840beee1665e9f04ea82368ecdde87c791a22.1664318353.git.william.gray@linaro.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 650ae67 commit 9830288

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/counter/104-quad-8.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,32 @@ static int quad8_index_polarity_set(struct counter_device *counter,
549549
return 0;
550550
}
551551

552+
static int quad8_polarity_read(struct counter_device *counter,
553+
struct counter_signal *signal,
554+
enum counter_signal_polarity *polarity)
555+
{
556+
int err;
557+
u32 index_polarity;
558+
559+
err = quad8_index_polarity_get(counter, signal, &index_polarity);
560+
if (err)
561+
return err;
562+
563+
*polarity = (index_polarity) ? COUNTER_SIGNAL_POLARITY_POSITIVE :
564+
COUNTER_SIGNAL_POLARITY_NEGATIVE;
565+
566+
return 0;
567+
}
568+
569+
static int quad8_polarity_write(struct counter_device *counter,
570+
struct counter_signal *signal,
571+
enum counter_signal_polarity polarity)
572+
{
573+
const u32 pol = (polarity == COUNTER_SIGNAL_POLARITY_POSITIVE) ? 1 : 0;
574+
575+
return quad8_index_polarity_set(counter, signal, pol);
576+
}
577+
552578
static const char *const quad8_synchronous_modes[] = {
553579
"non-synchronous",
554580
"synchronous"
@@ -977,13 +1003,22 @@ static struct counter_comp quad8_signal_ext[] = {
9771003
quad8_signal_fck_prescaler_write)
9781004
};
9791005

1006+
static const enum counter_signal_polarity quad8_polarities[] = {
1007+
COUNTER_SIGNAL_POLARITY_POSITIVE,
1008+
COUNTER_SIGNAL_POLARITY_NEGATIVE,
1009+
};
1010+
1011+
static DEFINE_COUNTER_AVAILABLE(quad8_polarity_available, quad8_polarities);
1012+
9801013
static DEFINE_COUNTER_ENUM(quad8_index_pol_enum, quad8_index_polarity_modes);
9811014
static DEFINE_COUNTER_ENUM(quad8_synch_mode_enum, quad8_synchronous_modes);
9821015

9831016
static struct counter_comp quad8_index_ext[] = {
9841017
COUNTER_COMP_SIGNAL_ENUM("index_polarity", quad8_index_polarity_get,
9851018
quad8_index_polarity_set,
9861019
quad8_index_pol_enum),
1020+
COUNTER_COMP_POLARITY(quad8_polarity_read, quad8_polarity_write,
1021+
quad8_polarity_available),
9871022
COUNTER_COMP_SIGNAL_ENUM("synchronous_mode", quad8_synchronous_mode_get,
9881023
quad8_synchronous_mode_set,
9891024
quad8_synch_mode_enum),

0 commit comments

Comments
 (0)