All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] msm: qsd8x50: Add support for USB peripheral
@ 2010-09-02  8:29 Pavankumar Kondeti
  0 siblings, 0 replies; only message in thread
From: Pavankumar Kondeti @ 2010-09-02  8:29 UTC (permalink / raw)
  To: dwalker; +Cc: linux-arm-msm, Pavankumar Kondeti

Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
---
 arch/arm/mach-msm/board-qsd8x50.c      |   59 ++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/devices-qsd8x50.c    |   23 ++++++++++++
 arch/arm/mach-msm/include/mach/board.h |    5 +++
 3 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c
index e3cc807..976cb7c 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -20,6 +20,9 @@
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+#include <linux/usb/msm_hsusb.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -35,6 +38,60 @@
 
 extern struct sys_timer msm_timer;
 
+static int hsusb_phy_init_seq[] = {
+	0x08, 0x31,	/* Increase HS Driver Amplitude */
+	0x20, 0x32,	/* Enable and set Pre-Emphasis Depth to 10% */
+	-1 };
+
+static void hsusb_phy_reset(void)
+{
+	struct clk *phy_reset_clk;
+	int ret;
+
+	phy_reset_clk = clk_get(NULL, "usb_phy_clk");
+	if (IS_ERR(phy_reset_clk)) {
+		pr_err("%s: failed to get usb_phy_clk\n", __func__);
+		return;
+	}
+
+	ret = clk_reset(phy_reset_clk, CLK_RESET_ASSERT);
+	if (ret) {
+		pr_err("%s: phy clk assert failed\n", __func__);
+		clk_put(phy_reset_clk);
+		return;
+	}
+	usleep_range(1000, 1200);
+	ret = clk_reset(phy_reset_clk, CLK_RESET_DEASSERT);
+	if (ret)
+		pr_err("%s: phy clk deassert failed\n", __func__);
+	clk_put(phy_reset_clk);
+}
+
+static void hsusb_hw_reset(bool enable)
+{
+	struct clk *hs_clk;
+	int ret;
+
+	hs_clk = clk_get(NULL, "usb_hs_clk");
+	if (IS_ERR(hs_clk)) {
+		pr_err("%s: failed to get usb_hs_clk\n", __func__);
+		return;
+	}
+	ret = clk_reset(hs_clk, enable ? CLK_RESET_ASSERT : CLK_RESET_DEASSERT);
+	if (ret)
+		pr_err("%s: usb hs_clk %s failed\n", __func__,
+				enable ? "assert" : "deassert");
+
+	clk_put(hs_clk);
+}
+
+
+static struct msm_hsusb_platform_data msm_hsusb_pdata = {
+	.phy_init_seq		= hsusb_phy_init_seq,
+	.phy_reset		= hsusb_phy_reset,
+	.hw_reset		= hsusb_hw_reset,
+};
+
 static struct msm_gpio uart3_config_data[] = {
 	{ GPIO_CFG(86, 1, GPIO_INPUT,   GPIO_PULL_DOWN, GPIO_2MA), "UART2_Rx"},
 	{ GPIO_CFG(87, 1, GPIO_OUTPUT,  GPIO_PULL_DOWN, GPIO_2MA), "UART2_Tx"},
@@ -42,6 +99,7 @@ static struct msm_gpio uart3_config_data[] = {
 
 static struct platform_device *devices[] __initdata = {
 	&msm_device_uart3,
+	&msm_device_hsusb,
 };
 
 static void msm8x50_init_uart3(void)
@@ -65,6 +123,7 @@ static void __init qsd8x50_init_irq(void)
 static void __init qsd8x50_init(void)
 {
 	msm8x50_init_uart3();
+	msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata;
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
diff --git a/arch/arm/mach-msm/devices-qsd8x50.c b/arch/arm/mach-msm/devices-qsd8x50.c
index 4d4a507..74240e9 100644
--- a/arch/arm/mach-msm/devices-qsd8x50.c
+++ b/arch/arm/mach-msm/devices-qsd8x50.c
@@ -28,6 +28,29 @@
 
 #include <mach/mmc.h>
 
+static struct resource resources_hsusb[] = {
+	{
+		.start	= MSM_HSUSB_PHYS,
+		.end	= MSM_HSUSB_PHYS + MSM_HSUSB_SIZE,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= INT_USB_HS,
+		.end	= INT_USB_HS,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device msm_device_hsusb = {
+	.name		= "msm_hsusb",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(resources_hsusb),
+	.resource	= resources_hsusb,
+	.dev		= {
+		.coherent_dma_mask	= 0xffffffff,
+	},
+};
+
 static struct resource resources_uart3[] = {
 	{
 		.start	= INT_UART3,
diff --git a/arch/arm/mach-msm/include/mach/board.h b/arch/arm/mach-msm/include/mach/board.h
index 5a79bcf..6b69eda 100644
--- a/arch/arm/mach-msm/include/mach/board.h
+++ b/arch/arm/mach-msm/include/mach/board.h
@@ -44,5 +44,10 @@ void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *);
 int __init msm_add_sdcc(unsigned int controller,
 			struct msm_mmc_platform_data *plat,
 			unsigned int stat_irq, unsigned long stat_irq_flags);
+#ifdef CONFIG_USB_MSM_72K
+void msm_hsusb_set_vbus_state(int online);
+#else
+static inline void msm_hsusb_set_vbus_state(int online) {}
+#endif
 
 #endif
-- 
1.7.1

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-09-02  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02  8:29 [PATCH] msm: qsd8x50: Add support for USB peripheral Pavankumar Kondeti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.