driver_chipcommon_nflash.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Broadcom specific AMBA
  3. * ChipCommon NAND flash interface
  4. *
  5. * Licensed under the GNU/GPL. See COPYING for details.
  6. */
  7. #include "bcma_private.h"
  8. #include <linux/bitops.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/platform_data/brcmnand.h>
  11. #include <linux/bcma/bcma.h>
  12. /* Alternate NAND controller driver name in order to allow both bcm47xxnflash
  13. * and bcma_brcmnand to be built into the same kernel image.
  14. */
  15. static const char *bcma_nflash_alt_name = "bcma_brcmnand";
  16. struct platform_device bcma_nflash_dev = {
  17. .name = "bcma_nflash",
  18. .num_resources = 0,
  19. };
  20. static const char *probes[] = { "bcm47xxpart", NULL };
  21. /* Initialize NAND flash access */
  22. int bcma_nflash_init(struct bcma_drv_cc *cc)
  23. {
  24. struct bcma_bus *bus = cc->core->bus;
  25. u32 reg;
  26. if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
  27. cc->core->id.rev != 38) {
  28. bcma_err(bus, "NAND flash on unsupported board!\n");
  29. return -ENOTSUPP;
  30. }
  31. if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
  32. bcma_err(bus, "NAND flash not present according to ChipCommon\n");
  33. return -ENODEV;
  34. }
  35. cc->nflash.present = true;
  36. if (cc->core->id.rev == 38 &&
  37. (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) {
  38. cc->nflash.boot = true;
  39. /* Determine the chip select that is being used */
  40. reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff;
  41. cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1;
  42. cc->nflash.brcmnand_info.part_probe_types = probes;
  43. cc->nflash.brcmnand_info.ecc_stepsize = 512;
  44. cc->nflash.brcmnand_info.ecc_strength = 1;
  45. bcma_nflash_dev.name = bcma_nflash_alt_name;
  46. }
  47. /* Prepare platform device, but don't register it yet. It's too early,
  48. * malloc (required by device_private_init) is not available yet. */
  49. bcma_nflash_dev.dev.platform_data = &cc->nflash;
  50. return 0;
  51. }