cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

driver_chipcommon_nflash.c (1784B)


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