From e26e3477448079dbec29acc1c414c3d6316a5a59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Mon, 1 Aug 2011 01:29:20 +0800 Subject: [PATCH] Revert "temp revert usb gadget change" This reverts commit aa382e22fb1ff34df15ec71d14182c11264526d9. Conflicts: drivers/usb/gadget/composite.c drivers/usb/gadget/f_mass_storage.c --- drivers/usb/gadget/android.c | 6 +- drivers/usb/gadget/composite.c | 1 + drivers/usb/gadget/f_adb.c | 2 +- drivers/usb/gadget/f_mass_storage.c | 114 ++++++++++++++++++++++++++++ drivers/usb/gadget/storage_common.c | 3 + 5 files changed, 122 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index a107dd25fc8f..cbbf691db2b4 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -54,8 +54,8 @@ MODULE_VERSION("1.0"); static const char longname[] = "Gadget Android"; /* Default vendor and product IDs, overridden by platform data */ -#define VENDOR_ID 0x18D1 -#define PRODUCT_ID 0x0001 +#define VENDOR_ID 0x2207//0x18D1 +#define PRODUCT_ID 0x2910 struct android_dev { struct usb_composite_dev *cdev; @@ -187,7 +187,7 @@ static int android_bind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; - printk(KERN_DEBUG "android_bind_config\n"); + printk("android_bind_config\n"); dev->config = c; if (should_bind_functions(dev)) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 331eb847e138..d91cdcab8f65 100755 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -599,6 +599,7 @@ int usb_add_config(struct usb_composite_dev *cdev, /* Prevent duplicate configuration identifiers */ list_for_each_entry(c, &cdev->configs, list) { if (c->bConfigurationValue == config->bConfigurationValue) { + printk("usb_add_config, already configed,everest\n"); status = -EBUSY; goto done; } diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c index a0b0774b9556..827d1b931271 100644 --- a/drivers/usb/gadget/f_adb.c +++ b/drivers/usb/gadget/f_adb.c @@ -77,7 +77,7 @@ static struct usb_endpoint_descriptor adb_highspeed_in_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(512), + .wMaxPacketSize = __constant_cpu_to_le16(64), }; static struct usb_endpoint_descriptor adb_highspeed_out_desc = { diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 9e37e0863143..236863e64747 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -302,6 +302,28 @@ #define FUNCTION_NAME "usb_mass_storage" #endif +#ifdef CONFIG_ARCH_RK29 +#include +#include +#include + +static int usb_msc_connected; /*usb charge status*/ + +static void set_msc_connect_flag( int connected ) +{ + printk("%s status = %d 20101216\n" , __func__, connected); + if( usb_msc_connected == connected ) + return; + usb_msc_connected = connected;//usb mass storage is ok +} + +int get_msc_connect_flag( void ) +{ + return usb_msc_connected; +} +EXPORT_SYMBOL(get_msc_connect_flag); +#endif + /*------------------------------------------------------------------------*/ #define FSG_DRIVER_DESC "Mass Storage Function" @@ -1940,6 +1962,15 @@ static int check_command(struct fsg_common *common, int cmnd_size, } +#ifdef CONFIG_ARCH_RK29 +static void deferred_restart(struct work_struct *dummy) +{ + sys_sync(); + kernel_restart("loader"); +} +static DECLARE_WORK(restart_work, deferred_restart); +#endif + static int do_scsi_command(struct fsg_common *common) { struct fsg_buffhd *bh; @@ -2135,7 +2166,11 @@ static int do_scsi_command(struct fsg_common *common) (1<<1) | (0xf<<2) | (3<<7), 1, "VERIFY"); if (reply == 0) +#ifdef CONFIG_ARCH_RK29 + reply = 0; //zyf 20100302 +#else reply = do_verify(common); +#endif break; case SC_WRITE_6: @@ -2189,6 +2224,15 @@ unknown_cmnd: reply = -EINVAL; } break; +#ifdef CONFIG_ARCH_RK29 + case 0xff: + if (fsg->cmnd_size >= 6 && fsg->cmnd[1] == 0xe0 && + fsg->cmnd[2] == 0xff && fsg->cmnd[3] == 0xff && + fsg->cmnd[4] == 0xff && fsg->cmnd[5] == 0xfe) { + schedule_work(&restart_work); + } + break; +#endif } up_read(&common->filesem); @@ -2443,6 +2487,8 @@ static void fsg_disable(struct usb_function *f) struct fsg_dev *fsg = fsg_from_func(f); fsg->common->new_fsg = NULL; raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); + // yk 201009 + set_msc_connect_flag(0); } @@ -3174,6 +3220,60 @@ fsg_common_from_params(struct fsg_common *common, #ifdef CONFIG_USB_ANDROID_MASS_STORAGE +#ifdef CONFIG_ARCH_RK29 +static enum power_supply_property usb_props[] = { +// POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_ONLINE, +}; + +static int usb_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + int ret = 0; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: +#ifndef CONFIG_DWC_OTG_HOST_ONLY + val->intval = get_msc_connect_flag(); +#else + val->intval = 0; +#endif + break; + default: + return -EINVAL; + } + + return ret; +} + +static int usb_power_supply_register(struct device* parent) +{ + struct power_supply *ps; + int retval = 0; + + ps = kzalloc(sizeof(*ps), GFP_KERNEL); + if (!ps) { + dev_err(parent, "failed to allocate power supply data\n"); + retval = -ENOMEM; + goto out; + } + ps->name = "usb"; + ps->type = POWER_SUPPLY_TYPE_USB; + ps->properties = usb_props; + ps->num_properties = ARRAY_SIZE(usb_props); + ps->get_property = usb_get_property; + ps->external_power_changed = NULL; + retval = power_supply_register(parent, ps); + if (retval) { + dev_err(parent, "failed to register battery\n"); + goto out; + } +out: + return retval; +} +#endif + static struct fsg_config fsg_cfg; static int fsg_probe(struct platform_device *pdev) @@ -3198,7 +3298,21 @@ static int fsg_probe(struct platform_device *pdev) fsg_cfg.can_stall = 0; fsg_cfg.pdev = pdev; +#ifdef CONFIG_ARCH_RK29 +{ + /* + * Initialize usb power supply + */ + int retval = usb_power_supply_register(&pdev->dev); + if (retval != 0) { + dev_err(&pdev->dev, "usb_power_supply_register failed\n"); + } + + return retval; +} +#else return 0; +#endif } static struct platform_driver fsg_platform_driver = { diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 2771166ac69a..7e3d5599b898 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -805,6 +805,9 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr, struct rw_semaphore *filesem = dev_get_drvdata(dev); int rc = 0; +#ifdef CONFIG_ARCH_RK29 + printk("store_file: \"%s\"\n", buf); +#endif #ifndef CONFIG_USB_ANDROID_MASS_STORAGE /* disabled in android because we need to allow closing the backing file -- 2.34.1