Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
[deliverable/linux.git] / drivers / mtd / nand / bcm47xxnflash / main.c
CommitLineData
a5401370
RM
1/*
2 * BCM47XX NAND flash driver
3 *
4 * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
5 *
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.
9 *
10 */
11
be0638d9
RM
12#include "bcm47xxnflash.h"
13
a5401370
RM
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>
19
a5401370
RM
20MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
21MODULE_LICENSE("GPL");
22MODULE_AUTHOR("Rafał Miłecki");
23
24static const char *probes[] = { "bcm47xxpart", NULL };
25
26static int bcm47xxnflash_probe(struct platform_device *pdev)
27{
28 struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
29 struct bcm47xxnflash *b47n;
17dd20bd 30 struct mtd_info *mtd;
a5401370
RM
31 int err = 0;
32
7e3019e3
SK
33 b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
34 if (!b47n)
35 return -ENOMEM;
a5401370 36
d699ed25 37 nand_set_controller_data(&b47n->nand_chip, b47n);
17dd20bd
BB
38 mtd = nand_to_mtd(&b47n->nand_chip);
39 mtd->dev.parent = &pdev->dev;
a5401370
RM
40 b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
41
00940a23
RM
42 if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
43 err = bcm47xxnflash_ops_bcm4706_init(b47n);
a5401370
RM
44 } else {
45 pr_err("Device not supported\n");
46 err = -ENOTSUPP;
47 }
48 if (err) {
49 pr_err("Initialization failed: %d\n", err);
7e3019e3 50 return err;
a5401370
RM
51 }
52
665d2c28
BN
53 platform_set_drvdata(pdev, b47n);
54
17dd20bd 55 err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
a5401370
RM
56 if (err) {
57 pr_err("Failed to register MTD device: %d\n", err);
7e3019e3 58 return err;
a5401370
RM
59 }
60
61 return 0;
a5401370
RM
62}
63
d8929942 64static int bcm47xxnflash_remove(struct platform_device *pdev)
a5401370 65{
665d2c28 66 struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
a5401370 67
17dd20bd 68 nand_release(nand_to_mtd(&nflash->nand_chip));
a5401370
RM
69
70 return 0;
71}
72
73static struct platform_driver bcm47xxnflash_driver = {
a7bf6543 74 .probe = bcm47xxnflash_probe,
d8929942 75 .remove = bcm47xxnflash_remove,
a5401370
RM
76 .driver = {
77 .name = "bcma_nflash",
a5401370
RM
78 },
79};
80
994bbd0e 81module_platform_driver(bcm47xxnflash_driver);
This page took 0.434831 seconds and 5 git commands to generate.