snowball.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2009
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <config.h>
  19. #include <common.h>
  20. #include <malloc.h>
  21. #include <i2c.h>
  22. #include <mmc.h>
  23. #include <asm/types.h>
  24. #include <asm/io.h>
  25. #include <asm/errno.h>
  26. #include <asm/arch/db8500_pincfg.h>
  27. #include <asm/arch/prcmu.h>
  28. #include <asm/arch/hardware.h>
  29. #include "db8500_pins.h"
  30. /*
  31. * Get a global data pointer
  32. */
  33. DECLARE_GLOBAL_DATA_PTR;
  34. /*
  35. * Memory controller register
  36. */
  37. #define DMC_BASE_ADDR 0x80156000
  38. #define DMC_CTL_97 (DMC_BASE_ADDR + 0x184)
  39. /*
  40. * GPIO pin config common for MOP500/HREF boards
  41. */
  42. unsigned long gpio_cfg_common[] = {
  43. /* I2C */
  44. GPIO147_I2C0_SCL,
  45. GPIO148_I2C0_SDA,
  46. GPIO16_I2C1_SCL,
  47. GPIO17_I2C1_SDA,
  48. GPIO10_I2C2_SDA,
  49. GPIO11_I2C2_SCL,
  50. GPIO229_I2C3_SDA,
  51. GPIO230_I2C3_SCL,
  52. /* SSP0, to AB8500 */
  53. GPIO143_SSP0_CLK,
  54. GPIO144_SSP0_FRM,
  55. GPIO145_SSP0_RXD | PIN_PULL_DOWN,
  56. GPIO146_SSP0_TXD,
  57. /* MMC0 (MicroSD card) */
  58. GPIO18_MC0_CMDDIR | PIN_OUTPUT_HIGH,
  59. GPIO19_MC0_DAT0DIR | PIN_OUTPUT_HIGH,
  60. GPIO20_MC0_DAT2DIR | PIN_OUTPUT_HIGH,
  61. GPIO21_MC0_DAT31DIR | PIN_OUTPUT_HIGH,
  62. GPIO22_MC0_FBCLK | PIN_INPUT_NOPULL,
  63. GPIO23_MC0_CLK | PIN_OUTPUT_LOW,
  64. GPIO24_MC0_CMD | PIN_INPUT_PULLUP,
  65. GPIO25_MC0_DAT0 | PIN_INPUT_PULLUP,
  66. GPIO26_MC0_DAT1 | PIN_INPUT_PULLUP,
  67. GPIO27_MC0_DAT2 | PIN_INPUT_PULLUP,
  68. GPIO28_MC0_DAT3 | PIN_INPUT_PULLUP,
  69. /* MMC4 (On-board eMMC) */
  70. GPIO197_MC4_DAT3 | PIN_INPUT_PULLUP,
  71. GPIO198_MC4_DAT2 | PIN_INPUT_PULLUP,
  72. GPIO199_MC4_DAT1 | PIN_INPUT_PULLUP,
  73. GPIO200_MC4_DAT0 | PIN_INPUT_PULLUP,
  74. GPIO201_MC4_CMD | PIN_INPUT_PULLUP,
  75. GPIO202_MC4_FBCLK | PIN_INPUT_NOPULL,
  76. GPIO203_MC4_CLK | PIN_OUTPUT_LOW,
  77. GPIO204_MC4_DAT7 | PIN_INPUT_PULLUP,
  78. GPIO205_MC4_DAT6 | PIN_INPUT_PULLUP,
  79. GPIO206_MC4_DAT5 | PIN_INPUT_PULLUP,
  80. GPIO207_MC4_DAT4 | PIN_INPUT_PULLUP,
  81. /* UART2, console */
  82. GPIO29_U2_RXD | PIN_INPUT_PULLUP,
  83. GPIO30_U2_TXD | PIN_OUTPUT_HIGH,
  84. GPIO31_U2_CTSn | PIN_INPUT_PULLUP,
  85. GPIO32_U2_RTSn | PIN_OUTPUT_HIGH,
  86. /*
  87. * USB, pin 256-267 USB, Is probably already setup correctly from
  88. * BootROM/boot stages, but we don't trust that and set it up anyway
  89. */
  90. GPIO256_USB_NXT,
  91. GPIO257_USB_STP,
  92. GPIO258_USB_XCLK,
  93. GPIO259_USB_DIR,
  94. GPIO260_USB_DAT7,
  95. GPIO261_USB_DAT6,
  96. GPIO262_USB_DAT5,
  97. GPIO263_USB_DAT4,
  98. GPIO264_USB_DAT3,
  99. GPIO265_USB_DAT2,
  100. GPIO266_USB_DAT1,
  101. GPIO267_USB_DAT0,
  102. };
  103. unsigned long gpio_cfg_snowball[] = {
  104. /* MMC0 (MicroSD card) */
  105. GPIO217_GPIO | PIN_OUTPUT_HIGH, /* MMC_EN */
  106. GPIO218_GPIO | PIN_INPUT_NOPULL, /* MMC_CD */
  107. GPIO228_GPIO | PIN_OUTPUT_HIGH, /* SD_SEL */
  108. /* eMMC */
  109. GPIO167_GPIO | PIN_OUTPUT_HIGH, /* RSTn_MLC */
  110. /* LAN */
  111. GPIO131_SM_ADQ8,
  112. GPIO132_SM_ADQ9,
  113. GPIO133_SM_ADQ10,
  114. GPIO134_SM_ADQ11,
  115. GPIO135_SM_ADQ12,
  116. GPIO136_SM_ADQ13,
  117. GPIO137_SM_ADQ14,
  118. GPIO138_SM_ADQ15,
  119. /* RSTn_LAN */
  120. GPIO141_GPIO | PIN_OUTPUT_HIGH,
  121. };
  122. /*
  123. * Miscellaneous platform dependent initialisations
  124. */
  125. int board_init(void)
  126. {
  127. /*
  128. * Setup board (bd) and board-info (bi).
  129. * bi_arch_number: Unique id for this board. It will passed in r1 to
  130. * Linux startup code and is the machine_id.
  131. * bi_boot_params: Where this board expects params.
  132. */
  133. gd->bd->bi_arch_number = MACH_TYPE_SNOWBALL;
  134. gd->bd->bi_boot_params = 0x00000100;
  135. /* Configure GPIO pins needed by U-boot */
  136. db8500_gpio_config_pins(gpio_cfg_common, ARRAY_SIZE(gpio_cfg_common));
  137. db8500_gpio_config_pins(gpio_cfg_snowball,
  138. ARRAY_SIZE(gpio_cfg_snowball));
  139. return 0;
  140. }
  141. int dram_init(void)
  142. {
  143. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  144. gd->ram_size = gd->bd->bi_dram[0].size =
  145. get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
  146. return 0;
  147. }
  148. static int raise_ab8500_gpio16(void)
  149. {
  150. int ret;
  151. /* selection */
  152. ret = ab8500_read(AB8500_MISC, AB8500_GPIO_SEL2_REG);
  153. if (ret < 0)
  154. goto out;
  155. ret |= 0x80;
  156. ret = ab8500_write(AB8500_MISC, AB8500_GPIO_SEL2_REG, ret);
  157. if (ret < 0)
  158. goto out;
  159. /* direction */
  160. ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR2_REG);
  161. if (ret < 0)
  162. goto out;
  163. ret |= 0x80;
  164. ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR2_REG, ret);
  165. if (ret < 0)
  166. goto out;
  167. /* out */
  168. ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT2_REG);
  169. if (ret < 0)
  170. goto out;
  171. ret |= 0x80;
  172. ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT2_REG, ret);
  173. out:
  174. return ret;
  175. }
  176. static int raise_ab8500_gpio26(void)
  177. {
  178. int ret;
  179. /* selection */
  180. ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR4_REG);
  181. if (ret < 0)
  182. goto out;
  183. ret |= 0x2;
  184. ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR4_REG, ret);
  185. if (ret < 0)
  186. goto out;
  187. /* out */
  188. ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT4_REG);
  189. if (ret < 0)
  190. goto out;
  191. ret |= 0x2;
  192. ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT4_REG, ret);
  193. out:
  194. return ret;
  195. }
  196. int board_late_init(void)
  197. {
  198. /* enable 3V3 for LAN controller */
  199. if (raise_ab8500_gpio26() >= 0) {
  200. /* Turn on FSMC device */
  201. writel(0x1, 0x8000f000);
  202. writel(0x1, 0x8000f008);
  203. /* setup FSMC for LAN controler */
  204. writel(0x305b, 0x80000000);
  205. /* run at the highest possible speed */
  206. writel(0x01010210, 0x80000004);
  207. } else
  208. printf("error: can't raise GPIO26\n");
  209. /* enable 3v6 for GBF chip */
  210. if ((raise_ab8500_gpio16() < 0))
  211. printf("error: cant' raise GPIO16\n");
  212. return 0;
  213. }