Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519290
  • 博文数量: 398
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 14
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-21 16:02
个人简介

嵌入式屌丝

文章分类

全部博文(398)

文章存档

2013年(398)

我的朋友

分类: LINUX

2013-08-21 16:24:42

Arm-linux东东nand: s3c2410_nand_update_chip

先来看简单的s3c2410_nand_update_chip

static void s3c2410_nand_update_chip(struct s3c2410_nand_info *info,

                                 struct s3c2410_nand_mtd *nmtd)

{

       struct nand_chip *chip = &nmtd->chip;

 

       printk("%s: chip %p: %d\n", __func__, chip, chip->page_shift);

 

       if (hardware_ecc) {

              /* change the behaviour depending on wether we are using

               * the large or small page nand device */

 

              if (chip->page_shift > 10) {

                     chip->ecc.size     = 256;

                     chip->ecc.bytes         = 3;

              } else {

                     chip->ecc.size     = 512;

                     chip->ecc.bytes         = 3;

                     chip->ecc.layout    = &nand_hw_eccoob;

              }

       }

}

这里跑出这么样的结构体:

/**

 * struct nand_ecc_ctrl - Control structure for ecc

 * @mode:     ecc mode

 * @steps:     number of ecc steps per page

 * @size:       data bytes per ecc step

 * @bytes:     ecc bytes per step

 * @total:       total number of ecc bytes per page

 * @prepad:   padding information for syndrome based ecc generators

 * @postpad:  padding information for syndrome based ecc generators

 * @layout:    ECC layout control struct pointer

 * @hwctl:     function to control hardware ecc generator. Must only

 *           be provided if an hardware ECC is available

 * @calculate:       function for ecc calculation or readback from ecc hardware

 * @correct:  function for ecc correction, matching to ecc generator (sw/hw)

 * @read_page_raw:     function to read a raw page without ECC

 * @write_page_raw:    function to write a raw page without ECC

 * @read_page:     function to read a page according to the ecc generator requirements

 * @write_page:    function to write a page according to the ecc generator requirements

 * @read_oob:       function to read chip OOB data

 * @write_oob:     function to write chip OOB data

 */

struct nand_ecc_ctrl {

       nand_ecc_modes_t mode;

       int                  steps;

       int                  size;

       int                  bytes;

       int                  total;

       int                  prepad;

       int                  postpad;

       struct nand_ecclayout    *layout;

       void               (*hwctl)(struct mtd_info *mtd, int mode);

       int                  (*calculate)(struct mtd_info *mtd,

                                        const uint8_t *dat,

                                        uint8_t *ecc_code);

       int                  (*correct)(struct mtd_info *mtd, uint8_t *dat,

                                      uint8_t *read_ecc,

                                      uint8_t *calc_ecc);

       int                  (*read_page_raw)(struct mtd_info *mtd,

                                           struct nand_chip *chip,

                                           uint8_t *buf);

       void               (*write_page_raw)(struct mtd_info *mtd,

                                            struct nand_chip *chip,

                                            const uint8_t *buf);

       int                  (*read_page)(struct mtd_info *mtd,

                                        struct nand_chip *chip,

                                        uint8_t *buf);

       void               (*write_page)(struct mtd_info *mtd,

                                         struct nand_chip *chip,

                                         const uint8_t *buf);

       int                  (*read_oob)(struct mtd_info *mtd,

                                       struct nand_chip *chip,

                                       int page,

                                       int sndcmd);

       int                  (*write_oob)(struct mtd_info *mtd,

                                        struct nand_chip *chip,

                                        int page);

};

好长呀.这里else语句会执行.

ecc.size就是计算一次ECC的时候的大小.什么意思呀>>

举个例子.我的硬件没有那么高级.只能算256ByteECC.512是不是要分两次来发送.不然的话我没有办法计算.

ecc.bytes就是算一次ECC有多少字节.不同的算法有不同的ECC长度.这个好理解.

static struct nand_ecclayout nand_hw_eccoob = {

       .eccbytes = 3,

       .eccpos = {0, 1, 2},

       .oobfree = {{8, 8}}

};

这个用到再说.反正就是一些值.

这个函数就这样了.

阅读(389) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~