t208xrdb.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2009-2013 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <env.h>
  8. #include <fdt_support.h>
  9. #include <i2c.h>
  10. #include <init.h>
  11. #include <netdev.h>
  12. #include <linux/compiler.h>
  13. #include <asm/mmu.h>
  14. #include <asm/processor.h>
  15. #include <asm/immap_85xx.h>
  16. #include <asm/fsl_law.h>
  17. #include <asm/fsl_serdes.h>
  18. #include <asm/fsl_liodn.h>
  19. #include <fm_eth.h>
  20. #include "t208xrdb.h"
  21. #include "cpld.h"
  22. #include "../common/vid.h"
  23. DECLARE_GLOBAL_DATA_PTR;
  24. int checkboard(void)
  25. {
  26. struct cpu_type *cpu = gd->arch.cpu;
  27. static const char *freq[3] = {"100.00MHZ", "125.00MHz", "156.25MHZ"};
  28. printf("Board: %sRDB, ", cpu->name);
  29. printf("Board rev: 0x%02x CPLD ver: 0x%02x, boot from ",
  30. CPLD_READ(hw_ver), CPLD_READ(sw_ver));
  31. #ifdef CONFIG_SDCARD
  32. puts("SD/MMC\n");
  33. #elif CONFIG_SPIFLASH
  34. puts("SPI\n");
  35. #else
  36. u8 reg;
  37. reg = CPLD_READ(flash_csr);
  38. if (reg & CPLD_BOOT_SEL) {
  39. puts("NAND\n");
  40. } else {
  41. reg = ((reg & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
  42. printf("NOR vBank%d\n", reg);
  43. }
  44. #endif
  45. puts("SERDES Reference Clocks:\n");
  46. printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[2], freq[0]);
  47. printf("SD2_CLK1=%s, SD2_CLK2=%s\n", freq[0], freq[0]);
  48. return 0;
  49. }
  50. int board_early_init_r(void)
  51. {
  52. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  53. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  54. /*
  55. * Remap Boot flash + PROMJET region to caching-inhibited
  56. * so that flash can be erased properly.
  57. */
  58. /* Flush d-cache and invalidate i-cache of any FLASH data */
  59. flush_dcache();
  60. invalidate_icache();
  61. if (flash_esel == -1) {
  62. /* very unlikely unless something is messed up */
  63. puts("Error: Could not find TLB for FLASH BASE\n");
  64. flash_esel = 2; /* give our best effort to continue */
  65. } else {
  66. /* invalidate existing TLB entry for flash + promjet */
  67. disable_tlb(flash_esel);
  68. }
  69. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  70. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  71. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  72. /*
  73. * Adjust core voltage according to voltage ID
  74. * This function changes I2C mux to channel 2.
  75. */
  76. if (adjust_vdd(0))
  77. printf("Warning: Adjusting core voltage failed.\n");
  78. return 0;
  79. }
  80. unsigned long get_board_sys_clk(void)
  81. {
  82. return CONFIG_SYS_CLK_FREQ;
  83. }
  84. unsigned long get_board_ddr_clk(void)
  85. {
  86. return CONFIG_DDR_CLK_FREQ;
  87. }
  88. int misc_init_r(void)
  89. {
  90. u8 reg;
  91. /* Reset CS4315 PHY */
  92. reg = CPLD_READ(reset_ctl);
  93. reg |= CPLD_RSTCON_EDC_RST;
  94. CPLD_WRITE(reset_ctl, reg);
  95. return 0;
  96. }
  97. int ft_board_setup(void *blob, bd_t *bd)
  98. {
  99. phys_addr_t base;
  100. phys_size_t size;
  101. ft_cpu_setup(blob, bd);
  102. base = env_get_bootm_low();
  103. size = env_get_bootm_size();
  104. fdt_fixup_memory(blob, (u64)base, (u64)size);
  105. #ifdef CONFIG_PCI
  106. pci_of_setup(blob, bd);
  107. #endif
  108. fdt_fixup_liodn(blob);
  109. fsl_fdt_fixup_dr_usb(blob, bd);
  110. #ifdef CONFIG_SYS_DPAA_FMAN
  111. fdt_fixup_fman_ethernet(blob);
  112. fdt_fixup_board_enet(blob);
  113. #endif
  114. return 0;
  115. }