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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 597715c61ae75a05ab3310a34ff3857a006f0f63 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  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 <[email protected]>
  9. ---
  10. drivers/bcma/driver_chipcommon_sflash.c | 29 +++++++++++++++++++++++++++++
  11. 1 file changed, 29 insertions(+)
  12. diff --git a/drivers/bcma/driver_chipcommon_sflash.c b/drivers/bcma/driver_chipcommon_sflash.c
  13. index 7e11ef4..25d9e17 100644
  14. --- a/drivers/bcma/driver_chipcommon_sflash.c
  15. +++ b/drivers/bcma/driver_chipcommon_sflash.c
  16. @@ -9,6 +9,7 @@
  17. #include <linux/platform_device.h>
  18. #include <linux/bcma/bcma.h>
  19. +#include <bcm47xx_board.h>
  20. static struct resource bcma_sflash_resource = {
  21. .name = "bcma_sflash",
  22. @@ -41,6 +42,13 @@ static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
  23. { NULL },
  24. };
  25. +/* Some devices use smaller blocks (and have more of them) */
  26. +static const struct bcma_sflash_tbl_e bcma_sflash_st_shrink_tbl[] = {
  27. + { "M25P16", 0x14, 0x1000, 512, },
  28. + { "M25P32", 0x15, 0x1000, 1024, },
  29. + { NULL },
  30. +};
  31. +
  32. static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  33. { "SST25WF512", 1, 0x1000, 16, },
  34. { "SST25VF512", 0x48, 0x1000, 16, },
  35. @@ -84,6 +92,23 @@ static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
  36. bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
  37. }
  38. +const struct bcma_sflash_tbl_e *bcma_sflash_shrink_flash(u32 id)
  39. +{
  40. + enum bcm47xx_board board = bcm47xx_board_get();
  41. + const struct bcma_sflash_tbl_e *e;
  42. +
  43. + switch (board) {
  44. + case BCM47XX_BOARD_NETGEAR_WGR614_V10:
  45. + for (e = bcma_sflash_st_shrink_tbl; e->name; e++) {
  46. + if (e->id == id)
  47. + return e;
  48. + }
  49. + return NULL;
  50. + default:
  51. + return NULL;
  52. + }
  53. +}
  54. +
  55. /* Initialize serial flash access */
  56. int bcma_sflash_init(struct bcma_drv_cc *cc)
  57. {
  58. @@ -114,6 +139,10 @@ int bcma_sflash_init(struct bcma_drv_cc *cc)
  59. case 0x13:
  60. return -ENOTSUPP;
  61. default:
  62. + e = bcma_sflash_shrink_flash(id);
  63. + if (e)
  64. + break;
  65. +
  66. for (e = bcma_sflash_st_tbl; e->name; e++) {
  67. if (e->id == id)
  68. break;
  69. --
  70. 1.8.4.5