2008-03-12 02:33:13 +07:00
|
|
|
/*
|
|
|
|
* Freescale UPM NAND driver.
|
|
|
|
*
|
|
|
|
* Copyright © 2007-2008 MontaVista Software, Inc.
|
|
|
|
*
|
|
|
|
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2008-06-09 15:19:08 +07:00
|
|
|
#include <linux/delay.h>
|
2008-03-12 02:33:13 +07:00
|
|
|
#include <linux/mtd/nand.h>
|
|
|
|
#include <linux/mtd/nand_ecc.h>
|
|
|
|
#include <linux/mtd/partitions.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/of_platform.h>
|
|
|
|
#include <linux/of_gpio.h>
|
|
|
|
#include <linux/io.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-03-12 02:33:13 +07:00
|
|
|
#include <asm/fsl_lbc.h>
|
|
|
|
|
2009-03-30 17:02:43 +07:00
|
|
|
#define FSL_UPM_WAIT_RUN_PATTERN 0x1
|
|
|
|
#define FSL_UPM_WAIT_WRITE_BYTE 0x2
|
|
|
|
#define FSL_UPM_WAIT_WRITE_BUFFER 0x4
|
|
|
|
|
2008-03-12 02:33:13 +07:00
|
|
|
struct fsl_upm_nand {
|
|
|
|
struct device *dev;
|
|
|
|
struct mtd_info mtd;
|
|
|
|
struct nand_chip chip;
|
|
|
|
int last_ctrl;
|
|
|
|
struct mtd_partition *parts;
|
|
|
|
struct fsl_upm upm;
|
|
|
|
uint8_t upm_addr_offset;
|
|
|
|
uint8_t upm_cmd_offset;
|
|
|
|
void __iomem *io_base;
|
2009-03-30 17:02:42 +07:00
|
|
|
int rnb_gpio[NAND_MAX_CHIPS];
|
|
|
|
uint32_t mchip_offsets[NAND_MAX_CHIPS];
|
|
|
|
uint32_t mchip_count;
|
|
|
|
uint32_t mchip_number;
|
2008-06-09 15:19:08 +07:00
|
|
|
int chip_delay;
|
2009-03-30 17:02:43 +07:00
|
|
|
uint32_t wait_flags;
|
2008-03-12 02:33:13 +07:00
|
|
|
};
|
|
|
|
|
2010-03-24 00:08:16 +07:00
|
|
|
static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo)
|
|
|
|
{
|
|
|
|
return container_of(mtdinfo, struct fsl_upm_nand, mtd);
|
|
|
|
}
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
static int fun_chip_ready(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
if (gpio_get_value(fun->rnb_gpio[fun->mchip_number]))
|
2008-03-12 02:33:13 +07:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
dev_vdbg(fun->dev, "busy\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fun_wait_rnb(struct fsl_upm_nand *fun)
|
|
|
|
{
|
2009-03-30 17:02:42 +07:00
|
|
|
if (fun->rnb_gpio[fun->mchip_number] >= 0) {
|
|
|
|
int cnt = 1000000;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
while (--cnt && !fun_chip_ready(&fun->mtd))
|
|
|
|
cpu_relax();
|
2008-06-09 15:19:08 +07:00
|
|
|
if (!cnt)
|
|
|
|
dev_err(fun->dev, "tired waiting for RNB\n");
|
|
|
|
} else {
|
|
|
|
ndelay(100);
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
|
|
|
{
|
2009-03-30 17:02:42 +07:00
|
|
|
struct nand_chip *chip = mtd->priv;
|
2008-03-12 02:33:13 +07:00
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
2009-03-30 17:02:42 +07:00
|
|
|
u32 mar;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
if (!(ctrl & fun->last_ctrl)) {
|
|
|
|
fsl_upm_end_pattern(&fun->upm);
|
|
|
|
|
|
|
|
if (cmd == NAND_CMD_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fun->last_ctrl = ctrl & (NAND_ALE | NAND_CLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctrl & NAND_CTRL_CHANGE) {
|
|
|
|
if (ctrl & NAND_ALE)
|
|
|
|
fsl_upm_start_pattern(&fun->upm, fun->upm_addr_offset);
|
|
|
|
else if (ctrl & NAND_CLE)
|
|
|
|
fsl_upm_start_pattern(&fun->upm, fun->upm_cmd_offset);
|
|
|
|
}
|
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
mar = (cmd << (32 - fun->upm.width)) |
|
|
|
|
fun->mchip_offsets[fun->mchip_number];
|
|
|
|
fsl_upm_run_pattern(&fun->upm, chip->IO_ADDR_R, mar);
|
2008-03-12 02:33:13 +07:00
|
|
|
|
2009-03-30 17:02:43 +07:00
|
|
|
if (fun->wait_flags & FSL_UPM_WAIT_RUN_PATTERN)
|
|
|
|
fun_wait_rnb(fun);
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
|
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd->priv;
|
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
|
|
|
|
|
|
|
if (mchip_nr == -1) {
|
|
|
|
chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
|
2009-11-04 02:49:18 +07:00
|
|
|
} else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) {
|
2009-03-30 17:02:42 +07:00
|
|
|
fun->mchip_number = mchip_nr;
|
|
|
|
chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
|
|
|
|
chip->IO_ADDR_W = chip->IO_ADDR_R;
|
|
|
|
} else {
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-12 02:33:13 +07:00
|
|
|
static uint8_t fun_read_byte(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
|
|
|
|
|
|
|
return in_8(fun->chip.IO_ADDR_R);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fun_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
buf[i] = in_8(fun->chip.IO_ADDR_R);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
|
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
out_8(fun->chip.IO_ADDR_W, buf[i]);
|
2009-03-30 17:02:43 +07:00
|
|
|
if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BYTE)
|
|
|
|
fun_wait_rnb(fun);
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
2009-03-30 17:02:43 +07:00
|
|
|
if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BUFFER)
|
|
|
|
fun_wait_rnb(fun);
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
|
2008-09-18 23:50:26 +07:00
|
|
|
static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
|
|
|
|
const struct device_node *upm_np,
|
|
|
|
const struct resource *io_res)
|
2008-03-12 02:33:13 +07:00
|
|
|
{
|
|
|
|
int ret;
|
2008-09-18 23:50:26 +07:00
|
|
|
struct device_node *flash_np;
|
2011-05-30 04:02:23 +07:00
|
|
|
struct mtd_part_parser_data ppdata;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
fun->chip.IO_ADDR_R = fun->io_base;
|
|
|
|
fun->chip.IO_ADDR_W = fun->io_base;
|
|
|
|
fun->chip.cmd_ctrl = fun_cmd_ctrl;
|
2008-06-09 15:19:08 +07:00
|
|
|
fun->chip.chip_delay = fun->chip_delay;
|
2008-03-12 02:33:13 +07:00
|
|
|
fun->chip.read_byte = fun_read_byte;
|
|
|
|
fun->chip.read_buf = fun_read_buf;
|
|
|
|
fun->chip.write_buf = fun_write_buf;
|
|
|
|
fun->chip.ecc.mode = NAND_ECC_SOFT;
|
2009-03-30 17:02:42 +07:00
|
|
|
if (fun->mchip_count > 1)
|
|
|
|
fun->chip.select_chip = fun_select_chip;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
if (fun->rnb_gpio[0] >= 0)
|
2008-03-12 02:33:13 +07:00
|
|
|
fun->chip.dev_ready = fun_chip_ready;
|
|
|
|
|
|
|
|
fun->mtd.priv = &fun->chip;
|
|
|
|
fun->mtd.owner = THIS_MODULE;
|
|
|
|
|
2008-09-18 23:50:26 +07:00
|
|
|
flash_np = of_get_next_child(upm_np, NULL);
|
|
|
|
if (!flash_np)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2010-09-08 15:47:55 +07:00
|
|
|
fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start,
|
2008-09-18 23:50:26 +07:00
|
|
|
flash_np->name);
|
|
|
|
if (!fun->mtd.name) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
ret = nand_scan(&fun->mtd, fun->mchip_count);
|
2008-03-12 02:33:13 +07:00
|
|
|
if (ret)
|
2008-09-18 23:50:26 +07:00
|
|
|
goto err;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
2011-05-30 04:02:23 +07:00
|
|
|
ppdata.of_node = flash_np;
|
2011-06-02 21:00:37 +07:00
|
|
|
ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0);
|
2008-09-18 23:50:26 +07:00
|
|
|
err:
|
|
|
|
of_node_put(flash_np);
|
2011-06-30 18:53:09 +07:00
|
|
|
if (ret)
|
|
|
|
kfree(fun->mtd.name);
|
2008-09-18 23:50:26 +07:00
|
|
|
return ret;
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
|
2011-02-17 16:43:24 +07:00
|
|
|
static int __devinit fun_probe(struct platform_device *ofdev)
|
2008-03-12 02:33:13 +07:00
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun;
|
|
|
|
struct resource io_res;
|
2010-10-01 14:06:08 +07:00
|
|
|
const __be32 *prop;
|
2009-03-30 17:02:42 +07:00
|
|
|
int rnb_gpio;
|
2008-03-12 02:33:13 +07:00
|
|
|
int ret;
|
|
|
|
int size;
|
2009-03-30 17:02:42 +07:00
|
|
|
int i;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
fun = kzalloc(sizeof(*fun), GFP_KERNEL);
|
|
|
|
if (!fun)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
ret = of_address_to_resource(ofdev->dev.of_node, 0, &io_res);
|
2008-03-12 02:33:13 +07:00
|
|
|
if (ret) {
|
|
|
|
dev_err(&ofdev->dev, "can't get IO base\n");
|
|
|
|
goto err1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fsl_upm_find(io_res.start, &fun->upm);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&ofdev->dev, "can't find UPM\n");
|
|
|
|
goto err1;
|
|
|
|
}
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-addr-offset",
|
|
|
|
&size);
|
2008-03-12 02:33:13 +07:00
|
|
|
if (!prop || size != sizeof(uint32_t)) {
|
|
|
|
dev_err(&ofdev->dev, "can't get UPM address offset\n");
|
|
|
|
ret = -EINVAL;
|
2009-03-30 17:02:42 +07:00
|
|
|
goto err1;
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
fun->upm_addr_offset = *prop;
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-cmd-offset", &size);
|
2008-03-12 02:33:13 +07:00
|
|
|
if (!prop || size != sizeof(uint32_t)) {
|
|
|
|
dev_err(&ofdev->dev, "can't get UPM command offset\n");
|
|
|
|
ret = -EINVAL;
|
2009-03-30 17:02:42 +07:00
|
|
|
goto err1;
|
2008-03-12 02:33:13 +07:00
|
|
|
}
|
|
|
|
fun->upm_cmd_offset = *prop;
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
prop = of_get_property(ofdev->dev.of_node,
|
2009-03-30 17:02:42 +07:00
|
|
|
"fsl,upm-addr-line-cs-offsets", &size);
|
|
|
|
if (prop && (size / sizeof(uint32_t)) > 0) {
|
|
|
|
fun->mchip_count = size / sizeof(uint32_t);
|
|
|
|
if (fun->mchip_count >= NAND_MAX_CHIPS) {
|
|
|
|
dev_err(&ofdev->dev, "too much multiple chips\n");
|
|
|
|
goto err1;
|
|
|
|
}
|
|
|
|
for (i = 0; i < fun->mchip_count; i++)
|
2010-10-01 14:06:08 +07:00
|
|
|
fun->mchip_offsets[i] = be32_to_cpu(prop[i]);
|
2009-03-30 17:02:42 +07:00
|
|
|
} else {
|
|
|
|
fun->mchip_count = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < fun->mchip_count; i++) {
|
|
|
|
fun->rnb_gpio[i] = -1;
|
2010-06-03 07:37:17 +07:00
|
|
|
rnb_gpio = of_get_gpio(ofdev->dev.of_node, i);
|
2009-03-30 17:02:42 +07:00
|
|
|
if (rnb_gpio >= 0) {
|
|
|
|
ret = gpio_request(rnb_gpio, dev_name(&ofdev->dev));
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&ofdev->dev,
|
|
|
|
"can't request RNB gpio #%d\n", i);
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
gpio_direction_input(rnb_gpio);
|
|
|
|
fun->rnb_gpio[i] = rnb_gpio;
|
|
|
|
} else if (rnb_gpio == -EINVAL) {
|
|
|
|
dev_err(&ofdev->dev, "RNB gpio #%d is invalid\n", i);
|
2008-03-12 02:33:13 +07:00
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
prop = of_get_property(ofdev->dev.of_node, "chip-delay", NULL);
|
2008-06-09 15:19:08 +07:00
|
|
|
if (prop)
|
2010-10-01 14:06:08 +07:00
|
|
|
fun->chip_delay = be32_to_cpup(prop);
|
2008-06-09 15:19:08 +07:00
|
|
|
else
|
|
|
|
fun->chip_delay = 50;
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-wait-flags", &size);
|
2009-03-30 17:02:43 +07:00
|
|
|
if (prop && size == sizeof(uint32_t))
|
2010-10-01 14:06:08 +07:00
|
|
|
fun->wait_flags = be32_to_cpup(prop);
|
2009-03-30 17:02:43 +07:00
|
|
|
else
|
|
|
|
fun->wait_flags = FSL_UPM_WAIT_RUN_PATTERN |
|
|
|
|
FSL_UPM_WAIT_WRITE_BYTE;
|
|
|
|
|
2008-03-12 02:33:13 +07:00
|
|
|
fun->io_base = devm_ioremap_nocache(&ofdev->dev, io_res.start,
|
2009-12-15 04:22:49 +07:00
|
|
|
resource_size(&io_res));
|
2008-03-12 02:33:13 +07:00
|
|
|
if (!fun->io_base) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
|
|
|
fun->dev = &ofdev->dev;
|
|
|
|
fun->last_ctrl = NAND_CLE;
|
|
|
|
|
2010-06-03 07:37:17 +07:00
|
|
|
ret = fun_chip_init(fun, ofdev->dev.of_node, &io_res);
|
2008-03-12 02:33:13 +07:00
|
|
|
if (ret)
|
|
|
|
goto err2;
|
|
|
|
|
|
|
|
dev_set_drvdata(&ofdev->dev, fun);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
err2:
|
2009-03-30 17:02:42 +07:00
|
|
|
for (i = 0; i < fun->mchip_count; i++) {
|
|
|
|
if (fun->rnb_gpio[i] < 0)
|
|
|
|
break;
|
|
|
|
gpio_free(fun->rnb_gpio[i]);
|
|
|
|
}
|
2008-03-12 02:33:13 +07:00
|
|
|
err1:
|
|
|
|
kfree(fun);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-08-06 22:25:50 +07:00
|
|
|
static int __devexit fun_remove(struct platform_device *ofdev)
|
2008-03-12 02:33:13 +07:00
|
|
|
{
|
|
|
|
struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev);
|
2009-03-30 17:02:42 +07:00
|
|
|
int i;
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
nand_release(&fun->mtd);
|
2008-09-18 23:50:26 +07:00
|
|
|
kfree(fun->mtd.name);
|
2008-03-12 02:33:13 +07:00
|
|
|
|
2009-03-30 17:02:42 +07:00
|
|
|
for (i = 0; i < fun->mchip_count; i++) {
|
|
|
|
if (fun->rnb_gpio[i] < 0)
|
|
|
|
break;
|
|
|
|
gpio_free(fun->rnb_gpio[i]);
|
|
|
|
}
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
kfree(fun);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-09 21:10:46 +07:00
|
|
|
static const struct of_device_id of_fun_match[] = {
|
2008-03-12 02:33:13 +07:00
|
|
|
{ .compatible = "fsl,upm-nand" },
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, of_fun_match);
|
|
|
|
|
2011-02-17 16:43:24 +07:00
|
|
|
static struct platform_driver of_fun_driver = {
|
2010-04-14 06:13:02 +07:00
|
|
|
.driver = {
|
|
|
|
.name = "fsl,upm-nand",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.of_match_table = of_fun_match,
|
|
|
|
},
|
2008-03-12 02:33:13 +07:00
|
|
|
.probe = fun_probe,
|
|
|
|
.remove = __devexit_p(fun_remove),
|
|
|
|
};
|
|
|
|
|
2011-11-27 19:45:03 +07:00
|
|
|
module_platform_driver(of_fun_driver);
|
2008-03-12 02:33:13 +07:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
|
|
|
|
MODULE_DESCRIPTION("Driver for NAND chips working through Freescale "
|
|
|
|
"LocalBus User-Programmable Machine");
|