Ignore:
Timestamp:
Mar 19, 2017, 2:58:06 PM (6 days ago)
Author:
brainslayer
Message:

compiles on northstar, but nand driver will likelly not work yet. still something todo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-4.9/drivers/mtd/bcm947xx/nand/brcmnand.c

    r31574 r31707  
    6060#include <bcmutils.h>
    6161
     62
     63struct nand_ecclayout {
     64        __u32 eccbytes;
     65        __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
     66        __u32 oobavail;
     67        struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
     68};
    6269/*
    6370 * Because the bcm_nflash doesn't consider second chip case,
     
    9198        struct nand_ecclayout   ecclayout;
    9299        int                     cmd_ret;        /* saved error code */
    93         int                     page_addr;      /* saved page address from SEQIN */
    94100        unsigned char           oob_index;
    95101        unsigned char           id_byte_index;
     
    285291        layout->oobavail = ((oob_per_sec - ecc_per_sec) << brcmnand->sec_per_page_shift) - 1;
    286292
    287         brcmnand->mtd.oobavail = layout->oobavail;
     293//      brcmnand->mtd.oobavail = layout->oobavail;
    288294//      brcmnand->chip.ecclayout = layout;
    289         brcmnand->chip.ecc.layout = layout;
    290 
     295//      brcmnand->chip.ecc.layout = layout;
     296        mtd_set_ooblayout(&brcmnand->mtd, &nand_ooblayout_lp_ops);
    291297        /* Output layout for debugging */
    292298        printk("Spare area=%d eccbytes %d, ecc bytes located at:\n",
     
    380386brcmnand_dev_ready(struct mtd_info *mtd)
    381387{
    382         struct nand_chip *chip = (struct nand_chip *)mtd->priv;
     388        struct nand_chip *chip = mtd_to_nand(mtd);;
    383389        struct brcmnand_mtd *brcmnand = (struct brcmnand_mtd *)chip->priv;
    384390
     
    499505 * INTERNAL - do page write, with or without ECC generation enabled
    500506 */
     507 
     508 
    501509static void
    502 _brcmnand_write_page_do(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, bool ecc)
     510_brcmnand_write_page_do(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int page, bool ecc)
    503511{
    504512        struct brcmnand_mtd *brcmnand = chip->priv;
     
    507515        int i;
    508516
    509         BUG_ON(brcmnand->page_addr == 0);
    510517        BUG_ON(mtd->oobsize > sizeof(tmp_poi));
    511518
    512519        /* Retreive pre-existing OOB values */
    513520        memcpy(tmp_poi, chip->oob_poi, mtd->oobsize);
    514         brcmnand->cmd_ret = brcmnand_read_oob(mtd, chip, brcmnand->page_addr);
     521        brcmnand->cmd_ret = brcmnand_read_oob(mtd, chip, page);
    515522        if (brcmnand->cmd_ret < 0)
    516523                return;
     
    520527                chip->oob_poi[i] &= tmp_poi[i];
    521528
    522         nand_addr = ((uint64)brcmnand->page_addr << chip->page_shift);
     529                       
     530        nand_addr = ((uint64)page << chip->page_shift);
    523531        brcmnand->cmd_ret = hndnand_write_page(brcmnand->nfl, nand_addr, buf,
    524532                chip->oob_poi, ecc);
     
    532540static int
    533541brcmnand_write_page_ecc(struct mtd_info *mtd, struct nand_chip *chip,
    534                 const uint8_t *buf, int oob_required)
    535 {
    536         _brcmnand_write_page_do(mtd, chip, buf, TRUE);
     542                const uint8_t *buf, int oob_required, int page)
     543{
     544        _brcmnand_write_page_do(mtd, chip, buf, page, TRUE);
    537545        return 0;
    538546}
     
    543551static int
    544552brcmnand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
    545                 const uint8_t *buf, int oob_required)
     553                const uint8_t *buf, int oob_required, int page)
    546554{
    547555        printk(KERN_INFO "%s: Enter!\n", __FUNCTION__);
    548556
    549         _brcmnand_write_page_do(mtd, chip, buf, FALSE);
     557        _brcmnand_write_page_do(mtd, chip, buf, page, FALSE);
    550558        return 0;
    551559}
     
    560568brcmnand_read_byte(struct mtd_info *mtd)
    561569{
    562         struct nand_chip *chip = mtd->priv;
     570        struct nand_chip *chip = mtd_to_nand(mtd);
    563571        struct brcmnand_mtd *brcmnand = chip->priv;
    564572        uint32 reg;
     
    618626brcmnand_select_chip(struct mtd_info *mtd, int chip_num)
    619627{
    620         struct nand_chip *chip = mtd->priv;
     628        struct nand_chip *chip = mtd_to_nand(mtd);
    621629        struct brcmnand_mtd *brcmnand = chip->priv;
    622630        /* chip_num == -1 means de-select the device */
     
    633641brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, int column, int page_addr)
    634642{
    635         struct nand_chip *chip = mtd->priv;
     643        struct nand_chip *chip = mtd_to_nand(mtd);
    636644        struct brcmnand_mtd *brcmnand = chip->priv;
    637645        uint64 nand_addr;
     
    656664                case NAND_CMD_SEQIN:
    657665                        BUG_ON(column >= mtd->writesize);
    658                         brcmnand->page_addr = page_addr;
    659666                        nand_addr = (uint64) column | ((uint64)page_addr << chip->page_shift);
    660667                        hndnand_cmdfunc(brcmnand->nfl, nand_addr, CMDFUNC_SEQIN);
     
    699706brcmnand_scan(struct mtd_info *mtd)
    700707{
    701         struct nand_chip *chip = mtd->priv;
     708        struct nand_chip *chip = mtd_to_nand(mtd);
    702709        struct brcmnand_mtd *brcmnand = chip->priv;
    703710        hndnand_t *nfl = brcmnand->nfl;
     
    727734                return ret;
    728735
    729         pr_debug( "%s: layout.oobavail=%d\n", __func__,
    730                 chip->ecc.layout->oobavail);
     736//      pr_debug( "%s: layout.oobavail=%d\n", __func__,
     737//              chip->ecc.layout->oobavail);
    731738
    732739        ret = nand_scan_tail(mtd);
     
    777784brcmnand_command_lp(struct mtd_info *mtd, unsigned int command, int column, int page_addr)
    778785{
    779         register struct nand_chip *chip = mtd->priv;
     786        register struct nand_chip *chip = mtd_to_nand(mtd);
    780787
    781788        /* Emulate NAND_CMD_READOOB */
     
    894901brcmnand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr)
    895902{
    896         register struct nand_chip *chip = mtd->priv;
     903        register struct nand_chip *chip = mtd_to_nand(mtd);
    897904        int ctrl = NAND_CTRL_CLE;
    898905
     
    10201027        int knldev;
    10211028        int offset = 0;
    1022         struct nand_chip *chip = mtd->priv;
     1029        struct nand_chip *chip = mtd_to_nand(mtd);
    10231030        struct brcmnand_mtd *brcmnand = chip->priv;
    10241031        int isbufdual=0;
Note: See TracChangeset for help on using the changeset viewer.