Hardik Arya | d6da1cb | 2017-11-23 20:40:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015, 2017 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 DIAGFWD_SMD_H |
| 14 | #define DIAGFWD_SMD_H |
| 15 | |
| 16 | #define DIAG_SMD_NAME_SZ 24 |
| 17 | #define SMD_DRAIN_BUF_SIZE 4096 |
| 18 | |
| 19 | struct diag_smd_info { |
| 20 | uint8_t peripheral; |
| 21 | uint8_t type; |
| 22 | uint8_t inited; |
| 23 | atomic_t opened; |
| 24 | atomic_t diag_state; |
| 25 | uint32_t fifo_size; |
| 26 | smd_channel_t *hdl; |
| 27 | char name[DIAG_SMD_NAME_SZ]; |
| 28 | struct mutex lock; |
| 29 | wait_queue_head_t read_wait_q; |
| 30 | struct workqueue_struct *wq; |
| 31 | struct work_struct open_work; |
| 32 | struct work_struct close_work; |
| 33 | struct work_struct read_work; |
| 34 | struct work_struct late_init_work; |
| 35 | struct diagfwd_info *fwd_ctxt; |
| 36 | }; |
| 37 | |
| 38 | extern struct diag_smd_info smd_data[NUM_PERIPHERALS]; |
| 39 | extern struct diag_smd_info smd_cntl[NUM_PERIPHERALS]; |
| 40 | extern struct diag_smd_info smd_dci[NUM_PERIPHERALS]; |
| 41 | extern struct diag_smd_info smd_cmd[NUM_PERIPHERALS]; |
| 42 | extern struct diag_smd_info smd_dci_cmd[NUM_PERIPHERALS]; |
| 43 | |
| 44 | int diag_smd_init_peripheral(uint8_t peripheral); |
| 45 | void diag_smd_exit(void); |
| 46 | int diag_smd_init(void); |
| 47 | void diag_smd_early_exit(void); |
| 48 | void diag_smd_invalidate(void *ctxt, struct diagfwd_info *fwd_ctxt); |
| 49 | int diag_smd_check_state(void *ctxt); |
| 50 | |
| 51 | #ifndef CONFIG_DIAG_USES_SMD |
| 52 | #define _diag_smd_exit(void) |
| 53 | #define _diag_smd_init(void) |
| 54 | #else |
| 55 | #define _diag_smd_exit(void) diag_smd_exit(void) |
| 56 | #define _diag_smd_init(void) diag_smd_init(void) |
| 57 | #endif |
| 58 | |
| 59 | #endif |