linux/drivers/counter/104-quad-8.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Counter driver for the ACCES 104-QUAD-8
 * Copyright (C) 2016 William Breathitt Gray
 *
 * This driver supports the ACCES 104-QUAD-8 and ACCES 104-QUAD-4.
 */
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/counter.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/isa.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/regmap.h>
#include <linux/spinlock.h>
#include <linux/types.h>

#include <linux/unaligned.h>

#define QUAD8_EXTENT

static unsigned int base[max_num_isa_dev(QUAD8_EXTENT)];
static unsigned int num_quad8;
module_param_hw_array(base, uint, ioport, &num_quad8, 0);
MODULE_PARM_DESC();

static unsigned int irq[max_num_isa_dev(QUAD8_EXTENT)];
static unsigned int num_irq;
module_param_hw_array(irq, uint, irq, &num_irq, 0);
MODULE_PARM_DESC();

#define QUAD8_NUM_COUNTERS

#define QUAD8_DATA(_channel)
#define QUAD8_CONTROL(_channel)
#define QUAD8_INTERRUPT_STATUS
#define QUAD8_CHANNEL_OPERATION
#define QUAD8_INDEX_INTERRUPT
#define QUAD8_INDEX_INPUT_LEVELS
#define QUAD8_CABLE_STATUS

/**
 * struct quad8 - device private data structure
 * @lock:		lock to prevent clobbering device states during R/W ops
 * @cmr:		array of Counter Mode Register states
 * @ior:		array of Input / Output Control Register states
 * @idr:		array of Index Control Register states
 * @fck_prescaler:	array of filter clock prescaler configurations
 * @preset:		array of preset values
 * @cable_fault_enable:	differential encoder cable status enable configurations
 * @map:		regmap for the device
 */
struct quad8 {};

static const struct regmap_range quad8_wr_ranges[] =;
static const struct regmap_range quad8_rd_ranges[] =;
static const struct regmap_access_table quad8_wr_table =;
static const struct regmap_access_table quad8_rd_table =;
static const struct regmap_config quad8_regmap_config =;

/* Error flag */
#define FLAG_E
/* Up/Down flag */
#define FLAG_UD
/* Counting up */
#define UP

#define REGISTER_SELECTION

/* Reset and Load Signal Decoders */
#define SELECT_RLD
/* Counter Mode Register */
#define SELECT_CMR
/* Input / Output Control Register */
#define SELECT_IOR
/* Index Control Register */
#define SELECT_IDR

/*
 * Reset and Load Signal Decoders
 */
#define RESETS
#define LOADS
/* Reset Byte Pointer (three byte data pointer) */
#define RESET_BP
/* Reset Borrow Toggle, Carry toggle, Compare toggle, Sign, and Index flags */
#define RESET_BT_CT_CPT_S_IDX
/* Reset Error flag */
#define RESET_E
/* Preset Register to Counter */
#define TRANSFER_PR_TO_CNTR
/* Transfer Counter to Output Latch */
#define TRANSFER_CNTR_TO_OL
/* Transfer Preset Register LSB to FCK Prescaler */
#define TRANSFER_PR0_TO_PSC

/*
 * Counter Mode Registers
 */
#define COUNT_ENCODING
#define COUNT_MODE
#define QUADRATURE_MODE
/* Binary count */
#define BINARY
/* Normal count */
#define NORMAL_COUNT
/* Range Limit */
#define RANGE_LIMIT
/* Non-recycle count */
#define NON_RECYCLE_COUNT
/* Modulo-N */
#define MODULO_N
/* Non-quadrature */
#define NON_QUADRATURE
/* Quadrature X1 */
#define QUADRATURE_X1
/* Quadrature X2 */
#define QUADRATURE_X2
/* Quadrature X4 */
#define QUADRATURE_X4

/*
 * Input/Output Control Register
 */
#define AB_GATE
#define LOAD_PIN
#define FLG_PINS
/* Disable inputs A and B */
#define DISABLE_AB
/* Load Counter input */
#define LOAD_CNTR
/* FLG1 = CARRY(active low); FLG2 = BORROW(active low) */
#define FLG1_CARRY_FLG2_BORROW
/* FLG1 = COMPARE(active low); FLG2 = BORROW(active low) */
#define FLG1_COMPARE_FLG2_BORROW
/* FLG1 = Carry(active low)/Borrow(active low); FLG2 = U/D(active low) flag */
#define FLG1_CARRYBORROW_FLG2_UD
/* FLG1 = INDX (low pulse at INDEX pin active level); FLG2 = E flag */
#define FLG1_INDX_FLG2_E

/*
 * INDEX CONTROL REGISTERS
 */
#define INDEX_MODE
#define INDEX_POLARITY
/* Disable Index mode */
#define DISABLE_INDEX_MODE
/* Enable Index mode */
#define ENABLE_INDEX_MODE
/* Negative Index Polarity */
#define NEGATIVE_INDEX_POLARITY
/* Positive Index Polarity */
#define POSITIVE_INDEX_POLARITY

/*
 * Channel Operation Register
 */
#define COUNTERS_OPERATION
#define INTERRUPT_FUNCTION
/* Enable all Counters */
#define ENABLE_COUNTERS
/* Reset all Counters */
#define RESET_COUNTERS
/* Disable the interrupt function */
#define DISABLE_INTERRUPT_FUNCTION
/* Enable the interrupt function */
#define ENABLE_INTERRUPT_FUNCTION
/* Any write to the Channel Operation register clears any pending interrupts */
#define CLEAR_PENDING_INTERRUPTS

/* Each Counter is 24 bits wide */
#define LS7267_CNTR_MAX

static __always_inline int quad8_control_register_update(struct regmap *const map, u8 *const buf,
							 const size_t channel, const u8 val,
							 const u8 field)
{}

static int quad8_signal_read(struct counter_device *counter,
			     struct counter_signal *signal,
			     enum counter_signal_level *level)
{}

static int quad8_count_read(struct counter_device *counter,
			    struct counter_count *count, u64 *val)
{}

static int quad8_preset_register_set(struct quad8 *const priv, const size_t id,
				     const unsigned long preset)
{}

static int quad8_flag_register_reset(struct quad8 *const priv, const size_t id)
{}

static int quad8_count_write(struct counter_device *counter,
			     struct counter_count *count, u64 val)
{}

static const enum counter_function quad8_count_functions_list[] =;

static int quad8_function_get(const struct quad8 *const priv, const size_t id,
			      enum counter_function *const function)
{}

static int quad8_function_read(struct counter_device *counter,
			       struct counter_count *count,
			       enum counter_function *function)
{}

static int quad8_function_write(struct counter_device *counter,
				struct counter_count *count,
				enum counter_function function)
{}

static int quad8_direction_read(struct counter_device *counter,
				struct counter_count *count,
				enum counter_count_direction *direction)
{}

static const enum counter_synapse_action quad8_index_actions_list[] =;

static const enum counter_synapse_action quad8_synapse_actions_list[] =;

static int quad8_action_read(struct counter_device *counter,
			     struct counter_count *count,
			     struct counter_synapse *synapse,
			     enum counter_synapse_action *action)
{}

static int quad8_events_configure(struct counter_device *counter)
{}

static int quad8_watch_validate(struct counter_device *counter,
				const struct counter_watch *watch)
{}

static const struct counter_ops quad8_ops =;

static const char *const quad8_index_polarity_modes[] =;

static int quad8_index_polarity_get(struct counter_device *counter,
				    struct counter_signal *signal,
				    u32 *index_polarity)
{}

static int quad8_index_polarity_set(struct counter_device *counter,
				    struct counter_signal *signal,
				    u32 index_polarity)
{}

static int quad8_polarity_read(struct counter_device *counter,
			       struct counter_signal *signal,
			       enum counter_signal_polarity *polarity)
{}

static int quad8_polarity_write(struct counter_device *counter,
				struct counter_signal *signal,
				enum counter_signal_polarity polarity)
{}

static const char *const quad8_synchronous_modes[] =;

static int quad8_synchronous_mode_get(struct counter_device *counter,
				      struct counter_signal *signal,
				      u32 *synchronous_mode)
{}

static int quad8_synchronous_mode_set(struct counter_device *counter,
				      struct counter_signal *signal,
				      u32 synchronous_mode)
{}

static int quad8_count_floor_read(struct counter_device *counter,
				  struct counter_count *count, u64 *floor)
{}

static int quad8_count_mode_read(struct counter_device *counter,
				 struct counter_count *count,
				 enum counter_count_mode *cnt_mode)
{}

static int quad8_count_mode_write(struct counter_device *counter,
				  struct counter_count *count,
				  enum counter_count_mode cnt_mode)
{}

static int quad8_count_enable_read(struct counter_device *counter,
				   struct counter_count *count, u8 *enable)
{}

static int quad8_count_enable_write(struct counter_device *counter,
				    struct counter_count *count, u8 enable)
{}

static const char *const quad8_noise_error_states[] =;

static int quad8_error_noise_get(struct counter_device *counter,
				 struct counter_count *count, u32 *noise_error)
{}

static int quad8_count_preset_read(struct counter_device *counter,
				   struct counter_count *count, u64 *preset)
{}

static int quad8_count_preset_write(struct counter_device *counter,
				    struct counter_count *count, u64 preset)
{}

static int quad8_count_ceiling_read(struct counter_device *counter,
				    struct counter_count *count, u64 *ceiling)
{}

static int quad8_count_ceiling_write(struct counter_device *counter,
				     struct counter_count *count, u64 ceiling)
{}

static int quad8_count_preset_enable_read(struct counter_device *counter,
					  struct counter_count *count,
					  u8 *preset_enable)
{}

static int quad8_count_preset_enable_write(struct counter_device *counter,
					   struct counter_count *count,
					   u8 preset_enable)
{}

static int quad8_signal_cable_fault_read(struct counter_device *counter,
					 struct counter_signal *signal,
					 u8 *cable_fault)
{}

static int quad8_signal_cable_fault_enable_read(struct counter_device *counter,
						struct counter_signal *signal,
						u8 *enable)
{}

static int quad8_signal_cable_fault_enable_write(struct counter_device *counter,
						 struct counter_signal *signal,
						 u8 enable)
{}

static int quad8_signal_fck_prescaler_read(struct counter_device *counter,
					   struct counter_signal *signal,
					   u8 *prescaler)
{}

static int quad8_filter_clock_prescaler_set(struct quad8 *const priv, const size_t id,
					    const u8 prescaler)
{}

static int quad8_signal_fck_prescaler_write(struct counter_device *counter,
					    struct counter_signal *signal,
					    u8 prescaler)
{}

static struct counter_comp quad8_signal_ext[] =;

static const enum counter_signal_polarity quad8_polarities[] =;

static DEFINE_COUNTER_AVAILABLE(quad8_polarity_available, quad8_polarities);

static DEFINE_COUNTER_ENUM(quad8_index_pol_enum, quad8_index_polarity_modes);
static DEFINE_COUNTER_ENUM(quad8_synch_mode_enum, quad8_synchronous_modes);

static struct counter_comp quad8_index_ext[] =;

#define QUAD8_QUAD_SIGNAL(_id, _name)

#define QUAD8_INDEX_SIGNAL(_id, _name)

static struct counter_signal quad8_signals[] =;

#define QUAD8_COUNT_SYNAPSES(_id)

static struct counter_synapse quad8_count_synapses[][3] =;

static const enum counter_count_mode quad8_cnt_modes[] =;

static DEFINE_COUNTER_AVAILABLE(quad8_count_mode_available, quad8_cnt_modes);

static DEFINE_COUNTER_ENUM(quad8_error_noise_enum, quad8_noise_error_states);

static struct counter_comp quad8_count_ext[] =;

#define QUAD8_COUNT(_id, _cntname)

static struct counter_count quad8_counts[] =;

static irqreturn_t quad8_irq_handler(int irq, void *private)
{}

static int quad8_init_counter(struct quad8 *const priv, const size_t channel)
{}

static int quad8_probe(struct device *dev, unsigned int id)
{}

static struct isa_driver quad8_driver =;

module_isa_driver_with_irq(quad8_driver, num_quad8, num_irq);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_IMPORT_NS();