wcd9xxx-slimslave.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* Copyright (c) 2012-2015, 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 __WCD9XXX_SLIMSLAVE_H_
  13. #define __WCD9XXX_SLIMSLAVE_H_
  14. #include <linux/slimbus/slimbus.h>
  15. #include "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 SLIM_MAX_REG_ADDR (0x180 + 4 * (SLIM_MAX_RX_PORTS))
  34. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  35. TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  36. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  37. TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  38. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16
  39. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31
  40. #define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9
  41. #define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15
  42. /* below details are taken from SLIMBUS slave SWI */
  43. #define SB_PGD_PORT_BASE 0x000
  44. #define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \
  45. (SB_PGD_PORT_BASE + offset + (1 * port_num))
  46. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \
  47. (SB_PGD_PORT_BASE + 0x100 + 4*port_num)
  48. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID 0
  49. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID 7
  50. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \
  51. (SB_PGD_PORT_BASE + 0x101 + 4*port_num)
  52. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID 8
  53. #define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \
  54. (SB_PGD_PORT_BASE + offset + (4 * port_num))
  55. /* slave port water mark level
  56. * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
  57. */
  58. #define SLAVE_PORT_WATER_MARK_6BYTES 0
  59. #define SLAVE_PORT_WATER_MARK_9BYTES 1
  60. #define SLAVE_PORT_WATER_MARK_12BYTES 2
  61. #define SLAVE_PORT_WATER_MARK_15BYTES 3
  62. #define SLAVE_PORT_WATER_MARK_SHIFT 1
  63. #define SLAVE_PORT_ENABLE 1
  64. #define SLAVE_PORT_DISABLE 0
  65. #define WATER_MARK_VAL \
  66. ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
  67. (SLAVE_PORT_ENABLE))
  68. #define BASE_CH_NUM 128
  69. int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx,
  70. u8 wcd9xxx_pgd_la,
  71. unsigned int tx_num, unsigned int *tx_slot,
  72. unsigned int rx_num, unsigned int *rx_slot);
  73. int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx);
  74. int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  75. struct list_head *wcd9xxx_ch_list,
  76. unsigned int rate, unsigned int bit_width,
  77. u16 *grph);
  78. int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  79. struct list_head *wcd9xxx_ch_list,
  80. unsigned int rate, unsigned int bit_width,
  81. u16 *grph);
  82. int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  83. struct list_head *wcd9xxx_ch_list, u16 grph);
  84. int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  85. struct list_head *wcd9xxx_ch_list, u16 grph);
  86. int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx,
  87. unsigned int *rx_ch,
  88. unsigned int *tx_ch);
  89. int wcd9xxx_get_slave_port(unsigned int ch_num);
  90. int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
  91. struct list_head *wcd9xxx_ch_list, u16 grph);
  92. int wcd9xxx_rx_vport_validation(u32 port_id,
  93. struct list_head *codec_dai_list);
  94. int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
  95. struct wcd9xxx_codec_dai_data *codec_dai,
  96. u32 num_codec_dais);
  97. #endif /* __WCD9XXX_SLIMSLAVE_H_ */