800-bcma-add-table-of-serial-flashes-with-smaller-blocks.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From 597715c61ae75a05ab3310a34ff3857a006f0f63 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Thu, 20 Nov 2014 21:32:42 +0100
  4. Subject: [PATCH] bcma: add table of serial flashes with smaller blocks
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  9. ---
  10. drivers/bcma/driver_chipcommon_sflash.c | 29 +++++++++++++++++++++++++++++
  11. 1 file changed, 29 insertions(+)
  12. --- a/drivers/bcma/driver_chipcommon_sflash.c
  13. +++ b/drivers/bcma/driver_chipcommon_sflash.c
  14. @@ -9,6 +9,7 @@
  15. #include <linux/platform_device.h>
  16. #include <linux/bcma/bcma.h>
  17. +#include <bcm47xx_board.h>
  18. static struct resource bcma_sflash_resource = {
  19. .name = "bcma_sflash",
  20. @@ -42,6 +43,13 @@ static const struct bcma_sflash_tbl_e bc
  21. { NULL },
  22. };
  23. +/* Some devices use smaller blocks (and have more of them) */
  24. +static const struct bcma_sflash_tbl_e bcma_sflash_st_shrink_tbl[] = {
  25. + { "M25P16", 0x14, 0x1000, 512, },
  26. + { "M25P32", 0x15, 0x1000, 1024, },
  27. + { NULL },
  28. +};
  29. +
  30. static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  31. { "SST25WF512", 1, 0x1000, 16, },
  32. { "SST25VF512", 0x48, 0x1000, 16, },
  33. @@ -85,6 +93,24 @@ static void bcma_sflash_cmd(struct bcma_
  34. bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
  35. }
  36. +const struct bcma_sflash_tbl_e *bcma_sflash_shrink_flash(u32 id)
  37. +{
  38. + enum bcm47xx_board board = bcm47xx_board_get();
  39. + const struct bcma_sflash_tbl_e *e;
  40. +
  41. + switch (board) {
  42. + case BCM47XX_BOARD_NETGEAR_WGR614_V10:
  43. + case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
  44. + for (e = bcma_sflash_st_shrink_tbl; e->name; e++) {
  45. + if (e->id == id)
  46. + return e;
  47. + }
  48. + return NULL;
  49. + default:
  50. + return NULL;
  51. + }
  52. +}
  53. +
  54. /* Initialize serial flash access */
  55. int bcma_sflash_init(struct bcma_drv_cc *cc)
  56. {
  57. @@ -115,6 +141,10 @@ int bcma_sflash_init(struct bcma_drv_cc
  58. case 0x13:
  59. return -ENOTSUPP;
  60. default:
  61. + e = bcma_sflash_shrink_flash(id);
  62. + if (e)
  63. + break;
  64. +
  65. for (e = bcma_sflash_st_tbl; e->name; e++) {
  66. if (e->id == id)
  67. break;