blob: dac08b313324f63ff73e7bc88a11251655c91ab2 [file] [log] [blame]
Sreelakshmi Gownipalli75c91e12018-10-16 16:54:43 -07001/* Copyright (c) 2014-2016, 2018 The Linux Foundation. All rights reserved.
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -07002 *
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#ifndef DIAG_MUX_H
13#define DIAG_MUX_H
14#include "diagchar.h"
15
16struct diag_mux_state_t {
17 struct diag_logger_t *logger;
18 struct diag_logger_t *usb_ptr;
19 struct diag_logger_t *md_ptr;
Sreelakshmi Gownipalli75c91e12018-10-16 16:54:43 -070020 struct diag_logger_t *pcie_ptr;
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070021 unsigned int mux_mask;
22 unsigned int mode;
23};
24
25struct diag_mux_ops {
26 int (*open)(int id, int mode);
27 int (*close)(int id, int mode);
28 int (*read_done)(unsigned char *buf, int len, int id);
29 int (*write_done)(unsigned char *buf, int len, int buf_ctx,
30 int id);
31};
32
33#define DIAG_USB_MODE 0
34#define DIAG_MEMORY_DEVICE_MODE 1
35#define DIAG_NO_LOGGING_MODE 2
36#define DIAG_MULTI_MODE 3
Sreelakshmi Gownipalli75c91e12018-10-16 16:54:43 -070037#define DIAG_PCIE_MODE 4
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070038
39#define DIAG_MUX_LOCAL 0
40#define DIAG_MUX_LOCAL_LAST 1
41#define DIAG_MUX_BRIDGE_BASE DIAG_MUX_LOCAL_LAST
42#define DIAG_MUX_MDM (DIAG_MUX_BRIDGE_BASE)
43#define DIAG_MUX_MDM2 (DIAG_MUX_BRIDGE_BASE + 1)
44#define DIAG_MUX_SMUX (DIAG_MUX_BRIDGE_BASE + 2)
45#define DIAG_MUX_BRIDGE_LAST (DIAG_MUX_BRIDGE_BASE + 3)
46
47#ifndef CONFIG_DIAGFWD_BRIDGE_CODE
48#define NUM_MUX_PROC DIAG_MUX_LOCAL_LAST
49#else
50#define NUM_MUX_PROC DIAG_MUX_BRIDGE_LAST
51#endif
52
53struct diag_logger_ops {
54 void (*open)(void);
55 void (*close)(void);
56 int (*queue_read)(int id);
57 int (*write)(int id, unsigned char *buf, int len, int ctx);
58 int (*close_peripheral)(int id, uint8_t peripheral);
59};
60
61struct diag_logger_t {
62 int mode;
63 struct diag_mux_ops *ops[NUM_MUX_PROC];
64 struct diag_logger_ops *log_ops;
65};
66
67extern struct diag_mux_state_t *diag_mux;
68
69int diag_mux_init(void);
70void diag_mux_exit(void);
71int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops);
72int diag_mux_queue_read(int proc);
73int diag_mux_write(int proc, unsigned char *buf, int len, int ctx);
74int diag_mux_close_peripheral(int proc, uint8_t peripheral);
75int diag_mux_open_all(struct diag_logger_t *logger);
76int diag_mux_close_all(void);
77int diag_mux_switch_logging(int *new_mode, int *peripheral_mask);
Sreelakshmi Gownipalli75c91e12018-10-16 16:54:43 -070078int diag_pcie_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
79int diag_usb_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
80int diag_mux_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -070081#endif