pwm-clock.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* linux/arch/arm/mach-s5p6440/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. * Copyright 2009 Samsung Electronics Co., Ltd.
  8. * http://www.samsung.com/
  9. *
  10. * S5P6440 - pwm clock and timer support
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. /**
  17. * pwm_cfg_src_is_tclk() - return whether the given mux config is a tclk
  18. * @cfg: The timer TCFG1 register bits shifted down to 0.
  19. *
  20. * Return true if the given configuration from TCFG1 is a TCLK instead
  21. * any of the TDIV clocks.
  22. */
  23. static inline int pwm_cfg_src_is_tclk(unsigned long tcfg)
  24. {
  25. return tcfg == S3C2410_TCFG1_MUX_TCLK;
  26. }
  27. /**
  28. * tcfg_to_divisor() - convert tcfg1 setting to a divisor
  29. * @tcfg1: The tcfg1 setting, shifted down.
  30. *
  31. * Get the divisor value for the given tcfg1 setting. We assume the
  32. * caller has already checked to see if this is not a TCLK source.
  33. */
  34. static inline unsigned long tcfg_to_divisor(unsigned long tcfg1)
  35. {
  36. return 1 << (1 + tcfg1);
  37. }
  38. /**
  39. * pwm_tdiv_has_div1() - does the tdiv setting have a /1
  40. *
  41. * Return true if we have a /1 in the tdiv setting.
  42. */
  43. static inline unsigned int pwm_tdiv_has_div1(void)
  44. {
  45. return 0;
  46. }
  47. /**
  48. * pwm_tdiv_div_bits() - calculate TCFG1 divisor value.
  49. * @div: The divisor to calculate the bit information for.
  50. *
  51. * Turn a divisor into the necessary bit field for TCFG1.
  52. */
  53. static inline unsigned long pwm_tdiv_div_bits(unsigned int div)
  54. {
  55. return ilog2(div) - 1;
  56. }
  57. #define S3C_TCFG1_MUX_TCLK S3C2410_TCFG1_MUX_TCLK