920-ar7part.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. --- a/drivers/mtd/ar7part.c
  2. +++ b/drivers/mtd/ar7part.c
  3. @@ -30,11 +30,14 @@
  4. #include <uapi/linux/magic.h>
  5. +#include <asm/mach-ar7/prom.h>
  6. +
  7. #define AR7_PARTS 4
  8. #define ROOT_OFFSET 0xe0000
  9. #define LOADER_MAGIC1 le32_to_cpu(0xfeedfa42)
  10. #define LOADER_MAGIC2 le32_to_cpu(0xfeed1281)
  11. +#define LOADER_MAGIC3 le32_to_cpu(0x434d4d4c)
  12. struct ar7_bin_rec {
  13. unsigned int checksum;
  14. @@ -42,12 +45,16 @@ struct ar7_bin_rec {
  15. unsigned int address;
  16. };
  17. +int create_titan_partitions(struct mtd_info *master,
  18. + struct mtd_partition **pparts,
  19. + struct mtd_part_parser_data *data);
  20. +
  21. static int create_mtd_partitions(struct mtd_info *master,
  22. struct mtd_partition **pparts,
  23. struct mtd_part_parser_data *data)
  24. {
  25. struct ar7_bin_rec header;
  26. - unsigned int offset;
  27. + unsigned int offset, mtd_start, mtd_end;
  28. size_t len;
  29. unsigned int pre_size = master->erasesize, post_size = 0;
  30. unsigned int root_offset = ROOT_OFFSET;
  31. @@ -55,6 +62,16 @@ static int create_mtd_partitions(struct
  32. int retries = 10;
  33. struct mtd_partition *ar7_parts;
  34. + const char *prom_str = prom_getenv("ProductID");
  35. + char mtd_name[] = "mtd1";
  36. + if(prom_str &&
  37. + (strcmp(prom_str, "CYWL")==0 ||
  38. + strcmp(prom_str, "CYWM")==0 ||
  39. + strcmp(prom_str, "CYLM")==0 ||
  40. + strcmp(prom_str, "CYLL")==0)){
  41. + return create_titan_partitions(master, pparts, data);
  42. + }
  43. +
  44. ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL);
  45. if (!ar7_parts)
  46. return -ENOMEM;
  47. @@ -83,34 +100,39 @@ static int create_mtd_partitions(struct
  48. pre_size = offset;
  49. - if (!ar7_parts[1].offset) {
  50. - ar7_parts[1].offset = master->size - master->erasesize;
  51. - post_size = master->erasesize;
  52. - }
  53. -
  54. switch (header.checksum) {
  55. - case LOADER_MAGIC1:
  56. - while (header.length) {
  57. - offset += sizeof(header) + header.length;
  58. - mtd_read(master, offset, sizeof(header), &len,
  59. - (uint8_t *)&header);
  60. - }
  61. - root_offset = offset + sizeof(header) + 4;
  62. - break;
  63. case LOADER_MAGIC2:
  64. + for (retries = 0; retries <= 9; retries++) {
  65. + mtd_name[3] = '0' + retries;
  66. + prom_str = prom_getenv(mtd_name);
  67. + if (prom_str == NULL)
  68. + continue;
  69. + sscanf(prom_str, "%i,%i", &mtd_start, &mtd_end);
  70. + if (pre_size == (mtd_start & 0x1ffffff)) {
  71. + ar7_parts[1].offset = mtd_end &= 0x1ffffff;
  72. + ar7_parts[1].size = post_size = master->size - mtd_end;
  73. + break;
  74. + }
  75. + }
  76. + case LOADER_MAGIC1:
  77. + root_offset = (header.checksum == LOADER_MAGIC1) ? 4 : 0;
  78. while (header.length) {
  79. offset += sizeof(header) + header.length;
  80. mtd_read(master, offset, sizeof(header), &len,
  81. (uint8_t *)&header);
  82. }
  83. - root_offset = offset + sizeof(header) + 4 + 0xff;
  84. - root_offset &= ~(uint32_t)0xff;
  85. + root_offset += offset + sizeof(header);
  86. break;
  87. default:
  88. printk(KERN_WARNING "Unknown magic: %08x\n", header.checksum);
  89. break;
  90. }
  91. + if (!ar7_parts[1].offset) {
  92. + post_size = master->erasesize;
  93. + ar7_parts[1].offset = master->size - post_size;
  94. + }
  95. +
  96. mtd_read(master, root_offset, sizeof(header), &len, (u8 *)&header);
  97. if (header.checksum != SQUASHFS_MAGIC) {
  98. root_offset += master->erasesize - 1;
  99. --- a/drivers/mtd/titanpart.c
  100. +++ b/drivers/mtd/titanpart.c
  101. @@ -149,7 +149,7 @@ static void titan_add_partition(char * e
  102. }
  103. int create_titan_partitions(struct mtd_info *master,
  104. struct mtd_partition **pparts,
  105. - unsigned long origin)
  106. + struct mtd_part_parser_data *data)
  107. {
  108. struct nsp_img_hdr_head hdr;
  109. struct nsp_img_hdr_section_info sect_info;