clk-plla.c 1.1 KB

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