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 #define SYSTEM_MAX_ID 31
17 static inline int is_pck(int id)
19 return (id >= 8) && (id <= 15);
22 static int at91_system_clk_enable(struct clk *clk)
24 struct pmc_platdata *plat = dev_get_platdata(clk->dev);
25 struct at91_pmc *pmc = plat->reg_base;
28 if (clk->id > SYSTEM_MAX_ID)
33 writel(mask, &pmc->scer);
36 * For the programmable clocks the Ready status in the PMC
37 * status register should be checked after enabling.
38 * For other clocks this is unnecessary.
43 while (!(readl(&pmc->sr) & mask))
49 static struct clk_ops at91_system_clk_ops = {
50 .enable = at91_system_clk_enable,
53 static int at91_system_clk_bind(struct udevice *dev)
55 return at91_pmc_clk_node_bind(dev);
58 static int at91_system_clk_probe(struct udevice *dev)
60 return at91_pmc_core_probe(dev);
63 static const struct udevice_id at91_system_clk_match[] = {
64 { .compatible = "atmel,at91rm9200-clk-system" },
68 U_BOOT_DRIVER(at91_system_clk) = {
69 .name = "at91-system-clk",
71 .of_match = at91_system_clk_match,
72 .bind = at91_system_clk_bind,
73 .probe = at91_system_clk_probe,
74 .platdata_auto_alloc_size = sizeof(struct pmc_platdata),
75 .ops = &at91_system_clk_ops,