blob: f5b2ca167340bd8d07e46ef00cee492855fbcf8a [file] [log] [blame]
Wenyou Yang9e5935c2016-07-20 17:55:12 +08001/*
2 * Copyright (C) 2016 Atmel Corporation
3 * Wenyou.Yang <wenyou.yang@atmel.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <clk-uclass.h>
Simon Glass9d922452017-05-17 17:18:03 -060010#include <dm.h>
Wenyou Yang9e5935c2016-07-20 17:55:12 +080011#include <linux/io.h>
12#include <mach/at91_pmc.h>
13#include "pmc.h"
14
15DECLARE_GLOBAL_DATA_PTR;
16
17static int plla_clk_enable(struct clk *clk)
18{
19 struct pmc_platdata *plat = dev_get_platdata(clk->dev);
20 struct at91_pmc *pmc = plat->reg_base;
21
22 if (readl(&pmc->sr) & AT91_PMC_LOCKA)
23 return 0;
24
25 return -EINVAL;
26}
27
28static ulong plla_clk_get_rate(struct clk *clk)
29{
30 return gd->arch.plla_rate_hz;
31}
32
33static struct clk_ops plla_clk_ops = {
34 .enable = plla_clk_enable,
35 .get_rate = plla_clk_get_rate,
36};
37
38static int plla_clk_probe(struct udevice *dev)
39{
40 return at91_pmc_core_probe(dev);
41}
42
43static const struct udevice_id plla_clk_match[] = {
44 { .compatible = "atmel,sama5d3-clk-pll" },
45 {}
46};
47
48U_BOOT_DRIVER(at91_plla_clk) = {
49 .name = "at91-plla-clk",
50 .id = UCLASS_CLK,
51 .of_match = plla_clk_match,
52 .probe = plla_clk_probe,
53 .platdata_auto_alloc_size = sizeof(struct pmc_platdata),
54 .ops = &plla_clk_ops,
55};