]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/devs/usb/d12/v2_0/src/usbs_d12_data.cxx
Initial revision
[karo-tx-redboot.git] / packages / devs / usb / d12 / v2_0 / src / usbs_d12_data.cxx
1 //==========================================================================
2 //
3 //      usbs_d12_data.cxx
4 //
5 //      Static data for the D12 USB device driver
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2006 eCosCentric Ltd
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 // -------------------------------------------
37 //####ECOSGPLCOPYRIGHTEND####
38 //==========================================================================
39 //#####DESCRIPTIONBEGIN####
40 //
41 // Author(s):    fmp
42 // Contributors: fmp
43 // Date:         2004-05-27
44 //
45 // This file contains various objects that should go into extras.o
46 // rather than libtarget.a, e.g. devtab entries that would normally
47 // be eliminated by the selective linking.
48 //
49 //####DESCRIPTIONEND####
50 //==========================================================================
51
52 #include <cyg/io/devtab.h>
53 #include <cyg/io/usb/usbs_d12.h>
54 #include <pkgconf/devs_usb_d12.h>
55
56 // ----------------------------------------------------------------------------
57 // Initialization. The goal here is to call usbs_d12_init()
58 // early on during system startup, to take care of things like
59 // registering interrupt handlers etc. which are best done
60 // during system init.
61 //
62 // If the endpoint 0 devtab entry is available then its init()
63 // function can be used to take care of this. However the devtab
64 // entries are optional so an alternative mechanism must be
65 // provided. Unfortunately although it is possible to give
66 // a C function the constructor attribute, it cannot be given
67 // an initpri attribute. Instead it is necessary to define a
68 // dummy C++ class.
69
70 extern "C" void usbs_d12_init(void);
71
72 #ifndef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
73 class usbs_d12_initialization {
74 public:
75   usbs_d12_initialization() {
76     usbs_d12_init();
77   }
78 };
79
80 static usbs_d12_initialization usbs_d12_init_object 
81        CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO);
82 #endif
83
84 // ----------------------------------------------------------------------------
85 // The devtab entries. Each of these is optional, many applications
86 // will want to use the lower-level API rather than go via
87 // open/read/write/ioctl.
88
89 #ifdef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
90
91 // For endpoint 0 the only legal operations are get_config() and
92 // set_config(), and these are provided by the common package.
93
94 static bool 
95 usbs_d12_devtab_ep0_init(struct cyg_devtab_entry* tab)
96 {
97   CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
98   usbs_d12_init();
99   return true;
100 }
101
102 static 
103 CHAR_DEVIO_TABLE(usbs_d12_ep0_devtab_functions,
104                  &cyg_devio_cwrite,
105                  &cyg_devio_cread,
106                  &cyg_devio_select,
107                  &usbs_devtab_get_config,
108                  &usbs_devtab_set_config);
109
110 static CHAR_DEVTAB_ENTRY(usbs_d12_ep0_devtab_entry,
111                          CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "0c",
112                          0,
113                          &usbs_d12_ep0_devtab_functions,
114                          &usbs_d12_devtab_ep0_init,
115                          0,
116                          (void*) &usbs_d12_ep0);
117 #endif
118
119 // ----------------------------------------------------------------------------
120 // Common routines for ep1 and ep2.
121
122 #if defined(CYGVAR_DEVS_USB_D12_TX_EP1_DEVTAB_ENTRY) ||     \
123   defined(CYGVAR_DEVS_USB_D12_RX_EP1_DEVTAB_ENTRY) ||       \
124   defined(CYGVAR_DEVS_USB_D12_TX_EP2_DEVTAB_ENTRY) ||       \
125   defined(CYGVAR_DEVS_USB_D12_RX_EP2_DEVTAB_ENTRY)
126
127 static bool 
128 usbs_d12_devtab_dummy_init(struct cyg_devtab_entry* tab)
129 {
130   CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
131   return true;
132 }
133 #endif
134
135 // ----------------------------------------------------------------------------
136 // tx (in) ep1 devtab entry. This can only be used for slave->host,
137 // so only the cwrite() function makes sense.
138
139 #ifdef CYGVAR_DEVS_USB_D12_TX_EP1_DEVTAB_ENTRY
140
141 static 
142 CHAR_DEVIO_TABLE(usbs_d12_tx_ep1_devtab_functions,
143                  &usbs_devtab_cwrite,
144                  &cyg_devio_cread,
145                  &cyg_devio_select,
146                  &usbs_devtab_get_config,
147                  &usbs_devtab_set_config);
148
149 static 
150 CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep1_devtab_entry,
151                   CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1w",
152                   0,
153                   &usbs_d12_tx_ep1_devtab_functions,
154                   &usbs_d12_devtab_dummy_init,
155                   0,
156                   (void*) &usbs_d12_tx_ep1);
157 #endif
158
159 // ----------------------------------------------------------------------------
160 // rx (out) ep1 devtab entry. This can only be used for host->slave, 
161 // so only the cread() function makes sense.
162
163 #ifdef CYGVAR_DEVS_USB_D12_RX_EP1_DEVTAB_ENTRY
164
165 static 
166 CHAR_DEVIO_TABLE(usbs_d12_rx_ep1_devtab_functions,
167                  &cyg_devio_cwrite,
168                  &usbs_devtab_cread,
169                  &cyg_devio_select,
170                  &usbs_devtab_get_config,
171                  &usbs_devtab_set_config);
172
173 static 
174 CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep1_devtab_entry,
175                   CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1r",
176                   0,
177                   &usbs_d12_rx_ep1_devtab_functions,
178                   &usbs_d12_devtab_dummy_init,
179                   0,
180                   (void*) &usbs_d12_rx_ep1);
181 #endif
182
183
184 // ----------------------------------------------------------------------------
185 // tx (in) ep2 devtab entry. This can only be used for slave->host, so only the
186 // cwrite() function makes sense.
187
188 #ifdef CYGVAR_DEVS_USB_D12_TX_EP2_DEVTAB_ENTRY
189
190 static 
191 CHAR_DEVIO_TABLE(usbs_d12_tx_ep2_devtab_functions,
192                  &usbs_devtab_cwrite,
193                  &cyg_devio_cread,
194                  &cyg_devio_select,
195                  &usbs_devtab_get_config,
196                  &usbs_devtab_set_config);
197
198 static 
199 CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep2_devtab_entry,
200                   CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2w",
201                   0,
202                   &usbs_d12_tx_ep2_devtab_functions,
203                   &usbs_d12_devtab_dummy_init,
204                   0,
205                   (void*) &usbs_d12_tx_ep2);
206 #endif
207
208 // ----------------------------------------------------------------------------
209 // rx (out) ep2 devtab entry. This can only be used for host->slave, 
210 // so only the cread() function makes sense.
211
212 #ifdef CYGVAR_DEVS_USB_D12_RX_EP2_DEVTAB_ENTRY
213
214 static 
215 CHAR_DEVIO_TABLE(usbs_d12_rx_ep2_devtab_functions,
216                  &cyg_devio_cwrite,
217                  &usbs_devtab_cread,
218                  &cyg_devio_select,
219                  &usbs_devtab_get_config,
220                  &usbs_devtab_set_config);
221
222 static 
223 CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep2_devtab_entry,
224                   CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2r",
225                   0,
226                   &usbs_d12_rx_ep2_devtab_functions,
227                   &usbs_d12_devtab_dummy_init,
228                   0,
229                   (void*) &usbs_d12_rx_ep2);
230 #endif