105-v5.18-mtd-rawnand-brcmnand-Add-platform-data-structure-for-BCMA.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From: Florian Fainelli <[email protected]>
  2. Subject: [PATCH v3 6/9] mtd: rawnand: brcmnand: Add platform data structure for BCMA
  3. Date: Fri, 07 Jan 2022 10:46:11 -0800
  4. Content-Type: text/plain; charset="utf-8"
  5. Update the BCMA's chipcommon nand flash driver to detect which
  6. chip-select is used and pass that information via platform data to the
  7. brcmnand driver. Make sure that the brcmnand platform data structure is
  8. always at the beginning of the platform data of the "nflash" device
  9. created by BCMA to allow brcmnand to safely de-reference it.
  10. Signed-off-by: Florian Fainelli <[email protected]>
  11. ---
  12. MAINTAINERS | 1 +
  13. drivers/bcma/driver_chipcommon_nflash.c | 20 +++++++++++++++++++-
  14. include/linux/bcma/bcma_driver_chipcommon.h | 5 +++++
  15. include/linux/platform_data/brcmnand.h | 12 ++++++++++++
  16. 4 files changed, 37 insertions(+), 1 deletion(-)
  17. create mode 100644 include/linux/platform_data/brcmnand.h
  18. --- a/MAINTAINERS
  19. +++ b/MAINTAINERS
  20. @@ -3901,6 +3901,7 @@ L: [email protected]
  21. L: [email protected]
  22. S: Maintained
  23. F: drivers/mtd/nand/raw/brcmnand/
  24. +F: include/linux/platform_data/brcmnand.h
  25. BROADCOM STB PCIE DRIVER
  26. M: Jim Quinlan <[email protected]>
  27. --- a/drivers/bcma/driver_chipcommon_nflash.c
  28. +++ b/drivers/bcma/driver_chipcommon_nflash.c
  29. @@ -7,18 +7,28 @@
  30. #include "bcma_private.h"
  31. +#include <linux/bitops.h>
  32. #include <linux/platform_device.h>
  33. +#include <linux/platform_data/brcmnand.h>
  34. #include <linux/bcma/bcma.h>
  35. +/* Alternate NAND controller driver name in order to allow both bcm47xxnflash
  36. + * and bcma_brcmnand to be built into the same kernel image.
  37. + */
  38. +static const char *bcma_nflash_alt_name = "bcma_brcmnand";
  39. +
  40. struct platform_device bcma_nflash_dev = {
  41. .name = "bcma_nflash",
  42. .num_resources = 0,
  43. };
  44. +static const char *probes[] = { "bcm47xxpart", NULL };
  45. +
  46. /* Initialize NAND flash access */
  47. int bcma_nflash_init(struct bcma_drv_cc *cc)
  48. {
  49. struct bcma_bus *bus = cc->core->bus;
  50. + u32 reg;
  51. if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
  52. cc->core->id.rev != 38) {
  53. @@ -33,8 +43,16 @@ int bcma_nflash_init(struct bcma_drv_cc
  54. cc->nflash.present = true;
  55. if (cc->core->id.rev == 38 &&
  56. - (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
  57. + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) {
  58. cc->nflash.boot = true;
  59. + /* Determine the chip select that is being used */
  60. + reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff;
  61. + cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1;
  62. + cc->nflash.brcmnand_info.part_probe_types = probes;
  63. + cc->nflash.brcmnand_info.ecc_stepsize = 512;
  64. + cc->nflash.brcmnand_info.ecc_strength = 1;
  65. + bcma_nflash_dev.name = bcma_nflash_alt_name;
  66. + }
  67. /* Prepare platform device, but don't register it yet. It's too early,
  68. * malloc (required by device_private_init) is not available yet. */
  69. --- a/include/linux/bcma/bcma_driver_chipcommon.h
  70. +++ b/include/linux/bcma/bcma_driver_chipcommon.h
  71. @@ -3,6 +3,7 @@
  72. #define LINUX_BCMA_DRIVER_CC_H_
  73. #include <linux/platform_device.h>
  74. +#include <linux/platform_data/brcmnand.h>
  75. #include <linux/gpio.h>
  76. /** ChipCommon core registers. **/
  77. @@ -599,6 +600,10 @@ struct bcma_sflash {
  78. #ifdef CONFIG_BCMA_NFLASH
  79. struct bcma_nflash {
  80. + /* Must be the fist member for the brcmnand driver to
  81. + * de-reference that structure.
  82. + */
  83. + struct brcmnand_platform_data brcmnand_info;
  84. bool present;
  85. bool boot; /* This is the flash the SoC boots from */
  86. };
  87. --- /dev/null
  88. +++ b/include/linux/platform_data/brcmnand.h
  89. @@ -0,0 +1,12 @@
  90. +/* SPDX-License-Identifier: GPL-2.0-only */
  91. +#ifndef BRCMNAND_PLAT_DATA_H
  92. +#define BRCMNAND_PLAT_DATA_H
  93. +
  94. +struct brcmnand_platform_data {
  95. + int chip_select;
  96. + const char * const *part_probe_types;
  97. + unsigned int ecc_stepsize;
  98. + unsigned int ecc_strength;
  99. +};
  100. +
  101. +#endif /* BRCMNAND_PLAT_DATA_H */