smdk5250.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 <fdtdec.h>
  24. #include <asm/io.h>
  25. #include <i2c.h>
  26. #include <netdev.h>
  27. #include <spi.h>
  28. #include <asm/arch/cpu.h>
  29. #include <asm/arch/gpio.h>
  30. #include <asm/arch/mmc.h>
  31. #include <asm/arch/pinmux.h>
  32. #include <asm/arch/sromc.h>
  33. #include <power/pmic.h>
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int board_init(void)
  36. {
  37. gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
  38. #ifdef CONFIG_EXYNOS_SPI
  39. spi_init();
  40. #endif
  41. return 0;
  42. }
  43. int dram_init(void)
  44. {
  45. gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
  46. + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
  47. + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
  48. + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE)
  49. + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE)
  50. + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE)
  51. + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE)
  52. + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE);
  53. return 0;
  54. }
  55. #if defined(CONFIG_POWER)
  56. int power_init_board(void)
  57. {
  58. if (pmic_init(I2C_PMIC))
  59. return -1;
  60. else
  61. return 0;
  62. }
  63. #endif
  64. void dram_init_banksize(void)
  65. {
  66. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  67. gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
  68. PHYS_SDRAM_1_SIZE);
  69. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  70. gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
  71. PHYS_SDRAM_2_SIZE);
  72. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  73. gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
  74. PHYS_SDRAM_3_SIZE);
  75. gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
  76. gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
  77. PHYS_SDRAM_4_SIZE);
  78. gd->bd->bi_dram[4].start = PHYS_SDRAM_5;
  79. gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5,
  80. PHYS_SDRAM_5_SIZE);
  81. gd->bd->bi_dram[5].start = PHYS_SDRAM_6;
  82. gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6,
  83. PHYS_SDRAM_6_SIZE);
  84. gd->bd->bi_dram[6].start = PHYS_SDRAM_7;
  85. gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7,
  86. PHYS_SDRAM_7_SIZE);
  87. gd->bd->bi_dram[7].start = PHYS_SDRAM_8;
  88. gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8,
  89. PHYS_SDRAM_8_SIZE);
  90. }
  91. #ifdef CONFIG_OF_CONTROL
  92. static int decode_sromc(const void *blob, struct fdt_sromc *config)
  93. {
  94. int err;
  95. int node;
  96. node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC);
  97. if (node < 0) {
  98. debug("Could not find SROMC node\n");
  99. return node;
  100. }
  101. config->bank = fdtdec_get_int(blob, node, "bank", 0);
  102. config->width = fdtdec_get_int(blob, node, "width", 2);
  103. err = fdtdec_get_int_array(blob, node, "srom-timing", config->timing,
  104. FDT_SROM_TIMING_COUNT);
  105. if (err < 0) {
  106. debug("Could not decode SROMC configuration\n");
  107. return -FDT_ERR_NOTFOUND;
  108. }
  109. return 0;
  110. }
  111. #endif
  112. int board_eth_init(bd_t *bis)
  113. {
  114. #ifdef CONFIG_SMC911X
  115. u32 smc_bw_conf, smc_bc_conf;
  116. struct fdt_sromc config;
  117. fdt_addr_t base_addr;
  118. int node;
  119. #ifdef CONFIG_OF_CONTROL
  120. node = decode_sromc(gd->fdt_blob, &config);
  121. if (node < 0) {
  122. debug("%s: Could not find sromc configuration\n", __func__);
  123. return 0;
  124. }
  125. node = fdtdec_next_compatible(gd->fdt_blob, node, COMPAT_SMSC_LAN9215);
  126. if (node < 0) {
  127. debug("%s: Could not find lan9215 configuration\n", __func__);
  128. return 0;
  129. }
  130. /* We now have a node, so any problems from now on are errors */
  131. base_addr = fdtdec_get_addr(gd->fdt_blob, node, "reg");
  132. if (base_addr == FDT_ADDR_T_NONE) {
  133. debug("%s: Could not find lan9215 address\n", __func__);
  134. return -1;
  135. }
  136. #else
  137. /* Non-FDT configuration - bank number and timing parameters*/
  138. config.bank = CONFIG_ENV_SROM_BANK;
  139. config.width = 2;
  140. config.timing[FDT_SROM_TACS] = 0x01;
  141. config.timing[FDT_SROM_TCOS] = 0x01;
  142. config.timing[FDT_SROM_TACC] = 0x06;
  143. config.timing[FDT_SROM_TCOH] = 0x01;
  144. config.timing[FDT_SROM_TAH] = 0x0C;
  145. config.timing[FDT_SROM_TACP] = 0x09;
  146. config.timing[FDT_SROM_PMC] = 0x01;
  147. base_addr = CONFIG_SMC911X_BASE;
  148. #endif
  149. /* Ethernet needs data bus width of 16 bits */
  150. if (config.width != 2) {
  151. debug("%s: Unsupported bus width %d\n", __func__,
  152. config.width);
  153. return -1;
  154. }
  155. smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
  156. | SROMC_BYTE_ENABLE(config.bank);
  157. smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |\
  158. SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |\
  159. SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |\
  160. SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |\
  161. SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |\
  162. SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |\
  163. SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
  164. /* Select and configure the SROMC bank */
  165. exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
  166. s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
  167. return smc911x_initialize(0, base_addr);
  168. #endif
  169. return 0;
  170. }
  171. #ifdef CONFIG_DISPLAY_BOARDINFO
  172. int checkboard(void)
  173. {
  174. printf("\nBoard: SMDK5250\n");
  175. return 0;
  176. }
  177. #endif
  178. #ifdef CONFIG_GENERIC_MMC
  179. int board_mmc_init(bd_t *bis)
  180. {
  181. int err;
  182. err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
  183. if (err) {
  184. debug("SDMMC0 not configured\n");
  185. return err;
  186. }
  187. err = s5p_mmc_init(0, 8);
  188. return err;
  189. }
  190. #endif
  191. static int board_uart_init(void)
  192. {
  193. int err;
  194. err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
  195. if (err) {
  196. debug("UART0 not configured\n");
  197. return err;
  198. }
  199. err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
  200. if (err) {
  201. debug("UART1 not configured\n");
  202. return err;
  203. }
  204. err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
  205. if (err) {
  206. debug("UART2 not configured\n");
  207. return err;
  208. }
  209. err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
  210. if (err) {
  211. debug("UART3 not configured\n");
  212. return err;
  213. }
  214. return 0;
  215. }
  216. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  217. static int board_i2c_init(void)
  218. {
  219. int i, err;
  220. for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
  221. err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
  222. PINMUX_FLAG_NONE);
  223. if (err) {
  224. debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
  225. return err;
  226. }
  227. }
  228. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  229. return 0;
  230. }
  231. #endif
  232. #ifdef CONFIG_BOARD_EARLY_INIT_F
  233. int board_early_init_f(void)
  234. {
  235. int err;
  236. err = board_uart_init();
  237. if (err) {
  238. debug("UART init failed\n");
  239. return err;
  240. }
  241. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  242. err = board_i2c_init();
  243. #endif
  244. return err;
  245. }
  246. #endif