first adaption of 'usbport' by Benedikt Sauter
[ppcskel.git] / usb / host / sl811hs.h
1 /*
2  * Copyright (c) 2007, Benedikt Sauter <sauter@ixbat.de>
3  * All rights reserved.
4  *
5  * Short descripton of file (sl811hs.h):
6  * Register definitions of SL811, created from the datasheet
7  *
8  * Redistribution and use in source and binary forms, with or without 
9  * modification, are permitted provided that the following conditions 
10  * are met:
11  *
12  *   * Redistributions of source code must retain the above copyright 
13  *     notice, this list of conditions and the following disclaimer.
14  *   * Redistributions in binary form must reproduce the above 
15  *     copyright notice, this list of conditions and the following 
16  *     disclaimer in the documentation and/or other materials provided 
17  *     with the distribution.
18  *   * Neither the name of the FH Augsburg nor the names of its 
19  *     contributors may be used to endorse or promote products derived 
20  *     from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef _SL811HS_H
36 #define _SL811HS_H
37
38 /* prototypes for communication functions */
39 void sl811_init();
40 void sl811_reset();
41 void sl811_write(u8 addr, u8 data);
42 u8 sl811_read(u8 addr);
43
44 void sl811_write_burst(u8 data);
45 u8 sl811_read_burst();
46
47 void sl811_write_buf(u8 addr, unsigned char *buffer,u8 size);
48 void sl811_read_buf(u8 addr, unsigned char *buffer,u8 size);
49
50 /*
51  *  * ScanLogic SL811HS/T USB Host Controller
52  *   */
53
54 #define SL811_IDX_ADDR (0x00)
55 #define SL811_IDX_DATA (0x01)
56 #define SL811_PORTSIZE (0x02)
57
58 #define SL811_E0BASE (0x00)    /* Base of Control0 */
59 #define SL811_E0CTRL (0x00)    /* Host Control Register */
60 #define SL811_E0ADDR (0x01)    /* Host Base Address */
61 #define SL811_E0LEN  (0x02)    /* Host Base Length */
62 #define SL811_E0STAT (0x03)    /* USB Status (Read) */
63 #define SL811_E0PID  SL811_E0STAT       /* Host PID, Device Endpoint (Write) */
64 #define SL811_E0CONT (0x04)    /* Transfer Count (Read) */
65 #define SL811_E0DEV  SL811_E0CONT       /* Host Device Address (Write) */
66
67 #define SL811_E1BASE (0x08)    /* Base of Control1 */
68 #define SL811_E1CTRL (SL811_E1BASE + SL811_E0CTRL)
69 #define SL811_E1ADDR (SL811_E1BASE + SL811_E0ADDR)
70 #define SL811_E1LEN  (SL811_E1BASE + SL811_E0LEN)
71 #define SL811_E1STAT (SL811_E1BASE + SL811_E0STAT)
72 #define SL811_E1PID  (SL811_E1BASE + SL811_E0PID)
73 #define SL811_E1CONT (SL811_E1BASE + SL811_E0CONT)
74 #define SL811_E1DEV  (SL811_E1BASE + SL811_E0DEV)
75
76 #define SL811_CTRL (0x05)    /* Control Register1 */
77 #define SL811_IER  (0x06)    /* Interrupt Enable Register */
78 #define SL811_ISR  (0x0d)    /* Interrupt Status Register */
79 #define SL811_DATA (0x0e)    /* SOF Counter Low (Write) */
80 #define SL811_REV  SL811_DATA /* HW Revision Register (Read) */
81 #define SL811_CSOF  (0x0f)    /* SOF Counter High(R), Control2(W) */
82 #define SL811_MEM  (0x10)    /* Memory Buffer (0x10 - 0xff) */
83
84 #define SL811_EPCTRL_ARM          (0x01)
85 #define SL811_EPCTRL_ENABLE  (0x02)
86 #define SL811_EPCTRL_DIRECTION (0x04)
87 #define SL811_EPCTRL_ISO          (0x10)
88 #define SL811_EPCTRL_SOF          (0x20)
89 #define SL811_EPCTRL_DATATOGGLE (0x40)
90 #define SL811_EPCTRL_PREAMBLE  (0x80)
91
92 #define SL811_EPPID_PIDMASK  (0xf0)
93 #define SL811_EPPID_EPMASK (0x0f)
94
95 #define SL811_EPSTAT_ACK          (0x01)
96 #define SL811_EPSTAT_ERROR (0x02)
97 #define SL811_EPSTAT_TIMEOUT (0x04)
98 #define SL811_EPSTAT_SEQUENCE  (0x08)
99 #define SL811_EPSTAT_SETUP (0x10)
100 #define SL811_EPSTAT_OVERFLOW  (0x20)
101 #define SL811_EPSTAT_NAK          (0x40)
102 #define SL811_EPSTAT_STALL (0x80)
103
104 #define SL811_CTRL_ENABLESOF (0x01)
105 #define SL811_CTRL_EOF2   (0x04)
106 #define SL811_CTRL_RESETENGINE (0x08)
107 #define SL811_CTRL_JKSTATE (0x10)
108 #define SL811_CTRL_LOWSPEED  (0x20)
109 #define SL811_CTRL_SUSPEND (0x40)
110
111 #define SL811_IER_USBA  (0x01)  /* USB-A done */
112 #define SL811_IER_USBB  (0x02)  /* USB-B done */
113 #define SL811_IER_BABBLE          (0x04)  /* Babble detection */
114 #define SL811_IER_SOFTIMER (0x10)  /* 1ms SOF timer */
115 #define SL811_IER_INSERT          (0x20)  /* Slave Insert/Remove detection */
116 #define SL811_IER_RESET   (0x40)  /* USB Reset/Resume */
117
118 #define SL811_ISR_USBA  (0x01)  /* USB-A done */
119 #define SL811_ISR_USBB  (0x02)  /* USB-B done */
120 #define SL811_ISR_BABBLE          (0x04)  /* Babble detection */
121 #define SL811_ISR_SOFTIMER (0x10)  /* 1ms SOF timer */
122 #define SL811_ISR_INSERT          (0x20)  /* Slave Insert/Remove detection */
123 #define SL811_ISR_RESET   (0x40)  /* USB Reset/Resume */
124 #define SL811_ISR_DATA  (0x80)  /* Value of the Data+ pin */
125
126 #define SL811_REV_USBA  (0x01)  /* USB-A */
127 #define SL811_REV_USBB  (0x02)  /* USB-B */
128 #define SL811_REV_REVMASK  (0xf0)  /* HW Revision */
129 #define SL811_REV_REVSL811H (0x00)  /* HW is SL811H */
130 #define SL811_REV_REVSL811HS (0x10)  /* HW is SL811HS */
131
132 #define SL811_CSOF_SOFMASK  (0x3f)  /* SOF High Counter */
133 #define SL811_CSOF_POLARITY (0x40)  /* Change polarity */
134 #define SL811_CSOF_MASTER (0x80)  /* Master/Slave selection */
135
136
137 #define cMemStart 0x10
138 #define ubufA     0x80
139 #define ubufB     0xc0
140 #define uxferLen  0x40
141 #define sMemSize  0xc0
142 #define cMemEnd   256
143
144
145 #define EP0Buf  0x40
146 #define EP0Len  0x40
147
148 #define DATA0_WR  0x07
149 #define DATA1_WR  0x47
150
151 #define ZDATA0_WR 0x05
152 #define ZDATA1_WR 0x45
153
154 #define DATA0_RD  0x03
155 #define DATA1_RD  0x43
156
157 #define PID_SOF   0x50
158 #define PID_SETUP 0xd0
159 #define PID_IN    0x90
160 #define PID_OUT   0x10
161 #define PID_PRE   0xc0
162 #define PID_NAK   0xa0
163 #define PID_STALL 0xe0
164 #define PID_DATA0 0x30
165 #define PID_DATA1 0xb0
166
167
168 #endif /* _SL811HS_H */
169