smdk5250.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 <spi.h>
  27. #include <asm/arch/cpu.h>
  28. #include <asm/arch/gpio.h>
  29. #include <asm/arch/mmc.h>
  30. #include <asm/arch/pinmux.h>
  31. #include <asm/arch/sromc.h>
  32. #include <power/pmic.h>
  33. DECLARE_GLOBAL_DATA_PTR;
  34. #ifdef CONFIG_SMC911X
  35. static int smc9115_pre_init(void)
  36. {
  37. u32 smc_bw_conf, smc_bc_conf;
  38. int err;
  39. /* Ethernet needs data bus width of 16 bits */
  40. smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK)
  41. | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK);
  42. smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01)
  43. | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01)
  44. | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09)
  45. | SROMC_BC_PMC(0x01);
  46. /* Select and configure the SROMC bank */
  47. err = exynos_pinmux_config(PERIPH_ID_SROMC,
  48. CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT);
  49. if (err) {
  50. debug("SROMC not configured\n");
  51. return err;
  52. }
  53. s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
  54. return 0;
  55. }
  56. #endif
  57. int board_init(void)
  58. {
  59. gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
  60. #ifdef CONFIG_EXYNOS_SPI
  61. spi_init();
  62. #endif
  63. return 0;
  64. }
  65. int dram_init(void)
  66. {
  67. gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
  68. + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
  69. + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
  70. + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE)
  71. + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE)
  72. + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE)
  73. + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE)
  74. + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE);
  75. return 0;
  76. }
  77. #if defined(CONFIG_POWER)
  78. int power_init_board(void)
  79. {
  80. if (pmic_init(I2C_PMIC))
  81. return -1;
  82. else
  83. return 0;
  84. }
  85. #endif
  86. void dram_init_banksize(void)
  87. {
  88. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  89. gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
  90. PHYS_SDRAM_1_SIZE);
  91. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  92. gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
  93. PHYS_SDRAM_2_SIZE);
  94. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  95. gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
  96. PHYS_SDRAM_3_SIZE);
  97. gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
  98. gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
  99. PHYS_SDRAM_4_SIZE);
  100. gd->bd->bi_dram[4].start = PHYS_SDRAM_5;
  101. gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5,
  102. PHYS_SDRAM_5_SIZE);
  103. gd->bd->bi_dram[5].start = PHYS_SDRAM_6;
  104. gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6,
  105. PHYS_SDRAM_6_SIZE);
  106. gd->bd->bi_dram[6].start = PHYS_SDRAM_7;
  107. gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7,
  108. PHYS_SDRAM_7_SIZE);
  109. gd->bd->bi_dram[7].start = PHYS_SDRAM_8;
  110. gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8,
  111. PHYS_SDRAM_8_SIZE);
  112. }
  113. int board_eth_init(bd_t *bis)
  114. {
  115. #ifdef CONFIG_SMC911X
  116. if (smc9115_pre_init())
  117. return -1;
  118. return smc911x_initialize(0, CONFIG_SMC911X_BASE);
  119. #endif
  120. return 0;
  121. }
  122. #ifdef CONFIG_DISPLAY_BOARDINFO
  123. int checkboard(void)
  124. {
  125. printf("\nBoard: SMDK5250\n");
  126. return 0;
  127. }
  128. #endif
  129. #ifdef CONFIG_GENERIC_MMC
  130. int board_mmc_init(bd_t *bis)
  131. {
  132. int err;
  133. err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
  134. if (err) {
  135. debug("SDMMC0 not configured\n");
  136. return err;
  137. }
  138. err = s5p_mmc_init(0, 8);
  139. return err;
  140. }
  141. #endif
  142. static int board_uart_init(void)
  143. {
  144. int err;
  145. err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
  146. if (err) {
  147. debug("UART0 not configured\n");
  148. return err;
  149. }
  150. err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
  151. if (err) {
  152. debug("UART1 not configured\n");
  153. return err;
  154. }
  155. err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
  156. if (err) {
  157. debug("UART2 not configured\n");
  158. return err;
  159. }
  160. err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
  161. if (err) {
  162. debug("UART3 not configured\n");
  163. return err;
  164. }
  165. return 0;
  166. }
  167. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  168. static int board_i2c_init(void)
  169. {
  170. int i, err;
  171. for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
  172. err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
  173. PINMUX_FLAG_NONE);
  174. if (err) {
  175. debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
  176. return err;
  177. }
  178. }
  179. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  180. return 0;
  181. }
  182. #endif
  183. #ifdef CONFIG_BOARD_EARLY_INIT_F
  184. int board_early_init_f(void)
  185. {
  186. int err;
  187. err = board_uart_init();
  188. if (err) {
  189. debug("UART init failed\n");
  190. return err;
  191. }
  192. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  193. err = board_i2c_init();
  194. #endif
  195. return err;
  196. }
  197. #endif