flash.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2004, Li-Pro.Net <www.li-pro.net>
  6. * Stephan Linz <linz@li-pro.net>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <nios.h>
  28. /*
  29. * include common flash code (for ssv boards)
  30. */
  31. #include "../common/flash.c"
  32. /*---------------------------------------------------------------------*/
  33. #define BANKSZ (8 * 1024 * 1024)
  34. #define SECTSZ (64 * 1024)
  35. #define UBOOTSECS ((CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE) / SECTSZ)
  36. #define UBOOTAREA (UBOOTSECS * 64 * 1024) /* monitor / env area */
  37. /*---------------------------------------------------------------------*/
  38. unsigned long flash_init (void)
  39. {
  40. int i;
  41. unsigned long addr;
  42. flash_info_t *fli = &flash_info[0];
  43. fli->size = BANKSZ;
  44. fli->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
  45. fli->flash_id = FLASH_MAN_AMD + FLASH_AMLV640U;
  46. addr = CONFIG_SYS_FLASH_BASE;
  47. for (i = 0; i < fli->sector_count; ++i) {
  48. fli->start[i] = addr;
  49. addr += SECTSZ;
  50. /* Protect monitor / environment area */
  51. if (addr <= (CONFIG_SYS_FLASH_BASE + UBOOTAREA))
  52. fli->protect[i] = 1;
  53. else
  54. fli->protect[i] = 0;
  55. }
  56. return (BANKSZ);
  57. }