2 * linux/drivers/mtd/onenand/generic.c
4 * Copyright (c) 2005 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 * This is a device driver for the OneNAND flash for generic boards.
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/platform_device.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/onenand.h>
20 #include <linux/mtd/partitions.h>
24 * Note: Driver name and platform data format have been updated!
26 * This version of the driver is named "onenand-flash" and takes struct
27 * onenand_platform_data as platform data. The old ARM-specific version
28 * with the name "onenand" used to take struct flash_platform_data.
30 #define DRIVER_NAME "onenand-flash"
34 struct onenand_chip onenand
;
37 static int generic_onenand_probe(struct platform_device
*pdev
)
39 struct onenand_info
*info
;
40 struct onenand_platform_data
*pdata
= dev_get_platdata(&pdev
->dev
);
41 struct resource
*res
= pdev
->resource
;
42 unsigned long size
= resource_size(res
);
45 info
= kzalloc(sizeof(struct onenand_info
), GFP_KERNEL
);
49 if (!request_mem_region(res
->start
, size
, dev_name(&pdev
->dev
))) {
54 info
->onenand
.base
= ioremap(res
->start
, size
);
55 if (!info
->onenand
.base
) {
57 goto out_release_mem_region
;
60 info
->onenand
.mmcontrol
= pdata
? pdata
->mmcontrol
: NULL
;
61 info
->onenand
.irq
= platform_get_irq(pdev
, 0);
63 info
->mtd
.name
= dev_name(&pdev
->dev
);
64 info
->mtd
.priv
= &info
->onenand
;
65 info
->mtd
.owner
= THIS_MODULE
;
67 if (onenand_scan(&info
->mtd
, 1)) {
72 err
= mtd_device_parse_register(&info
->mtd
, NULL
, NULL
,
73 pdata
? pdata
->parts
: NULL
,
74 pdata
? pdata
->nr_parts
: 0);
76 platform_set_drvdata(pdev
, info
);
81 iounmap(info
->onenand
.base
);
82 out_release_mem_region
:
83 release_mem_region(res
->start
, size
);
90 static int generic_onenand_remove(struct platform_device
*pdev
)
92 struct onenand_info
*info
= platform_get_drvdata(pdev
);
93 struct resource
*res
= pdev
->resource
;
94 unsigned long size
= resource_size(res
);
97 onenand_release(&info
->mtd
);
98 release_mem_region(res
->start
, size
);
99 iounmap(info
->onenand
.base
);
106 static struct platform_driver generic_onenand_driver
= {
110 .probe
= generic_onenand_probe
,
111 .remove
= generic_onenand_remove
,
114 module_platform_driver(generic_onenand_driver
);
116 MODULE_LICENSE("GPL");
117 MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
118 MODULE_DESCRIPTION("Glue layer for OneNAND flash on generic boards");
119 MODULE_ALIAS("platform:" DRIVER_NAME
);