microblaze-generic.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <asm/processor.h>
  14. #include <asm/microblaze_intc.h>
  15. #include <asm/asm.h>
  16. #include <asm/gpio.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #ifdef CONFIG_XILINX_GPIO
  19. static int reset_pin = -1;
  20. #endif
  21. ulong ram_base;
  22. void dram_init_banksize(void)
  23. {
  24. gd->bd->bi_dram[0].start = ram_base;
  25. gd->bd->bi_dram[0].size = get_effective_memsize();
  26. }
  27. int dram_init(void)
  28. {
  29. int node;
  30. fdt_addr_t addr;
  31. fdt_size_t size;
  32. const void *blob = gd->fdt_blob;
  33. node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
  34. "memory", 7);
  35. if (node == -FDT_ERR_NOTFOUND) {
  36. debug("DRAM: Can't get memory node\n");
  37. return 1;
  38. }
  39. addr = fdtdec_get_addr_size(blob, node, "reg", &size);
  40. if (addr == FDT_ADDR_T_NONE || size == 0) {
  41. debug("DRAM: Can't get base address or size\n");
  42. return 1;
  43. }
  44. ram_base = addr;
  45. gd->ram_top = addr; /* In setup_dest_addr() is done +ram_size */
  46. gd->ram_size = size;
  47. return 0;
  48. };
  49. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  50. {
  51. #ifndef CONFIG_SPL_BUILD
  52. #ifdef CONFIG_XILINX_GPIO
  53. if (reset_pin != -1)
  54. gpio_direction_output(reset_pin, 1);
  55. #endif
  56. #ifdef CONFIG_XILINX_TB_WATCHDOG
  57. hw_watchdog_disable();
  58. #endif
  59. #endif
  60. puts ("Reseting board\n");
  61. __asm__ __volatile__ (" mts rmsr, r0;" \
  62. "bra r0");
  63. return 0;
  64. }
  65. static int gpio_init(void)
  66. {
  67. #ifdef CONFIG_XILINX_GPIO
  68. reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
  69. if (reset_pin != -1)
  70. gpio_request(reset_pin, "reset_pin");
  71. #endif
  72. return 0;
  73. }
  74. int board_late_init(void)
  75. {
  76. gpio_init();
  77. return 0;
  78. }