public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wang Jian <lark@linux.net.cn>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Suggestion on flash init
Date: Sun, 25 Dec 2005 12:33:23 +0800	[thread overview]
Message-ID: <20051225120433.F3F6.LARK@linux.net.cn> (raw)

Hi,

After reading many board/*/flash.c and writing customer board driver for
one of my customer, I think the current flash interface can be improved.

I suggest adding a subdir $(TOPDIR)/include/flash/ and putting flash
chip information here. When you use some kinds of flash chips, just
include relevant header files.

If we go further, many information in $(TOPDIR)/include/flash.h can be
put into these header files.

And, even flash operation (non-CFI) sample code can be put into
$(TOPDIR)/contrib/flash/.

The following is an example of AMD Spansion S29AL016M chip.

--snip--
#ifndef _FLASH_S29AL016M_H_ 
#define _FLASH_S29AL016M_H_ 
        
#define FLASH_S29AL016M_T_SECTORS       35
#define FLASH_S29AL016M_B_SECTORS       35
        
#define FLASH_S29AL016M_T_SIZE          0x00200000
#define FLASH_S29AL016M_B_SIZE          0x00200000


int FLASH_S29AL016M_T_BYTE_SA[] = {
        0x000000, 0x010000, 0x020000, 0x030000,
        0x040000, 0x050000, 0x060000, 0x070000,
        0x080000, 0x090000, 0x0A0000, 0x0B0000,
        0x0C0000, 0x0D0000, 0x0E0000, 0x0F0000,
        0x100000, 0x110000, 0x120000, 0x130000,
        0x140000, 0x150000, 0x160000, 0x170000,
        0x180000, 0x190000, 0x1A0000, 0x1B0000,
        0x1C0000, 0x1D0000, 0x1E0000, 0x1F0000,
        0x1F8000, 0x1FA000, 0x1C0000
};

int FLASH_S29AL016M_T_WORD_SA[] = {
        0x000000, 0x008000, 0x010000, 0x018000,
        0x020000, 0x028000, 0x030000, 0x038000,
        0x040000, 0x048000, 0x050000, 0x058000,
        0x060000, 0x068000, 0x070000, 0x078000,
        0x080000, 0x088000, 0x090000, 0x098000,
        0x0A0000, 0x0A8000, 0x0B0000, 0x0B8000,
        0x0C0000, 0x0C8000, 0x0D0000, 0x0D8000,
        0x0E0000, 0x0E8000, 0x0F0000, 0x0F8000,
        0x0FC000, 0x0FD000, 0x0FE000
};

int FLASH_S29AL016M_B_BYTE_SA[] = {
        0x000000, 0x004000, 0x006000, 0x008000,
        0x010000, 0x020000, 0x030000, 0x040000,
        0x050000, 0x060000, 0x070000, 0x080000,
        0x090000, 0x0A0000, 0x0B0000, 0x0C0000,
        0x0D0000, 0x0E0000, 0x0F0000, 0x100000,
        0x110000, 0x120000, 0x130000, 0x140000,
        0x150000, 0x160000, 0x170000, 0x180000,
        0x190000, 0x1A0000, 0x1B0000, 0x1C0000,
        0x1D0000, 0x1E0000, 0x1F0000
};

int FLASH_S29AL016M_B_WORD_SA[] = {
        0x000000, 0x002000, 0x003000, 0x004000,
        0x008000, 0x010000, 0x018000, 0x020000,
        0x028000, 0x030000, 0x038000, 0x040000,
        0x048000, 0x050000, 0x058000, 0x060000,
        0x068000, 0x070000, 0x078000, 0x080000,
        0x088000, 0x090000, 0x098000, 0x0A0000,
        0x0A8000, 0x0B0000, 0x0B8000, 0x0C0000,
        0x0C8000, 0x0D0000, 0x0D8000, 0x0E0000,
        0x0E8000, 0x0F0000, 0x0F8000
};

#endif
--snip--


In flash_get_size()
--snip--
        switch (device) {
        case BYTEME(AMD_ID_S29AL016M_T):
                info->flash_id += FLASH_S29AL016M_T;
                info->sector_count = FLASH_S29AL016M_T_SECTORS;
                info->size = FLASH_S29AL016M_T_SIZE;
                break;

        case BYTEME(AMD_ID_S29AL016M_B):
                info->flash_id += FLASH_S29AL016M_B;
                info->sector_count = FLASH_S29AL016M_B_SECTORS;
                info->size = FLASH_S29AL016M_B_SIZE;
                break;
--snip--


In flash_get_offset()
--snip--
        switch (info->flash_id & FLASH_TYPEMASK) {
        case FLASH_S29AL016M_T:
                for (i = 0; i < info->sector_count; i++) {
                        info->start[i] = base + FLASH_S29AL016M_T_BYTE_SA[i];
                }
                break;
        case FLASH_S29AL016M_B:
                for (i = 0; i < info->sector_count; i++) {
                        info->start[i] = base + FLASH_S29AL016M_B_BYTE_SA[i];
                }
                break;
--snip--

-- 
  lark

             reply	other threads:[~2005-12-25  4:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-25  4:33 Wang Jian [this message]
2005-12-25 10:19 ` [U-Boot-Users] Suggestion on flash init Wolfgang Denk
2005-12-25 12:02   ` Wang Jian
2005-12-25 16:34     ` Wolfgang Denk
2005-12-26  1:49       ` Wang Jian
2006-01-03 13:16         ` Wang Jian
2006-01-03 14:08           ` Wolfgang Denk
2006-01-03 15:34             ` Wang Jian
2006-01-03 15:44               ` Wolfgang Denk
2006-01-04 22:31         ` Tolunay Orkun
2006-01-04 23:51           ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2006-01-05 16:20 Nuno João (Ext_NBS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051225120433.F3F6.LARK@linux.net.cn \
    --to=lark@linux.net.cn \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox