]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/usb/at91/v2_0/src/usbs_at91_data.cxx
Initial revision
[karo-tx-redboot.git] / packages / devs / usb / at91 / v2_0 / src / usbs_at91_data.cxx
1 //==========================================================================
2 //
3 //      usbs_at91_data.cxx
4 //
5 //      Static data for the ATMEL AT91 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 //
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.
16 //
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
20 // for more details.
21 //
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.
25 //
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.
32 //
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####
39 //
40 // Author(s):    Oliver Munz
41 // Contributors: bartv
42 // Date:         2006-02-22
43 //
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.
47 //
48 //####DESCRIPTIONEND####
49 //==========================================================================
50
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>
55
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.
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_at91_init(void);
71
72 #ifndef CYGVAR_DEVS_USB_AT91_EP0_DEVTAB_ENTRY
73         
74 class usbs_at91_initialization {
75 public:
76   usbs_at91_initialization() {
77     usbs_at91_init();
78   }
79 };
80
81 static usbs_at91_initialization CYGBLD_ATTRIB_INIT_BEFORE(CYG_INIT_IO) 
82   usbs_at91_init_object;
83 #endif
84
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.
89
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.
93
94 static bool usbs_at91_devtab_ep0_init(struct cyg_devtab_entry* tab){
95   
96   CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
97   
98   usbs_at91_init();
99   
100   return true;
101 }
102
103 CHAR_DEVIO_TABLE(usbs_at91_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 CHAR_DEVTAB_ENTRY(usbs_at91_ep0_devtab_entry,
111                   CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "0",
112                   0,
113                   &usbs_at91_ep0_devtab_functions,
114                   &usbs_at91_devtab_ep0_init,
115                   0,
116                   (void*) &usbs_at91_ep0);
117 #endif
118
119 // ----------------------------------------------------------------------------
120 // Common routines for ep1..3
121
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)
125
126 static bool usbs_at91_devtab_dummy_init(struct cyg_devtab_entry* tab){
127   
128     CYG_UNUSED_PARAM(struct cyg_devtab_entry*, tab);
129     return true;
130 }
131
132 #endif
133
134 #ifdef CYGVAR_DEVS_USB_AT91_EP1_DEVTAB_ENTRY
135 CHAR_DEVIO_TABLE(usbs_at91_ep1_devtab_functions,
136                  &usbs_devtab_cwrite,
137                  &usbs_devtab_cread,
138                  &cyg_devio_select,
139                  &usbs_devtab_get_config,
140                  &usbs_devtab_set_config);
141
142 CHAR_DEVTAB_ENTRY(usbs_at91_ep1_devtab_entry,
143                   CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "1",
144                   0,
145                   &usbs_at91_ep1_devtab_functions,
146                   &usbs_at91_devtab_dummy_init,
147                   0,
148                   (void*) &usbs_at91_ep1);
149 #endif         
150
151 #ifdef CYGVAR_DEVS_USB_AT91_EP2_DEVTAB_ENTRY
152 CHAR_DEVIO_TABLE(usbs_at91_ep2_devtab_functions,
153                  &usbs_devtab_cwrite,
154                  &usbs_devtab_cread,
155                  &cyg_devio_select,
156                  &usbs_devtab_get_config,
157                  &usbs_devtab_set_config);
158
159 CHAR_DEVTAB_ENTRY(usbs_at91_ep2_devtab_entry,
160                   CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "2",
161                   0,
162                   &usbs_at91_ep2_devtab_functions,
163                   &usbs_at91_devtab_dummy_init,
164                   0,
165                   (void*) &usbs_at91_ep2);
166 #endif
167
168 #ifdef CYGVAR_DEVS_USB_AT91_EP3_DEVTAB_ENTRY  
169 CHAR_DEVIO_TABLE(usbs_at91_ep3_devtab_functions,
170                  &usbs_devtab_cwrite,
171                  &usbs_devtab_cread,
172                  &cyg_devio_select,
173                  &usbs_devtab_get_config,
174                  &usbs_devtab_set_config);
175
176 CHAR_DEVTAB_ENTRY(usbs_at91_ep3_devtab_entry,
177                   CYGDAT_DEVS_USB_AT91_DEVTAB_BASENAME "3",
178                   0,
179                   &usbs_at91_ep3_devtab_functions,
180                   &usbs_at91_devtab_dummy_init,
181                   0,
182                   (void*) &usbs_at91_ep3);
183 #endif