2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-11-12 20:03:21 +08:00
|
|
|
/*
|
|
|
|
* BCM47XX NAND flash driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2013-02-07 18:56:04 +08:00
|
|
|
#include "bcm47xxnflash.h"
|
|
|
|
|
2012-11-12 20:03:21 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/bcma/bcma.h>
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Rafał Miłecki");
|
|
|
|
|
|
|
|
static const char *probes[] = { "bcm47xxpart", NULL };
|
|
|
|
|
|
|
|
static int bcm47xxnflash_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
|
|
|
|
struct bcm47xxnflash *b47n;
|
2015-12-10 15:59:52 +08:00
|
|
|
struct mtd_info *mtd;
|
2012-11-12 20:03:21 +08:00
|
|
|
int err = 0;
|
|
|
|
|
2013-10-11 12:41:25 +08:00
|
|
|
b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
|
|
|
|
if (!b47n)
|
|
|
|
return -ENOMEM;
|
2012-11-12 20:03:21 +08:00
|
|
|
|
2015-12-10 16:00:41 +08:00
|
|
|
nand_set_controller_data(&b47n->nand_chip, b47n);
|
2015-12-10 15:59:52 +08:00
|
|
|
mtd = nand_to_mtd(&b47n->nand_chip);
|
|
|
|
mtd->dev.parent = &pdev->dev;
|
2012-11-12 20:03:21 +08:00
|
|
|
b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
|
|
|
|
|
2012-11-12 20:03:25 +08:00
|
|
|
if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
|
|
|
|
err = bcm47xxnflash_ops_bcm4706_init(b47n);
|
2012-11-12 20:03:21 +08:00
|
|
|
} else {
|
|
|
|
pr_err("Device not supported\n");
|
|
|
|
err = -ENOTSUPP;
|
|
|
|
}
|
|
|
|
if (err) {
|
|
|
|
pr_err("Initialization failed: %d\n", err);
|
2013-10-11 12:41:25 +08:00
|
|
|
return err;
|
2012-11-12 20:03:21 +08:00
|
|
|
}
|
|
|
|
|
2015-12-09 09:04:59 +08:00
|
|
|
platform_set_drvdata(pdev, b47n);
|
|
|
|
|
2015-12-10 15:59:52 +08:00
|
|
|
err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
|
2012-11-12 20:03:21 +08:00
|
|
|
if (err) {
|
|
|
|
pr_err("Failed to register MTD device: %d\n", err);
|
2013-10-11 12:41:25 +08:00
|
|
|
return err;
|
2012-11-12 20:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:19:05 +08:00
|
|
|
static int bcm47xxnflash_remove(struct platform_device *pdev)
|
2012-11-12 20:03:21 +08:00
|
|
|
{
|
2015-12-09 09:04:59 +08:00
|
|
|
struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
|
2012-11-12 20:03:21 +08:00
|
|
|
|
2018-09-06 20:05:15 +08:00
|
|
|
nand_release(&nflash->nand_chip);
|
2012-11-12 20:03:21 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver bcm47xxnflash_driver = {
|
2013-01-28 18:25:48 +08:00
|
|
|
.probe = bcm47xxnflash_probe,
|
2012-12-22 05:19:05 +08:00
|
|
|
.remove = bcm47xxnflash_remove,
|
2012-11-12 20:03:21 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "bcma_nflash",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-10-11 12:41:24 +08:00
|
|
|
module_platform_driver(bcm47xxnflash_driver);
|