2 * Copyright (C) 2016 Atmel Corporation
3 * Wenyou.Yang <wenyou.yang@atmel.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <clk-uclass.h>
10 #include <dm/device.h>
12 #include <mach/at91_pmc.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 #define UTMI_FIXED_MUL 40
19 static int utmi_clk_enable(struct clk *clk)
21 struct pmc_platdata *plat = dev_get_platdata(clk->dev);
22 struct at91_pmc *pmc = plat->reg_base;
25 if (readl(&pmc->sr) & AT91_PMC_LOCKU)
28 tmp = readl(&pmc->uckr);
29 tmp |= AT91_PMC_UPLLEN |
32 writel(tmp, &pmc->uckr);
34 while (!(readl(&pmc->sr) & AT91_PMC_LOCKU))
40 static ulong utmi_clk_get_rate(struct clk *clk)
42 return gd->arch.main_clk_rate_hz * UTMI_FIXED_MUL;
45 static struct clk_ops utmi_clk_ops = {
46 .enable = utmi_clk_enable,
47 .get_rate = utmi_clk_get_rate,
50 static int utmi_clk_probe(struct udevice *dev)
52 return at91_pmc_core_probe(dev);
55 static const struct udevice_id utmi_clk_match[] = {
56 { .compatible = "atmel,at91sam9x5-clk-utmi" },
60 U_BOOT_DRIVER(at91sam9x5_utmi_clk) = {
61 .name = "at91sam9x5-utmi-clk",
63 .of_match = utmi_clk_match,
64 .probe = utmi_clk_probe,
65 .platdata_auto_alloc_size = sizeof(struct pmc_platdata),