1
2
3
4
5
6
7#ifndef R592_H
8
9#include <linux/memstick.h>
10#include <linux/spinlock.h>
11#include <linux/interrupt.h>
12#include <linux/workqueue.h>
13#include <linux/kfifo.h>
14#include <linux/ctype.h>
15
16
17#define R592_TPC_EXEC 0x00
18#define R592_TPC_EXEC_LEN_SHIFT 16
19#define R592_TPC_EXEC_BIG_FIFO (1 << 26)
20#define R592_TPC_EXEC_TPC_SHIFT 28
21
22
23
24
25
26#define R592_SFIFO 0x08
27
28
29
30#define R592_STATUS 0x10
31
32#define R592_STATUS_P_CMDNACK (1 << 16)
33#define R592_STATUS_P_BREQ (1 << 17)
34#define R592_STATUS_P_INTERR (1 << 18)
35#define R592_STATUS_P_CED (1 << 19)
36
37
38#define R592_STATUS_SFIFO_FULL (1 << 20)
39#define R592_STATUS_SFIFO_EMPTY (1 << 21)
40
41
42#define R592_STATUS_SEND_ERR (1 << 24)
43#define R592_STATUS_RECV_ERR (1 << 25)
44
45
46#define R592_STATUS_RDY (1 << 28)
47#define R592_STATUS_CED (1 << 29)
48#define R592_STATUS_SFIFO_INPUT (1 << 30)
49
50#define R592_SFIFO_SIZE 32
51#define R592_SFIFO_PACKET 8
52
53
54#define R592_IO 0x18
55#define R592_IO_16 (1 << 16)
56#define R592_IO_18 (1 << 18)
57#define R592_IO_SERIAL1 (1 << 20)
58#define R592_IO_22 (1 << 22)
59#define R592_IO_DIRECTION (1 << 24)
60#define R592_IO_26 (1 << 26)
61#define R592_IO_SERIAL2 (1 << 30)
62#define R592_IO_RESET (1 << 31)
63
64
65
66#define R592_POWER 0x20
67#define R592_POWER_0 (1 << 0)
68#define R592_POWER_1 (1 << 1)
69#define R592_POWER_3 (1 << 3)
70#define R592_POWER_20 (1 << 5)
71
72
73#define R592_IO_MODE 0x24
74#define R592_IO_MODE_SERIAL 1
75#define R592_IO_MODE_PARALLEL 3
76
77
78
79
80#define R592_REG_MSC 0x28
81#define R592_REG_MSC_PRSNT (1 << 1)
82#define R592_REG_MSC_IRQ_INSERT (1 << 8)
83#define R592_REG_MSC_IRQ_REMOVE (1 << 9)
84#define R592_REG_MSC_FIFO_EMPTY (1 << 10)
85#define R592_REG_MSC_FIFO_DMA_DONE (1 << 11)
86
87#define R592_REG_MSC_FIFO_USER_ORN (1 << 12)
88#define R592_REG_MSC_FIFO_MISMATH (1 << 13)
89#define R592_REG_MSC_FIFO_DMA_ERR (1 << 14)
90#define R592_REG_MSC_LED (1 << 15)
91
92#define DMA_IRQ_ACK_MASK \
93 (R592_REG_MSC_FIFO_DMA_DONE | R592_REG_MSC_FIFO_DMA_ERR)
94
95#define DMA_IRQ_EN_MASK (DMA_IRQ_ACK_MASK << 16)
96
97#define IRQ_ALL_ACK_MASK 0x00007F00
98#define IRQ_ALL_EN_MASK (IRQ_ALL_ACK_MASK << 16)
99
100
101#define R592_FIFO_DMA 0x2C
102
103
104#define R592_FIFO_PIO 0x30
105#define R592_LFIFO_SIZE 512
106
107
108
109#define R592_FIFO_DMA_SETTINGS 0x34
110#define R592_FIFO_DMA_SETTINGS_EN (1 << 0)
111#define R592_FIFO_DMA_SETTINGS_DIR (1 << 1)
112#define R592_FIFO_DMA_SETTINGS_CAP (1 << 24)
113
114
115
116
117
118
119
120#define R592_REG38 0x38
121#define R592_REG38_CHANGE (1 << 16)
122#define R592_REG38_DONE (1 << 20)
123#define R592_REG38_SHIFT 17
124
125
126#define R592_REG_3C 0x3C
127
128struct r592_device {
129 struct pci_dev *pci_dev;
130 struct memstick_host *host;
131 struct memstick_request *req;
132
133
134 void __iomem *mmio;
135 int irq;
136 spinlock_t irq_lock;
137 spinlock_t io_thread_lock;
138 struct timer_list detect_timer;
139
140 struct task_struct *io_thread;
141 bool parallel_mode;
142
143 DECLARE_KFIFO(pio_fifo, u8, sizeof(u32));
144
145
146 int dma_capable;
147 int dma_error;
148 struct completion dma_done;
149 void *dummy_dma_page;
150 dma_addr_t dummy_dma_page_physical_address;
151
152};
153
154#define DRV_NAME "r592"
155
156
157#define message(format, ...) \
158 printk(KERN_INFO DRV_NAME ": " format "\n", ## __VA_ARGS__)
159
160#define __dbg(level, format, ...) \
161 do { \
162 if (debug >= level) \
163 printk(KERN_DEBUG DRV_NAME \
164 ": " format "\n", ## __VA_ARGS__); \
165 } while (0)
166
167
168#define dbg(format, ...) __dbg(1, format, ## __VA_ARGS__)
169#define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__)
170#define dbg_reg(format, ...) __dbg(3, format, ## __VA_ARGS__)
171
172#endif
173