2 * Copyright (c) 2005 Samsung Electronics
3 * Kyungmin Park <kyungmin.park@samsung.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
10 * This is a device driver for the OneNAND flash for generic boards.
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/platform_device.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/onenand.h>
18 #include <linux/mtd/partitions.h>
22 * Note: Driver name and platform data format have been updated!
24 * This version of the driver is named "onenand-flash" and takes struct
25 * onenand_platform_data as platform data. The old ARM-specific version
26 * with the name "onenand" used to take struct flash_platform_data.
28 #define DRIVER_NAME "onenand-flash"
32 struct onenand_chip onenand
;
35 static int generic_onenand_probe(struct platform_device
*pdev
)
37 struct onenand_info
*info
;
38 struct onenand_platform_data
*pdata
= dev_get_platdata(&pdev
->dev
);
39 struct resource
*res
= pdev
->resource
;
40 unsigned long size
= resource_size(res
);
43 info
= kzalloc(sizeof(struct onenand_info
), GFP_KERNEL
);
47 if (!request_mem_region(res
->start
, size
, dev_name(&pdev
->dev
))) {
52 info
->onenand
.base
= ioremap(res
->start
, size
);
53 if (!info
->onenand
.base
) {
55 goto out_release_mem_region
;
58 info
->onenand
.mmcontrol
= pdata
? pdata
->mmcontrol
: NULL
;
59 info
->onenand
.irq
= platform_get_irq(pdev
, 0);
61 info
->mtd
.dev
.parent
= &pdev
->dev
;
62 info
->mtd
.priv
= &info
->onenand
;
64 if (onenand_scan(&info
->mtd
, 1)) {
69 err
= mtd_device_register(&info
->mtd
, pdata
? pdata
->parts
: NULL
,
70 pdata
? pdata
->nr_parts
: 0);
72 platform_set_drvdata(pdev
, info
);
77 iounmap(info
->onenand
.base
);
78 out_release_mem_region
:
79 release_mem_region(res
->start
, size
);
86 static int generic_onenand_remove(struct platform_device
*pdev
)
88 struct onenand_info
*info
= platform_get_drvdata(pdev
);
89 struct resource
*res
= pdev
->resource
;
90 unsigned long size
= resource_size(res
);
93 onenand_release(&info
->mtd
);
94 release_mem_region(res
->start
, size
);
95 iounmap(info
->onenand
.base
);
102 static struct platform_driver generic_onenand_driver
= {
106 .probe
= generic_onenand_probe
,
107 .remove
= generic_onenand_remove
,
110 module_platform_driver(generic_onenand_driver
);
112 MODULE_LICENSE("GPL");
113 MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
114 MODULE_DESCRIPTION("Glue layer for OneNAND flash on generic boards");
115 MODULE_ALIAS("platform:" DRIVER_NAME
);