2008-11-10 11:04:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Rafaël Carré
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-04-12 19:08:26 +00:00
|
|
|
#include "config.h"
|
2011-01-29 00:44:59 +00:00
|
|
|
#include "system.h"
|
2008-11-10 11:04:43 +00:00
|
|
|
#include "usb.h"
|
2009-10-15 10:23:18 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
2009-10-15 10:03:20 +00:00
|
|
|
#include "usb_core.h"
|
2009-10-15 10:23:18 +00:00
|
|
|
#endif
|
2009-04-12 19:08:26 +00:00
|
|
|
#include "usb-target.h"
|
2008-11-10 11:04:43 +00:00
|
|
|
#include "power.h"
|
2008-12-29 23:32:11 +00:00
|
|
|
#include "as3525.h"
|
2008-11-10 11:04:43 +00:00
|
|
|
|
2011-01-29 00:44:59 +00:00
|
|
|
static int usb_status = USB_EXTRACTED;
|
|
|
|
|
2008-11-10 11:04:43 +00:00
|
|
|
void usb_enable(bool on)
|
|
|
|
{
|
2010-05-16 11:48:43 +00:00
|
|
|
#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB)
|
2009-10-15 10:03:20 +00:00
|
|
|
if (on)
|
|
|
|
usb_core_init();
|
|
|
|
else
|
|
|
|
usb_core_exit();
|
2009-10-15 10:23:18 +00:00
|
|
|
#else
|
|
|
|
(void)on;
|
|
|
|
#endif
|
2008-11-10 11:04:43 +00:00
|
|
|
}
|
|
|
|
|
2010-03-23 05:02:37 +00:00
|
|
|
void usb_insert_int(void)
|
|
|
|
{
|
2011-09-14 15:26:57 +00:00
|
|
|
usb_status = USB_INSERTED;
|
2011-09-14 16:00:26 +00:00
|
|
|
#ifdef USB_STATUS_BY_EVENT
|
2011-12-15 00:14:36 +00:00
|
|
|
usb_status_event(USB_INSERTED);
|
2011-09-14 16:00:26 +00:00
|
|
|
#endif
|
2010-03-23 05:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usb_remove_int(void)
|
|
|
|
{
|
2011-01-29 00:44:59 +00:00
|
|
|
usb_status = USB_EXTRACTED;
|
2011-09-14 16:00:26 +00:00
|
|
|
#ifdef USB_STATUS_BY_EVENT
|
2011-12-15 00:14:36 +00:00
|
|
|
usb_status_event(USB_EXTRACTED);
|
2011-09-14 16:00:26 +00:00
|
|
|
#endif
|
2010-12-12 20:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usb_drv_usb_detect_event(void)
|
|
|
|
{
|
2011-09-14 16:00:26 +00:00
|
|
|
#if (CONFIG_CPU != AS3525v2 || defined(USE_ROCKBOX_USB)) \
|
|
|
|
&& defined (USB_STATUS_BY_EVENT)
|
2011-09-14 15:26:57 +00:00
|
|
|
/* Rebooting on USB plug can crash these players in a state where
|
|
|
|
* hardware power off (pressing the power button) doesn't work anymore
|
|
|
|
* TODO: Implement USB in rockbox for these players */
|
2011-01-29 00:44:59 +00:00
|
|
|
int oldstatus = disable_irq_save(); /* May come via USB thread */
|
2011-09-14 15:26:57 +00:00
|
|
|
|
|
|
|
if (usb_status == USB_INSERTED)
|
2011-12-15 00:14:36 +00:00
|
|
|
usb_status_event(USB_HOSTED);
|
2011-09-14 15:26:57 +00:00
|
|
|
|
2011-01-29 00:44:59 +00:00
|
|
|
restore_irq(oldstatus);
|
2011-09-14 15:26:57 +00:00
|
|
|
#endif
|
2010-03-23 05:02:37 +00:00
|
|
|
}
|
|
|
|
|
2010-03-23 11:13:17 +00:00
|
|
|
int usb_detect(void)
|
2008-11-10 11:04:43 +00:00
|
|
|
{
|
2011-01-29 00:44:59 +00:00
|
|
|
return usb_status;
|
2008-11-10 11:04:43 +00:00
|
|
|
}
|