Prepare new maemo release
[maemo-rb.git] / firmware / export / usb_core.h
blob9e3d0d79162d5df9ccff1783f361a55ad64946f3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Björn Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef USB_CORE_H
22 #define USB_CORE_H
24 #include "usb_ch9.h"
25 #include "usb.h"
27 /* endpoints */
28 #define EP_CONTROL 0
30 #define DIR_OUT 0
31 #define DIR_IN 1
33 /* The USB core is a device, and OUT is RX from that P.O.V */
34 #define DIR_RX DIR_OUT
35 #define DIR_TX DIR_IN
37 #define EP_DIR(ep) (((ep) & USB_ENDPOINT_DIR_MASK) ? DIR_IN : DIR_OUT)
38 #define EP_NUM(ep) ((ep) & USB_ENDPOINT_NUMBER_MASK)
40 extern int usb_max_pkt_size;
42 struct usb_class_driver;
44 void usb_core_init(void);
45 void usb_core_exit(void);
46 void usb_core_control_request(struct usb_ctrlrequest* req);
47 void usb_core_transfer_complete(int endpoint,int dir,int status,int length);
48 void usb_core_bus_reset(void);
49 bool usb_core_any_exclusive_storage(void);
50 void usb_core_enable_driver(int driver,bool enabled);
51 bool usb_core_driver_enabled(int driver);
52 void usb_core_handle_transfer_completion(
53 struct usb_transfer_completion_event_data* event);
54 void usb_core_handle_notify(long id, intptr_t data);
55 /* For controllers which handle SET ADDR and/or SET CONFIG in hardware */
56 void usb_core_notify_set_address(uint8_t addr);
57 void usb_core_notify_set_config(uint8_t config);
59 int usb_core_request_endpoint(int type, int dir,struct usb_class_driver* drv);
60 void usb_core_release_endpoint(int dir);
62 #ifdef HAVE_HOTSWAP
63 void usb_core_hotswap_event(int volume,bool inserted);
64 #endif
66 #ifdef HAVE_USB_CHARGING_ENABLE
67 /* hardware which knows how to control usb current should use one
68 * of the following to find out from the usb stack how much is ok
70 /* implemented by target, called by usb when value changes */
71 void usb_charging_maxcurrent_change(int maxcurrent);
72 /* implemented by usb, called by target to get value */
73 int usb_charging_maxcurrent(void);
74 #endif
76 #endif