]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/mtd/cfi_flash.h
Merge git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / include / mtd / cfi_flash.h
index 2aa6911237bb197bfe1017f128f8e6be2aa95d4b..5198ecd404abb517cb13a03d2e8b017b6ab9764e 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2009
  * Stefan Roese, DENX Software Engineering, sr@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef __CFI_FLASH_H__
@@ -32,6 +15,8 @@
 #define FLASH_CMD_ERASE_CONFIRM                0xD0
 #define FLASH_CMD_WRITE                        0x40
 #define FLASH_CMD_PROTECT              0x60
+#define FLASH_CMD_SETUP                        0x60
+#define FLASH_CMD_SET_CR_CONFIRM       0x03
 #define FLASH_CMD_PROTECT_SET          0x01
 #define FLASH_CMD_PROTECT_CLEAR                0xD0
 #define FLASH_CMD_CLEAR_STATUS         0x50
 #define AMD_CMD_UNLOCK_ACK             0x55
 #define AMD_CMD_WRITE_TO_BUFFER                0x25
 #define AMD_CMD_WRITE_BUFFER_CONFIRM   0x29
+#define AMD_CMD_SET_PPB_ENTRY          0xC0
+#define AMD_CMD_SET_PPB_EXIT_BC1       0x90
+#define AMD_CMD_SET_PPB_EXIT_BC2       0x00
+#define AMD_CMD_PPB_UNLOCK_BC1         0x80
+#define AMD_CMD_PPB_UNLOCK_BC2         0x30
+#define AMD_CMD_PPB_LOCK_BC1           0xA0
+#define AMD_CMD_PPB_LOCK_BC2           0x00
 
 #define AMD_STATUS_TOGGLE              0x40
 #define AMD_STATUS_ERROR               0x20
@@ -120,12 +112,16 @@ typedef union {
 } cfiword_t;
 
 /* CFI standard query structure */
+/* The offsets and sizes of this packed structure members correspond
+ * to the actual layout in CFI Flash chips. Some 16- and 32-bit members
+ * are unaligned and must be accessed with explicit unaligned access macros.
+ */
 struct cfi_qry {
        u8      qry[3];
-       u16     p_id;
-       u16     p_adr;
-       u16     a_id;
-       u16     a_adr;
+       u16     p_id;                   /* unaligned */
+       u16     p_adr;                  /* unaligned */
+       u16     a_id;                   /* unaligned */
+       u16     a_adr;                  /* unaligned */
        u8      vcc_min;
        u8      vcc_max;
        u8      vpp_min;
@@ -139,10 +135,10 @@ struct cfi_qry {
        u8      block_erase_timeout_max;
        u8      chip_erase_timeout_max;
        u8      dev_size;
-       u16     interface_desc;
-       u16     max_buf_write_size;
+       u16     interface_desc;         /* aligned */
+       u16     max_buf_write_size;     /* aligned */
        u8      num_erase_regions;
-       u32     erase_region_info[NUM_ERASE_REGIONS];
+       u32     erase_region_info[NUM_ERASE_REGIONS];   /* unaligned */
 } __attribute__((packed));
 
 struct cfi_pri_hdr {
@@ -151,6 +147,24 @@ struct cfi_pri_hdr {
        u8      minor_version;
 } __attribute__((packed));
 
+#ifndef CONFIG_SYS_FLASH_BANKS_LIST
+#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE }
+#endif
+
+/*
+ * CFI_MAX_FLASH_BANKS only used for flash_info struct declaration.
+ *
+ * Use CONFIG_SYS_MAX_FLASH_BANKS_DETECT if defined
+ */
+#if defined(CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
+#define CONFIG_SYS_MAX_FLASH_BANKS     (cfi_flash_num_flash_banks)
+#define CFI_MAX_FLASH_BANKS    CONFIG_SYS_MAX_FLASH_BANKS_DETECT
+/* board code can update this variable before CFI detection */
+extern int cfi_flash_num_flash_banks;
+#else
+#define CFI_MAX_FLASH_BANKS    CONFIG_SYS_MAX_FLASH_BANKS
+#endif
+
 void flash_write_cmd(flash_info_t * info, flash_sect_t sect,
                     uint offset, u32 cmd);