microblaze-generic.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * (C) Copyright 2007 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. /* This is a board specific file. It's OK to include board specific
  9. * header files */
  10. #include <common.h>
  11. #include <config.h>
  12. #include <fdtdec.h>
  13. #include <netdev.h>
  14. #include <asm/processor.h>
  15. #include <asm/microblaze_intc.h>
  16. #include <asm/asm.h>
  17. #include <asm/gpio.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. #ifdef CONFIG_XILINX_GPIO
  20. static int reset_pin = -1;
  21. #endif
  22. #if CONFIG_IS_ENABLED(OF_CONTROL)
  23. ulong ram_base;
  24. void dram_init_banksize(void)
  25. {
  26. gd->bd->bi_dram[0].start = ram_base;
  27. gd->bd->bi_dram[0].size = get_effective_memsize();
  28. }
  29. int dram_init(void)
  30. {
  31. int node;
  32. fdt_addr_t addr;
  33. fdt_size_t size;
  34. const void *blob = gd->fdt_blob;
  35. node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
  36. "memory", 7);
  37. if (node == -FDT_ERR_NOTFOUND) {
  38. debug("DRAM: Can't get memory node\n");
  39. return 1;
  40. }
  41. addr = fdtdec_get_addr_size(blob, node, "reg", &size);
  42. if (addr == FDT_ADDR_T_NONE || size == 0) {
  43. debug("DRAM: Can't get base address or size\n");
  44. return 1;
  45. }
  46. ram_base = addr;
  47. gd->ram_top = addr; /* In setup_dest_addr() is done +ram_size */
  48. gd->ram_size = size;
  49. return 0;
  50. };
  51. #else
  52. int dram_init(void)
  53. {
  54. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  55. return 0;
  56. }
  57. #endif
  58. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  59. {
  60. #ifndef CONFIG_SPL_BUILD
  61. #ifdef CONFIG_XILINX_GPIO
  62. if (reset_pin != -1)
  63. gpio_direction_output(reset_pin, 1);
  64. #endif
  65. #ifdef CONFIG_XILINX_TB_WATCHDOG
  66. hw_watchdog_disable();
  67. #endif
  68. #endif
  69. puts ("Reseting board\n");
  70. __asm__ __volatile__ (" mts rmsr, r0;" \
  71. "bra r0");
  72. return 0;
  73. }
  74. int gpio_init (void)
  75. {
  76. #ifdef CONFIG_XILINX_GPIO
  77. reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
  78. if (reset_pin != -1)
  79. gpio_request(reset_pin, "reset_pin");
  80. #endif
  81. return 0;
  82. }
  83. void board_init(void)
  84. {
  85. gpio_init();
  86. }
  87. int board_eth_init(bd_t *bis)
  88. {
  89. int ret = 0;
  90. #ifdef CONFIG_XILINX_AXIEMAC
  91. ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
  92. XILINX_AXIDMA_BASEADDR);
  93. #endif
  94. #if defined(CONFIG_XILINX_EMACLITE) && defined(XILINX_EMACLITE_BASEADDR)
  95. u32 txpp = 0;
  96. u32 rxpp = 0;
  97. # ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
  98. txpp = 1;
  99. # endif
  100. # ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
  101. rxpp = 1;
  102. # endif
  103. ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
  104. txpp, rxpp);
  105. #endif
  106. return ret;
  107. }