pmt.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2015 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _PMT_H
  14. #define _PMT_H
  15. #include <mach/mtk_nand.h>
  16. #include <mtk_nand_util.h>
  17. #if defined(CONFIG_MTK_TLC_NAND_SUPPORT)
  18. #include "partition_define_tlc.h"
  19. #else
  20. #include "partition_define_mlc.h"
  21. #endif
  22. #define MAX_PARTITION_NAME_LEN 64
  23. int new_part_tab(u8 *buf, struct mtd_info *mtd);
  24. int update_part_tab(struct mtd_info *mtd);
  25. static int read_pmt(void __user *arg);
  26. typedef u32(*GetLowPageNumber) (u32 pageNo);
  27. extern GetLowPageNumber functArray[];
  28. extern bool g_bInitDone;
  29. extern struct mtk_nand_host *host;
  30. extern flashdev_info gn_devinfo;
  31. extern bool g_bInitDone;
  32. #define REGION_LOW_PAGE 0x004C4F57
  33. #define REGION_FULL_PAGE 0x46554C4C
  34. #if defined(CONFIG_MTK_TLC_NAND_SUPPORT)
  35. #define REGION_SLC_MODE 0x00534C43
  36. #define REGION_TLC_MODE 0x00544C43
  37. #endif
  38. typedef struct {
  39. unsigned char name[MAX_PARTITION_NAME_LEN]; /* partition name */
  40. unsigned long long size; /* partition size */
  41. unsigned long long part_id; /* partition region */
  42. unsigned long long offset; /* partition start */
  43. unsigned long long mask_flags; /* partition flags */
  44. } pt_resident;
  45. #define DM_ERR_OK 0
  46. #define DM_ERR_NO_VALID_TABLE 9
  47. #define DM_ERR_NO_SPACE_FOUND 10
  48. #define ERR_NO_EXIST 1
  49. #define PT_SIG 0x50547633 /*"PTv3" */
  50. #define MPT_SIG 0x4D505433 /*"MPT3" */
  51. #define PT_SIG_SIZE 8
  52. #define is_valid_pt(buf) (!memcmp(buf, "3vTP", 4))
  53. #define is_valid_mpt(buf) (!memcmp(buf, "3TPM", 4))
  54. #define RETRY_TIMES 5
  55. extern u32 slc_ratio;
  56. extern u32 sys_slc_ratio;
  57. extern u32 usr_slc_ratio;
  58. typedef u32 (*GetLowPageNumber)(u32 pageNo);
  59. extern GetLowPageNumber functArray[];
  60. extern u32 system_block_count;
  61. typedef struct _DM_PARTITION_INFO {
  62. char part_name[MAX_PARTITION_NAME_LEN]; /* the name of partition */
  63. unsigned long long start_addr; /* the start address of partition */
  64. unsigned long long part_len; /* the length of partition */
  65. unsigned char part_visibility; /* part_visibility is 0: this partition is hidden and CANNOT download */
  66. /* part_visibility is 1: this partition is visible and can download */
  67. unsigned char dl_selected; /* dl_selected is 0: this partition is NOT selected to download */
  68. /* dl_selected is 1: this partition is selected to download */
  69. } DM_PARTITION_INFO;
  70. typedef struct {
  71. unsigned int pattern;
  72. unsigned int part_num; /* The actual number of partitions */
  73. DM_PARTITION_INFO part_info[PART_MAX_COUNT];
  74. } DM_PARTITION_INFO_PACKET;
  75. typedef struct {
  76. int sequencenumber:8;
  77. int tool_or_sd_update:8;
  78. int mirror_pt_dl:4;
  79. int mirror_pt_has_space:4;
  80. int pt_changed:4;
  81. int pt_has_space:4;
  82. } pt_info;
  83. #endif