0001
0002
0003
0004
0005
0006
0007 #ifndef R592_H
0008
0009 #include <linux/memstick.h>
0010 #include <linux/spinlock.h>
0011 #include <linux/interrupt.h>
0012 #include <linux/workqueue.h>
0013 #include <linux/kfifo.h>
0014 #include <linux/ctype.h>
0015
0016
0017 #define R592_TPC_EXEC 0x00
0018 #define R592_TPC_EXEC_LEN_SHIFT 16
0019 #define R592_TPC_EXEC_BIG_FIFO (1 << 26)
0020 #define R592_TPC_EXEC_TPC_SHIFT 28
0021
0022
0023
0024
0025
0026 #define R592_SFIFO 0x08
0027
0028
0029
0030 #define R592_STATUS 0x10
0031
0032 #define R592_STATUS_P_CMDNACK (1 << 16)
0033 #define R592_STATUS_P_BREQ (1 << 17)
0034 #define R592_STATUS_P_INTERR (1 << 18)
0035 #define R592_STATUS_P_CED (1 << 19)
0036
0037
0038 #define R592_STATUS_SFIFO_FULL (1 << 20)
0039 #define R592_STATUS_SFIFO_EMPTY (1 << 21)
0040
0041
0042 #define R592_STATUS_SEND_ERR (1 << 24)
0043 #define R592_STATUS_RECV_ERR (1 << 25)
0044
0045
0046 #define R592_STATUS_RDY (1 << 28)
0047 #define R592_STATUS_CED (1 << 29)
0048 #define R592_STATUS_SFIFO_INPUT (1 << 30)
0049
0050 #define R592_SFIFO_SIZE 32
0051 #define R592_SFIFO_PACKET 8
0052
0053
0054 #define R592_IO 0x18
0055 #define R592_IO_16 (1 << 16)
0056 #define R592_IO_18 (1 << 18)
0057 #define R592_IO_SERIAL1 (1 << 20)
0058 #define R592_IO_22 (1 << 22)
0059 #define R592_IO_DIRECTION (1 << 24)
0060 #define R592_IO_26 (1 << 26)
0061 #define R592_IO_SERIAL2 (1 << 30)
0062 #define R592_IO_RESET (1 << 31)
0063
0064
0065
0066 #define R592_POWER 0x20
0067 #define R592_POWER_0 (1 << 0)
0068 #define R592_POWER_1 (1 << 1)
0069 #define R592_POWER_3 (1 << 3)
0070 #define R592_POWER_20 (1 << 5)
0071
0072
0073 #define R592_IO_MODE 0x24
0074 #define R592_IO_MODE_SERIAL 1
0075 #define R592_IO_MODE_PARALLEL 3
0076
0077
0078
0079
0080 #define R592_REG_MSC 0x28
0081 #define R592_REG_MSC_PRSNT (1 << 1)
0082 #define R592_REG_MSC_IRQ_INSERT (1 << 8)
0083 #define R592_REG_MSC_IRQ_REMOVE (1 << 9)
0084 #define R592_REG_MSC_FIFO_EMPTY (1 << 10)
0085 #define R592_REG_MSC_FIFO_DMA_DONE (1 << 11)
0086
0087 #define R592_REG_MSC_FIFO_USER_ORN (1 << 12)
0088 #define R592_REG_MSC_FIFO_MISMATH (1 << 13)
0089 #define R592_REG_MSC_FIFO_DMA_ERR (1 << 14)
0090 #define R592_REG_MSC_LED (1 << 15)
0091
0092 #define DMA_IRQ_ACK_MASK \
0093 (R592_REG_MSC_FIFO_DMA_DONE | R592_REG_MSC_FIFO_DMA_ERR)
0094
0095 #define DMA_IRQ_EN_MASK (DMA_IRQ_ACK_MASK << 16)
0096
0097 #define IRQ_ALL_ACK_MASK 0x00007F00
0098 #define IRQ_ALL_EN_MASK (IRQ_ALL_ACK_MASK << 16)
0099
0100
0101 #define R592_FIFO_DMA 0x2C
0102
0103
0104 #define R592_FIFO_PIO 0x30
0105 #define R592_LFIFO_SIZE 512
0106
0107
0108
0109 #define R592_FIFO_DMA_SETTINGS 0x34
0110 #define R592_FIFO_DMA_SETTINGS_EN (1 << 0)
0111 #define R592_FIFO_DMA_SETTINGS_DIR (1 << 1)
0112 #define R592_FIFO_DMA_SETTINGS_CAP (1 << 24)
0113
0114
0115
0116
0117
0118
0119
0120 #define R592_REG38 0x38
0121 #define R592_REG38_CHANGE (1 << 16)
0122 #define R592_REG38_DONE (1 << 20)
0123 #define R592_REG38_SHIFT 17
0124
0125
0126 #define R592_REG_3C 0x3C
0127
0128 struct r592_device {
0129 struct pci_dev *pci_dev;
0130 struct memstick_host *host;
0131 struct memstick_request *req;
0132
0133
0134 void __iomem *mmio;
0135 int irq;
0136 spinlock_t irq_lock;
0137 spinlock_t io_thread_lock;
0138 struct timer_list detect_timer;
0139
0140 struct task_struct *io_thread;
0141 bool parallel_mode;
0142
0143 DECLARE_KFIFO(pio_fifo, u8, sizeof(u32));
0144
0145
0146 int dma_capable;
0147 int dma_error;
0148 struct completion dma_done;
0149 void *dummy_dma_page;
0150 dma_addr_t dummy_dma_page_physical_address;
0151
0152 };
0153
0154 #define DRV_NAME "r592"
0155
0156
0157 #define message(format, ...) \
0158 printk(KERN_INFO DRV_NAME ": " format "\n", ## __VA_ARGS__)
0159
0160 #define __dbg(level, format, ...) \
0161 do { \
0162 if (debug >= level) \
0163 printk(KERN_DEBUG DRV_NAME \
0164 ": " format "\n", ## __VA_ARGS__); \
0165 } while (0)
0166
0167
0168 #define dbg(format, ...) __dbg(1, format, ## __VA_ARGS__)
0169 #define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__)
0170 #define dbg_reg(format, ...) __dbg(3, format, ## __VA_ARGS__)
0171
0172 #endif