root/drivers/mtd/nand/raw/bcm47xxnflash/main.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. bcm47xxnflash_probe
  2. bcm47xxnflash_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * BCM47XX NAND flash driver
   4  *
   5  * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com>
   6  */
   7 
   8 #include "bcm47xxnflash.h"
   9 
  10 #include <linux/module.h>
  11 #include <linux/kernel.h>
  12 #include <linux/slab.h>
  13 #include <linux/platform_device.h>
  14 #include <linux/bcma/bcma.h>
  15 
  16 MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
  17 MODULE_LICENSE("GPL");
  18 MODULE_AUTHOR("Rafał Miłecki");
  19 
  20 static const char *probes[] = { "bcm47xxpart", NULL };
  21 
  22 static int bcm47xxnflash_probe(struct platform_device *pdev)
  23 {
  24         struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
  25         struct bcm47xxnflash *b47n;
  26         struct mtd_info *mtd;
  27         int err = 0;
  28 
  29         b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
  30         if (!b47n)
  31                 return -ENOMEM;
  32 
  33         nand_set_controller_data(&b47n->nand_chip, b47n);
  34         mtd = nand_to_mtd(&b47n->nand_chip);
  35         mtd->dev.parent = &pdev->dev;
  36         b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
  37 
  38         if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
  39                 err = bcm47xxnflash_ops_bcm4706_init(b47n);
  40         } else {
  41                 pr_err("Device not supported\n");
  42                 err = -ENOTSUPP;
  43         }
  44         if (err) {
  45                 pr_err("Initialization failed: %d\n", err);
  46                 return err;
  47         }
  48 
  49         platform_set_drvdata(pdev, b47n);
  50 
  51         err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
  52         if (err) {
  53                 pr_err("Failed to register MTD device: %d\n", err);
  54                 return err;
  55         }
  56 
  57         return 0;
  58 }
  59 
  60 static int bcm47xxnflash_remove(struct platform_device *pdev)
  61 {
  62         struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
  63 
  64         nand_release(&nflash->nand_chip);
  65 
  66         return 0;
  67 }
  68 
  69 static struct platform_driver bcm47xxnflash_driver = {
  70         .probe  = bcm47xxnflash_probe,
  71         .remove = bcm47xxnflash_remove,
  72         .driver = {
  73                 .name = "bcma_nflash",
  74         },
  75 };
  76 
  77 module_platform_driver(bcm47xxnflash_driver);

/* [<][>][^][v][top][bottom][index][help] */