pwm-clock.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* linux/arch/arm/mach-s3c6400/include/mach/pwm-clock.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64xx - pwm clock and timer support
  9. */
  10. /**
  11. * pwm_cfg_src_is_tclk() - return whether the given mux config is a tclk
  12. * @tcfg: The timer TCFG1 register bits shifted down to 0.
  13. *
  14. * Return true if the given configuration from TCFG1 is a TCLK instead
  15. * any of the TDIV clocks.
  16. */
  17. static inline int pwm_cfg_src_is_tclk(unsigned long tcfg)
  18. {
  19. return tcfg >= S3C64XX_TCFG1_MUX_TCLK;
  20. }
  21. /**
  22. * tcfg_to_divisor() - convert tcfg1 setting to a divisor
  23. * @tcfg1: The tcfg1 setting, shifted down.
  24. *
  25. * Get the divisor value for the given tcfg1 setting. We assume the
  26. * caller has already checked to see if this is not a TCLK source.
  27. */
  28. static inline unsigned long tcfg_to_divisor(unsigned long tcfg1)
  29. {
  30. return 1 << tcfg1;
  31. }
  32. /**
  33. * pwm_tdiv_has_div1() - does the tdiv setting have a /1
  34. *
  35. * Return true if we have a /1 in the tdiv setting.
  36. */
  37. static inline unsigned int pwm_tdiv_has_div1(void)
  38. {
  39. return 1;
  40. }
  41. /**
  42. * pwm_tdiv_div_bits() - calculate TCFG1 divisor value.
  43. * @div: The divisor to calculate the bit information for.
  44. *
  45. * Turn a divisor into the necessary bit field for TCFG1.
  46. */
  47. static inline unsigned long pwm_tdiv_div_bits(unsigned int div)
  48. {
  49. return ilog2(div);
  50. }
  51. #define S3C_TCFG1_MUX_TCLK S3C64XX_TCFG1_MUX_TCLK