public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core
@ 2010-05-10 16:21 Dinh Nguyen
  2010-05-10 16:21 ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
  2010-05-10 18:43 ` [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Guennadi Liakhovetski
  0 siblings, 2 replies; 6+ messages in thread
From: Dinh Nguyen @ 2010-05-10 16:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux-usb, s.hauer, valentin.longchamp, daniel,
	grant.likely, bryan.wu, amit.kucheria, Jun.Li, xiao-lizhang,
	Dinh Nguyen

renamed fsl_mx3_udc.c -> fsl_mxc_udc.c
for mx51, usb core is clocked from sources that are not 60mhz.

This patch applies to 2.6.34-rc7.

Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
 drivers/usb/gadget/Makefile      |    2 +-
 drivers/usb/gadget/fsl_mx3_udc.c |  104 -------------------------------------
 drivers/usb/gadget/fsl_mxc_udc.c |  106 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 105 deletions(-)
 delete mode 100644 drivers/usb/gadget/fsl_mx3_udc.c
 create mode 100644 drivers/usb/gadget/fsl_mxc_udc.c

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 43b51da..c922eef 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -20,7 +20,7 @@ obj-$(CONFIG_USB_ATMEL_USBA)	+= atmel_usba_udc.o
 obj-$(CONFIG_USB_FSL_USB2)	+= fsl_usb2_udc.o
 fsl_usb2_udc-objs		:= fsl_udc_core.o
 ifeq ($(CONFIG_ARCH_MXC),y)
-fsl_usb2_udc-objs		+= fsl_mx3_udc.o
+fsl_usb2_udc-objs		+= fsl_mxc_udc.o
 endif
 obj-$(CONFIG_USB_M66592)	+= m66592-udc.o
 obj-$(CONFIG_USB_R8A66597)	+= r8a66597-udc.o
diff --git a/drivers/usb/gadget/fsl_mx3_udc.c b/drivers/usb/gadget/fsl_mx3_udc.c
deleted file mode 100644
index 20a802e..0000000
--- a/drivers/usb/gadget/fsl_mx3_udc.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2009
- * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
- *
- * Description:
- * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c
- * driver to function correctly on these systems.
- *
- * 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.
- */
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/err.h>
-#include <linux/fsl_devices.h>
-#include <linux/platform_device.h>
-
-#include <mach/hardware.h>
-
-static struct clk *mxc_ahb_clk;
-static struct clk *mxc_usb_clk;
-
-int fsl_udc_clk_init(struct platform_device *pdev)
-{
-	struct fsl_usb2_platform_data *pdata;
-	unsigned long freq;
-	int ret;
-
-	pdata = pdev->dev.platform_data;
-
-	if (!cpu_is_mx35()) {
-		mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
-		if (IS_ERR(mxc_ahb_clk))
-			return PTR_ERR(mxc_ahb_clk);
-
-		ret = clk_enable(mxc_ahb_clk);
-		if (ret < 0) {
-			dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
-			goto eenahb;
-		}
-	}
-
-	/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
-	mxc_usb_clk = clk_get(&pdev->dev, "usb");
-	if (IS_ERR(mxc_usb_clk)) {
-		dev_err(&pdev->dev, "clk_get(\"usb\") failed\n");
-		ret = PTR_ERR(mxc_usb_clk);
-		goto egusb;
-	}
-
-	freq = clk_get_rate(mxc_usb_clk);
-	if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
-	    (freq < 59999000 || freq > 60001000)) {
-		dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
-		ret = -EINVAL;
-		goto eclkrate;
-	}
-
-	ret = clk_enable(mxc_usb_clk);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
-		goto eenusb;
-	}
-
-	return 0;
-
-eenusb:
-eclkrate:
-	clk_put(mxc_usb_clk);
-	mxc_usb_clk = NULL;
-egusb:
-	if (!cpu_is_mx35())
-		clk_disable(mxc_ahb_clk);
-eenahb:
-	if (!cpu_is_mx35())
-		clk_put(mxc_ahb_clk);
-	return ret;
-}
-
-void fsl_udc_clk_finalize(struct platform_device *pdev)
-{
-	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
-
-	/* ULPI transceivers don't need usbpll */
-	if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
-		clk_disable(mxc_usb_clk);
-		clk_put(mxc_usb_clk);
-		mxc_usb_clk = NULL;
-	}
-}
-
-void fsl_udc_clk_release(void)
-{
-	if (mxc_usb_clk) {
-		clk_disable(mxc_usb_clk);
-		clk_put(mxc_usb_clk);
-	}
-	if (!cpu_is_mx35()) {
-		clk_disable(mxc_ahb_clk);
-		clk_put(mxc_ahb_clk);
-	}
-}
diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
new file mode 100644
index 0000000..d0b8bde
--- /dev/null
+++ b/drivers/usb/gadget/fsl_mxc_udc.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2009
+ * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
+ *
+ * Description:
+ * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c
+ * driver to function correctly on these systems.
+ *
+ * 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.
+ */
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fsl_devices.h>
+#include <linux/platform_device.h>
+
+#include <mach/hardware.h>
+
+static struct clk *mxc_ahb_clk;
+static struct clk *mxc_usb_clk;
+
+int fsl_udc_clk_init(struct platform_device *pdev)
+{
+	struct fsl_usb2_platform_data *pdata;
+	unsigned long freq;
+	int ret;
+
+	pdata = pdev->dev.platform_data;
+
+	if (!cpu_is_mx35()) {
+		mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
+		if (IS_ERR(mxc_ahb_clk))
+			return PTR_ERR(mxc_ahb_clk);
+
+		ret = clk_enable(mxc_ahb_clk);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
+			goto eenahb;
+		}
+	}
+
+	/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
+	mxc_usb_clk = clk_get(&pdev->dev, "usb");
+	if (IS_ERR(mxc_usb_clk)) {
+		dev_err(&pdev->dev, "clk_get(\"usb\") failed\n");
+		ret = PTR_ERR(mxc_usb_clk);
+		goto egusb;
+	}
+
+	if (!cpu_is_mx51()) {
+		freq = clk_get_rate(mxc_usb_clk);
+		if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
+		    (freq < 59999000 || freq > 60001000)) {
+			dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
+			ret = -EINVAL;
+			goto eclkrate;
+		}
+	}
+
+	ret = clk_enable(mxc_usb_clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
+		goto eenusb;
+	}
+
+	return 0;
+
+eenusb:
+eclkrate:
+	clk_put(mxc_usb_clk);
+	mxc_usb_clk = NULL;
+egusb:
+	if (!cpu_is_mx35())
+		clk_disable(mxc_ahb_clk);
+eenahb:
+	if (!cpu_is_mx35())
+		clk_put(mxc_ahb_clk);
+	return ret;
+}
+
+void fsl_udc_clk_finalize(struct platform_device *pdev)
+{
+	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
+
+	/* ULPI transceivers don't need usbpll */
+	if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
+		clk_disable(mxc_usb_clk);
+		clk_put(mxc_usb_clk);
+		mxc_usb_clk = NULL;
+	}
+}
+
+void fsl_udc_clk_release(void)
+{
+	if (mxc_usb_clk) {
+		clk_disable(mxc_usb_clk);
+		clk_put(mxc_usb_clk);
+	}
+	if (!cpu_is_mx35()) {
+		clk_disable(mxc_ahb_clk);
+		clk_put(mxc_ahb_clk);
+	}
+}
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2
  2010-05-10 16:21 [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Dinh Nguyen
@ 2010-05-10 16:21 ` Dinh Nguyen
  2010-05-10 16:21   ` [PATCHv2 2.6.34-rc7 3/3] mx5: enable usb gadget for freescale mx51 babbage board Dinh Nguyen
  2010-05-11 23:32   ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Greg KH
  2010-05-10 18:43 ` [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Guennadi Liakhovetski
  1 sibling, 2 replies; 6+ messages in thread
From: Dinh Nguyen @ 2010-05-10 16:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux-usb, s.hauer, valentin.longchamp, daniel,
	grant.likely, bryan.wu, amit.kucheria, Jun.Li, xiao-lizhang,
	Dinh Nguyen

For power management reasons, pll2 should be used to source the USBOH3
clock for mx51. PLL3 can be completely gated off when USB is not used.

This patch applies to 2.6.34-rc7.

Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
 arch/arm/mach-mx5/clock-mx51.c |   43 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 1fe40e1..b63ba71 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -37,6 +37,7 @@ static struct clk lp_apm_clk;
 static struct clk periph_apm_clk;
 static struct clk ahb_clk;
 static struct clk ipg_clk;
+static struct clk usboh3_clk;
 
 #define MAX_DPLL_WAIT_TRIES	1000 /* 1000 * udelay(1) = 1ms */
 
@@ -570,6 +571,35 @@ static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
 	return 0;
 }
 
+static unsigned long clk_usboh3_get_rate(struct clk *clk)
+{
+	u32 reg, prediv, podf;
+	unsigned long parent_rate;
+
+	parent_rate = clk_get_rate(clk->parent);
+
+	reg = __raw_readl(MXC_CCM_CSCDR1);
+	prediv = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PRED_MASK) >>
+		  MXC_CCM_CSCDR1_USBOH3_CLK_PRED_OFFSET) + 1;
+	podf = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PODF_MASK) >>
+		MXC_CCM_CSCDR1_USBOH3_CLK_PODF_OFFSET) + 1;
+
+	return parent_rate / (prediv * podf);
+}
+
+static int _clk_usboh3_set_parent(struct clk *clk, struct clk *parent)
+{
+	u32 reg, mux;
+
+	mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
+		       &lp_apm_clk);
+	reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_USBOH3_CLK_SEL_MASK;
+	reg |= mux << MXC_CCM_CSCMR1_USBOH3_CLK_SEL_OFFSET;
+	__raw_writel(reg, MXC_CCM_CSCMR1);
+
+	return 0;
+}
+
 static unsigned long get_high_reference_clock_rate(struct clk *clk)
 {
 	return external_high_reference;
@@ -691,6 +721,12 @@ static struct clk uart_root_clk = {
 	.set_parent = _clk_uart_set_parent,
 };
 
+static struct clk usboh3_clk = {
+	.parent = &pll2_sw_clk,
+	.get_rate = clk_usboh3_get_rate,
+	.set_parent = _clk_usboh3_set_parent,
+};
+
 static struct clk ahb_max_clk = {
 	.parent = &ahb_clk,
 	.enable_reg = MXC_CCM_CCGR0,
@@ -762,10 +798,6 @@ DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
 DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
 	NULL,  NULL, &ipg_clk, NULL);
 
-/* USB */
-DEFINE_CLOCK(usboh3_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG14_OFFSET,
-	NULL, NULL, &pll3_sw_clk, NULL);
-
 /* FEC */
 DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
 	NULL,  NULL, &ipg_clk, NULL);
@@ -827,6 +859,9 @@ int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
 	clk_enable(&cpu_clk);
 	clk_enable(&main_bus_clk);
 
+	/* set the usboh3_clk parent to pll2_sw_clk */
+	clk_set_parent(&usboh3_clk, &pll2_sw_clk);
+
 	/* System timer */
 	mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
 		MX51_MXC_INT_GPT);
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCHv2 2.6.34-rc7 3/3] mx5: enable usb gadget for freescale mx51 babbage board
  2010-05-10 16:21 ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
@ 2010-05-10 16:21   ` Dinh Nguyen
  2010-05-11 23:32   ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Dinh Nguyen @ 2010-05-10 16:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux-usb, s.hauer, valentin.longchamp, daniel,
	grant.likely, bryan.wu, amit.kucheria, Jun.Li, xiao-lizhang,
	Dinh Nguyen

This patch enables usb gadget for freescale mx51 babbage hw. By default,
the OTG port will be in device mode. To put the OTG port into Host mode,
pass "otg_mode=host" in the exec command.

This patch applies to 2.6.34-rc7.

Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
 arch/arm/mach-mx5/board-mx51_babbage.c |   28 +++++++++++++++++++++++++++-
 arch/arm/mach-mx5/clock-mx51.c         |    2 ++
 arch/arm/mach-mx5/devices.c            |   12 ++++++++++++
 arch/arm/mach-mx5/devices.h            |    1 +
 4 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 99f7ea9..dacf506 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -15,6 +15,7 @@
 #include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/fsl_devices.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
@@ -179,12 +180,32 @@ static struct mxc_usbh_platform_data dr_utmi_config = {
 	.flags	= MXC_EHCI_INTERNAL_PHY,
 };
 
+static struct fsl_usb2_platform_data usb_pdata = {
+	.operating_mode	= FSL_USB2_DR_DEVICE,
+	.phy_mode	= FSL_USB2_PHY_UTMI_WIDE,
+};
+
 static struct mxc_usbh_platform_data usbh1_config = {
 	.init		= initialize_usbh1_port,
 	.portsc	= MXC_EHCI_MODE_ULPI,
 	.flags	= (MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_ITC_NO_THRESHOLD),
 };
 
+static int otg_mode_host;
+
+static int __init babbage_otg_mode(char *options)
+{
+	if (!strcmp(options, "host"))
+		otg_mode_host = 1;
+	else if (!strcmp(options, "device"))
+		otg_mode_host = 0;
+	else
+		pr_info("otg_mode neither \"host\" nor \"device\". "
+			"Defaulting to device\n");
+	return 0;
+}
+__setup("otg_mode=", babbage_otg_mode);
+
 /*
  * Board specific initialization.
  */
@@ -197,7 +218,12 @@ static void __init mxc_board_init(void)
 	mxc_init_imx_uart();
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 
-	mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
+	if (otg_mode_host)
+		mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
+	else {
+		initialize_otg_port(NULL);
+		mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata);
+	}
 
 	gpio_usbh1_active();
 	mxc_register_device(&mxc_usbh1_device, &usbh1_config);
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index b63ba71..d9f612d 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -819,6 +819,8 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", ahb_clk)
 	_REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk)
 	_REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", ahb_clk)
+	_REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
+	_REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices.c b/arch/arm/mach-mx5/devices.c
index e6262f3..23850e6 100644
--- a/arch/arm/mach-mx5/devices.c
+++ b/arch/arm/mach-mx5/devices.c
@@ -107,6 +107,18 @@ static struct resource usbotg_resources[] = {
 	},
 };
 
+/* OTG gadget device */
+struct platform_device mxc_usbdr_udc_device = {
+	.name		= "fsl-usb2-udc",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(usbotg_resources),
+	.resource	= usbotg_resources,
+	.dev		= {
+		.dma_mask		= &usb_dma_mask,
+		.coherent_dma_mask	= DMA_BIT_MASK(32),
+	},
+};
+
 struct platform_device mxc_usbdr_host_device = {
 	.name = "mxc-ehci",
 	.id = 0,
diff --git a/arch/arm/mach-mx5/devices.h b/arch/arm/mach-mx5/devices.h
index 95c45f9..0494d6b 100644
--- a/arch/arm/mach-mx5/devices.h
+++ b/arch/arm/mach-mx5/devices.h
@@ -4,3 +4,4 @@ extern struct platform_device mxc_uart_device2;
 extern struct platform_device mxc_fec_device;
 extern struct platform_device mxc_usbdr_host_device;
 extern struct platform_device mxc_usbh1_device;
+extern struct platform_device mxc_usbdr_udc_device;
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core
  2010-05-10 16:21 [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Dinh Nguyen
  2010-05-10 16:21 ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
@ 2010-05-10 18:43 ` Guennadi Liakhovetski
  1 sibling, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2010-05-10 18:43 UTC (permalink / raw)
  To: Dinh Nguyen
  Cc: linux-kernel, amit.kucheria, s.hauer, linux-usb, Jun.Li,
	grant.likely, linux-arm-kernel, daniel, bryan.wu, xiao-lizhang,
	valentin.longchamp

On Mon, 10 May 2010, Dinh Nguyen wrote:

> renamed fsl_mx3_udc.c -> fsl_mxc_udc.c
> for mx51, usb core is clocked from sources that are not 60mhz.
> 
> This patch applies to 2.6.34-rc7.

For such patches it helps to use the "-M -C" options to "git format 
patch," which would then make reviewing your changes easier...

Thanks
Guennadi

> 
> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> ---
>  drivers/usb/gadget/Makefile      |    2 +-
>  drivers/usb/gadget/fsl_mx3_udc.c |  104 -------------------------------------
>  drivers/usb/gadget/fsl_mxc_udc.c |  106 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 107 insertions(+), 105 deletions(-)
>  delete mode 100644 drivers/usb/gadget/fsl_mx3_udc.c
>  create mode 100644 drivers/usb/gadget/fsl_mxc_udc.c
> 
> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> index 43b51da..c922eef 100644
> --- a/drivers/usb/gadget/Makefile
> +++ b/drivers/usb/gadget/Makefile
> @@ -20,7 +20,7 @@ obj-$(CONFIG_USB_ATMEL_USBA)	+= atmel_usba_udc.o
>  obj-$(CONFIG_USB_FSL_USB2)	+= fsl_usb2_udc.o
>  fsl_usb2_udc-objs		:= fsl_udc_core.o
>  ifeq ($(CONFIG_ARCH_MXC),y)
> -fsl_usb2_udc-objs		+= fsl_mx3_udc.o
> +fsl_usb2_udc-objs		+= fsl_mxc_udc.o
>  endif
>  obj-$(CONFIG_USB_M66592)	+= m66592-udc.o
>  obj-$(CONFIG_USB_R8A66597)	+= r8a66597-udc.o
> diff --git a/drivers/usb/gadget/fsl_mx3_udc.c b/drivers/usb/gadget/fsl_mx3_udc.c
> deleted file mode 100644
> index 20a802e..0000000
> --- a/drivers/usb/gadget/fsl_mx3_udc.c
> +++ /dev/null
> @@ -1,104 +0,0 @@
> -/*
> - * Copyright (C) 2009
> - * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
> - *
> - * Description:
> - * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c
> - * driver to function correctly on these systems.
> - *
> - * 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.
> - */
> -#include <linux/clk.h>
> -#include <linux/delay.h>
> -#include <linux/err.h>
> -#include <linux/fsl_devices.h>
> -#include <linux/platform_device.h>
> -
> -#include <mach/hardware.h>
> -
> -static struct clk *mxc_ahb_clk;
> -static struct clk *mxc_usb_clk;
> -
> -int fsl_udc_clk_init(struct platform_device *pdev)
> -{
> -	struct fsl_usb2_platform_data *pdata;
> -	unsigned long freq;
> -	int ret;
> -
> -	pdata = pdev->dev.platform_data;
> -
> -	if (!cpu_is_mx35()) {
> -		mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
> -		if (IS_ERR(mxc_ahb_clk))
> -			return PTR_ERR(mxc_ahb_clk);
> -
> -		ret = clk_enable(mxc_ahb_clk);
> -		if (ret < 0) {
> -			dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
> -			goto eenahb;
> -		}
> -	}
> -
> -	/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
> -	mxc_usb_clk = clk_get(&pdev->dev, "usb");
> -	if (IS_ERR(mxc_usb_clk)) {
> -		dev_err(&pdev->dev, "clk_get(\"usb\") failed\n");
> -		ret = PTR_ERR(mxc_usb_clk);
> -		goto egusb;
> -	}
> -
> -	freq = clk_get_rate(mxc_usb_clk);
> -	if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
> -	    (freq < 59999000 || freq > 60001000)) {
> -		dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
> -		ret = -EINVAL;
> -		goto eclkrate;
> -	}
> -
> -	ret = clk_enable(mxc_usb_clk);
> -	if (ret < 0) {
> -		dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
> -		goto eenusb;
> -	}
> -
> -	return 0;
> -
> -eenusb:
> -eclkrate:
> -	clk_put(mxc_usb_clk);
> -	mxc_usb_clk = NULL;
> -egusb:
> -	if (!cpu_is_mx35())
> -		clk_disable(mxc_ahb_clk);
> -eenahb:
> -	if (!cpu_is_mx35())
> -		clk_put(mxc_ahb_clk);
> -	return ret;
> -}
> -
> -void fsl_udc_clk_finalize(struct platform_device *pdev)
> -{
> -	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
> -
> -	/* ULPI transceivers don't need usbpll */
> -	if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
> -		clk_disable(mxc_usb_clk);
> -		clk_put(mxc_usb_clk);
> -		mxc_usb_clk = NULL;
> -	}
> -}
> -
> -void fsl_udc_clk_release(void)
> -{
> -	if (mxc_usb_clk) {
> -		clk_disable(mxc_usb_clk);
> -		clk_put(mxc_usb_clk);
> -	}
> -	if (!cpu_is_mx35()) {
> -		clk_disable(mxc_ahb_clk);
> -		clk_put(mxc_ahb_clk);
> -	}
> -}
> diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
> new file mode 100644
> index 0000000..d0b8bde
> --- /dev/null
> +++ b/drivers/usb/gadget/fsl_mxc_udc.c
> @@ -0,0 +1,106 @@
> +/*
> + * Copyright (C) 2009
> + * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
> + *
> + * Description:
> + * Helper routines for i.MX3x SoCs from Freescale, needed by the fsl_usb2_udc.c
> + * driver to function correctly on these systems.
> + *
> + * 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.
> + */
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/fsl_devices.h>
> +#include <linux/platform_device.h>
> +
> +#include <mach/hardware.h>
> +
> +static struct clk *mxc_ahb_clk;
> +static struct clk *mxc_usb_clk;
> +
> +int fsl_udc_clk_init(struct platform_device *pdev)
> +{
> +	struct fsl_usb2_platform_data *pdata;
> +	unsigned long freq;
> +	int ret;
> +
> +	pdata = pdev->dev.platform_data;
> +
> +	if (!cpu_is_mx35()) {
> +		mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
> +		if (IS_ERR(mxc_ahb_clk))
> +			return PTR_ERR(mxc_ahb_clk);
> +
> +		ret = clk_enable(mxc_ahb_clk);
> +		if (ret < 0) {
> +			dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
> +			goto eenahb;
> +		}
> +	}
> +
> +	/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
> +	mxc_usb_clk = clk_get(&pdev->dev, "usb");
> +	if (IS_ERR(mxc_usb_clk)) {
> +		dev_err(&pdev->dev, "clk_get(\"usb\") failed\n");
> +		ret = PTR_ERR(mxc_usb_clk);
> +		goto egusb;
> +	}
> +
> +	if (!cpu_is_mx51()) {
> +		freq = clk_get_rate(mxc_usb_clk);
> +		if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
> +		    (freq < 59999000 || freq > 60001000)) {
> +			dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
> +			ret = -EINVAL;
> +			goto eclkrate;
> +		}
> +	}
> +
> +	ret = clk_enable(mxc_usb_clk);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
> +		goto eenusb;
> +	}
> +
> +	return 0;
> +
> +eenusb:
> +eclkrate:
> +	clk_put(mxc_usb_clk);
> +	mxc_usb_clk = NULL;
> +egusb:
> +	if (!cpu_is_mx35())
> +		clk_disable(mxc_ahb_clk);
> +eenahb:
> +	if (!cpu_is_mx35())
> +		clk_put(mxc_ahb_clk);
> +	return ret;
> +}
> +
> +void fsl_udc_clk_finalize(struct platform_device *pdev)
> +{
> +	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
> +
> +	/* ULPI transceivers don't need usbpll */
> +	if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
> +		clk_disable(mxc_usb_clk);
> +		clk_put(mxc_usb_clk);
> +		mxc_usb_clk = NULL;
> +	}
> +}
> +
> +void fsl_udc_clk_release(void)
> +{
> +	if (mxc_usb_clk) {
> +		clk_disable(mxc_usb_clk);
> +		clk_put(mxc_usb_clk);
> +	}
> +	if (!cpu_is_mx35()) {
> +		clk_disable(mxc_ahb_clk);
> +		clk_put(mxc_ahb_clk);
> +	}
> +}
> -- 
> 1.6.0.4
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2
  2010-05-10 16:21 ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
  2010-05-10 16:21   ` [PATCHv2 2.6.34-rc7 3/3] mx5: enable usb gadget for freescale mx51 babbage board Dinh Nguyen
@ 2010-05-11 23:32   ` Greg KH
  2010-05-12  3:44     ` Nguyen Dinh-R00091
  1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2010-05-11 23:32 UTC (permalink / raw)
  To: Dinh Nguyen
  Cc: linux-kernel, linux-arm-kernel, linux-usb, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu, amit.kucheria,
	Jun.Li, xiao-lizhang

On Mon, May 10, 2010 at 11:21:58AM -0500, Dinh Nguyen wrote:
> For power management reasons, pll2 should be used to source the USBOH3
> clock for mx51. PLL3 can be completely gated off when USB is not used.
> 
> This patch applies to 2.6.34-rc7.

Hm, no, it seems to conflict and does not apply :(

I've taken the first one, shouldn't the two others go through some arm
tree?


thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2
  2010-05-11 23:32   ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Greg KH
@ 2010-05-12  3:44     ` Nguyen Dinh-R00091
  0 siblings, 0 replies; 6+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-05-12  3:44 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-arm-kernel, linux-usb, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu, amit.kucheria,
	Li Jun-R65092, Zhang Lily-R58066

On Mon, May 10, 2010 at 11:21:58AM -0500, Dinh Nguyen wrote:
> For power management reasons, pll2 should be used to source the USBOH3

> clock for mx51. PLL3 can be completely gated off when USB is not used.
> 
> This patch applies to 2.6.34-rc7.

On Tuesday, May 11, 2010 6:32 PM , Greg KH wroe:
> Hm, no, it seems to conflict and does not apply :(

>I've taken the first one, shouldn't the two others go through some arm
tree?

It looks like Sascha has taken the patch 2/3 and 3/3. Thanks, Dinh


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-12  3:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-10 16:21 [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Dinh Nguyen
2010-05-10 16:21 ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
2010-05-10 16:21   ` [PATCHv2 2.6.34-rc7 3/3] mx5: enable usb gadget for freescale mx51 babbage board Dinh Nguyen
2010-05-11 23:32   ` [PATCHv2 2.6.34-rc7 2/3] mx5: change usb clock source from pll3 to pll2 Greg KH
2010-05-12  3:44     ` Nguyen Dinh-R00091
2010-05-10 18:43 ` [PATCHv2 2.6.34-rc7 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Guennadi Liakhovetski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox