pwm-uclass.c 921 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2016 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #define LOG_CATEGORY UCLASS_PWM
  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. };