Skip to contentSkip to conversation

Updates for S3C HSOTG driver

PATCH New Kukjin Kim 3 participants 10 messages May 28, 2010 – May 31, 2010

Subsystems (4)
lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

PATCH 1/1 Updates for S3C HSOTG driver

This patch series adds the following updates for S3C HSTOG driver.
1. Adds HCLK clock for S3C HSOTG module.
2. Adds clk_xusbxti clock to the list of clocks to be registred in S5P.
3. Sets the clk_xusbsti clock rate on S5PV210 to 24Mhz.
4. Updates the s3c hsotg driver to use the HCLK OTG clock.

[PATCH 1/4] ARM: S3C64XX: Add USB OTG HCLK to the list of clocks [PATCH 2/4] ARM: S5PV210: Assign clock rate for clk_xusbxti clock. [PATCH 3/4] ARM: S5P: Add clk_xusbxti clock to the list of clocks to be registered. [PATCH 4/4] usb: s3c-hsotg: Enable HCLK for the OTG module.

author
#1 lore raw

PATCH 1/4 ARM: S3C64XX: Add USB OTG HCLK to the list of clocks

From: Thomas Abraham <[email protected]>

Add the USB OTG HCLK clock to the list of clocks to be registered during initialization.

---
 arch/arm/mach-s3c64xx/clock.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/mach-s3c64xx/clock.c +6 -0
index 7a4138b..fbd85a9 100644
@@ -259,6 +259,12 @@ static struct clk init_clocks[] = {
 		.enable		= s3c64xx_hclk_ctrl,
 		.ctrlbit	= S3C_CLKCON_HCLK_HSMMC2,
 	}, {
+		.name		= "otg",
+		.id		= -1,
+		.parent		= &clk_h,
+		.enable		= s3c64xx_hclk_ctrl,
+		.ctrlbit	= S3C_CLKCON_HCLK_USB,
+	}, {
 		.name		= "timers",
 		.id		= -1,
 		.parent		= &clk_p,
Signature · 1 line
1.6.3.3
author
#2 lore raw

PATCH 2/4 ARM: S5PV210: Assign clock rate for clk_xusbxti clock.

In reply to Kukjin Kim

From: Thomas Abraham <[email protected]>

The input clock frequency for USB Phy is 24 Mhz on the S5PV210 platform. This patch initializes the clk_xusbxti clock rate to 24Mhz.

---
 arch/arm/mach-s5pv210/clock.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/clock.c +2 -0
index 154bca4..4ef09d4 100644
@@ -954,6 +954,8 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
 
 	printk(KERN_DEBUG "%s: registering clocks\n", __func__);
 
+	clk_xusbxti.rate = 24 * MHZ;
+
 	clkdiv0 = __raw_readl(S5P_CLK_DIV0);
 	clkdiv1 = __raw_readl(S5P_CLK_DIV1);
 
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 2/4 ARM: S5PV210: Assign clock rate for clk_xusbxti clock.

Quoted 4 lines · Kukjin Kim

From: Thomas Abraham <[email protected]>

The input clock frequency for USB Phy is 24 Mhz on the S5PV210 platform. This patch initializes the clk_xusbxti clock rate to 24Mhz.

is this all s5pv210/s5pc110 machines, or are there any current/likely machines with non 24M clocks?

Quoted 22 lines
---
 arch/arm/mach-s5pv210/clock.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/clock.c +2 -0
index 154bca4..4ef09d4 100644
@@ -954,6 +954,8 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
 
 	printk(KERN_DEBUG "%s: registering clocks\n", __func__);
 
+	clk_xusbxti.rate = 24 * MHZ;
+
 	clkdiv0 = __raw_readl(S5P_CLK_DIV0);
 	clkdiv1 = __raw_readl(S5P_CLK_DIV1);
 
Signature · 1 line
1.6.3.3
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
author
#4 lore raw

PATCH 3/4 ARM: S5P: Add clk_xusbxti clock to the list of clocks to be registered.

In reply to Kukjin Kim

From: Thomas Abraham <[email protected]>

The clk_xusbxti clock is added to the list of clocks to be registred during boot time clock registration.

---
 arch/arm/plat-s5p/clock.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/plat-s5p/clock.c +1 -0
index 24a931f..b5e2552 100644
@@ -148,6 +148,7 @@ static struct clk *s5p_clks[] __initdata = {
 	&clk_fout_vpll,
 	&clk_arm,
 	&clk_vpll,
+	&clk_xusbxti,
 };
 
 void __init s5p_register_clocks(unsigned long xtal_freq)
Signature · 1 line
1.6.3.3
author
#5 lore raw

PATCH 4/4 usb: s3c-hsotg: Enable HCLK for the OTG module.

In reply to Kukjin Kim

From: Thomas Abraham <[email protected]>

This patch modifies the following in S3C hsotg driver.

1. Gets a reference to the USB OTG hclk clock and enables it. This is required for plaforms on which the USB OTG hclk is disabled during the boot time clock intialization.

2. Add necessary clock clean up in case of error during initialization failure or during module unload.

3. Add a new field 'clk_otg' in 'struct s3c_hsotg' to maintain a reference to the USB OTG hclk clock.

---
 drivers/usb/gadget/s3c-hsotg.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/usb/gadget/s3c-hsotg.c +17 -0
index 81c47d2..526d081 100644
@@ -130,6 +130,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @plat: The platform specific configuration data.
+ * @clk_otg: The hclk for otg module.
  * @regs: The memory area mapped for accessing registers.
  * @regs_res: The resource that was allocated when claiming register space.
  * @irq: The IRQ number we are using
@@ -147,6 +148,7 @@ struct s3c_hsotg {
 	struct device		 *dev;
 	struct usb_gadget_driver *driver;
 	struct s3c_hsotg_plat	 *plat;
+	struct clk		 *clk_otg;
 
 	void __iomem		*regs;
 	struct resource		*regs_res;
@@ -3269,6 +3271,14 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_regs_res;
 	}
 
+	hsotg->clk_otg = clk_get(&pdev->dev, "otg");
+	if (IS_ERR(hsotg->clk_otg)) {
+		dev_err(dev, "failed to find usb otg clock source\n");
+		ret = -ENODEV;
+		goto err_noclk;
+	}
+	clk_enable(hsotg->clk_otg);
+
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0) {
 		dev_err(dev, "cannot find IRQ\n");
@@ -3330,6 +3340,10 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 	return 0;
 
 err_regs:
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
+err_noclk:
 	iounmap(hsotg->regs);
 
 err_regs_res:
@@ -3352,6 +3366,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
 	free_irq(hsotg->irq, hsotg);
 	iounmap(hsotg->regs);
 
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
 	release_resource(hsotg->regs_res);
 	kfree(hsotg->regs_res);
 
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH 4/4 usb: s3c-hsotg: Enable HCLK for the OTG module.

Quoted 8 lines · Kukjin Kim

From: Thomas Abraham <[email protected]>

This patch modifies the following in S3C hsotg driver.

1. Gets a reference to the USB OTG hclk clock and enables it. This is required for plaforms on which the USB OTG hclk is disabled during the boot time clock intialization.

Quoted 5 lines

2. Add necessary clock clean up in case of error during initialization failure or during module unload.

3. Add a new field 'clk_otg' in 'struct s3c_hsotg' to maintain a reference to the USB OTG hclk clock.

ok, please note that the recent update sent from Marus to set the PHY clock rate already gets the clock. we should make sure that the code that does that uses this new clock from the hsotg info.

Quoted 65 lines
---
 drivers/usb/gadget/s3c-hsotg.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/usb/gadget/s3c-hsotg.c +17 -0
index 81c47d2..526d081 100644
@@ -130,6 +130,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @plat: The platform specific configuration data.
+ * @clk_otg: The hclk for otg module.
  * @regs: The memory area mapped for accessing registers.
  * @regs_res: The resource that was allocated when claiming register space.
  * @irq: The IRQ number we are using
@@ -147,6 +148,7 @@ struct s3c_hsotg {
 	struct device		 *dev;
 	struct usb_gadget_driver *driver;
 	struct s3c_hsotg_plat	 *plat;
+	struct clk		 *clk_otg;
 
 	void __iomem		*regs;
 	struct resource		*regs_res;
@@ -3269,6 +3271,14 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_regs_res;
 	}
 
+	hsotg->clk_otg = clk_get(&pdev->dev, "otg");
+	if (IS_ERR(hsotg->clk_otg)) {
+		dev_err(dev, "failed to find usb otg clock source\n");
+		ret = -ENODEV;
+		goto err_noclk;
+	}
+	clk_enable(hsotg->clk_otg);
+
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0) {
 		dev_err(dev, "cannot find IRQ\n");
@@ -3330,6 +3340,10 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 	return 0;
 
 err_regs:
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
+err_noclk:
 	iounmap(hsotg->regs);
 
 err_regs_res:
@@ -3352,6 +3366,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
 	free_irq(hsotg->irq, hsotg);
 	iounmap(hsotg->regs);
 
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
 	release_resource(hsotg->regs_res);
 	kfree(hsotg->regs_res);
 
Signature · 1 line
1.6.3.3
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#7 lore raw

PATCH 4/4 usb: s3c-hsotg: Enable HCLK for the OTG module.

In reply to Kukjin Kim
Quoted 41 lines · Kukjin Kim

From: Thomas Abraham <[email protected]>

This patch modifies the following in S3C hsotg driver.

1. Gets a reference to the USB OTG hclk clock and enables it. This is required for plaforms on which the USB OTG hclk is disabled during the boot time clock intialization.

2. Add necessary clock clean up in case of error during initialization failure or during module unload.

3. Add a new field 'clk_otg' in 'struct s3c_hsotg' to maintain a reference to the USB OTG hclk clock.

---
 drivers/usb/gadget/s3c-hsotg.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/usb/gadget/s3c-hsotg.c +2 -0
index 81c47d2..526d081 100644
@@ -130,6 +130,7 @@ struct s3c_hsotg_ep {
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
  * @plat: The platform specific configuration data.
+ * @clk_otg: The hclk for otg module.
  * @regs: The memory area mapped for accessing registers.
  * @regs_res: The resource that was allocated when claiming register space.
  * @irq: The IRQ number we are using
@@ -147,6 +148,7 @@ struct s3c_hsotg {
 	struct device		 *dev;
 	struct usb_gadget_driver *driver;
 	struct s3c_hsotg_plat	 *plat;
+	struct clk		 *clk_otg;
 
 	void __iomem		*regs;
 	struct resource		*regs_res;

drivers/usb/gadget/s3c-hsotg.c static int __devinit s3c_hsotg_probe(struct platform_device *pdev) · line 3277

Quoted 7 lines
drivers/usb/gadget/s3c-hsotg.c +4 -0
@@ -3269,6 +3271,14 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_regs_res;
 	}
 
+	hsotg->clk_otg = clk_get(&pdev->dev, "otg");
+	if (IS_ERR(hsotg->clk_otg)) {
+		dev_err(dev, "failed to find usb otg clock source\n");
+		ret = -ENODEV;

hmm, -ENODEV isn't really the right error to return here, it'll get silently ignored by the device core.

Quoted 31 lines
drivers/usb/gadget/s3c-hsotg.c +11 -0
+		goto err_noclk;
+	}
+	clk_enable(hsotg->clk_otg);
+
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0) {
 		dev_err(dev, "cannot find IRQ\n");
@@ -3330,6 +3340,10 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 	return 0;
 
 err_regs:
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
+err_noclk:
 	iounmap(hsotg->regs);
 
 err_regs_res:
@@ -3352,6 +3366,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
 	free_irq(hsotg->irq, hsotg);
 	iounmap(hsotg->regs);
 
+	clk_disable(hsotg->clk_otg);
+	clk_put(hsotg->clk_otg);
+
 	release_resource(hsotg->regs_res);
 	kfree(hsotg->regs_res);
 
Signature · 1 line
1.6.3.3
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#8 lore raw

PATCH 4/4 usb: s3c-hsotg: Enable HCLK for the OTG module.

Hello.

Quoted 24 lines · Ben Dooks
Quoted 24 lines

From: Thomas Abraham <[email protected]>

This patch modifies the following in S3C hsotg driver.

1. Gets a reference to the USB OTG hclk clock and enables it. This is required for plaforms on which the USB OTG hclk is disabled during the boot time clock intialization.

2. Add necessary clock clean up in case of error during initialization failure or during module unload.

3. Add a new field 'clk_otg' in 'struct s3c_hsotg' to maintain a reference to the USB OTG hclk clock.

---
 drivers/usb/gadget/s3c-hsotg.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/usb/gadget/s3c-hsotg.c +0 -0
index 81c47d2..526d081 100644

[...]

Quoted 11 lines

drivers/usb/gadget/s3c-hsotg.c static int __devinit s3c_hsotg_probe(struct platform_device *pdev) · line 3277

Quoted 8 lines
drivers/usb/gadget/s3c-hsotg.c +4 -0
@@ -3269,6 +3271,14 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_regs_res;
 	}
 
+	hsotg->clk_otg = clk_get(&pdev->dev, "otg");
+	if (IS_ERR(hsotg->clk_otg)) {
+		dev_err(dev, "failed to find usb otg clock source\n");
+		ret = -ENODEV;

hmm, -ENODEV isn't really the right error to return here, it'll get silently ignored by the device core.

    Right, PTR_ERR(hsotg->clk_otg) should be returned in this case.

WBR, Sergei

#9 lore raw

PATCH 4/4 usb: s3c-hsotg: Enable HCLK for the OTG module.

Quoted 42 lines · Sergei Shtylyov

Hello.

Quoted 24 lines · Ben Dooks
Quoted 24 lines

From: Thomas Abraham <[email protected]>

This patch modifies the following in S3C hsotg driver.

1. Gets a reference to the USB OTG hclk clock and enables it. This is required for plaforms on which the USB OTG hclk is disabled during the boot time clock intialization.

2. Add necessary clock clean up in case of error during initialization failure or during module unload.

3. Add a new field 'clk_otg' in 'struct s3c_hsotg' to maintain a reference to the USB OTG hclk clock.

---
 drivers/usb/gadget/s3c-hsotg.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/usb/gadget/s3c-hsotg.c +0 -0
index 81c47d2..526d081 100644

[...]

Quoted 10 lines

drivers/usb/gadget/s3c-hsotg.c static int __devinit s3c_hsotg_probe(struct platform_device *pdev) · line 3276

Quoted 7 lines
drivers/usb/gadget/s3c-hsotg.c +3 -0
@@ -3269,6 +3271,14 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 		goto err_regs_res;
 	}
 +	hsotg->clk_otg = clk_get(&pdev->dev, "otg");
+	if (IS_ERR(hsotg->clk_otg)) {
+		dev_err(dev, "failed to find usb otg clock source\n");
+		ret = -ENODEV;

hmm, -ENODEV isn't really the right error to return here, it'll get silently ignored by the device core.

Quoted 3 lines

Right, PTR_ERR(hsotg->clk_otg) should be returned in this case.

WBR, Sergei

yes, missed that thanks.

Signature · 4 lines
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.