USB: android: Add support for USB Target Function (UASP)

Add UASP function to Android supported functions array.  UASP
function depend on Target core.  Provide empty functions when
Target core is not enabled.

Change-Id: I959f26ebd63e036dae041708d0ad6169213a3cf0
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This commit is contained in:
Pavankumar Kondeti 2012-06-26 09:44:36 +05:30 committed by Stephen Boyd
parent c3c28c1bef
commit cd99d0ea1d
2 changed files with 69 additions and 0 deletions

View file

@ -71,6 +71,9 @@
#include "u_ether.c"
#include "u_bam_data.c"
#include "f_mbim.c"
#ifdef CONFIG_TARGET_CORE
#include "f_tcm.c"
#endif
MODULE_AUTHOR("Mike Lockwood");
MODULE_DESCRIPTION("Android Composite USB Driver");
@ -1211,6 +1214,51 @@ static struct android_usb_function accessory_function = {
.ctrlrequest = accessory_function_ctrlrequest,
};
static int android_uasp_connect_cb(bool connect)
{
/*
* TODO
* We may have to disable gadget till UASP configfs nodes
* are configured which includes mapping LUN with the
* backing file. It is a fundamental difference between
* f_mass_storage and f_tcp. That means UASP can not be
* in default composition.
*
* For now, assume that UASP configfs nodes are configured
* before enabling android gadget. Or cable should be
* reconnected after mapping the LUN.
*
* Also consider making UASP to respond to Host requests when
* Lun is not mapped.
*/
pr_debug("UASP %s\n", connect ? "connect" : "disconnect");
return 0;
}
static int uasp_function_init(struct android_usb_function *f,
struct usb_composite_dev *cdev)
{
return f_tcm_init(&android_uasp_connect_cb);
}
static void uasp_function_cleanup(struct android_usb_function *f)
{
f_tcm_exit();
}
static int uasp_function_bind_config(struct android_usb_function *f,
struct usb_configuration *c)
{
return tcm_bind_config(c);
}
static struct android_usb_function uasp_function = {
.name = "uasp",
.init = uasp_function_init,
.cleanup = uasp_function_cleanup,
.bind_config = uasp_function_bind_config,
};
static struct android_usb_function *supported_functions[] = {
&mbim_function,
@ -1228,6 +1276,7 @@ static struct android_usb_function *supported_functions[] = {
&rndis_function,
&mass_storage_function,
&accessory_function,
&uasp_function,
NULL
};

View file

@ -17,6 +17,8 @@
#ifndef __LINUX_USB_ANDROID_H
#define __LINUX_USB_ANDROID_H
#include <linux/usb/composite.h>
struct android_usb_platform_data {
int (*update_pid_and_serial_num)(uint32_t, const char *);
u32 swfi_latency;
@ -24,4 +26,22 @@ struct android_usb_platform_data {
bool cdrom;
};
#ifndef CONFIG_TARGET_CORE
static inline int f_tcm_init(int (*connect_cb)(bool connect))
{
/*
* Fail bind() not init(). If a function init() returns error
* android composite registration would fail.
*/
return 0;
}
static inline void f_tcm_exit(void)
{
}
static inline int tcm_bind_config(struct usb_configuration *c)
{
return -ENODEV;
}
#endif
#endif /* __LINUX_USB_ANDROID_H */