/* * (C) Copyright 2005 * Greg Ungerer, OpenGear Inc, greg.ungerer@opengear.com * * (C) Copyright 2001 * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net * * (C) Copyright 2001 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * SPDX-License-Identifier: GPL-2.0+ */ #include #include #include flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ #define mb() __asm__ __volatile__ ("" : : : "memory") /*----------------------------------------------------------------------- * Functions */ static ulong flash_get_size (unsigned char * addr, flash_info_t * info); static int write_data (flash_info_t * info, ulong dest, unsigned char data); static void flash_get_offsets (ulong base, flash_info_t * info); void inline spin_wheel (void); /*----------------------------------------------------------------------- */ unsigned long flash_init (void) { int i; ulong size = 0; for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) { switch (i) { case 0: flash_get_size ((unsigned char *) PHYS_FLASH_1, &flash_info[i]); flash_get_offsets (PHYS_FLASH_1, &flash_info[i]); break; case 1: /* ignore for now */ flash_info[i].flash_id = FLASH_UNKNOWN; break; default: panic ("configured too many flash banks!\n"); break; } size += flash_info[i].size; } /* Protect monitor and environment sectors */ flash_protect (FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE + (__bss_end - __bss_start), &flash_info[0]); return size; } /*----------------------------------------------------------------------- */ static void flash_get_offsets (ulong base, flash_info_t * info) { int i; if (info->flash_id == FLASH_UNKNOWN) return; if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) { for (i = 0; i < info->sector_count; i++) { info->start[i] = base + (i * PHYS_FLASH_SECT_SIZE); info->protect[i] = 0; } } } /*----------------------------------------------------------------------- */ void flash_print_info (flash_info_t * info) { int i; if (info->flash_id == FLASH_UNKNOWN) { printf ("missing or unknown FLASH type\n"); return; } switch (info->flash_id & FLASH_VENDMASK) { case FLASH_MAN_INTEL: printf ("INTEL "); break; default: printf ("Unknown Vendor "); break; } switch (info->flash_id & FLASH_TYPEMASK) { case FLASH_28F128J3A: printf ("28F128J3A\n"); break; default: printf ("Unknown Chip Type\n"); break; } 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"); return; } /* * The following co
#
# (C) Copyright 2000-2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# SPDX-License-Identifier:	GPL-2.0+
#

obj-y	= hermes.o flash.o