364-MIPS-BCM63XX-allow-board-files-to-provide-sprom-fixu.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 8575548b08e33c9ff4fd540abec09dd177e33682 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Thu, 31 Jul 2014 19:12:33 +0200
  4. Subject: [PATCH 09/10] MIPS: BCM63XX: allow board files to provide sprom
  5. fixups
  6. Allow board_info files to supply fixups for the base sproms to adapt
  7. them to the actual used sprom contents in case they do not use the
  8. default ones.
  9. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  10. ---
  11. arch/mips/bcm63xx/sprom.c | 14 +++++++++++++-
  12. .../mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h | 8 ++++++++
  13. 2 files changed, 21 insertions(+), 1 deletion(-)
  14. --- a/arch/mips/bcm63xx/sprom.c
  15. +++ b/arch/mips/bcm63xx/sprom.c
  16. @@ -883,6 +883,14 @@ static int sprom_extract(struct ssb_spro
  17. return 0;
  18. }
  19. +void sprom_apply_fixups(u16 *sprom, struct sprom_fixup *fixups, int n)
  20. +{
  21. + unsigned int i;
  22. +
  23. + for (i = 0; i < n; i++)
  24. + sprom[fixups[i].offset] = fixups[i].value;
  25. +}
  26. +
  27. static __initdata u16 template_sprom[220];
  28. #endif
  29. @@ -961,8 +969,12 @@ int __init bcm63xx_register_fallback_spr
  30. return -EINVAL;
  31. }
  32. - if (size > 0)
  33. + if (size > 0) {
  34. + sprom_apply_fixups(template_sprom, data->board_fixups,
  35. + data->num_board_fixups);
  36. +
  37. sprom_extract(&bcm63xx_sprom, template_sprom, size);
  38. + }
  39. memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
  40. memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
  41. --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
  42. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
  43. @@ -21,9 +21,17 @@ enum sprom_type {
  44. SPROM_BCM4331,
  45. };
  46. +struct sprom_fixup {
  47. + u16 offset;
  48. + u16 value;
  49. +};
  50. +
  51. struct fallback_sprom_data {
  52. u8 mac_addr[ETH_ALEN];
  53. enum sprom_type type;
  54. +
  55. + struct sprom_fixup *board_fixups;
  56. + unsigned int num_board_fixups;
  57. };
  58. int bcm63xx_register_fallback_sprom(struct fallback_sprom_data *data);