public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Kári Davíðsson" <kari.davidsson@marel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Flash CFI detection code.
Date: Tue, 13 May 2008 14:43:22 +0000	[thread overview]
Message-ID: <1210689802.25113.12.camel@marel2693> (raw)

Hi,

We have an flash (CFI) connected through an 8 bit bus.

What happens is that the call to cmdset_amd_init() is called with
portwidth set to 2 resulting in flash_info_t::manufacturer_id equal to 0
and also flash_info_t::device_id is set to 0. This is because the
commandpatterns are wrong for 8 bit devices.

Later on in the flash_get_size() function the portwidth is set to 1 as
it should be (around line 1807).

After that the cmdset_amd_init() can be called and the 
manufacturer_id and device_id are set correctly....

Maybe this does not make sense but the patch below allows me to read the
manufacturer_id and device_id correctly. If this is applicable in
general for all boards I have no idea.

The patch is against u-boot-1.3.2.

rg
kd


Index: drivers/mtd/cfi_flash.c
===================================================================
--- drivers/mtd/cfi_flash.c     (revision 283)
+++ drivers/mtd/cfi_flash.c     (working copy)
@@ -102,9 +102,9 @@
 #define AMD_STATUS_ERROR               0x20

 #define FLASH_OFFSET_MANUFACTURER_ID   0x00
-#define FLASH_OFFSET_DEVICE_ID         0x01
-#define FLASH_OFFSET_DEVICE_ID2                0x0E
-#define FLASH_OFFSET_DEVICE_ID3                0x0F
+#define FLASH_OFFSET_DEVICE_ID         ((info->portwidth ==
FLASH_CFI_8BIT) ? 0x02 : 0x01)
+#define FLASH_OFFSET_DEVICE_ID2                ((info->portwidth ==
FLASH_CFI_8BIT) ? 0x1C : 0x0E)
+#define FLASH_OFFSET_DEVICE_ID3                ((info->portwidth ==
FLASH_CFI_8BIT) ? 0x1E : 0x0F)
 #define FLASH_OFFSET_CFI               0x55
 #define FLASH_OFFSET_CFI_ALT           0x555
 #define FLASH_OFFSET_CFI_RESP          0x10
@@ -1695,11 +1695,8 @@
                switch (info->vendor) {
                case CFI_CMDSET_INTEL_STANDARD:
                case CFI_CMDSET_INTEL_EXTENDED:
-                       cmdset_intel_init(info, &qry);
-                       break;
                case CFI_CMDSET_AMD_STANDARD:
                case CFI_CMDSET_AMD_EXTENDED:
-                       cmdset_amd_init(info, &qry);
                        break;
                default:
                        printf("CFI: Unknown command set 0x%x\n",
@@ -1811,6 +1808,17 @@
                }
        }

+       switch (info->vendor) {
+       case CFI_CMDSET_INTEL_STANDARD:
+       case CFI_CMDSET_INTEL_EXTENDED:
+               cmdset_intel_init(info, &qry);
+               break;
+       case CFI_CMDSET_AMD_STANDARD:
+       case CFI_CMDSET_AMD_EXTENDED:
+               cmdset_amd_init(info, &qry);
+               break;
+       }
+
        flash_write_cmd (info, 0, 0, info->cmd_reset);
        return (info->size);
 }

                 reply	other threads:[~2008-05-13 14:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1210689802.25113.12.camel@marel2693 \
    --to=kari.davidsson@marel.com \
    --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