flash.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * (C) Copyright 2001
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/ppc4xx.h>
  9. #include <asm/processor.h>
  10. /*
  11. * include common flash code (for esd boards)
  12. */
  13. #include "../common/flash.c"
  14. /*-----------------------------------------------------------------------
  15. * Functions
  16. */
  17. static ulong flash_get_size (vu_long *addr, flash_info_t *info);
  18. static void flash_get_offsets (ulong base, flash_info_t *info);
  19. /*-----------------------------------------------------------------------
  20. */
  21. unsigned long flash_init (void)
  22. {
  23. unsigned long size_b0;
  24. int i;
  25. uint pbcr;
  26. unsigned long base_b0;
  27. /* Init: no FLASHes known */
  28. for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
  29. flash_info[i].flash_id = FLASH_UNKNOWN;
  30. }
  31. /* Static FLASH Bank configuration here - FIXME XXX */
  32. size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
  33. if (flash_info[0].flash_id == FLASH_UNKNOWN) {
  34. printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
  35. size_b0, size_b0<<20);
  36. }
  37. /* Setup offsets */
  38. flash_get_offsets (-size_b0, &flash_info[0]);
  39. /* Re-do sizing to get full correct info */
  40. mtdcr(EBC0_CFGADDR, PB0CR);
  41. pbcr = mfdcr(EBC0_CFGDATA);
  42. mtdcr(EBC0_CFGADDR, PB0CR);
  43. base_b0 = -size_b0;
  44. pbcr = (pbcr & 0x0001ffff) | base_b0 | (((size_b0/1024/1024)-1)<<17);
  45. mtdcr(EBC0_CFGDATA, pbcr);
  46. /* printf("PB1CR = %x\n", pbcr); */
  47. /* Monitor protection ON by default */
  48. (void)flash_protect(FLAG_PROTECT_SET,
  49. -monitor_flash_len,
  50. 0xffffffff,
  51. &flash_info[0]);
  52. flash_info[0].size = size_b0;
  53. return (size_b0);
  54. }