//////////////////arch/arm/mach-s3c6410/mach-smdk6410.c
MACHINE_START(SMDK6410, "SMDK6410")
/* Maintainer: Ben Dooks */
.phys_io = S3C_PA_UART & 0xfff00000,
.io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
.boot_params = S3C64XX_PA_SDRAM + 0x100,
.init_irq = s3c6410_init_irq,
.map_io =
smdk6410_map_io,
.init_machine =
smdk6410_machine_init,
.timer = &s3c64xx_timer,
MACHINE_END
//////////////////arch/arm/mach-s3c6410/mach-smdk6410.c
static void __init smdk6410_map_io(void)
{
//有没有感觉到上面有什么不对?平台设备的驱动名和设备名应该是一样的,可现在不一样了。
//不过在下面这个函数中:进行了修正。
s3c_device_nand.name = "s3c6410-nand";
s3c64xx_init_io(smdk6410_iodesc, ARRAY_SIZE(smdk6410_iodesc));
s3c24xx_init_clocks(12000000);
s3c24xx_init_uarts(smdk6410_uartcfgs, ARRAY_SIZE(smdk6410_uartcfgs));
s3c64xx_reserve_bootmem();
}
//////////////////arch/arm/mach-s3c6410/mach-smdk6410.c
static void __init s
mdk6410_machine_init(void)
{
unsigned int tmp;
s3c_device_nand.dev.platform_data = &s3c_nand_mtd_part_info;//注意下面s3c_nand_mtd_part_info的定义很关键
s3c_device_onenand.dev.platform_data = &s3c_onenand_data;
//fusq
// smdk6410_smc911x_set();
s3c_i2c0_set_platdata(NULL);
//s3c_i2c1_set_platdata(NULL);
s3c_ts_set_platdata(&s3c_ts_platform);
s3c_adc_set_platdata(&s3c_adc_platform);
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
spi_register_board_info(sam_spi_devs, ARRAY_SIZE(sam_spi_devs));
s3c_fimc0_set_platdata(NULL);
s3c_fimc1_set_platdata(NULL);
#ifdef CONFIG_VIDEO_FIMC
//s3c_fimc_reset_camera();
#endif
//平台设备都在这里?
platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
s3c6410_pm_init();
smdk_backlight_register();
}
//////////////////arch/arm/mach-s3c6410/mach-smdk6410.c
static
struct platform_device *smdk6410_devices[] __initdata = {
#ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
#endif
#ifdef CONFIG_SMDK6410_SD_CH1
&s3c_device_hsmmc1,
#endif
#ifdef CONFIG_SMDK6410_SD_CH2
&s3c_device_hsmmc2,
#endif
&s3c_device_wdt,
&s3c_device_rtc,
&s3c_device_i2c0,
//&s3c_device_i2c1,
&s3c_device_spi0,
&s3c_device_spi1,
&s3c_device_keypad,
&s3c_device_ts,
//&s3c_device_smc911x,
&s3c_device_dm9000_cs1,
&s3c_device_lcd,
&s3c_device_vpp,
&s3c_device_mfc,
&s3c_device_tvenc,
&s3c_device_tvscaler,
&s3c_device_rotator,
&s3c_device_jpeg,
&s3c_device_nand,
&s3c_device_onenand,
&s3c_device_usb,
&s3c_device_usbgadget,
&s3c_device_usb_otghcd,
&s3c_device_fimc0,
&s3c_device_fimc1,
&s3c_device_g2d,
&s3c_device_g3d,
#ifdef CONFIG_S3C64XX_ADC
&s3c_device_adc,
#endif
#ifdef CONFIG_HAVE_PWM
&s3c_device_timer[0],
&s3c_device_timer[1],
#endif
};
//////////////////////////////arch/arm/plat-s3c64xx/devs.c
struct platform_device s3c_device_nand = {
//设备名称
.name = "
s3c-nand",//s3c_nand.c struct platform_driver s3c6410_nand_driver .name = "
s3c6410-nand",
.id = -1,
//资源数量
.num_resources = ARRAY_SIZE(s3c_nand_resource),
//引用资源
.resource = s3c_nand_resource,
};
//////////////////////////////arch/arm/plat-s3c64xx/devs.c
/* NAND Controller */
static struct resource s3c_nand_resource[] = {
[0] = {
.start = S3C64XX_PA_NAND,//寄存器组的内存首地址
.end =
S3C64XX_PA_NAND + S3C64XX_SZ_NAND - 1,
.flags = IORESOURCE_MEM,//内存资源
}
};
////////////////////////////// arch/arm/mach-s3c6400/include/mach/map.h
/* NAND flash controller */
#define S3C64XX_PA_NAND (0x70200000)
#define S3C64XX_SZ_NAND SZ_1M
查看S3C6410芯片手册
////////////////////////////////arch/arm/plat-s3c/include/plat/partition.h
struct s3c_nand_mtd_info
s3c_nand_mtd_part_info = {
.chip_nr = 1,
.mtd_part_nr = ARRAY_SIZE(s3c_partition_info),
.partition =
s3c_partition_info,
};
////////////////////////////////arch/arm/plat-s3c/include/plat/partition.h
struct mtd_partition
s3c_partition_info[] = {
{
.name = "Bootloader",
.offset = 0,
.size = (256*SZ_1K),
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = "Kernel",
.offset = (256*SZ_1K),
.size = (4*SZ_1M) - (256*SZ_1K),
.mask_flags = MTD_CAP_NANDFLASH,
},
#if defined(CONFIG_SPLIT_ROOT_FILESYSTEM)
{
.name = "Rootfs",
.offset = (4*SZ_1M),
.size = (80*SZ_1M),//(48*SZ_1M),
},
#endif
{
.name = "File System",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
};
以下是内核启动时打印出来的
NAND
device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V
8-bit)
Creating 4
MTD partitions on "NAND 256MiB 3,3V
8-bit":
0x00000000-0x00040000 :
"Bootloader"
0x00040000-0x00400000 :
"Kernel"
0x00400000-0x05400000 :
"Rootfs"
0x05400000-0x10000000 : "File System"
//////////////////////include/linux/mtd/partitions.h
/*
* Partition definition structure:
*
* An array of struct partition is passed along with a MTD object to
* add_mtd_partitions() to create them.
*
* For each partition, these fields are available:
* name: string that will be used to label the partition's MTD device.
* size: the partition size; if defined as MTDPART_SIZ_FULL, the partition
* will extend to the end of the master MTD device.
* offset: absolute starting position within the master MTD device; if
* defined as MTDPART_OFS_APPEND, the partition will start where the
* previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block.
* mask_flags: contains flags that have to be masked (removed) from the
* master MTD flag set for the corresponding MTD partition.
* For example, to force a read-only partition, simply adding
* MTD_WRITEABLE to the mask_flags will do the trick.
*
* Note: writeable partitions require their size and offset be
* erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
*/
//描述MTD分区
struct mtd_partition {
/* 分区名,如TQ2440_Board_uboot、TQ2440_Board_kernel、TQ2440_Board_yaffs2 */
char *name; /* identifier string */ 识别 字符串
u_int32_t size; /* partition size */ 分区 大小
u_int32_t offset; /* offset within the master MTD space */
/* 分区偏移值 */
u_int32_t mask_flags; /* master MTD flags to mask out for this partition */
/* 掩码标识,不重要 */
struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/
/* OOB布局 */
struct mtd_info **mtdp; /* pointer to store the MTD object */
};