Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os 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>

authored by

Fabio Estevam and committed by
Felipe Balbi
ba789170 3d4eb9df

+33 -45
+33 -45
drivers/usb/gadget/fsl_mxc_udc.c
··· 21 21 #include <mach/hardware.h> 22 22 23 23 static struct clk *mxc_ahb_clk; 24 - static struct clk *mxc_usb_clk; 24 + static struct clk *mxc_per_clk; 25 + static struct clk *mxc_ipg_clk; 25 26 26 27 /* workaround ENGcm09152 for i.MX35 */ 27 28 #define USBPHYCTRL_OTGBASE_OFFSET 0x608 ··· 36 35 37 36 pdata = pdev->dev.platform_data; 38 37 39 - if (!cpu_is_mx35() && !cpu_is_mx25()) { 40 - mxc_ahb_clk = clk_get(&pdev->dev, "usb_ahb"); 41 - if (IS_ERR(mxc_ahb_clk)) 42 - return PTR_ERR(mxc_ahb_clk); 43 - 44 - ret = clk_prepare_enable(mxc_ahb_clk); 45 - if (ret < 0) { 46 - dev_err(&pdev->dev, "clk_enable(\"usb_ahb\") failed\n"); 47 - goto eenahb; 48 - } 38 + mxc_ipg_clk = devm_clk_get(&pdev->dev, "ipg"); 39 + if (IS_ERR(mxc_ipg_clk)) { 40 + dev_err(&pdev->dev, "clk_get(\"ipg\") failed\n"); 41 + return PTR_ERR(mxc_ipg_clk); 49 42 } 43 + 44 + mxc_ahb_clk = devm_clk_get(&pdev->dev, "ahb"); 45 + if (IS_ERR(mxc_ahb_clk)) { 46 + dev_err(&pdev->dev, "clk_get(\"ahb\") failed\n"); 47 + return PTR_ERR(mxc_ahb_clk); 48 + } 49 + 50 + mxc_per_clk = devm_clk_get(&pdev->dev, "per"); 51 + if (IS_ERR(mxc_per_clk)) { 52 + dev_err(&pdev->dev, "clk_get(\"per\") failed\n"); 53 + return PTR_ERR(mxc_per_clk); 54 + } 55 + 56 + clk_prepare_enable(mxc_ipg_clk); 57 + clk_prepare_enable(mxc_ahb_clk); 58 + clk_prepare_enable(mxc_per_clk); 50 59 51 60 /* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */ 52 - mxc_usb_clk = clk_get(&pdev->dev, "usb"); 53 - if (IS_ERR(mxc_usb_clk)) { 54 - dev_err(&pdev->dev, "clk_get(\"usb\") failed\n"); 55 - ret = PTR_ERR(mxc_usb_clk); 56 - goto egusb; 57 - } 58 - 59 61 if (!cpu_is_mx51()) { 60 - freq = clk_get_rate(mxc_usb_clk); 62 + freq = clk_get_rate(mxc_per_clk); 61 63 if (pdata->phy_mode != FSL_USB2_PHY_ULPI && 62 64 (freq < 59999000 || freq > 60001000)) { 63 65 dev_err(&pdev->dev, "USB_CLK=%lu, should be 60MHz\n", freq); ··· 69 65 } 70 66 } 71 67 72 - ret = clk_prepare_enable(mxc_usb_clk); 73 - if (ret < 0) { 74 - dev_err(&pdev->dev, "clk_enable(\"usb_clk\") failed\n"); 75 - goto eenusb; 76 - } 77 - 78 68 return 0; 79 69 80 - eenusb: 81 70 eclkrate: 82 - clk_put(mxc_usb_clk); 83 - mxc_usb_clk = NULL; 84 - egusb: 85 - if (!cpu_is_mx35()) 86 - clk_disable_unprepare(mxc_ahb_clk); 87 - eenahb: 88 - if (!cpu_is_mx35()) 89 - clk_put(mxc_ahb_clk); 71 + clk_disable_unprepare(mxc_ipg_clk); 72 + clk_disable_unprepare(mxc_ahb_clk); 73 + clk_disable_unprepare(mxc_per_clk); 74 + mxc_per_clk = NULL; 90 75 return ret; 91 76 } 92 77 ··· 97 104 98 105 /* ULPI transceivers don't need usbpll */ 99 106 if (pdata->phy_mode == FSL_USB2_PHY_ULPI) { 100 - clk_disable_unprepare(mxc_usb_clk); 101 - clk_put(mxc_usb_clk); 102 - mxc_usb_clk = NULL; 107 + clk_disable_unprepare(mxc_per_clk); 108 + mxc_per_clk = NULL; 103 109 } 104 110 } 105 111 106 112 void fsl_udc_clk_release(void) 107 113 { 108 - if (mxc_usb_clk) { 109 - clk_disable_unprepare(mxc_usb_clk); 110 - clk_put(mxc_usb_clk); 111 - } 112 - if (!cpu_is_mx35()) { 113 - clk_disable_unprepare(mxc_ahb_clk); 114 - clk_put(mxc_ahb_clk); 115 - } 114 + if (mxc_per_clk) 115 + clk_disable_unprepare(mxc_per_clk); 116 + clk_disable_unprepare(mxc_ahb_clk); 117 + clk_disable_unprepare(mxc_ipg_clk); 116 118 }