pwm-uclass.c 888 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2016 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <pwm.h>
  9. int pwm_set_invert(struct udevice *dev, uint channel, bool polarity)
  10. {
  11. struct pwm_ops *ops = pwm_get_ops(dev);
  12. if (!ops->set_invert)
  13. return -ENOSYS;
  14. return ops->set_invert(dev, channel, polarity);
  15. }
  16. int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
  17. uint duty_ns)
  18. {
  19. struct pwm_ops *ops = pwm_get_ops(dev);
  20. if (!ops->set_config)
  21. return -ENOSYS;
  22. return ops->set_config(dev, channel, period_ns, duty_ns);
  23. }
  24. int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
  25. {
  26. struct pwm_ops *ops = pwm_get_ops(dev);
  27. if (!ops->set_enable)
  28. return -ENOSYS;
  29. return ops->set_enable(dev, channel, enable);
  30. }
  31. UCLASS_DRIVER(pwm) = {
  32. .id = UCLASS_PWM,
  33. .name = "pwm",
  34. };