blob: d4f699aef8c440081d0f5847ab67766b6e128f48 [file] [log] [blame]
Rafał Miłecki23cb3b22012-07-17 16:26:41 +02001/*
2 * Broadcom specific AMBA
3 * ChipCommon NAND flash interface
4 *
5 * Licensed under the GNU/GPL. See COPYING for details.
6 */
7
Rafał Miłecki58b27102013-01-30 08:46:53 +01008#include "bcma_private.h"
9
Rafał Miłecki371a0042012-08-12 13:08:05 +020010#include <linux/platform_device.h>
Rafał Miłecki23cb3b22012-07-17 16:26:41 +020011#include <linux/bcma/bcma.h>
Rafał Miłecki23cb3b22012-07-17 16:26:41 +020012
Rafał Miłecki371a0042012-08-12 13:08:05 +020013struct platform_device bcma_nflash_dev = {
14 .name = "bcma_nflash",
15 .num_resources = 0,
16};
17
Rafał Miłecki23cb3b22012-07-17 16:26:41 +020018/* Initialize NAND flash access */
19int bcma_nflash_init(struct bcma_drv_cc *cc)
20{
Rafał Miłecki371a0042012-08-12 13:08:05 +020021 struct bcma_bus *bus = cc->core->bus;
22
23 if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
Rafał Miłecki6b112de2013-01-27 14:30:29 +010024 cc->core->id.rev != 38) {
Rafał Miłecki371a0042012-08-12 13:08:05 +020025 bcma_err(bus, "NAND flash on unsupported board!\n");
26 return -ENOTSUPP;
27 }
28
29 if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
30 bcma_err(bus, "NAND flash not present according to ChipCommon\n");
31 return -ENODEV;
32 }
33
34 cc->nflash.present = true;
Hauke Mehrtense661b752012-09-29 20:33:51 +020035 if (cc->core->id.rev == 38 &&
36 (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
37 cc->nflash.boot = true;
Rafał Miłecki371a0042012-08-12 13:08:05 +020038
39 /* Prepare platform device, but don't register it yet. It's too early,
40 * malloc (required by device_private_init) is not available yet. */
41 bcma_nflash_dev.dev.platform_data = &cc->nflash;
42
Rafał Miłecki23cb3b22012-07-17 16:26:41 +020043 return 0;
44}