Re: [U-Boot] [PATCH v4 1/3] usb:gadget:composite USB composite gadget support

2012-04-29 Thread Marek Vasut
Dear Lukasz Majewski,

 On Thu, 26 Apr 2012 00:53:01 +0200
 
 Marek Vasut ma...@denx.de wrote:
  Dear Lukasz Majewski,
  
   USB Composite gadget implementation for u-boot. It builds on top
   of USB UDC drivers.
   
   This commit is based on following files from Linux Kernel v2.6.36:
   
   ./include/linux/usb/composite.h
   ./drivers/usb/gadget/composite.c
   
   SHA1: d187abb9a83e6c6b6e9f2ca17962bdeafb4bc903
   
   Signed-off-by: Lukasz Majewski l.majew...@samsung.com
   Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
   Cc: Marek Vasut ma...@denx.de
  
  Quick glance through this looks fine, I'll preempt here and check the
  rest in a few days ... sorry for the delays, I'm overloaded, please
  understand :-(
 
 Ok, no problem :-)
 
 I just remind about those patches.

They keep being on my mind, and now it looks like I'll get to reviewing them 
tomorrow ;-)

 
 Since I'm developing the composite gadget for u-boot, it is important
 for me to have the UDC composite driver stabilized in u-boot mainline.

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/3] usb:gadget:composite USB composite gadget support

2012-04-26 Thread Lukasz Majewski
On Thu, 26 Apr 2012 00:53:01 +0200
Marek Vasut ma...@denx.de wrote:

 Dear Lukasz Majewski,
 
  USB Composite gadget implementation for u-boot. It builds on top
  of USB UDC drivers.
  
  This commit is based on following files from Linux Kernel v2.6.36:
  
  ./include/linux/usb/composite.h
  ./drivers/usb/gadget/composite.c
  
  SHA1: d187abb9a83e6c6b6e9f2ca17962bdeafb4bc903
  
  Signed-off-by: Lukasz Majewski l.majew...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  Cc: Marek Vasut ma...@denx.de
  
 
 Quick glance through this looks fine, I'll preempt here and check the
 rest in a few days ... sorry for the delays, I'm overloaded, please
 understand :-(
 

Ok, no problem :-)

I just remind about those patches.

Since I'm developing the composite gadget for u-boot, it is important
for me to have the UDC composite driver stabilized in u-boot mainline.

-- 
Best regards,

Lukasz Majewski

Samsung Poland RD Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/3] usb:gadget:composite USB composite gadget support

2012-04-25 Thread Marek Vasut
Dear Lukasz Majewski,

 USB Composite gadget implementation for u-boot. It builds on top
 of USB UDC drivers.
 
 This commit is based on following files from Linux Kernel v2.6.36:
 
 ./include/linux/usb/composite.h
 ./drivers/usb/gadget/composite.c
 
 SHA1: d187abb9a83e6c6b6e9f2ca17962bdeafb4bc903
 
 Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 Cc: Marek Vasut ma...@denx.de
 

Quick glance through this looks fine, I'll preempt here and check the rest in a 
few days ... sorry for the delays, I'm overloaded, please understand :-(

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/3] usb:gadget:composite USB composite gadget support

2012-04-18 Thread Lukasz Majewski
USB Composite gadget implementation for u-boot. It builds on top
of USB UDC drivers.

This commit is based on following files from Linux Kernel v2.6.36:

./include/linux/usb/composite.h
./drivers/usb/gadget/composite.c

SHA1: d187abb9a83e6c6b6e9f2ca17962bdeafb4bc903

Signed-off-by: Lukasz Majewski l.majew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Marek Vasut ma...@denx.de

---
 drivers/usb/gadget/composite.c  | 1082 +++
 include/linux/usb/composite.h   |  350 +
 include/usb/lin_gadget_compat.h |   24 +-
 3 files changed, 1454 insertions(+), 2 deletions(-)
 create mode 100644 drivers/usb/gadget/composite.c
 create mode 100644 include/linux/usb/composite.h

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
new file mode 100644
index 000..905077d
--- /dev/null
+++ b/drivers/usb/gadget/composite.c
@@ -0,0 +1,1082 @@
+/*
+ * composite.c - infrastructure for Composite USB Gadgets
+ *
+ * Copyright (C) 2006-2008 David Brownell
+ * U-boot porting: Lukasz Majewski l.majew...@samsung.com
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#undef DEBUG
+
+#include linux/bitops.h
+#include linux/usb/composite.h
+
+#define USB_BUFSIZ 4096
+
+static struct usb_composite_driver *composite;
+
+/**
+ * usb_add_function() - add a function to a configuration
+ * @config: the configuration
+ * @function: the function being added
+ * Context: single threaded during gadget setup
+ *
+ * After initialization, each configuration must have one or more
+ * functions added to it.  Adding a function involves calling its @bind()
+ * method to allocate resources such as interface and string identifiers
+ * and endpoints.
+ *
+ * This function returns the value of the function's bind(), which is
+ * zero for success else a negative errno value.
+ */
+int usb_add_function(struct usb_configuration *config,
+   struct usb_function *function)
+{
+   int value = -EINVAL;
+
+   debug(adding '%s'/%p to config '%s'/%p\n,
+   function-name, function,
+   config-label, config);
+
+   if (!function-set_alt || !function-disable)
+   goto done;
+
+   function-config = config;
+   list_add_tail(function-list, config-functions);
+
+   if (function-bind) {
+   value = function-bind(config, function);
+   if (value  0) {
+   list_del(function-list);
+   function-config = NULL;
+   }
+   } else
+   value = 0;
+
+   if (!config-fullspeed  function-descriptors)
+   config-fullspeed = 1;
+   if (!config-highspeed  function-hs_descriptors)
+   config-highspeed = 1;
+
+done:
+   if (value)
+   debug(adding '%s'/%p -- %d\n,
+   function-name, function, value);
+   return value;
+}
+
+/**
+ * usb_function_deactivate - prevent function and gadget enumeration
+ * @function: the function that isn't yet ready to respond
+ *
+ * Blocks response of the gadget driver to host enumeration by
+ * preventing the data line pullup from being activated.  This is
+ * normally called during @bind() processing to change from the
+ * initial ready to respond state, or when a required resource
+ * becomes available.
+ *
+ * For example, drivers that serve as a passthrough to a userspace
+ * daemon can block enumeration unless that daemon (such as an OBEX,
+ * MTP, or print server) is ready to handle host requests.
+ *
+ * Not all systems support software control of their USB peripheral
+ * data pullups.
+ *
+ * Returns zero on success, else negative errno.
+ */
+int usb_function_deactivate(struct usb_function *function)
+{
+   struct usb_composite_dev*cdev = function-config-cdev;
+   int status = 0;
+
+   if (cdev-deactivations == 0)
+   status = usb_gadget_disconnect(cdev-gadget);
+   if (status == 0)
+   cdev-deactivations++;
+
+   return status;
+}
+
+/**
+ * usb_function_activate - allow function and gadget enumeration
+ * @function: function on which usb_function_activate() was called
+ *
+ * Reverses effect of usb_function_deactivate().  If no more