pwm-clock.h 1.4 KB

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