pwm.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Tegra pulse width frequency modulator definitions
  3. *
  4. * Copyright (c) 2011 The Chromium OS Authors.
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __ASM_ARCH_TEGRA_PWM_H
  24. #define __ASM_ARCH_TEGRA_PWM_H
  25. /* This is a single PWM channel */
  26. struct pwm_ctlr {
  27. uint control; /* Control register */
  28. uint reserved[3]; /* Space space */
  29. };
  30. #define PWM_NUM_CHANNELS 4
  31. /* PWM_CONTROLLER_PWM_CSR_0/1/2/3_0 */
  32. #define PWM_ENABLE_SHIFT 31
  33. #define PWM_ENABLE_MASK (0x1 << PWM_ENABLE_SHIFT)
  34. #define PWM_WIDTH_SHIFT 16
  35. #define PWM_WIDTH_MASK (0x7FFF << PWM_WIDTH_SHIFT)
  36. #define PWM_DIVIDER_SHIFT 0
  37. #define PWM_DIVIDER_MASK (0x1FFF << PWM_DIVIDER_SHIFT)
  38. /**
  39. * Program the PWM with the given parameters.
  40. *
  41. * @param channel PWM channel to update
  42. * @param rate Clock rate to use for PWM
  43. * @param pulse_width high pulse width: 0=always low, 1=1/256 pulse high,
  44. * n = n/256 pulse high
  45. * @param freq_divider frequency divider value (1 to use rate as is)
  46. */
  47. void pwm_enable(unsigned channel, int rate, int pulse_width, int freq_divider);
  48. /**
  49. * Request a pwm channel as referenced by a device tree node.
  50. *
  51. * This channel can then be passed to pwm_enable().
  52. *
  53. * @param blob Device tree blob
  54. * @param node Node containing reference to pwm
  55. * @param prop_name Property name of pwm reference
  56. * @return channel number, if ok, else -1
  57. */
  58. int pwm_request(const void *blob, int node, const char *prop_name);
  59. /**
  60. * Set up the pwm controller, by looking it up in the fdt.
  61. *
  62. * @return 0 if ok, -1 if the device tree node was not found or invalid.
  63. */
  64. int pwm_init(const void *blob);
  65. #endif /* __ASM_ARCH_TEGRA_PWM_H */