Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Synaptics RMI4 touchscreen driver |
| 3 | * |
| 4 | * Copyright (C) 2012 Synaptics Incorporated |
| 5 | * |
| 6 | * Copyright (C) 2012 Alexandra Chin <alexandra.chin@tw.synaptics.com> |
| 7 | * Copyright (C) 2012 Scott Lin <scott.lin@tw.synaptics.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/i2c.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/input.h> |
| 27 | #include <linux/firmware.h> |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 28 | #include <linux/string.h> |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 29 | #include <linux/input/synaptics_dsx.h> |
| 30 | #include "synaptics_i2c_rmi4.h" |
| 31 | |
| 32 | #define DEBUG_FW_UPDATE |
| 33 | #define SHOW_PROGRESS |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 34 | #define MAX_FIRMWARE_ID_LEN 10 |
| 35 | #define FORCE_UPDATE false |
| 36 | #define INSIDE_FIRMWARE_UPDATE |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 37 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 38 | #define FW_IMAGE_OFFSET 0x100 |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 39 | |
| 40 | #define BOOTLOADER_ID_OFFSET 0 |
| 41 | #define FLASH_PROPERTIES_OFFSET 2 |
| 42 | #define BLOCK_SIZE_OFFSET 3 |
| 43 | #define FW_BLOCK_COUNT_OFFSET 5 |
| 44 | |
| 45 | #define REG_MAP (1 << 0) |
| 46 | #define UNLOCKED (1 << 1) |
| 47 | #define HAS_CONFIG_ID (1 << 2) |
| 48 | #define HAS_PERM_CONFIG (1 << 3) |
| 49 | #define HAS_BL_CONFIG (1 << 4) |
| 50 | #define HAS_DISP_CONFIG (1 << 5) |
| 51 | #define HAS_CTRL1 (1 << 6) |
| 52 | |
| 53 | #define BLOCK_NUMBER_OFFSET 0 |
| 54 | #define BLOCK_DATA_OFFSET 2 |
| 55 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 56 | enum falsh_config_area { |
| 57 | UI_CONFIG_AREA = 0x00, |
| 58 | PERM_CONFIG_AREA = 0x01, |
| 59 | BL_CONFIG_AREA = 0x02, |
| 60 | DISP_CONFIG_AREA = 0x03 |
| 61 | }; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 62 | |
| 63 | enum flash_command { |
| 64 | CMD_WRITE_FW_BLOCK = 0x2, |
| 65 | CMD_ERASE_ALL = 0x3, |
| 66 | CMD_READ_CONFIG_BLOCK = 0x5, |
| 67 | CMD_WRITE_CONFIG_BLOCK = 0x6, |
| 68 | CMD_ERASE_CONFIG = 0x7, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 69 | CMD_READ_SENSOR_ID = 0x8, |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 70 | CMD_ERASE_BL_CONFIG = 0x9, |
| 71 | CMD_ERASE_DISP_CONFIG = 0xA, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 72 | CMD_ENABLE_FLASH_PROG = 0xF |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 73 | }; |
| 74 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 75 | enum flash_area { |
| 76 | NONE, |
| 77 | UI_FIRMWARE, |
| 78 | CONFIG_AREA |
| 79 | }; |
| 80 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 81 | enum image_file_option { |
| 82 | OPTION_BUILD_INFO = 0, |
| 83 | OPTION_CONTAIN_BOOTLOADER = 1, |
| 84 | }; |
| 85 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 86 | #define SLEEP_MODE_NORMAL (0x00) |
| 87 | #define SLEEP_MODE_SENSOR_SLEEP (0x01) |
| 88 | #define SLEEP_MODE_RESERVED0 (0x02) |
| 89 | #define SLEEP_MODE_RESERVED1 (0x03) |
| 90 | |
| 91 | #define ENABLE_WAIT_MS (1 * 1000) |
| 92 | #define WRITE_WAIT_MS (3 * 1000) |
| 93 | #define ERASE_WAIT_MS (5 * 1000) |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 94 | #define RESET_WAIT_MS (500) |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 95 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 96 | #define POLLING_MODE 0 |
| 97 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 98 | #define SLEEP_TIME_US 50 |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 99 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 100 | static int fwu_wait_for_idle(int timeout_ms); |
| 101 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 102 | struct image_header_data { |
| 103 | union { |
| 104 | struct { |
| 105 | /* 0x00-0x0F */ |
| 106 | unsigned char file_checksum[4]; |
| 107 | unsigned char reserved_04; |
| 108 | unsigned char reserved_05; |
| 109 | unsigned char options_firmware_id:1; |
| 110 | unsigned char options_contain_bootloader:1; |
| 111 | unsigned char options_reserved:6; |
| 112 | unsigned char bootloader_version; |
| 113 | unsigned char firmware_size[4]; |
| 114 | unsigned char config_size[4]; |
| 115 | /* 0x10-0x1F */ |
| 116 | unsigned char product_id[SYNAPTICS_RMI4_PRODUCT_ID_SIZE]; |
| 117 | unsigned char reserved_1a; |
| 118 | unsigned char reserved_1b; |
| 119 | unsigned char reserved_1c; |
| 120 | unsigned char reserved_1d; |
| 121 | unsigned char product_info[SYNAPTICS_RMI4_PRODUCT_INFO_SIZE]; |
| 122 | /* 0x20-0x2F */ |
| 123 | unsigned char reserved_20_2f[0x10]; |
| 124 | /* 0x30-0x3F */ |
| 125 | unsigned char ds_firmware_id[0x10]; |
| 126 | /* 0x40-0x4F */ |
| 127 | unsigned char ds_customize_info[10]; |
| 128 | unsigned char reserved_4a_4f[6]; |
| 129 | /* 0x50-0x53*/ |
| 130 | unsigned char firmware_id[4]; |
| 131 | } __packed; |
| 132 | unsigned char data[54]; |
| 133 | }; |
| 134 | }; |
| 135 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 136 | struct image_header { |
| 137 | unsigned int checksum; |
| 138 | unsigned int image_size; |
| 139 | unsigned int config_size; |
| 140 | unsigned char options; |
| 141 | unsigned char bootloader_version; |
| 142 | unsigned char product_id[SYNAPTICS_RMI4_PRODUCT_ID_SIZE + 1]; |
| 143 | unsigned char product_info[SYNAPTICS_RMI4_PRODUCT_INFO_SIZE]; |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 144 | unsigned int firmware_id; |
| 145 | bool is_contain_build_info; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | struct pdt_properties { |
| 149 | union { |
| 150 | struct { |
| 151 | unsigned char reserved_1:6; |
| 152 | unsigned char has_bsr:1; |
| 153 | unsigned char reserved_2:1; |
| 154 | } __packed; |
| 155 | unsigned char data[1]; |
| 156 | }; |
| 157 | }; |
| 158 | |
| 159 | struct f01_device_status { |
| 160 | union { |
| 161 | struct { |
| 162 | unsigned char status_code:4; |
| 163 | unsigned char reserved:2; |
| 164 | unsigned char flash_prog:1; |
| 165 | unsigned char unconfigured:1; |
| 166 | } __packed; |
| 167 | unsigned char data[1]; |
| 168 | }; |
| 169 | }; |
| 170 | |
| 171 | struct f01_device_control { |
| 172 | union { |
| 173 | struct { |
| 174 | unsigned char sleep_mode:2; |
| 175 | unsigned char nosleep:1; |
| 176 | unsigned char reserved:2; |
| 177 | unsigned char charger_connected:1; |
| 178 | unsigned char report_rate:1; |
| 179 | unsigned char configured:1; |
| 180 | } __packed; |
| 181 | unsigned char data[1]; |
| 182 | }; |
| 183 | }; |
| 184 | |
| 185 | struct f34_flash_control { |
| 186 | union { |
| 187 | struct { |
| 188 | unsigned char command:4; |
| 189 | unsigned char status:3; |
| 190 | unsigned char program_enabled:1; |
| 191 | } __packed; |
| 192 | unsigned char data[1]; |
| 193 | }; |
| 194 | }; |
| 195 | |
| 196 | struct f34_flash_properties { |
| 197 | union { |
| 198 | struct { |
| 199 | unsigned char regmap:1; |
| 200 | unsigned char unlocked:1; |
| 201 | unsigned char has_configid:1; |
| 202 | unsigned char has_perm_config:1; |
| 203 | unsigned char has_bl_config:1; |
| 204 | unsigned char has_display_config:1; |
| 205 | unsigned char has_blob_config:1; |
| 206 | unsigned char reserved:1; |
| 207 | } __packed; |
| 208 | unsigned char data[1]; |
| 209 | }; |
| 210 | }; |
| 211 | |
| 212 | struct synaptics_rmi4_fwu_handle { |
| 213 | bool initialized; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 214 | bool force_update; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 215 | char product_id[SYNAPTICS_RMI4_PRODUCT_ID_SIZE + 1]; |
| 216 | unsigned int image_size; |
| 217 | unsigned int data_pos; |
| 218 | unsigned char intr_mask; |
| 219 | unsigned char bootloader_id[2]; |
| 220 | unsigned char productinfo1; |
| 221 | unsigned char productinfo2; |
| 222 | unsigned char *ext_data_source; |
| 223 | unsigned char *read_config_buf; |
| 224 | const unsigned char *firmware_data; |
| 225 | const unsigned char *config_data; |
| 226 | unsigned short block_size; |
| 227 | unsigned short fw_block_count; |
| 228 | unsigned short config_block_count; |
| 229 | unsigned short perm_config_block_count; |
| 230 | unsigned short bl_config_block_count; |
| 231 | unsigned short disp_config_block_count; |
| 232 | unsigned short config_size; |
| 233 | unsigned short config_area; |
| 234 | unsigned short addr_f34_flash_control; |
| 235 | unsigned short addr_f01_interrupt_register; |
| 236 | struct synaptics_rmi4_fn_desc f01_fd; |
| 237 | struct synaptics_rmi4_fn_desc f34_fd; |
| 238 | struct synaptics_rmi4_exp_fn_ptr *fn_ptr; |
| 239 | struct synaptics_rmi4_data *rmi4_data; |
| 240 | struct f34_flash_control flash_control; |
| 241 | struct f34_flash_properties flash_properties; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 242 | struct workqueue_struct *fwu_workqueue; |
| 243 | struct delayed_work fwu_work; |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 244 | char firmware_name[NAME_BUFFER_SIZE]; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | static struct synaptics_rmi4_fwu_handle *fwu; |
| 248 | |
| 249 | static struct completion remove_complete; |
| 250 | |
| 251 | static unsigned int extract_uint(const unsigned char *ptr) |
| 252 | { |
| 253 | return (unsigned int)ptr[0] + |
| 254 | (unsigned int)ptr[1] * 0x100 + |
| 255 | (unsigned int)ptr[2] * 0x10000 + |
| 256 | (unsigned int)ptr[3] * 0x1000000; |
| 257 | } |
| 258 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 259 | static unsigned int extract_uint_be(const unsigned char *ptr) |
| 260 | { |
| 261 | return (unsigned int)ptr[3] + |
| 262 | (unsigned int)ptr[2] * 0x100 + |
| 263 | (unsigned int)ptr[1] * 0x10000 + |
| 264 | (unsigned int)ptr[0] * 0x1000000; |
| 265 | } |
| 266 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 267 | static void parse_header(struct image_header *header, |
| 268 | const unsigned char *fw_image) |
| 269 | { |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 270 | struct image_header_data *data = (struct image_header_data *)fw_image; |
| 271 | header->checksum = extract_uint(data->file_checksum); |
| 272 | header->bootloader_version = data->bootloader_version; |
| 273 | header->image_size = extract_uint(data->firmware_size); |
| 274 | header->config_size = extract_uint(data->config_size); |
| 275 | memcpy(header->product_id, data->product_id, |
| 276 | sizeof(data->product_id)); |
| 277 | header->product_id[sizeof(data->product_info)] = 0; |
| 278 | memcpy(header->product_info, data->product_info, |
| 279 | sizeof(data->product_info)); |
| 280 | |
| 281 | header->is_contain_build_info = |
| 282 | (data->options_firmware_id == (1 << OPTION_BUILD_INFO)); |
| 283 | if (header->is_contain_build_info) { |
| 284 | header->firmware_id = extract_uint(data->firmware_id); |
| 285 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 286 | "%s Firwmare build id %d\n", __func__, |
| 287 | header->firmware_id); |
| 288 | } |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 289 | |
| 290 | #ifdef DEBUG_FW_UPDATE |
| 291 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 292 | "Firwmare size %d, config size %d\n", |
| 293 | header->image_size, |
| 294 | header->config_size); |
| 295 | #endif |
| 296 | return; |
| 297 | } |
| 298 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 299 | static int fwu_read_f01_device_status(struct f01_device_status *status) |
| 300 | { |
| 301 | int retval; |
| 302 | |
| 303 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 304 | fwu->f01_fd.data_base_addr, |
| 305 | status->data, |
| 306 | sizeof(status->data)); |
| 307 | if (retval < 0) { |
| 308 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 309 | "%s: Failed to read F01 device status\n", |
| 310 | __func__); |
| 311 | return retval; |
| 312 | } |
| 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | static int fwu_read_f34_queries(void) |
| 318 | { |
| 319 | int retval; |
| 320 | unsigned char count = 4; |
| 321 | unsigned char buf[10]; |
| 322 | struct i2c_client *i2c_client = fwu->rmi4_data->i2c_client; |
| 323 | |
| 324 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 325 | fwu->f34_fd.query_base_addr + BOOTLOADER_ID_OFFSET, |
| 326 | fwu->bootloader_id, |
| 327 | sizeof(fwu->bootloader_id)); |
| 328 | if (retval < 0) { |
| 329 | dev_err(&i2c_client->dev, |
| 330 | "%s: Failed to read bootloader ID\n", |
| 331 | __func__); |
| 332 | return retval; |
| 333 | } |
| 334 | |
| 335 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 336 | fwu->f34_fd.query_base_addr + FLASH_PROPERTIES_OFFSET, |
| 337 | fwu->flash_properties.data, |
| 338 | sizeof(fwu->flash_properties.data)); |
| 339 | if (retval < 0) { |
| 340 | dev_err(&i2c_client->dev, |
| 341 | "%s: Failed to read flash properties\n", |
| 342 | __func__); |
| 343 | return retval; |
| 344 | } |
| 345 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 346 | dev_info(&i2c_client->dev, "%s perm:%d, bl:%d, display:%d\n", |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 347 | __func__, |
| 348 | fwu->flash_properties.has_perm_config, |
| 349 | fwu->flash_properties.has_bl_config, |
| 350 | fwu->flash_properties.has_display_config); |
| 351 | |
| 352 | if (fwu->flash_properties.has_perm_config) |
| 353 | count += 2; |
| 354 | |
| 355 | if (fwu->flash_properties.has_bl_config) |
| 356 | count += 2; |
| 357 | |
| 358 | if (fwu->flash_properties.has_display_config) |
| 359 | count += 2; |
| 360 | |
| 361 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 362 | fwu->f34_fd.query_base_addr + BLOCK_SIZE_OFFSET, |
| 363 | buf, |
| 364 | 2); |
| 365 | if (retval < 0) { |
| 366 | dev_err(&i2c_client->dev, |
| 367 | "%s: Failed to read block size info\n", |
| 368 | __func__); |
| 369 | return retval; |
| 370 | } |
| 371 | |
| 372 | batohs(&fwu->block_size, &(buf[0])); |
| 373 | |
| 374 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 375 | fwu->f34_fd.query_base_addr + FW_BLOCK_COUNT_OFFSET, |
| 376 | buf, |
| 377 | count); |
| 378 | if (retval < 0) { |
| 379 | dev_err(&i2c_client->dev, |
| 380 | "%s: Failed to read block count info\n", |
| 381 | __func__); |
| 382 | return retval; |
| 383 | } |
| 384 | |
| 385 | batohs(&fwu->fw_block_count, &(buf[0])); |
| 386 | batohs(&fwu->config_block_count, &(buf[2])); |
| 387 | |
| 388 | count = 4; |
| 389 | |
| 390 | if (fwu->flash_properties.has_perm_config) { |
| 391 | batohs(&fwu->perm_config_block_count, &(buf[count])); |
| 392 | count += 2; |
| 393 | } |
| 394 | |
| 395 | if (fwu->flash_properties.has_bl_config) { |
| 396 | batohs(&fwu->bl_config_block_count, &(buf[count])); |
| 397 | count += 2; |
| 398 | } |
| 399 | |
| 400 | if (fwu->flash_properties.has_display_config) |
| 401 | batohs(&fwu->disp_config_block_count, &(buf[count])); |
| 402 | |
| 403 | fwu->addr_f34_flash_control = fwu->f34_fd.data_base_addr + |
| 404 | BLOCK_DATA_OFFSET + |
| 405 | fwu->block_size; |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | static int fwu_read_interrupt_status(void) |
| 410 | { |
| 411 | int retval; |
| 412 | unsigned char interrupt_status; |
| 413 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 414 | fwu->addr_f01_interrupt_register, |
| 415 | &interrupt_status, |
| 416 | sizeof(interrupt_status)); |
| 417 | if (retval < 0) { |
| 418 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 419 | "%s: Failed to read flash status\n", |
| 420 | __func__); |
| 421 | return retval; |
| 422 | } |
| 423 | return interrupt_status; |
| 424 | } |
| 425 | |
| 426 | static int fwu_read_f34_flash_status(void) |
| 427 | { |
| 428 | int retval; |
| 429 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 430 | fwu->addr_f34_flash_control, |
| 431 | fwu->flash_control.data, |
| 432 | sizeof(fwu->flash_control.data)); |
| 433 | if (retval < 0) { |
| 434 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 435 | "%s: Failed to read flash status\n", |
| 436 | __func__); |
| 437 | return retval; |
| 438 | } |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | static int fwu_reset_device(void) |
| 443 | { |
| 444 | int retval; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 445 | |
| 446 | #ifdef DEBUG_FW_UPDATE |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 447 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 448 | "%s: Reset device\n", |
| 449 | __func__); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 450 | #endif |
| 451 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 452 | retval = fwu->rmi4_data->reset_device(fwu->rmi4_data); |
| 453 | if (retval < 0) { |
| 454 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 455 | "%s: Failed to reset core driver after reflash\n", |
| 456 | __func__); |
| 457 | return retval; |
| 458 | } |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | static int fwu_write_f34_command(unsigned char cmd) |
| 463 | { |
| 464 | int retval; |
| 465 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 466 | fwu->flash_control.data[0] = cmd; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 467 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 468 | fwu->addr_f34_flash_control, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 469 | fwu->flash_control.data, |
| 470 | sizeof(fwu->flash_control.data)); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 471 | if (retval < 0) { |
| 472 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 473 | "%s: Failed to write command 0x%02x\n", |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 474 | __func__, fwu->flash_control.data[0]); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 475 | return retval; |
| 476 | } |
| 477 | return 0; |
| 478 | } |
| 479 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 480 | static int fwu_wait_for_idle(int timeout_ms) |
| 481 | { |
| 482 | int count = 0; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 483 | int timeout_count = ((timeout_ms * 1000) / SLEEP_TIME_US) + 1; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 484 | do { |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 485 | #if POLLING_MODE |
| 486 | fwu_read_f34_flash_status(); |
| 487 | #endif |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 488 | if (fwu->flash_control.command == 0x00) |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 489 | return 0; |
| 490 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 491 | usleep_range(SLEEP_TIME_US, SLEEP_TIME_US + 100); |
| 492 | } while (count++ < timeout_count); |
| 493 | |
| 494 | fwu_read_f34_flash_status(); |
| 495 | if (fwu->flash_control.command == 0x00) |
| 496 | return 0; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 497 | |
| 498 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 499 | "%s: Timed out waiting for idle status\n", |
| 500 | __func__); |
| 501 | |
| 502 | return -ETIMEDOUT; |
| 503 | } |
| 504 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 505 | static enum flash_area fwu_go_nogo(struct image_header *header) |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 506 | { |
| 507 | int retval = 0; |
| 508 | int index = 0; |
| 509 | int deviceFirmwareID; |
| 510 | int imageConfigID; |
| 511 | int deviceConfigID; |
| 512 | unsigned long imageFirmwareID; |
| 513 | unsigned char firmware_id[4]; |
| 514 | unsigned char config_id[4]; |
| 515 | char *strptr; |
| 516 | char *imagePR = kzalloc(sizeof(MAX_FIRMWARE_ID_LEN), GFP_KERNEL); |
| 517 | enum flash_area flash_area = NONE; |
| 518 | struct i2c_client *i2c_client = fwu->rmi4_data->i2c_client; |
| 519 | struct f01_device_status f01_device_status; |
| 520 | |
| 521 | if (fwu->force_update) { |
| 522 | flash_area = UI_FIRMWARE; |
| 523 | goto exit; |
| 524 | } |
| 525 | |
| 526 | retval = fwu_read_f01_device_status(&f01_device_status); |
| 527 | if (retval < 0) { |
| 528 | flash_area = NONE; |
| 529 | goto exit; |
| 530 | } |
| 531 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 532 | /* Force update firmware when device is in bootloader mode */ |
| 533 | if (f01_device_status.flash_prog) { |
| 534 | dev_info(&i2c_client->dev, |
| 535 | "%s: In flash prog mode\n", |
| 536 | __func__); |
| 537 | flash_area = UI_FIRMWARE; |
| 538 | goto exit; |
| 539 | } |
| 540 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 541 | /* device firmware id */ |
| 542 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 543 | fwu->f01_fd.query_base_addr + 18, |
| 544 | firmware_id, |
| 545 | sizeof(firmware_id)); |
| 546 | if (retval < 0) { |
| 547 | dev_err(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 548 | "%s: Failed to read firmware ID (code %d).\n", |
| 549 | __func__, retval); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 550 | goto exit; |
| 551 | } |
| 552 | firmware_id[3] = 0; |
| 553 | deviceFirmwareID = extract_uint(firmware_id); |
| 554 | |
| 555 | /* .img firmware id */ |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 556 | if (header->is_contain_build_info) { |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 557 | dev_err(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 558 | "%s: Image option contains build info.\n", |
| 559 | __func__); |
| 560 | imageFirmwareID = header->firmware_id; |
| 561 | } else { |
| 562 | strptr = strnstr(fwu->firmware_name, "PR", |
| 563 | sizeof(fwu->firmware_name)); |
| 564 | if (!strptr) { |
| 565 | dev_err(&i2c_client->dev, |
| 566 | "No valid PR number (PRxxxxxxx)" \ |
| 567 | "found in image file name...\n"); |
| 568 | goto exit; |
| 569 | } |
| 570 | |
| 571 | strptr += 2; |
| 572 | while (strptr[index] >= '0' && strptr[index] <= '9') { |
| 573 | imagePR[index] = strptr[index]; |
| 574 | index++; |
| 575 | } |
| 576 | imagePR[index] = 0; |
| 577 | |
| 578 | retval = kstrtoul(imagePR, 10, &imageFirmwareID); |
| 579 | if (retval == -EINVAL) { |
| 580 | dev_err(&i2c_client->dev, |
| 581 | "invalid image firmware id...\n"); |
| 582 | goto exit; |
| 583 | } |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 584 | } |
| 585 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 586 | dev_dbg(&i2c_client->dev, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 587 | "Device firmware id %d, .img firmware id %d\n", |
| 588 | deviceFirmwareID, |
| 589 | (unsigned int)imageFirmwareID); |
| 590 | if (imageFirmwareID > deviceFirmwareID) { |
| 591 | flash_area = UI_FIRMWARE; |
| 592 | goto exit; |
Alexandra Chin | c556cf0 | 2013-03-19 17:46:05 -0700 | [diff] [blame] | 593 | } else if (imageFirmwareID < deviceFirmwareID) { |
| 594 | flash_area = NONE; |
| 595 | dev_info(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 596 | "%s: Img fw is older than device fw. Skip fw update.\n", |
| 597 | __func__); |
Alexandra Chin | c556cf0 | 2013-03-19 17:46:05 -0700 | [diff] [blame] | 598 | goto exit; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /* device config id */ |
| 602 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 603 | fwu->f34_fd.ctrl_base_addr, |
| 604 | config_id, |
| 605 | sizeof(config_id)); |
| 606 | if (retval < 0) { |
| 607 | dev_err(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 608 | "%s: Failed to read config ID (code %d).\n", |
| 609 | __func__, retval); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 610 | flash_area = NONE; |
| 611 | goto exit; |
| 612 | } |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 613 | deviceConfigID = extract_uint_be(config_id); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 614 | |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 615 | dev_dbg(&i2c_client->dev, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 616 | "Device config ID 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", |
| 617 | config_id[0], config_id[1], config_id[2], config_id[3]); |
| 618 | |
| 619 | /* .img config id */ |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 620 | dev_dbg(&i2c_client->dev, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 621 | ".img config ID 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", |
| 622 | fwu->config_data[0], |
| 623 | fwu->config_data[1], |
| 624 | fwu->config_data[2], |
| 625 | fwu->config_data[3]); |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 626 | imageConfigID = extract_uint_be(fwu->config_data); |
| 627 | |
| 628 | dev_dbg(&i2c_client->dev, |
| 629 | "%s: Device config ID %d, .img config ID %d\n", |
| 630 | __func__, deviceConfigID, imageConfigID); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 631 | |
| 632 | if (imageConfigID > deviceConfigID) { |
| 633 | flash_area = CONFIG_AREA; |
| 634 | goto exit; |
| 635 | } |
| 636 | |
| 637 | exit: |
| 638 | kfree(imagePR); |
| 639 | if (flash_area == NONE) |
| 640 | dev_info(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 641 | "%s: Nothing needs to be updated\n", __func__); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 642 | else |
| 643 | dev_info(&i2c_client->dev, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 644 | "%s: Update %s block\n", __func__, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 645 | flash_area == UI_FIRMWARE ? "UI FW" : "CONFIG"); |
| 646 | return flash_area; |
| 647 | } |
| 648 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 649 | static int fwu_scan_pdt(void) |
| 650 | { |
| 651 | int retval; |
| 652 | unsigned char ii; |
| 653 | unsigned char intr_count = 0; |
| 654 | unsigned char intr_off; |
| 655 | unsigned char intr_src; |
| 656 | unsigned short addr; |
| 657 | bool f01found = false; |
| 658 | bool f34found = false; |
| 659 | struct synaptics_rmi4_fn_desc rmi_fd; |
| 660 | |
| 661 | #ifdef DEBUG_FW_UPDATE |
| 662 | dev_info(&fwu->rmi4_data->i2c_client->dev, "Scan PDT\n"); |
| 663 | #endif |
| 664 | |
| 665 | for (addr = PDT_START; addr > PDT_END; addr -= PDT_ENTRY_SIZE) { |
| 666 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 667 | addr, |
| 668 | (unsigned char *)&rmi_fd, |
| 669 | sizeof(rmi_fd)); |
| 670 | if (retval < 0) |
| 671 | return retval; |
| 672 | |
| 673 | if (rmi_fd.fn_number) { |
| 674 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 675 | "%s: Found F%02x\n", |
| 676 | __func__, rmi_fd.fn_number); |
| 677 | switch (rmi_fd.fn_number) { |
| 678 | case SYNAPTICS_RMI4_F01: |
| 679 | f01found = true; |
| 680 | fwu->f01_fd = rmi_fd; |
| 681 | fwu->addr_f01_interrupt_register = |
| 682 | fwu->f01_fd.data_base_addr + 1; |
| 683 | break; |
| 684 | case SYNAPTICS_RMI4_F34: |
| 685 | f34found = true; |
| 686 | fwu->f34_fd = rmi_fd; |
| 687 | fwu->intr_mask = 0; |
| 688 | intr_src = rmi_fd.intr_src_count; |
| 689 | intr_off = intr_count % 8; |
| 690 | for (ii = intr_off; |
| 691 | ii < ((intr_src & MASK_3BIT) + |
| 692 | intr_off); |
| 693 | ii++) |
| 694 | fwu->intr_mask |= 1 << ii; |
| 695 | break; |
| 696 | } |
| 697 | } else |
| 698 | break; |
| 699 | |
| 700 | intr_count += (rmi_fd.intr_src_count & MASK_3BIT); |
| 701 | } |
| 702 | |
| 703 | if (!f01found || !f34found) { |
| 704 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 705 | "%s: Failed to find both F01 and F34\n", |
| 706 | __func__); |
| 707 | return -EINVAL; |
| 708 | } |
| 709 | |
| 710 | fwu_read_interrupt_status(); |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | static int fwu_write_blocks(unsigned char *block_ptr, unsigned short block_cnt, |
| 715 | unsigned char command) |
| 716 | { |
| 717 | int retval; |
| 718 | unsigned char block_offset[] = {0, 0}; |
| 719 | unsigned short block_num; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 720 | struct i2c_client *i2c_client = fwu->rmi4_data->i2c_client; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 721 | #ifdef SHOW_PROGRESS |
| 722 | unsigned int progress = (command == CMD_WRITE_CONFIG_BLOCK) ? |
| 723 | 10 : 100; |
| 724 | #endif |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 725 | |
| 726 | #ifdef DEBUG_FW_UPDATE |
| 727 | dev_info(&i2c_client->dev, |
| 728 | "%s: Start to update %s blocks\n", |
| 729 | __func__, |
| 730 | command == CMD_WRITE_CONFIG_BLOCK ? |
| 731 | "config" : "firmware"); |
| 732 | #endif |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 733 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 734 | fwu->f34_fd.data_base_addr + BLOCK_NUMBER_OFFSET, |
| 735 | block_offset, |
| 736 | sizeof(block_offset)); |
| 737 | if (retval < 0) { |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 738 | dev_err(&i2c_client->dev, |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 739 | "%s: Failed to write to block number registers\n", |
| 740 | __func__); |
| 741 | return retval; |
| 742 | } |
| 743 | |
| 744 | for (block_num = 0; block_num < block_cnt; block_num++) { |
| 745 | #ifdef SHOW_PROGRESS |
| 746 | if (block_num % progress == 0) |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 747 | dev_info(&i2c_client->dev, |
| 748 | "%s: update %s %3d / %3d\n", |
| 749 | __func__, |
| 750 | command == CMD_WRITE_CONFIG_BLOCK ? |
| 751 | "config" : "firmware", |
| 752 | block_num, block_cnt); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 753 | #endif |
| 754 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 755 | fwu->f34_fd.data_base_addr + BLOCK_DATA_OFFSET, |
| 756 | block_ptr, |
| 757 | fwu->block_size); |
| 758 | if (retval < 0) { |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 759 | dev_err(&i2c_client->dev, |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 760 | "%s: Failed to write block data (block %d)\n", |
| 761 | __func__, block_num); |
| 762 | return retval; |
| 763 | } |
| 764 | |
| 765 | retval = fwu_write_f34_command(command); |
| 766 | if (retval < 0) { |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 767 | dev_err(&i2c_client->dev, |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 768 | "%s: Failed to write command for block %d\n", |
| 769 | __func__, block_num); |
| 770 | return retval; |
| 771 | } |
| 772 | |
| 773 | retval = fwu_wait_for_idle(WRITE_WAIT_MS); |
| 774 | if (retval < 0) { |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 775 | dev_err(&i2c_client->dev, |
| 776 | "%s: Failed to wait for idle status (block %d)\n", |
| 777 | __func__, block_num); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 778 | return retval; |
| 779 | } |
| 780 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 781 | if (fwu->flash_control.status != 0x00) { |
| 782 | dev_err(&i2c_client->dev, |
| 783 | "%s: Flash block %d failed, status 0x%02X\n", |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 784 | __func__, block_num, retval); |
Shantanu Jain | 41f0d47 | 2013-01-04 12:14:37 +0530 | [diff] [blame] | 785 | return retval; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 786 | } |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 787 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 788 | block_ptr += fwu->block_size; |
| 789 | } |
| 790 | #ifdef SHOW_PROGRESS |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 791 | dev_info(&i2c_client->dev, |
| 792 | "%s: update %s %3d / %3d\n", |
| 793 | __func__, |
| 794 | command == CMD_WRITE_CONFIG_BLOCK ? |
| 795 | "config" : "firmware", |
| 796 | block_cnt, block_cnt); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 797 | #endif |
| 798 | return 0; |
| 799 | } |
| 800 | |
| 801 | static int fwu_write_firmware(void) |
| 802 | { |
| 803 | return fwu_write_blocks((unsigned char *)fwu->firmware_data, |
| 804 | fwu->fw_block_count, CMD_WRITE_FW_BLOCK); |
| 805 | } |
| 806 | |
| 807 | static int fwu_write_configuration(void) |
| 808 | { |
| 809 | return fwu_write_blocks((unsigned char *)fwu->config_data, |
| 810 | fwu->config_block_count, CMD_WRITE_CONFIG_BLOCK); |
| 811 | } |
| 812 | |
| 813 | static int fwu_write_bootloader_id(void) |
| 814 | { |
| 815 | int retval; |
| 816 | |
| 817 | #ifdef DEBUG_FW_UPDATE |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 818 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 819 | "Write bootloader ID 0x%02X 0x%02X\n", |
| 820 | fwu->bootloader_id[0], |
| 821 | fwu->bootloader_id[1]); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 822 | #endif |
| 823 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 824 | fwu->f34_fd.data_base_addr + BLOCK_DATA_OFFSET, |
| 825 | fwu->bootloader_id, |
| 826 | sizeof(fwu->bootloader_id)); |
| 827 | if (retval < 0) { |
| 828 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 829 | "%s: Failed to write bootloader ID\n", |
| 830 | __func__); |
| 831 | return retval; |
| 832 | } |
| 833 | |
| 834 | return 0; |
| 835 | } |
| 836 | |
| 837 | static int fwu_enter_flash_prog(void) |
| 838 | { |
| 839 | int retval; |
| 840 | struct f01_device_status f01_device_status; |
| 841 | struct f01_device_control f01_device_control; |
| 842 | |
| 843 | #ifdef DEBUG_FW_UPDATE |
| 844 | dev_info(&fwu->rmi4_data->i2c_client->dev, "Enter bootloader mode\n"); |
| 845 | #endif |
| 846 | retval = fwu_read_f01_device_status(&f01_device_status); |
| 847 | if (retval < 0) |
| 848 | return retval; |
| 849 | |
| 850 | if (f01_device_status.flash_prog) { |
| 851 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 852 | "%s: Already in flash prog mode\n", |
| 853 | __func__); |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | retval = fwu_write_bootloader_id(); |
| 858 | if (retval < 0) |
| 859 | return retval; |
| 860 | |
| 861 | retval = fwu_write_f34_command(CMD_ENABLE_FLASH_PROG); |
| 862 | if (retval < 0) |
| 863 | return retval; |
| 864 | |
| 865 | retval = fwu_wait_for_idle(ENABLE_WAIT_MS); |
| 866 | if (retval < 0) |
| 867 | return retval; |
| 868 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 869 | retval = fwu_scan_pdt(); |
| 870 | if (retval < 0) |
| 871 | return retval; |
| 872 | |
| 873 | retval = fwu_read_f01_device_status(&f01_device_status); |
| 874 | if (retval < 0) |
| 875 | return retval; |
| 876 | |
| 877 | if (!f01_device_status.flash_prog) { |
| 878 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 879 | "%s: Not in flash prog mode\n", |
| 880 | __func__); |
| 881 | return -EINVAL; |
| 882 | } |
| 883 | |
| 884 | retval = fwu_read_f34_queries(); |
| 885 | if (retval < 0) |
| 886 | return retval; |
| 887 | |
| 888 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 889 | fwu->f01_fd.ctrl_base_addr, |
| 890 | f01_device_control.data, |
| 891 | sizeof(f01_device_control.data)); |
| 892 | if (retval < 0) { |
| 893 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 894 | "%s: Failed to read F01 device control\n", |
| 895 | __func__); |
| 896 | return retval; |
| 897 | } |
| 898 | |
| 899 | f01_device_control.nosleep = true; |
| 900 | f01_device_control.sleep_mode = SLEEP_MODE_NORMAL; |
| 901 | |
| 902 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 903 | fwu->f01_fd.ctrl_base_addr, |
| 904 | f01_device_control.data, |
| 905 | sizeof(f01_device_control.data)); |
| 906 | if (retval < 0) { |
| 907 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 908 | "%s: Failed to write F01 device control\n", |
| 909 | __func__); |
| 910 | return retval; |
| 911 | } |
| 912 | |
| 913 | return retval; |
| 914 | } |
| 915 | |
| 916 | static int fwu_do_reflash(void) |
| 917 | { |
| 918 | int retval; |
| 919 | |
| 920 | retval = fwu_enter_flash_prog(); |
| 921 | if (retval < 0) |
| 922 | return retval; |
| 923 | |
| 924 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 925 | "%s: Entered flash prog mode\n", |
| 926 | __func__); |
| 927 | |
| 928 | retval = fwu_write_bootloader_id(); |
| 929 | if (retval < 0) |
| 930 | return retval; |
| 931 | |
| 932 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 933 | "%s: Bootloader ID written\n", |
| 934 | __func__); |
| 935 | |
| 936 | retval = fwu_write_f34_command(CMD_ERASE_ALL); |
| 937 | if (retval < 0) |
| 938 | return retval; |
| 939 | |
| 940 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 941 | "%s: Erase all command written\n", |
| 942 | __func__); |
| 943 | |
| 944 | retval = fwu_wait_for_idle(ERASE_WAIT_MS); |
| 945 | if (retval < 0) |
| 946 | return retval; |
| 947 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 948 | if (fwu->flash_control.status != 0x00) { |
| 949 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 950 | "%s: Erase all command failed, status 0x%02X\n", |
| 951 | __func__, retval); |
| 952 | return -1; |
| 953 | } |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 954 | |
| 955 | if (fwu->firmware_data) { |
| 956 | retval = fwu_write_firmware(); |
| 957 | if (retval < 0) |
| 958 | return retval; |
| 959 | pr_notice("%s: Firmware programmed\n", __func__); |
| 960 | } |
| 961 | |
| 962 | if (fwu->config_data) { |
| 963 | retval = fwu_write_configuration(); |
| 964 | if (retval < 0) |
| 965 | return retval; |
| 966 | pr_notice("%s: Configuration programmed\n", __func__); |
| 967 | } |
| 968 | |
| 969 | return retval; |
| 970 | } |
| 971 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 972 | static int fwu_do_write_config(void) |
| 973 | { |
| 974 | int retval; |
| 975 | |
| 976 | retval = fwu_enter_flash_prog(); |
| 977 | if (retval < 0) |
| 978 | return retval; |
| 979 | |
| 980 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 981 | "%s: Entered flash prog mode\n", |
| 982 | __func__); |
| 983 | |
| 984 | if (fwu->config_area == PERM_CONFIG_AREA) { |
| 985 | fwu->config_block_count = fwu->perm_config_block_count; |
| 986 | goto write_config; |
| 987 | } |
| 988 | |
| 989 | retval = fwu_write_bootloader_id(); |
| 990 | if (retval < 0) |
| 991 | return retval; |
| 992 | |
| 993 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 994 | "%s: Bootloader ID written\n", |
| 995 | __func__); |
| 996 | |
| 997 | switch (fwu->config_area) { |
| 998 | case UI_CONFIG_AREA: |
| 999 | retval = fwu_write_f34_command(CMD_ERASE_CONFIG); |
| 1000 | break; |
| 1001 | case BL_CONFIG_AREA: |
| 1002 | retval = fwu_write_f34_command(CMD_ERASE_BL_CONFIG); |
| 1003 | fwu->config_block_count = fwu->bl_config_block_count; |
| 1004 | break; |
| 1005 | case DISP_CONFIG_AREA: |
| 1006 | retval = fwu_write_f34_command(CMD_ERASE_DISP_CONFIG); |
| 1007 | fwu->config_block_count = fwu->disp_config_block_count; |
| 1008 | break; |
| 1009 | } |
| 1010 | if (retval < 0) |
| 1011 | return retval; |
| 1012 | |
| 1013 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 1014 | "%s: Erase command written\n", |
| 1015 | __func__); |
| 1016 | |
| 1017 | retval = fwu_wait_for_idle(ERASE_WAIT_MS); |
| 1018 | if (retval < 0) |
| 1019 | return retval; |
| 1020 | |
| 1021 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 1022 | "%s: Idle status detected\n", |
| 1023 | __func__); |
| 1024 | |
| 1025 | write_config: |
| 1026 | retval = fwu_write_configuration(); |
| 1027 | if (retval < 0) |
| 1028 | return retval; |
| 1029 | |
| 1030 | pr_notice("%s: Config written\n", __func__); |
| 1031 | |
| 1032 | return retval; |
| 1033 | } |
| 1034 | |
| 1035 | static int fwu_start_write_config(void) |
| 1036 | { |
| 1037 | int retval; |
| 1038 | struct image_header header; |
| 1039 | |
| 1040 | switch (fwu->config_area) { |
| 1041 | case UI_CONFIG_AREA: |
| 1042 | break; |
| 1043 | case PERM_CONFIG_AREA: |
| 1044 | if (!fwu->flash_properties.has_perm_config) |
| 1045 | return -EINVAL; |
| 1046 | break; |
| 1047 | case BL_CONFIG_AREA: |
| 1048 | if (!fwu->flash_properties.has_bl_config) |
| 1049 | return -EINVAL; |
| 1050 | break; |
| 1051 | case DISP_CONFIG_AREA: |
| 1052 | if (!fwu->flash_properties.has_display_config) |
| 1053 | return -EINVAL; |
| 1054 | break; |
| 1055 | default: |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | |
| 1059 | if (fwu->ext_data_source) |
| 1060 | fwu->config_data = fwu->ext_data_source; |
| 1061 | else |
| 1062 | return -EINVAL; |
| 1063 | |
| 1064 | if (fwu->config_area == UI_CONFIG_AREA) { |
| 1065 | parse_header(&header, fwu->ext_data_source); |
| 1066 | |
| 1067 | if (header.config_size) { |
| 1068 | fwu->config_data = fwu->ext_data_source + |
| 1069 | FW_IMAGE_OFFSET + |
| 1070 | header.image_size; |
| 1071 | } else { |
| 1072 | return -EINVAL; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | pr_notice("%s: Start of write config process\n", __func__); |
| 1077 | |
| 1078 | retval = fwu_do_write_config(); |
| 1079 | if (retval < 0) { |
| 1080 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1081 | "%s: Failed to write config\n", |
| 1082 | __func__); |
| 1083 | } |
| 1084 | |
| 1085 | fwu->rmi4_data->reset_device(fwu->rmi4_data); |
| 1086 | |
| 1087 | pr_notice("%s: End of write config process\n", __func__); |
| 1088 | |
| 1089 | return retval; |
| 1090 | } |
| 1091 | |
| 1092 | static int fwu_do_read_config(void) |
| 1093 | { |
| 1094 | int retval; |
| 1095 | unsigned char block_offset[] = {0, 0}; |
| 1096 | unsigned short block_num; |
| 1097 | unsigned short block_count; |
| 1098 | unsigned short index = 0; |
| 1099 | |
| 1100 | retval = fwu_enter_flash_prog(); |
| 1101 | if (retval < 0) |
| 1102 | goto exit; |
| 1103 | |
| 1104 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 1105 | "%s: Entered flash prog mode\n", |
| 1106 | __func__); |
| 1107 | |
| 1108 | switch (fwu->config_area) { |
| 1109 | case UI_CONFIG_AREA: |
| 1110 | block_count = fwu->config_block_count; |
| 1111 | break; |
| 1112 | case PERM_CONFIG_AREA: |
| 1113 | if (!fwu->flash_properties.has_perm_config) { |
| 1114 | retval = -EINVAL; |
| 1115 | goto exit; |
| 1116 | } |
| 1117 | block_count = fwu->perm_config_block_count; |
| 1118 | break; |
| 1119 | case BL_CONFIG_AREA: |
| 1120 | if (!fwu->flash_properties.has_bl_config) { |
| 1121 | retval = -EINVAL; |
| 1122 | goto exit; |
| 1123 | } |
| 1124 | block_count = fwu->bl_config_block_count; |
| 1125 | break; |
| 1126 | case DISP_CONFIG_AREA: |
| 1127 | if (!fwu->flash_properties.has_display_config) { |
| 1128 | retval = -EINVAL; |
| 1129 | goto exit; |
| 1130 | } |
| 1131 | block_count = fwu->disp_config_block_count; |
| 1132 | break; |
| 1133 | default: |
| 1134 | retval = -EINVAL; |
| 1135 | goto exit; |
| 1136 | } |
| 1137 | |
| 1138 | fwu->config_size = fwu->block_size * block_count; |
| 1139 | |
| 1140 | kfree(fwu->read_config_buf); |
| 1141 | fwu->read_config_buf = kzalloc(fwu->config_size, GFP_KERNEL); |
| 1142 | |
| 1143 | block_offset[1] |= (fwu->config_area << 5); |
| 1144 | |
| 1145 | retval = fwu->fn_ptr->write(fwu->rmi4_data, |
| 1146 | fwu->f34_fd.data_base_addr + BLOCK_NUMBER_OFFSET, |
| 1147 | block_offset, |
| 1148 | sizeof(block_offset)); |
| 1149 | if (retval < 0) { |
| 1150 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1151 | "%s: Failed to write to block number registers\n", |
| 1152 | __func__); |
| 1153 | goto exit; |
| 1154 | } |
| 1155 | |
| 1156 | for (block_num = 0; block_num < block_count; block_num++) { |
| 1157 | retval = fwu_write_f34_command(CMD_READ_CONFIG_BLOCK); |
| 1158 | if (retval < 0) { |
| 1159 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1160 | "%s: Failed to write read config command\n", |
| 1161 | __func__); |
| 1162 | goto exit; |
| 1163 | } |
| 1164 | |
| 1165 | retval = fwu_wait_for_idle(WRITE_WAIT_MS); |
| 1166 | if (retval < 0) { |
| 1167 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1168 | "%s: Failed to wait for idle status\n", |
| 1169 | __func__); |
| 1170 | goto exit; |
| 1171 | } |
| 1172 | |
| 1173 | retval = fwu->fn_ptr->read(fwu->rmi4_data, |
| 1174 | fwu->f34_fd.data_base_addr + BLOCK_DATA_OFFSET, |
| 1175 | &fwu->read_config_buf[index], |
| 1176 | fwu->block_size); |
| 1177 | if (retval < 0) { |
| 1178 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1179 | "%s: Failed to read block data (block %d)\n", |
| 1180 | __func__, block_num); |
| 1181 | goto exit; |
| 1182 | } |
| 1183 | |
| 1184 | index += fwu->block_size; |
| 1185 | } |
| 1186 | |
| 1187 | exit: |
| 1188 | fwu->rmi4_data->reset_device(fwu->rmi4_data); |
| 1189 | |
| 1190 | return retval; |
| 1191 | } |
| 1192 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1193 | static int fwu_start_reflash(void) |
| 1194 | { |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 1195 | int retval = 0; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1196 | struct image_header header; |
| 1197 | const unsigned char *fw_image; |
| 1198 | const struct firmware *fw_entry = NULL; |
| 1199 | struct f01_device_status f01_device_status; |
| 1200 | enum flash_area flash_area; |
| 1201 | |
| 1202 | pr_notice("%s: Start of reflash process\n", __func__); |
| 1203 | |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1204 | if (strnlen(fwu->rmi4_data->fw_image_name, NAME_BUFFER_SIZE) == 0) { |
Amy Maloche | cb83583 | 2013-03-26 18:06:05 -0700 | [diff] [blame] | 1205 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1206 | "Firmware image name not given, skipping update\n"); |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1207 | return 0; |
| 1208 | } |
| 1209 | |
| 1210 | if (strnlen(fwu->rmi4_data->fw_image_name, NAME_BUFFER_SIZE) == |
| 1211 | NAME_BUFFER_SIZE) { |
| 1212 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1213 | "Firmware image name exceeds max length (%d), " \ |
| 1214 | "skipping update\n", NAME_BUFFER_SIZE); |
| 1215 | return 0; |
Amy Maloche | cb83583 | 2013-03-26 18:06:05 -0700 | [diff] [blame] | 1216 | } |
| 1217 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1218 | if (fwu->ext_data_source) |
| 1219 | fw_image = fwu->ext_data_source; |
| 1220 | else { |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 1221 | snprintf(fwu->firmware_name, NAME_BUFFER_SIZE, "%s", |
| 1222 | fwu->rmi4_data->fw_image_name); |
| 1223 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 1224 | "%s: Requesting firmware image %s\n", |
| 1225 | __func__, fwu->firmware_name); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1226 | |
Amy Maloche | cb83583 | 2013-03-26 18:06:05 -0700 | [diff] [blame] | 1227 | retval = request_firmware(&fw_entry, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 1228 | fwu->firmware_name, |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1229 | &fwu->rmi4_data->i2c_client->dev); |
| 1230 | if (retval != 0) { |
| 1231 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1232 | "%s: Firmware image %s not available\n", |
Amy Maloche | cb83583 | 2013-03-26 18:06:05 -0700 | [diff] [blame] | 1233 | __func__, |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 1234 | fwu->firmware_name); |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1235 | return -EINVAL; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | dev_dbg(&fwu->rmi4_data->i2c_client->dev, |
| 1239 | "%s: Firmware image size = %d\n", |
| 1240 | __func__, fw_entry->size); |
| 1241 | |
| 1242 | fw_image = fw_entry->data; |
| 1243 | } |
| 1244 | |
| 1245 | parse_header(&header, fw_image); |
| 1246 | |
| 1247 | if (header.image_size) |
| 1248 | fwu->firmware_data = fw_image + FW_IMAGE_OFFSET; |
| 1249 | if (header.config_size) { |
| 1250 | fwu->config_data = fw_image + FW_IMAGE_OFFSET + |
| 1251 | header.image_size; |
| 1252 | } |
| 1253 | |
| 1254 | if (fwu->ext_data_source) |
| 1255 | flash_area = UI_FIRMWARE; |
| 1256 | else |
Amy Maloche | afcecb2 | 2013-04-16 18:43:22 -0700 | [diff] [blame] | 1257 | flash_area = fwu_go_nogo(&header); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1258 | |
| 1259 | switch (flash_area) { |
| 1260 | case NONE: |
| 1261 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 1262 | "%s: No need to do reflash.\n", |
| 1263 | __func__); |
| 1264 | goto exit; |
| 1265 | case UI_FIRMWARE: |
| 1266 | retval = fwu_do_reflash(); |
| 1267 | break; |
| 1268 | case CONFIG_AREA: |
| 1269 | retval = fwu_do_write_config(); |
| 1270 | break; |
| 1271 | default: |
| 1272 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1273 | "%s: Unknown flash area\n", |
| 1274 | __func__); |
| 1275 | goto exit; |
| 1276 | } |
| 1277 | |
| 1278 | if (retval < 0) { |
| 1279 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1280 | "%s: Failed to do reflash\n", |
| 1281 | __func__); |
| 1282 | } |
| 1283 | |
| 1284 | /* reset device */ |
| 1285 | fwu_reset_device(); |
| 1286 | |
| 1287 | /* check device status */ |
| 1288 | retval = fwu_read_f01_device_status(&f01_device_status); |
| 1289 | if (retval < 0) |
| 1290 | goto exit; |
| 1291 | |
| 1292 | dev_info(&fwu->rmi4_data->i2c_client->dev, "Device is in %s mode\n", |
| 1293 | f01_device_status.flash_prog == 1 ? "bootloader" : "UI"); |
| 1294 | if (f01_device_status.flash_prog) |
| 1295 | dev_info(&fwu->rmi4_data->i2c_client->dev, "Flash status %d\n", |
| 1296 | f01_device_status.status_code); |
| 1297 | |
| 1298 | if (f01_device_status.flash_prog) { |
| 1299 | dev_info(&fwu->rmi4_data->i2c_client->dev, |
| 1300 | "%s: Device is in flash prog mode 0x%02X\n", |
| 1301 | __func__, f01_device_status.status_code); |
| 1302 | retval = 0; |
| 1303 | goto exit; |
| 1304 | } |
| 1305 | |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1306 | exit: |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1307 | if (fw_entry) |
| 1308 | release_firmware(fw_entry); |
| 1309 | |
| 1310 | pr_notice("%s: End of reflash process\n", __func__); |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1311 | return retval; |
| 1312 | } |
| 1313 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1314 | int synaptics_fw_updater(unsigned char *fw_data) |
| 1315 | { |
| 1316 | int retval; |
| 1317 | |
| 1318 | if (!fwu) |
| 1319 | return -ENODEV; |
| 1320 | |
| 1321 | if (!fwu->initialized) |
| 1322 | return -ENODEV; |
| 1323 | |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1324 | fwu->rmi4_data->fw_updating = true; |
| 1325 | if (fwu->rmi4_data->touch_stopped == true) { |
| 1326 | fwu->rmi4_data->fw_updating = false; |
| 1327 | dev_err(&fwu->rmi4_data->i2c_client->dev, |
| 1328 | "Cannot start fw upgrade while device is in suspend\n"); |
| 1329 | return -EBUSY; |
| 1330 | } |
| 1331 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1332 | fwu->ext_data_source = fw_data; |
| 1333 | fwu->config_area = UI_CONFIG_AREA; |
| 1334 | |
| 1335 | retval = fwu_start_reflash(); |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1336 | fwu->rmi4_data->fw_updating = false; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1337 | |
| 1338 | return retval; |
| 1339 | } |
| 1340 | EXPORT_SYMBOL(synaptics_fw_updater); |
| 1341 | |
| 1342 | static ssize_t fwu_sysfs_show_image(struct file *data_file, |
| 1343 | struct kobject *kobj, struct bin_attribute *attributes, |
| 1344 | char *buf, loff_t pos, size_t count) |
| 1345 | { |
| 1346 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1347 | |
| 1348 | if (count < fwu->config_size) { |
| 1349 | dev_err(&rmi4_data->i2c_client->dev, |
| 1350 | "%s: Not enough space (%d bytes) in buffer\n", |
| 1351 | __func__, count); |
| 1352 | return -EINVAL; |
| 1353 | } |
| 1354 | |
| 1355 | memcpy(buf, fwu->read_config_buf, fwu->config_size); |
| 1356 | |
| 1357 | return fwu->config_size; |
| 1358 | } |
| 1359 | |
| 1360 | static ssize_t fwu_sysfs_store_image(struct file *data_file, |
| 1361 | struct kobject *kobj, struct bin_attribute *attributes, |
| 1362 | char *buf, loff_t pos, size_t count) |
| 1363 | { |
| 1364 | memcpy((void *)(&fwu->ext_data_source[fwu->data_pos]), |
| 1365 | (const void *)buf, |
| 1366 | count); |
| 1367 | |
| 1368 | fwu->data_pos += count; |
| 1369 | |
| 1370 | return count; |
| 1371 | } |
| 1372 | |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1373 | static ssize_t fwu_sysfs_fw_name_store(struct device *dev, |
| 1374 | struct device_attribute *attr, const char *buf, size_t count) |
| 1375 | { |
| 1376 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1377 | char *strptr; |
| 1378 | |
| 1379 | if (count >= NAME_BUFFER_SIZE) { |
| 1380 | dev_err(&rmi4_data->i2c_client->dev, |
| 1381 | "Input over %d characters long\n", NAME_BUFFER_SIZE); |
| 1382 | return -EINVAL; |
| 1383 | } |
| 1384 | |
| 1385 | strptr = strnstr(buf, ".img", |
| 1386 | count); |
| 1387 | if (!strptr) { |
| 1388 | dev_err(&rmi4_data->i2c_client->dev, |
| 1389 | "Input is not valid .img file\n"); |
| 1390 | return -EINVAL; |
| 1391 | } |
| 1392 | |
| 1393 | strlcpy(rmi4_data->fw_image_name, buf, count); |
| 1394 | return count; |
| 1395 | } |
| 1396 | |
| 1397 | static ssize_t fwu_sysfs_fw_name_show(struct device *dev, |
| 1398 | struct device_attribute *attr, char *buf) |
| 1399 | { |
| 1400 | if (strnlen(fwu->rmi4_data->fw_image_name, NAME_BUFFER_SIZE) > 0) |
| 1401 | return snprintf(buf, PAGE_SIZE, "%s\n", |
| 1402 | fwu->rmi4_data->fw_image_name); |
| 1403 | else |
| 1404 | return snprintf(buf, PAGE_SIZE, "No firmware name given\n"); |
| 1405 | } |
| 1406 | |
Amy Maloche | 5e0360e | 2013-05-01 13:31:57 -0700 | [diff] [blame] | 1407 | static ssize_t fwu_sysfs_force_reflash_store(struct device *dev, |
| 1408 | struct device_attribute *attr, const char *buf, size_t count) |
| 1409 | { |
| 1410 | int retval; |
| 1411 | unsigned int input; |
| 1412 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1413 | |
| 1414 | if (sscanf(buf, "%u", &input) != 1) { |
| 1415 | retval = -EINVAL; |
| 1416 | goto exit; |
| 1417 | } |
| 1418 | |
| 1419 | if (input != 1) { |
| 1420 | retval = -EINVAL; |
| 1421 | goto exit; |
| 1422 | } |
| 1423 | |
| 1424 | fwu->force_update = true; |
| 1425 | retval = synaptics_fw_updater(fwu->ext_data_source); |
| 1426 | if (retval < 0) { |
| 1427 | dev_err(&rmi4_data->i2c_client->dev, |
| 1428 | "%s: Failed to do reflash\n", |
| 1429 | __func__); |
| 1430 | goto exit; |
| 1431 | } |
| 1432 | |
| 1433 | retval = count; |
| 1434 | |
| 1435 | exit: |
| 1436 | kfree(fwu->ext_data_source); |
| 1437 | fwu->ext_data_source = NULL; |
| 1438 | return retval; |
| 1439 | } |
| 1440 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1441 | static ssize_t fwu_sysfs_do_reflash_store(struct device *dev, |
| 1442 | struct device_attribute *attr, const char *buf, size_t count) |
| 1443 | { |
| 1444 | int retval; |
| 1445 | unsigned int input; |
| 1446 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1447 | |
| 1448 | if (sscanf(buf, "%u", &input) != 1) { |
| 1449 | retval = -EINVAL; |
| 1450 | goto exit; |
| 1451 | } |
| 1452 | |
| 1453 | if (input != 1) { |
| 1454 | retval = -EINVAL; |
| 1455 | goto exit; |
| 1456 | } |
| 1457 | |
| 1458 | retval = synaptics_fw_updater(fwu->ext_data_source); |
| 1459 | if (retval < 0) { |
| 1460 | dev_err(&rmi4_data->i2c_client->dev, |
| 1461 | "%s: Failed to do reflash\n", |
| 1462 | __func__); |
| 1463 | goto exit; |
| 1464 | } |
| 1465 | |
| 1466 | retval = count; |
| 1467 | |
| 1468 | exit: |
| 1469 | kfree(fwu->ext_data_source); |
| 1470 | fwu->ext_data_source = NULL; |
| 1471 | return retval; |
| 1472 | } |
| 1473 | |
| 1474 | static ssize_t fwu_sysfs_write_config_store(struct device *dev, |
| 1475 | struct device_attribute *attr, const char *buf, size_t count) |
| 1476 | { |
| 1477 | int retval; |
| 1478 | unsigned int input; |
| 1479 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1480 | |
| 1481 | if (sscanf(buf, "%u", &input) != 1) { |
| 1482 | retval = -EINVAL; |
| 1483 | goto exit; |
| 1484 | } |
| 1485 | |
| 1486 | if (input != 1) { |
| 1487 | retval = -EINVAL; |
| 1488 | goto exit; |
| 1489 | } |
| 1490 | |
| 1491 | retval = fwu_start_write_config(); |
| 1492 | if (retval < 0) { |
| 1493 | dev_err(&rmi4_data->i2c_client->dev, |
| 1494 | "%s: Failed to write config\n", |
| 1495 | __func__); |
| 1496 | goto exit; |
| 1497 | } |
| 1498 | |
| 1499 | retval = count; |
| 1500 | |
| 1501 | exit: |
| 1502 | kfree(fwu->ext_data_source); |
| 1503 | fwu->ext_data_source = NULL; |
| 1504 | return retval; |
| 1505 | } |
| 1506 | |
| 1507 | static ssize_t fwu_sysfs_read_config_store(struct device *dev, |
| 1508 | struct device_attribute *attr, const char *buf, size_t count) |
| 1509 | { |
| 1510 | int retval; |
| 1511 | unsigned int input; |
| 1512 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1513 | |
| 1514 | if (sscanf(buf, "%u", &input) != 1) |
| 1515 | return -EINVAL; |
| 1516 | |
| 1517 | if (input != 1) |
| 1518 | return -EINVAL; |
| 1519 | |
| 1520 | retval = fwu_do_read_config(); |
| 1521 | if (retval < 0) { |
| 1522 | dev_err(&rmi4_data->i2c_client->dev, |
| 1523 | "%s: Failed to read config\n", |
| 1524 | __func__); |
| 1525 | return retval; |
| 1526 | } |
| 1527 | |
| 1528 | return count; |
| 1529 | } |
| 1530 | |
| 1531 | static ssize_t fwu_sysfs_config_area_store(struct device *dev, |
| 1532 | struct device_attribute *attr, const char *buf, size_t count) |
| 1533 | { |
| 1534 | int retval; |
| 1535 | unsigned long config_area; |
| 1536 | |
Shantanu Jain | 41f0d47 | 2013-01-04 12:14:37 +0530 | [diff] [blame] | 1537 | retval = kstrtoul(buf, 10, &config_area); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1538 | if (retval) |
| 1539 | return retval; |
| 1540 | |
| 1541 | fwu->config_area = config_area; |
| 1542 | |
| 1543 | return count; |
| 1544 | } |
| 1545 | |
| 1546 | static ssize_t fwu_sysfs_image_size_store(struct device *dev, |
| 1547 | struct device_attribute *attr, const char *buf, size_t count) |
| 1548 | { |
| 1549 | int retval; |
| 1550 | unsigned long size; |
| 1551 | struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data; |
| 1552 | |
Shantanu Jain | 41f0d47 | 2013-01-04 12:14:37 +0530 | [diff] [blame] | 1553 | retval = kstrtoul(buf, 10, &size); |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1554 | if (retval) |
| 1555 | return retval; |
| 1556 | |
| 1557 | fwu->image_size = size; |
| 1558 | fwu->data_pos = 0; |
| 1559 | |
| 1560 | kfree(fwu->ext_data_source); |
| 1561 | fwu->ext_data_source = kzalloc(fwu->image_size, GFP_KERNEL); |
| 1562 | if (!fwu->ext_data_source) { |
| 1563 | dev_err(&rmi4_data->i2c_client->dev, |
| 1564 | "%s: Failed to alloc mem for image data\n", |
| 1565 | __func__); |
| 1566 | return -ENOMEM; |
| 1567 | } |
| 1568 | |
| 1569 | return count; |
| 1570 | } |
| 1571 | |
| 1572 | static ssize_t fwu_sysfs_block_size_show(struct device *dev, |
| 1573 | struct device_attribute *attr, char *buf) |
| 1574 | { |
| 1575 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->block_size); |
| 1576 | } |
| 1577 | |
| 1578 | static ssize_t fwu_sysfs_firmware_block_count_show(struct device *dev, |
| 1579 | struct device_attribute *attr, char *buf) |
| 1580 | { |
| 1581 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->fw_block_count); |
| 1582 | } |
| 1583 | |
| 1584 | static ssize_t fwu_sysfs_configuration_block_count_show(struct device *dev, |
| 1585 | struct device_attribute *attr, char *buf) |
| 1586 | { |
| 1587 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->config_block_count); |
| 1588 | } |
| 1589 | |
| 1590 | static ssize_t fwu_sysfs_perm_config_block_count_show(struct device *dev, |
| 1591 | struct device_attribute *attr, char *buf) |
| 1592 | { |
| 1593 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->perm_config_block_count); |
| 1594 | } |
| 1595 | |
| 1596 | static ssize_t fwu_sysfs_bl_config_block_count_show(struct device *dev, |
| 1597 | struct device_attribute *attr, char *buf) |
| 1598 | { |
| 1599 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->bl_config_block_count); |
| 1600 | } |
| 1601 | |
| 1602 | static ssize_t fwu_sysfs_disp_config_block_count_show(struct device *dev, |
| 1603 | struct device_attribute *attr, char *buf) |
| 1604 | { |
| 1605 | return snprintf(buf, PAGE_SIZE, "%u\n", fwu->disp_config_block_count); |
| 1606 | } |
| 1607 | |
Amy Maloche | d25bd8c | 2013-01-25 12:34:31 -0800 | [diff] [blame] | 1608 | static ssize_t fwu_sysfs_config_id_show(struct device *dev, |
| 1609 | struct device_attribute *attr, char *buf) |
| 1610 | { |
Amy Maloche | 581f740 | 2013-02-19 16:29:37 -0800 | [diff] [blame] | 1611 | unsigned char config_id[4]; |
Amy Maloche | d25bd8c | 2013-01-25 12:34:31 -0800 | [diff] [blame] | 1612 | /* device config id */ |
| 1613 | fwu->fn_ptr->read(fwu->rmi4_data, |
| 1614 | fwu->f34_fd.ctrl_base_addr, |
| 1615 | config_id, |
| 1616 | sizeof(config_id)); |
| 1617 | |
| 1618 | return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", |
| 1619 | config_id[0], config_id[1], config_id[2], config_id[3]); |
| 1620 | } |
| 1621 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1622 | static void synaptics_rmi4_fwu_attn(struct synaptics_rmi4_data *rmi4_data, |
| 1623 | unsigned char intr_mask) |
| 1624 | { |
| 1625 | if (fwu->intr_mask & intr_mask) |
| 1626 | fwu_read_f34_flash_status(); |
| 1627 | |
| 1628 | return; |
| 1629 | } |
| 1630 | |
Amy Maloche | b494b9a | 2013-05-13 18:01:53 -0700 | [diff] [blame^] | 1631 | static struct bin_attribute dev_attr_data = { |
| 1632 | .attr = { |
| 1633 | .name = "data", |
| 1634 | .mode = (S_IRUGO | S_IWUGO), |
| 1635 | }, |
| 1636 | .size = 0, |
| 1637 | .read = fwu_sysfs_show_image, |
| 1638 | .write = fwu_sysfs_store_image, |
| 1639 | }; |
| 1640 | |
| 1641 | static struct device_attribute attrs[] = { |
| 1642 | __ATTR(fw_name, S_IWUGO | S_IRUGO, |
| 1643 | fwu_sysfs_fw_name_show, |
| 1644 | fwu_sysfs_fw_name_store), |
| 1645 | __ATTR(force_update_fw, S_IWUGO, |
| 1646 | synaptics_rmi4_show_error, |
| 1647 | fwu_sysfs_force_reflash_store), |
| 1648 | __ATTR(update_fw, S_IWUGO, |
| 1649 | synaptics_rmi4_show_error, |
| 1650 | fwu_sysfs_do_reflash_store), |
| 1651 | __ATTR(writeconfig, S_IWUGO, |
| 1652 | synaptics_rmi4_show_error, |
| 1653 | fwu_sysfs_write_config_store), |
| 1654 | __ATTR(readconfig, S_IWUGO, |
| 1655 | synaptics_rmi4_show_error, |
| 1656 | fwu_sysfs_read_config_store), |
| 1657 | __ATTR(configarea, S_IWUGO, |
| 1658 | synaptics_rmi4_show_error, |
| 1659 | fwu_sysfs_config_area_store), |
| 1660 | __ATTR(imagesize, S_IWUGO, |
| 1661 | synaptics_rmi4_show_error, |
| 1662 | fwu_sysfs_image_size_store), |
| 1663 | __ATTR(blocksize, S_IRUGO, |
| 1664 | fwu_sysfs_block_size_show, |
| 1665 | synaptics_rmi4_store_error), |
| 1666 | __ATTR(fwblockcount, S_IRUGO, |
| 1667 | fwu_sysfs_firmware_block_count_show, |
| 1668 | synaptics_rmi4_store_error), |
| 1669 | __ATTR(configblockcount, S_IRUGO, |
| 1670 | fwu_sysfs_configuration_block_count_show, |
| 1671 | synaptics_rmi4_store_error), |
| 1672 | __ATTR(permconfigblockcount, S_IRUGO, |
| 1673 | fwu_sysfs_perm_config_block_count_show, |
| 1674 | synaptics_rmi4_store_error), |
| 1675 | __ATTR(blconfigblockcount, S_IRUGO, |
| 1676 | fwu_sysfs_bl_config_block_count_show, |
| 1677 | synaptics_rmi4_store_error), |
| 1678 | __ATTR(dispconfigblockcount, S_IRUGO, |
| 1679 | fwu_sysfs_disp_config_block_count_show, |
| 1680 | synaptics_rmi4_store_error), |
| 1681 | __ATTR(config_id, S_IRUGO, |
| 1682 | fwu_sysfs_config_id_show, |
| 1683 | synaptics_rmi4_store_error), |
| 1684 | }; |
| 1685 | |
| 1686 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1687 | static void synaptics_rmi4_fwu_work(struct work_struct *work) |
| 1688 | { |
| 1689 | fwu_start_reflash(); |
| 1690 | } |
| 1691 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1692 | static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data) |
| 1693 | { |
| 1694 | int retval; |
| 1695 | unsigned char attr_count; |
| 1696 | struct pdt_properties pdt_props; |
| 1697 | |
| 1698 | fwu = kzalloc(sizeof(*fwu), GFP_KERNEL); |
| 1699 | if (!fwu) { |
| 1700 | dev_err(&rmi4_data->i2c_client->dev, |
| 1701 | "%s: Failed to alloc mem for fwu\n", |
| 1702 | __func__); |
| 1703 | goto exit; |
| 1704 | } |
| 1705 | |
| 1706 | fwu->fn_ptr = kzalloc(sizeof(*(fwu->fn_ptr)), GFP_KERNEL); |
| 1707 | if (!fwu->fn_ptr) { |
| 1708 | dev_err(&rmi4_data->i2c_client->dev, |
| 1709 | "%s: Failed to alloc mem for fn_ptr\n", |
| 1710 | __func__); |
| 1711 | retval = -ENOMEM; |
| 1712 | goto exit_free_fwu; |
| 1713 | } |
| 1714 | |
| 1715 | fwu->rmi4_data = rmi4_data; |
| 1716 | fwu->fn_ptr->read = rmi4_data->i2c_read; |
| 1717 | fwu->fn_ptr->write = rmi4_data->i2c_write; |
| 1718 | fwu->fn_ptr->enable = rmi4_data->irq_enable; |
| 1719 | |
| 1720 | retval = fwu->fn_ptr->read(rmi4_data, |
| 1721 | PDT_PROPS, |
| 1722 | pdt_props.data, |
| 1723 | sizeof(pdt_props.data)); |
| 1724 | if (retval < 0) { |
| 1725 | dev_dbg(&rmi4_data->i2c_client->dev, |
| 1726 | "%s: Failed to read PDT properties, assuming 0x00\n", |
| 1727 | __func__); |
| 1728 | } else if (pdt_props.has_bsr) { |
| 1729 | dev_err(&rmi4_data->i2c_client->dev, |
| 1730 | "%s: Reflash for LTS not currently supported\n", |
| 1731 | __func__); |
| 1732 | goto exit_free_mem; |
| 1733 | } |
| 1734 | |
| 1735 | retval = fwu_scan_pdt(); |
| 1736 | if (retval < 0) |
| 1737 | goto exit_free_mem; |
| 1738 | |
| 1739 | fwu->productinfo1 = rmi4_data->rmi4_mod_info.product_info[0]; |
| 1740 | fwu->productinfo2 = rmi4_data->rmi4_mod_info.product_info[1]; |
| 1741 | |
| 1742 | memcpy(fwu->product_id, rmi4_data->rmi4_mod_info.product_id_string, |
| 1743 | SYNAPTICS_RMI4_PRODUCT_ID_SIZE); |
| 1744 | fwu->product_id[SYNAPTICS_RMI4_PRODUCT_ID_SIZE] = 0; |
| 1745 | |
| 1746 | dev_dbg(&rmi4_data->i2c_client->dev, |
| 1747 | "%s: F01 product info: 0x%04x 0x%04x\n", |
| 1748 | __func__, fwu->productinfo1, fwu->productinfo2); |
| 1749 | dev_dbg(&rmi4_data->i2c_client->dev, |
| 1750 | "%s: F01 product ID: %s\n", |
| 1751 | __func__, fwu->product_id); |
| 1752 | |
| 1753 | retval = fwu_read_f34_queries(); |
| 1754 | if (retval < 0) |
| 1755 | goto exit_free_mem; |
| 1756 | |
| 1757 | fwu->initialized = true; |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1758 | fwu->force_update = FORCE_UPDATE; |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1759 | |
| 1760 | retval = sysfs_create_bin_file(&rmi4_data->input_dev->dev.kobj, |
| 1761 | &dev_attr_data); |
| 1762 | if (retval < 0) { |
| 1763 | dev_err(&rmi4_data->i2c_client->dev, |
| 1764 | "%s: Failed to create sysfs bin file\n", |
| 1765 | __func__); |
| 1766 | goto exit_free_mem; |
| 1767 | } |
| 1768 | |
| 1769 | for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) { |
| 1770 | retval = sysfs_create_file(&rmi4_data->input_dev->dev.kobj, |
| 1771 | &attrs[attr_count].attr); |
| 1772 | if (retval < 0) { |
| 1773 | dev_err(&rmi4_data->i2c_client->dev, |
| 1774 | "%s: Failed to create sysfs attributes\n", |
| 1775 | __func__); |
| 1776 | retval = -ENODEV; |
| 1777 | goto exit_remove_attrs; |
| 1778 | } |
| 1779 | } |
| 1780 | |
Alexandra Chin | d5591a6 | 2013-02-07 12:59:15 -0800 | [diff] [blame] | 1781 | #ifdef INSIDE_FIRMWARE_UPDATE |
| 1782 | fwu->fwu_workqueue = create_singlethread_workqueue("fwu_workqueue"); |
| 1783 | INIT_DELAYED_WORK(&fwu->fwu_work, synaptics_rmi4_fwu_work); |
| 1784 | queue_delayed_work(fwu->fwu_workqueue, |
| 1785 | &fwu->fwu_work, |
| 1786 | msecs_to_jiffies(1000)); |
| 1787 | #endif |
Alexandra Chin | c556cf0 | 2013-03-19 17:46:05 -0700 | [diff] [blame] | 1788 | |
| 1789 | init_completion(&remove_complete); |
| 1790 | |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1791 | return 0; |
| 1792 | |
| 1793 | exit_remove_attrs: |
| 1794 | for (attr_count--; attr_count >= 0; attr_count--) { |
| 1795 | sysfs_remove_file(&rmi4_data->input_dev->dev.kobj, |
| 1796 | &attrs[attr_count].attr); |
| 1797 | } |
| 1798 | |
| 1799 | sysfs_remove_bin_file(&rmi4_data->input_dev->dev.kobj, &dev_attr_data); |
| 1800 | |
| 1801 | exit_free_mem: |
| 1802 | kfree(fwu->fn_ptr); |
| 1803 | |
| 1804 | exit_free_fwu: |
| 1805 | kfree(fwu); |
| 1806 | |
| 1807 | exit: |
| 1808 | return 0; |
| 1809 | } |
| 1810 | |
| 1811 | static void synaptics_rmi4_fwu_remove(struct synaptics_rmi4_data *rmi4_data) |
| 1812 | { |
| 1813 | unsigned char attr_count; |
| 1814 | |
| 1815 | sysfs_remove_bin_file(&rmi4_data->input_dev->dev.kobj, &dev_attr_data); |
| 1816 | |
| 1817 | for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) { |
| 1818 | sysfs_remove_file(&rmi4_data->input_dev->dev.kobj, |
| 1819 | &attrs[attr_count].attr); |
| 1820 | } |
| 1821 | |
| 1822 | kfree(fwu->fn_ptr); |
| 1823 | kfree(fwu); |
| 1824 | |
| 1825 | complete(&remove_complete); |
| 1826 | |
| 1827 | return; |
| 1828 | } |
| 1829 | |
| 1830 | static int __init rmi4_fw_update_module_init(void) |
| 1831 | { |
| 1832 | synaptics_rmi4_new_function(RMI_FW_UPDATER, true, |
| 1833 | synaptics_rmi4_fwu_init, |
| 1834 | synaptics_rmi4_fwu_remove, |
| 1835 | synaptics_rmi4_fwu_attn); |
| 1836 | return 0; |
| 1837 | } |
| 1838 | |
| 1839 | static void __exit rmi4_fw_update_module_exit(void) |
| 1840 | { |
Alexandra Chin | 669d27c | 2012-12-24 15:42:30 +0800 | [diff] [blame] | 1841 | synaptics_rmi4_new_function(RMI_FW_UPDATER, false, |
| 1842 | synaptics_rmi4_fwu_init, |
| 1843 | synaptics_rmi4_fwu_remove, |
| 1844 | synaptics_rmi4_fwu_attn); |
| 1845 | wait_for_completion(&remove_complete); |
| 1846 | return; |
| 1847 | } |
| 1848 | |
| 1849 | module_init(rmi4_fw_update_module_init); |
| 1850 | module_exit(rmi4_fw_update_module_exit); |
| 1851 | |
| 1852 | MODULE_AUTHOR("Synaptics, Inc."); |
| 1853 | MODULE_DESCRIPTION("RMI4 FW Update Module"); |
Alexandra Chin | bd1dac2 | 2013-02-22 12:33:19 -0800 | [diff] [blame] | 1854 | MODULE_LICENSE("GPL v2"); |