901-mtd-bcm47xxpart-add-device-specific-workarounds.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  2. Subject: [PATCH] mtd: bcm47xxpart: add device specific workarounds
  3. MIME-Version: 1.0
  4. Content-Type: text/plain; charset=UTF-8
  5. Content-Transfer-Encoding: 8bit
  6. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  7. ---
  8. --- a/drivers/mtd/bcm47xxpart.c
  9. +++ b/drivers/mtd/bcm47xxpart.c
  10. @@ -15,6 +15,7 @@
  11. #include <linux/slab.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. +#include <linux/of.h>
  15. #include <uapi/linux/magic.h>
  16. @@ -249,6 +250,36 @@ static int bcm47xxpart_parse(struct mtd_
  17. break;
  18. }
  19. + /*
  20. + * Device specific workarounds (hacks). We should use DT to
  21. + * define partitions but we need a working TRX firmware splitter
  22. + * first.
  23. + */
  24. + if (of_machine_is_compatible("asus,rt-ac87u") && offset == 0x7ec0000) {
  25. + /*
  26. + * "asus" partition uses JFFS2 which we don't detect and
  27. + * we don't want to as this could affect other devices.
  28. + */
  29. + bcm47xxpart_add_part(&parts[curr_part++], "asus", offset, MTD_WRITEABLE);
  30. + continue;
  31. + } else if (of_machine_is_compatible("tplink,archer-c5-v2") && offset == 0xe40000) {
  32. + /*
  33. + * There is a whole set of partitions (not even listed
  34. + * by original firmware): "default-mac", "pin",
  35. + * "partition-table", etc.
  36. + */
  37. + bcm47xxpart_add_part(&parts[curr_part++], "tplink", offset, MTD_WRITEABLE);
  38. + continue;
  39. + } else if (of_machine_is_compatible("tplink,archer-c9-v1") && offset == 0xe40000) {
  40. + /*
  41. + * There is a whole set of partitions (not even listed
  42. + * by original firmware): "default-mac", "pin",
  43. + * "partition-table", etc.
  44. + */
  45. + bcm47xxpart_add_part(&parts[curr_part++], "tplink", offset, MTD_WRITEABLE);
  46. + continue;
  47. + }
  48. +
  49. /* Read beginning of the block */
  50. err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
  51. &bytes_read, (uint8_t *)buf);