2006-12-06 18:17:49 +08:00
|
|
|
/*
|
2007-09-20 09:22:25 +08:00
|
|
|
* Flash mappings described by the OF (or flattened) device tree
|
2006-12-06 18:17:49 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 MontaVista Software Inc.
|
|
|
|
* Author: Vitaly Wool <vwool@ru.mvista.com>
|
|
|
|
*
|
2007-09-07 11:23:53 +08:00
|
|
|
* Revised to handle newer style flash binding by:
|
|
|
|
* Copyright (C) 2007 David Gibson, IBM Corporation.
|
|
|
|
*
|
2006-12-06 18:17:49 +08:00
|
|
|
* 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/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/mtd/map.h>
|
|
|
|
#include <linux/mtd/partitions.h>
|
2009-04-16 20:10:45 +08:00
|
|
|
#include <linux/mtd/concat.h>
|
2007-09-20 09:22:25 +08:00
|
|
|
#include <linux/of.h>
|
2010-08-18 01:13:44 +08:00
|
|
|
#include <linux/of_address.h>
|
2007-09-20 09:22:25 +08:00
|
|
|
#include <linux/of_platform.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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2017-01-29 05:50:48 +08:00
|
|
|
#include "physmap_of_gemini.h"
|
2016-01-26 18:58:07 +08:00
|
|
|
#include "physmap_of_versatile.h"
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
struct of_flash_list {
|
|
|
|
struct mtd_info *mtd;
|
|
|
|
struct map_info map;
|
|
|
|
struct resource *res;
|
|
|
|
};
|
|
|
|
|
2007-09-20 09:22:25 +08:00
|
|
|
struct of_flash {
|
2009-04-16 20:10:45 +08:00
|
|
|
struct mtd_info *cmtd;
|
|
|
|
int list_size; /* number of elements in of_flash_list */
|
|
|
|
struct of_flash_list list[0];
|
2006-12-06 18:17:49 +08:00
|
|
|
};
|
|
|
|
|
2010-08-06 23:25:50 +08:00
|
|
|
static int of_flash_remove(struct platform_device *dev)
|
2006-12-06 18:17:49 +08:00
|
|
|
{
|
2007-09-20 09:22:25 +08:00
|
|
|
struct of_flash *info;
|
2009-04-16 20:10:45 +08:00
|
|
|
int i;
|
2006-12-06 18:17:49 +08:00
|
|
|
|
|
|
|
info = dev_get_drvdata(&dev->dev);
|
2007-09-20 09:22:25 +08:00
|
|
|
if (!info)
|
2006-12-06 18:17:49 +08:00
|
|
|
return 0;
|
|
|
|
dev_set_drvdata(&dev->dev, NULL);
|
|
|
|
|
2014-11-30 20:51:03 +08:00
|
|
|
if (info->cmtd) {
|
2011-05-23 17:22:45 +08:00
|
|
|
mtd_device_unregister(info->cmtd);
|
2014-11-30 20:51:03 +08:00
|
|
|
if (info->cmtd != info->list[0].mtd)
|
|
|
|
mtd_concat_destroy(info->cmtd);
|
2009-04-16 20:10:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < info->list_size; i++) {
|
|
|
|
if (info->list[i].mtd)
|
|
|
|
map_destroy(info->list[i].mtd);
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
if (info->list[i].map.virt)
|
|
|
|
iounmap(info->list[i].map.virt);
|
|
|
|
|
|
|
|
if (info->list[i].res) {
|
|
|
|
release_resource(info->list[i].res);
|
|
|
|
kfree(info->list[i].res);
|
|
|
|
}
|
2006-12-06 18:17:49 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-12 16:42:56 +08:00
|
|
|
static const char * const rom_probe_types[] = {
|
|
|
|
"cfi_probe", "jedec_probe", "map_rom" };
|
|
|
|
|
2007-09-07 11:23:53 +08:00
|
|
|
/* Helper function to handle probing of the obsolete "direct-mapped"
|
|
|
|
* compatible binding, which has an extra "probe-type" property
|
|
|
|
* describing the type of flash probe necessary. */
|
2012-11-20 02:23:07 +08:00
|
|
|
static struct mtd_info *obsolete_probe(struct platform_device *dev,
|
2012-12-22 05:19:05 +08:00
|
|
|
struct map_info *map)
|
2006-12-06 18:17:49 +08:00
|
|
|
{
|
2010-04-14 07:12:29 +08:00
|
|
|
struct device_node *dp = dev->dev.of_node;
|
2006-12-06 18:17:49 +08:00
|
|
|
const char *of_probe;
|
2007-09-07 11:23:53 +08:00
|
|
|
struct mtd_info *mtd;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dev_warn(&dev->dev, "Device tree uses obsolete \"direct-mapped\" "
|
|
|
|
"flash binding\n");
|
|
|
|
|
|
|
|
of_probe = of_get_property(dp, "probe-type", NULL);
|
|
|
|
if (!of_probe) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(rom_probe_types); i++) {
|
|
|
|
mtd = do_map_probe(rom_probe_types[i], map);
|
|
|
|
if (mtd)
|
|
|
|
return mtd;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
} else if (strcmp(of_probe, "CFI") == 0) {
|
|
|
|
return do_map_probe("cfi_probe", map);
|
|
|
|
} else if (strcmp(of_probe, "JEDEC") == 0) {
|
|
|
|
return do_map_probe("jedec_probe", map);
|
|
|
|
} else {
|
|
|
|
if (strcmp(of_probe, "ROM") != 0)
|
2007-09-20 09:22:25 +08:00
|
|
|
dev_warn(&dev->dev, "obsolete_probe: don't know probe "
|
|
|
|
"type '%s', mapping as rom\n", of_probe);
|
2014-09-18 02:08:18 +08:00
|
|
|
return do_map_probe("map_rom", map);
|
2007-09-07 11:23:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-10 03:27:56 +08:00
|
|
|
/* When partitions are set we look for a linux,part-probe property which
|
|
|
|
specifies the list of partition probers to use. If none is given then the
|
|
|
|
default is use. These take precedence over other device tree
|
|
|
|
information. */
|
2013-03-12 16:42:56 +08:00
|
|
|
static const char * const part_probe_types_def[] = {
|
|
|
|
"cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
|
|
|
|
|
|
|
|
static const char * const *of_get_probes(struct device_node *dp)
|
2010-03-10 03:27:56 +08:00
|
|
|
{
|
|
|
|
const char **res;
|
2017-03-30 23:58:53 +08:00
|
|
|
int count;
|
2010-03-10 03:27:56 +08:00
|
|
|
|
2017-03-30 23:58:53 +08:00
|
|
|
count = of_property_count_strings(dp, "linux,part-probe");
|
|
|
|
if (count < 0)
|
2010-03-10 03:27:56 +08:00
|
|
|
return part_probe_types_def;
|
|
|
|
|
2017-03-30 23:58:53 +08:00
|
|
|
res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
|
2015-07-17 18:37:52 +08:00
|
|
|
if (!res)
|
|
|
|
return NULL;
|
2017-03-30 23:58:53 +08:00
|
|
|
|
|
|
|
count = of_property_read_string_array(dp, "linux,part-probe", res,
|
|
|
|
count);
|
|
|
|
if (count < 0)
|
|
|
|
return NULL;
|
|
|
|
|
2010-03-10 03:27:56 +08:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-03-12 16:42:56 +08:00
|
|
|
static void of_free_probes(const char * const *probes)
|
2010-03-10 03:27:56 +08:00
|
|
|
{
|
|
|
|
if (probes != part_probe_types_def)
|
|
|
|
kfree(probes);
|
|
|
|
}
|
|
|
|
|
2015-03-17 03:20:28 +08:00
|
|
|
static const struct of_device_id of_flash_match[];
|
2012-11-20 02:23:07 +08:00
|
|
|
static int of_flash_probe(struct platform_device *dev)
|
2006-12-06 18:17:49 +08:00
|
|
|
{
|
2013-03-12 16:42:56 +08:00
|
|
|
const char * const *part_probe_types;
|
2011-05-19 01:19:24 +08:00
|
|
|
const struct of_device_id *match;
|
2010-04-14 07:12:29 +08:00
|
|
|
struct device_node *dp = dev->dev.of_node;
|
2006-12-06 18:17:49 +08:00
|
|
|
struct resource res;
|
2007-09-20 09:22:25 +08:00
|
|
|
struct of_flash *info;
|
2011-02-17 17:43:24 +08:00
|
|
|
const char *probe_type;
|
2010-10-01 15:06:08 +08:00
|
|
|
const __be32 *width;
|
2006-12-06 18:17:49 +08:00
|
|
|
int err;
|
2009-04-16 20:10:45 +08:00
|
|
|
int i;
|
|
|
|
int count;
|
2010-10-01 15:06:08 +08:00
|
|
|
const __be32 *p;
|
2009-04-16 20:10:45 +08:00
|
|
|
int reg_tuple_size;
|
|
|
|
struct mtd_info **mtd_list = NULL;
|
2009-07-17 23:54:14 +08:00
|
|
|
resource_size_t res_size;
|
2012-08-17 21:22:32 +08:00
|
|
|
bool map_indirect;
|
2012-12-23 19:10:50 +08:00
|
|
|
const char *mtd_name = NULL;
|
2009-04-16 20:10:45 +08:00
|
|
|
|
2011-05-19 01:19:24 +08:00
|
|
|
match = of_match_device(of_flash_match, &dev->dev);
|
|
|
|
if (!match)
|
2011-02-17 17:43:24 +08:00
|
|
|
return -EINVAL;
|
2011-05-19 01:19:24 +08:00
|
|
|
probe_type = match->data;
|
2011-02-17 17:43:24 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32);
|
|
|
|
|
2012-11-07 23:32:16 +08:00
|
|
|
of_property_read_string(dp, "linux,mtd-name", &mtd_name);
|
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
/*
|
|
|
|
* Get number of "reg" tuples. Scan for MTD devices on area's
|
|
|
|
* described by each "reg" region. This makes it possible (including
|
|
|
|
* the concat support) to support the Intel P30 48F4400 chips which
|
|
|
|
* consists internally of 2 non-identical NOR chips on one die.
|
|
|
|
*/
|
|
|
|
p = of_get_property(dp, "reg", &count);
|
2016-03-08 07:52:05 +08:00
|
|
|
if (!p || count % reg_tuple_size != 0) {
|
2009-04-16 20:10:45 +08:00
|
|
|
dev_err(&dev->dev, "Malformed reg property on %s\n",
|
2010-04-14 07:12:29 +08:00
|
|
|
dev->dev.of_node->full_name);
|
2009-04-16 20:10:45 +08:00
|
|
|
err = -EINVAL;
|
2009-07-30 23:24:27 +08:00
|
|
|
goto err_flash_remove;
|
2006-12-06 18:17:49 +08:00
|
|
|
}
|
2009-04-16 20:10:45 +08:00
|
|
|
count /= reg_tuple_size;
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2012-08-17 21:22:32 +08:00
|
|
|
map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access");
|
|
|
|
|
2007-09-20 09:22:25 +08:00
|
|
|
err = -ENOMEM;
|
2013-01-25 22:50:27 +08:00
|
|
|
info = devm_kzalloc(&dev->dev,
|
|
|
|
sizeof(struct of_flash) +
|
|
|
|
sizeof(struct of_flash_list) * count, GFP_KERNEL);
|
2009-04-16 20:10:45 +08:00
|
|
|
if (!info)
|
2009-07-30 23:24:27 +08:00
|
|
|
goto err_flash_remove;
|
2006-12-06 18:17:49 +08:00
|
|
|
|
|
|
|
dev_set_drvdata(&dev->dev, info);
|
|
|
|
|
2009-12-30 03:15:23 +08:00
|
|
|
mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL);
|
2009-07-30 23:24:27 +08:00
|
|
|
if (!mtd_list)
|
|
|
|
goto err_flash_remove;
|
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
err = -ENXIO;
|
|
|
|
if (of_address_to_resource(dp, i, &res)) {
|
2010-10-08 20:41:27 +08:00
|
|
|
/*
|
|
|
|
* Continue with next register tuple if this
|
|
|
|
* one is not mappable
|
|
|
|
*/
|
|
|
|
continue;
|
2009-04-16 20:10:45 +08:00
|
|
|
}
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2010-11-13 05:37:57 +08:00
|
|
|
dev_dbg(&dev->dev, "of_flash device: %pR\n", &res);
|
2009-04-16 20:10:45 +08:00
|
|
|
|
|
|
|
err = -EBUSY;
|
2009-07-17 23:54:14 +08:00
|
|
|
res_size = resource_size(&res);
|
|
|
|
info->list[i].res = request_mem_region(res.start, res_size,
|
2009-04-16 20:10:45 +08:00
|
|
|
dev_name(&dev->dev));
|
|
|
|
if (!info->list[i].res)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
err = -ENXIO;
|
|
|
|
width = of_get_property(dp, "bank-width", NULL);
|
|
|
|
if (!width) {
|
|
|
|
dev_err(&dev->dev, "Can't get bank width from device"
|
|
|
|
" tree\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2012-11-07 23:32:16 +08:00
|
|
|
info->list[i].map.name = mtd_name ?: dev_name(&dev->dev);
|
2009-04-16 20:10:45 +08:00
|
|
|
info->list[i].map.phys = res.start;
|
2009-07-17 23:54:14 +08:00
|
|
|
info->list[i].map.size = res_size;
|
2010-10-01 15:06:08 +08:00
|
|
|
info->list[i].map.bankwidth = be32_to_cpup(width);
|
2013-01-18 20:10:05 +08:00
|
|
|
info->list[i].map.device_node = dp;
|
2017-01-29 05:50:48 +08:00
|
|
|
|
|
|
|
err = of_flash_probe_gemini(dev, dp, &info->list[i].map);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2016-01-26 18:58:07 +08:00
|
|
|
err = of_flash_probe_versatile(dev, dp, &info->list[i].map);
|
2017-01-29 05:50:48 +08:00
|
|
|
if (err)
|
2016-01-26 18:58:07 +08:00
|
|
|
return err;
|
2009-04-16 20:10:45 +08:00
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
info->list[i].map.virt = ioremap(info->list[i].map.phys,
|
|
|
|
info->list[i].map.size);
|
|
|
|
if (!info->list[i].map.virt) {
|
|
|
|
dev_err(&dev->dev, "Failed to ioremap() flash"
|
|
|
|
" region\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
simple_map_init(&info->list[i].map);
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2012-08-17 21:22:32 +08:00
|
|
|
/*
|
|
|
|
* On some platforms (e.g. MPC5200) a direct 1:1 mapping
|
|
|
|
* may cause problems with JFFS2 usage, as the local bus (LPB)
|
|
|
|
* doesn't support unaligned accesses as implemented in the
|
|
|
|
* JFFS2 code via memcpy(). By setting NO_XIP, the
|
|
|
|
* flash will not be exposed directly to the MTD users
|
|
|
|
* (e.g. JFFS2) any more.
|
|
|
|
*/
|
|
|
|
if (map_indirect)
|
|
|
|
info->list[i].map.phys = NO_XIP;
|
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
if (probe_type) {
|
|
|
|
info->list[i].mtd = do_map_probe(probe_type,
|
|
|
|
&info->list[i].map);
|
|
|
|
} else {
|
|
|
|
info->list[i].mtd = obsolete_probe(dev,
|
|
|
|
&info->list[i].map);
|
|
|
|
}
|
2014-09-26 01:20:08 +08:00
|
|
|
|
|
|
|
/* Fall back to mapping region as ROM */
|
|
|
|
if (!info->list[i].mtd) {
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"do_map_probe() failed for type %s\n",
|
|
|
|
probe_type);
|
|
|
|
|
|
|
|
info->list[i].mtd = do_map_probe("map_rom",
|
|
|
|
&info->list[i].map);
|
|
|
|
}
|
2009-04-16 20:10:45 +08:00
|
|
|
mtd_list[i] = info->list[i].mtd;
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
err = -ENXIO;
|
|
|
|
if (!info->list[i].mtd) {
|
|
|
|
dev_err(&dev->dev, "do_map_probe() failed\n");
|
|
|
|
goto err_out;
|
|
|
|
} else {
|
|
|
|
info->list_size++;
|
|
|
|
}
|
|
|
|
info->list[i].mtd->dev.parent = &dev->dev;
|
|
|
|
}
|
2007-09-07 11:23:53 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
err = 0;
|
2012-11-27 23:38:16 +08:00
|
|
|
info->cmtd = NULL;
|
2009-04-16 20:10:45 +08:00
|
|
|
if (info->list_size == 1) {
|
|
|
|
info->cmtd = info->list[0].mtd;
|
|
|
|
} else if (info->list_size > 1) {
|
|
|
|
/*
|
|
|
|
* We detected multiple devices. Concatenate them together.
|
|
|
|
*/
|
|
|
|
info->cmtd = mtd_concat_create(mtd_list, info->list_size,
|
|
|
|
dev_name(&dev->dev));
|
2006-12-06 18:17:49 +08:00
|
|
|
}
|
2012-11-27 23:38:16 +08:00
|
|
|
if (info->cmtd == NULL)
|
|
|
|
err = -ENXIO;
|
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
if (err)
|
|
|
|
goto err_out;
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2015-10-31 11:33:30 +08:00
|
|
|
info->cmtd->dev.parent = &dev->dev;
|
2015-10-31 11:33:28 +08:00
|
|
|
mtd_set_of_node(info->cmtd, dp);
|
2010-03-10 03:27:56 +08:00
|
|
|
part_probe_types = of_get_probes(dp);
|
2015-07-17 18:37:52 +08:00
|
|
|
if (!part_probe_types) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out;
|
|
|
|
}
|
2015-10-31 11:33:28 +08:00
|
|
|
mtd_device_parse_register(info->cmtd, part_probe_types, NULL,
|
2011-06-02 21:59:59 +08:00
|
|
|
NULL, 0);
|
2010-03-10 03:27:56 +08:00
|
|
|
of_free_probes(part_probe_types);
|
2008-01-16 07:54:43 +08:00
|
|
|
|
2009-04-16 20:10:45 +08:00
|
|
|
kfree(mtd_list);
|
2006-12-06 18:17:49 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out:
|
2009-04-16 20:10:45 +08:00
|
|
|
kfree(mtd_list);
|
2009-07-30 23:24:27 +08:00
|
|
|
err_flash_remove:
|
2007-09-20 09:22:25 +08:00
|
|
|
of_flash_remove(dev);
|
2009-04-16 20:10:45 +08:00
|
|
|
|
2006-12-06 18:17:49 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2015-03-17 03:20:28 +08:00
|
|
|
static const struct of_device_id of_flash_match[] = {
|
2007-09-07 11:23:53 +08:00
|
|
|
{
|
|
|
|
.compatible = "cfi-flash",
|
|
|
|
.data = (void *)"cfi_probe",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
/* FIXME: JEDEC chips can't be safely and reliably
|
|
|
|
* probed, although the mtd code gets it right in
|
|
|
|
* practice most of the time. We should use the
|
|
|
|
* vendor and device ids specified by the binding to
|
|
|
|
* bypass the heuristic probe code, but the mtd layer
|
|
|
|
* provides, at present, no interface for doing so
|
|
|
|
* :(. */
|
|
|
|
.compatible = "jedec-flash",
|
|
|
|
.data = (void *)"jedec_probe",
|
|
|
|
},
|
2009-07-17 20:39:23 +08:00
|
|
|
{
|
|
|
|
.compatible = "mtd-ram",
|
|
|
|
.data = (void *)"map_ram",
|
|
|
|
},
|
2014-09-18 02:08:28 +08:00
|
|
|
{
|
|
|
|
.compatible = "mtd-rom",
|
|
|
|
.data = (void *)"map_rom",
|
|
|
|
},
|
2006-12-06 18:17:49 +08:00
|
|
|
{
|
|
|
|
.type = "rom",
|
|
|
|
.compatible = "direct-mapped"
|
|
|
|
},
|
|
|
|
{ },
|
|
|
|
};
|
2007-09-20 09:22:25 +08:00
|
|
|
MODULE_DEVICE_TABLE(of, of_flash_match);
|
2006-12-06 18:17:49 +08:00
|
|
|
|
2011-02-17 17:43:24 +08:00
|
|
|
static struct platform_driver of_flash_driver = {
|
2010-04-14 07:13:02 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "of-flash",
|
|
|
|
.of_match_table = of_flash_match,
|
|
|
|
},
|
2007-09-20 09:22:25 +08:00
|
|
|
.probe = of_flash_probe,
|
|
|
|
.remove = of_flash_remove,
|
2006-12-06 18:17:49 +08:00
|
|
|
};
|
|
|
|
|
2011-11-27 20:45:03 +08:00
|
|
|
module_platform_driver(of_flash_driver);
|
2006-12-06 18:17:49 +08:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Vitaly Wool <vwool@ru.mvista.com>");
|
2007-09-20 09:22:25 +08:00
|
|
|
MODULE_DESCRIPTION("Device tree based MTD map driver");
|