2 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 Copyright (c) 2011 Synaptics, Inc.
5 Permission is hereby granted, free of charge, to any person obtaining a copy of
6 this software and associated documentation files (the "Software"), to deal in
7 the Software without restriction, including without limitation the rights to use,
8 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9 Software, and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 #include <linux/module.h>
26 #include <linux/delay.h>
27 #include <linux/hrtimer.h>
28 #include <linux/i2c.h>
29 #include <linux/input.h>
30 #include <linux/interrupt.h>
32 #include <linux/platform_device.h>
33 #include <linux/gpio.h>
34 #include <linux/slab.h>
35 #include <linux/jiffies.h>
36 #include <linux/syscalls.h>
37 #include <linux/uaccess.h>
39 #include <mach/mt_gpio.h>
41 #include "synaptics_ts.h"
44 /* Variables for F34 functionality */
45 unsigned short SynaF34DataBase
;
46 unsigned short SynaF34QueryBase
;
47 unsigned short SynaF01DataBase
;
48 unsigned short SynaF01CommandBase
;
49 unsigned short SynaF01ControlBase
;
50 unsigned short SynaF01QueryBase
;
52 unsigned short SynaF34Reflash_BlockNum
;
53 unsigned short SynaF34Reflash_BlockData
;
54 unsigned short SynaF34ReflashQuery_BootID
;
55 unsigned short SynaF34ReflashQuery_FlashPropertyQuery
;
56 unsigned short SynaF34ReflashQuery_FirmwareBlockSize
;
57 unsigned short SynaF34ReflashQuery_FirmwareBlockCount
;
58 unsigned short SynaF34ReflashQuery_ConfigBlockSize
;
59 unsigned short SynaF34ReflashQuery_ConfigBlockCount
;
61 unsigned short SynaFirmwareBlockSize
;
62 unsigned short SynaFirmwareBlockCount
;
63 unsigned long SynaImageSize
;
65 unsigned short SynaConfigBlockSize
;
66 unsigned short SynaConfigBlockCount
;
67 unsigned long SynaConfigImageSize
;
69 unsigned short SynaBootloadID
;
71 unsigned short SynaF34_FlashControl
;
73 unsigned char *SynafirmwareImgData
;
74 unsigned char *SynaconfigImgData
;
75 unsigned char *SynalockImgData
;
76 unsigned int SynafirmwareImgVersion
;
78 unsigned char *my_image_bin
;
79 unsigned long my_image_size
;
82 int CompleteReflash(struct synaptics_ts_data
*ts
);
83 int ConfigBlockReflash(struct synaptics_ts_data
*ts
);
84 int CompleteReflash_Lockdown(struct synaptics_ts_data
*ts
);
85 void SynaInitialize(struct synaptics_ts_data
*ts
);
86 void SynaReadConfigInfo(struct synaptics_ts_data
*ts
);
87 void SynaReadFirmwareInfo(struct synaptics_ts_data
*ts
);
88 int SynaEnableFlashing(struct synaptics_ts_data
*ts
);
89 int SynaProgramFirmware(struct synaptics_ts_data
*ts
);
90 int SynaProgramConfiguration(struct synaptics_ts_data
*ts
);
91 int SynaFinalizeReflash(struct synaptics_ts_data
*ts
);
92 int SynaWaitForATTN(int time
, struct synaptics_ts_data
*ts
);
94 extern int synaptics_ts_write(struct i2c_client
*client
, u8 reg
, u8
* buf
, int len
);
95 extern int synaptics_ts_read(struct i2c_client
*client
, u8 reg
, int num
, u8
*buf
);
98 int FirmwareUpgrade(struct synaptics_ts_data
*ts
, const char* fw_path
)
102 mm_segment_t old_fs
= 0;
103 struct stat fw_bin_stat
;
104 unsigned long read_bytes
;
106 if(unlikely(fw_path
[0] != 0)) {
110 if ((fd
= sys_open((const char __user
*) fw_path
, O_RDONLY
, 0)) < 0) {
111 SYNAPTICS_ERR_MSG("Can not read FW binary from %s\n", fw_path
);
116 if ((ret
= sys_newstat((char __user
*) fw_path
, (struct stat
*)&fw_bin_stat
)) < 0) {
117 SYNAPTICS_ERR_MSG("Can not read FW binary stat from %s\n", fw_path
);
118 goto fw_mem_alloc_fail
;
121 my_image_size
= fw_bin_stat
.st_size
;
122 my_image_bin
= kzalloc(sizeof(char) * (my_image_size
+1), GFP_KERNEL
);
123 if (my_image_bin
== NULL
) {
124 SYNAPTICS_ERR_MSG("Can not allocate memory\n");
126 goto fw_mem_alloc_fail
;
129 read_bytes
= sys_read(fd
, (char __user
*)my_image_bin
, my_image_size
);
132 *(my_image_bin
+my_image_size
) = 0xFF;
134 SYNAPTICS_INFO_MSG("Touch FW image read %ld bytes from %s\n", read_bytes
, fw_path
);
137 my_image_size
= ts
->fw_size
-1;
138 my_image_bin
= (unsigned char *)(&ts
->fw_start
[0]);
141 ret
= CompleteReflash_Lockdown(ts
);
143 SYNAPTICS_ERR_MSG("CompleteReflash_Lockdown fail\n");
146 if(unlikely(fw_path
[0] != 0))
157 static int writeRMI(struct i2c_client
*client
, u8 uRmiAddress
, u8
*data
, unsigned int length
)
159 return synaptics_ts_write(client
, uRmiAddress
, data
, length
);
162 static int readRMI(struct i2c_client
*client
, u8 uRmiAddress
, u8
*data
, unsigned int length
)
164 return synaptics_ts_read(client
, uRmiAddress
, length
, data
);
167 /* SynaSetup scans the Page Description Table (PDT) and sets up the necessary variables
168 * for the reflash process. This function is a "slim" version of the PDT scan function in
169 * in PDT.c, since only F34 and F01 are needed for reflash.
171 void SynaSetup(struct synaptics_ts_data
*ts
)
173 unsigned char address
;
174 unsigned char buffer
[6];
175 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
177 for (address
= 0xe9; address
> 0xd0; address
= address
- 6)
179 readRMI(ts
->client
, address
, &buffer
[0], 6);
181 if(!buffer
[5]) break;
186 SynaF34DataBase
= buffer
[3];
187 SynaF34QueryBase
= buffer
[0];
190 SynaF01DataBase
= buffer
[3];
191 SynaF01CommandBase
= buffer
[1];
192 SynaF01ControlBase
= buffer
[2];
193 SynaF01QueryBase
= buffer
[0];
198 SynaF34Reflash_BlockNum
= SynaF34DataBase
;
199 SynaF34Reflash_BlockData
= SynaF34DataBase
+ 2;
200 SynaF34ReflashQuery_BootID
= SynaF34QueryBase
;
201 SynaF34ReflashQuery_FlashPropertyQuery
= SynaF34QueryBase
+ 2;
202 SynaF34ReflashQuery_FirmwareBlockSize
= SynaF34QueryBase
+ 3;
203 SynaF34ReflashQuery_FirmwareBlockCount
= SynaF34QueryBase
+5;
204 SynaF34ReflashQuery_ConfigBlockSize
= SynaF34QueryBase
+ 3;
205 SynaF34ReflashQuery_ConfigBlockCount
= SynaF34QueryBase
+ 7;
207 SynafirmwareImgData
= (unsigned char *)((&my_image_bin
[0])+0x100);
208 SynaconfigImgData
= (unsigned char *)(SynafirmwareImgData
+SynaImageSize
);
209 SynafirmwareImgVersion
= (unsigned int)(my_image_bin
[7]);
211 switch(SynafirmwareImgVersion
)
214 SynalockImgData
= (unsigned char *)((&my_image_bin
[0]) + 0xD0);
218 SynalockImgData
= (unsigned char *)((&my_image_bin
[0]) + 0xC0);
221 SynalockImgData
= (unsigned char *)((&my_image_bin
[0]) + 0xB0);
227 /* SynaInitialize sets up the reflahs process
229 void SynaInitialize(struct synaptics_ts_data
*ts
)
231 unsigned char uData
[2];
233 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
235 SYNAPTICS_INFO_MSG("Initializing Reflash Process...\n");
237 writeRMI(ts
->client
, 0xff, &uData
[0], 1);
241 //Set all interrupt enable
243 writeRMI(ts
->client
, SynaF01ControlBase
+1, &uData
[0], 1);
245 readRMI(ts
->client
, SynaF34ReflashQuery_FirmwareBlockSize
, &uData
[0], 2);
247 SynaFirmwareBlockSize
= uData
[0] | (uData
[1] << 8);
250 /* SynaReadFirmwareInfo reads the F34 query registers and retrieves the block size and count
251 * of the firmware section of the image to be reflashed
253 void SynaReadFirmwareInfo(struct synaptics_ts_data
*ts
)
255 unsigned char uData
[2];
259 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
261 SYNAPTICS_INFO_MSG("Read Firmware Info\n");
263 readRMI(ts
->client
, SynaF34ReflashQuery_FirmwareBlockSize
, &uData
[0], 2);
264 SynaFirmwareBlockSize
= uData
[0] | (uData
[1] << 8);
266 readRMI(ts
->client
, SynaF34ReflashQuery_FirmwareBlockCount
, &uData
[0], 2);
267 SynaFirmwareBlockCount
= uData
[0] | (uData
[1] << 8);
268 SynaImageSize
= SynaFirmwareBlockCount
* SynaFirmwareBlockSize
;
271 /* SynaReadConfigInfo reads the F34 query registers and retrieves the block size and count
272 * of the configuration section of the image to be reflashed
274 void SynaReadConfigInfo(struct synaptics_ts_data
*ts
)
276 unsigned char uData
[2];
277 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
279 SYNAPTICS_INFO_MSG("Read Config Info\n");
281 readRMI(ts
->client
, SynaF34ReflashQuery_ConfigBlockSize
, &uData
[0], 2);
282 SynaConfigBlockSize
= uData
[0] | (uData
[1] << 8);
284 readRMI(ts
->client
, SynaF34ReflashQuery_ConfigBlockCount
, &uData
[0], 2);
285 SynaConfigBlockCount
= uData
[0] | (uData
[1] << 8);
286 SynaConfigImageSize
= SynaConfigBlockCount
* SynaConfigBlockSize
;
289 /* SynaReadBootloadID reads the F34 query registers and retrieves the bootloader ID of the firmware
291 void SynaReadBootloadID(struct synaptics_ts_data
*ts
)
293 unsigned char uData
[2];
294 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
296 readRMI(ts
->client
, SynaF34ReflashQuery_BootID
, &uData
[0], 2);
297 SynaBootloadID
= uData
[0] + uData
[1] * 0x100;
300 /* SynaWriteBootloadID writes the bootloader ID to the F34 data register to unlock the reflash process
302 void SynaWriteBootloadID(struct synaptics_ts_data
*ts
)
304 unsigned char uData
[2];
305 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
307 uData
[0] = SynaBootloadID
% 0x100;
308 uData
[1] = SynaBootloadID
/ 0x100;
310 writeRMI(ts
->client
, SynaF34Reflash_BlockData
, &uData
[0], 2);
313 /* SynaWaitForATTN waits for ATTN to be asserted within a certain time threshold.
315 int SynaWaitForATTN(int time
, struct synaptics_ts_data
*ts
)
319 while((mt_get_gpio_in(ts
->pdata
->int_gpio
) != 0) && (trial_us
< (time
* 1000))) {
324 if (mt_get_gpio_in(ts
->pdata
->int_gpio
) != 0)
330 /* SynaWaitATTN waits for ATTN to be asserted within a certain time threshold.
331 * The function also checks for the F34 "Program Enabled" bit and clear ATTN accordingly.
333 int SynaWaitATTN(struct synaptics_ts_data
*ts
)
337 unsigned char uStatus
;
339 ret
= SynaWaitForATTN(1000, ts
);
341 SYNAPTICS_ERR_MSG("SynaWaitForATTN 1000ms timeout error\n");
346 readRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
347 readRMI(ts
->client
, (SynaF01DataBase
+ 1), &uStatus
, 1);
348 } while (uData
!= 0x80);
353 /* SynaEnableFlashing kicks off the reflash process
355 int SynaEnableFlashing(struct synaptics_ts_data
*ts
)
359 unsigned char uStatus
;
360 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
362 SYNAPTICS_INFO_MSG("Enable Reflash...\n");
364 // Reflash is enabled by first reading the bootloader ID from the firmware and write it back
365 SynaReadBootloadID(ts
);
366 SynaWriteBootloadID(ts
);
368 // Make sure Reflash is not already enabled
370 readRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
371 } while (((uData
& 0x0f) != 0x00));
374 readRMI (ts
->client
, SynaF01DataBase
, &uStatus
, 1);
376 if ((uStatus
&0x40) == 0)
378 // Write the "Enable Flash Programming command to F34 Control register
379 // Wait for ATTN and then clear the ATTN.
381 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
382 ret
= SynaWaitForATTN(100, ts
);
384 SYNAPTICS_ERR_MSG("SynaWaitForATTN 100ms timeout error\n");
387 readRMI(ts
->client
, (SynaF01DataBase
+ 1), &uStatus
, 1);
388 // Scan the PDT again to ensure all register offsets are correct
390 // Read the "Program Enabled" bit of the F34 Control register, and proceed only if the
393 readRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
394 // In practice, if uData!=0x80 happens for multiple counts, it indicates reflash
395 // is failed to be enabled, and program should quit
396 }while (uData
!= 0x80);
402 /* SynaProgramConfiguration writes the configuration section of the image block by block
404 int SynaProgramConfiguration(struct synaptics_ts_data
*ts
)
406 unsigned char uData
[2];
407 unsigned char *puData
= (unsigned char *)&my_image_bin
[0xb100];
409 unsigned short blockNum
;
410 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
412 SYNAPTICS_INFO_MSG("Program Configuration Section...\n");
414 for (blockNum
= 0; blockNum
< SynaConfigBlockCount
; blockNum
++)
416 uData
[0] = blockNum
& 0xff;
417 uData
[1] = (blockNum
& 0xff00) >> 8;
419 //Block by blcok, write the block number and data to the corresponding F34 data registers
420 writeRMI(ts
->client
, SynaF34Reflash_BlockNum
, &uData
[0], 2);
421 writeRMI(ts
->client
, SynaF34Reflash_BlockData
, puData
, SynaConfigBlockSize
);
422 puData
+= SynaConfigBlockSize
;
424 // Issue the "Write Configuration Block" command
426 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
[0], 1);
427 if(SynaWaitATTN(ts
) < 0) return -1;
428 SYNAPTICS_INFO_MSG(".\n");
433 /* SynaFinalizeReflash finalizes the reflash process
435 int SynaFinalizeReflash(struct synaptics_ts_data
*ts
)
439 unsigned char uStatus
;
440 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
442 SYNAPTICS_INFO_MSG("Finalizing Reflash...\n");
444 // Issue the "Reset" command to F01 command register to reset the chip
445 // This command will also test the new firmware image and check if its is valid
447 writeRMI(ts
->client
, SynaF01CommandBase
, &uData
, 1);
449 ret
= SynaWaitForATTN(100, ts
);
451 SYNAPTICS_ERR_MSG("SynaWaitForATTN 100ms timeout error\n");
454 readRMI(ts
->client
, SynaF01DataBase
, &uData
, 1);
456 // Sanity check that the reflash process is still enabled
458 readRMI(ts
->client
, SynaF34_FlashControl
, &uStatus
, 1);
459 } while ((uStatus
& 0x0f) != 0x00);
460 readRMI(ts
->client
, (SynaF01DataBase
+ 1), &uStatus
, 1);
465 // Check if the "Program Enabled" bit in F01 data register is cleared
466 // Reflash is completed, and the image passes testing when the bit is cleared
468 readRMI(ts
->client
, SynaF01DataBase
, &uData
, 1);
469 } while ((uData
& 0x40) != 0);
471 // Rescan PDT the update any changed register offsets
474 SYNAPTICS_INFO_MSG("Reflash Completed. Please reboot.\n");
479 /* SynaFlashFirmwareWrite writes the firmware section of the image block by block
481 int SynaFlashFirmwareWrite(struct synaptics_ts_data
*ts
)
483 unsigned char *puFirmwareData
= (unsigned char *)&my_image_bin
[0x100];
484 unsigned char uData
[2];
485 unsigned short blockNum
;
486 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
488 for (blockNum
= 0; blockNum
< SynaFirmwareBlockCount
; ++blockNum
)
490 if(blockNum
%100 == 0)
491 SYNAPTICS_INFO_MSG("blockNum = [%d], (SynaFirmwareBlockCount=%d)\n", blockNum
, SynaFirmwareBlockCount
);
492 //Block by blcok, write the block number and data to the corresponding F34 data registers
493 uData
[0] = blockNum
& 0xff;
494 uData
[1] = (blockNum
& 0xff00) >> 8;
495 writeRMI(ts
->client
, SynaF34Reflash_BlockNum
, &uData
[0], 2);
497 writeRMI(ts
->client
, SynaF34Reflash_BlockData
, puFirmwareData
, SynaFirmwareBlockSize
);
498 puFirmwareData
+= SynaFirmwareBlockSize
;
500 // Issue the "Write Firmware Block" command
502 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
[0], 1);
504 if(SynaWaitATTN(ts
) < 0) return -1;
510 /* SynaProgramFirmware prepares the firmware writing process
512 int SynaProgramFirmware(struct synaptics_ts_data
*ts
)
516 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
518 SYNAPTICS_INFO_MSG("Program Firmware Section...\n");
520 SynaWriteBootloadID(ts
);
523 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
529 ret
= SynaFlashFirmwareWrite(ts
);
531 SYNAPTICS_ERR_MSG("SynaFlashFirmwareWrite fail\n");
539 /* eraseConfigBlock erases the config block
541 int eraseConfigBlock(struct synaptics_ts_data
*ts
)
544 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
546 // Erase of config block is done by first entering into bootloader mode
547 SynaReadBootloadID(ts
);
548 SynaWriteBootloadID(ts
);
550 // Command 7 to erase config block
552 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
, 1);
554 if(SynaWaitATTN(ts
) < 0) return -1;
559 // CRC_Calculate illustates how to calculate a checksum from the config block data.
560 // With DS4, the config block checksum is calculated and applies towards the end of
561 // the config block data automatically
562 // Variable data to this function represents the data only portion of the config block
563 // Varaible len represents the length of the variable data.
564 void CRC_Calculate(unsigned short * data
, unsigned short len
)
567 unsigned long Data_CRC
= 0xffffffff;
568 unsigned long sum1
= (unsigned long)(Data_CRC
& 0xFFFF);
569 unsigned long sum2
= (unsigned long)(Data_CRC
>> 16);
570 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
572 for (i
= 0; i
< len
; i
++)
574 unsigned long temp
= data
[i
];
577 sum1
= (unsigned long)((sum1
& 0xffff) + (sum1
>> 16));
578 sum2
= (unsigned long)((sum2
& 0xffff) + (sum2
>> 16));
581 Data_CRC
= (unsigned long)(sum2
<< 16 | sum1
);
584 int SynaBootloaderLock(struct synaptics_ts_data
*ts
)
587 unsigned short lockBlockCount
;
588 unsigned char *puFirmwareData
= SynalockImgData
;
589 unsigned char uData
[2];
590 unsigned short uBlockNum
;
592 // Check if device is in unlocked state
593 readRMI(ts
->client
, (SynaF34QueryBase
+ 2), &uData
[0], 1);
598 SYNAPTICS_INFO_MSG("Device unlocked. Lock it first...\n");
599 // Different bootloader version has different block count for the lockdown data
600 // Need to check the bootloader version from the image file being reflashed
601 switch (SynafirmwareImgVersion
)
618 // Write the lockdown info block by block
619 // This reference code of lockdown process does not check for bootloader version
620 // currently programmed on the ASIC against the bootloader version of the image to
621 // be reflashed. Such case should not happen in practice. Reflashing cross different
622 // bootloader versions is not supported.
623 for (uBlockNum
= 0; uBlockNum
< lockBlockCount
; ++uBlockNum
)
625 uData
[0] = uBlockNum
& 0xff;
626 uData
[1] = (uBlockNum
& 0xff00) >> 8;
628 /* Write Block Number */
629 readRMI(ts
->client
, SynaF34Reflash_BlockNum
, &uData
[0], 2);
631 /* Write Data Block */
632 writeRMI(ts
->client
, SynaF34Reflash_BlockData
, puFirmwareData
, SynaFirmwareBlockSize
);
634 /* Move to next data block */
635 puFirmwareData
+= SynaFirmwareBlockSize
;
637 /* Issue Write Lockdown Block command */
639 writeRMI(ts
->client
, SynaF34_FlashControl
, &uData
[0], 1);
641 /* Wait ATTN until device is done writing the block and is ready for the next. */
642 if(SynaWaitATTN(ts
) < 0) return -1;
644 SYNAPTICS_INFO_MSG("Device locking done.\n");
646 // Enable reflash again to finish the lockdown process.
647 // Since this lockdown process is part of the reflash process, we are enabling
648 // reflash instead, rather than resetting the device to finish the unlock procedure.
649 ret
= SynaEnableFlashing(ts
);
651 SYNAPTICS_ERR_MSG("SynaEnableFlashing fail\n");
655 else SYNAPTICS_INFO_MSG("Device already locked.\n");
660 /* ConfigBlockReflash reflashes the config block only
662 int ConfigBlockReflash(struct synaptics_ts_data
*ts
)
665 unsigned char uData
[2];
666 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
670 SynaReadConfigInfo(ts
);
672 SynaReadFirmwareInfo(ts
);
674 SynaF34_FlashControl
= SynaF34DataBase
+ SynaFirmwareBlockSize
+ 2;
676 ret
= SynaEnableFlashing(ts
);
678 SYNAPTICS_ERR_MSG("SynaEnableFlashing fail\n");
682 // Check if device is in unlocked state
683 readRMI(ts
->client
, (SynaF34QueryBase
+ 2), &uData
[0], 1);
688 ret
= SynaFinalizeReflash(ts
);
690 SYNAPTICS_ERR_MSG("SynaFinalizeReflash fail\n");
694 // Do not reflash config block if not locked.
697 ret
= eraseConfigBlock(ts
);
699 SYNAPTICS_ERR_MSG("eraseConfigBlock fail\n");
703 ret
= SynaProgramConfiguration(ts
);
705 SYNAPTICS_ERR_MSG("SynaProgramConfiguration fail\n");
709 ret
= SynaFinalizeReflash(ts
);
711 SYNAPTICS_ERR_MSG("SynaFinalizeReflash fail\n");
718 /* CompleteReflash reflashes the entire user image, including the configuration block and firmware
720 int CompleteReflash(struct synaptics_ts_data
*ts
)
723 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
726 SynaReadConfigInfo(ts
);
728 SynaReadFirmwareInfo(ts
);
730 SynaF34_FlashControl
= SynaF34DataBase
+ SynaFirmwareBlockSize
+ 2;
732 ret
= SynaEnableFlashing(ts
);
734 SYNAPTICS_ERR_MSG("SynaEnableFlashing fail\n");
738 ret
= SynaProgramFirmware(ts
);
740 SYNAPTICS_ERR_MSG("SynaProgramFirmware fail\n");
744 ret
= SynaProgramConfiguration(ts
);
746 SYNAPTICS_ERR_MSG("SynaProgramConfiguration fail\n");
750 ret
= SynaFinalizeReflash(ts
);
752 SYNAPTICS_ERR_MSG("SynaFinalizeReflash fail\n");
759 int CompleteReflash_Lockdown(struct synaptics_ts_data
*ts
)
762 SYNAPTICS_INFO_MSG("%s\n", __FUNCTION__
);
766 SynaReadConfigInfo(ts
);
768 SynaReadFirmwareInfo(ts
);
770 SynaF34_FlashControl
= SynaF34DataBase
+ SynaFirmwareBlockSize
+ 2;
772 ret
= SynaEnableFlashing(ts
);
774 SYNAPTICS_ERR_MSG("SynaEnableFlashing fail\n");
778 ret
= SynaBootloaderLock(ts
);
780 SYNAPTICS_ERR_MSG("SynaBootloaderLock fail\n");
784 ret
= SynaProgramFirmware(ts
);
786 SYNAPTICS_ERR_MSG("SynaProgramFirmware fail\n");
790 ret
= SynaProgramConfiguration(ts
);
792 SYNAPTICS_ERR_MSG("SynaProgramConfiguration fail\n");
796 ret
= SynaFinalizeReflash(ts
);
798 SYNAPTICS_ERR_MSG("SynaFinalizeReflash fail\n");