-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 151388 b: refs/heads/master c: 54e4026 h: refs/heads/master v: v3
- Loading branch information
Guennadi Liakhovetski
authored and
Greg Kroah-Hartman
committed
Jun 16, 2009
1 parent
2a0a1b5
commit 49e9b8b
Showing
6 changed files
with
165 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 568d422e9cf52b7b26d2e026ae1617971f62b560 | ||
refs/heads/master: 54e4026b64a970303349b952866641a7804ef594 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* 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> | ||
|
||
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; | ||
|
||
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); | ||
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: | ||
clk_disable(mxc_ahb_clk); | ||
eenahb: | ||
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); | ||
} | ||
clk_disable(mxc_ahb_clk); | ||
clk_put(mxc_ahb_clk); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters