ubispl.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */
  2. /*
  3. * Copyright (c) Thomas Gleixner <tglx@linutronix.de>
  4. */
  5. #ifndef __UBOOT_UBISPL_H
  6. #define __UBOOT_UBISPL_H
  7. /*
  8. * The following CONFIG options are relevant for UBISPL
  9. *
  10. * #define CONFIG_SPL_UBI_MAX_VOL_LEBS 256
  11. *
  12. * Defines the maximum number of logical erase blocks per loadable
  13. * (static) volume to size the ubispl internal arrays.
  14. *
  15. * #define CONFIG_SPL_UBI_MAX_PEB_SIZE (256*1024)
  16. *
  17. * Defines the maximum physical erase block size to size the fastmap
  18. * buffer for ubispl.
  19. *
  20. * #define CONFIG_SPL_UBI_MAX_PEBS 4096
  21. *
  22. * Define the maximum number of physical erase blocks to size the
  23. * ubispl internal arrays.
  24. *
  25. * #define CONFIG_SPL_UBI_VOL_IDS 8
  26. *
  27. * Defines the maximum number of volumes in which UBISPL is
  28. * interested. Limits the amount of memory for the scan data and
  29. * speeds up the scan process as we simply ignore stuff which we dont
  30. * want to load from the SPL anyway. So the volumes which can be
  31. * loaded in the above example are ids 0 - 7
  32. */
  33. /*
  34. * The struct definition is in drivers/mtd/ubispl/ubispl.h. It does
  35. * not fit into the BSS due to the large buffer requirement of the
  36. * upstream fastmap code. So the caller of ubispl_load_volumes needs
  37. * to hand in a pointer to a free memory area where ubispl will place
  38. * its data. The area is not required to be initialized.
  39. */
  40. struct ubi_scan_info;
  41. typedef int (*ubispl_read_flash)(int pnum, int offset, int len, void *dst);
  42. /**
  43. * struct ubispl_info - description structure for fast ubi scan
  44. * @ubi: Pointer to memory space for ubi scan info structure
  45. * @peb_size: Physical erase block size
  46. * @vid_offset: Offset of the VID header
  47. * @leb_start: Start of the logical erase block, i.e. offset of data
  48. * @peb_count: Number of physical erase blocks in the UBI FLASH area
  49. * aka MTD partition.
  50. * @peb_offset: Offset of PEB0 in the UBI FLASH area (aka MTD partition)
  51. * to the real start of the FLASH in erase blocks.
  52. * @fastmap: Enable fastmap attachment
  53. * @read: Read function to access the flash
  54. */
  55. struct ubispl_info {
  56. struct ubi_scan_info *ubi;
  57. u32 peb_size;
  58. u32 vid_offset;
  59. u32 leb_start;
  60. u32 peb_count;
  61. u32 peb_offset;
  62. int fastmap;
  63. ubispl_read_flash read;
  64. };
  65. /**
  66. * struct ubispl_load - structure to describe a volume to load
  67. * @vol_id: Volume id
  68. * @load_addr: Load address of the volume
  69. */
  70. struct ubispl_load {
  71. int vol_id;
  72. void *load_addr;
  73. };
  74. /**
  75. * ubispl_load_volumes - Scan flash and load volumes
  76. * @info: Pointer to the ubi scan info structure
  77. * @lovls: Pointer to array of volumes to load
  78. * @nrvols: Array size of @lovls
  79. */
  80. int ubispl_load_volumes(struct ubispl_info *info,
  81. struct ubispl_load *lvols, int nrvols);
  82. #endif