I. Partition Information
HHARM2410-STUDY Development Board uses 16 bit 8 m nor flash, partition information is as follows:
0x00000000-0x00040000: "bootloader"
0x00040000-0x00140000: "kernel"
0x00140000-0x00540000: "ramdisk"
0x0054-0x00740000: "cramfs"
0x0074109-0x00800000: "jffs2"
2. Add configuration items
1. Modify the drivers/MTD/maps/kconfig file and add the following content:
Config mtd_s3c2410
Tristate "CFI flash device mapped on S3C2410"
Depends on arm & mtd_cfi
Help
This enables access to the CFI flash on the cogent S3C2410 board.
If you have such a board, say 'y' here.
2. Modify the drivers/MTD/maps/MAKEFILE file and add the following content:
OBJ-$ (config_mtd_s3c2410) + = S3C2410. o
3. Copy the driver file S3C2410. C to the drivers/MTD/maps directory.
3. Configure and compile the kernel
# Make menuconfig
The following content is required:
Memory technology devices (MTD) -->
<*> Memory technology device (MTD) Support
[*] MTD partitioning support
<*> Direct char device access to MTD Devices
<*> Caching block Device Access to MTD Devices
RAM/ROM/flash chip drivers -->
<*> Detect flash chips by common flash interface (CFI) Probe
<*> Support for inter/sharp flash chips
Mapping drivers for Chip access -->
<*> CFI flash device mapped on S3C2410
Miscellaneous filesystems -->
<*> Journalling FLASH file system V2 (jffs2) Support
<*> Compressed ROM file system support (cramfs)
# Make zimage
4. Create a device file
# Mknod-M 666 mtd0 C 90 0
# Mknod-M 666 mtd1 C 90 2
# Mknod-M 666 mtd2 C 90 4
# Mknod-M 666 mtd3 C 90 6
# Mknod-M 666 mtd4 C 90 8
# Mknod-M 666 mtd5 C 90 10
# Mknod-M 666 mtdblock0 B 31 0
# Mknod-M 666 mtdblock1 B 31 1
# Mknod-M 666 mtdblock2 B 31 2
# Mknod-M 666 mtdblock3 B 31 3
# Mknod-M 666 mtdblock4 B 31 4
# Mknod-M 666 mtdblock5 B 31 5
V. Driver file S3C2410. c
/*
* $ ID: S3C2410. C, v 1.00 2006/12/05 10:18:14 gleixner exp $
*
* Handle mapping of the nor flash on cogent S3C2410 boards
*
* Copyright 2002 sysgo Real-Time Solutions GmbH
*
* This program is free software; you can redistribute it and/or modify
* It under the terms of the GNU General Public License version 2
* Published by the Free Software Foundation.
*/
# Include # Include # Include # Include # Include
# Include # Include # Include
# Ifdef config_mtd_partitions
# Include # Endif
# Define window_addr 0x01000000/* Physical Properties of Flash */
# Define window_size 0x800000
# Define buswidth 2
# Define flash_blocksize_main0x20000
# Define flash_numblocks_main128
/* Can be "cfi_probe", "jedec_probe", "map_rom", null };*/
# Define probetypes {"cfi_probe", null}
# Define msg_prefix "S3C2410-NOR:"/* prefix for our printk ()'s */
# Define mtdid "s3c2410-nor"/* For mtdparts = partitioning */
Static struct mtd_info * mymtd;
Struct map_info s3c2410nor_map = {
. Name = "nor flash on S3C2410 ",
. Size = window_size,
. Bankwidth = buswidth,
. Phys = window_addr,
};
# Ifdef config_mtd_partitions
/*
* MTD partitioning stuff
*/
Static struct mtd_partition static_partitions [] =
{
{
. Name = "bootloader ",
. Size = 0x040000,
. Offset = 0x0
},
{
. Name = "kernel ",
. Size = 0x0100000,
. Offset = 0x40000
},
{
. Name = "ramdisk ",
. Size = 0x400000,
. Offset = 0x140000
},
{
. Name = "cramfs (2 MB )",
. Size = 0x200000,
. Offset = 0x540000
},
{
. Name = "jffs2 (0.75 MB )",
. Size = 0xc0000,
. Offset = 0x740000
},
};
// Static const char * probes [] = {"Redboot", "cmdlinepart", null };
Static const char * probes [] = {null };
# Endif
Static int mtd_parts_nb = 0;
Static struct mtd_partition * mtd_parts = 0;
Int _ init init_s3c2410nor (void)
{
Static const char * rom_probe_types [] = probetypes;
Const char ** type;
Const char * part_type = 0;
Printk (kern_notice msg_prefix "0x % 08x at 0x % 08x/N ",
Window_size, window_addr );
S3c2410nor_map.virt = ioremap (window_addr, window_size );
If (! S3c2410nor_map.virt ){
Printk (msg_prefix "failed to ioremap/N ");
Return-EIO;
}
Simple_map_init (& s3c2410nor_map );
Mymtd = 0;
Type = rom_probe_types;
For (;! Mymtd & * type; Type ++ ){
Mymtd = do_map_probe (* type, & s3c2410nor_map );
}
If (mymtd ){
Mymtd-> owner = this_module;
# Ifdef config_mtd_partitions
Mtd_parts_nb = parse_mtd_partitions (mymtd, probes, & mtd_parts, mtdid );
If (mtd_parts_nb> 0)
Part_type = "detected ";
If (mtd_parts_nb = 0)
{
Mtd_parts = static_partitions;
Mtd_parts_nb = array_size (static_partitions );
Part_type = "static ";
}
# Endif
Add_mtd_device (mymtd );
If (mtd_parts_nb = 0)
Printk (kern_notice msg_prefix "no partition info available/N ");
Else
{
Printk (kern_notice msg_prefix
"Using % s partition definition/N", part_type );
Add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb );
}
Return 0;
}
Iounmap (void *) s3c2410nor_map.virt );
Return-enxio;
}
Static void _ exit cleanup_s3c2410nor (void)
{
If (mymtd ){
Del_mtd_device (mymtd );
Map_destroy (mymtd );
}
If (s3c2410nor_map.virt ){
Iounmap (void *) s3c2410nor_map.virt );
S3c2410nor_map.virt = 0;
}
}
Module_init (init_s3c2410nor );
Module_exit (cleanup_s3c2410nor );
Module_license ("GPL ");
Module_author ("gengyaojun ");
Module_description ("generic configurable MTD map driver ");