3056bcd8a393e36c70415af1656fae59e2c84f1f
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / isp1760-hcd.h
1 #ifndef _ISP1760_HCD_H_
2 #define _ISP1760_HCD_H_
3
4 /* exports for if */
5 int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
6                      struct device *dev, unsigned int devflags);
7 void isp1760_unregister(struct device *dev);
8
9 int isp1760_init_kmem_once(void);
10 void isp1760_deinit_kmem_cache(void);
11
12 /* EHCI capability registers */
13 #define HC_CAPLENGTH            0x00
14 #define HC_HCSPARAMS            0x04
15 #define HC_HCCPARAMS            0x08
16
17 /* EHCI operational registers */
18 #define HC_USBCMD               0x20
19 #define HC_USBSTS               0x24
20 #define HC_FRINDEX              0x2c
21 #define HC_CONFIGFLAG           0x60
22 #define HC_PORTSC1              0x64
23 #define HC_ISO_PTD_DONEMAP_REG  0x130
24 #define HC_ISO_PTD_SKIPMAP_REG  0x134
25 #define HC_ISO_PTD_LASTPTD_REG  0x138
26 #define HC_INT_PTD_DONEMAP_REG  0x140
27 #define HC_INT_PTD_SKIPMAP_REG  0x144
28 #define HC_INT_PTD_LASTPTD_REG  0x148
29 #define HC_ATL_PTD_DONEMAP_REG  0x150
30 #define HC_ATL_PTD_SKIPMAP_REG  0x154
31 #define HC_ATL_PTD_LASTPTD_REG  0x158
32
33 /* Configuration Register */
34 #define HC_HW_MODE_CTRL         0x300
35 #define ALL_ATX_RESET           (1 << 31)
36 #define HW_ANA_DIGI_OC          (1 << 15)
37 #define HW_DATA_BUS_32BIT       (1 << 8)
38 #define HW_DACK_POL_HIGH        (1 << 6)
39 #define HW_DREQ_POL_HIGH        (1 << 5)
40 #define HW_INTR_HIGH_ACT        (1 << 2)
41 #define HW_INTR_EDGE_TRIG       (1 << 1)
42 #define HW_GLOBAL_INTR_EN       (1 << 0)
43
44 #define HC_CHIP_ID_REG          0x304
45 #define HC_SCRATCH_REG          0x308
46
47 #define HC_RESET_REG            0x30c
48 #define SW_RESET_RESET_HC       (1 << 1)
49 #define SW_RESET_RESET_ALL      (1 << 0)
50
51 #define HC_BUFFER_STATUS_REG    0x334
52 #define ISO_BUF_FILL            (1 << 2)
53 #define INT_BUF_FILL            (1 << 1)
54 #define ATL_BUF_FILL            (1 << 0)
55
56 #define HC_MEMORY_REG           0x33c
57 #define ISP_BANK(x)             ((x) << 16)
58
59 #define HC_PORT1_CTRL           0x374
60 #define PORT1_POWER             (3 << 3)
61 #define PORT1_INIT1             (1 << 7)
62 #define PORT1_INIT2             (1 << 23)
63 #define HW_OTG_CTRL_SET         0x374
64 #define HW_OTG_CTRL_CLR         0x376
65
66 /* Interrupt Register */
67 #define HC_INTERRUPT_REG        0x310
68
69 #define HC_INTERRUPT_ENABLE     0x314
70 #define HC_ISO_INT              (1 << 9)
71 #define HC_ATL_INT              (1 << 8)
72 #define HC_INTL_INT             (1 << 7)
73 #define HC_EOT_INT              (1 << 3)
74 #define HC_SOT_INT              (1 << 1)
75 #define INTERRUPT_ENABLE_MASK   (HC_INTL_INT | HC_ATL_INT)
76
77 #define HC_ISO_IRQ_MASK_OR_REG  0x318
78 #define HC_INT_IRQ_MASK_OR_REG  0x31C
79 #define HC_ATL_IRQ_MASK_OR_REG  0x320
80 #define HC_ISO_IRQ_MASK_AND_REG 0x324
81 #define HC_INT_IRQ_MASK_AND_REG 0x328
82 #define HC_ATL_IRQ_MASK_AND_REG 0x32C
83
84 /* urb state*/
85 #define DELETE_URB              (0x0008)
86 #define NO_TRANSFER_ACTIVE      (0xffffffff)
87
88 /* Philips Proprietary Transfer Descriptor (PTD) */
89 typedef __u32 __bitwise __dw;
90 struct ptd {
91         __dw dw0;
92         __dw dw1;
93         __dw dw2;
94         __dw dw3;
95         __dw dw4;
96         __dw dw5;
97         __dw dw6;
98         __dw dw7;
99 };
100 #define PTD_OFFSET              0x0400
101 #define ISO_PTD_OFFSET          0x0400
102 #define INT_PTD_OFFSET          0x0800
103 #define ATL_PTD_OFFSET          0x0c00
104 #define PAYLOAD_OFFSET          0x1000
105
106 struct isp1760_slotinfo {
107         struct isp1760_qh *qh;
108         struct isp1760_qtd *qtd;
109         unsigned long timestamp;
110 };
111
112
113 /*
114  * Device flags that can vary from board to board.  All of these
115  * indicate the most "atypical" case, so that a devflags of 0 is
116  * a sane default configuration.
117  */
118 #define ISP1760_FLAG_BUS_WIDTH_16       0x00000002 /* 16-bit data bus width */
119 #define ISP1760_FLAG_OTG_EN             0x00000004 /* Port 1 supports OTG */
120 #define ISP1760_FLAG_ANALOG_OC          0x00000008 /* Analog overcurrent */
121 #define ISP1760_FLAG_DACK_POL_HIGH      0x00000010 /* DACK active high */
122 #define ISP1760_FLAG_DREQ_POL_HIGH      0x00000020 /* DREQ active high */
123 #define ISP1760_FLAG_ISP1761            0x00000040 /* Chip is ISP1761 */
124 #define ISP1760_FLAG_INTR_POL_HIGH      0x00000080 /* Interrupt polarity active high */
125 #define ISP1760_FLAG_INTR_EDGE_TRIG     0x00000100 /* Interrupt edge triggered */
126
127 /* chip memory management */
128 struct isp1760_memory_chunk {
129         unsigned int start;
130         unsigned int size;
131         unsigned int free;
132 };
133
134 /*
135  * 60kb divided in:
136  * - 32 blocks @ 256  bytes
137  * - 20 blocks @ 1024 bytes
138  * -  4 blocks @ 8192 bytes
139  */
140
141 #define BLOCK_1_NUM 32
142 #define BLOCK_2_NUM 20
143 #define BLOCK_3_NUM 4
144
145 #define BLOCK_1_SIZE 256
146 #define BLOCK_2_SIZE 1024
147 #define BLOCK_3_SIZE 8192
148 #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
149 #define MAX_PAYLOAD_SIZE BLOCK_3_SIZE
150 #define PAYLOAD_AREA_SIZE 0xf000
151
152 /* ATL */
153 /* DW0 */
154 #define DW0_VALID_BIT                   1
155 #define FROM_DW0_VALID(x)               ((x) & 0x01)
156 #define TO_DW0_LENGTH(x)                (((u32) x) << 3)
157 #define TO_DW0_MAXPACKET(x)             (((u32) x) << 18)
158 #define TO_DW0_MULTI(x)                 (((u32) x) << 29)
159 #define TO_DW0_ENDPOINT(x)              (((u32) x) << 31)
160 /* DW1 */
161 #define TO_DW1_DEVICE_ADDR(x)           (((u32) x) << 3)
162 #define TO_DW1_PID_TOKEN(x)             (((u32) x) << 10)
163 #define DW1_TRANS_BULK                  ((u32) 2 << 12)
164 #define DW1_TRANS_INT                   ((u32) 3 << 12)
165 #define DW1_TRANS_SPLIT                 ((u32) 1 << 14)
166 #define DW1_SE_USB_LOSPEED              ((u32) 2 << 16)
167 #define TO_DW1_PORT_NUM(x)              (((u32) x) << 18)
168 #define TO_DW1_HUB_NUM(x)               (((u32) x) << 25)
169 /* DW2 */
170 #define TO_DW2_DATA_START_ADDR(x)       (((u32) x) << 8)
171 #define TO_DW2_RL(x)                    ((x) << 25)
172 #define FROM_DW2_RL(x)                  (((x) >> 25) & 0xf)
173 /* DW3 */
174 #define FROM_DW3_NRBYTESTRANSFERRED(x)          ((x) & 0x7fff)
175 #define FROM_DW3_SCS_NRBYTESTRANSFERRED(x)      ((x) & 0x07ff)
176 #define TO_DW3_NAKCOUNT(x)              ((x) << 19)
177 #define FROM_DW3_NAKCOUNT(x)            (((x) >> 19) & 0xf)
178 #define TO_DW3_CERR(x)                  ((x) << 23)
179 #define FROM_DW3_CERR(x)                (((x) >> 23) & 0x3)
180 #define TO_DW3_DATA_TOGGLE(x)           ((x) << 25)
181 #define FROM_DW3_DATA_TOGGLE(x)         (((x) >> 25) & 0x1)
182 #define TO_DW3_PING(x)                  ((x) << 26)
183 #define FROM_DW3_PING(x)                (((x) >> 26) & 0x1)
184 #define DW3_ERROR_BIT                   (1 << 28)
185 #define DW3_BABBLE_BIT                  (1 << 29)
186 #define DW3_HALT_BIT                    (1 << 30)
187 #define DW3_ACTIVE_BIT                  (1 << 31)
188 #define FROM_DW3_ACTIVE(x)              (((x) >> 31) & 0x01)
189
190 #define INT_UNDERRUN                    (1 << 2)
191 #define INT_BABBLE                      (1 << 1)
192 #define INT_EXACT                       (1 << 0)
193
194 #define SETUP_PID       (2)
195 #define IN_PID          (1)
196 #define OUT_PID         (0)
197
198 /* Errata 1 */
199 #define RL_COUNTER      (0)
200 #define NAK_COUNTER     (0)
201 #define ERR_COUNTER     (2)
202
203 #endif /* _ISP1760_HCD_H_ */