1 /* Copyright (c) 2012, 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 13 #ifndef __WCD9310_SLIMSLAVE_H_ 14 #define __WCD9310_SLIMSLAVE_H_ 15 16 #include <linux/slimbus/slimbus.h> 17 #include <linux/mfd/wcd9xxx/core.h> 18 19 /* Channel numbers to be used for each port */ 20 enum { 21 SLIM_TX_1 = 128, 22 SLIM_TX_2 = 129, 23 SLIM_TX_3 = 130, 24 SLIM_TX_4 = 131, 25 SLIM_TX_5 = 132, 26 SLIM_TX_6 = 133, 27 SLIM_TX_7 = 134, 28 SLIM_TX_8 = 135, 29 SLIM_TX_9 = 136, 30 SLIM_TX_10 = 137, 31 SLIM_RX_1 = 138, 32 SLIM_RX_2 = 139, 33 SLIM_RX_3 = 140, 34 SLIM_RX_4 = 141, 35 SLIM_RX_5 = 142, 36 SLIM_RX_6 = 143, 37 SLIM_RX_7 = 144, 38 SLIM_MAX = 145 39 }; 40 41 /* 42 * client is expected to give port ids in the range of 43 * 1-10 for pre Taiko Tx ports and 1-16 for Taiko 44 * 1-7 for pre Taiko Rx ports and 1-16 for Tako, 45 * we need to add offset for getting the absolute slave 46 * port id before configuring the HW 47 */ 48 #define TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 10 49 #define TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 16 50 51 #define SLIM_MAX_TX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 52 53 #define TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \ 54 TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 55 #define TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \ 56 TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 57 58 #define TABLA_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 7 59 #define TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 13 60 61 #define SLIM_MAX_RX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 62 63 #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \ 64 TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS 65 #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \ 66 TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS 67 68 #define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16 69 #define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31 70 71 #define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9 72 #define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15 73 74 /* below details are taken from SLIMBUS slave SWI */ 75 #define SB_PGD_PORT_BASE 0x000 76 77 #define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \ 78 (SB_PGD_PORT_BASE + offset + (1 * port_num)) 79 80 #define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \ 81 (SB_PGD_PORT_BASE + 0x100 + 4*port_num) 82 #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID 0 83 #define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID 7 84 85 #define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \ 86 (SB_PGD_PORT_BASE + 0x101 + 4*port_num) 87 #define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID 8 88 89 #define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \ 90 (SB_PGD_PORT_BASE + offset + (4 * port_num)) 91 92 /* slave port water mark level 93 * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes) 94 */ 95 #define SLAVE_PORT_WATER_MARK_VALUE 2 96 #define SLAVE_PORT_WATER_MARK_SHIFT 1 97 #define SLAVE_PORT_ENABLE 1 98 #define SLAVE_PORT_DISABLE 0 99 100 #define BASE_CH_NUM 128 101 102 103 int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx, u8 wcd9xxx_pgd_la); 104 105 int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx); 106 107 int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx, unsigned int *ch_num, 108 unsigned int tot_ch, unsigned int rate); 109 int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx, unsigned int *ch_num, 110 unsigned int tot_ch, unsigned int rate); 111 int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx, unsigned int *ch_num, 112 unsigned int tot_ch); 113 int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx, unsigned int *ch_num, 114 unsigned int tot_ch); 115 int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx, 116 unsigned int *rx_ch, 117 unsigned int *tx_ch); 118 int wcd9xxx_get_slave_port(unsigned int ch_num); 119 int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx, unsigned int *ch_num, 120 unsigned int tot_ch, unsigned int rx_tx); 121 #endif /* __WCD9310_SLIMSLAVE_H_ */ 122