1/* ********************************************************************* 2 * Broadcom Common Firmware Environment (CFE) 3 * 4 * Flash memory definitions File: dev_flash.h 5 * 6 * Stuff we use when manipulating flash memory devices. 7 * 8 * Author: Mitch Lichtenberg 9 * 10 ********************************************************************* 11 * 12 * Copyright 2000,2001,2002,2003 13 * Broadcom Corporation. All rights reserved. 14 * 15 * This software is furnished under license and may be used and 16 * copied only in accordance with the following terms and 17 * conditions. Subject to these conditions, you may download, 18 * copy, install, use, modify and distribute modified or unmodified 19 * copies of this software in source and/or binary form. No title 20 * or ownership is transferred hereby. 21 * 22 * 1) Any source code used, modified or distributed must reproduce 23 * and retain this copyright notice and list of conditions 24 * as they appear in the source file. 25 * 26 * 2) No right is granted to use any trade name, trademark, or 27 * logo of Broadcom Corporation. The "Broadcom Corporation" 28 * name may not be used to endorse or promote products derived 29 * from this software without the prior written permission of 30 * Broadcom Corporation. 31 * 32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 44 * THE POSSIBILITY OF SUCH DAMAGE. 45 ********************************************************************* */ 46 47/* Bits for compile-time removal of features */ 48#define FLASH_DRIVER_INTEL 1 /* support Intel cmd sets */ 49#define FLASH_DRIVER_AMD 2 /* support AMD cmd sets */ 50#define FLASH_DRIVER_CFI 4 /* support auto probing */ 51 52/* Default value unless overridden in bsp_config.h */ 53#ifndef FLASH_DRIVERS 54#define FLASH_DRIVERS (FLASH_DRIVER_INTEL | FLASH_DRIVER_AMD | FLASH_DRIVER_CFI) 55#endif 56 57 58/* 59 * AMD Flash commands and magic offsets 60 */ 61 62#define AMD_FLASH_MAGIC_ADDR_1 0x555 /* AAA for 16-bit devices in 8-bit mode */ 63#define AMD_FLASH_MAGIC_ADDR_2 0x2AA /* 554 for 16-bit devices in 8-bit mode */ 64 65#define AMD_FLASH_RESET 0xF0 66#define AMD_FLASH_MAGIC_1 0xAA 67#define AMD_FLASH_MAGIC_2 0x55 68#define AMD_FLASH_AUTOSEL 0x90 69#define AMD_FLASH_PROGRAM 0xA0 70#define AMD_FLASH_UNLOCK_BYPASS 0x20 71#define AMD_FLASH_ERASE_3 0x80 72#define AMD_FLASH_ERASE_4 0xAA 73#define AMD_FLASH_ERASE_5 0x55 74#define AMD_FLASH_ERASE_ALL_6 0x10 75#define AMD_FLASH_ERASE_SEC_6 0x30 76 77/* 78 * INTEL Flash commands and magic offsets 79 */ 80 81#define INTEL_FLASH_8BIT 0 82#define INTEL_FLASH_16BIT 1 83 84#define INTEL_FLASH_READ_MODE 0xFF 85#define INTEL_FLASH_ERASE_BLOCK 0x20 86#define INTEL_FLASH_ERASE_CONFIRM 0xD0 87#define INTEL_FLASH_PROGRAM 0x40 88#define INTEL_FLASH_READ_STATUS 0x70 89#define INTEL_FLASH_WRITE_BUFFER 0xE8 90 91/* INTEL Flash commands for 16-bit mode */ 92#define INTEL_FLASH_16BIT_READ_MODE 0xFF00 93#define INTEL_FLASH_16BIT_ERASE_BLOCK 0x2000 94#define INTEL_FLASH_16BIT_ERASE_CONFIRM 0xD000 95#define INTEL_FLASH_16BIT_PROGRAM 0x4000 96#define INTEL_FLASH_16BIT_READ_STATUS 0x7000 97#define INTEL_FLASH_16BIT_WRITE_BUFFER 0xE800 98 99 100/* 101 * Common Flash Interface (CFI) commands and offsets 102 */ 103 104#define FLASH_CFI_QUERY_ADDR 0x55 105#define FLASH_CFI_QUERY_MODE 0x98 106#define FLASH_CFI_QUERY_EXIT 0xFF 107 108#define FLASH_CFI_MANUFACTURER 0x00 109#define FLASH_CFI_DEVICE 0x01 110#define FLASH_CFI_SIGNATURE 0x10 111#define FLASH_CFI_QUERY_STRING 0x10 112#define FLASH_CFI_COMMAND_SET 0x13 113#define FLASH_CFI_DEVICE_SIZE 0x27 114#define FLASH_CFI_DEVICE_INTERFACE 0x28 115#define FLASH_CFI_REGION_COUNT 0x2C 116#define FLASH_CFI_REGION_TABLE 0x2D 117 118#define FLASH_CFI_CMDSET_INTEL_ECS 0x0001 /* Intel extended */ 119#define FLASH_CFI_CMDSET_AMD_STD 0x0002 /* AMD Standard */ 120#define FLASH_CFI_CMDSET_INTEL_STD 0x0003 /* Intel Standard */ 121#define FLASH_CFI_CMDSET_AMD_ECS 0x0004 /* AMD Extended */ 122 123#define FLASH_CFI_DEVIF_X8 0x0000 /* 8-bit asynchronous */ 124#define FLASH_CFI_DEVIF_X16 0x0001 /* 16-bit asynchronous */ 125#define FLASH_CFI_DEVIF_X8X16 0x0002 /* 8 or 16-bit with BYTE# pin */ 126#define FLASH_CFI_DEVIF_X32 0x0003 /* 32-bit asynchronous */ 127 128/* 129 * JEDEC offsets 130 */ 131 132#define FLASH_JEDEC_OFFSET_MFR 0 133#define FLASH_JEDEC_OFFSET_DEV 1 134 135/* Vendor-specific flash identifiers */ 136 137#define FLASH_MFR_HYUNDAI 0xAD 138 139/* ********************************************************************* 140 * Macros for defining custom sector tables 141 ********************************************************************* */ 142 143#define FLASH_SECTOR_RANGE(nblks,size) (((nblks)-1) << 16) + ((size)/256) 144#define FLASH_SECTOR_NBLKS(x) (((x) >> 16)+1) 145#define FLASH_SECTOR_SIZE(x) (((x) & 0xFFFF)*256) 146#define FLASH_MAXSECTORS 8 147 148 149/* ********************************************************************* 150 * Structures 151 ********************************************************************* */ 152 153/* 154 * This structure is passed in the "probe_ptr" field of the 155 * flash's probe routines and can be used for advanced 156 * configuration. If you pass this structure, probe_a and 157 * probe_b will be ignored by the driver 158 * 159 * flash_prog_phys is the base address you use for flash commands - 160 * you can put 0 here if it's the same as flash_phys. some boards, 161 * like the Algor P5064, have a different PA region used for doing 162 * byte accesses to the flash. In this case the special 163 * "flash_prog_phys" field is used for that. 164 */ 165 166 167#define FLASH_FLG_NVRAM 0x00000001 /* Reserve space for NVRAM */ 168#define FLASH_FLG_AUTOSIZE 0x00000002 /* resize to actual device size */ 169#define FLASH_FLG_16BIT 0x00000004 /* it's a 16-bit ROM in 16-bit mode */ 170#define FLASH_FLG_MANUAL 0x00000008 /* Not CFI, manual sectoring */ 171#define FLASH_FLG_WIDE 0x00000010 /* must shift control addresses left one bit */ 172 173#ifndef __ASSEMBLER__ 174typedef struct flash_probe_t { 175 long flash_phys; 176 long flash_prog_phys; /* base address for programming, if different */ 177 int flash_size; /* total flash size */ 178 int flash_flags; 179 /* The following are used when manually sectoring */ 180 int flash_cmdset; 181 int flash_nsectors; /* number of ranges */ 182 int flash_sectors[FLASH_MAXSECTORS]; 183} flash_probe_t; 184#endif 185