blob: d79195c77c187ab5389d99bf468e02a217284745 [file] [log] [blame]
Dixon Petersonf2d449c2013-02-01 18:02:20 -08001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -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
13#ifndef DIAGFWD_CNTL_H
14#define DIAGFWD_CNTL_H
15
Shalabh Jainf50076b2012-02-15 19:27:01 -080016/* Message registration commands */
17#define DIAG_CTRL_MSG_REG 1
18/* Message passing for DTR events */
19#define DIAG_CTRL_MSG_DTR 2
20/* Control Diag sleep vote, buffering etc */
21#define DIAG_CTRL_MSG_DIAGMODE 3
22/* Diag data based on "light" diag mask */
23#define DIAG_CTRL_MSG_DIAGDATA 4
Shalabh Jainf50076b2012-02-15 19:27:01 -080024/* Send diag internal feature mask 'diag_int_feature_mask' */
25#define DIAG_CTRL_MSG_FEATURE 8
26/* Send Diag log mask for a particular equip id */
27#define DIAG_CTRL_MSG_EQUIP_LOG_MASK 9
28/* Send Diag event mask */
29#define DIAG_CTRL_MSG_EVENT_MASK_V2 10
30/* Send Diag F3 mask */
31#define DIAG_CTRL_MSG_F3_MASK_V2 11
Dixon Petersonbae1fe02013-05-07 19:42:55 -070032#define DIAG_CTRL_MSG_NUM_PRESETS 12
33#define DIAG_CTRL_MSG_SET_PRESET_ID 13
34#define DIAG_CTRL_MSG_LOG_MASK_WITH_PRESET_ID 14
35#define DIAG_CTRL_MSG_EVENT_MASK_WITH_PRESET_ID 15
36#define DIAG_CTRL_MSG_F3_MASK_WITH_PRESET_ID 16
37#define DIAG_CTRL_MSG_LAST DIAG_CTRL_MSG_F3_MASK_WITH_PRESET_ID
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038
Dixon Peterson2a49ad22013-04-24 17:10:39 -070039/* Denotes that we support sending/receiving the feature mask */
Dixon Peterson3ff84ea2012-12-21 20:16:18 -080040#define F_DIAG_INT_FEATURE_MASK 0x01
41/* Denotes that we support responding to "Log on Demand" */
42#define F_DIAG_LOG_ON_DEMAND_RSP_ON_MASTER 0x04
43/*
44 * Supports dedicated main request/response on
45 * new Data Rx and DCI Rx channels
46 */
47#define F_DIAG_REQ_RSP_CHANNEL 0x10
Dixon Peterson15a6ecb2013-06-25 12:36:33 -070048/* Denotes we support diag over stm */
49#define F_DIAG_OVER_STM 0x02
Dixon Peterson3ff84ea2012-12-21 20:16:18 -080050
Dixon Peterson9ce39c62013-02-21 13:00:52 -080051 /* Perform hdlc encoding of data coming from smd channel */
52#define F_DIAG_HDLC_ENCODE_IN_APPS_MASK 0x40
53
Dixon Peterson3ff84ea2012-12-21 20:16:18 -080054#define ENABLE_SEPARATE_CMDRSP 1
55#define DISABLE_SEPARATE_CMDRSP 0
Dixon Peterson2a49ad22013-04-24 17:10:39 -070056
Dixon Peterson15a6ecb2013-06-25 12:36:33 -070057#define ENABLE_STM 1
58#define DISABLE_STM 0
59
60#define UPDATE_PERIPHERAL_STM_STATE 1
61#define CLEAR_PERIPHERAL_STM_STATE 2
62
Dixon Peterson9ce39c62013-02-21 13:00:52 -080063#define ENABLE_APPS_HDLC_ENCODING 1
64#define DISABLE_APPS_HDLC_ENCODING 0
65
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066struct cmd_code_range {
67 uint16_t cmd_code_lo;
68 uint16_t cmd_code_hi;
69 uint32_t data;
70};
71
72struct diag_ctrl_msg {
73 uint32_t version;
74 uint16_t cmd_code;
75 uint16_t subsysid;
76 uint16_t count_entries;
77 uint16_t port;
78};
79
Shalabh Jain321c8b52012-02-22 12:37:06 -080080struct diag_ctrl_event_mask {
81 uint32_t cmd_type;
82 uint32_t data_len;
83 uint8_t stream_id;
84 uint8_t status;
85 uint8_t event_config;
86 uint32_t event_mask_size;
87 /* Copy event mask here */
88} __packed;
89
90struct diag_ctrl_log_mask {
91 uint32_t cmd_type;
92 uint32_t data_len;
93 uint8_t stream_id;
94 uint8_t status;
95 uint8_t equip_id;
96 uint32_t num_items; /* Last log code for this equip_id */
97 uint32_t log_mask_size; /* Size of log mask stored in log_mask[] */
98 /* Copy log mask here */
99} __packed;
100
101struct diag_ctrl_msg_mask {
102 uint32_t cmd_type;
103 uint32_t data_len;
104 uint8_t stream_id;
105 uint8_t status;
106 uint8_t msg_mode;
107 uint16_t ssid_first; /* Start of range of supported SSIDs */
108 uint16_t ssid_last; /* Last SSID in range */
109 uint32_t msg_mask_size; /* ssid_last - ssid_first + 1 */
110 /* Copy msg mask here */
111} __packed;
112
Ravi Aravamudhand09f8772012-12-20 14:48:30 -0800113struct diag_ctrl_feature_mask {
114 uint32_t ctrl_pkt_id;
115 uint32_t ctrl_pkt_data_len;
116 uint32_t feature_mask_len;
117 /* Copy feature mask here */
118} __packed;
119
Dixon Petersonf2d449c2013-02-01 18:02:20 -0800120struct diag_ctrl_msg_diagmode {
121 uint32_t ctrl_pkt_id;
122 uint32_t ctrl_pkt_data_len;
123 uint32_t version;
124 uint32_t sleep_vote;
125 uint32_t real_time;
126 uint32_t use_nrt_values;
127 uint32_t commit_threshold;
128 uint32_t sleep_threshold;
129 uint32_t sleep_time;
130 uint32_t drain_timer_val;
131 uint32_t event_stale_timer_val;
132} __packed;
133
Dixon Peterson15a6ecb2013-06-25 12:36:33 -0700134struct diag_ctrl_msg_stm {
135 uint32_t ctrl_pkt_id;
136 uint32_t ctrl_pkt_data_len;
137 uint32_t version;
138 uint8_t control_data;
139} __packed;
140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141void diagfwd_cntl_init(void);
142void diagfwd_cntl_exit(void);
143void diag_read_smd_cntl_work_fn(struct work_struct *);
Dixon Peterson3ff84ea2012-12-21 20:16:18 -0800144void diag_notify_ctrl_update_fn(struct work_struct *work);
Dixon Peterson66fb11b2012-12-04 20:30:54 -0800145void diag_clean_reg_fn(struct work_struct *work);
Dixon Peterson15a6ecb2013-06-25 12:36:33 -0700146void diag_cntl_smd_work_fn(struct work_struct *work);
Dixon Peterson66fb11b2012-12-04 20:30:54 -0800147int diag_process_smd_cntl_read_data(struct diag_smd_info *smd_info, void *buf,
148 int total_recd);
Dixon Petersonf2d449c2013-02-01 18:02:20 -0800149void diag_send_diag_mode_update_by_smd(struct diag_smd_info *smd_info,
150 int real_time);
Ravi Aravamudhan6a2da562013-06-17 16:01:34 -0700151void diag_update_proc_vote(uint16_t proc, uint8_t vote);
152void diag_update_real_time_vote(uint16_t proc, uint8_t real_time);
153void diag_real_time_work_fn(struct work_struct *work);
Dixon Peterson15a6ecb2013-06-25 12:36:33 -0700154int diag_send_stm_state(struct diag_smd_info *smd_info,
155 uint8_t stm_control_data);
156void diag_cntl_stm_notify(struct diag_smd_info *smd_info, int action);
157
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158#endif