sib.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /****************************************************************************/
  2. /*
  3. * arch/arm/mach-l7200/include/mach/sib.h
  4. *
  5. * Registers and helper functions for the Serial Interface Bus.
  6. *
  7. * (C) Copyright 2000, S A McConnell (samcconn@cotw.com)
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file COPYING in the main directory of this archive for
  11. * more details.
  12. */
  13. /****************************************************************************/
  14. #define SIB_OFF 0x00040000 /* Offset from IO_START to the SIB reg's. */
  15. /* IO_START and IO_BASE are defined in hardware.h */
  16. #define SIB_START (IO_START + SIB_OFF) /* Physical addr of the SIB reg. */
  17. #define SIB_BASE (IO_BASE + SIB_OFF) /* Virtual addr of the SIB reg. */
  18. /* Offsets from the start of the SIB for all the registers. */
  19. /* Define the SIB registers for use by device drivers and the kernel. */
  20. typedef struct
  21. {
  22. unsigned int MCCR; /* SIB Control Register Offset: 0x00 */
  23. unsigned int RES1; /* Reserved Offset: 0x04 */
  24. unsigned int MCDR0; /* SIB Data Register 0 Offset: 0x08 */
  25. unsigned int MCDR1; /* SIB Data Register 1 Offset: 0x0c */
  26. unsigned int MCDR2; /* SIB Data Register 2 (UCB1x00) Offset: 0x10 */
  27. unsigned int RES2; /* Reserved Offset: 0x14 */
  28. unsigned int MCSR; /* SIB Status Register Offset: 0x18 */
  29. } SIB_Interface;
  30. #define SIB ((volatile SIB_Interface *) (SIB_BASE))
  31. /* MCCR */
  32. #define INTERNAL_FREQ 9216000 /* Hertz */
  33. #define AUDIO_FREQ 5000 /* Hertz */
  34. #define TELECOM_FREQ 5000 /* Hertz */
  35. #define AUDIO_DIVIDE (INTERNAL_FREQ / (32 * AUDIO_FREQ))
  36. #define TELECOM_DIVIDE (INTERNAL_FREQ / (32 * TELECOM_FREQ))
  37. #define MCCR_ASD57 AUDIO_DIVIDE
  38. #define MCCR_TSD57 (TELECOM_DIVIDE << 8)
  39. #define MCCR_MCE (1 << 16) /* SIB enable */
  40. #define MCCR_ECS (1 << 17) /* External Clock Select */
  41. #define MCCR_ADM (1 << 18) /* A/D Data Sampling */
  42. #define MCCR_PMC (1 << 26) /* PIN Multiplexer Control */
  43. #define GET_ASD ((SIB->MCCR >> 0) & 0x3f) /* Audio Sample Rate Div. */
  44. #define GET_TSD ((SIB->MCCR >> 8) & 0x3f) /* Telcom Sample Rate Div. */
  45. #define GET_MCE ((SIB->MCCR >> 16) & 0x01) /* SIB Enable */
  46. #define GET_ECS ((SIB->MCCR >> 17) & 0x01) /* External Clock Select */
  47. #define GET_ADM ((SIB->MCCR >> 18) & 0x01) /* A/D Data Sampling Mode */
  48. #define GET_TTM ((SIB->MCCR >> 19) & 0x01) /* Telco Trans. FIFO I mask */
  49. #define GET_TRM ((SIB->MCCR >> 20) & 0x01) /* Telco Recv. FIFO I mask */
  50. #define GET_ATM ((SIB->MCCR >> 21) & 0x01) /* Audio Trans. FIFO I mask */
  51. #define GET_ARM ((SIB->MCCR >> 22) & 0x01) /* Audio Recv. FIFO I mask */
  52. #define GET_LBM ((SIB->MCCR >> 23) & 0x01) /* Loop Back Mode */
  53. #define GET_ECP ((SIB->MCCR >> 24) & 0x03) /* Extern. Clck Prescale sel */
  54. #define GET_PMC ((SIB->MCCR >> 26) & 0x01) /* PIN Multiplexer Control */
  55. #define GET_ERI ((SIB->MCCR >> 27) & 0x01) /* External Read Interrupt */
  56. #define GET_EWI ((SIB->MCCR >> 28) & 0x01) /* External Write Interrupt */
  57. /* MCDR0 */
  58. #define AUDIO_RECV ((SIB->MCDR0 >> 4) & 0xfff)
  59. #define AUDIO_WRITE(v) ((SIB->MCDR0 = (v & 0xfff) << 4))
  60. /* MCDR1 */
  61. #define TELECOM_RECV ((SIB->MCDR1 >> 2) & 032fff)
  62. #define TELECOM_WRITE(v) ((SIB->MCDR1 = (v & 0x3fff) << 2))
  63. /* MCSR */
  64. #define MCSR_ATU (1 << 4) /* Audio Transmit FIFO Underrun */
  65. #define MCSR_ARO (1 << 5) /* Audio Receive FIFO Underrun */
  66. #define MCSR_TTU (1 << 6) /* TELECOM Transmit FIFO Underrun */
  67. #define MCSR_TRO (1 << 7) /* TELECOM Receive FIFO Underrun */
  68. #define MCSR_CLEAR_UNDERUN_BITS (MCSR_ATU | MCSR_ARO | MCSR_TTU | MCSR_TRO)
  69. #define GET_ATS ((SIB->MCSR >> 0) & 0x01) /* Audio Transmit FIFO Service Req*/
  70. #define GET_ARS ((SIB->MCSR >> 1) & 0x01) /* Audio Recv FIFO Service Request*/
  71. #define GET_TTS ((SIB->MCSR >> 2) & 0x01) /* TELECOM Transmit FIFO Flag */
  72. #define GET_TRS ((SIB->MCSR >> 3) & 0x01) /* TELECOM Recv FIFO Service Req. */
  73. #define GET_ATU ((SIB->MCSR >> 4) & 0x01) /* Audio Transmit FIFO Underrun */
  74. #define GET_ARO ((SIB->MCSR >> 5) & 0x01) /* Audio Receive FIFO Underrun */
  75. #define GET_TTU ((SIB->MCSR >> 6) & 0x01) /* TELECOM Transmit FIFO Underrun */
  76. #define GET_TRO ((SIB->MCSR >> 7) & 0x01) /* TELECOM Receive FIFO Underrun */
  77. #define GET_ANF ((SIB->MCSR >> 8) & 0x01) /* Audio Transmit FIFO not full */
  78. #define GET_ANE ((SIB->MCSR >> 9) & 0x01) /* Audio Receive FIFO not empty */
  79. #define GET_TNF ((SIB->MCSR >> 10) & 0x01) /* Telecom Transmit FIFO not full */
  80. #define GET_TNE ((SIB->MCSR >> 11) & 0x01) /* Telecom Receive FIFO not empty */
  81. #define GET_CWC ((SIB->MCSR >> 12) & 0x01) /* Codec Write Complete */
  82. #define GET_CRC ((SIB->MCSR >> 13) & 0x01) /* Codec Read Complete */
  83. #define GET_ACE ((SIB->MCSR >> 14) & 0x01) /* Audio Codec Enabled */
  84. #define GET_TCE ((SIB->MCSR >> 15) & 0x01) /* Telecom Codec Enabled */
  85. /* MCDR2 */
  86. #define MCDR2_rW (1 << 16)
  87. #define WRITE_MCDR2(reg, data) (SIB->MCDR2 =((reg<<17)|MCDR2_rW|(data&0xffff)))
  88. #define MCDR2_WRITE_COMPLETE GET_CWC
  89. #define INITIATE_MCDR2_READ(reg) (SIB->MCDR2 = (reg << 17))
  90. #define MCDR2_READ_COMPLETE GET_CRC
  91. #define MCDR2_READ (SIB->MCDR2 & 0xffff)