clk-uclass.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <clk.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <dm/lists.h>
  12. #include <dm/root.h>
  13. ulong clk_get_rate(struct udevice *dev)
  14. {
  15. struct clk_ops *ops = clk_get_ops(dev);
  16. if (!ops->get_rate)
  17. return -ENOSYS;
  18. return ops->get_rate(dev);
  19. }
  20. ulong clk_set_rate(struct udevice *dev, ulong rate)
  21. {
  22. struct clk_ops *ops = clk_get_ops(dev);
  23. if (!ops->set_rate)
  24. return -ENOSYS;
  25. return ops->set_rate(dev, rate);
  26. }
  27. ulong clk_get_periph_rate(struct udevice *dev, int periph)
  28. {
  29. struct clk_ops *ops = clk_get_ops(dev);
  30. if (!ops->get_periph_rate)
  31. return -ENOSYS;
  32. return ops->get_periph_rate(dev, periph);
  33. }
  34. ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
  35. {
  36. struct clk_ops *ops = clk_get_ops(dev);
  37. if (!ops->set_periph_rate)
  38. return -ENOSYS;
  39. return ops->set_periph_rate(dev, periph, rate);
  40. }
  41. UCLASS_DRIVER(clk) = {
  42. .id = UCLASS_CLK,
  43. .name = "clk",
  44. };