forked from Minki/linux
usb: gadget: fsl_mxc_udc: do not depend on grouped clocks
With the new common clock infrastructure, the following clocks should be used on i.MX drivers: ipg, per and ahb. Adapt fsl_mxc_udc to follow this new behaviour to fix the following probe error: Freescale High-Speed USB SOC Device Controller driver (Apr 20, 2007) fsl-usb2-udc fsl-usb2-udc: clk_get("usb") failed fsl-usb2-udc: probe of fsl-usb2-udc failed with error -2 Reported-by: Christoph Fritz <chf.fritz@googlemail.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
3d4eb9dfa3
commit
ba789170d2
@ -21,7 +21,8 @@
|
|||||||
#include <mach/hardware.h>
|
#include <mach/hardware.h>
|
||||||
|
|
||||||
static struct clk *mxc_ahb_clk;
|
static struct clk *mxc_ahb_clk;
|
||||||
static struct clk *mxc_usb_clk;
|
static struct clk *mxc_per_clk;
|
||||||
|
static struct clk *mxc_ipg_clk;
|
||||||
|
|
||||||
/* workaround ENGcm09152 for i.MX35 */
|
/* workaround ENGcm09152 for i.MX35 */
|
||||||
#define USBPHYCTRL_OTGBASE_OFFSET 0x608
|
#define USBPHYCTRL_OTGBASE_OFFSET 0x608
|
||||||
@ -35,28 +36,31 @@ int fsl_udc_clk_init(struct platform_device *pdev)
|
|||||||
|
|
||||||
pdata = pdev->dev.platform_data;
|
pdata = pdev->dev.platform_data;
|
||||||
|
|
||||||
if (!cpu_is_mx35() && !cpu_is_mx25()) {
|
mxc_ipg_clk = devm_clk_get(&pdev->dev, "ipg");
|
||||||
mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb");
|
if (IS_ERR(mxc_ipg_clk)) {
|
||||||
if (IS_ERR(mxc_ahb_clk))
|
dev_err(&pdev->dev, "clk_get(\"ipg\") failed\n");
|
||||||
return PTR_ERR(mxc_ahb_clk);
|
return PTR_ERR(mxc_ipg_clk);
|
||||||
|
|
||||||
ret = clk_prepare_enable(mxc_ahb_clk);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n");
|
|
||||||
goto eenahb;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mxc_ahb_clk = devm_clk_get(&pdev->dev, "ahb");
|
||||||
|
if (IS_ERR(mxc_ahb_clk)) {
|
||||||
|
dev_err(&pdev->dev, "clk_get(\"ahb\") failed\n");
|
||||||
|
return PTR_ERR(mxc_ahb_clk);
|
||||||
|
}
|
||||||
|
|
||||||
|
mxc_per_clk = devm_clk_get(&pdev->dev, "per");
|
||||||
|
if (IS_ERR(mxc_per_clk)) {
|
||||||
|
dev_err(&pdev->dev, "clk_get(\"per\") failed\n");
|
||||||
|
return PTR_ERR(mxc_per_clk);
|
||||||
|
}
|
||||||
|
|
||||||
|
clk_prepare_enable(mxc_ipg_clk);
|
||||||
|
clk_prepare_enable(mxc_ahb_clk);
|
||||||
|
clk_prepare_enable(mxc_per_clk);
|
||||||
|
|
||||||
/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
|
/* 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()) {
|
if (!cpu_is_mx51()) {
|
||||||
freq = clk_get_rate(mxc_usb_clk);
|
freq = clk_get_rate(mxc_per_clk);
|
||||||
if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
|
if (pdata->phy_mode != FSL_USB2_PHY_ULPI &&
|
||||||
(freq < 59999000 || freq > 60001000)) {
|
(freq < 59999000 || freq > 60001000)) {
|
||||||
dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
|
dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq);
|
||||||
@ -65,24 +69,13 @@ int fsl_udc_clk_init(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(mxc_usb_clk);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n");
|
|
||||||
goto eenusb;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
eenusb:
|
|
||||||
eclkrate:
|
eclkrate:
|
||||||
clk_put(mxc_usb_clk);
|
clk_disable_unprepare(mxc_ipg_clk);
|
||||||
mxc_usb_clk = NULL;
|
clk_disable_unprepare(mxc_ahb_clk);
|
||||||
egusb:
|
clk_disable_unprepare(mxc_per_clk);
|
||||||
if (!cpu_is_mx35())
|
mxc_per_clk = NULL;
|
||||||
clk_disable_unprepare(mxc_ahb_clk);
|
|
||||||
eenahb:
|
|
||||||
if (!cpu_is_mx35())
|
|
||||||
clk_put(mxc_ahb_clk);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,20 +97,15 @@ void fsl_udc_clk_finalize(struct platform_device *pdev)
|
|||||||
|
|
||||||
/* ULPI transceivers don't need usbpll */
|
/* ULPI transceivers don't need usbpll */
|
||||||
if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
|
if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
|
||||||
clk_disable_unprepare(mxc_usb_clk);
|
clk_disable_unprepare(mxc_per_clk);
|
||||||
clk_put(mxc_usb_clk);
|
mxc_per_clk = NULL;
|
||||||
mxc_usb_clk = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsl_udc_clk_release(void)
|
void fsl_udc_clk_release(void)
|
||||||
{
|
{
|
||||||
if (mxc_usb_clk) {
|
if (mxc_per_clk)
|
||||||
clk_disable_unprepare(mxc_usb_clk);
|
clk_disable_unprepare(mxc_per_clk);
|
||||||
clk_put(mxc_usb_clk);
|
clk_disable_unprepare(mxc_ahb_clk);
|
||||||
}
|
clk_disable_unprepare(mxc_ipg_clk);
|
||||||
if (!cpu_is_mx35()) {
|
|
||||||
clk_disable_unprepare(mxc_ahb_clk);
|
|
||||||
clk_put(mxc_ahb_clk);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user