ftsFlash.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * FTS Capacitive touch screen controller (FingerTipS)
  4. *
  5. * Copyright (C) 2016-2019, STMicroelectronics Limited.
  6. * Authors: AMG(Analog Mems Group) <[email protected]>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. *
  23. **************************************************************************
  24. ** STMicroelectronics **
  25. **************************************************************************
  26. ** [email protected] **
  27. **************************************************************************
  28. * *
  29. * FTS API for Flashing the IC *
  30. * *
  31. **************************************************************************
  32. **************************************************************************
  33. *
  34. */
  35. #ifndef __FTS_FLASH_H
  36. #define __FTS_FLASH_H
  37. #include "ftsSoftware.h"
  38. //Flash possible status
  39. #define FLASH_READY 0
  40. #define FLASH_BUSY 1
  41. #define FLASH_UNKNOWN -1
  42. #define FLASH_STATUS_BYTES 1
  43. //Flash timing parameters
  44. #define FLASH_RETRY_COUNT 1000
  45. #define FLASH_WAIT_BEFORE_RETRY 50 //ms
  46. #define FLASH_WAIT_TIME 200 //ms
  47. //PATHS FW FILES
  48. //#define PATH_FILE_FW "fw.memh"
  49. #ifdef FTM3_CHIP
  50. #define PATH_FILE_FW "st_fts.bin"
  51. #else
  52. #define PATH_FILE_FW "st_fts.ftb"//new bin file structure
  53. #endif
  54. #ifndef FTM3_CHIP
  55. #define FLASH_CHUNK (64 * 1024)
  56. #define DMA_CHUNK (2 * 1024)
  57. #endif
  58. struct Firmware {
  59. u8 *data;
  60. u16 fw_ver;
  61. u16 config_id;
  62. u8 externalRelease[EXTERNAL_RELEASE_INFO_SIZE];
  63. int data_size;
  64. #ifndef FTM3_CHIP
  65. u32 sec0_size;
  66. u32 sec1_size;
  67. u32 sec2_size;
  68. u32 sec3_size;
  69. #endif
  70. };
  71. #ifdef FTM3_CHIP
  72. int flash_status(void);
  73. int flash_status_ready(void);
  74. int wait_for_flash_ready(void);
  75. #else
  76. int wait_for_flash_ready(u8 type);
  77. int fts_warm_boot(void);
  78. int flash_erase_unlock(void);
  79. int flash_full_erase(void);
  80. int flash_erase_page_by_page(int keep_cx);
  81. //int flash_erase_page_by_page_info(int page);
  82. int start_flash_dma(void);
  83. int fillFlash(u32 address, u8 *data, int size);
  84. #endif
  85. int flash_unlock(void);
  86. int fillMemory(u32 address, u8 *data, int size);
  87. int getFirmwareVersion(u16 *fw_vers, u16 *config_id);
  88. int getFWdata(const char *pathToFile, u8 **data, int *size, int from);
  89. int getFWdata_nocheck(const char *pathToFile, u8 **data, int *size, int from);
  90. int parseBinFile(u8 *fw_data, int fw_size, struct Firmware *fw, int keep_cx);
  91. int readFwFile(const char *path, struct Firmware *fw, int keep_cx);
  92. int flash_burn(struct Firmware *fw, int force_burn, int keep_cx);
  93. int flashProcedure(const char *path, int force, int keep_cx);
  94. #endif