pwm-uclass.c 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2016 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 <dm.h>
  9. #include <pwm.h>
  10. int pwm_set_invert(struct udevice *dev, uint channel, bool polarity)
  11. {
  12. struct pwm_ops *ops = pwm_get_ops(dev);
  13. if (!ops->set_invert)
  14. return -ENOSYS;
  15. return ops->set_invert(dev, channel, polarity);
  16. }
  17. int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
  18. uint duty_ns)
  19. {
  20. struct pwm_ops *ops = pwm_get_ops(dev);
  21. if (!ops->set_config)
  22. return -ENOSYS;
  23. return ops->set_config(dev, channel, period_ns, duty_ns);
  24. }
  25. int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
  26. {
  27. struct pwm_ops *ops = pwm_get_ops(dev);
  28. if (!ops->set_enable)
  29. return -ENOSYS;
  30. return ops->set_enable(dev, channel, enable);
  31. }
  32. UCLASS_DRIVER(pwm) = {
  33. .id = UCLASS_PWM,
  34. .name = "pwm",
  35. };