integrator.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2002
  4. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  5. * Marius Groeger <mgroeger@sysgo.de>
  6. *
  7. * (C) Copyright 2002
  8. * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
  9. *
  10. * (C) Copyright 2003
  11. * Texas Instruments, <www.ti.com>
  12. * Kshitij Gupta <Kshitij@ti.com>
  13. *
  14. * (C) Copyright 2004
  15. * ARM Ltd.
  16. * Philippe Robin, <philippe.robin@arm.com>
  17. */
  18. #include <common.h>
  19. #include <dm.h>
  20. #include <netdev.h>
  21. #include <asm/io.h>
  22. #include <dm/platform_data/serial_pl01x.h>
  23. #include "arm-ebi.h"
  24. #include "integrator-sc.h"
  25. #include <asm/mach-types.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. static const struct pl01x_serial_platdata serial_platdata = {
  28. .base = 0x16000000,
  29. #ifdef CONFIG_ARCH_CINTEGRATOR
  30. .type = TYPE_PL011,
  31. .clock = 14745600,
  32. #else
  33. .type = TYPE_PL010,
  34. .clock = 0, /* Not used for PL010 */
  35. #endif
  36. };
  37. U_BOOT_DEVICE(integrator_serials) = {
  38. .name = "serial_pl01x",
  39. .platdata = &serial_platdata,
  40. };
  41. void peripheral_power_enable (void);
  42. #if defined(CONFIG_SHOW_BOOT_PROGRESS)
  43. void show_boot_progress(int progress)
  44. {
  45. printf("Boot reached stage %d\n", progress);
  46. }
  47. #endif
  48. #define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF)
  49. /*
  50. * Miscellaneous platform dependent initialisations
  51. */
  52. int board_init (void)
  53. {
  54. u32 val;
  55. /* arch number of Integrator Board */
  56. #ifdef CONFIG_ARCH_CINTEGRATOR
  57. gd->bd->bi_arch_number = MACH_TYPE_CINTEGRATOR;
  58. #else
  59. gd->bd->bi_arch_number = MACH_TYPE_INTEGRATOR;
  60. #endif
  61. /* adress of boot parameters */
  62. gd->bd->bi_boot_params = 0x00000100;
  63. #ifdef CONFIG_CM_REMAP
  64. extern void cm_remap(void);
  65. cm_remap(); /* remaps writeable memory to 0x00000000 */
  66. #endif
  67. #ifdef CONFIG_ARCH_CINTEGRATOR
  68. /*
  69. * Flash protection on the Integrator/CP is in a simple register
  70. */
  71. val = readl(CP_FLASHPROG);
  72. val |= (CP_FLASHPROG_FLVPPEN | CP_FLASHPROG_FLWREN);
  73. writel(val, CP_FLASHPROG);
  74. #else
  75. /*
  76. * The Integrator/AP has some special protection mechanisms
  77. * for the external memories, first the External Bus Interface (EBI)
  78. * then the system controller (SC).
  79. *
  80. * The system comes up with the flash memory non-writable and
  81. * configuration locked. If we want U-Boot to be used for flash
  82. * access we cannot have the flash memory locked.
  83. */
  84. writel(EBI_UNLOCK_MAGIC, EBI_BASE + EBI_LOCK_REG);
  85. val = readl(EBI_BASE + EBI_CSR1_REG);
  86. val &= EBI_CSR_WREN_MASK;
  87. val |= EBI_CSR_WREN_ENABLE;
  88. writel(val, EBI_BASE + EBI_CSR1_REG);
  89. writel(0, EBI_BASE + EBI_LOCK_REG);
  90. /*
  91. * Set up the system controller to remove write protection from
  92. * the flash memory and enable Vpp
  93. */
  94. writel(SC_CTRL_FLASHVPP | SC_CTRL_FLASHWP, SC_CTRLS);
  95. #endif
  96. icache_enable ();
  97. return 0;
  98. }
  99. int misc_init_r (void)
  100. {
  101. env_set("verify", "n");
  102. return (0);
  103. }
  104. /*
  105. * The Integrator remaps the Flash memory to 0x00000000 and executes U-Boot
  106. * from there, which means we cannot test the RAM underneath the ROM at this
  107. * point. It will be unmapped later on, when we are executing from the
  108. * relocated in RAM U-Boot. We simply assume that this RAM is usable if the
  109. * RAM on higher addresses works fine.
  110. */
  111. #define REMAPPED_FLASH_SZ 0x40000
  112. int dram_init (void)
  113. {
  114. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  115. #ifdef CONFIG_CM_SPD_DETECT
  116. {
  117. extern void dram_query(void);
  118. u32 cm_reg_sdram;
  119. u32 sdram_shift;
  120. dram_query(); /* Assembler accesses to CM registers */
  121. /* Queries the SPD values */
  122. /* Obtain the SDRAM size from the CM SDRAM register */
  123. cm_reg_sdram = readl(CM_BASE + OS_SDRAM);
  124. /* Register SDRAM size
  125. *
  126. * 0xXXXXXXbbb000bb 16 MB
  127. * 0xXXXXXXbbb001bb 32 MB
  128. * 0xXXXXXXbbb010bb 64 MB
  129. * 0xXXXXXXbbb011bb 128 MB
  130. * 0xXXXXXXbbb100bb 256 MB
  131. *
  132. */
  133. sdram_shift = ((cm_reg_sdram & 0x0000001C)/4)%4;
  134. gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
  135. REMAPPED_FLASH_SZ,
  136. 0x01000000 << sdram_shift);
  137. }
  138. #else
  139. gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
  140. REMAPPED_FLASH_SZ,
  141. PHYS_SDRAM_1_SIZE);
  142. #endif /* CM_SPD_DETECT */
  143. /* We only have one bank of RAM, set it to whatever was detected */
  144. gd->bd->bi_dram[0].size = gd->ram_size;
  145. return 0;
  146. }
  147. #ifdef CONFIG_CMD_NET
  148. int board_eth_init(bd_t *bis)
  149. {
  150. int rc = 0;
  151. #ifdef CONFIG_SMC91111
  152. rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
  153. #endif
  154. rc += pci_eth_init(bis);
  155. return rc;
  156. }
  157. #endif