Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Intel Management Engine Interface (Intel MEI) Linux driver |
Tomas Winkler | 733ba91 | 2012-02-09 19:25:53 +0200 | [diff] [blame] | 4 | * Copyright (c) 2003-2012, Intel Corporation. |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef _MEI_DEV_H_ |
| 18 | #define _MEI_DEV_H_ |
| 19 | |
| 20 | #include <linux/types.h> |
Oren Weil | 9ce178e | 2011-09-07 09:03:09 +0300 | [diff] [blame] | 21 | #include <linux/watchdog.h> |
Tomas Winkler | 4f3afe1 | 2012-05-09 16:38:59 +0300 | [diff] [blame] | 22 | #include <linux/mei.h> |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 23 | #include "hw.h" |
| 24 | |
| 25 | /* |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 26 | * watch dog definition |
| 27 | */ |
| 28 | #define MEI_WATCHDOG_DATA_SIZE 16 |
| 29 | #define MEI_START_WD_DATA_SIZE 20 |
| 30 | #define MEI_WD_PARAMS_SIZE 4 |
| 31 | #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) |
| 32 | |
Tomas Winkler | edf1eed | 2012-02-09 19:25:54 +0200 | [diff] [blame] | 33 | #define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32)) |
| 34 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 35 | /* |
Oren Weil | 4a3cafd | 2011-09-07 09:03:10 +0300 | [diff] [blame] | 36 | * MEI PCI Device object |
| 37 | */ |
| 38 | extern struct pci_dev *mei_device; |
| 39 | |
Oren Weil | 9ce178e | 2011-09-07 09:03:09 +0300 | [diff] [blame] | 40 | |
| 41 | /* |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 42 | * AMTHI Client UUID |
| 43 | */ |
| 44 | extern const uuid_le mei_amthi_guid; |
| 45 | |
| 46 | /* |
| 47 | * Watchdog Client UUID |
| 48 | */ |
| 49 | extern const uuid_le mei_wd_guid; |
| 50 | |
| 51 | /* |
| 52 | * Watchdog independence state message |
| 53 | */ |
| 54 | extern const u8 mei_wd_state_independence_msg[3][4]; |
| 55 | |
| 56 | /* |
| 57 | * Number of File descriptors/handles |
| 58 | * that can be opened to the driver. |
| 59 | * |
| 60 | * Limit to 253: 255 Total Clients |
| 61 | * minus internal client for AMTHI |
| 62 | * minus internal client for Watchdog |
| 63 | */ |
| 64 | #define MEI_MAX_OPEN_HANDLE_COUNT 253 |
| 65 | |
| 66 | /* |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 67 | * Number of Maximum MEI Clients |
| 68 | */ |
| 69 | #define MEI_CLIENTS_MAX 255 |
| 70 | |
| 71 | /* File state */ |
| 72 | enum file_state { |
| 73 | MEI_FILE_INITIALIZING = 0, |
| 74 | MEI_FILE_CONNECTING, |
| 75 | MEI_FILE_CONNECTED, |
| 76 | MEI_FILE_DISCONNECTING, |
| 77 | MEI_FILE_DISCONNECTED |
| 78 | }; |
| 79 | |
| 80 | /* MEI device states */ |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 81 | enum mei_dev_state { |
| 82 | MEI_DEV_INITIALIZING = 0, |
| 83 | MEI_DEV_INIT_CLIENTS, |
| 84 | MEI_DEV_ENABLED, |
| 85 | MEI_DEV_RESETING, |
| 86 | MEI_DEV_DISABLED, |
| 87 | MEI_DEV_RECOVERING_FROM_RESET, |
| 88 | MEI_DEV_POWER_DOWN, |
| 89 | MEI_DEV_POWER_UP |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 90 | }; |
| 91 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 92 | const char *mei_dev_state_str(int state); |
| 93 | |
Justin P. Mattock | 5f9092f3 | 2012-03-12 07:18:09 -0700 | [diff] [blame] | 94 | /* init clients states*/ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 95 | enum mei_init_clients_states { |
| 96 | MEI_START_MESSAGE = 0, |
| 97 | MEI_ENUM_CLIENTS_MESSAGE, |
| 98 | MEI_CLIENT_PROPERTIES_MESSAGE |
| 99 | }; |
| 100 | |
| 101 | enum iamthif_states { |
| 102 | MEI_IAMTHIF_IDLE, |
| 103 | MEI_IAMTHIF_WRITING, |
| 104 | MEI_IAMTHIF_FLOW_CONTROL, |
| 105 | MEI_IAMTHIF_READING, |
| 106 | MEI_IAMTHIF_READ_COMPLETE |
| 107 | }; |
| 108 | |
| 109 | enum mei_file_transaction_states { |
| 110 | MEI_IDLE, |
| 111 | MEI_WRITING, |
| 112 | MEI_WRITE_COMPLETE, |
| 113 | MEI_FLOW_CONTROL, |
| 114 | MEI_READING, |
| 115 | MEI_READ_COMPLETE |
| 116 | }; |
| 117 | |
| 118 | /* MEI CB */ |
| 119 | enum mei_cb_major_types { |
| 120 | MEI_READ = 0, |
| 121 | MEI_WRITE, |
| 122 | MEI_IOCTL, |
| 123 | MEI_OPEN, |
| 124 | MEI_CLOSE |
| 125 | }; |
| 126 | |
| 127 | /* |
| 128 | * Intel MEI message data struct |
| 129 | */ |
| 130 | struct mei_message_data { |
| 131 | u32 size; |
Tomas Winkler | edf1eed | 2012-02-09 19:25:54 +0200 | [diff] [blame] | 132 | unsigned char *data; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 133 | } __packed; |
| 134 | |
| 135 | |
| 136 | struct mei_cl_cb { |
| 137 | struct list_head cb_list; |
| 138 | enum mei_cb_major_types major_file_operations; |
| 139 | void *file_private; |
| 140 | struct mei_message_data request_buffer; |
| 141 | struct mei_message_data response_buffer; |
| 142 | unsigned long information; |
| 143 | unsigned long read_time; |
| 144 | struct file *file_object; |
| 145 | }; |
| 146 | |
| 147 | /* MEI client instance carried as file->pirvate_data*/ |
| 148 | struct mei_cl { |
| 149 | struct list_head link; |
| 150 | struct mei_device *dev; |
| 151 | enum file_state state; |
| 152 | wait_queue_head_t tx_wait; |
| 153 | wait_queue_head_t rx_wait; |
| 154 | wait_queue_head_t wait; |
| 155 | int read_pending; |
| 156 | int status; |
| 157 | /* ID of client connected */ |
| 158 | u8 host_client_id; |
| 159 | u8 me_client_id; |
| 160 | u8 mei_flow_ctrl_creds; |
| 161 | u8 timer_count; |
| 162 | enum mei_file_transaction_states reading_state; |
| 163 | enum mei_file_transaction_states writing_state; |
| 164 | int sm_state; |
| 165 | struct mei_cl_cb *read_cb; |
| 166 | }; |
| 167 | |
| 168 | struct mei_io_list { |
| 169 | struct mei_cl_cb mei_cb; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 170 | }; |
| 171 | |
Tomas Winkler | 24aadc8 | 2012-06-25 23:46:27 +0300 | [diff] [blame] | 172 | /** |
| 173 | * struct mei_deive - MEI private device struct |
| 174 | * @hbuf_depth - depth of host(write) buffer |
| 175 | */ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 176 | struct mei_device { |
| 177 | struct pci_dev *pdev; /* pointer to pci device struct */ |
| 178 | /* |
| 179 | * lists of queues |
| 180 | */ |
| 181 | /* array of pointers to aio lists */ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 182 | struct mei_io_list read_list; /* driver read queue */ |
| 183 | struct mei_io_list write_list; /* driver write queue */ |
| 184 | struct mei_io_list write_waiting_list; /* write waiting queue */ |
| 185 | struct mei_io_list ctrl_wr_list; /* managed write IOCTL list */ |
| 186 | struct mei_io_list ctrl_rd_list; /* managed read IOCTL list */ |
| 187 | struct mei_io_list amthi_cmd_list; /* amthi list for cmd waiting */ |
| 188 | |
| 189 | /* driver managed amthi list for reading completed amthi cmd data */ |
| 190 | struct mei_io_list amthi_read_complete_list; |
| 191 | /* |
| 192 | * list of files |
| 193 | */ |
| 194 | struct list_head file_list; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 195 | long open_handle_count; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 196 | /* |
| 197 | * memory of device |
| 198 | */ |
| 199 | unsigned int mem_base; |
| 200 | unsigned int mem_length; |
| 201 | void __iomem *mem_addr; |
| 202 | /* |
| 203 | * lock for the device |
| 204 | */ |
| 205 | struct mutex device_lock; /* device lock */ |
Oren Weil | a61c653 | 2011-09-07 09:03:13 +0300 | [diff] [blame] | 206 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 207 | bool recvd_msg; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 208 | /* |
| 209 | * hw states of host and fw(ME) |
| 210 | */ |
| 211 | u32 host_hw_state; |
| 212 | u32 me_hw_state; |
Tomas Winkler | 24aadc8 | 2012-06-25 23:46:27 +0300 | [diff] [blame] | 213 | u8 hbuf_depth; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 214 | /* |
| 215 | * waiting queue for receive message from FW |
| 216 | */ |
| 217 | wait_queue_head_t wait_recvd_msg; |
| 218 | wait_queue_head_t wait_stop_wd; |
| 219 | |
| 220 | /* |
| 221 | * mei device states |
| 222 | */ |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 223 | enum mei_dev_state dev_state; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 224 | enum mei_init_clients_states init_clients_state; |
| 225 | u16 init_clients_timer; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 226 | bool stop; |
| 227 | bool need_reset; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 228 | |
| 229 | u32 extra_write_index; |
Tomas Winkler | edf1eed | 2012-02-09 19:25:54 +0200 | [diff] [blame] | 230 | unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 231 | u32 wr_msg_buf[128]; /* used for control messages */ |
| 232 | u32 ext_msg_buf[8]; /* for control responses */ |
| 233 | u32 rd_msg_hdr; |
| 234 | |
| 235 | struct hbm_version version; |
| 236 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 237 | struct mei_me_client *me_clients; /* Note: memory has to be allocated */ |
| 238 | DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX); |
| 239 | DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX); |
Tomas Winkler | cf9673d | 2011-06-06 10:44:33 +0300 | [diff] [blame] | 240 | u8 me_clients_num; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 241 | u8 me_client_presentation_num; |
| 242 | u8 me_client_index; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 243 | bool mei_host_buffer_is_empty; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 244 | |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 245 | struct mei_cl wd_cl; |
Tomas Winkler | 21c66d1 | 2012-06-19 09:13:37 +0300 | [diff] [blame] | 246 | bool wd_interface_reg; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 247 | bool wd_pending; |
| 248 | bool wd_stopped; |
| 249 | bool wd_bypass; /* if false, don't refresh watchdog ME client */ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 250 | u16 wd_timeout; /* seconds ((wd_data[1] << 8) + wd_data[0]) */ |
| 251 | unsigned char wd_data[MEI_START_WD_DATA_SIZE]; |
| 252 | |
| 253 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 254 | struct file *iamthif_file_object; |
| 255 | struct mei_cl iamthif_cl; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 256 | struct mei_cl_cb *iamthif_current_cb; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 257 | int iamthif_mtu; |
| 258 | unsigned long iamthif_timer; |
| 259 | u32 iamthif_stall_timer; |
| 260 | unsigned char *iamthif_msg_buf; /* Note: memory has to be allocated */ |
| 261 | u32 iamthif_msg_buf_size; |
| 262 | u32 iamthif_msg_buf_index; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 263 | enum iamthif_states iamthif_state; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 264 | bool iamthif_flow_control_pending; |
| 265 | bool iamthif_ioctl; |
| 266 | bool iamthif_canceled; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | |
| 270 | /* |
| 271 | * mei init function prototypes |
| 272 | */ |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 273 | struct mei_device *mei_device_init(struct pci_dev *pdev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 274 | void mei_reset(struct mei_device *dev, int interrupts); |
| 275 | int mei_hw_init(struct mei_device *dev); |
| 276 | int mei_task_initialize_clients(void *data); |
| 277 | int mei_initialize_clients(struct mei_device *dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 278 | int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl); |
Tomas Winkler | 106fb49 | 2011-05-25 17:28:20 +0300 | [diff] [blame] | 279 | void mei_remove_client_from_file_list(struct mei_device *dev, u8 host_client_id); |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 280 | void mei_host_init_iamthif(struct mei_device *dev); |
| 281 | void mei_allocate_me_clients_storage(struct mei_device *dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 282 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 283 | |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 284 | int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl, |
| 285 | const uuid_le *cguid, u8 host_client_id); |
| 286 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid); |
| 287 | int mei_me_cl_by_id(struct mei_device *dev, u8 client_id); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 288 | |
| 289 | /* |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 290 | * MEI IO List Functions |
| 291 | */ |
| 292 | void mei_io_list_init(struct mei_io_list *list); |
| 293 | void mei_io_list_flush(struct mei_io_list *list, struct mei_cl *cl); |
| 294 | |
| 295 | /* |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 296 | * MEI ME Client Functions |
| 297 | */ |
| 298 | |
| 299 | struct mei_cl *mei_cl_allocate(struct mei_device *dev); |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 300 | void mei_cl_init(struct mei_cl *cl, struct mei_device *dev); |
| 301 | int mei_cl_flush_queues(struct mei_cl *cl); |
| 302 | /** |
| 303 | * mei_cl_cmp_id - tells if file private data have same id |
| 304 | * |
| 305 | * @fe1: private data of 1. file object |
| 306 | * @fe2: private data of 2. file object |
| 307 | * |
| 308 | * returns true - if ids are the same and not NULL |
| 309 | */ |
| 310 | static inline bool mei_cl_cmp_id(const struct mei_cl *cl1, |
| 311 | const struct mei_cl *cl2) |
| 312 | { |
| 313 | return cl1 && cl2 && |
| 314 | (cl1->host_client_id == cl2->host_client_id) && |
| 315 | (cl1->me_client_id == cl2->me_client_id); |
| 316 | } |
| 317 | |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 318 | |
| 319 | |
| 320 | /* |
| 321 | * MEI Host Client Functions |
| 322 | */ |
| 323 | void mei_host_start_message(struct mei_device *dev); |
| 324 | void mei_host_enum_clients_message(struct mei_device *dev); |
Oren Weil | abc51b6 | 2011-09-21 16:45:30 +0300 | [diff] [blame] | 325 | int mei_host_client_properties(struct mei_device *dev); |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * MEI interrupt functions prototype |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 329 | */ |
| 330 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id); |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 331 | irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id); |
Oren Weil | a61c653 | 2011-09-07 09:03:13 +0300 | [diff] [blame] | 332 | void mei_timer(struct work_struct *work); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 333 | |
| 334 | /* |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 335 | * MEI input output function prototype |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 336 | */ |
| 337 | int mei_ioctl_connect_client(struct file *file, |
| 338 | struct mei_connect_client_data *data); |
| 339 | |
| 340 | int mei_start_read(struct mei_device *dev, struct mei_cl *cl); |
| 341 | |
| 342 | int amthi_write(struct mei_device *dev, struct mei_cl_cb *priv_cb); |
| 343 | |
| 344 | int amthi_read(struct mei_device *dev, struct file *file, |
| 345 | char __user *ubuf, size_t length, loff_t *offset); |
| 346 | |
| 347 | struct mei_cl_cb *find_amthi_read_list_entry(struct mei_device *dev, |
| 348 | struct file *file); |
| 349 | |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 350 | void mei_run_next_iamthif_cmd(struct mei_device *dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 351 | |
| 352 | void mei_free_cb_private(struct mei_cl_cb *priv_cb); |
| 353 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * Register Access Function |
| 357 | */ |
| 358 | |
| 359 | /** |
| 360 | * mei_reg_read - Reads 32bit data from the mei device |
| 361 | * |
| 362 | * @dev: the device structure |
| 363 | * @offset: offset from which to read the data |
| 364 | * |
Oren Weil | 92eb401 | 2011-09-07 09:03:08 +0300 | [diff] [blame] | 365 | * returns register value (u32) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 366 | */ |
Tomas Winkler | 4a0d6a7 | 2012-07-04 19:24:49 +0300 | [diff] [blame] | 367 | static inline u32 mei_reg_read(const struct mei_device *dev, |
| 368 | unsigned long offset) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 369 | { |
| 370 | return ioread32(dev->mem_addr + offset); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * mei_reg_write - Writes 32bit data to the mei device |
| 375 | * |
| 376 | * @dev: the device structure |
| 377 | * @offset: offset from which to write the data |
Oren Weil | 92eb401 | 2011-09-07 09:03:08 +0300 | [diff] [blame] | 378 | * @value: register value to write (u32) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 379 | */ |
Tomas Winkler | 4a0d6a7 | 2012-07-04 19:24:49 +0300 | [diff] [blame] | 380 | static inline void mei_reg_write(const struct mei_device *dev, |
| 381 | unsigned long offset, u32 value) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 382 | { |
| 383 | iowrite32(value, dev->mem_addr + offset); |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * mei_hcsr_read - Reads 32bit data from the host CSR |
| 388 | * |
| 389 | * @dev: the device structure |
| 390 | * |
| 391 | * returns the byte read. |
| 392 | */ |
Tomas Winkler | 4a0d6a7 | 2012-07-04 19:24:49 +0300 | [diff] [blame] | 393 | static inline u32 mei_hcsr_read(const struct mei_device *dev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 394 | { |
| 395 | return mei_reg_read(dev, H_CSR); |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * mei_mecsr_read - Reads 32bit data from the ME CSR |
| 400 | * |
| 401 | * @dev: the device structure |
| 402 | * |
| 403 | * returns ME_CSR_HA register value (u32) |
| 404 | */ |
Tomas Winkler | 4a0d6a7 | 2012-07-04 19:24:49 +0300 | [diff] [blame] | 405 | static inline u32 mei_mecsr_read(const struct mei_device *dev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 406 | { |
| 407 | return mei_reg_read(dev, ME_CSR_HA); |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * get_me_cb_rw - Reads 32bit data from the mei ME_CB_RW register |
| 412 | * |
| 413 | * @dev: the device structure |
| 414 | * |
| 415 | * returns ME_CB_RW register value (u32) |
| 416 | */ |
Tomas Winkler | 4a0d6a7 | 2012-07-04 19:24:49 +0300 | [diff] [blame] | 417 | static inline u32 mei_mecbrw_read(const struct mei_device *dev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 418 | { |
| 419 | return mei_reg_read(dev, ME_CB_RW); |
| 420 | } |
| 421 | |
| 422 | |
| 423 | /* |
| 424 | * mei interface function prototypes |
| 425 | */ |
| 426 | void mei_hcsr_set(struct mei_device *dev); |
| 427 | void mei_csr_clear_his(struct mei_device *dev); |
| 428 | |
| 429 | void mei_enable_interrupts(struct mei_device *dev); |
| 430 | void mei_disable_interrupts(struct mei_device *dev); |
| 431 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 432 | #endif |