wcd9xxx-slimslave.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __WCD9310_SLIMSLAVE_H_
  13. #define __WCD9310_SLIMSLAVE_H_
  14. #include <linux/slimbus/slimbus.h>
  15. #include <linux/mfd/wcd9xxx/core.h>
  16. /*
  17. * client is expected to give port ids in the range of
  18. * 1-10 for pre Taiko Tx ports and 1-16 for Taiko
  19. * 1-7 for pre Taiko Rx ports and 1-16 for Tako,
  20. * we need to add offset for getting the absolute slave
  21. * port id before configuring the HW
  22. */
  23. #define TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 10
  24. #define TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 16
  25. #define SLIM_MAX_TX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  26. #define TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
  27. TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  28. #define TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
  29. TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  30. #define TABLA_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 7
  31. #define TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 13
  32. #define SLIM_MAX_RX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS
  33. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  34. TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  35. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  36. TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  37. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16
  38. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31
  39. #define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9
  40. #define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15
  41. /* below details are taken from SLIMBUS slave SWI */
  42. #define SB_PGD_PORT_BASE 0x000
  43. #define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \
  44. (SB_PGD_PORT_BASE + offset + (1 * port_num))
  45. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \
  46. (SB_PGD_PORT_BASE + 0x100 + 4*port_num)
  47. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID 0
  48. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID 7
  49. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \
  50. (SB_PGD_PORT_BASE + 0x101 + 4*port_num)
  51. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID 8
  52. #define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \
  53. (SB_PGD_PORT_BASE + offset + (4 * port_num))
  54. /* slave port water mark level
  55. * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
  56. */
  57. #define SLAVE_PORT_WATER_MARK_6BYTES 0
  58. #define SLAVE_PORT_WATER_MARK_9BYTES 1
  59. #define SLAVE_PORT_WATER_MARK_12BYTES 2
  60. #define SLAVE_PORT_WATER_MARK_15BYTES 3
  61. #define SLAVE_PORT_WATER_MARK_SHIFT 1
  62. #define SLAVE_PORT_ENABLE 1
  63. #define SLAVE_PORT_DISABLE 0
  64. #define WATER_MARK_VAL \
  65. ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
  66. (SLAVE_PORT_ENABLE))
  67. #define BASE_CH_NUM 128
  68. int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx,
  69. u8 wcd9xxx_pgd_la,
  70. unsigned int tx_num, unsigned int *tx_slot,
  71. unsigned int rx_num, unsigned int *rx_slot);
  72. int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx);
  73. int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  74. struct list_head *wcd9xxx_ch_list,
  75. unsigned int rate, unsigned int bit_width,
  76. u16 *grph);
  77. int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  78. struct list_head *wcd9xxx_ch_list,
  79. unsigned int rate, unsigned int bit_width,
  80. u16 *grph);
  81. int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  82. struct list_head *wcd9xxx_ch_list, u16 grph);
  83. int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  84. struct list_head *wcd9xxx_ch_list, u16 grph);
  85. int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx,
  86. unsigned int *rx_ch,
  87. unsigned int *tx_ch);
  88. int wcd9xxx_get_slave_port(unsigned int ch_num);
  89. int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
  90. struct list_head *wcd9xxx_ch_list, u16 grph);
  91. int wcd9xxx_rx_vport_validation(u32 port_id,
  92. struct list_head *codec_dai_list);
  93. int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
  94. struct wcd9xxx_codec_dai_data *codec_dai,
  95. u32 num_codec_dais);
  96. #endif /* __WCD9310_SLIMSLAVE_H_ */