Go to the documentation of this file.
73 #include <linux/slab.h>
75 #define S626_SIZE 0x0200
76 #define DMABUF_SIZE 4096
78 #define S626_ADC_CHANNELS 16
79 #define S626_DAC_CHANNELS 4
80 #define S626_ENCODER_CHANNELS 6
81 #define S626_DIO_CHANNELS 48
82 #define S626_DIO_BANKS 3
83 #define S626_DIO_EXTCHANS 40
87 #define NUM_TRIMDACS 12
93 #define PLATFORM INTEL
96 #define RANGE_10V 0x00
99 #define GSEL_BIPOLAR5V 0x00F0
100 #define GSEL_BIPOLAR10V 0x00A0
103 #define ERR_ILLEGAL_PARM 0x00010000
104 #define ERR_I2C 0x00020000
105 #define ERR_COUNTERSETUP 0x00200000
106 #define ERR_DEBI_TIMEOUT 0x00400000
109 #define ADC_DMABUF_DWORDS 40
110 #define DAC_WDMABUF_DWORDS 1
115 #define DAC_WDMABUF_OS ADC_DMABUF_DWORDS
118 #define IRQ_GPIO3 0x00000040
119 #define IRQ_RPS1 0x10000000
120 #define ISR_AFOU 0x00000800
123 #define IRQ_COINT1A 0x0400
124 #define IRQ_COINT1B 0x0800
125 #define IRQ_COINT2A 0x1000
126 #define IRQ_COINT2B 0x2000
127 #define IRQ_COINT3A 0x4000
128 #define IRQ_COINT3B 0x8000
131 #define RPS_CLRSIGNAL 0x00000000
132 #define RPS_SETSIGNAL 0x10000000
133 #define RPS_NOP 0x00000000
134 #define RPS_PAUSE 0x20000000
135 #define RPS_UPLOAD 0x40000000
136 #define RPS_JUMP 0x80000000
137 #define RPS_LDREG 0x90000100
138 #define RPS_STREG 0xA0000100
139 #define RPS_STOP 0x50000000
140 #define RPS_IRQ 0x60000000
142 #define RPS_LOGICAL_OR 0x08000000
143 #define RPS_INVERT 0x04000000
144 #define RPS_DEBI 0x00000002
146 #define RPS_SIG0 0x00200000
147 #define RPS_SIG1 0x00400000
148 #define RPS_SIG2 0x00800000
149 #define RPS_GPIO2 0x00080000
150 #define RPS_GPIO3 0x00100000
152 #define RPS_SIGADC RPS_SIG0
153 #define RPS_SIGDAC RPS_SIG1
156 #define RPSCLK_SCALAR 8
157 #define RPSCLK_PER_US (33 / RPSCLK_SCALAR)
160 #define SBA_RPS_A0 0x27
163 #define GPIO_BASE 0x10004000
164 #define GPIO1_LO 0x00000000
165 #define GPIO1_HI 0x00001000
168 #define PSR_DEBI_E 0x00040000
169 #define PSR_DEBI_S 0x00080000
170 #define PSR_A2_IN 0x00008000
171 #define PSR_AFOU 0x00000800
172 #define PSR_GPIO2 0x00000020
173 #define PSR_EC0S 0x00000001
176 #define SSR_AF2_OUT 0x00000200
179 #define MC1_SOFT_RESET 0x80000000
180 #define MC1_SHUTDOWN 0x3FFF0000
182 #define MC1_ERPS1 0x2000
183 #define MC1_ERPS0 0x1000
184 #define MC1_DEBI 0x0800
185 #define MC1_AUDIO 0x0200
186 #define MC1_I2C 0x0100
187 #define MC1_A2OUT 0x0008
188 #define MC1_A2IN 0x0004
189 #define MC1_A1IN 0x0001
192 #define MC2_UPLD_DEBIq 0x00020002
193 #define MC2_UPLD_IICq 0x00010001
194 #define MC2_RPSSIG2_ONq 0x20002000
195 #define MC2_RPSSIG1_ONq 0x10001000
196 #define MC2_RPSSIG0_ONq 0x08000800
197 #define MC2_UPLD_DEBI_MASKq 0x00000002
198 #define MC2_UPLD_IIC_MASKq 0x00000001
199 #define MC2_RPSSIG2_MASKq 0x00002000
200 #define MC2_RPSSIG1_MASKq 0x00001000
201 #define MC2_RPSSIG0_MASKq 0x00000800
203 #define MC2_DELAYTRIG_4USq MC2_RPSSIG1_ON
204 #define MC2_DELAYBUSY_4USq MC2_RPSSIG1_MASK
206 #define MC2_DELAYTRIG_6USq MC2_RPSSIG2_ON
207 #define MC2_DELAYBUSY_6USq MC2_RPSSIG2_MASK
209 #define MC2_UPLD_DEBI 0x0002
210 #define MC2_UPLD_IIC 0x0001
211 #define MC2_RPSSIG2 0x2000
212 #define MC2_RPSSIG1 0x1000
213 #define MC2_RPSSIG0 0x0800
215 #define MC2_ADC_RPS MC2_RPSSIG0
216 #define MC2_DAC_RPS MC2_RPSSIG1
219 #define MC2_UPLD_DEBIQ 0x00020002
220 #define MC2_UPLD_IICQ 0x00010001
223 #define P_PCI_BT_A 0x004C
224 #define P_DEBICFG 0x007C
225 #define P_DEBICMD 0x0080
226 #define P_DEBIPAGE 0x0084
227 #define P_DEBIAD 0x0088
228 #define P_I2CCTRL 0x008C
229 #define P_I2CSTAT 0x0090
230 #define P_BASEA2_IN 0x00AC
232 #define P_PROTA2_IN 0x00B0
234 #define P_PAGEA2_IN 0x00B4
235 #define P_BASEA2_OUT 0x00B8
237 #define P_PROTA2_OUT 0x00BC
239 #define P_PAGEA2_OUT 0x00C0
240 #define P_RPSPAGE0 0x00C4
241 #define P_RPSPAGE1 0x00C8
242 #define P_RPS0_TOUT 0x00D4
243 #define P_RPS1_TOUT 0x00D8
245 #define P_GPIO 0x00E0
246 #define P_EC1SSR 0x00E4
247 #define P_ECT1R 0x00EC
248 #define P_ACON1 0x00F4
249 #define P_ACON2 0x00F8
252 #define P_RPSADDR0 0x0104
253 #define P_RPSADDR1 0x0108
257 #define P_EC1R 0x0118
258 #define P_ADP4 0x0138
260 #define P_FB_BUFFER1 0x0144
261 #define P_FB_BUFFER2 0x0148
262 #define P_TSL1 0x0180
263 #define P_TSL2 0x01C0
267 #define LP_DACPOL 0x0082
268 #define LP_GSEL 0x0084
269 #define LP_ISEL 0x0086
271 #define LP_WRINTSELA 0x0042
272 #define LP_WREDGSELA 0x0044
273 #define LP_WRCAPSELA 0x0046
274 #define LP_WRDOUTA 0x0048
275 #define LP_WRINTSELB 0x0052
276 #define LP_WREDGSELB 0x0054
277 #define LP_WRCAPSELB 0x0056
278 #define LP_WRDOUTB 0x0058
279 #define LP_WRINTSELC 0x0062
280 #define LP_WREDGSELC 0x0064
281 #define LP_WRCAPSELC 0x0066
282 #define LP_WRDOUTC 0x0068
285 #define LP_RDDINA 0x0040
286 #define LP_RDCAPFLGA 0x0048
287 #define LP_RDINTSELA 0x004A
288 #define LP_RDEDGSELA 0x004C
289 #define LP_RDCAPSELA 0x004E
290 #define LP_RDDINB 0x0050
291 #define LP_RDCAPFLGB 0x0058
292 #define LP_RDINTSELB 0x005A
293 #define LP_RDEDGSELB 0x005C
294 #define LP_RDCAPSELB 0x005E
295 #define LP_RDDINC 0x0060
296 #define LP_RDCAPFLGC 0x0068
297 #define LP_RDINTSELC 0x006A
298 #define LP_RDEDGSELC 0x006C
299 #define LP_RDCAPSELC 0x006E
302 #define LP_CR0A 0x0000
303 #define LP_CR0B 0x0002
304 #define LP_CR1A 0x0004
305 #define LP_CR1B 0x0006
306 #define LP_CR2A 0x0008
307 #define LP_CR2B 0x000A
310 #define LP_CNTR0ALSW 0x000C
311 #define LP_CNTR0AMSW 0x000E
312 #define LP_CNTR0BLSW 0x0010
313 #define LP_CNTR0BMSW 0x0012
314 #define LP_CNTR1ALSW 0x0014
315 #define LP_CNTR1AMSW 0x0016
316 #define LP_CNTR1BLSW 0x0018
317 #define LP_CNTR1BMSW 0x001A
318 #define LP_CNTR2ALSW 0x001C
319 #define LP_CNTR2AMSW 0x001E
320 #define LP_CNTR2BLSW 0x0020
321 #define LP_CNTR2BMSW 0x0022
324 #define LP_MISC1 0x0088
325 #define LP_WRMISC2 0x0090
326 #define LP_RDMISC2 0x0082
329 #define MISC1_WENABLE 0x8000
331 #define MISC1_WDISABLE 0x0000
332 #define MISC1_EDCAP 0x1000
334 #define MISC1_NOEDCAP 0x0000
338 #define RDMISC1_WDTIMEOUT 0x4000
341 #define WRMISC2_WDCLEAR 0x8000
342 #define WRMISC2_CHARGE_ENABLE 0x4000
345 #define MISC2_BATT_ENABLE 0x0008
346 #define MISC2_WDENABLE 0x0004
347 #define MISC2_WDPERIOD_MASK 0x0003
351 #define A2_RUN 0x40000000
352 #define A1_RUN 0x20000000
353 #define A1_SWAP 0x00200000
354 #define A2_SWAP 0x00100000
355 #define WS_MODES 0x00019999
359 #if PLATFORM == INTEL
361 #define ACON1_BASE (WS_MODES | A1_RUN)
362 #elif PLATFORM == MOTOROLA
363 #define ACON1_BASE (WS_MODES | A1_RUN | A1_SWAP | A2_SWAP)
366 #define ACON1_ADCSTART ACON1_BASE
368 #define ACON1_DACSTART (ACON1_BASE | A2_RUN)
370 #define ACON1_DACSTOP ACON1_BASE
373 #define A1_CLKSRC_BCLK1 0x00000000
374 #define A2_CLKSRC_X1 0x00800000
375 #define A2_CLKSRC_X2 0x00C00000
376 #define A2_CLKSRC_X4 0x01400000
377 #define INVERT_BCLK2 0x00100000
378 #define BCLK2_OE 0x00040000
379 #define ACON2_XORMASK 0x000C0000
382 #define ACON2_INIT (ACON2_XORMASK ^ (A1_CLKSRC_BCLK1 | A2_CLKSRC_X2 | INVERT_BCLK2 | BCLK2_OE))
385 #define WS1 0x40000000
386 #define WS2 0x20000000
387 #define WS3 0x10000000
388 #define WS4 0x08000000
389 #define RSD1 0x01000000
390 #define SDW_A1 0x00800000
392 #define SIB_A1 0x00400000
394 #define SF_A1 0x00200000
398 #define XFIFO_0 0x00000000
399 #define XFIFO_1 0x00000010
400 #define XFIFO_2 0x00000020
401 #define XFIFO_3 0x00000030
402 #define XFB0 0x00000040
403 #define XFB1 0x00000050
404 #define XFB2 0x00000060
405 #define XFB3 0x00000070
406 #define SIB_A2 0x00000200
408 #define SF_A2 0x00000100
411 #define LF_A2 0x00000080
414 #define XSD2 0x00000008
415 #define RSD3 0x00001800
416 #define RSD2 0x00001000
417 #define LOW_A2 0x00000002
420 #define EOS 0x00000001
423 #define I2C_CLKSEL 0x0400
426 #define I2C_BITRATE 68.75
429 #define I2C_WRTIME 15.0
435 #define I2C_RETRIES (I2C_WRTIME * I2C_BITRATE / 9.0)
436 #define I2C_ERR 0x0002
438 #define I2C_BUSY 0x0001
440 #define I2C_ABORT 0x0080
441 #define I2C_ATTRSTART 0x3
442 #define I2C_ATTRCONT 0x2
443 #define I2C_ATTRSTOP 0x1
444 #define I2C_ATTRNOP 0x0
447 #define I2CR (devpriv->I2CAdrs | 1)
450 #define I2CW (devpriv->I2CAdrs)
453 #define I2C_B2(ATTR, VAL) (((ATTR) << 6) | ((VAL) << 24))
454 #define I2C_B1(ATTR, VAL) (((ATTR) << 4) | ((VAL) << 16))
455 #define I2C_B0(ATTR, VAL) (((ATTR) << 2) | ((VAL) << 8))
458 #define P_DEBICFGq 0x007C
459 #define P_DEBICMDq 0x0080
460 #define P_DEBIPAGEq 0x0084
461 #define P_DEBIADq 0x0088
463 #define DEBI_CFG_TOQ 0x03C00000
464 #define DEBI_CFG_FASTQ 0x10000000
465 #define DEBI_CFG_16Q 0x00080000
466 #define DEBI_CFG_INCQ 0x00040000
467 #define DEBI_CFG_TIMEROFFQ 0x00010000
468 #define DEBI_CMD_RDQ 0x00050000
469 #define DEBI_CMD_WRQ 0x00040000
470 #define DEBI_PAGE_DISABLEQ 0x00000000
473 #define DEBI_CMD_SIZE16 (2 << 17)
475 #define DEBI_CMD_READ 0x00010000
476 #define DEBI_CMD_WRITE 0x00000000
479 #define DEBI_CMD_RDWORD (DEBI_CMD_READ | DEBI_CMD_SIZE16)
482 #define DEBI_CMD_WRWORD (DEBI_CMD_WRITE | DEBI_CMD_SIZE16)
485 #define DEBI_CFG_XIRQ_EN 0x80000000
487 #define DEBI_CFG_XRESUME 0x40000000
490 #define DEBI_CFG_FAST 0x10000000
493 #define DEBI_CFG_TOUT_BIT 22
497 #define DEBI_CFG_SWAP_NONE 0x00000000
500 #define DEBI_CFG_SWAP_2 0x00100000
501 #define DEBI_CFG_SWAP_4 0x00200000
502 #define DEBI_CFG_16 0x00080000
506 #define DEBI_CFG_SLAVE16 0x00080000
509 #define DEBI_CFG_INC 0x00040000
512 #define DEBI_CFG_INTEL 0x00020000
513 #define DEBI_CFG_TIMEROFF 0x00010000
515 #if PLATFORM == INTEL
522 #define DEBI_SWAP DEBI_CFG_SWAP_NONE
524 #elif PLATFORM == MOTOROLA
528 #define DEBI_SWAP DEBI_CFG_SWAP_2
533 #define DEBI_PAGE_DISABLE 0x00000000
538 #define LOADSRC_INDX 0
540 #define LOADSRC_OVER 1
542 #define LOADSRCB_OVERA 2
544 #define LOADSRC_NONE 3
547 #define INTSRC_NONE 0
548 #define INTSRC_OVER 1
549 #define INTSRC_INDX 2
550 #define INTSRC_BOTH 3
553 #define LATCHSRC_AB_READ 0
554 #define LATCHSRC_A_INDXA 1
555 #define LATCHSRC_B_INDXB 2
556 #define LATCHSRC_B_OVERA 3
559 #define INDXSRC_HARD 0
560 #define INDXSRC_SOFT 1
563 #define INDXPOL_POS 0
564 #define INDXPOL_NEG 1
567 #define CLKSRC_COUNTER 0
568 #define CLKSRC_TIMER 2
569 #define CLKSRC_EXTENDER 3
577 #define CNTDIR_DOWN 1
580 #define CLKENAB_ALWAYS 0
581 #define CLKENAB_INDEX 1
600 #define CLKSRC_COUNTER 0
602 #define CLKSRC_TIMER 2
605 #define CLKSRC_EXTENDER 3
610 #define MULT_X0 0x0003
613 #define MULT_X1 0x0002
616 #define MULT_X2 0x0001
619 #define MULT_X4 0x0000
625 #define NUM_COUNTERS 6
627 #define NUM_INTSOURCES 4
628 #define NUM_LATCHSOURCES 4
629 #define NUM_CLKMULTS 4
630 #define NUM_CLKSOURCES 4
631 #define NUM_CLKPOLS 2
632 #define NUM_INDEXPOLS 2
633 #define NUM_INDEXSOURCES 2
634 #define NUM_LOADTRIGS 4
639 #define CRABIT_INDXSRC_B 14
640 #define CRABIT_CLKSRC_B 12
641 #define CRABIT_INDXPOL_A 11
642 #define CRABIT_LOADSRC_A 9
643 #define CRABIT_CLKMULT_A 7
644 #define CRABIT_INTSRC_A 5
645 #define CRABIT_CLKPOL_A 4
646 #define CRABIT_INDXSRC_A 2
647 #define CRABIT_CLKSRC_A 0
650 #define CRBBIT_INTRESETCMD 15
651 #define CRBBIT_INTRESET_B 14
652 #define CRBBIT_INTRESET_A 13
653 #define CRBBIT_CLKENAB_A 12
654 #define CRBBIT_INTSRC_B 10
655 #define CRBBIT_LATCHSRC 8
656 #define CRBBIT_LOADSRC_B 6
657 #define CRBBIT_CLKMULT_B 3
658 #define CRBBIT_CLKENAB_B 2
659 #define CRBBIT_INDXPOL_B 1
660 #define CRBBIT_CLKPOL_B 0
664 #define CRAMSK_INDXSRC_B ((uint16_t)(3 << CRABIT_INDXSRC_B))
665 #define CRAMSK_CLKSRC_B ((uint16_t)(3 << CRABIT_CLKSRC_B))
666 #define CRAMSK_INDXPOL_A ((uint16_t)(1 << CRABIT_INDXPOL_A))
667 #define CRAMSK_LOADSRC_A ((uint16_t)(3 << CRABIT_LOADSRC_A))
668 #define CRAMSK_CLKMULT_A ((uint16_t)(3 << CRABIT_CLKMULT_A))
669 #define CRAMSK_INTSRC_A ((uint16_t)(3 << CRABIT_INTSRC_A))
670 #define CRAMSK_CLKPOL_A ((uint16_t)(3 << CRABIT_CLKPOL_A))
671 #define CRAMSK_INDXSRC_A ((uint16_t)(3 << CRABIT_INDXSRC_A))
672 #define CRAMSK_CLKSRC_A ((uint16_t)(3 << CRABIT_CLKSRC_A))
674 #define CRBMSK_INTRESETCMD ((uint16_t)(1 << CRBBIT_INTRESETCMD))
675 #define CRBMSK_INTRESET_B ((uint16_t)(1 << CRBBIT_INTRESET_B))
676 #define CRBMSK_INTRESET_A ((uint16_t)(1 << CRBBIT_INTRESET_A))
677 #define CRBMSK_CLKENAB_A ((uint16_t)(1 << CRBBIT_CLKENAB_A))
678 #define CRBMSK_INTSRC_B ((uint16_t)(3 << CRBBIT_INTSRC_B))
679 #define CRBMSK_LATCHSRC ((uint16_t)(3 << CRBBIT_LATCHSRC))
680 #define CRBMSK_LOADSRC_B ((uint16_t)(3 << CRBBIT_LOADSRC_B))
681 #define CRBMSK_CLKMULT_B ((uint16_t)(3 << CRBBIT_CLKMULT_B))
682 #define CRBMSK_CLKENAB_B ((uint16_t)(1 << CRBBIT_CLKENAB_B))
683 #define CRBMSK_INDXPOL_B ((uint16_t)(1 << CRBBIT_INDXPOL_B))
684 #define CRBMSK_CLKPOL_B ((uint16_t)(1 << CRBBIT_CLKPOL_B))
686 #define CRBMSK_INTCTRL (CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A | CRBMSK_INTRESET_B)
690 #define STDBIT_INTSRC 13
691 #define STDBIT_LATCHSRC 11
692 #define STDBIT_LOADSRC 9
693 #define STDBIT_INDXSRC 7
694 #define STDBIT_INDXPOL 6
695 #define STDBIT_CLKSRC 4
696 #define STDBIT_CLKPOL 3
697 #define STDBIT_CLKMULT 1
698 #define STDBIT_CLKENAB 0
702 #define STDMSK_INTSRC ((uint16_t)(3 << STDBIT_INTSRC))
703 #define STDMSK_LATCHSRC ((uint16_t)(3 << STDBIT_LATCHSRC))
704 #define STDMSK_LOADSRC ((uint16_t)(3 << STDBIT_LOADSRC))
705 #define STDMSK_INDXSRC ((uint16_t)(1 << STDBIT_INDXSRC))
706 #define STDMSK_INDXPOL ((uint16_t)(1 << STDBIT_INDXPOL))
707 #define STDMSK_CLKSRC ((uint16_t)(3 << STDBIT_CLKSRC))
708 #define STDMSK_CLKPOL ((uint16_t)(1 << STDBIT_CLKPOL))
709 #define STDMSK_CLKMULT ((uint16_t)(3 << STDBIT_CLKMULT))
710 #define STDMSK_CLKENAB ((uint16_t)(1 << STDBIT_CLKENAB))