2007-08-27 16:04:32 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2008-04-18 17:24:19 +00:00
|
|
|
* $Id$
|
2007-08-27 16:04:32 +00:00
|
|
|
*
|
2008-05-05 10:32:46 +00:00
|
|
|
* Copyright (C) 2007 by Björn Stenberg
|
2007-08-27 16:04:32 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-08-27 16:04:32 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-03-26 00:34:50 +00:00
|
|
|
#ifndef _USB_DRV_H
|
|
|
|
#define _USB_DRV_H
|
2007-11-22 20:51:00 +00:00
|
|
|
#include "usb_ch9.h"
|
|
|
|
#include "kernel.h"
|
2007-08-27 16:04:32 +00:00
|
|
|
|
2017-11-13 23:26:16 +00:00
|
|
|
/** USB initialisation flow:
|
|
|
|
* usb_init()
|
|
|
|
* -> usb_init_device()
|
|
|
|
* -> [soc specific one-time init]
|
|
|
|
* -> usb_drv_startup()
|
|
|
|
* .....
|
|
|
|
* [USB is plugged]
|
|
|
|
* usb_enable(true)
|
|
|
|
* -> soc specific controller/clock init
|
|
|
|
* -> usb_core_init()
|
|
|
|
* -> usb_drv_init()
|
|
|
|
* -> usb_drv_int_enable(true) [only if controller needs soc specific code for interrupt]
|
|
|
|
* -> for each usb driver, driver.init()
|
|
|
|
* #ifdef USB_DETECT_BY_REQUEST
|
|
|
|
* [rockbox waits until first control request before proceeding]
|
|
|
|
* #endif
|
|
|
|
* [rockbox decides which usb drivers to enable, based on user preference and buttons]
|
|
|
|
* -> if not exclusive mode, usb_attach()
|
|
|
|
* -> if exclusive mode, usb_attach() call be called at any point starting from now
|
|
|
|
* (but after threads have acked usb mode and disk have been unmounted)
|
|
|
|
* for each enabled driver
|
|
|
|
* -> driver.request_endpoints()
|
|
|
|
* -> driver.set_first_interface()
|
|
|
|
* [usb controller/core start answering requests]
|
|
|
|
* .....
|
|
|
|
* [USB is unplugged]
|
|
|
|
* usb_enable(false)
|
|
|
|
* -> usb_core_exit()
|
|
|
|
* -> for each enabled usb driver, driver.disconnect()
|
|
|
|
* -> usb_drv_exit()
|
|
|
|
* -> usb_drv_int_enable(false) [ditto]
|
|
|
|
* -> soc specific controller/clock deinit */
|
|
|
|
|
|
|
|
/* one-time initialisation of the USB driver */
|
2008-04-20 03:30:57 +00:00
|
|
|
void usb_drv_startup(void);
|
2009-01-19 13:41:25 +00:00
|
|
|
void usb_drv_int_enable(bool enable); /* Target implemented */
|
2017-11-13 23:26:16 +00:00
|
|
|
/* enable and initialise the USB controller */
|
2007-11-22 20:51:00 +00:00
|
|
|
void usb_drv_init(void);
|
2017-11-13 23:26:16 +00:00
|
|
|
/* stop and disable and the USB controller */
|
2007-11-22 20:51:00 +00:00
|
|
|
void usb_drv_exit(void);
|
2009-01-19 13:41:25 +00:00
|
|
|
void usb_drv_int(void); /* Call from target INT handler */
|
2008-02-20 22:54:26 +00:00
|
|
|
void usb_drv_stall(int endpoint, bool stall,bool in);
|
|
|
|
bool usb_drv_stalled(int endpoint,bool in);
|
2010-08-12 08:43:18 +00:00
|
|
|
int usb_drv_send(int endpoint, void* ptr, int length);
|
|
|
|
int usb_drv_send_nonblocking(int endpoint, void* ptr, int length);
|
2007-11-27 13:42:47 +00:00
|
|
|
int usb_drv_recv(int endpoint, void* ptr, int length);
|
2007-11-22 20:51:00 +00:00
|
|
|
void usb_drv_ack(struct usb_ctrlrequest* req);
|
|
|
|
void usb_drv_set_address(int address);
|
|
|
|
void usb_drv_reset_endpoint(int endpoint, bool send);
|
2007-11-22 22:17:45 +00:00
|
|
|
bool usb_drv_powered(void);
|
2008-02-11 14:26:25 +00:00
|
|
|
int usb_drv_port_speed(void);
|
2008-02-20 22:54:26 +00:00
|
|
|
void usb_drv_cancel_all_transfers(void);
|
2008-02-26 18:02:26 +00:00
|
|
|
void usb_drv_set_test_mode(int mode);
|
2008-03-20 20:01:28 +00:00
|
|
|
bool usb_drv_connected(void);
|
2009-05-16 15:30:09 +00:00
|
|
|
int usb_drv_request_endpoint(int type, int dir);
|
2008-10-03 22:43:16 +00:00
|
|
|
void usb_drv_release_endpoint(int ep);
|
2007-08-27 16:04:32 +00:00
|
|
|
|
2009-03-26 00:34:50 +00:00
|
|
|
#endif /* _USB_DRV_H */
|