smdk5250.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/io.h>
  24. #include <i2c.h>
  25. #include <netdev.h>
  26. #include <asm/arch/cpu.h>
  27. #include <asm/arch/gpio.h>
  28. #include <asm/arch/mmc.h>
  29. #include <asm/arch/pinmux.h>
  30. #include <asm/arch/sromc.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. #ifdef CONFIG_SMC911X
  33. static int smc9115_pre_init(void)
  34. {
  35. u32 smc_bw_conf, smc_bc_conf;
  36. int err;
  37. /* Ethernet needs data bus width of 16 bits */
  38. smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK)
  39. | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK);
  40. smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01)
  41. | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01)
  42. | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09)
  43. | SROMC_BC_PMC(0x01);
  44. /* Select and configure the SROMC bank */
  45. err = exynos_pinmux_config(PERIPH_ID_SROMC,
  46. CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT);
  47. if (err) {
  48. debug("SROMC not configured\n");
  49. return err;
  50. }
  51. s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
  52. return 0;
  53. }
  54. #endif
  55. int board_init(void)
  56. {
  57. gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
  58. return 0;
  59. }
  60. int dram_init(void)
  61. {
  62. gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
  63. + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
  64. + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
  65. + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE)
  66. + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE)
  67. + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE)
  68. + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE)
  69. + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE);
  70. return 0;
  71. }
  72. void dram_init_banksize(void)
  73. {
  74. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  75. gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
  76. PHYS_SDRAM_1_SIZE);
  77. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  78. gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
  79. PHYS_SDRAM_2_SIZE);
  80. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  81. gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
  82. PHYS_SDRAM_3_SIZE);
  83. gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
  84. gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
  85. PHYS_SDRAM_4_SIZE);
  86. gd->bd->bi_dram[4].start = PHYS_SDRAM_5;
  87. gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5,
  88. PHYS_SDRAM_5_SIZE);
  89. gd->bd->bi_dram[5].start = PHYS_SDRAM_6;
  90. gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6,
  91. PHYS_SDRAM_6_SIZE);
  92. gd->bd->bi_dram[6].start = PHYS_SDRAM_7;
  93. gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7,
  94. PHYS_SDRAM_7_SIZE);
  95. gd->bd->bi_dram[7].start = PHYS_SDRAM_8;
  96. gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8,
  97. PHYS_SDRAM_8_SIZE);
  98. }
  99. int board_eth_init(bd_t *bis)
  100. {
  101. #ifdef CONFIG_SMC911X
  102. if (smc9115_pre_init())
  103. return -1;
  104. return smc911x_initialize(0, CONFIG_SMC911X_BASE);
  105. #endif
  106. return 0;
  107. }
  108. #ifdef CONFIG_DISPLAY_BOARDINFO
  109. int checkboard(void)
  110. {
  111. printf("\nBoard: SMDK5250\n");
  112. return 0;
  113. }
  114. #endif
  115. #ifdef CONFIG_GENERIC_MMC
  116. int board_mmc_init(bd_t *bis)
  117. {
  118. int err;
  119. err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
  120. if (err) {
  121. debug("SDMMC0 not configured\n");
  122. return err;
  123. }
  124. err = s5p_mmc_init(0, 8);
  125. return err;
  126. }
  127. #endif
  128. static int board_uart_init(void)
  129. {
  130. int err;
  131. err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
  132. if (err) {
  133. debug("UART0 not configured\n");
  134. return err;
  135. }
  136. err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
  137. if (err) {
  138. debug("UART1 not configured\n");
  139. return err;
  140. }
  141. err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
  142. if (err) {
  143. debug("UART2 not configured\n");
  144. return err;
  145. }
  146. err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
  147. if (err) {
  148. debug("UART3 not configured\n");
  149. return err;
  150. }
  151. return 0;
  152. }
  153. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  154. static int board_i2c_init(void)
  155. {
  156. int i, err;
  157. for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
  158. err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
  159. PINMUX_FLAG_NONE);
  160. if (err) {
  161. debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
  162. return err;
  163. }
  164. }
  165. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  166. return 0;
  167. }
  168. #endif
  169. #ifdef CONFIG_BOARD_EARLY_INIT_F
  170. int board_early_init_f(void)
  171. {
  172. int err;
  173. err = board_uart_init();
  174. if (err) {
  175. debug("UART init failed\n");
  176. return err;
  177. }
  178. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  179. err = board_i2c_init();
  180. #endif
  181. return err;
  182. }
  183. #endif