Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Broadcom specific AMBA
0003  * ChipCommon NAND flash interface
0004  *
0005  * Licensed under the GNU/GPL. See COPYING for details.
0006  */
0007 
0008 #include "bcma_private.h"
0009 
0010 #include <linux/bitops.h>
0011 #include <linux/platform_device.h>
0012 #include <linux/platform_data/brcmnand.h>
0013 #include <linux/bcma/bcma.h>
0014 
0015 /* Alternate NAND controller driver name in order to allow both bcm47xxnflash
0016  * and bcma_brcmnand to be built into the same kernel image.
0017  */
0018 static const char *bcma_nflash_alt_name = "bcma_brcmnand";
0019 
0020 struct platform_device bcma_nflash_dev = {
0021     .name       = "bcma_nflash",
0022     .num_resources  = 0,
0023 };
0024 
0025 static const char *probes[] = { "bcm47xxpart", NULL };
0026 
0027 /* Initialize NAND flash access */
0028 int bcma_nflash_init(struct bcma_drv_cc *cc)
0029 {
0030     struct bcma_bus *bus = cc->core->bus;
0031     u32 reg;
0032 
0033     if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
0034         cc->core->id.rev != 38) {
0035         bcma_err(bus, "NAND flash on unsupported board!\n");
0036         return -ENOTSUPP;
0037     }
0038 
0039     if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
0040         bcma_err(bus, "NAND flash not present according to ChipCommon\n");
0041         return -ENODEV;
0042     }
0043 
0044     cc->nflash.present = true;
0045     if (cc->core->id.rev == 38 &&
0046         (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) {
0047         cc->nflash.boot = true;
0048         /* Determine the chip select that is being used */
0049         reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff;
0050         cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1;
0051         cc->nflash.brcmnand_info.part_probe_types = probes;
0052         cc->nflash.brcmnand_info.ecc_stepsize = 512;
0053         cc->nflash.brcmnand_info.ecc_strength = 1;
0054         bcma_nflash_dev.name = bcma_nflash_alt_name;
0055     }
0056 
0057     /* Prepare platform device, but don't register it yet. It's too early,
0058      * malloc (required by device_private_init) is not available yet. */
0059     bcma_nflash_dev.dev.platform_data = &cc->nflash;
0060 
0061     return 0;
0062 }