1 //==========================================================================
5 // Static data for the ATMEL AT91 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.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
35 // -------------------------------------------
36 //####ECOSGPLCOPYRIGHTEND####
37 //==========================================================================
38 //#####DESCRIPTIONBEGIN####
40 // Author(s): Oliver Munz
41 // Contributors: bartv
44 // This file contains various objects that should go into extras.o
45 // rather than libtarget.a, e.g. devtab entries that would normally
46 // be eliminated by the selective linking.
48 //####DESCRIPTIONEND####
49 //==========================================================================
51 #include <cyg/infra/diag.h>
52 #include <cyg/io/devtab.h>
53 #include <cyg/io/usb/usbs_at91.h>
54 #include <pkgconf/devs_usb_at91.h>
56 // ----------------------------------------------------------------------------
57 // Initialization. The goal here is to call usbs_at91_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_at91_init(void);
72 #ifndef CYGVAR_DEVS_USB_AT91_EP0_DEVTAB_ENTRY
74 class usbs_at91_initialization {
76 usbs_at91_initialization() {
81 static usbs_at91_initialization CYGBLD_ATTRIB_INIT_BEFORE(CYG_INIT_IO)
82 usbs_at91_init_object;
85 // ----------------------------------------------------------------------------
86 // The devtab entries. Each of these is optional, many applications
87 // will want to use the lower-level API rather than go via
88 // open/read/write/ioctl.
90 #ifdef CYGVAR_DEVS_USB_AT91_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.
94 static bool usbs_at91_devtab_ep0_init(struct cyg_devtab_entry* tab){
96 CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
103 CHAR_DEVIO_TABLE(usbs_at91_ep0_devtab_functions,
107 &usbs_devtab_get_config,
108 &usbs_devtab_set_config);
110 CHAR_DEVTAB_ENTRY(usbs_at91_ep0_devtab_entry,
111 CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "0",
113 &usbs_at91_ep0_devtab_functions,
114 &usbs_at91_devtab_ep0_init,
116 (void*) &usbs_at91_ep0);
119 // ----------------------------------------------------------------------------
120 // Common routines for ep1..3
122 #if defined(CYGVAR_DEVS_USB_AT91_EP1_DEVTAB_ENTRY) || \
123 defined(CYGVAR_DEVS_USB_AT91_EP2_DEVTAB_ENTRY) || \
124 defined(CYGVAR_DEVS_USB_AT91_EP3_DEVTAB_ENTRY)
126 static bool usbs_at91_devtab_dummy_init(struct cyg_devtab_entry* tab){
128 CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
134 #ifdef CYGVAR_DEVS_USB_AT91_EP1_DEVTAB_ENTRY
135 CHAR_DEVIO_TABLE(usbs_at91_ep1_devtab_functions,
139 &usbs_devtab_get_config,
140 &usbs_devtab_set_config);
142 CHAR_DEVTAB_ENTRY(usbs_at91_ep1_devtab_entry,
143 CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "1",
145 &usbs_at91_ep1_devtab_functions,
146 &usbs_at91_devtab_dummy_init,
148 (void*) &usbs_at91_ep1);
151 #ifdef CYGVAR_DEVS_USB_AT91_EP2_DEVTAB_ENTRY
152 CHAR_DEVIO_TABLE(usbs_at91_ep2_devtab_functions,
156 &usbs_devtab_get_config,
157 &usbs_devtab_set_config);
159 CHAR_DEVTAB_ENTRY(usbs_at91_ep2_devtab_entry,
160 CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "2",
162 &usbs_at91_ep2_devtab_functions,
163 &usbs_at91_devtab_dummy_init,
165 (void*) &usbs_at91_ep2);
168 #ifdef CYGVAR_DEVS_USB_AT91_EP3_DEVTAB_ENTRY
169 CHAR_DEVIO_TABLE(usbs_at91_ep3_devtab_functions,
173 &usbs_devtab_get_config,
174 &usbs_devtab_set_config);
176 CHAR_DEVTAB_ENTRY(usbs_at91_ep3_devtab_entry,
177 CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "3",
179 &usbs_at91_ep3_devtab_functions,
180 &usbs_at91_devtab_dummy_init,
182 (void*) &usbs_at91_ep3);