diff options
Diffstat (limited to 'drivers/usb/gadget/at91_udc.c')
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index d9a6add0c852..4cc4fd6d1473 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -870,6 +870,11 @@ static void clk_on(struct at91_udc *udc) | |||
870 | if (udc->clocked) | 870 | if (udc->clocked) |
871 | return; | 871 | return; |
872 | udc->clocked = 1; | 872 | udc->clocked = 1; |
873 | |||
874 | if (IS_ENABLED(CONFIG_COMMON_CLK)) { | ||
875 | clk_set_rate(udc->uclk, 48000000); | ||
876 | clk_prepare_enable(udc->uclk); | ||
877 | } | ||
873 | clk_prepare_enable(udc->iclk); | 878 | clk_prepare_enable(udc->iclk); |
874 | clk_prepare_enable(udc->fclk); | 879 | clk_prepare_enable(udc->fclk); |
875 | } | 880 | } |
@@ -882,6 +887,8 @@ static void clk_off(struct at91_udc *udc) | |||
882 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 887 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
883 | clk_disable_unprepare(udc->fclk); | 888 | clk_disable_unprepare(udc->fclk); |
884 | clk_disable_unprepare(udc->iclk); | 889 | clk_disable_unprepare(udc->iclk); |
890 | if (IS_ENABLED(CONFIG_COMMON_CLK)) | ||
891 | clk_disable_unprepare(udc->uclk); | ||
885 | } | 892 | } |
886 | 893 | ||
887 | /* | 894 | /* |
@@ -1697,7 +1704,7 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1697 | int retval; | 1704 | int retval; |
1698 | struct resource *res; | 1705 | struct resource *res; |
1699 | 1706 | ||
1700 | if (!dev->platform_data && !pdev->dev.of_node) { | 1707 | if (!dev_get_platdata(dev) && !pdev->dev.of_node) { |
1701 | /* small (so we copy it) but critical! */ | 1708 | /* small (so we copy it) but critical! */ |
1702 | DBG("missing platform_data\n"); | 1709 | DBG("missing platform_data\n"); |
1703 | return -ENODEV; | 1710 | return -ENODEV; |
@@ -1728,7 +1735,7 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1728 | if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) | 1735 | if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) |
1729 | at91udc_of_init(udc, pdev->dev.of_node); | 1736 | at91udc_of_init(udc, pdev->dev.of_node); |
1730 | else | 1737 | else |
1731 | memcpy(&udc->board, dev->platform_data, | 1738 | memcpy(&udc->board, dev_get_platdata(dev), |
1732 | sizeof(struct at91_udc_data)); | 1739 | sizeof(struct at91_udc_data)); |
1733 | udc->pdev = pdev; | 1740 | udc->pdev = pdev; |
1734 | udc->enabled = 0; | 1741 | udc->enabled = 0; |
@@ -1774,10 +1781,12 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1774 | /* get interface and function clocks */ | 1781 | /* get interface and function clocks */ |
1775 | udc->iclk = clk_get(dev, "udc_clk"); | 1782 | udc->iclk = clk_get(dev, "udc_clk"); |
1776 | udc->fclk = clk_get(dev, "udpck"); | 1783 | udc->fclk = clk_get(dev, "udpck"); |
1777 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { | 1784 | if (IS_ENABLED(CONFIG_COMMON_CLK)) |
1785 | udc->uclk = clk_get(dev, "usb_clk"); | ||
1786 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) || | ||
1787 | (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) { | ||
1778 | DBG("clocks missing\n"); | 1788 | DBG("clocks missing\n"); |
1779 | retval = -ENODEV; | 1789 | retval = -ENODEV; |
1780 | /* NOTE: we "know" here that refcounts on these are NOPs */ | ||
1781 | goto fail1; | 1790 | goto fail1; |
1782 | } | 1791 | } |
1783 | 1792 | ||
@@ -1851,6 +1860,12 @@ fail3: | |||
1851 | fail2: | 1860 | fail2: |
1852 | free_irq(udc->udp_irq, udc); | 1861 | free_irq(udc->udp_irq, udc); |
1853 | fail1: | 1862 | fail1: |
1863 | if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk)) | ||
1864 | clk_put(udc->uclk); | ||
1865 | if (!IS_ERR(udc->fclk)) | ||
1866 | clk_put(udc->fclk); | ||
1867 | if (!IS_ERR(udc->iclk)) | ||
1868 | clk_put(udc->iclk); | ||
1854 | iounmap(udc->udp_baseaddr); | 1869 | iounmap(udc->udp_baseaddr); |
1855 | fail0a: | 1870 | fail0a: |
1856 | if (cpu_is_at91rm9200()) | 1871 | if (cpu_is_at91rm9200()) |
@@ -1894,6 +1909,8 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1894 | 1909 | ||
1895 | clk_put(udc->iclk); | 1910 | clk_put(udc->iclk); |
1896 | clk_put(udc->fclk); | 1911 | clk_put(udc->fclk); |
1912 | if (IS_ENABLED(CONFIG_COMMON_CLK)) | ||
1913 | clk_put(udc->uclk); | ||
1897 | 1914 | ||
1898 | return 0; | 1915 | return 0; |
1899 | } | 1916 | } |