2 * Copyright (C) 2017, Lothar Waßmann <LW@KARO-electronics.de>
4 * SPDX-License-Identifier: GPL-2.0+
6 * based on: platform/msm_shared/include/smd.h
7 * from Android Little Kernel: https://github.com/littlekernel/lk
9 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * * Neither the name of The Linux Fundation, Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #define SMD_CHANNEL_ALLOC_MAX 2048
42 #define SMD_CHANNEL_NAME_SIZE_MAX 20
44 /* Stream related states */
45 #define SMD_SS_CLOSED 0x0 /* Closed: must be 0 */
46 #define SMD_SS_OPENING 0x1 /* Stream is opening */
47 #define SMD_SS_OPENED 0x2 /* Stream is opened */
48 #define SMD_SS_FLUSHING 0x3 /* Stream is flushing */
49 #define SMD_SS_CLOSING 0x4 /* Stream is closing */
50 #define SMD_SS_RESET 0x5 /* Stream is resetting */
51 #define SMD_SS_RESET_OPENING 0x6 /* Stream reset on local */
58 uint32_t stream_state;
63 uint32_t data_written;
65 uint32_t state_updated;
66 uint32_t mask_recv_intr;
69 } smd_shared_stream_info_type;
71 /* Each port has 2 FIFOs, one per direction */
73 char name[SMD_CHANNEL_NAME_SIZE_MAX];
77 } smd_channel_alloc_entry_t;
84 smd_protocol_type protocol;
86 smd_channel_type ch_type;
87 } smd_port_to_info_type;
98 smd_shared_stream_info_type ch0;
99 smd_shared_stream_info_type ch1;
100 } smd_port_ctrl_info;
103 smd_channel_alloc_entry_t alloc_entry;
107 smd_port_ctrl_info *port_info;
108 uint32_t current_state;
109 } smd_channel_info_t;
111 int smd_init(smd_channel_info_t *ch, uint32_t ch_type);
112 void smd_uninit(smd_channel_info_t *ch);
113 int smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type,
115 int smd_write(smd_channel_info_t *ch, const void *data, uint32_t len, int type);
116 void smd_signal_read_complete(smd_channel_info_t *ch, uint32_t len);
117 #endif /* __QCOM_SMD_H */