Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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_CNTL_H |
| 14 | #define DIAGFWD_CNTL_H |
| 15 | |
Shalabh Jain | f50076b | 2012-02-15 19:27:01 -0800 | [diff] [blame] | 16 | /* 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 Jain | f50076b | 2012-02-15 19:27:01 -0800 | [diff] [blame] | 24 | /* 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 Peterson | bae1fe0 | 2013-05-07 19:42:55 -0700 | [diff] [blame] | 32 | #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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | |
Dixon Peterson | 2a49ad2 | 2013-04-24 17:10:39 -0700 | [diff] [blame] | 39 | /* Denotes that we support sending/receiving the feature mask */ |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 40 | #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 Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 48 | /* Denotes we support diag over stm */ |
| 49 | #define F_DIAG_OVER_STM 0x02 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 50 | |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 51 | /* Perform hdlc encoding of data coming from smd channel */ |
| 52 | #define F_DIAG_HDLC_ENCODE_IN_APPS_MASK 0x40 |
| 53 | |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 54 | #define ENABLE_SEPARATE_CMDRSP 1 |
| 55 | #define DISABLE_SEPARATE_CMDRSP 0 |
Dixon Peterson | 2a49ad2 | 2013-04-24 17:10:39 -0700 | [diff] [blame] | 56 | |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 57 | #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 Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 63 | #define ENABLE_APPS_HDLC_ENCODING 1 |
| 64 | #define DISABLE_APPS_HDLC_ENCODING 0 |
| 65 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 66 | struct cmd_code_range { |
| 67 | uint16_t cmd_code_lo; |
| 68 | uint16_t cmd_code_hi; |
| 69 | uint32_t data; |
| 70 | }; |
| 71 | |
| 72 | struct 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 Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 80 | struct 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 | |
| 90 | struct 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 | |
| 101 | struct 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 Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 113 | struct 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 Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 120 | struct 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 Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 134 | struct 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 141 | void diagfwd_cntl_init(void); |
| 142 | void diagfwd_cntl_exit(void); |
| 143 | void diag_read_smd_cntl_work_fn(struct work_struct *); |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 144 | void diag_notify_ctrl_update_fn(struct work_struct *work); |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 145 | void diag_clean_reg_fn(struct work_struct *work); |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 146 | void diag_cntl_smd_work_fn(struct work_struct *work); |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 147 | int diag_process_smd_cntl_read_data(struct diag_smd_info *smd_info, void *buf, |
| 148 | int total_recd); |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 149 | void diag_send_diag_mode_update_by_smd(struct diag_smd_info *smd_info, |
| 150 | int real_time); |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 151 | void diag_update_proc_vote(uint16_t proc, uint8_t vote); |
| 152 | void diag_update_real_time_vote(uint16_t proc, uint8_t real_time); |
| 153 | void diag_real_time_work_fn(struct work_struct *work); |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 154 | int diag_send_stm_state(struct diag_smd_info *smd_info, |
| 155 | uint8_t stm_control_data); |
| 156 | void diag_cntl_stm_notify(struct diag_smd_info *smd_info, int action); |
| 157 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 158 | #endif |