Skip to contentSkip to conversation

Adding usb gadget support

PATCH In review David Lanzendörfer 4 participants 7 messages Jul 15, 2010 – Jul 16, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Adding usb gadget support

Hi
I wanna propose the introduction of usb gadget for msm72k into
https://www.codeaurora.org/gitweb/quic/kernel/?p=dwalker/linux-msm.git;a=tree;h=refs/heads/for-next;hb=for-next
sadly the following patch seems to have some flaws.
I finds the internal chip and creates a iface usb0, but doesnt get up and online. I do not get an usb0 popping up on hostside either.
Someone an idea how to fix this code?

best regards
leviathan

---
 arch/arm/mach-msm/include/mach/msm_hsusb.h    |   74 ++
 arch/arm/mach-msm/include/mach/msm_hsusb_hw.h |  204 +++
 drivers/usb/gadget/Kconfig                    |   17 +
 drivers/usb/gadget/Makefile                   |    1 +
 drivers/usb/gadget/msm72k_udc.c               | 1738 +++++++++++++++++++++++++
 5 files changed, 2034 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-msm/include/mach/msm_hsusb.h
 create mode 100644 arch/arm/mach-msm/include/mach/msm_hsusb_hw.h
 create mode 100644 drivers/usb/gadget/msm72k_udc.c
arch/arm/mach-msm/include/mach/msm_hsusb.h new file +74 -0
new file mode 100644
index 0000000..2d49b0f
@@ -0,0 +1,74 @@
+/* linux/include/asm-arm/arch-msm/hsusb.h
+ *
+ * Copyright (C) 2008 Google, Inc.
+ * Author: Brian Swetland <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#ifndef __ASM_ARCH_MSM_HSUSB_H
+#define __ASM_ARCH_MSM_HSUSB_H
+
+#include <linux/types.h>
+
+/* platform device data for msm_hsusb driver */
+
+#ifdef CONFIG_USB_FUNCTION
+/* matches a product ID to a list of enabled functions */
+struct msm_hsusb_product {
+	/* product ID for usb_device_descriptor.idProduct */
+	__u16 product_id;
+
+	/* bit mask of enabled usb_functions, matching ordering
+	** in msm_hsusb_platform_data.functions
+	*/
+	__u32 functions;
+};
+#endif
+
+struct msm_hsusb_platform_data {
+	/* hard reset the ULPI PHY */
+	void (*phy_reset)(void);
+
+	/* for notification when USB is connected or disconnected */
+	void (*usb_connected)(int);
+
+	/* val, reg pairs terminated by -1 */
+	int *phy_init_seq;
+
+#ifdef CONFIG_USB_FUNCTION
+	/* USB device descriptor fields */
+	__u16 vendor_id;
+
+	/* Default product ID.
+	** This can be overridden dynamically based on the disabled
+	** state of the functions using the product_table.
+	*/
+	__u16 product_id;
+
+	__u16 version;
+	char *serial_number;
+	char *product_name;
+	char *manufacturer_name;
+
+	/* list of function drivers to bind to this configuration */
+	int num_functions;
+	char **functions;
+
+	/* if num_products is zero, then the default value in product_id
+	** is used for the configuration descriptor.
+	*/
+	int num_products;
+	struct msm_hsusb_product *products;
+#endif
+};
+
+#endif
arch/arm/mach-msm/include/mach/msm_hsusb_hw.h new file +204 -0

204 lines not on this page · raw message

drivers/usb/gadget/Kconfig +17 -0
index 591ae9f..18d28c2 100644
@@ -509,6 +509,23 @@ config USB_LANGWELL
 #
 # LAST -- dummy/emulated controller
 #
+config USB_GADGET_MSM_72K
+	boolean "MSM 72K Device Controller"
+	depends on ARCH_MSM
+	select USB_GADGET_SELECTED
+	select USB_GADGET_DUALSPEED
+	help
+	  USB gadget driver for Qualcomm MSM 72K architecture.
+
+	  Say "y" to link the driver statically, or "m" to build a
+	  dynamically linked module called "msm72k" and force all
+	  gadget drivers to also be dynamically linked.
+
+config USB_MSM_72K
+	tristate
+	depends on USB_GADGET_MSM_72K
+	default USB_GADGET
+	select USB_GADGET_SELECTED
 
 config USB_GADGET_DUMMY_HCD
 	boolean "Dummy HCD (DEVELOPMENT)"
drivers/usb/gadget/Makefile +1 -0
index 9bcde11..48ea27a 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_USB_FSL_QE)	+= fsl_qe_udc.o
 obj-$(CONFIG_USB_CI13XXX)	+= ci13xxx_udc.o
 obj-$(CONFIG_USB_S3C_HSOTG)	+= s3c-hsotg.o
 obj-$(CONFIG_USB_LANGWELL)	+= langwell_udc.o
+obj-$(CONFIG_USB_MSM_72K)       += msm72k_udc.o
 
 #
 # USB gadget drivers
drivers/usb/gadget/msm72k_udc.c new file +1738 -0

1,738 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#1 lore raw
Quoted 6 lines · David Lanzendörfer

I wanna propose the introduction of usb gadget for msm72k into
https://www.codeaurora.org/gitweb/quic/kernel/?p=dwalker/linux-msm.git;a=tree;h=refs/heads/for-next;hb=for-next
sadly the following patch seems to have some flaws.
I finds the internal chip and creates a iface usb0, but doesnt get up and online. I do not get an usb0 popping up on hostside either.
Someone an idea how to fix this code?

Be weary of the phy_reset() code which must be implemented correctly and passed in as platform_data. This code can be board dependent. Failure to implement this correctly will result in the interface not coming online.

Michael

Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
#2 lore raw
Quoted 1 line

Be weary of the phy_reset() code which must be implemented correctly and passed in as platform_data.

Ok. That might be the problem.

Quoted 1 line

This code can be board dependent. Failure to implement this correctly will result in the interface not coming online.

Ok. I'll check.

thx and best regards
leviathan

#3 lore raw
Quoted 5 lines
Quoted 1 line

Be weary of the phy_reset() code which must be implemented correctly and passed in as platform_data.

Ok. That might be the problem.

Quoted 1 line

This code can be board dependent. Failure to implement this correctly will result in the interface not coming online.

Ok. I'll check.

I was informed in #htc-linux that there is already a call PCOM_MSM_HSUSB_PHY_RESET provided by proc_comm. But I do not have the lisest idea how to use that.

Someone inspiration?

best regards
leviathan

#4 lore raw
Quoted 2 lines · David Lanzendörfer

I was informed in #htc-linux that there is already a call PCOM_MSM_HSUSB_PHY_RESET provided by proc_comm. But I do not have the lisest idea how to use that.

I suggest looking at this tree which has USB support on multiple boards already:

https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git;a=shortlog;h=refs/heads/aosp/android-msm-2.6.32

That should make it more clear how to properly perform the reset for your particular board. It may not necessarily be PCOM_MSM_HSUSB_PHY_RESET. In fact, I don't think that command is actually used for any current boards.

Michael

Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
#5 lore raw
In reply to David Lanzendörfer
Quoted 6 lines · David Lanzendörfer
Quoted 5 lines
Quoted 1 line

Be weary of the phy_reset() code which must be implemented correctly and passed in as platform_data.

Ok. That might be the problem.

Quoted 1 line

This code can be board dependent. Failure to implement this correctly will result in the interface not coming online.

Ok. I'll check.

Quoted 8 lines

I was informed in #htc-linux that there is already a call PCOM_MSM_HSUSB_PHY_RESET provided by proc_comm. But I do not have the lisest idea how to use that.

Someone inspiration?

best regards
       leviathan

that's still device specific, it might work on our devices but certainly doesn't belong upstream (in for-next). maybe QuIC should look into implementing a proper PHY like Swetland's comment said early on, instead of the callback approach.

--
Timothy Meade
tmzt #htc-linux

#6 lore raw
In reply to David Lanzendörfer
Quoted 9 lines · ----- "David Lanzendörfer

Hi
I wanna propose the introduction of usb gadget for msm72k into
https://www.codeaurora.org/gitweb/quic/kernel/?p=dwalker/linux-msm.git;a=tree;h=refs/heads/for-next;hb=for-next
sadly the following patch seems to have some flaws.
I finds the internal chip and creates a iface usb0, but doesnt get up and online.
I do not get an usb0 popping up on hostside either. Someone an idea how to fix this code?

What do you mean by iface usb0? Are you referring to usb0 network interface showing up in ifconfig?

Thanks,
Pavan

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.