clk-plla.c 1.1 KB

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