incaip.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <asm/addrspace.h>
  26. #include <asm/inca-ip.h>
  27. extern uint incaip_get_cpuclk(void);
  28. static ulong max_sdram_size(void)
  29. {
  30. /* The only supported SDRAM data width is 16bit.
  31. */
  32. #define CFG_DW 2
  33. /* The only supported number of SDRAM banks is 4.
  34. */
  35. #define CFG_NB 4
  36. ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0;
  37. int cols = cfgpb0 & 0xF;
  38. int rows = (cfgpb0 & 0xF0) >> 4;
  39. ulong size = (1 << (rows + cols)) * CFG_DW * CFG_NB;
  40. return size;
  41. }
  42. long int initdram(int board_type)
  43. {
  44. int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  45. ulong size, max_size = 0;
  46. ulong our_address;
  47. asm volatile ("move %0, $25" : "=r" (our_address) :);
  48. /* Can't probe for RAM size unless we are running from Flash.
  49. */
  50. if (PHYSADDR(our_address) < PHYSADDR(PHYS_FLASH_1))
  51. {
  52. return max_sdram_size();
  53. }
  54. for (cols = 0x8; cols <= 0xC; cols++)
  55. {
  56. for (rows = 0xB; rows <= 0xD; rows++)
  57. {
  58. *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
  59. (rows << 4) | cols;
  60. size = get_ram_size((long *)CFG_SDRAM_BASE,
  61. max_sdram_size());
  62. if (size > max_size)
  63. {
  64. best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  65. max_size = size;
  66. }
  67. }
  68. }
  69. *INCA_IP_SDRAM_MC_CFGPB0 = best_val;
  70. return max_size;
  71. }
  72. int checkboard (void)
  73. {
  74. unsigned long chipid = *INCA_IP_WDT_CHIPID;
  75. int part_num;
  76. puts ("Board: INCA-IP ");
  77. part_num = (chipid >> 12) & 0xffff;
  78. switch (part_num) {
  79. case 0xc0:
  80. printf ("Standard Version, ");
  81. break;
  82. case 0xc1:
  83. printf ("Basic Version, ");
  84. break;
  85. default:
  86. printf ("Unknown Part Number 0x%x ", part_num);
  87. break;
  88. }
  89. printf ("Chip V1.%ld, ", (chipid >> 28));
  90. printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);
  91. return 0;
  92. }