lkml.org 
[lkml]   [2013]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v3 6/7] USB: ohci-at91: add usb_clk for transition to common clk framework
    Date
    The AT91 PMC (Power Management Controller) provides an USB clock used by
    USB Full Speed host (ohci) and USB Full Speed device (udc).
    The usb drivers (ohci and udc) must configure this clock to 48Mhz.
    This configuration was formely done in mach-at91/clock.c, but this
    implementation will be removed when moving to common clk framework.

    This patch add support for usb clock retrieval and configuration, and is
    backward compatible with the current at91 clk implementation (if usb clk
    is not found, it does not configure/enable the usb clk).

    Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
    ---
    drivers/usb/host/ohci-at91.c | 18 +++++++++++++++---
    1 file changed, 15 insertions(+), 3 deletions(-)

    diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
    index 9677f68..426c7d2 100644
    --- a/drivers/usb/host/ohci-at91.c
    +++ b/drivers/usb/host/ohci-at91.c
    @@ -31,8 +31,8 @@
    #define at91_for_each_port(index) \
    for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)

    -/* interface and function clocks; sometimes also an AHB clock */
    -static struct clk *iclk, *fclk, *hclk;
    +/* interface, function and usb clocks; sometimes also an AHB clock */
    +static struct clk *iclk, *fclk, *uclk, *hclk;
    static int clocked;

    extern int usb_disabled(void);
    @@ -41,6 +41,10 @@ extern int usb_disabled(void);

    static void at91_start_clock(void)
    {
    + if (uclk) {
    + clk_set_rate(uclk, 48000000);
    + clk_prepare_enable(uclk);
    + }
    clk_prepare_enable(hclk);
    clk_prepare_enable(iclk);
    clk_prepare_enable(fclk);
    @@ -52,6 +56,8 @@ static void at91_stop_clock(void)
    clk_disable_unprepare(fclk);
    clk_disable_unprepare(iclk);
    clk_disable_unprepare(hclk);
    + if (uclk)
    + clk_disable_unprepare(uclk);
    clocked = 0;
    }

    @@ -144,6 +150,11 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
    goto err2;
    }

    + uclk = clk_get(&pdev->dev, "usb_clk");
    + if (IS_ERR(uclk)) {
    + uclk = NULL;
    + dev_warn(&pdev->dev, "failed to get usb_clk\n");
    + }
    iclk = clk_get(&pdev->dev, "ohci_clk");
    if (IS_ERR(iclk)) {
    dev_err(&pdev->dev, "failed to get ohci_clk\n");
    @@ -212,10 +223,11 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
    release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
    usb_put_hcd(hcd);

    + clk_put(uclk);
    clk_put(hclk);
    clk_put(fclk);
    clk_put(iclk);
    - fclk = iclk = hclk = NULL;
    + fclk = iclk = hclk = uclk = NULL;

    dev_set_drvdata(&pdev->dev, NULL);
    }
    --
    1.7.9.5


    \
     
     \ /
      Last update: 2013-07-16 18:22    [W:2.405 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site