Linux 对 Nand Flash 的支持

4 在 Linux 对 Nand Flash 的支持
4.1 Linux 下 Nand Flash 调用关系
4.1.1 Nand Flash 设备添加时数据结构包含关系

struct mtd_partition partition_info[]--> struct s3c2410_nand_set nandset--> struct s3c2410_platform_nand superlpplatfrom--> struct platform_device s3c_device_nand

在该数据结构的 name 字段的初始化值"s3c2410-nand",必须与 Nand Flash 设备驱动注册时
struct device_driver结构中的 name 字段相同,因为 platfrom bus 是依靠名字来匹配的.

--> struct platform_device *smdk2410_devices[]

4.1.2 Nand Flash 设备注册时数据结构包含关系

struct device_driver s3c2410_nand_driver
-->struct device *dev

该数据构由系统分配.

-->struct platform_device *pdev
-->struct s3c2410_platform_nand *plat
-->struct s3c2410_nand_set nset
-->struct mtd_partition

4.1.3 当发生系统调用时数据结构调用关系
struct mtd_info
它的*priv 指向 chip

-->struct nand_chip

它的*priv 指向 nmtd

-->struct s3c2410_nand_mtd

它是 s3c2410_nand_info 的一个字段

-->s3c2410_nand_info

它被设为 Nand Flash 设备驱动的私有数据结构,在 Nand Flash 设备驱动注册时分配空间.

-->struct device 

4.2 Linux 下 Nand Flash 驱动主要数据结构说明
4.2.1 s3c2410 专有数据结构

  1. s3c2410_nand_set
    struct s3c2410_nand_set {
    int nr_chips; /* 芯片的数目 /int nr_partitions; / 分区的数目 */char name; / 集合名称 /int nr_map; / 可选, 底层逻辑到物理的芯片数目 /struct mtd_partition partitions; / 分区列表 */
    };
  2. s3c2410_platform_and
    struct s3c2410_platform_nand {
    /* timing information for controller, all times in nanoseconds /
    int tacls; /
    从 CLE/ALE 有效到 nWE/nOE 的时间 /
    int twrph0; /
    nWE/nOE 的有效时间 /
    int twrph1; /
    从释放 CLE/ALE 到 nWE/nOE 不活动的时间 /
    int nr_sets; /
    集合数目 /struct s3c2410_nand_set sets; / 集合列表 // 根据芯片编号选择有效集合 */
    void (*select_chip)(struct s3c2410_nand_set , int chip);
    };
  3. s3c2410_nand_mtd
    在 drivers/mtd/nand/s3c2410.c 中,
    struct s3c2410_nand_mtd {
    struct mtd_info mtd; /* MTD 信息 /struct nand_chip chip; / nand flash 芯片信息 /
    struct s3c2410_nand_set set; /
    nand flash 集合 */
    struct s3c2410_nand_info info; / nand flash 信息 */
    int scan_res;
    };
  4. s3c2410_nand_info
    struct s3c2410_nand_info {
    /* mtd info /
    struct nand_hw_control controller; /
    硬件控制器 */
    struct s3c2410_nand_mtd mtds; / MTD 设备表 /
    struct s3c2410_platform_nand platform; /
    Nand 设备的平台 /
    /
    device info */
    struct device *device; /*设备指针 */
    struct resource *area; /*资源指针 */
    struct clk clk; / Nand Flash 时钟 */
    void __iomem regs; / 寄存器基地址(map后的逻辑地址) /
    int mtd_count; /
    MTD的数目 */
    unsigned char is_s3c2440;
    };
  5. struct clk
    在 arch/arm/mach­s3c2410/clock.h 中
    struct clk {
    struct list_head list; /* clock 列表结点 */
    struct module owner; / 所属模块 */
    struct clk parent; / 父结点 */
    const char name; / 名称 /
    int id; /
    编号 /
    atomic_t used; /
    使用者计数 /
    unsigned long rate; /
    时钟速率 /
    unsigned long ctrlbit; /
    控制位 */
    int (*enable)(struct clk , int enable); / Clock 打开方法 */};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值