2005-04-17 02:20:36 +04:00
/*
2005-11-07 14:15:40 +03:00
* Flash memory access on Hynix GMS30C7201 / HMS30C7202 based
2005-04-17 02:20:36 +04:00
* evaluation boards
2005-11-07 14:15:40 +03:00
*
2005-04-17 02:20:36 +04:00
* ( C ) 2002 Jungjun Kim < jungjun . kim @ hynix . com >
2005-11-07 14:15:40 +03:00
* 2003 Thomas Gleixner < tglx @ linutronix . de >
2005-04-17 02:20:36 +04:00
*/
# include <linux/module.h>
# include <linux/types.h>
# include <linux/kernel.h>
# include <linux/init.h>
# include <linux/errno.h>
# include <linux/slab.h>
# include <linux/mtd/mtd.h>
# include <linux/mtd/map.h>
# include <linux/mtd/partitions.h>
2008-08-05 19:14:15 +04:00
# include <mach/hardware.h>
2005-04-17 02:20:36 +04:00
# include <asm/io.h>
static struct mtd_info * mymtd ;
static struct map_info h720x_map = {
. name = " H720X " ,
. bankwidth = 4 ,
2008-11-13 17:53:08 +03:00
. size = H720X_FLASH_SIZE ,
. phys = H720X_FLASH_PHYS ,
2005-04-17 02:20:36 +04:00
} ;
static struct mtd_partition h720x_partitions [ ] = {
{
. name = " ArMon " ,
. size = 0x00080000 ,
. offset = 0 ,
. mask_flags = MTD_WRITEABLE
} , {
. name = " Env " ,
. size = 0x00040000 ,
. offset = 0x00080000 ,
. mask_flags = MTD_WRITEABLE
} , {
. name = " Kernel " ,
. size = 0x00180000 ,
. offset = 0x000c0000 ,
. mask_flags = MTD_WRITEABLE
} , {
. name = " Ramdisk " ,
. size = 0x00400000 ,
. offset = 0x00240000 ,
. mask_flags = MTD_WRITEABLE
} , {
. name = " jffs2 " ,
. size = MTDPART_SIZ_FULL ,
. offset = MTDPART_OFS_APPEND
}
} ;
2006-03-31 14:29:45 +04:00
# define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions)
2005-04-17 02:20:36 +04:00
/*
* Initialize FLASH support
*/
2008-11-25 03:54:58 +03:00
static int __init h720x_mtd_init ( void )
2005-04-17 02:20:36 +04:00
{
2008-11-13 17:53:08 +03:00
h720x_map . virt = ioremap ( h720x_map . phys , h720x_map . size ) ;
2005-04-17 02:20:36 +04:00
if ( ! h720x_map . virt ) {
printk ( KERN_ERR " H720x-MTD: ioremap failed \n " ) ;
return - EIO ;
}
simple_map_init ( & h720x_map ) ;
// Probe for flash bankwidth 4
printk ( KERN_INFO " H720x-MTD probing 32bit FLASH \n " ) ;
mymtd = do_map_probe ( " cfi_probe " , & h720x_map ) ;
if ( ! mymtd ) {
printk ( KERN_INFO " H720x-MTD probing 16bit FLASH \n " ) ;
// Probe for bankwidth 2
h720x_map . bankwidth = 2 ;
mymtd = do_map_probe ( " cfi_probe " , & h720x_map ) ;
}
2005-11-07 14:15:40 +03:00
2005-04-17 02:20:36 +04:00
if ( mymtd ) {
mymtd - > owner = THIS_MODULE ;
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-09 21:24:26 +04:00
mtd_device_parse_register ( mymtd , NULL , NULL ,
h720x_partitions , NUM_PARTITIONS ) ;
2005-04-17 02:20:36 +04:00
return 0 ;
}
iounmap ( ( void * ) h720x_map . virt ) ;
return - ENXIO ;
}
/*
* Cleanup
*/
static void __exit h720x_mtd_cleanup ( void )
{
if ( mymtd ) {
2011-05-23 13:23:03 +04:00
mtd_device_unregister ( mymtd ) ;
2005-04-17 02:20:36 +04:00
map_destroy ( mymtd ) ;
}
2005-11-07 14:15:40 +03:00
2005-04-17 02:20:36 +04:00
if ( h720x_map . virt ) {
iounmap ( ( void * ) h720x_map . virt ) ;
h720x_map . virt = 0 ;
}
}
module_init ( h720x_mtd_init ) ;
module_exit ( h720x_mtd_cleanup ) ;
MODULE_LICENSE ( " GPL " ) ;
MODULE_AUTHOR ( " Thomas Gleixner <tglx@linutronix.de> " ) ;
MODULE_DESCRIPTION ( " MTD map driver for Hynix evaluation boards " ) ;