2 * BCM47XX NAND flash driver
4 * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include "bcm47xxnflash.h"
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/platform_device.h>
18 #include <linux/bcma/bcma.h>
20 MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
21 MODULE_LICENSE("GPL");
22 MODULE_AUTHOR("Rafał Miłecki");
24 static const char *probes
[] = { "bcm47xxpart", NULL
};
26 static int bcm47xxnflash_probe(struct platform_device
*pdev
)
28 struct bcma_nflash
*nflash
= dev_get_platdata(&pdev
->dev
);
29 struct bcm47xxnflash
*b47n
;
33 b47n
= devm_kzalloc(&pdev
->dev
, sizeof(*b47n
), GFP_KERNEL
);
37 b47n
->nand_chip
.priv
= b47n
;
38 mtd
= nand_to_mtd(&b47n
->nand_chip
);
39 mtd
->dev
.parent
= &pdev
->dev
;
40 mtd
->priv
= &b47n
->nand_chip
; /* Required */
41 b47n
->cc
= container_of(nflash
, struct bcma_drv_cc
, nflash
);
43 if (b47n
->cc
->core
->bus
->chipinfo
.id
== BCMA_CHIP_ID_BCM4706
) {
44 err
= bcm47xxnflash_ops_bcm4706_init(b47n
);
46 pr_err("Device not supported\n");
50 pr_err("Initialization failed: %d\n", err
);
54 platform_set_drvdata(pdev
, b47n
);
56 err
= mtd_device_parse_register(mtd
, probes
, NULL
, NULL
, 0);
58 pr_err("Failed to register MTD device: %d\n", err
);
65 static int bcm47xxnflash_remove(struct platform_device
*pdev
)
67 struct bcm47xxnflash
*nflash
= platform_get_drvdata(pdev
);
69 nand_release(nand_to_mtd(&nflash
->nand_chip
));
74 static struct platform_driver bcm47xxnflash_driver
= {
75 .probe
= bcm47xxnflash_probe
,
76 .remove
= bcm47xxnflash_remove
,
78 .name
= "bcma_nflash",
82 module_platform_driver(bcm47xxnflash_driver
);