2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-11-08 05:47:48 +08:00
|
|
|
/*
|
|
|
|
* Map driver for Intel XScale PXA2xx platforms.
|
|
|
|
*
|
|
|
|
* Author: Nicolas Pitre
|
|
|
|
* Copyright: (C) 2001 MontaVista Software Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.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>
|
2005-11-08 05:47:48 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/mtd/map.h>
|
|
|
|
#include <linux/mtd/partitions.h>
|
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/mach/flash.h>
|
|
|
|
|
2009-12-11 09:21:57 +08:00
|
|
|
#define CACHELINESIZE 32
|
|
|
|
|
2005-11-08 05:47:48 +08:00
|
|
|
static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from,
|
|
|
|
ssize_t len)
|
|
|
|
{
|
2009-12-11 09:21:57 +08:00
|
|
|
unsigned long start = (unsigned long)map->cached + from;
|
|
|
|
unsigned long end = start + len;
|
|
|
|
|
|
|
|
start &= ~(CACHELINESIZE - 1);
|
|
|
|
while (start < end) {
|
|
|
|
/* invalidate D cache line */
|
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start));
|
|
|
|
start += CACHELINESIZE;
|
|
|
|
}
|
2005-11-08 05:47:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct pxa2xx_flash_info {
|
|
|
|
struct mtd_info *mtd;
|
|
|
|
struct map_info map;
|
|
|
|
};
|
|
|
|
|
2013-03-12 16:46:37 +08:00
|
|
|
static const char * const probes[] = { "RedBoot", "cmdlinepart", NULL };
|
2005-11-08 05:47:48 +08:00
|
|
|
|
2012-11-20 02:23:07 +08:00
|
|
|
static int pxa2xx_flash_probe(struct platform_device *pdev)
|
2005-11-08 05:47:48 +08:00
|
|
|
{
|
2013-07-30 16:18:06 +08:00
|
|
|
struct flash_platform_data *flash = dev_get_platdata(&pdev->dev);
|
2005-11-08 05:47:48 +08:00
|
|
|
struct pxa2xx_flash_info *info;
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!res)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2010-05-14 04:03:15 +08:00
|
|
|
info = kzalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
|
2005-11-08 05:47:48 +08:00
|
|
|
if (!info)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-11-13 03:07:15 +08:00
|
|
|
info->map.name = flash->name;
|
2005-11-08 05:47:48 +08:00
|
|
|
info->map.bankwidth = flash->width;
|
|
|
|
info->map.phys = res->start;
|
2011-06-10 00:13:32 +08:00
|
|
|
info->map.size = resource_size(res);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
|
|
|
info->map.virt = ioremap(info->map.phys, info->map.size);
|
|
|
|
if (!info->map.virt) {
|
|
|
|
printk(KERN_WARNING "Failed to ioremap %s\n",
|
|
|
|
info->map.name);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2019-08-17 15:32:28 +08:00
|
|
|
info->map.cached = ioremap_cache(info->map.phys, info->map.size);
|
2005-11-08 05:47:48 +08:00
|
|
|
if (!info->map.cached)
|
|
|
|
printk(KERN_WARNING "Failed to ioremap cached %s\n",
|
|
|
|
info->map.name);
|
|
|
|
info->map.inval_cache = pxa2xx_map_inval_cache;
|
|
|
|
simple_map_init(&info->map);
|
|
|
|
|
|
|
|
printk(KERN_NOTICE
|
|
|
|
"Probing %s at physical address 0x%08lx"
|
|
|
|
" (%d-bit bankwidth)\n",
|
|
|
|
info->map.name, (unsigned long)info->map.phys,
|
|
|
|
info->map.bankwidth * 8);
|
|
|
|
|
|
|
|
info->mtd = do_map_probe(flash->map_name, &info->map);
|
|
|
|
|
|
|
|
if (!info->mtd) {
|
|
|
|
iounmap((void *)info->map.virt);
|
|
|
|
if (info->map.cached)
|
|
|
|
iounmap(info->map.cached);
|
|
|
|
return -EIO;
|
|
|
|
}
|
2015-06-11 04:38:33 +08:00
|
|
|
info->mtd->dev.parent = &pdev->dev;
|
2005-11-08 05:47:48 +08:00
|
|
|
|
mtd: do not use plain 0 as NULL
The first 3 arguments of 'mtd_device_parse_register()' are pointers,
but many callers pass '0' instead of 'NULL'. Fix this globally. Thanks
to coccinelle for making it easy to do with the following semantic patch:
@@
expression mtd, types, parser_data, parts, nr_parts;
@@
(
-mtd_device_parse_register(mtd, 0, parser_data, parts, nr_parts)
+mtd_device_parse_register(mtd, NULL, parser_data, parts, nr_parts)
|
-mtd_device_parse_register(mtd, types, 0, parts, nr_parts)
+mtd_device_parse_register(mtd, types, NULL, parts, nr_parts)
|
-mtd_device_parse_register(mtd, types, parser_data, 0, nr_parts)
+mtd_device_parse_register(mtd, types, parser_data, NULL, nr_parts)
)
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2012-03-10 01:24:26 +08:00
|
|
|
mtd_device_parse_register(info->mtd, probes, NULL, flash->parts,
|
|
|
|
flash->nr_parts);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
2009-02-06 23:40:12 +08:00
|
|
|
platform_set_drvdata(pdev, info);
|
2005-11-08 05:47:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:26:04 +08:00
|
|
|
static int pxa2xx_flash_remove(struct platform_device *dev)
|
2005-11-08 05:47:48 +08:00
|
|
|
{
|
2009-02-06 23:40:12 +08:00
|
|
|
struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
2011-05-23 17:22:50 +08:00
|
|
|
mtd_device_unregister(info->mtd);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
|
|
|
map_destroy(info->mtd);
|
|
|
|
iounmap(info->map.virt);
|
|
|
|
if (info->map.cached)
|
2016-02-25 15:57:52 +08:00
|
|
|
iounmap(info->map.cached);
|
2005-11-08 05:47:48 +08:00
|
|
|
kfree(info);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
2009-02-06 23:40:12 +08:00
|
|
|
static void pxa2xx_flash_shutdown(struct platform_device *dev)
|
2005-11-08 05:47:48 +08:00
|
|
|
{
|
2009-02-06 23:40:12 +08:00
|
|
|
struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
2011-12-24 01:25:16 +08:00
|
|
|
if (info && mtd_suspend(info->mtd) == 0)
|
2011-12-24 01:31:25 +08:00
|
|
|
mtd_resume(info->mtd);
|
2005-11-08 05:47:48 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define pxa2xx_flash_shutdown NULL
|
|
|
|
#endif
|
|
|
|
|
2009-02-06 23:40:12 +08:00
|
|
|
static struct platform_driver pxa2xx_flash_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "pxa2xx-flash",
|
|
|
|
},
|
2005-11-08 05:47:48 +08:00
|
|
|
.probe = pxa2xx_flash_probe,
|
2012-11-20 02:21:24 +08:00
|
|
|
.remove = pxa2xx_flash_remove,
|
2005-11-08 05:47:48 +08:00
|
|
|
.shutdown = pxa2xx_flash_shutdown,
|
|
|
|
};
|
|
|
|
|
2011-11-27 20:45:03 +08:00
|
|
|
module_platform_driver(pxa2xx_flash_driver);
|
2005-11-08 05:47:48 +08:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
2009-09-14 15:25:28 +08:00
|
|
|
MODULE_AUTHOR("Nicolas Pitre <nico@fluxnic.net>");
|
2005-11-08 05:47:48 +08:00
|
|
|
MODULE_DESCRIPTION("MTD map driver for Intel XScale PXA2xx");
|