incaip.c 2.7 KB

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