⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s3c2410_wpq.c

📁 uCLinux默认的根文件系统是romfs
💻 C
字号:
/*
 * $Id: s3c2410_wpq.c *
 * Normal mappings of chips in physical memory
 */

#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/config.h>
#include <linux/mtd/partitions.h>

#define WINDOW_ADDR 0x0 
#define WINDOW_SIZE 0x4000000  
#define BUSWIDTH 2
/*
#define WINDOW_ADDR CONFIG_MTD_PHYSMAP_START
#define WINDOW_SIZE CONFIG_MTD_PHYSMAP_LEN
#define BUSWIDTH CONFIG_MTD_PHYSMAP_BUSWIDTH
*/
static struct mtd_info *mymtd;

__u8 s3c2410_read8(struct map_info *map, unsigned long ofs)
{
	return __raw_readb(map->map_priv_1 + ofs);
}

__u16 s3c2410_read16(struct map_info *map, unsigned long ofs)
{
	return __raw_readw(map->map_priv_1 + ofs);
}

__u32 s3c2410_read32(struct map_info *map, unsigned long ofs)
{
	return __raw_readl(map->map_priv_1 + ofs);
}

#ifdef CFI_WORD_64
__u64 s3c2410_read64(struct map_info *map, unsigned long ofs)
{
	return __raw_readll(map->map_priv_1 + ofs);
}
#endif

void s3c2410_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
	memcpy_fromio(to, map->map_priv_1 + from, len);
}

void s3c2410_write8(struct map_info *map, __u8 d, unsigned long adr)
{
	__raw_writeb(d, map->map_priv_1 + adr);
	mb();
}

void s3c2410_write16(struct map_info *map, __u16 d, unsigned long adr)
{
	__raw_writew(d, map->map_priv_1 + adr);
	mb();
}

void s3c2410_write32(struct map_info *map, __u32 d, unsigned long adr)
{
	__raw_writel(d, map->map_priv_1 + adr);
	mb();
}

#ifdef CFI_WORD_64
void s3c2410_write64(struct map_info *map, __u64 d, unsigned long adr)
{
	__raw_writell(d, map->map_priv_1 + adr);
	mb();
}
#endif

void s3c2410_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
	memcpy_toio(map->map_priv_1 + to, from, len);
}

struct map_info s3c2410_map = {
	name: "s3c2410 flash device",
	size: WINDOW_SIZE,
	buswidth: BUSWIDTH,
	read8: s3c2410_read8,
	read16: s3c2410_read16,
	read32: s3c2410_read32,
#ifdef CFI_WORD_64
	read64: s3c2410_read64,
#endif
	copy_from: s3c2410_copy_from,
	write8: s3c2410_write8,
	write16: s3c2410_write16,
	write32: s3c2410_write32,
#ifdef CFI_WORD_64
	write64: s3c2410_write64,
#endif
	copy_to: s3c2410_copy_to
	map_priv_1: WINDOW_ADDR
    map_priv_2: -1
};

	static struct mtd_partition s3c2410_partitions[] = {
	{
		name:		"vivi",
		size:		0x020000,
		offset:		0x00000,
		mask_flags:	MTD_WRITEABLE,  /* force read-only */
	}, {
		name:		"param",
		size:		0x010000,
		offset:		0x020000,
	},
		{
		name:		"kernel",
		size:		0x0001c0000,
		offset:		0x030000,
	}, {
		name:		"root",
		size:		0x0200000,
		offset:		0x0200000,
	}, {
		name:		"usr",
		size:		0x01c8f000,
		offset:		0x0400000,
	}

};

int __init init_s3c2410(void)
{
	static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 };
	const char **type;

       	printk(KERN_NOTICE "s3c2410 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
	    s3c2410_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

	if (!s3c2410_map.map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	  }
	
	mymtd =do_map_probe("jedec_probe",&s3c2410_map);
	if (!mymtd) {
		mymtd =do_map_probe("cfi_probe",&s3c2410_map);
	}
	
	if (mymtd) {
		mymtd->module = THIS_MODULE;
		mymtd->erasesize = 0x40000;
		return add_mtd_partitions (mymtd,s3c2410_partitions,sizeof(s3c2410_partitions)/sizeof(struct mtd_partition));
	}

	iounmap((void *)s3c2410_map.map_priv_1);
	return -ENXIO;
}

static void __exit cleanup_s3c2410(void)
{
	if (mymtd) {
		del_mtd_device(mymtd);
		map_destroy(mymtd);
	}
	if (s3c2410_map.map_priv_1) {
		iounmap((void *)s3c2410_map.map_priv_1);
		s3c2410_map.map_priv_1 = 0;
	}
}

module_init(init_s3c2410);
module_exit(cleanup_s3c2410);、
6.配置内核

Linux Kernel v2.4.18-rmk7-pxa1 Configuration

Linux Kernel v2.4.18-rmk7-pxa1 Configuration
 ------------------------------------------------------------------------------
  +-------------------- Memory Technology Devices (MTD) --------------------+
  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.          |
  |  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, |
  |  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help.     |
  |  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable     |
  | +---------------------------------------------------------------------+ |
  | |         <*> Memory Technology Device (MTD) support                  | |
  | |         [*] Debugging                                               | |
  | |         (3)   Debugging verbosity (0 = quiet, 3 = noisy)            | |
  | |         <*>   MTD partitioning support                              | |
  | |         <*>   MTD concatenating support                             | |
  | |         < >   RedBoot partition table parsing                       | |
  | |         < >   Command line partition table parsing                  | |
  | |         < >   ARM Firmware Suite partition parsing                  | |
  | |         --- User Modules And Translation Layers                     | |
  | |         <*>   Direct char device access to MTD devices              | |
  | |         <*>   Caching block device access to MTD devices            | |
  |         < >   FTL (Flash Translation Layer) support                 | |
  | |         < >   NFTL (NAND Flash Translation Layer) support           | |
  | |         RAM/ROM/Flash chip drivers  --->                            | |
  | |         Mapping drivers for chip access  --->                       | |
  | |         Self-contained MTD device drivers  --->                     | |
  | |         NAND Flash Device Drivers  --->                             | |
  | +---------------------------------------------------------------------+ |
  +------------------------
  | +---------v(+)--------------------------------------------------------+ |
  +-------------------------------------------------------------------------+
  |                    <Select>    < Exit >    < Help >                     |
  +---------------------------------------------------


 Linux Kernel v2.4.18-rmk7-pxa1 Configuration
 ------------------------------------------------------------------------------
  +---------------------- RAM/ROM/Flash chip drivers -----------------------+
  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.          |
  |  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, |
  |  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help.     |
  |  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable     |
  | +---------------------------------------------------------------------+ |
  | |<*>   Detect flash chips by Common Flash Interface (CFI) probe       | |
  | |<*>   Detect JEDEC JESD21c compatible flash chips                    | |
  | |[ ]   Flash chip driver advanced configuration options               | |
  | |< >   Support for Intel/Sharp flash chips                            | |
  | |< >   Support for AMD/Fujitsu flash chips                            | |
  | |< >   Support for RAM chips in bus mapping                           | |
  | |< >   Support for ROM chips in bus mapping                           | |
  | |< >   Support for absent chips in bus mapping                        | |
  | |[ ]   Older (theoretically obsoleted now) drivers for non-CFI chips  | |
  | |                                                                     | |
  | |                                                                     | |
  | +---------------------------------------------------------------------+ |
  +-------------------------------------------------------------------------+
  |                    <Select>    < Exit >    < Help >                     |
  +-------------------------------------------------------------------------+




Linux Kernel v2.4.18-rmk7-pxa1 Configuration
 ------------------------------------------------------------------------------
  +-------------------- Mapping drivers for chip access --------------------+
  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.          |
  |  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, |
  |  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help.     |
  |  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable     |
  | +---------------------------------------------------------------------+ |
  | |       <*>   CFI Flash device in physical memory map                 | |
  | |       (8000000)     Physical start address of flash mapping          | |
  | |       (4000000)     Physical length of flash mapping                 | |
  | |       (2)     Bus width in octets                                   | |
  | |       <*>   CFI Flash device mapped on S3C2410                      | |
  | |                                                                     | |
  | |                                                                     | |
  | |                                                                     | |
  | |                                                                     | |
  | |                                                                     | |
  | |                                                                     | |
  | +---------------------------------------------------------------------+ |
  +-------------------------------------------------------------------------+
  |                    <Select>    < Exit >    < Help >                     |
  +-------------------------------------------------------------------------+



 Linux Kernel v2.4.18-rmk7-pxa1 Configuration
 ------------------------------------------------------------------------------
  +----------------------------- File systems ------------------------------+
  |  Arrow keys navigate the menu.  <Enter> selects submenus --->.          |
  |  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, |
  |  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help.     |
  |  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable     |
  | +---------------------------------------------------------------------+ |
  | |  [ ] Quota support                                                  | |
  | |  < > Kernel automounter support                                     | |
  | |  < > Kernel automounter version 4 support (also supports v3)        | |
  | |  < > Reiserfs support                                               | |
  | |  < > ADFS file system support                                       | |
  | |  < > Amiga FFS file system support (EXPERIMENTAL)                   | |
  | |  < > Apple Macintosh file system support (EXPERIMENTAL)             | |
  | |  < > BFS file system support (EXPERIMENTAL)                         | |
  | |  <*> Ext3 journalling file system support (EXPERIMENTAL)            | |
  | |  [ ]   JBD (ext3) debugging support                                 | |
  | |  <*> DOS FAT fs support                                             | |
 |  < >   MSDOS fs support                                             | |
  | |  <*>   VFAT (Windows-95) fs support                                 | |
  | |  < > EFS file system support (read only) (EXPERIMENTAL)             | |
  | |  < > Journalling Flash File System (JFFS) support                   | |
  | |  <*> Journalling Flash File System v2 (JFFS2) support               | |
  | |  (2) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)               | |
  | |  <*> Compressed ROM file system support                             | |
  | |  [*] Virtual memory file system support (former shm fs)             | |
  | |  <*> Simple RAM-based file system support                           | |
  | |  < > ISO 9660 CDROM file system support                             | |
  | |  < > Minix fs support         
  |  < > FreeVxFS file system support (VERITAS VxFS(TM) compatible)     | |
  | |  < > NTFS file system support (read only)                           | |
  | |  < > OS/2 HPFS file system support                                  | |
  | |  [*] /proc file system support                                      | |
  | |  [*] /dev file system support (EXPERIMENTAL)                        | |
  | |  [*]   Automatically mount at boot                                  | |
  | |  [ ]   Debug devfs                                                  | |
  | |  [*] /dev/pts file system for Unix98 PTYs                           | |
  | |  < > QNX4 file system support (read only) (EXPERIMENTAL)            | |
  | |  < > ROM file system support                                        | |
  | |  <*> Second extended fs support
  |  [ ]   Debug devfs                                                  | |
  | |  [*] /dev/pts file system for Unix98 PTYs                           | |
  | |  < > QNX4 file system support (read only) (EXPERIMENTAL)            | |
  | |  < > ROM file system support                                        | |
  | |  <*> Second extended fs support                                     | |
  | |  < > System V/Xenix/V7/Coherent file system support                 | |
  | |  < > UDF file system support (read only)                            | |
  | |  < > UFS file system support (read only)                            | |
  | |  Network File Systems  --->                                         | |
  | |  Partition Types  --->                                              | |
  | |  Native Language Support  --->          
  | +--v(+)---------------------------------------------------------------+ |
  +-------------------------------------------------------------------------+
  |                    <Select>    < Exit >    < Help >                     |
  +-------------------------------------------------------------------------+

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -