dumchar.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 __DUMCHAR_H__
  14. #define __DUMCHAR_H__
  15. #include <linux/ioctl.h>
  16. #include <linux/cdev.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/semaphore.h>
  19. #if defined(CONFIG_MTK_TLC_NAND_SUPPORT)
  20. #include "partition_define_tlc.h"
  21. #else
  22. #include "partition_define_mlc.h"
  23. #endif
  24. extern void env_init(loff_t env_part_addr, int mtd_number);
  25. extern struct mtd_info *__mtd_next_device(int i);
  26. extern int init_pmt(void);
  27. /* #include <linux/mmc/sd_misc.h> */
  28. /*
  29. * Macros to help debugging
  30. */
  31. #define DUMCHAR_DEBUG
  32. #undef DUMCHAR_DEBUG /* undef it, just in case */
  33. #ifdef DUMCHAR_DEBUG
  34. #define DDEBUG(fmt, args...) pr_debug("dumchar_debug: " fmt, ## args)
  35. #else
  36. #define DDEBUG(fmt, args...)
  37. #endif
  38. #define DUMCHAR_MAJOR 0 /* dynamic major by default */
  39. #define MAX_SD_BUFFER (512)
  40. #define ALIE_LEN 512
  41. /* #define PrintBuff 1 */
  42. struct dumchar_dev {
  43. char *dumname; /* nvram boot userdata... */
  44. char actname[64]; /* full act name /dev/mt6573_sd0 /dev/mtd/mtd1 */
  45. struct semaphore sem; /* Mutual exclusion */
  46. dev_type type; /* nand device or emmc device? */
  47. unsigned long long size; /* partition size */
  48. struct cdev cdev;
  49. Region region; /* for emmc */
  50. unsigned long long start_address; /* for emmc */
  51. unsigned int mtd_index; /* for nand */
  52. };
  53. struct Region_Info {
  54. Region region;
  55. unsigned long long size_Byte;
  56. };
  57. struct file_obj {
  58. struct file *act_filp;
  59. int index; /* index in dumchar_dev arry */
  60. };
  61. #define REGION_NUM 8
  62. #define EXT_CSD_BOOT_SIZE_MULT 226 /* R */
  63. #define EXT_CSD_RPMB_SIZE_MULT 168 /* R */
  64. #define MSDC_RAW_DEVICE "/dev/misc-sd"
  65. extern u64 mtd_partition_start_address(struct mtd_info *mtd);
  66. #define mtd_for_each_device(mtd) \
  67. for ((mtd) = __mtd_next_device(0); \
  68. (mtd) != NULL; \
  69. (mtd) = __mtd_next_device(mtd->index + 1))
  70. #endif /*__DUMCHAR_H__ */