at91_adc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * arch/arm/mach-at91/include/mach/at91_adc.h
  3. *
  4. * Copyright (C) SAN People
  5. *
  6. * Analog-to-Digital Converter (ADC) registers.
  7. * Based on AT91SAM9260 datasheet revision D.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. */
  14. #ifndef AT91_ADC_H
  15. #define AT91_ADC_H
  16. #define AT91_ADC_CR 0x00 /* Control Register */
  17. #define AT91_ADC_SWRST (1 << 0) /* Software Reset */
  18. #define AT91_ADC_START (1 << 1) /* Start Conversion */
  19. #define AT91_ADC_MR 0x04 /* Mode Register */
  20. #define AT91_ADC_TRGEN (1 << 0) /* Trigger Enable */
  21. #define AT91_ADC_TRGSEL (7 << 1) /* Trigger Selection */
  22. #define AT91_ADC_TRGSEL_TC0 (0 << 1)
  23. #define AT91_ADC_TRGSEL_TC1 (1 << 1)
  24. #define AT91_ADC_TRGSEL_TC2 (2 << 1)
  25. #define AT91_ADC_TRGSEL_EXTERNAL (6 << 1)
  26. #define AT91_ADC_LOWRES (1 << 4) /* Low Resolution */
  27. #define AT91_ADC_SLEEP (1 << 5) /* Sleep Mode */
  28. #define AT91_ADC_PRESCAL_9260 (0x3f << 8) /* Prescalar Rate Selection */
  29. #define AT91_ADC_PRESCAL_9G45 (0xff << 8)
  30. #define AT91_ADC_PRESCAL_(x) ((x) << 8)
  31. #define AT91_ADC_STARTUP_9260 (0x1f << 16) /* Startup Up Time */
  32. #define AT91_ADC_STARTUP_9G45 (0x7f << 16)
  33. #define AT91_ADC_STARTUP_9X5 (0xf << 16)
  34. #define AT91_ADC_STARTUP_(x) ((x) << 16)
  35. #define AT91_ADC_SHTIM (0xf << 24) /* Sample & Hold Time */
  36. #define AT91_ADC_SHTIM_(x) ((x) << 24)
  37. #define AT91_ADC_CHER 0x10 /* Channel Enable Register */
  38. #define AT91_ADC_CHDR 0x14 /* Channel Disable Register */
  39. #define AT91_ADC_CHSR 0x18 /* Channel Status Register */
  40. #define AT91_ADC_CH(n) (1 << (n)) /* Channel Number */
  41. #define AT91_ADC_SR 0x1C /* Status Register */
  42. #define AT91_ADC_EOC(n) (1 << (n)) /* End of Conversion on Channel N */
  43. #define AT91_ADC_OVRE(n) (1 << ((n) + 8))/* Overrun Error on Channel N */
  44. #define AT91_ADC_DRDY (1 << 16) /* Data Ready */
  45. #define AT91_ADC_GOVRE (1 << 17) /* General Overrun Error */
  46. #define AT91_ADC_ENDRX (1 << 18) /* End of RX Buffer */
  47. #define AT91_ADC_RXFUFF (1 << 19) /* RX Buffer Full */
  48. #define AT91_ADC_SR_9X5 0x30 /* Status Register for 9x5 */
  49. #define AT91_ADC_SR_DRDY_9X5 (1 << 24) /* Data Ready */
  50. #define AT91_ADC_LCDR 0x20 /* Last Converted Data Register */
  51. #define AT91_ADC_LDATA (0x3ff)
  52. #define AT91_ADC_IER 0x24 /* Interrupt Enable Register */
  53. #define AT91_ADC_IDR 0x28 /* Interrupt Disable Register */
  54. #define AT91_ADC_IMR 0x2C /* Interrupt Mask Register */
  55. #define AT91_ADC_IER_PEN (1 << 29)
  56. #define AT91_ADC_IER_NOPEN (1 << 30)
  57. #define AT91_ADC_IER_XRDY (1 << 20)
  58. #define AT91_ADC_IER_YRDY (1 << 21)
  59. #define AT91_ADC_IER_PRDY (1 << 22)
  60. #define AT91_ADC_ISR_PENS (1 << 31)
  61. #define AT91_ADC_CHR(n) (0x30 + ((n) * 4)) /* Channel Data Register N */
  62. #define AT91_ADC_DATA (0x3ff)
  63. #define AT91_ADC_CDR0_9X5 (0x50) /* Channel Data Register 0 for 9X5 */
  64. #define AT91_ADC_ACR 0x94 /* Analog Control Register */
  65. #define AT91_ADC_ACR_PENDETSENS (0x3 << 0) /* pull-up resistor */
  66. #define AT91_ADC_TSMR 0xB0
  67. #define AT91_ADC_TSMR_TSMODE (3 << 0) /* Touch Screen Mode */
  68. #define AT91_ADC_TSMR_TSMODE_NONE (0 << 0)
  69. #define AT91_ADC_TSMR_TSMODE_4WIRE_NO_PRESS (1 << 0)
  70. #define AT91_ADC_TSMR_TSMODE_4WIRE_PRESS (2 << 0)
  71. #define AT91_ADC_TSMR_TSMODE_5WIRE (3 << 0)
  72. #define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
  73. #define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
  74. #define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
  75. #define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
  76. #define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
  77. #define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
  78. #define AT91_ADC_TSMR_PENDET_DIS (0 << 24) /* Pen contact detection disable */
  79. #define AT91_ADC_TSMR_PENDET_ENA (1 << 24) /* Pen contact detection enable */
  80. #define AT91_ADC_TSXPOSR 0xB4
  81. #define AT91_ADC_TSYPOSR 0xB8
  82. #define AT91_ADC_TSPRESSR 0xBC
  83. #define AT91_ADC_TRGR_9260 AT91_ADC_MR
  84. #define AT91_ADC_TRGR_9G45 0x08
  85. #define AT91_ADC_TRGR_9X5 0xC0
  86. /* Trigger Register bit field */
  87. #define AT91_ADC_TRGR_TRGPER (0xffff << 16)
  88. #define AT91_ADC_TRGR_TRGPER_(x) ((x) << 16)
  89. #define AT91_ADC_TRGR_TRGMOD (0x7 << 0)
  90. #define AT91_ADC_TRGR_MOD_PERIOD_TRIG (5 << 0)
  91. #endif