bfin_rotary.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * board initialization should put one of these structures into platform_data
  3. * and place the bfin-rotary onto platform_bus named "bfin-rotary".
  4. *
  5. * Copyright 2008-2010 Analog Devices Inc.
  6. *
  7. * Licensed under the GPL-2 or later.
  8. */
  9. #ifndef _BFIN_ROTARY_H
  10. #define _BFIN_ROTARY_H
  11. /* mode bitmasks */
  12. #define ROT_QUAD_ENC CNTMODE_QUADENC /* quadrature/grey code encoder mode */
  13. #define ROT_BIN_ENC CNTMODE_BINENC /* binary encoder mode */
  14. #define ROT_UD_CNT CNTMODE_UDCNT /* rotary counter mode */
  15. #define ROT_DIR_CNT CNTMODE_DIRCNT /* direction counter mode */
  16. #define ROT_DEBE DEBE /* Debounce Enable */
  17. #define ROT_CDGINV CDGINV /* CDG Pin Polarity Invert */
  18. #define ROT_CUDINV CUDINV /* CUD Pin Polarity Invert */
  19. #define ROT_CZMINV CZMINV /* CZM Pin Polarity Invert */
  20. struct bfin_rotary_platform_data {
  21. /* set rotary UP KEY_### or BTN_### in case you prefer
  22. * bfin-rotary to send EV_KEY otherwise set 0
  23. */
  24. unsigned int rotary_up_key;
  25. /* set rotary DOWN KEY_### or BTN_### in case you prefer
  26. * bfin-rotary to send EV_KEY otherwise set 0
  27. */
  28. unsigned int rotary_down_key;
  29. /* set rotary BUTTON KEY_### or BTN_### */
  30. unsigned int rotary_button_key;
  31. /* set rotary Relative Axis REL_### in case you prefer
  32. * bfin-rotary to send EV_REL otherwise set 0
  33. */
  34. unsigned int rotary_rel_code;
  35. unsigned short debounce; /* 0..17 */
  36. unsigned short mode;
  37. unsigned short pm_wakeup;
  38. unsigned short *pin_list;
  39. };
  40. /* CNT_CONFIG bitmasks */
  41. #define CNTE (1 << 0) /* Counter Enable */
  42. #define DEBE (1 << 1) /* Debounce Enable */
  43. #define CDGINV (1 << 4) /* CDG Pin Polarity Invert */
  44. #define CUDINV (1 << 5) /* CUD Pin Polarity Invert */
  45. #define CZMINV (1 << 6) /* CZM Pin Polarity Invert */
  46. #define CNTMODE_SHIFT 8
  47. #define CNTMODE (0x7 << CNTMODE_SHIFT) /* Counter Operating Mode */
  48. #define ZMZC (1 << 1) /* CZM Zeroes Counter Enable */
  49. #define BNDMODE_SHIFT 12
  50. #define BNDMODE (0x3 << BNDMODE_SHIFT) /* Boundary register Mode */
  51. #define INPDIS (1 << 15) /* CUG and CDG Input Disable */
  52. #define CNTMODE_QUADENC (0 << CNTMODE_SHIFT) /* quadrature encoder mode */
  53. #define CNTMODE_BINENC (1 << CNTMODE_SHIFT) /* binary encoder mode */
  54. #define CNTMODE_UDCNT (2 << CNTMODE_SHIFT) /* up/down counter mode */
  55. #define CNTMODE_DIRCNT (4 << CNTMODE_SHIFT) /* direction counter mode */
  56. #define CNTMODE_DIRTMR (5 << CNTMODE_SHIFT) /* direction timer mode */
  57. #define BNDMODE_COMP (0 << BNDMODE_SHIFT) /* boundary compare mode */
  58. #define BNDMODE_ZERO (1 << BNDMODE_SHIFT) /* boundary compare and zero mode */
  59. #define BNDMODE_CAPT (2 << BNDMODE_SHIFT) /* boundary capture mode */
  60. #define BNDMODE_AEXT (3 << BNDMODE_SHIFT) /* boundary auto-extend mode */
  61. /* CNT_IMASK bitmasks */
  62. #define ICIE (1 << 0) /* Illegal Gray/Binary Code Interrupt Enable */
  63. #define UCIE (1 << 1) /* Up count Interrupt Enable */
  64. #define DCIE (1 << 2) /* Down count Interrupt Enable */
  65. #define MINCIE (1 << 3) /* Min Count Interrupt Enable */
  66. #define MAXCIE (1 << 4) /* Max Count Interrupt Enable */
  67. #define COV31IE (1 << 5) /* Bit 31 Overflow Interrupt Enable */
  68. #define COV15IE (1 << 6) /* Bit 15 Overflow Interrupt Enable */
  69. #define CZEROIE (1 << 7) /* Count to Zero Interrupt Enable */
  70. #define CZMIE (1 << 8) /* CZM Pin Interrupt Enable */
  71. #define CZMEIE (1 << 9) /* CZM Error Interrupt Enable */
  72. #define CZMZIE (1 << 10) /* CZM Zeroes Counter Interrupt Enable */
  73. /* CNT_STATUS bitmasks */
  74. #define ICII (1 << 0) /* Illegal Gray/Binary Code Interrupt Identifier */
  75. #define UCII (1 << 1) /* Up count Interrupt Identifier */
  76. #define DCII (1 << 2) /* Down count Interrupt Identifier */
  77. #define MINCII (1 << 3) /* Min Count Interrupt Identifier */
  78. #define MAXCII (1 << 4) /* Max Count Interrupt Identifier */
  79. #define COV31II (1 << 5) /* Bit 31 Overflow Interrupt Identifier */
  80. #define COV15II (1 << 6) /* Bit 15 Overflow Interrupt Identifier */
  81. #define CZEROII (1 << 7) /* Count to Zero Interrupt Identifier */
  82. #define CZMII (1 << 8) /* CZM Pin Interrupt Identifier */
  83. #define CZMEII (1 << 9) /* CZM Error Interrupt Identifier */
  84. #define CZMZII (1 << 10) /* CZM Zeroes Counter Interrupt Identifier */
  85. /* CNT_COMMAND bitmasks */
  86. #define W1LCNT 0xf /* Load Counter Register */
  87. #define W1LMIN 0xf0 /* Load Min Register */
  88. #define W1LMAX 0xf00 /* Load Max Register */
  89. #define W1ZMONCE (1 << 12) /* Enable CZM Clear Counter Once */
  90. #define W1LCNT_ZERO (1 << 0) /* write 1 to load CNT_COUNTER with zero */
  91. #define W1LCNT_MIN (1 << 2) /* write 1 to load CNT_COUNTER from CNT_MIN */
  92. #define W1LCNT_MAX (1 << 3) /* write 1 to load CNT_COUNTER from CNT_MAX */
  93. #define W1LMIN_ZERO (1 << 4) /* write 1 to load CNT_MIN with zero */
  94. #define W1LMIN_CNT (1 << 5) /* write 1 to load CNT_MIN from CNT_COUNTER */
  95. #define W1LMIN_MAX (1 << 7) /* write 1 to load CNT_MIN from CNT_MAX */
  96. #define W1LMAX_ZERO (1 << 8) /* write 1 to load CNT_MAX with zero */
  97. #define W1LMAX_CNT (1 << 9) /* write 1 to load CNT_MAX from CNT_COUNTER */
  98. #define W1LMAX_MIN (1 << 10) /* write 1 to load CNT_MAX from CNT_MIN */
  99. /* CNT_DEBOUNCE bitmasks */
  100. #define DPRESCALE 0xf /* Load Counter Register */
  101. #endif