pwm-uclass.c 684 B

123456789101112131415161718192021222324252627282930313233343536
  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_config(struct udevice *dev, uint channel, uint period_ns,
  11. uint duty_ns)
  12. {
  13. struct pwm_ops *ops = pwm_get_ops(dev);
  14. if (!ops->set_config)
  15. return -ENOSYS;
  16. return ops->set_config(dev, channel, period_ns, duty_ns);
  17. }
  18. int pwm_set_enable(struct udevice *dev, uint channel, bool enable)
  19. {
  20. struct pwm_ops *ops = pwm_get_ops(dev);
  21. if (!ops->set_enable)
  22. return -ENOSYS;
  23. return ops->set_enable(dev, channel, enable);
  24. }
  25. UCLASS_DRIVER(pwm) = {
  26. .id = UCLASS_PWM,
  27. .name = "pwm",
  28. };