wcd9xxx-slimslave.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef __WCD9XXX_SLIMSLAVE_H_
  5. #define __WCD9XXX_SLIMSLAVE_H_
  6. #include <linux/slimbus/slimbus.h>
  7. #include "core.h"
  8. /*
  9. * client is expected to give port ids in the range of
  10. * 1-10 for pre Taiko Tx ports and 1-16 for Taiko
  11. * 1-7 for pre Taiko Rx ports and 1-16 for Tako,
  12. * we need to add offset for getting the absolute slave
  13. * port id before configuring the HW
  14. */
  15. #define TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 10
  16. #define TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 16
  17. #define SLIM_MAX_TX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  18. #define TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
  19. TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  20. #define TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
  21. TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
  22. #define TABLA_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 7
  23. #define TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 13
  24. #define SLIM_MAX_RX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS
  25. #define SLIM_MAX_REG_ADDR (0x180 + 4 * (SLIM_MAX_RX_PORTS))
  26. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  27. TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  28. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
  29. TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
  30. #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16
  31. #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31
  32. #define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9
  33. #define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15
  34. /* below details are taken from SLIMBUS slave SWI */
  35. #define SB_PGD_PORT_BASE 0x000
  36. #define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \
  37. (SB_PGD_PORT_BASE + offset + (1 * port_num))
  38. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \
  39. (SB_PGD_PORT_BASE + 0x100 + 4*port_num)
  40. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID 0
  41. #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID 7
  42. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \
  43. (SB_PGD_PORT_BASE + 0x101 + 4*port_num)
  44. #define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID 8
  45. #define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \
  46. (SB_PGD_PORT_BASE + offset + (4 * port_num))
  47. /* slave port water mark level
  48. * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
  49. */
  50. #define SLAVE_PORT_WATER_MARK_6BYTES 0
  51. #define SLAVE_PORT_WATER_MARK_9BYTES 1
  52. #define SLAVE_PORT_WATER_MARK_12BYTES 2
  53. #define SLAVE_PORT_WATER_MARK_15BYTES 3
  54. #define SLAVE_PORT_WATER_MARK_SHIFT 1
  55. #define SLAVE_PORT_ENABLE 1
  56. #define SLAVE_PORT_DISABLE 0
  57. #define WATER_MARK_VAL \
  58. ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
  59. (SLAVE_PORT_ENABLE))
  60. #define BASE_CH_NUM 128
  61. int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx,
  62. u8 wcd9xxx_pgd_la,
  63. unsigned int tx_num, unsigned int *tx_slot,
  64. unsigned int rx_num, unsigned int *rx_slot);
  65. int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx);
  66. int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  67. struct list_head *wcd9xxx_ch_list,
  68. unsigned int rate, unsigned int bit_width,
  69. u16 *grph);
  70. int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  71. struct list_head *wcd9xxx_ch_list,
  72. unsigned int rate, unsigned int bit_width,
  73. u16 *grph);
  74. int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  75. struct list_head *wcd9xxx_ch_list, u16 grph);
  76. int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  77. struct list_head *wcd9xxx_ch_list, u16 grph);
  78. int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx,
  79. unsigned int *rx_ch,
  80. unsigned int *tx_ch);
  81. int wcd9xxx_get_slave_port(unsigned int ch_num);
  82. int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
  83. struct list_head *wcd9xxx_ch_list, u16 grph);
  84. int wcd9xxx_rx_vport_validation(u32 port_id,
  85. struct list_head *codec_dai_list);
  86. int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
  87. struct wcd9xxx_codec_dai_data *codec_dai,
  88. u32 num_codec_dais);
  89. #endif /* __WCD9XXX_SLIMSLAVE_H_ */