2002-06-29 22:41:39 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
|
|
|
*
|
2006-01-07 00:43:48 +00:00
|
|
|
* iPod driver based on code from the ipodlinux project - http://ipodlinux.org
|
|
|
|
* Adapted for Rockbox in January 2006
|
|
|
|
* Original file: podzilla/usb.c
|
|
|
|
* Copyright (C) 2005 Adam Johnston
|
|
|
|
*
|
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.
|
2002-06-29 22:41:39 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
2004-11-02 22:57:51 +00:00
|
|
|
#include "cpu.h"
|
2002-06-29 22:41:39 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "debug.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.h"
|
2002-06-30 13:13:13 +00:00
|
|
|
#include "fat.h"
|
|
|
|
#include "disk.h"
|
|
|
|
#include "panic.h"
|
2002-06-30 14:11:28 +00:00
|
|
|
#include "lcd.h"
|
2002-07-01 12:19:12 +00:00
|
|
|
#include "usb.h"
|
2002-07-02 18:30:39 +00:00
|
|
|
#include "button.h"
|
2006-01-07 00:43:48 +00:00
|
|
|
#include "string.h"
|
2008-02-27 19:08:30 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
|
|
|
#include "usb_core.h"
|
|
|
|
#endif
|
2009-04-18 21:32:41 +00:00
|
|
|
#include "logf.h"
|
2009-02-10 23:43:37 +00:00
|
|
|
#include "screendump.h"
|
2002-06-30 13:13:13 +00:00
|
|
|
|
2008-04-18 16:42:50 +00:00
|
|
|
/* Conditions under which we want the entire driver */
|
2008-09-24 21:17:53 +00:00
|
|
|
#if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \
|
2011-01-15 08:19:30 +00:00
|
|
|
(defined(HAVE_USBSTACK) && defined(HAVE_BOOTLOADER_USB_MODE)) || \
|
2009-10-20 07:21:08 +00:00
|
|
|
(defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx))) || \
|
|
|
|
(defined(HAVE_USBSTACK) && (defined(OLYMPUS_MROBE_500))) || \
|
2011-12-31 20:20:54 +00:00
|
|
|
(defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_S3C6400X) || \
|
2009-10-20 07:21:08 +00:00
|
|
|
defined(CPU_TCC77X) || defined(CPU_TCC780X) || \
|
2010-06-18 01:47:39 +00:00
|
|
|
(CONFIG_USBOTG == USBOTG_JZ4740) || \
|
2011-12-31 20:20:54 +00:00
|
|
|
(defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_AS3525)
|
2008-04-18 16:42:50 +00:00
|
|
|
#define USB_FULL_INIT
|
|
|
|
#endif
|
|
|
|
|
2004-06-30 13:31:14 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
bool do_screendump_instead_of_usb = false;
|
2008-04-18 16:42:50 +00:00
|
|
|
#endif
|
2004-06-30 13:31:14 +00:00
|
|
|
|
2003-12-12 13:30:15 +00:00
|
|
|
#if !defined(SIMULATOR) && !defined(USB_NONE)
|
2002-06-29 22:41:39 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
/* We assume that the USB cable is extracted */
|
|
|
|
static int usb_state = USB_EXTRACTED;
|
2011-10-08 13:00:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC) && defined(USB_FULL_INIT) && !defined(HAVE_USBSTACK)
|
2004-10-10 19:51:11 +00:00
|
|
|
static int usb_mmc_countdown = 0;
|
|
|
|
#endif
|
|
|
|
|
2010-10-25 12:36:57 +00:00
|
|
|
/* Make sure there's enough stack space for screendump */
|
2008-04-18 16:42:50 +00:00
|
|
|
#ifdef USB_FULL_INIT
|
2011-02-27 22:44:54 +00:00
|
|
|
static long usb_stack[(DEFAULT_STACK_SIZE + DUMP_BMP_LINESIZE)/sizeof(long)];
|
2004-08-03 19:22:56 +00:00
|
|
|
static const char usb_thread_name[] = "usb";
|
2008-12-10 08:57:10 +00:00
|
|
|
static unsigned int usb_thread_entry = 0;
|
2011-01-18 14:35:56 +00:00
|
|
|
static bool usb_monitor_enabled = false;
|
2009-01-14 07:23:41 +00:00
|
|
|
#endif /* USB_FULL_INIT */
|
2011-02-14 11:27:45 +00:00
|
|
|
static struct event_queue usb_queue SHAREDBSS_ATTR;
|
2011-01-18 14:10:06 +00:00
|
|
|
static bool exclusive_storage_access = false;
|
|
|
|
#ifdef USB_ENABLE_HID
|
|
|
|
static bool usb_hid = true;
|
2008-02-27 19:08:30 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-18 16:42:50 +00:00
|
|
|
#ifdef USB_FULL_INIT
|
2012-01-04 22:07:09 +00:00
|
|
|
static bool usb_host_present = false;
|
|
|
|
static int usb_num_acks_to_expect = 0;
|
|
|
|
static long usb_last_broadcast_tick = 0;
|
2009-01-13 16:27:35 +00:00
|
|
|
|
|
|
|
#if defined(USB_FIREWIRE_HANDLING) \
|
|
|
|
|| (defined(HAVE_USBSTACK) && !defined(USE_ROCKBOX_USB))
|
|
|
|
static void try_reboot(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_DISK_STORAGE
|
|
|
|
storage_sleepnow(); /* Immediately spindown the disk. */
|
|
|
|
sleep(HZ*2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IPOD_ARCH /* The following code is based on ipodlinux */
|
|
|
|
#if CONFIG_CPU == PP5020
|
|
|
|
memcpy((void *)0x40017f00, "diskmode\0\0hotstuff\0\0\1", 21);
|
|
|
|
#elif CONFIG_CPU == PP5022
|
|
|
|
memcpy((void *)0x4001ff00, "diskmode\0\0hotstuff\0\0\1", 21);
|
|
|
|
#endif /* CONFIG_CPU */
|
|
|
|
#endif /* IPOD_ARCH */
|
|
|
|
|
2009-10-20 06:37:07 +00:00
|
|
|
#ifdef IPOD_NANO2G
|
|
|
|
memcpy((void *)0x0002bf00, "diskmodehotstuff\1\0\0\0", 20);
|
|
|
|
#endif
|
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
system_reboot(); /* Reboot */
|
|
|
|
}
|
|
|
|
#endif /* USB_FIRWIRE_HANDLING || (HAVE_USBSTACK && !USE_ROCKBOX_USB) */
|
|
|
|
|
2011-12-15 00:14:36 +00:00
|
|
|
/* Screen dump */
|
2012-01-04 21:55:09 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2011-01-18 14:10:06 +00:00
|
|
|
static inline bool usb_do_screendump(void)
|
|
|
|
{
|
|
|
|
if(do_screendump_instead_of_usb)
|
|
|
|
{
|
|
|
|
screen_dump();
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
remote_screen_dump();
|
2011-12-15 00:14:36 +00:00
|
|
|
#endif /* HAVE_REMOTE_LCD */
|
2011-01-18 14:10:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-15 00:14:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-01-04 21:55:09 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2011-12-15 00:14:36 +00:00
|
|
|
/* Power (charging-only) button */
|
|
|
|
static inline bool usb_power_button(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_USB_POWER
|
|
|
|
return (button_status() & ~USBPOWER_BTN_IGNORE);
|
|
|
|
#else
|
2011-01-18 14:10:06 +00:00
|
|
|
return false;
|
2011-12-15 00:14:36 +00:00
|
|
|
#endif
|
2011-01-18 14:10:06 +00:00
|
|
|
}
|
2011-12-15 00:14:36 +00:00
|
|
|
|
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
|
|
|
static inline bool usb_reboot_button(void)
|
2011-01-18 14:10:06 +00:00
|
|
|
{
|
2011-12-15 00:14:36 +00:00
|
|
|
#ifdef HAVE_USB_POWER
|
|
|
|
return (button_status() & ~USBPOWER_BTN_IGNORE);
|
|
|
|
#else
|
2011-01-18 14:10:06 +00:00
|
|
|
return false;
|
2011-12-15 00:14:36 +00:00
|
|
|
#endif
|
2011-01-18 14:10:06 +00:00
|
|
|
}
|
2011-12-15 00:14:36 +00:00
|
|
|
#endif /* USB_FIREWIRE_HANDLING */
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2011-12-15 00:14:36 +00:00
|
|
|
/*--- Routines that differ depending upon the presence of a USB stack ---*/
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
2011-12-14 09:19:50 +00:00
|
|
|
/* Enable / disable USB when the stack is enabled - otherwise a noop */
|
|
|
|
static inline void usb_stack_enable(bool enable)
|
|
|
|
{
|
|
|
|
usb_enable(enable);
|
|
|
|
}
|
2011-01-18 14:35:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
static inline void usb_handle_hotswap(long id)
|
|
|
|
{
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYS_HOTSWAP_INSERTED:
|
|
|
|
case SYS_HOTSWAP_EXTRACTED:
|
|
|
|
usb_core_hotswap_event(1, id == SYS_HOTSWAP_INSERTED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Note: No MMC storage handling is needed with the stack atm. */
|
|
|
|
}
|
|
|
|
#endif /* HAVE_HOTSWAP */
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
static inline bool usb_configure_drivers(int for_state)
|
2009-01-13 16:27:35 +00:00
|
|
|
{
|
2011-01-18 14:10:06 +00:00
|
|
|
switch(for_state)
|
|
|
|
{
|
|
|
|
case USB_POWERED:
|
|
|
|
#ifdef USB_ENABLE_STORAGE
|
|
|
|
usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, false);
|
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_HID
|
|
|
|
#ifdef USB_ENABLE_CHARGING_ONLY
|
|
|
|
usb_core_enable_driver(USB_DRIVER_HID, false);
|
|
|
|
#else
|
|
|
|
usb_core_enable_driver(USB_DRIVER_HID, true);
|
|
|
|
#endif /* USB_ENABLE_CHARGING_ONLY */
|
|
|
|
#endif /* USB_ENABLE_HID */
|
|
|
|
|
|
|
|
#ifdef USB_ENABLE_CHARGING_ONLY
|
|
|
|
usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, true);
|
|
|
|
#endif
|
|
|
|
exclusive_storage_access = false;
|
|
|
|
|
|
|
|
usb_attach(); /* Powered only: attach now. */
|
|
|
|
break;
|
|
|
|
/* USB_POWERED: */
|
|
|
|
|
|
|
|
case USB_INSERTED:
|
|
|
|
#ifdef USB_ENABLE_STORAGE
|
|
|
|
usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, true);
|
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_HID
|
|
|
|
usb_core_enable_driver(USB_DRIVER_HID, usb_hid);
|
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_CHARGING_ONLY
|
|
|
|
usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false);
|
|
|
|
#endif
|
|
|
|
/* Check any drivers enabled at this point for exclusive storage
|
|
|
|
* access requirements. */
|
|
|
|
exclusive_storage_access = usb_core_any_exclusive_storage();
|
|
|
|
|
|
|
|
if(exclusive_storage_access)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
usb_attach(); /* Not exclusive: attach now. */
|
|
|
|
break;
|
|
|
|
/* USB_INSERTED: */
|
|
|
|
|
|
|
|
case USB_EXTRACTED:
|
|
|
|
if(exclusive_storage_access)
|
|
|
|
usb_release_exclusive_storage();
|
|
|
|
break;
|
|
|
|
/* USB_EXTRACTED: */
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
#ifdef USE_ROCKBOX_USB
|
2011-01-18 14:10:06 +00:00
|
|
|
static inline void usb_slave_mode(bool on)
|
|
|
|
{
|
2009-01-13 16:27:35 +00:00
|
|
|
int rc;
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
if(on)
|
2009-01-13 16:27:35 +00:00
|
|
|
{
|
|
|
|
trigger_cpu_boost();
|
|
|
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
2011-03-05 17:48:06 +00:00
|
|
|
thread_set_priority(thread_self(), PRIORITY_REALTIME);
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif
|
2010-11-28 15:22:51 +00:00
|
|
|
disk_unmount_all();
|
2009-01-19 13:41:25 +00:00
|
|
|
usb_attach();
|
2009-01-13 16:27:35 +00:00
|
|
|
}
|
|
|
|
else /* usb_state == USB_INSERTED (only!) */
|
|
|
|
{
|
|
|
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
2011-03-05 17:48:06 +00:00
|
|
|
thread_set_priority(thread_self(), PRIORITY_SYSTEM);
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif
|
|
|
|
/* Entered exclusive mode */
|
|
|
|
rc = disk_mount_all();
|
2011-01-18 14:10:06 +00:00
|
|
|
if(rc <= 0) /* no partition */
|
2009-01-13 16:27:35 +00:00
|
|
|
panicf("mount: %d",rc);
|
|
|
|
|
|
|
|
cancel_cpu_boost();
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
}
|
2011-11-20 17:57:24 +00:00
|
|
|
#else /* !USE_ROCKBOX_USB */
|
2011-01-18 14:10:06 +00:00
|
|
|
static inline void usb_slave_mode(bool on)
|
|
|
|
{
|
2011-12-15 00:14:36 +00:00
|
|
|
/* Until we have native mass-storage mode, we want to reboot on USB host
|
|
|
|
* connect */
|
2011-01-18 14:10:06 +00:00
|
|
|
if(on)
|
2009-01-13 16:27:35 +00:00
|
|
|
try_reboot();
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif /* USE_ROCKBOX_USB */
|
2009-01-13 16:27:35 +00:00
|
|
|
|
|
|
|
void usb_signal_transfer_completion(
|
|
|
|
struct usb_transfer_completion_event_data* event_data)
|
|
|
|
{
|
|
|
|
queue_post(&usb_queue, USB_TRANSFER_COMPLETION, (intptr_t)event_data);
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
#else /* !HAVE_USBSTACK */
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2011-12-14 09:19:50 +00:00
|
|
|
static inline void usb_stack_enable(bool enable)
|
|
|
|
{
|
|
|
|
(void)enable;
|
|
|
|
}
|
|
|
|
|
2011-01-18 14:35:56 +00:00
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
static inline void usb_handle_hotswap(long id)
|
|
|
|
{
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYS_HOTSWAP_INSERTED:
|
|
|
|
case SYS_HOTSWAP_EXTRACTED:
|
|
|
|
if(usb_state == USB_INSERTED)
|
|
|
|
{
|
|
|
|
usb_enable(false);
|
|
|
|
usb_mmc_countdown = HZ/2; /* re-enable after 0.5 sec */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case USB_REENABLE:
|
|
|
|
if(usb_state == USB_INSERTED)
|
|
|
|
usb_enable(true); /* reenable only if still inserted */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* STORAGE_MMC */
|
|
|
|
(void)id;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_HOTSWAP */
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
static inline bool usb_configure_drivers(int for_state)
|
|
|
|
{
|
|
|
|
switch(for_state)
|
|
|
|
{
|
|
|
|
case USB_POWERED:
|
|
|
|
exclusive_storage_access = false;
|
|
|
|
break;
|
|
|
|
case USB_INSERTED:
|
|
|
|
exclusive_storage_access = true;
|
|
|
|
return true;
|
|
|
|
case USB_EXTRACTED:
|
|
|
|
if(exclusive_storage_access)
|
|
|
|
usb_release_exclusive_storage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
static inline void usb_slave_mode(bool on)
|
2002-06-30 13:13:13 +00:00
|
|
|
{
|
|
|
|
int rc;
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2002-06-30 13:13:13 +00:00
|
|
|
if(on)
|
|
|
|
{
|
2002-07-01 11:02:54 +00:00
|
|
|
DEBUGF("Entering USB slave mode\n");
|
2010-11-28 15:22:51 +00:00
|
|
|
disk_unmount_all();
|
2008-11-01 16:14:28 +00:00
|
|
|
storage_soft_reset();
|
|
|
|
storage_init();
|
|
|
|
storage_enable(false);
|
2002-07-01 11:02:54 +00:00
|
|
|
usb_enable(true);
|
2009-01-13 16:27:35 +00:00
|
|
|
cpu_idle_mode(true);
|
2002-06-30 13:13:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-07-01 11:02:54 +00:00
|
|
|
DEBUGF("Leaving USB slave mode\n");
|
2007-11-22 20:51:00 +00:00
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
cpu_idle_mode(false);
|
|
|
|
|
2002-07-01 11:02:54 +00:00
|
|
|
/* Let the ISDx00 settle */
|
|
|
|
sleep(HZ*1);
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2002-07-01 11:02:54 +00:00
|
|
|
usb_enable(false);
|
2002-06-30 13:13:13 +00:00
|
|
|
|
2008-11-01 16:14:28 +00:00
|
|
|
rc = storage_init();
|
2002-07-01 11:02:54 +00:00
|
|
|
if(rc)
|
2008-11-01 16:14:28 +00:00
|
|
|
panicf("storage: %d",rc);
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2011-08-15 14:36:23 +00:00
|
|
|
sleep(HZ/10);
|
2004-12-29 22:10:24 +00:00
|
|
|
rc = disk_mount_all();
|
2011-01-18 14:10:06 +00:00
|
|
|
if(rc <= 0) /* no partition */
|
2002-07-01 11:02:54 +00:00
|
|
|
panicf("mount: %d",rc);
|
2002-06-30 13:13:13 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif /* HAVE_USBSTACK */
|
2008-02-27 19:08:30 +00:00
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
static void usb_set_host_present(bool present)
|
|
|
|
{
|
|
|
|
if(usb_host_present == present)
|
|
|
|
return;
|
|
|
|
|
|
|
|
usb_host_present = present;
|
|
|
|
|
|
|
|
if(!usb_host_present)
|
|
|
|
{
|
|
|
|
usb_configure_drivers(USB_EXTRACTED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(usb_power_button())
|
|
|
|
{
|
|
|
|
/* Only charging is desired */
|
|
|
|
usb_configure_drivers(USB_POWERED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!usb_configure_drivers(USB_INSERTED))
|
|
|
|
return; /* Exclusive storage access not required */
|
|
|
|
|
|
|
|
/* Tell all threads that they have to back off the storage.
|
|
|
|
We subtract one for our own thread. Expect an ACK for every
|
|
|
|
listener for each broadcast they received. If it has been too
|
|
|
|
long, the user might have entered a screen that didn't ACK
|
|
|
|
when inserting the cable, such as a debugging screen. In that
|
|
|
|
case, reset the count or else USB would be locked out until
|
|
|
|
rebooting because it most likely won't ever come. Simply
|
|
|
|
resetting to the most recent broadcast count is racy. */
|
|
|
|
if(TIME_AFTER(current_tick, usb_last_broadcast_tick + HZ*5))
|
|
|
|
{
|
|
|
|
usb_num_acks_to_expect = 0;
|
|
|
|
usb_last_broadcast_tick = current_tick;
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_num_acks_to_expect += queue_broadcast(SYS_USB_CONNECTED, 0) - 1;
|
2012-01-07 18:08:28 +00:00
|
|
|
DEBUGF("usb: waiting for %d acks...\n", usb_num_acks_to_expect);
|
2012-01-04 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool usb_handle_connected_ack(void)
|
|
|
|
{
|
|
|
|
if(usb_num_acks_to_expect > 0 && --usb_num_acks_to_expect == 0)
|
|
|
|
{
|
|
|
|
DEBUGF("usb: all threads have acknowledged the connect.\n");
|
|
|
|
if(usb_host_present)
|
|
|
|
{
|
|
|
|
usb_slave_mode(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-07 18:09:23 +00:00
|
|
|
DEBUGF("usb: got ack, %d to go...\n", usb_num_acks_to_expect);
|
2012-01-04 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-23 13:29:19 +00:00
|
|
|
|
2011-12-15 00:14:36 +00:00
|
|
|
/*--- General driver code ---*/
|
|
|
|
static void NORETURN_ATTR usb_thread(void)
|
2002-06-29 22:41:39 +00:00
|
|
|
{
|
2007-10-16 01:25:17 +00:00
|
|
|
struct queue_event ev;
|
2002-06-29 22:41:39 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2002-07-01 11:02:54 +00:00
|
|
|
queue_wait(&usb_queue, &ev);
|
2011-12-15 00:14:36 +00:00
|
|
|
|
2002-07-01 11:02:54 +00:00
|
|
|
switch(ev.id)
|
|
|
|
{
|
2011-01-18 14:10:06 +00:00
|
|
|
/*** Main USB thread duties ***/
|
|
|
|
|
2008-02-27 19:08:30 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
2011-01-18 14:10:06 +00:00
|
|
|
case USB_TRANSFER_COMPLETION:
|
2011-12-15 00:14:36 +00:00
|
|
|
if(usb_state <= USB_EXTRACTED)
|
|
|
|
break;
|
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
#ifdef USB_DETECT_BY_REQUEST
|
|
|
|
usb_set_host_present(true);
|
|
|
|
#endif
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
usb_core_handle_transfer_completion(
|
|
|
|
(struct usb_transfer_completion_event_data*)ev.data);
|
|
|
|
break;
|
|
|
|
#endif /* HAVE_USBSTACK */
|
|
|
|
|
|
|
|
case USB_INSERTED:
|
|
|
|
if(usb_state != USB_EXTRACTED)
|
2009-01-19 13:41:25 +00:00
|
|
|
break;
|
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2011-01-18 14:10:06 +00:00
|
|
|
if(usb_do_screendump())
|
|
|
|
{
|
2012-01-04 21:55:09 +00:00
|
|
|
usb_state = USB_SCREENDUMP;
|
2011-01-18 14:10:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-01-04 21:55:09 +00:00
|
|
|
#endif
|
2009-01-13 16:27:35 +00:00
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
usb_state = USB_POWERED;
|
|
|
|
usb_stack_enable(true);
|
2009-01-13 16:27:35 +00:00
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
#ifndef USB_DETECT_BY_REQUEST
|
|
|
|
usb_set_host_present(true);
|
|
|
|
#endif
|
2011-01-18 14:10:06 +00:00
|
|
|
break;
|
2012-01-04 21:55:09 +00:00
|
|
|
/* USB_INSERTED */
|
2011-01-18 14:10:06 +00:00
|
|
|
|
|
|
|
case SYS_USB_CONNECTED_ACK:
|
2012-01-04 21:55:09 +00:00
|
|
|
if(usb_handle_connected_ack())
|
|
|
|
usb_state = USB_INSERTED;
|
2011-01-18 14:10:06 +00:00
|
|
|
break;
|
|
|
|
/* SYS_USB_CONNECTED_ACK */
|
|
|
|
|
|
|
|
case USB_EXTRACTED:
|
|
|
|
if(usb_state == USB_EXTRACTED)
|
2002-07-01 11:02:54 +00:00
|
|
|
break;
|
2005-06-23 02:18:29 +00:00
|
|
|
|
2011-12-14 09:19:50 +00:00
|
|
|
if(usb_state == USB_POWERED || usb_state == USB_INSERTED)
|
|
|
|
usb_stack_enable(false);
|
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
/* Only disable the USB slave mode if we really have enabled
|
|
|
|
it. Some expected acks may not have been received. */
|
|
|
|
if(usb_state == USB_INSERTED)
|
|
|
|
usb_slave_mode(false);
|
|
|
|
|
|
|
|
usb_state = USB_EXTRACTED;
|
2011-01-28 04:01:34 +00:00
|
|
|
|
2012-01-04 21:55:09 +00:00
|
|
|
usb_set_host_present(false);
|
2011-01-18 14:10:06 +00:00
|
|
|
break;
|
2011-12-15 00:14:36 +00:00
|
|
|
/* USB_EXTRACTED: */
|
2004-10-10 19:51:11 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
/*** Miscellaneous USB thread duties ***/
|
|
|
|
|
|
|
|
/* HOTSWAP */
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
case SYS_HOTSWAP_INSERTED:
|
|
|
|
case SYS_HOTSWAP_EXTRACTED:
|
2009-01-13 16:27:35 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
2011-01-18 14:10:06 +00:00
|
|
|
case USB_REENABLE:
|
|
|
|
#endif
|
|
|
|
usb_handle_hotswap(ev.id);
|
2011-10-27 10:35:45 +00:00
|
|
|
break;
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif
|
2009-01-13 16:27:35 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
/* FIREWIRE */
|
2009-01-13 16:27:35 +00:00
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
2011-01-18 14:10:06 +00:00
|
|
|
case USB_REQUEST_REBOOT:
|
|
|
|
if(usb_reboot_button())
|
|
|
|
try_reboot();
|
|
|
|
break;
|
2008-02-27 19:23:16 +00:00
|
|
|
#endif
|
2010-06-05 20:43:30 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
/* CHARGING */
|
2010-06-05 20:43:30 +00:00
|
|
|
#if defined(HAVE_USB_CHARGING_ENABLE) && defined(HAVE_USBSTACK)
|
2011-01-18 14:10:06 +00:00
|
|
|
case USB_CHARGER_UPDATE:
|
|
|
|
usb_charging_maxcurrent_change(usb_charging_maxcurrent());
|
|
|
|
break;
|
2010-06-05 20:43:30 +00:00
|
|
|
#endif
|
2011-01-18 14:10:06 +00:00
|
|
|
|
|
|
|
/* CLOSE */
|
|
|
|
#ifdef USB_DRIVER_CLOSE
|
|
|
|
case USB_QUIT:
|
2011-12-15 00:14:36 +00:00
|
|
|
thread_exit();
|
|
|
|
break;
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif
|
|
|
|
} /* switch */
|
|
|
|
} /* while */
|
2002-06-29 22:41:39 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 20:43:30 +00:00
|
|
|
#if defined(HAVE_USB_CHARGING_ENABLE) && defined(HAVE_USBSTACK)
|
|
|
|
void usb_charger_update(void)
|
|
|
|
{
|
|
|
|
queue_post(&usb_queue, USB_CHARGER_UPDATE, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-01-14 07:01:49 +00:00
|
|
|
#ifdef USB_STATUS_BY_EVENT
|
|
|
|
void usb_status_event(int current_status)
|
|
|
|
{
|
2009-01-22 22:05:04 +00:00
|
|
|
/* Caller isn't expected to filter for changes in status.
|
|
|
|
* current_status:
|
2012-01-04 21:55:09 +00:00
|
|
|
* USB_INSERTED, USB_EXTRACTED
|
2009-01-22 22:05:04 +00:00
|
|
|
*/
|
2009-01-19 13:41:25 +00:00
|
|
|
if(usb_monitor_enabled)
|
2009-01-14 07:01:49 +00:00
|
|
|
{
|
2009-01-19 13:41:25 +00:00
|
|
|
int oldstatus = disable_irq_save(); /* Dual-use function */
|
2011-01-18 14:10:06 +00:00
|
|
|
queue_remove_from_head(&usb_queue, current_status);
|
|
|
|
queue_post(&usb_queue, current_status, 0);
|
2009-01-19 13:41:25 +00:00
|
|
|
restore_irq(oldstatus);
|
2009-01-14 07:01:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_start_monitoring(void)
|
|
|
|
{
|
2009-01-22 22:05:04 +00:00
|
|
|
int oldstatus = disable_irq_save(); /* Sync to event */
|
2009-01-19 13:41:25 +00:00
|
|
|
int status = usb_detect();
|
2009-01-22 22:05:04 +00:00
|
|
|
|
|
|
|
usb_monitor_enabled = true;
|
|
|
|
|
2011-01-17 13:12:22 +00:00
|
|
|
/* An event may have been missed because it was sent before monitoring
|
|
|
|
* was enabled due to the connector already having been inserted before
|
|
|
|
* before or during boot. */
|
2009-01-19 13:41:25 +00:00
|
|
|
usb_status_event(status);
|
2009-01-22 22:05:04 +00:00
|
|
|
|
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
2011-01-18 14:10:06 +00:00
|
|
|
if(firewire_detect())
|
2009-01-22 22:05:04 +00:00
|
|
|
usb_firewire_connect_event();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
restore_irq(oldstatus);
|
2009-01-14 07:01:49 +00:00
|
|
|
}
|
2009-01-22 22:05:04 +00:00
|
|
|
|
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
|
|
|
void usb_firewire_connect_event(void)
|
|
|
|
{
|
|
|
|
queue_post(&usb_queue, USB_REQUEST_REBOOT, 0);
|
|
|
|
}
|
|
|
|
#endif /* USB_FIREWIRE_HANDLING */
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2009-01-14 07:01:49 +00:00
|
|
|
#else /* !USB_STATUS_BY_EVENT */
|
2011-01-18 14:10:06 +00:00
|
|
|
|
2003-07-03 22:11:14 +00:00
|
|
|
static void usb_tick(void)
|
|
|
|
{
|
2011-01-18 14:10:06 +00:00
|
|
|
#define NUM_POLL_READINGS (HZ/5)
|
|
|
|
static int usb_countdown = -1;
|
|
|
|
static int last_usb_status = USB_EXTRACTED;
|
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
|
|
|
static int firewire_countdown = -1;
|
|
|
|
static int last_firewire_status = false;
|
|
|
|
#endif
|
2003-07-03 22:11:14 +00:00
|
|
|
|
|
|
|
if(usb_monitor_enabled)
|
|
|
|
{
|
2009-01-13 16:27:35 +00:00
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
2008-02-27 19:08:30 +00:00
|
|
|
int current_firewire_status = firewire_detect();
|
|
|
|
if(current_firewire_status != last_firewire_status)
|
|
|
|
{
|
|
|
|
last_firewire_status = current_firewire_status;
|
|
|
|
firewire_countdown = NUM_POLL_READINGS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Count down until it gets negative */
|
|
|
|
if(firewire_countdown >= 0)
|
|
|
|
firewire_countdown--;
|
|
|
|
|
|
|
|
/* Report to the thread if we have had 3 identical status
|
|
|
|
readings in a row */
|
|
|
|
if(firewire_countdown == 0)
|
|
|
|
{
|
|
|
|
queue_post(&usb_queue, USB_REQUEST_REBOOT, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif /* USB_FIREWIRE_HANDLING */
|
2008-02-27 19:08:30 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
int current_status = usb_detect();
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2002-07-01 11:02:54 +00:00
|
|
|
/* Only report when the status has changed */
|
|
|
|
if(current_status != last_usb_status)
|
|
|
|
{
|
|
|
|
last_usb_status = current_status;
|
2011-01-18 14:10:06 +00:00
|
|
|
usb_countdown = NUM_POLL_READINGS;
|
2002-07-01 19:32:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Count down until it gets negative */
|
2011-01-18 14:10:06 +00:00
|
|
|
if(usb_countdown >= 0)
|
|
|
|
usb_countdown--;
|
2002-07-01 19:32:54 +00:00
|
|
|
|
|
|
|
/* Report to the thread if we have had 3 identical status
|
|
|
|
readings in a row */
|
2011-01-18 14:10:06 +00:00
|
|
|
if(usb_countdown == 0)
|
2002-07-01 19:32:54 +00:00
|
|
|
{
|
2007-09-04 08:03:07 +00:00
|
|
|
queue_post(&usb_queue, current_status, 0);
|
2002-07-01 19:32:54 +00:00
|
|
|
}
|
2002-07-01 11:02:54 +00:00
|
|
|
}
|
2002-06-29 22:41:39 +00:00
|
|
|
}
|
2008-10-31 21:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
2004-10-10 19:51:11 +00:00
|
|
|
if(usb_mmc_countdown > 0)
|
|
|
|
{
|
|
|
|
usb_mmc_countdown--;
|
2011-01-18 14:10:06 +00:00
|
|
|
if(usb_mmc_countdown == 0)
|
2006-12-19 16:50:07 +00:00
|
|
|
queue_post(&usb_queue, USB_REENABLE, 0);
|
2004-10-10 19:51:11 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-06-29 22:41:39 +00:00
|
|
|
}
|
2009-01-14 07:01:49 +00:00
|
|
|
|
|
|
|
void usb_start_monitoring(void)
|
|
|
|
{
|
|
|
|
usb_monitor_enabled = true;
|
|
|
|
}
|
|
|
|
#endif /* USB_STATUS_BY_EVENT */
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif /* USB_FULL_INIT */
|
2002-06-29 22:41:39 +00:00
|
|
|
|
2005-01-30 15:16:58 +00:00
|
|
|
void usb_acknowledge(long id)
|
2002-06-29 22:41:39 +00:00
|
|
|
{
|
2006-12-19 16:50:07 +00:00
|
|
|
queue_post(&usb_queue, id, 0);
|
2002-06-29 22:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usb_init(void)
|
|
|
|
{
|
2008-04-18 16:42:50 +00:00
|
|
|
#ifdef USB_FULL_INIT
|
2002-06-30 13:13:13 +00:00
|
|
|
usb_enable(false);
|
|
|
|
|
2006-09-16 16:18:11 +00:00
|
|
|
queue_init(&usb_queue, true);
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2008-02-27 19:08:30 +00:00
|
|
|
usb_thread_entry = create_thread(usb_thread, usb_stack,
|
|
|
|
sizeof(usb_stack), 0, usb_thread_name
|
|
|
|
IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU));
|
2002-06-29 22:41:39 +00:00
|
|
|
|
2009-01-14 07:01:49 +00:00
|
|
|
#ifndef USB_STATUS_BY_EVENT
|
2002-06-30 13:13:13 +00:00
|
|
|
tick_add_task(usb_tick);
|
2009-01-14 07:01:49 +00:00
|
|
|
#endif
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif /* USB_FULL_INIT */
|
2011-09-05 11:37:12 +00:00
|
|
|
|
|
|
|
usb_init_device();
|
2002-06-30 13:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usb_wait_for_disconnect(struct event_queue *q)
|
|
|
|
{
|
2008-12-03 21:15:44 +00:00
|
|
|
#ifdef USB_FULL_INIT
|
2007-10-16 01:25:17 +00:00
|
|
|
struct queue_event ev;
|
2002-06-30 13:13:13 +00:00
|
|
|
|
|
|
|
/* Don't return until we get SYS_USB_DISCONNECTED */
|
|
|
|
while(1)
|
|
|
|
{
|
2002-07-01 11:02:54 +00:00
|
|
|
queue_wait(q, &ev);
|
|
|
|
if(ev.id == SYS_USB_DISCONNECTED)
|
|
|
|
return;
|
2002-06-30 13:13:13 +00:00
|
|
|
}
|
2008-12-03 21:15:44 +00:00
|
|
|
#endif /* USB_FULL_INIT */
|
2011-01-18 14:10:06 +00:00
|
|
|
(void)q;
|
2002-06-30 13:13:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-11 08:56:23 +00:00
|
|
|
int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks)
|
|
|
|
{
|
2008-12-03 21:15:44 +00:00
|
|
|
#ifdef USB_FULL_INIT
|
2007-10-16 01:25:17 +00:00
|
|
|
struct queue_event ev;
|
2002-10-11 08:56:23 +00:00
|
|
|
|
|
|
|
/* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
queue_wait_w_tmo(q, &ev, ticks);
|
|
|
|
switch(ev.id)
|
|
|
|
{
|
|
|
|
case SYS_USB_DISCONNECTED:
|
|
|
|
return 0;
|
|
|
|
case SYS_TIMEOUT:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif /* USB_FULL_INIT */
|
2008-12-03 21:15:44 +00:00
|
|
|
(void)q; (void)ticks;
|
|
|
|
return 0;
|
2002-10-11 08:56:23 +00:00
|
|
|
}
|
|
|
|
|
2008-05-10 18:00:11 +00:00
|
|
|
#ifdef USB_DRIVER_CLOSE
|
|
|
|
void usb_close(void)
|
2008-04-18 16:42:50 +00:00
|
|
|
{
|
2008-12-10 09:11:43 +00:00
|
|
|
unsigned int thread = usb_thread_entry;
|
2008-12-10 08:57:10 +00:00
|
|
|
usb_thread_entry = 0;
|
2008-05-10 18:00:11 +00:00
|
|
|
|
2011-01-18 14:10:06 +00:00
|
|
|
if(thread == 0)
|
2008-05-10 18:00:11 +00:00
|
|
|
return;
|
|
|
|
|
2009-01-14 07:01:49 +00:00
|
|
|
#ifndef USB_STATUS_BY_EVENT
|
2008-04-18 16:42:50 +00:00
|
|
|
tick_remove_task(usb_tick);
|
2009-01-14 07:01:49 +00:00
|
|
|
#endif
|
2008-04-18 16:42:50 +00:00
|
|
|
usb_monitor_enabled = false;
|
2008-05-10 18:00:11 +00:00
|
|
|
queue_post(&usb_queue, USB_QUIT, 0);
|
|
|
|
thread_wait(thread);
|
2008-04-18 16:42:50 +00:00
|
|
|
}
|
2008-05-10 18:00:11 +00:00
|
|
|
#endif /* USB_DRIVER_CLOSE */
|
2008-04-18 16:42:50 +00:00
|
|
|
|
2002-09-25 19:25:10 +00:00
|
|
|
bool usb_inserted(void)
|
|
|
|
{
|
2006-02-19 11:37:30 +00:00
|
|
|
return usb_state == USB_INSERTED || usb_state == USB_POWERED;
|
2002-09-25 19:25:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-02 00:15:02 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
2009-01-13 16:27:35 +00:00
|
|
|
bool usb_exclusive_storage(void)
|
2008-03-02 00:15:02 +00:00
|
|
|
{
|
2011-01-29 00:22:42 +00:00
|
|
|
/* Storage isn't actually exclusive until slave mode has been entered */
|
|
|
|
return exclusive_storage_access && usb_state == USB_INSERTED;
|
2008-03-02 00:15:02 +00:00
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif /* HAVE_USBSTACK */
|
2008-03-02 00:15:02 +00:00
|
|
|
|
2009-02-28 15:16:54 +00:00
|
|
|
int usb_release_exclusive_storage(void)
|
|
|
|
{
|
2011-01-18 14:10:06 +00:00
|
|
|
int bccount;
|
2009-02-28 15:16:54 +00:00
|
|
|
exclusive_storage_access = false;
|
|
|
|
/* Tell all threads that we are back in business */
|
2011-01-18 14:10:06 +00:00
|
|
|
bccount = queue_broadcast(SYS_USB_DISCONNECTED, 0) - 1;
|
|
|
|
DEBUGF("USB extracted. Broadcast to %d threads...\n", bccount);
|
|
|
|
return bccount;
|
2009-02-28 15:16:54 +00:00
|
|
|
}
|
|
|
|
|
2005-06-23 02:18:29 +00:00
|
|
|
#ifdef HAVE_USB_POWER
|
|
|
|
bool usb_powered(void)
|
|
|
|
{
|
|
|
|
return usb_state == USB_POWERED;
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif /* HAVE_USB_POWER */
|
2005-06-23 02:18:29 +00:00
|
|
|
|
2009-10-23 13:29:19 +00:00
|
|
|
#ifdef USB_ENABLE_HID
|
|
|
|
void usb_set_hid(bool enable)
|
|
|
|
{
|
|
|
|
usb_hid = enable;
|
|
|
|
usb_core_enable_driver(USB_DRIVER_HID, usb_hid);
|
|
|
|
}
|
2011-01-18 14:10:06 +00:00
|
|
|
#endif /* USB_ENABLE_HID */
|
2009-10-23 13:29:19 +00:00
|
|
|
|
2011-11-17 18:40:00 +00:00
|
|
|
#elif defined(USB_NONE)
|
|
|
|
/* Dummy functions for USB_NONE */
|
2002-06-29 22:41:39 +00:00
|
|
|
|
2003-12-12 13:30:15 +00:00
|
|
|
bool usb_inserted(void)
|
|
|
|
{
|
2003-12-15 11:44:06 +00:00
|
|
|
return false;
|
2003-12-12 13:30:15 +00:00
|
|
|
}
|
|
|
|
|
2005-01-30 15:16:58 +00:00
|
|
|
void usb_acknowledge(long id)
|
2002-06-29 22:41:39 +00:00
|
|
|
{
|
|
|
|
id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-06-30 13:13:13 +00:00
|
|
|
void usb_start_monitoring(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-09-04 08:03:07 +00:00
|
|
|
int usb_detect(void)
|
2003-07-20 00:08:09 +00:00
|
|
|
{
|
2007-09-04 08:03:07 +00:00
|
|
|
return USB_EXTRACTED;
|
2003-07-20 00:08:09 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 20:54:09 +00:00
|
|
|
void usb_wait_for_disconnect(struct event_queue *q)
|
|
|
|
{
|
2006-02-24 21:09:34 +00:00
|
|
|
(void)q;
|
2006-02-24 20:54:09 +00:00
|
|
|
}
|
2011-11-17 18:40:00 +00:00
|
|
|
#endif /* USB_NONE */
|
2006-02-24 20:54:09 +00:00
|
|
|
|