Release 4.7 drivers/mtd/nand/plat_nand.c
/*
* Generic NAND driver
*
* Author: Vitaly Wool <vitalywool@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
struct plat_nand_data {
struct nand_chip chip;
void __iomem *io_base;
};
/*
* Probe for the NAND device.
*/
static int plat_nand_probe(struct platform_device *pdev)
{
struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
struct plat_nand_data *data;
struct mtd_info *mtd;
struct resource *res;
const char **part_types;
int err = 0;
if (!pdata) {
dev_err(&pdev->dev, "platform_nand_data is missing\n");
return -EINVAL;
}
if (pdata->chip.nr_chips < 1) {
dev_err(&pdev->dev, "invalid number of chips specified\n");
return -EINVAL;
}
/* Allocate memory for the device structure (and zero it) */
data = devm_kzalloc(&pdev->dev, sizeof(struct plat_nand_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
data->io_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(data->io_base))
return PTR_ERR(data->io_base);
nand_set_flash_node(&data->chip, pdev->dev.of_node);
mtd = nand_to_mtd(&data->chip);
mtd->dev.parent = &pdev->dev;
data->chip.IO_ADDR_R = data->io_base;
data->chip.IO_ADDR_W = data->io_base;
data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl;
data->chip.dev_ready = pdata->ctrl.dev_ready;
data->chip.select_chip = pdata->ctrl.select_chip;
data->chip.write_buf = pdata->ctrl.write_buf;
data->chip.read_buf = pdata->ctrl.read_buf;
data->chip.read_byte = pdata->ctrl.read_byte;
data->chip.chip_delay = pdata->chip.chip_delay;
data->chip.options |= pdata->chip.options;
data->chip.bbt_options |= pdata->chip.bbt_options;
data->chip.ecc.hwctl = pdata->ctrl.hwcontrol;
data->chip.ecc.mode = NAND_ECC_SOFT;
data->chip.ecc.algo = NAND_ECC_HAMMING;
platform_set_drvdata(pdev, data);
/* Handle any platform specific setup */
if (pdata->ctrl.probe) {
err = pdata->ctrl.probe(pdev);
if (err)
goto out;
}
/* Scan to find existence of the device */
if (nand_scan(mtd, pdata->chip.nr_chips)) {
err = -ENXIO;
goto out;
}
part_types = pdata->chip.part_probe_types;
err = mtd_device_parse_register(mtd, part_types, NULL,
pdata->chip.partitions,
pdata->chip.nr_partitions);
if (!err)
return err;
nand_release(mtd);
out:
if (pdata->ctrl.remove)
pdata->ctrl.remove(pdev);
return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vitaly wool | vitaly wool | 224 | 45.71% | 1 | 4.76% |
h hartley sweeten | h hartley sweeten | 81 | 16.53% | 3 | 14.29% |
john crispin | john crispin | 33 | 6.73% | 2 | 9.52% |
marek vasut | marek vasut | 31 | 6.33% | 2 | 9.52% |
brian norris | brian norris | 27 | 5.51% | 2 | 9.52% |
alexander clouter | alexander clouter | 24 | 4.90% | 1 | 4.76% |
jingoo han | jingoo han | 22 | 4.49% | 2 | 9.52% |
boris brezillon | boris brezillon | 14 | 2.86% | 1 | 4.76% |
wei yongjun | wei yongjun | 11 | 2.24% | 1 | 4.76% |
rafal milecki | rafal milecki | 10 | 2.04% | 1 | 4.76% |
hamish moffatt | hamish moffatt | 8 | 1.63% | 1 | 4.76% |
frans klaver | frans klaver | 2 | 0.41% | 1 | 4.76% |
kay sievers | kay sievers | 1 | 0.20% | 1 | 4.76% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 1 | 0.20% | 1 | 4.76% |
lucas de marchi | lucas de marchi | 1 | 0.20% | 1 | 4.76% |
| Total | 490 | 100.00% | 21 | 100.00% |
/*
* Remove a NAND device.
*/
static int plat_nand_remove(struct platform_device *pdev)
{
struct plat_nand_data *data = platform_get_drvdata(pdev);
struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
nand_release(nand_to_mtd(&data->chip));
if (pdata->ctrl.remove)
pdata->ctrl.remove(pdev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vitaly wool | vitaly wool | 42 | 64.62% | 1 | 25.00% |
h hartley sweeten | h hartley sweeten | 15 | 23.08% | 1 | 25.00% |
jingoo han | jingoo han | 4 | 6.15% | 1 | 25.00% |
boris brezillon | boris brezillon | 4 | 6.15% | 1 | 25.00% |
| Total | 65 | 100.00% | 4 | 100.00% |
static const struct of_device_id plat_nand_match[] = {
{ .compatible = "gen_nand" },
{},
};
MODULE_DEVICE_TABLE(of, plat_nand_match);
static struct platform_driver plat_nand_driver = {
.probe = plat_nand_probe,
.remove = plat_nand_remove,
.driver = {
.name = "gen_nand",
.of_match_table = plat_nand_match,
},
};
module_platform_driver(plat_nand_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Vitaly Wool");
MODULE_DESCRIPTION("Simple generic NAND driver");
MODULE_ALIAS("platform:gen_nand");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vitaly wool | vitaly wool | 351 | 51.77% | 1 | 4.17% |
h hartley sweeten | h hartley sweeten | 96 | 14.16% | 3 | 12.50% |
john crispin | john crispin | 61 | 9.00% | 3 | 12.50% |
marek vasut | marek vasut | 31 | 4.57% | 2 | 8.33% |
jingoo han | jingoo han | 29 | 4.28% | 2 | 8.33% |
brian norris | brian norris | 27 | 3.98% | 2 | 8.33% |
alexander clouter | alexander clouter | 24 | 3.54% | 1 | 4.17% |
boris brezillon | boris brezillon | 18 | 2.65% | 1 | 4.17% |
wei yongjun | wei yongjun | 11 | 1.62% | 1 | 4.17% |
rafal milecki | rafal milecki | 10 | 1.47% | 1 | 4.17% |
hamish moffatt | hamish moffatt | 8 | 1.18% | 1 | 4.17% |
kay sievers | kay sievers | 6 | 0.88% | 2 | 8.33% |
axel lin | axel lin | 2 | 0.29% | 1 | 4.17% |
frans klaver | frans klaver | 2 | 0.29% | 1 | 4.17% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 1 | 0.15% | 1 | 4.17% |
lucas de marchi | lucas de marchi | 1 | 0.15% | 1 | 4.17% |
| Total | 678 | 100.00% | 24 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.