Commit fce0ff52 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: gsc_hpdi: tidy up the register map

For aesthetics, convert the various enums into simple defines to
describe the register map for the board. Group the bit defines with
the associated register define. Convert the helper functions for
the register bit/shift/mask stuff into simple defines.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4cbbacb2
...@@ -52,115 +52,80 @@ ...@@ -52,115 +52,80 @@
#include "plx9080.h" #include "plx9080.h"
#include "comedi_fc.h" #include "comedi_fc.h"
#define TIMER_BASE 50 /* 20MHz master clock */ /*
#define DMA_BUFFER_SIZE 0x10000 * PCI BAR2 Register map (devpriv->mmio)
#define NUM_DMA_BUFFERS 4 */
#define NUM_DMA_DESCRIPTORS 256 #define FIRMWARE_REV_REG 0x00
#define FEATURES_REG_PRESENT_BIT (1 << 15)
enum hpdi_registers { #define BOARD_CONTROL_REG 0x04
FIRMWARE_REV_REG = 0x0, #define BOARD_RESET_BIT (1 << 0)
BOARD_CONTROL_REG = 0x4, #define TX_FIFO_RESET_BIT (1 << 1)
BOARD_STATUS_REG = 0x8, #define RX_FIFO_RESET_BIT (1 << 2)
TX_PROG_ALMOST_REG = 0xc, #define TX_ENABLE_BIT (1 << 4)
RX_PROG_ALMOST_REG = 0x10, #define RX_ENABLE_BIT (1 << 5)
FEATURES_REG = 0x14, #define DEMAND_DMA_DIRECTION_TX_BIT (1 << 6) /* ch 0 only */
FIFO_REG = 0x18, #define LINE_VALID_ON_STATUS_VALID_BIT (1 << 7)
TX_STATUS_COUNT_REG = 0x1c, #define START_TX_BIT (1 << 8)
TX_LINE_VALID_COUNT_REG = 0x20, #define CABLE_THROTTLE_ENABLE_BIT (1 << 9)
TX_LINE_INVALID_COUNT_REG = 0x24, #define TEST_MODE_ENABLE_BIT (1 << 31)
RX_STATUS_COUNT_REG = 0x28, #define BOARD_STATUS_REG 0x08
RX_LINE_COUNT_REG = 0x2c, #define COMMAND_LINE_STATUS_MASK (0x7f << 0)
INTERRUPT_CONTROL_REG = 0x30, #define TX_IN_PROGRESS_BIT (1 << 7)
INTERRUPT_STATUS_REG = 0x34, #define TX_NOT_EMPTY_BIT (1 << 8)
TX_CLOCK_DIVIDER_REG = 0x38, #define TX_NOT_ALMOST_EMPTY_BIT (1 << 9)
TX_FIFO_SIZE_REG = 0x40, #define TX_NOT_ALMOST_FULL_BIT (1 << 10)
RX_FIFO_SIZE_REG = 0x44, #define TX_NOT_FULL_BIT (1 << 11)
TX_FIFO_WORDS_REG = 0x48, #define RX_NOT_EMPTY_BIT (1 << 12)
RX_FIFO_WORDS_REG = 0x4c, #define RX_NOT_ALMOST_EMPTY_BIT (1 << 13)
INTERRUPT_EDGE_LEVEL_REG = 0x50, #define RX_NOT_ALMOST_FULL_BIT (1 << 14)
INTERRUPT_POLARITY_REG = 0x54, #define RX_NOT_FULL_BIT (1 << 15)
}; #define BOARD_JUMPER0_INSTALLED_BIT (1 << 16)
#define BOARD_JUMPER1_INSTALLED_BIT (1 << 17)
/* bit definitions */ #define TX_OVERRUN_BIT (1 << 21)
#define RX_UNDERRUN_BIT (1 << 22)
enum firmware_revision_bits { #define RX_OVERRUN_BIT (1 << 23)
FEATURES_REG_PRESENT_BIT = 0x8000, #define TX_PROG_ALMOST_REG 0x0c
}; #define RX_PROG_ALMOST_REG 0x10
#define ALMOST_EMPTY_BITS(x) (((x) & 0xffff) << 0)
enum board_control_bits { #define ALMOST_FULL_BITS(x) (((x) & 0xff) << 16)
BOARD_RESET_BIT = 0x1, /* wait 10usec before accessing fifos */ #define FEATURES_REG 0x14
TX_FIFO_RESET_BIT = 0x2, #define FIFO_SIZE_PRESENT_BIT (1 << 0)
RX_FIFO_RESET_BIT = 0x4, #define FIFO_WORDS_PRESENT_BIT (1 << 1)
TX_ENABLE_BIT = 0x10, #define LEVEL_EDGE_INTERRUPTS_PRESENT_BIT (1 << 2)
RX_ENABLE_BIT = 0x20, #define GPIO_SUPPORTED_BIT (1 << 3)
DEMAND_DMA_DIRECTION_TX_BIT = 0x40, #define PLX_DMA_CH1_SUPPORTED_BIT (1 << 4)
/* for ch 0, ch 1 can only transmit (when present) */ #define OVERRUN_UNDERRUN_SUPPORTED_BIT (1 << 5)
LINE_VALID_ON_STATUS_VALID_BIT = 0x80, #define FIFO_REG 0x18
START_TX_BIT = 0x10, #define TX_STATUS_COUNT_REG 0x1c
CABLE_THROTTLE_ENABLE_BIT = 0x20, #define TX_LINE_VALID_COUNT_REG 0x20,
TEST_MODE_ENABLE_BIT = 0x80000000, #define TX_LINE_INVALID_COUNT_REG 0x24
}; #define RX_STATUS_COUNT_REG 0x28
#define RX_LINE_COUNT_REG 0x2c
enum board_status_bits { #define INTERRUPT_CONTROL_REG 0x30
COMMAND_LINE_STATUS_MASK = 0x7f, #define FRAME_VALID_START_INTR (1 << 0)
TX_IN_PROGRESS_BIT = 0x80, #define FRAME_VALID_END_INTR (1 << 1)
TX_NOT_EMPTY_BIT = 0x100, #define TX_FIFO_EMPTY_INTR (1 << 8)
TX_NOT_ALMOST_EMPTY_BIT = 0x200, #define TX_FIFO_ALMOST_EMPTY_INTR (1 << 9)
TX_NOT_ALMOST_FULL_BIT = 0x400, #define TX_FIFO_ALMOST_FULL_INTR (1 << 10)
TX_NOT_FULL_BIT = 0x800, #define TX_FIFO_FULL_INTR (1 << 11)
RX_NOT_EMPTY_BIT = 0x1000, #define RX_EMPTY_INTR (1 << 12)
RX_NOT_ALMOST_EMPTY_BIT = 0x2000, #define RX_ALMOST_EMPTY_INTR (1 << 13)
RX_NOT_ALMOST_FULL_BIT = 0x4000, #define RX_ALMOST_FULL_INTR (1 << 14)
RX_NOT_FULL_BIT = 0x8000, #define RX_FULL_INTR (1 << 15)
BOARD_JUMPER0_INSTALLED_BIT = 0x10000, #define INTERRUPT_STATUS_REG 0x34
BOARD_JUMPER1_INSTALLED_BIT = 0x20000, #define TX_CLOCK_DIVIDER_REG 0x38
TX_OVERRUN_BIT = 0x200000, #define TX_FIFO_SIZE_REG 0x40
RX_UNDERRUN_BIT = 0x400000, #define RX_FIFO_SIZE_REG 0x44
RX_OVERRUN_BIT = 0x800000, #define FIFO_SIZE_MASK (0xfffff << 0)
}; #define TX_FIFO_WORDS_REG 0x48
#define RX_FIFO_WORDS_REG 0x4c
static uint32_t almost_full_bits(unsigned int num_words) #define INTERRUPT_EDGE_LEVEL_REG 0x50
{ #define INTERRUPT_POLARITY_REG 0x54
/* XXX need to add or subtract one? */
return (num_words << 16) & 0xff0000; #define TIMER_BASE 50 /* 20MHz master clock */
} #define DMA_BUFFER_SIZE 0x10000
#define NUM_DMA_BUFFERS 4
static uint32_t almost_empty_bits(unsigned int num_words) #define NUM_DMA_DESCRIPTORS 256
{
return num_words & 0xffff;
}
enum features_bits {
FIFO_SIZE_PRESENT_BIT = 0x1,
FIFO_WORDS_PRESENT_BIT = 0x2,
LEVEL_EDGE_INTERRUPTS_PRESENT_BIT = 0x4,
GPIO_SUPPORTED_BIT = 0x8,
PLX_DMA_CH1_SUPPORTED_BIT = 0x10,
OVERRUN_UNDERRUN_SUPPORTED_BIT = 0x20,
};
enum interrupt_sources {
FRAME_VALID_START_INTR = 0,
FRAME_VALID_END_INTR = 1,
TX_FIFO_EMPTY_INTR = 8,
TX_FIFO_ALMOST_EMPTY_INTR = 9,
TX_FIFO_ALMOST_FULL_INTR = 10,
TX_FIFO_FULL_INTR = 11,
RX_EMPTY_INTR = 12,
RX_ALMOST_EMPTY_INTR = 13,
RX_ALMOST_FULL_INTR = 14,
RX_FULL_INTR = 15,
};
static uint32_t intr_bit(int interrupt_source)
{
return 0x1 << interrupt_source;
}
static unsigned int fifo_size(uint32_t fifo_size_bits)
{
return fifo_size_bits & 0xfffff;
}
struct hpdi_board { struct hpdi_board {
const char *name; /* board name */ const char *name; /* board name */
...@@ -390,7 +355,7 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, ...@@ -390,7 +355,7 @@ static int gsc_hpdi_cmd(struct comedi_device *dev,
devpriv->mmio + BOARD_STATUS_REG); devpriv->mmio + BOARD_STATUS_REG);
/* enable interrupts */ /* enable interrupts */
writel(intr_bit(RX_FULL_INTR), devpriv->mmio + INTERRUPT_CONTROL_REG); writel(RX_FULL_INTR, devpriv->mmio + INTERRUPT_CONTROL_REG);
writel(RX_ENABLE_BIT, devpriv->mmio + BOARD_CONTROL_REG); writel(RX_ENABLE_BIT, devpriv->mmio + BOARD_CONTROL_REG);
...@@ -541,18 +506,19 @@ static int gsc_hpdi_init(struct comedi_device *dev) ...@@ -541,18 +506,19 @@ static int gsc_hpdi_init(struct comedi_device *dev)
struct hpdi_private *devpriv = dev->private; struct hpdi_private *devpriv = dev->private;
uint32_t plx_intcsr_bits; uint32_t plx_intcsr_bits;
/* wait 10usec after reset before accessing fifos */
writel(BOARD_RESET_BIT, devpriv->mmio + BOARD_CONTROL_REG); writel(BOARD_RESET_BIT, devpriv->mmio + BOARD_CONTROL_REG);
udelay(10); udelay(10);
writel(almost_empty_bits(32) | almost_full_bits(32), writel(ALMOST_EMPTY_BITS(32) | ALMOST_FULL_BITS(32),
devpriv->mmio + RX_PROG_ALMOST_REG); devpriv->mmio + RX_PROG_ALMOST_REG);
writel(almost_empty_bits(32) | almost_full_bits(32), writel(ALMOST_EMPTY_BITS(32) | ALMOST_FULL_BITS(32),
devpriv->mmio + TX_PROG_ALMOST_REG); devpriv->mmio + TX_PROG_ALMOST_REG);
devpriv->tx_fifo_size = fifo_size(readl(devpriv->mmio + devpriv->tx_fifo_size = readl(devpriv->mmio + TX_FIFO_SIZE_REG) &
TX_FIFO_SIZE_REG)); FIFO_SIZE_MASK;
devpriv->rx_fifo_size = fifo_size(readl(devpriv->mmio + devpriv->rx_fifo_size = readl(devpriv->mmio + RX_FIFO_SIZE_REG) &
RX_FIFO_SIZE_REG)); FIFO_SIZE_MASK;
writel(0, devpriv->mmio + INTERRUPT_CONTROL_REG); writel(0, devpriv->mmio + INTERRUPT_CONTROL_REG);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment