blob: 5132e43efad0896c48cfa4f0bc6ec401e77a7a88 [file] [log] [blame]
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301/* 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
Laxminath Kasam605b42f2017-08-01 22:02:15 +053013#ifndef __WCD9XXX_SLIMSLAVE_H_
14#define __WCD9XXX_SLIMSLAVE_H_
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053015
16#include <linux/slimbus/slimbus.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +053017#include "core.h"
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053018
19
20/*
21 * client is expected to give port ids in the range of
22 * 1-10 for pre Taiko Tx ports and 1-16 for Taiko
23 * 1-7 for pre Taiko Rx ports and 1-16 for Tako,
24 * we need to add offset for getting the absolute slave
25 * port id before configuring the HW
26 */
27#define TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 10
28#define TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS 16
29
30#define SLIM_MAX_TX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
31
32#define TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
33 TABLA_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
34#define TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS \
35 TAIKO_SB_PGD_MAX_NUMBER_OF_TX_SLAVE_DEV_PORTS
36
37#define TABLA_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 7
38#define TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS 13
39
40#define SLIM_MAX_RX_PORTS TAIKO_SB_PGD_MAX_NUMBER_OF_RX_SLAVE_DEV_PORTS
41
42#define SLIM_MAX_REG_ADDR (0x180 + 4 * (SLIM_MAX_RX_PORTS))
43
44#define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
45 TABLA_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
46#define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_START_PORT_ID \
47 TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS
48
49#define TABLA_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 16
50#define TAIKO_SB_PGD_RX_PORT_MULTI_CHANNEL_0_END_PORT_ID 31
51
52#define TABLA_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 9
53#define TAIKO_SB_PGD_TX_PORT_MULTI_CHANNEL_1_END_PORT_ID 15
54
55/* below details are taken from SLIMBUS slave SWI */
56#define SB_PGD_PORT_BASE 0x000
57
58#define SB_PGD_PORT_CFG_BYTE_ADDR(offset, port_num) \
59 (SB_PGD_PORT_BASE + offset + (1 * port_num))
60
61#define SB_PGD_TX_PORT_MULTI_CHANNEL_0(port_num) \
62 (SB_PGD_PORT_BASE + 0x100 + 4*port_num)
63#define SB_PGD_TX_PORT_MULTI_CHANNEL_0_START_PORT_ID 0
64#define SB_PGD_TX_PORT_MULTI_CHANNEL_0_END_PORT_ID 7
65
66#define SB_PGD_TX_PORT_MULTI_CHANNEL_1(port_num) \
67 (SB_PGD_PORT_BASE + 0x101 + 4*port_num)
68#define SB_PGD_TX_PORT_MULTI_CHANNEL_1_START_PORT_ID 8
69
70#define SB_PGD_RX_PORT_MULTI_CHANNEL_0(offset, port_num) \
71 (SB_PGD_PORT_BASE + offset + (4 * port_num))
72
73/* slave port water mark level
74 * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes)
75 */
76#define SLAVE_PORT_WATER_MARK_6BYTES 0
77#define SLAVE_PORT_WATER_MARK_9BYTES 1
78#define SLAVE_PORT_WATER_MARK_12BYTES 2
79#define SLAVE_PORT_WATER_MARK_15BYTES 3
80#define SLAVE_PORT_WATER_MARK_SHIFT 1
81#define SLAVE_PORT_ENABLE 1
82#define SLAVE_PORT_DISABLE 0
83#define WATER_MARK_VAL \
84 ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \
85 (SLAVE_PORT_ENABLE))
86#define BASE_CH_NUM 128
87
88
89int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx,
90 u8 wcd9xxx_pgd_la,
91 unsigned int tx_num, unsigned int *tx_slot,
92 unsigned int rx_num, unsigned int *rx_slot);
93
94int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx);
95
96int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
97 struct list_head *wcd9xxx_ch_list,
98 unsigned int rate, unsigned int bit_width,
99 u16 *grph);
100int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
101 struct list_head *wcd9xxx_ch_list,
102 unsigned int rate, unsigned int bit_width,
103 u16 *grph);
104int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
105 struct list_head *wcd9xxx_ch_list, u16 grph);
106int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
107 struct list_head *wcd9xxx_ch_list, u16 grph);
108int wcd9xxx_get_channel(struct wcd9xxx *wcd9xxx,
109 unsigned int *rx_ch,
110 unsigned int *tx_ch);
111int wcd9xxx_get_slave_port(unsigned int ch_num);
112int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
113 struct list_head *wcd9xxx_ch_list, u16 grph);
114int wcd9xxx_rx_vport_validation(u32 port_id,
115 struct list_head *codec_dai_list);
116int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
117 struct wcd9xxx_codec_dai_data *codec_dai,
118 u32 num_codec_dais);
Laxminath Kasam605b42f2017-08-01 22:02:15 +0530119#endif /* __WCD9XXX_SLIMSLAVE_H_ */