030-02-MIPS-BCM47XX-Make-ssb-init-NVRAM-instead-of-bcm47xx-.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. From 21400f252a97755579b43a4dc95dd02cd7f0ca75 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Wed, 3 Sep 2014 22:59:45 +0200
  4. Subject: [PATCH 155/158] MIPS: BCM47XX: Make ssb init NVRAM instead of bcm47xx
  5. polling it
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. This makes NVRAM code less bcm47xx/ssb specific allowing it to become a
  10. standalone driver in the future. A similar patch for bcma will follow
  11. when it's ready.
  12. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  13. Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
  14. Cc: linux-mips@linux-mips.org
  15. Patchwork: https://patchwork.linux-mips.org/patch/7612/
  16. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  17. ---
  18. arch/mips/bcm47xx/nvram.c | 30 +++++++---------------
  19. arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h | 1 +
  20. drivers/ssb/driver_mipscore.c | 14 +++++++++-
  21. 3 files changed, 23 insertions(+), 22 deletions(-)
  22. --- a/arch/mips/bcm47xx/nvram.c
  23. +++ b/arch/mips/bcm47xx/nvram.c
  24. @@ -98,7 +98,14 @@ found:
  25. return 0;
  26. }
  27. -static int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
  28. +/*
  29. + * On bcm47xx we need access to the NVRAM very early, so we can't use mtd
  30. + * subsystem to access flash. We can't even use platform device / driver to
  31. + * store memory offset.
  32. + * To handle this we provide following symbol. It's supposed to be called as
  33. + * soon as we get info about flash device, before any NVRAM entry is needed.
  34. + */
  35. +int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
  36. {
  37. void __iomem *iobase;
  38. int err;
  39. @@ -114,25 +121,6 @@ static int bcm47xx_nvram_init_from_mem(u
  40. return err;
  41. }
  42. -#ifdef CONFIG_BCM47XX_SSB
  43. -static int nvram_init_ssb(void)
  44. -{
  45. - struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
  46. - u32 base;
  47. - u32 lim;
  48. -
  49. - if (mcore->pflash.present) {
  50. - base = mcore->pflash.window;
  51. - lim = mcore->pflash.window_size;
  52. - } else {
  53. - pr_err("Couldn't find supported flash memory\n");
  54. - return -ENXIO;
  55. - }
  56. -
  57. - return bcm47xx_nvram_init_from_mem(base, lim);
  58. -}
  59. -#endif
  60. -
  61. #ifdef CONFIG_BCM47XX_BCMA
  62. static int nvram_init_bcma(void)
  63. {
  64. @@ -168,7 +156,7 @@ static int nvram_init(void)
  65. switch (bcm47xx_bus_type) {
  66. #ifdef CONFIG_BCM47XX_SSB
  67. case BCM47XX_BUS_TYPE_SSB:
  68. - return nvram_init_ssb();
  69. + break;
  70. #endif
  71. #ifdef CONFIG_BCM47XX_BCMA
  72. case BCM47XX_BUS_TYPE_BCMA:
  73. --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
  74. +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
  75. @@ -32,6 +32,7 @@ struct nvram_header {
  76. #define NVRAM_MAX_VALUE_LEN 255
  77. #define NVRAM_MAX_PARAM_LEN 64
  78. +int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
  79. extern int bcm47xx_nvram_getenv(char *name, char *val, size_t val_len);
  80. static inline void bcm47xx_nvram_parse_macaddr(char *buf, u8 macaddr[6])
  81. --- a/drivers/ssb/driver_mipscore.c
  82. +++ b/drivers/ssb/driver_mipscore.c
  83. @@ -15,6 +15,9 @@
  84. #include <linux/serial_core.h>
  85. #include <linux/serial_reg.h>
  86. #include <linux/time.h>
  87. +#ifdef CONFIG_BCM47XX
  88. +#include <bcm47xx_nvram.h>
  89. +#endif
  90. #include "ssb_private.h"
  91. @@ -210,6 +213,7 @@ static void ssb_mips_serial_init(struct
  92. static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
  93. {
  94. struct ssb_bus *bus = mcore->dev->bus;
  95. + struct ssb_sflash *sflash = &mcore->sflash;
  96. struct ssb_pflash *pflash = &mcore->pflash;
  97. /* When there is no chipcommon on the bus there is 4MB flash */
  98. @@ -242,7 +246,15 @@ static void ssb_mips_flash_detect(struct
  99. }
  100. ssb_pflash:
  101. - if (pflash->present) {
  102. + if (sflash->present) {
  103. +#ifdef CONFIG_BCM47XX
  104. + bcm47xx_nvram_init_from_mem(sflash->window, sflash->size);
  105. +#endif
  106. + } else if (pflash->present) {
  107. +#ifdef CONFIG_BCM47XX
  108. + bcm47xx_nvram_init_from_mem(pflash->window, pflash->window_size);
  109. +#endif
  110. +
  111. ssb_pflash_data.width = pflash->buswidth;
  112. ssb_pflash_resource.start = pflash->window;
  113. ssb_pflash_resource.end = pflash->window + pflash->window_size;