incaip.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #include <asm/io.h>
  28. extern uint incaip_get_cpuclk(void);
  29. static ulong max_sdram_size(void)
  30. {
  31. /* The only supported SDRAM data width is 16bit.
  32. */
  33. #define CFG_DW 2
  34. /* The only supported number of SDRAM banks is 4.
  35. */
  36. #define CFG_NB 4
  37. ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0;
  38. int cols = cfgpb0 & 0xF;
  39. int rows = (cfgpb0 & 0xF0) >> 4;
  40. ulong size = (1 << (rows + cols)) * CFG_DW * CFG_NB;
  41. return size;
  42. }
  43. long int initdram(int board_type)
  44. {
  45. int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  46. ulong size, max_size = 0;
  47. ulong our_address;
  48. asm volatile ("move %0, $25" : "=r" (our_address) :);
  49. /* Can't probe for RAM size unless we are running from Flash.
  50. */
  51. if (PHYSADDR(our_address) < PHYSADDR(PHYS_FLASH_1))
  52. {
  53. return max_sdram_size();
  54. }
  55. for (cols = 0x8; cols <= 0xC; cols++)
  56. {
  57. for (rows = 0xB; rows <= 0xD; rows++)
  58. {
  59. *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
  60. (rows << 4) | cols;
  61. size = get_ram_size((long *)CFG_SDRAM_BASE,
  62. max_sdram_size());
  63. if (size > max_size)
  64. {
  65. best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  66. max_size = size;
  67. }
  68. }
  69. }
  70. *INCA_IP_SDRAM_MC_CFGPB0 = best_val;
  71. return max_size;
  72. }
  73. int checkboard (void)
  74. {
  75. unsigned long chipid = *INCA_IP_WDT_CHIPID;
  76. int part_num;
  77. puts ("Board: INCA-IP ");
  78. part_num = (chipid >> 12) & 0xffff;
  79. switch (part_num) {
  80. case 0xc0:
  81. printf ("Standard Version, ");
  82. break;
  83. case 0xc1:
  84. printf ("Basic Version, ");
  85. break;
  86. default:
  87. printf ("Unknown Part Number 0x%x ", part_num);
  88. break;
  89. }
  90. printf ("Chip V1.%ld, ", (chipid >> 28));
  91. printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);
  92. set_io_port_base(0);
  93. return 0;
  94. }