qe_tdm.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Internal header file for QE TDM mode routines.
  3. *
  4. * Copyright (C) 2016 Freescale Semiconductor, Inc. All rights reserved.
  5. *
  6. * Authors: Zhao Qiang <qiang.zhao@nxp.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version
  12. */
  13. #ifndef _QE_TDM_H_
  14. #define _QE_TDM_H_
  15. #include <linux/kernel.h>
  16. #include <linux/list.h>
  17. #include <soc/fsl/qe/immap_qe.h>
  18. #include <soc/fsl/qe/qe.h>
  19. #include <soc/fsl/qe/ucc.h>
  20. #include <soc/fsl/qe/ucc_fast.h>
  21. /* SI RAM entries */
  22. #define SIR_LAST 0x0001
  23. #define SIR_BYTE 0x0002
  24. #define SIR_CNT(x) ((x) << 2)
  25. #define SIR_CSEL(x) ((x) << 5)
  26. #define SIR_SGS 0x0200
  27. #define SIR_SWTR 0x4000
  28. #define SIR_MCC 0x8000
  29. #define SIR_IDLE 0
  30. /* SIxMR fields */
  31. #define SIMR_SAD(x) ((x) << 12)
  32. #define SIMR_SDM_NORMAL 0x0000
  33. #define SIMR_SDM_INTERNAL_LOOPBACK 0x0800
  34. #define SIMR_SDM_MASK 0x0c00
  35. #define SIMR_CRT 0x0040
  36. #define SIMR_SL 0x0020
  37. #define SIMR_CE 0x0010
  38. #define SIMR_FE 0x0008
  39. #define SIMR_GM 0x0004
  40. #define SIMR_TFSD(n) (n)
  41. #define SIMR_RFSD(n) ((n) << 8)
  42. enum tdm_ts_t {
  43. TDM_TX_TS,
  44. TDM_RX_TS
  45. };
  46. enum tdm_framer_t {
  47. TDM_FRAMER_T1,
  48. TDM_FRAMER_E1
  49. };
  50. enum tdm_mode_t {
  51. TDM_INTERNAL_LOOPBACK,
  52. TDM_NORMAL
  53. };
  54. struct si_mode_info {
  55. u8 simr_rfsd;
  56. u8 simr_tfsd;
  57. u8 simr_crt;
  58. u8 simr_sl;
  59. u8 simr_ce;
  60. u8 simr_fe;
  61. u8 simr_gm;
  62. };
  63. struct ucc_tdm_info {
  64. struct ucc_fast_info uf_info;
  65. struct si_mode_info si_info;
  66. };
  67. struct ucc_tdm {
  68. u16 tdm_port; /* port for this tdm:TDMA,TDMB */
  69. u32 siram_entry_id;
  70. u16 __iomem *siram;
  71. struct si1 __iomem *si_regs;
  72. enum tdm_framer_t tdm_framer_type;
  73. enum tdm_mode_t tdm_mode;
  74. u8 num_of_ts; /* the number of timeslots in this tdm frame */
  75. u32 tx_ts_mask; /* tx time slot mask */
  76. u32 rx_ts_mask; /* rx time slot mask */
  77. };
  78. int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
  79. struct ucc_tdm_info *ut_info);
  80. void ucc_tdm_init(struct ucc_tdm *utdm, struct ucc_tdm_info *ut_info);
  81. #endif