smdkv310.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011 Samsung Electronics
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <log.h>
  8. #include <net.h>
  9. #include <asm/gpio.h>
  10. #include <asm/io.h>
  11. #include <netdev.h>
  12. #include <asm/arch/cpu.h>
  13. #include <asm/arch/mmc.h>
  14. #include <asm/arch/periph.h>
  15. #include <asm/arch/pinmux.h>
  16. #include <asm/arch/sromc.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. static void smc9115_pre_init(void)
  19. {
  20. u32 smc_bw_conf, smc_bc_conf;
  21. /* gpio configuration GPK0CON */
  22. gpio_cfg_pin(EXYNOS4_GPIO_Y00 + CONFIG_ENV_SROM_BANK, S5P_GPIO_FUNC(2));
  23. /* Ethernet needs bus width of 16 bits */
  24. smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
  25. smc_bc_conf = SROMC_BC_TACS(0x0F) | SROMC_BC_TCOS(0x0F)
  26. | SROMC_BC_TACC(0x0F) | SROMC_BC_TCOH(0x0F)
  27. | SROMC_BC_TAH(0x0F) | SROMC_BC_TACP(0x0F)
  28. | SROMC_BC_PMC(0x0F);
  29. /* Select and configure the SROMC bank */
  30. s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
  31. }
  32. int board_init(void)
  33. {
  34. smc9115_pre_init();
  35. gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
  36. return 0;
  37. }
  38. int dram_init(void)
  39. {
  40. gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
  41. + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
  42. + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
  43. + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
  44. return 0;
  45. }
  46. int dram_init_banksize(void)
  47. {
  48. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  49. gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
  50. PHYS_SDRAM_1_SIZE);
  51. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  52. gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
  53. PHYS_SDRAM_2_SIZE);
  54. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  55. gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
  56. PHYS_SDRAM_3_SIZE);
  57. gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
  58. gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
  59. PHYS_SDRAM_4_SIZE);
  60. return 0;
  61. }
  62. int board_eth_init(struct bd_info *bis)
  63. {
  64. int rc = 0;
  65. #ifdef CONFIG_SMC911X
  66. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  67. #endif
  68. return rc;
  69. }
  70. #ifdef CONFIG_DISPLAY_BOARDINFO
  71. int checkboard(void)
  72. {
  73. printf("\nBoard: SMDKV310\n");
  74. return 0;
  75. }
  76. #endif
  77. #ifdef CONFIG_MMC
  78. int board_mmc_init(struct bd_info *bis)
  79. {
  80. int i, err;
  81. /*
  82. * MMC2 SD card GPIO:
  83. *
  84. * GPK2[0] SD_2_CLK(2)
  85. * GPK2[1] SD_2_CMD(2)
  86. * GPK2[2] SD_2_CDn
  87. * GPK2[3:6] SD_2_DATA[0:3](2)
  88. */
  89. for (i = EXYNOS4_GPIO_K20; i < EXYNOS4_GPIO_K27; i++) {
  90. /* GPK2[0:6] special function 2 */
  91. gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
  92. /* GPK2[0:6] drv 4x */
  93. gpio_set_drv(i, S5P_GPIO_DRV_4X);
  94. /* GPK2[0:1] pull disable */
  95. if (i == EXYNOS4_GPIO_K20 || i == EXYNOS4_GPIO_K21) {
  96. gpio_set_pull(i, S5P_GPIO_PULL_NONE);
  97. continue;
  98. }
  99. /* GPK2[2:6] pull up */
  100. gpio_set_pull(i, S5P_GPIO_PULL_UP);
  101. }
  102. err = s5p_mmc_init(2, 4);
  103. return err;
  104. }
  105. #endif
  106. static int board_uart_init(void)
  107. {
  108. int err;
  109. err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
  110. if (err) {
  111. debug("UART0 not configured\n");
  112. return err;
  113. }
  114. err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
  115. if (err) {
  116. debug("UART1 not configured\n");
  117. return err;
  118. }
  119. err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
  120. if (err) {
  121. debug("UART2 not configured\n");
  122. return err;
  123. }
  124. err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
  125. if (err) {
  126. debug("UART3 not configured\n");
  127. return err;
  128. }
  129. return 0;
  130. }
  131. #ifdef CONFIG_BOARD_EARLY_INIT_F
  132. int board_early_init_f(void)
  133. {
  134. int err;
  135. err = board_uart_init();
  136. if (err) {
  137. debug("UART init failed\n");
  138. return err;
  139. }
  140. return err;
  141. }
  142. #endif