1 //==========================================================================
5 // Static data for the D12 USB device driver
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
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.
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
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.
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.
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####
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.
49 //####DESCRIPTIONEND####
50 //==========================================================================
52 #include <cyg/io/devtab.h>
53 #include <cyg/io/usb/usbs_d12.h>
54 #include <pkgconf/devs_usb_d12.h>
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.
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
70 extern "C" void usbs_d12_init(void);
72 #ifndef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
73 class usbs_d12_initialization {
75 usbs_d12_initialization() {
80 static usbs_d12_initialization usbs_d12_init_object
81 CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO);
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.
89 #ifdef CYGVAR_DEVS_USB_D12_EP0_DEVTAB_ENTRY
91 // For endpoint 0 the only legal operations are get_config() and
92 // set_config(), and these are provided by the common package.
95 usbs_d12_devtab_ep0_init(struct cyg_devtab_entry* tab)
97 CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
103 CHAR_DEVIO_TABLE(usbs_d12_ep0_devtab_functions,
107 &usbs_devtab_get_config,
108 &usbs_devtab_set_config);
110 static CHAR_DEVTAB_ENTRY(usbs_d12_ep0_devtab_entry,
111 CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "0c",
113 &usbs_d12_ep0_devtab_functions,
114 &usbs_d12_devtab_ep0_init,
116 (void*) &usbs_d12_ep0);
119 // ----------------------------------------------------------------------------
120 // Common routines for ep1 and ep2.
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)
128 usbs_d12_devtab_dummy_init(struct cyg_devtab_entry* tab)
130 CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
135 // ----------------------------------------------------------------------------
136 // tx (in) ep1 devtab entry. This can only be used for slave->host,
137 // so only the cwrite() function makes sense.
139 #ifdef CYGVAR_DEVS_USB_D12_TX_EP1_DEVTAB_ENTRY
142 CHAR_DEVIO_TABLE(usbs_d12_tx_ep1_devtab_functions,
146 &usbs_devtab_get_config,
147 &usbs_devtab_set_config);
150 CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep1_devtab_entry,
151 CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1w",
153 &usbs_d12_tx_ep1_devtab_functions,
154 &usbs_d12_devtab_dummy_init,
156 (void*) &usbs_d12_tx_ep1);
159 // ----------------------------------------------------------------------------
160 // rx (out) ep1 devtab entry. This can only be used for host->slave,
161 // so only the cread() function makes sense.
163 #ifdef CYGVAR_DEVS_USB_D12_RX_EP1_DEVTAB_ENTRY
166 CHAR_DEVIO_TABLE(usbs_d12_rx_ep1_devtab_functions,
170 &usbs_devtab_get_config,
171 &usbs_devtab_set_config);
174 CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep1_devtab_entry,
175 CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "1r",
177 &usbs_d12_rx_ep1_devtab_functions,
178 &usbs_d12_devtab_dummy_init,
180 (void*) &usbs_d12_rx_ep1);
184 // ----------------------------------------------------------------------------
185 // tx (in) ep2 devtab entry. This can only be used for slave->host, so only the
186 // cwrite() function makes sense.
188 #ifdef CYGVAR_DEVS_USB_D12_TX_EP2_DEVTAB_ENTRY
191 CHAR_DEVIO_TABLE(usbs_d12_tx_ep2_devtab_functions,
195 &usbs_devtab_get_config,
196 &usbs_devtab_set_config);
199 CHAR_DEVTAB_ENTRY(usbs_d12_tx_ep2_devtab_entry,
200 CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2w",
202 &usbs_d12_tx_ep2_devtab_functions,
203 &usbs_d12_devtab_dummy_init,
205 (void*) &usbs_d12_tx_ep2);
208 // ----------------------------------------------------------------------------
209 // rx (out) ep2 devtab entry. This can only be used for host->slave,
210 // so only the cread() function makes sense.
212 #ifdef CYGVAR_DEVS_USB_D12_RX_EP2_DEVTAB_ENTRY
215 CHAR_DEVIO_TABLE(usbs_d12_rx_ep2_devtab_functions,
219 &usbs_devtab_get_config,
220 &usbs_devtab_set_config);
223 CHAR_DEVTAB_ENTRY(usbs_d12_rx_ep2_devtab_entry,
224 CYGDAT_DEVS_USB_D12_DEVTAB_BASENAME "2r",
226 &usbs_d12_rx_ep2_devtab_functions,
227 &usbs_d12_devtab_dummy_init,
229 (void*) &usbs_d12_rx_ep2);