From 9134219dda3772ff2a924eb3f78692e5b371b95f Mon Sep 17 00:00:00 2001 From: make shi Date: Fri, 4 Nov 2011 17:18:07 +0800 Subject: ENGR00161383 [MX6Q] USB OTG: enable OTG driver Enable OTG driver on mx6q board Signed-off-by: make shi --- arch/arm/configs/imx6_defconfig | 38 ++++++++++++++++++++++++++++++++++++-- arch/arm/mach-mx6/usb_dr.c | 25 ++++++++++++++++++++----- arch/arm/mach-mx6/usb_h1.c | 6 ++++-- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/arch/arm/configs/imx6_defconfig b/arch/arm/configs/imx6_defconfig index 60870a598b9..952311def96 100644 --- a/arch/arm/configs/imx6_defconfig +++ b/arch/arm/configs/imx6_defconfig @@ -1593,7 +1593,7 @@ CONFIG_USB=y # CONFIG_USB_DEVICE_CLASS is not set # CONFIG_USB_DYNAMIC_MINORS is not set CONFIG_USB_SUSPEND=y -# CONFIG_USB_OTG is not set +CONFIG_USB_OTG=y # CONFIG_USB_OTG_WHITELIST is not set # CONFIG_USB_OTG_BLACKLIST_HUB is not set # CONFIG_USB_MON is not set @@ -1686,7 +1686,40 @@ CONFIG_USB_STORAGE=y # CONFIG_USB_TEST is not set # CONFIG_USB_ISIGHTFW is not set # CONFIG_USB_YUREX is not set -# CONFIG_USB_GADGET is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +# CONFIG_USB_GADGET_DEBUG_FS is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +CONFIG_USB_GADGET_ARC=y +# CONFIG_USB_STATIC_IRAM_PPH is not set +CONFIG_USB_ARC=y +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_R8A66597 is not set +# CONFIG_USB_GADGET_PXA_U2O is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +# CONFIG_USB_ZERO is not set +# CONFIG_USB_AUDIO is not set +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +# CONFIG_USB_ETH_EEM is not set +# CONFIG_USB_G_NCM is not set +# CONFIG_USB_GADGETFS is not set +# CONFIG_USB_FUNCTIONFS is not set +CONFIG_USB_FILE_STORAGE=m +# CONFIG_FSL_UTP is not set +# CONFIG_USB_FILE_STORAGE_TEST is not set +# CONFIG_USB_MASS_STORAGE is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +# CONFIG_USB_CDC_COMPOSITE is not set +# CONFIG_USB_G_MULTI is not set +# CONFIG_USB_G_HID is not set +# CONFIG_USB_G_DBGP is not set +# CONFIG_USB_G_WEBCAM is not set # # OTG and related infrastructure @@ -1695,6 +1728,7 @@ CONFIG_USB_OTG_UTILS=y # CONFIG_USB_GPIO_VBUS is not set # CONFIG_USB_ULPI is not set # CONFIG_NOP_USB_XCEIV is not set +CONFIG_MXC_OTG=y CONFIG_MMC=y # CONFIG_MMC_DEBUG is not set CONFIG_MMC_UNSAFE_RESUME=y diff --git a/arch/arm/mach-mx6/usb_dr.c b/arch/arm/mach-mx6/usb_dr.c index d9b16a1c1a2..f498d6e94cc 100644 --- a/arch/arm/mach-mx6/usb_dr.c +++ b/arch/arm/mach-mx6/usb_dr.c @@ -28,6 +28,8 @@ #include "devices-imx6q.h" #include "regs-anadig.h" #include "usb.h" + + static int usbotg_init_ext(struct platform_device *pdev); static void usbotg_uninit_ext(struct platform_device *pdev); static void usbotg_clock_gate(bool on); @@ -38,6 +40,8 @@ static void usbotg_clock_gate(bool on); */ static struct clk *usb_phy1_clk; static struct clk *usb_oh3_clk; +static u8 otg_used; + static void usbotg_wakeup_event_clear(void); extern int clk_get_usecount(struct clk *clk); @@ -112,7 +116,6 @@ static int usb_phy_enable(struct fsl_usb2_platform_data *pdata) , phy_reg + HW_USBPHY_CTRL_SET); } - return 0; } /* Notes: configure USB clock*/ @@ -135,8 +138,16 @@ static int usbotg_init_ext(struct platform_device *pdev) printk(KERN_ERR "otg init fails......\n"); return ret; } - usbotg_internal_phy_clock_gate(true); - usb_phy_enable(pdev->dev.platform_data); + if (!otg_used) { + usbotg_internal_phy_clock_gate(true); + usb_phy_enable(pdev->dev.platform_data); + otg_used++; + /*after the phy reset,can not read the readingvalue for id/vbus at + * the register of otgsc ,cannot read at once ,need delay 3 ms + */ + mdelay(3); + } + return ret; } @@ -151,6 +162,7 @@ static void usbotg_uninit_ext(struct platform_device *pdev) clk_put(usb_oh3_clk); usbotg_uninit(pdata); + otg_used--; } static void usbotg_clock_gate(bool on) @@ -413,7 +425,7 @@ static void device_wakeup_handler(struct fsl_usb2_platform_data *pdata) void __init mx6_usb_dr_init(void) { - struct platform_device *pdev; + struct platform_device *pdev, *pdev_wakeup; static void __iomem *anatop_base_addr = MX6_IO_ADDRESS(ANATOP_BASE_ADDR); #ifdef CONFIG_USB_OTG /* wake_up_enable is useless, just for usb_register_remote_wakeup execution*/ @@ -444,7 +456,10 @@ void __init mx6_usb_dr_init(void) dr_wakeup_config.usb_pdata[2] = pdev->dev.platform_data; #endif /* register wakeup device */ - imx6q_add_fsl_usb2_otg_wakeup(&dr_wakeup_config); + pdev_wakeup = imx6q_add_fsl_usb2_otg_wakeup(&dr_wakeup_config); + ((struct fsl_usb2_platform_data *)(pdev->dev.platform_data))->wakeup_pdata = + (struct fsl_usb2_wakeup_platform_data *)(pdev_wakeup->dev.platform_data); + /* Some phy and power's special controls for otg * 1. The external charger detector needs to be disabled * or the signal at DP will be poor diff --git a/arch/arm/mach-mx6/usb_h1.c b/arch/arm/mach-mx6/usb_h1.c index f33f7365664..9c247d56875 100644 --- a/arch/arm/mach-mx6/usb_h1.c +++ b/arch/arm/mach-mx6/usb_h1.c @@ -239,12 +239,14 @@ static struct fsl_usb2_wakeup_platform_data usbh1_wakeup_config = { void __init mx6_usb_h1_init(void) { - struct platform_device *pdev; + struct platform_device *pdev, *pdev_wakeup; static void __iomem *anatop_base_addr = MX6_IO_ADDRESS(ANATOP_BASE_ADDR); usbh1_config.wakeup_pdata = &usbh1_wakeup_config; pdev = imx6q_add_fsl_ehci_hs(1, &usbh1_config); usbh1_wakeup_config.usb_pdata[0] = pdev->dev.platform_data; - imx6q_add_fsl_usb2_hs_wakeup(1, &usbh1_wakeup_config); + pdev_wakeup = imx6q_add_fsl_usb2_hs_wakeup(1, &usbh1_wakeup_config); + ((struct fsl_usb2_platform_data *)(pdev->dev.platform_data))->wakeup_pdata = + (struct fsl_usb2_wakeup_platform_data *)(pdev_wakeup->dev.platform_data); /* Some phy and power's special controls for host1 * 1. The external charger detector needs to be disabled * or the signal at DP will be poor -- cgit v1.2.3