blob: e33bea47219ec07ba3d6f919b8aece8c750f0d37 [file] [log] [blame]
Travis Geiselbrecht2c691e82008-09-04 02:41:01 -07001/*
2 * Copyright (c) 2008 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#ifndef __DEV_USB_H
24#define __DEV_USB_H
25
Travis Geiselbrecht89fcb142008-10-10 03:18:10 -070026#include <sys/types.h>
27#include <compiler.h>
28
29/* top level initialization for usb client, abstracts away the interfaces */
30typedef struct {
31 void *desc;
32 size_t len;
33} usb_descriptor __ALIGNED(2);
34
Travis Geiselbrecht345adb52009-01-01 05:25:50 -080035typedef struct {
36 usb_descriptor string;
37 uint8_t id;
38} usb_string;
39
Travis Geiselbrecht89fcb142008-10-10 03:18:10 -070040/* complete usb config struct, passed in to usb_setup() */
41typedef struct {
42 struct usb_descriptor_speed {
43 usb_descriptor device;
44 usb_descriptor device_qual;
45 usb_descriptor config;
46 } lowspeed, highspeed;
Travis Geiselbrecht89fcb142008-10-10 03:18:10 -070047 usb_descriptor langid;
48} usb_config;
Travis Geiselbrecht2c691e82008-09-04 02:41:01 -070049
50void usb_init(void);
51
Travis Geiselbrecht89fcb142008-10-10 03:18:10 -070052/* external code needs to set up the usb stack via the following calls */
53void usb_setup(usb_config *config);
54
55/* apped new interface descriptors to the existing config if desired */
56int usb_append_interface_highspeed(const uint8_t *int_descr, size_t len);
57int usb_append_interface_lowspeed(const uint8_t *int_descr, size_t len);
58
Travis Geiselbrecht345adb52009-01-01 05:25:50 -080059void usb_add_string(const char *string, uint8_t id);
60
Travis Geiselbrecht89fcb142008-10-10 03:18:10 -070061void usb_start(void);
62void usb_stop(void);
63
Travis Geiselbrecht2c691e82008-09-04 02:41:01 -070064#endif
65