incaip.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <netdev.h>
  10. #include <asm/addrspace.h>
  11. #include <asm/inca-ip.h>
  12. #include <asm/io.h>
  13. #include <asm/reboot.h>
  14. extern uint incaip_get_cpuclk(void);
  15. void _machine_restart(void)
  16. {
  17. *INCA_IP_WDT_RST_REQ = 0x3f;
  18. }
  19. static ulong max_sdram_size(void)
  20. {
  21. /* The only supported SDRAM data width is 16bit.
  22. */
  23. #define CONFIG_SYS_DW 2
  24. /* The only supported number of SDRAM banks is 4.
  25. */
  26. #define CONFIG_SYS_NB 4
  27. ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0;
  28. int cols = cfgpb0 & 0xF;
  29. int rows = (cfgpb0 & 0xF0) >> 4;
  30. ulong size = (1 << (rows + cols)) * CONFIG_SYS_DW * CONFIG_SYS_NB;
  31. return size;
  32. }
  33. phys_size_t initdram(int board_type)
  34. {
  35. int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  36. ulong size, max_size = 0;
  37. ulong our_address;
  38. asm volatile ("move %0, $25" : "=r" (our_address) :);
  39. /* Can't probe for RAM size unless we are running from Flash.
  40. */
  41. if (CPHYSADDR(our_address) < CPHYSADDR(PHYS_FLASH_1))
  42. {
  43. return max_sdram_size();
  44. }
  45. for (cols = 0x8; cols <= 0xC; cols++)
  46. {
  47. for (rows = 0xB; rows <= 0xD; rows++)
  48. {
  49. *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
  50. (rows << 4) | cols;
  51. size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
  52. max_sdram_size());
  53. if (size > max_size)
  54. {
  55. best_val = *INCA_IP_SDRAM_MC_CFGPB0;
  56. max_size = size;
  57. }
  58. }
  59. }
  60. *INCA_IP_SDRAM_MC_CFGPB0 = best_val;
  61. return max_size;
  62. }
  63. int checkboard (void)
  64. {
  65. unsigned long chipid = *INCA_IP_WDT_CHIPID;
  66. int part_num;
  67. puts ("Board: INCA-IP ");
  68. part_num = (chipid >> 12) & 0xffff;
  69. switch (part_num) {
  70. case 0xc0:
  71. printf ("Standard Version, ");
  72. break;
  73. case 0xc1:
  74. printf ("Basic Version, ");
  75. break;
  76. default:
  77. printf ("Unknown Part Number 0x%x ", part_num);
  78. break;
  79. }
  80. printf ("Chip V1.%ld, ", (chipid >> 28));
  81. printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);
  82. set_io_port_base(0);
  83. return 0;
  84. }
  85. #if defined(CONFIG_INCA_IP_SWITCH)
  86. int board_eth_init(bd_t *bis)
  87. {
  88. return inca_switch_initialize(bis);
  89. }
  90. #endif