pwm.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * header file for pwm driver.
  3. *
  4. * Copyright 2016 Google Inc.
  5. * Copyright (c) 2011 samsung electronics
  6. * Donghwa Lee <dh09.lee@samsung.com>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #ifndef _pwm_h_
  11. #define _pwm_h_
  12. /* struct pwm_ops: Operations for the PWM uclass */
  13. struct pwm_ops {
  14. /**
  15. * set_config() - Set the PWM configuration
  16. *
  17. * @dev: PWM device to update
  18. * @channel: PWM channel to update
  19. * @period_ns: PWM period in nanoseconds
  20. * @duty_ns: PWM duty period in nanoseconds
  21. * @return 0 if OK, -ve on error
  22. */
  23. int (*set_config)(struct udevice *dev, uint channel, uint period_ns,
  24. uint duty_ns);
  25. /**
  26. * set_enable() - Enable or disable the PWM
  27. *
  28. * @dev: PWM device to update
  29. * @channel: PWM channel to update
  30. * @enable: true to enable, false to disable
  31. * @return 0 if OK, -ve on error
  32. */
  33. int (*set_enable)(struct udevice *dev, uint channel, bool enable);
  34. };
  35. #define pwm_get_ops(dev) ((struct pwm_ops *)(dev)->driver->ops)
  36. /**
  37. * pwm_set_config() - Set the PWM configuration
  38. *
  39. * @dev: PWM device to update
  40. * @channel: PWM channel to update
  41. * @period_ns: PWM period in nanoseconds
  42. * @duty_ns: PWM duty period in nanoseconds
  43. * @return 0 if OK, -ve on error
  44. */
  45. int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
  46. uint duty_ns);
  47. /**
  48. * pwm_set_enable() - Enable or disable the PWM
  49. *
  50. * @dev: PWM device to update
  51. * @channel: PWM channel to update
  52. * @enable: true to enable, false to disable
  53. * @return 0 if OK, -ve on error
  54. */
  55. int pwm_set_enable(struct udevice *dev, uint channel, bool enable);
  56. /* Legacy interface */
  57. #ifndef CONFIG_DM_PWM
  58. int pwm_init (int pwm_id, int div, int invert);
  59. int pwm_config (int pwm_id, int duty_ns, int period_ns);
  60. int pwm_enable (int pwm_id);
  61. void pwm_disable (int pwm_id);
  62. #endif
  63. #endif /* _pwm_h_ */