goni.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * Copyright (C) 2008-2009 Samsung Electronics
  3. * Minkyu Kang <mk7.kang@samsung.com>
  4. * Kyungmin Park <kyungmin.park@samsung.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/gpio.h>
  10. #include <asm/arch/mmc.h>
  11. #include <power/pmic.h>
  12. #include <usb/dwc2_udc.h>
  13. #include <asm/arch/cpu.h>
  14. #include <power/max8998_pmic.h>
  15. #include <samsung/misc.h>
  16. #include <usb.h>
  17. #include <usb_mass_storage.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. u32 get_board_rev(void)
  20. {
  21. return 0;
  22. }
  23. int board_init(void)
  24. {
  25. /* Set Initial global variables */
  26. gd->bd->bi_arch_number = MACH_TYPE_GONI;
  27. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  28. return 0;
  29. }
  30. #ifdef CONFIG_SYS_I2C_INIT_BOARD
  31. void i2c_init_board(void)
  32. {
  33. gpio_request(S5PC110_GPIO_J43, "i2c_clk");
  34. gpio_request(S5PC110_GPIO_J40, "i2c_data");
  35. gpio_direction_output(S5PC110_GPIO_J43, 1);
  36. gpio_direction_output(S5PC110_GPIO_J40, 1);
  37. }
  38. #endif
  39. int power_init_board(void)
  40. {
  41. #ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
  42. /*
  43. * For PMIC the I2C bus is named as I2C5, but it is connected
  44. * to logical I2C adapter 0
  45. */
  46. return pmic_init(I2C_0);
  47. #else
  48. return 0;
  49. #endif
  50. }
  51. int dram_init(void)
  52. {
  53. gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
  54. PHYS_SDRAM_3_SIZE;
  55. return 0;
  56. }
  57. void dram_init_banksize(void)
  58. {
  59. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  60. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  61. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  62. gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
  63. gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
  64. gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
  65. }
  66. #ifdef CONFIG_DISPLAY_BOARDINFO
  67. int checkboard(void)
  68. {
  69. puts("Board:\tGoni\n");
  70. return 0;
  71. }
  72. #endif
  73. #ifdef CONFIG_GENERIC_MMC
  74. int board_mmc_init(bd_t *bis)
  75. {
  76. int i, ret, ret_sd = 0;
  77. /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
  78. gpio_request(S5PC110_GPIO_J27, "massmemory_en");
  79. gpio_direction_output(S5PC110_GPIO_J27, 1);
  80. /*
  81. * MMC0 GPIO
  82. * GPG0[0] SD_0_CLK
  83. * GPG0[1] SD_0_CMD
  84. * GPG0[2] SD_0_CDn -> Not used
  85. * GPG0[3:6] SD_0_DATA[0:3]
  86. */
  87. for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) {
  88. if (i == S5PC110_GPIO_G02)
  89. continue;
  90. /* GPG0[0:6] special function 2 */
  91. gpio_cfg_pin(i, 0x2);
  92. /* GPG0[0:6] pull disable */
  93. gpio_set_pull(i, S5P_GPIO_PULL_NONE);
  94. /* GPG0[0:6] drv 4x */
  95. gpio_set_drv(i, S5P_GPIO_DRV_4X);
  96. }
  97. ret = s5p_mmc_init(0, 4);
  98. if (ret)
  99. error("MMC: Failed to init MMC:0.\n");
  100. /*
  101. * SD card (T_FLASH) detect and init
  102. * T_FLASH_DETECT: EINT28: GPH3[4] input mode
  103. */
  104. gpio_request(S5PC110_GPIO_H34, "t_flash_detect");
  105. gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
  106. gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
  107. if (!gpio_get_value(S5PC110_GPIO_H34)) {
  108. for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) {
  109. if (i == S5PC110_GPIO_G22)
  110. continue;
  111. /* GPG2[0:6] special function 2 */
  112. gpio_cfg_pin(i, 0x2);
  113. /* GPG2[0:6] pull disable */
  114. gpio_set_pull(i, S5P_GPIO_PULL_NONE);
  115. /* GPG2[0:6] drv 4x */
  116. gpio_set_drv(i, S5P_GPIO_DRV_4X);
  117. }
  118. ret_sd = s5p_mmc_init(2, 4);
  119. if (ret_sd)
  120. error("MMC: Failed to init SD card (MMC:2).\n");
  121. }
  122. return ret & ret_sd;
  123. }
  124. #endif
  125. #ifdef CONFIG_USB_GADGET
  126. static int s5pc1xx_phy_control(int on)
  127. {
  128. #ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
  129. int ret;
  130. static int status;
  131. struct pmic *p = pmic_get("MAX8998_PMIC");
  132. if (!p)
  133. return -ENODEV;
  134. if (pmic_probe(p))
  135. return -1;
  136. if (on && !status) {
  137. ret = pmic_set_output(p, MAX8998_REG_ONOFF1,
  138. MAX8998_LDO3, LDO_ON);
  139. ret = pmic_set_output(p, MAX8998_REG_ONOFF2,
  140. MAX8998_LDO8, LDO_ON);
  141. if (ret) {
  142. puts("MAX8998 LDO setting error!\n");
  143. return -1;
  144. }
  145. status = 1;
  146. } else if (!on && status) {
  147. ret = pmic_set_output(p, MAX8998_REG_ONOFF1,
  148. MAX8998_LDO3, LDO_OFF);
  149. ret = pmic_set_output(p, MAX8998_REG_ONOFF2,
  150. MAX8998_LDO8, LDO_OFF);
  151. if (ret) {
  152. puts("MAX8998 LDO setting error!\n");
  153. return -1;
  154. }
  155. status = 0;
  156. }
  157. udelay(10000);
  158. #endif
  159. return 0;
  160. }
  161. struct dwc2_plat_otg_data s5pc110_otg_data = {
  162. .phy_control = s5pc1xx_phy_control,
  163. .regs_phy = S5PC110_PHY_BASE,
  164. .regs_otg = S5PC110_OTG_BASE,
  165. .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL,
  166. };
  167. int board_usb_init(int index, enum usb_init_type init)
  168. {
  169. debug("USB_udc_probe\n");
  170. return dwc2_udc_probe(&s5pc110_otg_data);
  171. }
  172. #endif
  173. #ifdef CONFIG_MISC_INIT_R
  174. int misc_init_r(void)
  175. {
  176. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  177. set_board_info();
  178. #endif
  179. return 0;
  180. }
  181. #endif
  182. int board_usb_cleanup(int index, enum usb_init_type init)
  183. {
  184. return 0;
  185. }