Commit | Line | Data |
---|---|---|
23cb3b21 RM |
1 | /* |
2 | * Broadcom specific AMBA | |
3 | * ChipCommon NAND flash interface | |
4 | * | |
5 | * Licensed under the GNU/GPL. See COPYING for details. | |
6 | */ | |
7 | ||
58b27101 RM |
8 | #include "bcma_private.h" |
9 | ||
02d1d0e4 | 10 | #include <linux/bitops.h> |
371a0044 | 11 | #include <linux/platform_device.h> |
02d1d0e4 | 12 | #include <linux/platform_data/brcmnand.h> |
23cb3b21 | 13 | #include <linux/bcma/bcma.h> |
23cb3b21 | 14 | |
02d1d0e4 FF |
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 | */ | |
18 | static const char *bcma_nflash_alt_name = "bcma_brcmnand"; | |
19 | ||
371a0044 RM |
20 | struct platform_device bcma_nflash_dev = { |
21 | .name = "bcma_nflash", | |
22 | .num_resources = 0, | |
23 | }; | |
24 | ||
02d1d0e4 FF |
25 | static const char *probes[] = { "bcm47xxpart", NULL }; |
26 | ||
23cb3b21 RM |
27 | /* Initialize NAND flash access */ |
28 | int bcma_nflash_init(struct bcma_drv_cc *cc) | |
29 | { | |
371a0044 | 30 | struct bcma_bus *bus = cc->core->bus; |
02d1d0e4 | 31 | u32 reg; |
371a0044 RM |
32 | |
33 | if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 && | |
6b112dec | 34 | cc->core->id.rev != 38) { |
371a0044 RM |
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; | |
e661b75a | 45 | if (cc->core->id.rev == 38 && |
02d1d0e4 | 46 | (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) { |
e661b75a | 47 | cc->nflash.boot = true; |
02d1d0e4 FF |
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 | } | |
371a0044 RM |
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 | ||
23cb3b21 RM |
61 | return 0; |
62 | } |