?? u-boot-1.1.4-imx21-jk1.patch
字號(hào):
diff -X linux/Documentation/dontdiff -Nur u-boot-1.1.4/board/fs3/config.mk u-boot-1.1.4.imx21/board/fs3/config.mk--- u-boot-1.1.4/board/fs3/config.mk 1970-01-01 01:00:00.000000000 +0100+++ u-boot-1.1.4.imx21/board/fs3/config.mk 2006-07-03 22:25:00.000000000 +0200@@ -0,0 +1,23 @@+#+# board/mx21ads/config.mk+#+# (C) Copyright 2006 Jochen Karrer+#+#+# 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++TEXT_BASE = 0xC0400000+diff -X linux/Documentation/dontdiff -Nur u-boot-1.1.4/board/fs3/flash.c u-boot-1.1.4.imx21/board/fs3/flash.c--- u-boot-1.1.4/board/fs3/flash.c 1970-01-01 01:00:00.000000000 +0100+++ u-boot-1.1.4.imx21/board/fs3/flash.c 2006-07-11 15:11:34.000000000 +0200@@ -0,0 +1,596 @@+/*+ * (C) 2000-2004 Wolfgang Denk, DENX Software Engineering, wd@denx.de.+ * (C) 2003 August Hoeraendl, Logotronic GmbH+ *+ * 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+ */++#undef CONFIG_FLASH_16BIT++#include <common.h>++//define FLASH_BANK_SIZE MX21FS3_FLASH_BANK_SIZE+#define MAIN_SECT_SIZE MX21FS3_FLASH_SECT_SIZE++flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */++/*+ * NOTE - CONFIG_FLASH_16BIT means the CPU interface is 16-bit, it+ * has nothing to do with the flash chip being 8-bit or 16-bit.+ */+#ifdef CONFIG_FLASH_16BIT+typedef unsigned short FLASH_PORT_WIDTH;+typedef volatile unsigned short FLASH_PORT_WIDTHV;++#define FLASH_ID_MASK 0xFFFF+#else+typedef unsigned long FLASH_PORT_WIDTH;+typedef volatile unsigned long FLASH_PORT_WIDTHV;++#define FLASH_ID_MASK 0xFFFFFFFF+#endif++#define FPW FLASH_PORT_WIDTH+#define FPWV FLASH_PORT_WIDTHV++#define ORMASK(size) ((-size) & OR_AM_MSK)++/*-----------------------------------------------------------------------+ * Functions+ */+#if 0+static ulong flash_get_size(FPWV * addr, flash_info_t * info);+static void flash_get_offsets(ulong base, flash_info_t * info);+#endif++static void flash_reset(flash_info_t * info);+static int write_word_amd(flash_info_t * info, FPWV * dest, FPW data);+#define write_word(in, de, da) write_word_amd(in, de, da)+#ifdef CFG_FLASH_PROTECTION+static void flash_sync_real_protect(flash_info_t * info);+#endif++/*-----------------------------------------------------------------------+ * flash_init()+ *+ * sets up flash_info and returns size of FLASH (bytes)+ */++static ulong +flash_get_size (FPWV *addr, flash_info_t * info)+{+ FPW vendor_id,device_id;+ int i;+ int nr_regions;+ ulong flashbase = (ulong)addr;+ ulong offset;+ int dir = 1;++ /* Write auto select command: read Manufacturer ID */+ addr[0x0555] = (FPW)0x00AA00AA;+ addr[0x02AA] = (FPW)0x00550055;+ addr[0x0555] = (FPW)0x00900090;++ vendor_id = addr[0];+ device_id = addr[1];+ if(vendor_id == (FPW)AMD_MANUFACT) {+ info->flash_id = FLASH_MAN_AMD; + }++ switch (device_id) {+ case (FPW) (AMD_ID_LV160T): + info->flash_id += FLASH_AM160LV;+ dir = -1;+ break;++ case (FPW) (AMD_ID_LV160B):+ info->flash_id += FLASH_AM160LV;+ dir=1;+ break;+ }+ info->size = 0;+ info->sector_count = 0;+ addr[0] = (FPW) 0x00FF00FF; /* restore read mode */+ addr[0x055] = (FPW)0x00980098;+ nr_regions = addr[0x2c] & 0xff;+ if(nr_regions > 4) {+ printf("Illegal number of erase regions (%d)\n",nr_regions);+ nr_regions = 4;+ }+ for(i = 0,offset = 0;i<4;i++) {+ int j;+ int idx; + uint16_t nsects;+ uint32_t sectsize;++ if(dir==1) {+ idx = i<<2;+ } else {+ idx = (3-i)<<2;+ }+ nsects = (addr[0x2d + idx] & 0xff) + 256 * (addr[0x2e + idx] & 0xff) + 1; + sectsize = (addr[0x2f + idx] & 0xff) + 256 *(addr[0x30 + idx] & 0xff);+ sectsize *= 256;+ if(!sectsize) {+ continue;+ }+ if(sizeof(FPW) == 4) {+ sectsize <<= 1;+ }+ for (j = 0; j < nsects; j++) {+ info->start[info->sector_count] = flashbase + info->size;+ info->size+=sectsize;+ info->sector_count++;+ }+ }+ addr[0] = (FPW) 0x00FF00FF; /* restore read mode */+}++ulong+flash_init(void)+{+ int i;+ ulong size = 0;++ for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {+ ulong flashbase = 0;+ flash_info[i].size = 0;+ flash_info[i].sector_count = 0;+ memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);+ switch (i) {+ case 0:+ flashbase = MX21FS3_FLASH_BASE;+ break;+ default:+ panic("configured too many flash banks!\n");+ break;+ }+ flash_get_size((FPW*)flashbase,&flash_info[i]);+ }++ /* Protect monitor and environment sectors */+ flash_protect(FLAG_PROTECT_SET,+ CFG_FLASH_BASE,+ CFG_FLASH_BASE + _bss_start - _armboot_start,+ &flash_info[0]);++ flash_protect(FLAG_PROTECT_SET,+ CFG_ENV_ADDR,+ CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);++ return size;+}++/*-----------------------------------------------------------------------+ */+static void+flash_reset(flash_info_t * info)+{+ FPWV *base = (FPWV *) (info->start[0]);++ /* Put FLASH back in read mode */+ if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL)+ *base = (FPW) 0x00FF00FF; /* Intel Read Mode */+ else if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_AMD)+ *base = (FPW) 0x00F000F0; /* AMD Read Mode */+}++/*-----------------------------------------------------------------------+ */++void+flash_print_info(flash_info_t * info)+{+ int i;+ uchar *boottype;+ uchar *bootletter;+ uchar *fmt;+ uchar botbootletter[] = "B";+ uchar topbootletter[] = "T";+ uchar botboottype[] = "bottom boot sector";+ uchar topboottype[] = "top boot sector";++ if (info->flash_id == FLASH_UNKNOWN) {+ printf("missing or unknown FLASH type\n");+ return;+ }++ switch (info->flash_id & FLASH_VENDMASK) {+ case FLASH_MAN_AMD:+ printf("AMD ");+ break;+ case FLASH_MAN_BM:+ printf("BRIGHT MICRO ");+ break;+ case FLASH_MAN_FUJ:+ printf("FUJITSU ");+ break;+ case FLASH_MAN_SST:+ printf("SST ");+ break;+ case FLASH_MAN_STM:+ printf("STM ");+ break;+ case FLASH_MAN_INTEL:+ printf("INTEL ");+ break;+ default:+ printf("Unknown Vendor ");+ break;+ }++ /* check for top or bottom boot, if it applies */+ if (info->flash_id & FLASH_BTYPE) {+ boottype = botboottype;+ bootletter = botbootletter;+ } else {+ boottype = topboottype;+ bootletter = topbootletter;+ }++ switch (info->flash_id & FLASH_TYPEMASK) {+ case FLASH_AM640U:+ fmt = "29LV641D (64 Mbit, uniform sectors)\n";+ break;++ case FLASH_AM160LV:+ fmt = "29LV160D%s (16 Mbit non uniform sectors)\n";+ break;++ default:+ fmt = "Unknown Chip Type\n";+ printf(" Unknown type %04x\n",info->flash_id);+ break;+ }++ printf(fmt, bootletter, boottype);++ printf(" Size: %ld MB in %d Sectors\n",+ info->size >> 20, info->sector_count);++ printf(" Sector Start Addresses:");++ for (i = 0; i < info->sector_count; ++i) {+ if ((i % 5) == 0) {+ printf("\n ");+ }++ printf(" %08lX%s", info->start[i],+ info->protect[i] ? " (RO)" : " ");+ }++ printf("\n");+}++/*-----------------------------------------------------------------------+ */+++//#ifdef CFG_FLASH_PROTECTION++/*-----------------------------------------------------------------------+ */++int+flash_erase(flash_info_t * info, int s_first, int s_last)+{+ FPWV *addr;+ int flag, prot, sect;+ int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL;+ ulong start, now, last;+ int rcode = 0;++ if ((s_first < 0) || (s_first > s_last)) {+ if (info->flash_id == FLASH_UNKNOWN) {+ printf("- missing\n");+ } else {+ printf("- no sectors to erase\n");+ }+ return 1;+ }++ switch (info->flash_id & FLASH_TYPEMASK) {+ case FLASH_AM640U:+ break;+ break;+ case FLASH_UNKNOWN:+ default:+ printf("Can't erase unknown flash type %08lx - aborted\n",+ info->flash_id);+ return 1;+ }++ prot = 0;+ for (sect = s_first; sect <= s_last; ++sect) {+ if (info->protect[sect]) {+ prot++;+ }+ }++ if (prot) {+ printf("- Warning: %d protected sectors will not be erased!\n",+ prot);+ } else {+ printf("\n");+ }++ start = get_timer(0);+ last = start;++ /* Start erase on unprotected sectors */+ for (sect = s_first; sect <= s_last && rcode == 0; sect++) {++ if (info->protect[sect] != 0) /* protected, skip it */+ continue;++ /* Disable interrupts which might cause a timeout here */+ flag = disable_interrupts();++ addr = (FPWV *) (info->start[sect]);+ if (intel) {+ *addr = (FPW) 0x00500050; /* clear status register */+ *addr = (FPW) 0x00200020; /* erase setup */+ *addr = (FPW) 0x00D000D0; /* erase confirm */+ } else {+ /* must be AMD style if not Intel */+ FPWV *base; /* first address in bank */++ base = (FPWV *) (info->start[0]);+ base[0x0555] = (FPW) 0x00AA00AA; /* unlock */+ base[0x02AA] = (FPW) 0x00550055; /* unlock */+ base[0x0555] = (FPW) 0x00AA00AA; /* unlock */+ base[0x02AA] = (FPW) 0x00550055; /* unlock */+ *addr = (FPW) 0x00300030; /* erase sector */+ }++ /* re-enable interrupts if necessary */+ if (flag)+ enable_interrupts();++ /* wait at least 50us for AMD, 80us for Intel.+ * Let's wait 1 ms.+ */+ udelay(1000);++ while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) {+ if ((now = get_timer(0)) - start > CFG_FLASH_ERASE_TOUT) {+ printf("Timeout\n");++ if (intel) {+ /* suspend erase */+ *addr = (FPW) 0x00B000B0;+ }++ flash_reset(info); /* reset to read mode */+ rcode = 1; /* failed */+ break;+ }++ /* show that we're waiting */+ if ((now - last) > 1000) { /* every second */+ putc('.');+ last = now;+ }+ }++ flash_reset(info); /* reset to read mode */+ }++ printf(" done\n");+ return rcode;+}++/*-----------------------------------------------------------------------+ * Copy memory to flash, returns:+ * 0 - OK+ * 1 - write timeout+ * 2 - Flash not erased+ */+int+bad_write_buff(flash_info_t * info, uchar * src, ulong addr, ulong cnt)+{+ FPW data = 0; /* 16 or 32 bit word, matches flash bus width on MPC8XX */+ int bytes; /* number of bytes to program in current word */+ int left; /* number of bytes left to program */+ int i, res;++ for (left = cnt, res = 0;+ left > 0 && res == 0;+ addr += sizeof (data), left -= sizeof (data) - bytes) {++ bytes = addr & (sizeof (data) - 1);+ addr &= ~(sizeof (data) - 1);++ /* combine source and destination data so can program+ * an entire word of 16 or 32 bits+ */+ for (i = 0; i < sizeof (data); i++) {+ data <<= 8;+ if (i < bytes || i - bytes >= left)+ data += *((uchar *) addr + i);+ else+ data += *src++;+ }++ /* write one word to the flash */+ switch (info->flash_id & FLASH_VENDMASK) {+ case FLASH_MAN_AMD:+ res = write_word_amd(info, (FPWV *) addr, data);+ break;+ default:+ /* unknown flash type, error! */+ printf("missing or unknown FLASH type\n");+ res = 1; /* not really a timeout, but gives error */+ break;+ }+ }++ return (res);+}++/**+ * write_buf: - Copy memory to flash.+ *
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -