mx6quq7.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (C) 2013 Freescale Semiconductor, Inc.
  3. * Copyright (C) 2015 ECA Sinters
  4. *
  5. * Author: Fabio Estevam <fabio.estevam@freescale.com>
  6. * Modified by: Boris Brezillon <boris.brezillon@free-electrons.com>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <asm/arch/clock.h>
  11. #include <asm/arch/imx-regs.h>
  12. #include <asm/arch/iomux.h>
  13. #include <asm/arch/mx6-pins.h>
  14. #include <linux/errno.h>
  15. #include <asm/gpio.h>
  16. #include <asm/imx-common/iomux-v3.h>
  17. #include <asm/imx-common/boot_mode.h>
  18. #include <malloc.h>
  19. #include <mmc.h>
  20. #include <fsl_esdhc.h>
  21. #include <miiphy.h>
  22. #include <netdev.h>
  23. #include <asm/arch/mxc_hdmi.h>
  24. #include <asm/arch/crm_regs.h>
  25. #include <linux/fb.h>
  26. #include <ipu_pixfmt.h>
  27. #include <asm/io.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <micrel.h>
  30. #include <asm/imx-common/mxc_i2c.h>
  31. #include <i2c.h>
  32. #include "../common/mx6.h"
  33. DECLARE_GLOBAL_DATA_PTR;
  34. int dram_init(void)
  35. {
  36. gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
  37. return 0;
  38. }
  39. int board_early_init_f(void)
  40. {
  41. seco_mx6_setup_uart_iomux();
  42. return 0;
  43. }
  44. int board_phy_config(struct phy_device *phydev)
  45. {
  46. seco_mx6_rgmii_rework(phydev);
  47. if (phydev->drv->config)
  48. phydev->drv->config(phydev);
  49. return 0;
  50. }
  51. int board_eth_init(bd_t *bis)
  52. {
  53. uint32_t base = IMX_FEC_BASE;
  54. struct mii_dev *bus = NULL;
  55. struct phy_device *phydev = NULL;
  56. int ret = 0;
  57. seco_mx6_setup_enet_iomux();
  58. #ifdef CONFIG_FEC_MXC
  59. bus = fec_get_miibus(base, -1);
  60. if (!bus)
  61. return -ENOMEM;
  62. /* scan phy 4,5,6,7 */
  63. phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
  64. if (!phydev) {
  65. free(bus);
  66. return -ENOMEM;
  67. }
  68. printf("using phy at %d\n", phydev->addr);
  69. ret = fec_probe(bis, -1, base, bus, phydev);
  70. if (ret) {
  71. free(phydev);
  72. free(bus);
  73. printf("FEC MXC: %s:failed\n", __func__);
  74. }
  75. #endif
  76. return ret;
  77. }
  78. #define USDHC4_CD_GPIO IMX_GPIO_NR(2, 6)
  79. static struct fsl_esdhc_cfg usdhc_cfg[2] = {
  80. {USDHC3_BASE_ADDR, 0, 4},
  81. {USDHC4_BASE_ADDR, 0, 4},
  82. };
  83. int board_mmc_getcd(struct mmc *mmc)
  84. {
  85. struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
  86. int ret = 0;
  87. switch (cfg->esdhc_base) {
  88. case USDHC3_BASE_ADDR:
  89. ret = 1; /* Assume eMMC is always present */
  90. break;
  91. case USDHC4_BASE_ADDR:
  92. ret = !gpio_get_value(USDHC4_CD_GPIO);
  93. break;
  94. }
  95. return ret;
  96. }
  97. int board_mmc_init(bd_t *bis)
  98. {
  99. u32 index = 0;
  100. int ret;
  101. /*
  102. * Following map is done:
  103. * (U-Boot device node) (Physical Port)
  104. * mmc0 eMMC on Board
  105. * mmc1 Ext SD
  106. */
  107. for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
  108. switch (index) {
  109. case 0:
  110. seco_mx6_setup_usdhc_iomux(3);
  111. usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
  112. break;
  113. case 1:
  114. seco_mx6_setup_usdhc_iomux(4);
  115. usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK);
  116. break;
  117. default:
  118. printf("Warning: %d exceed maximum number of SD ports %d\n",
  119. index + 1, CONFIG_SYS_FSL_USDHC_NUM);
  120. return -EINVAL;
  121. }
  122. ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
  123. if (ret)
  124. return ret;
  125. }
  126. return 0;
  127. }
  128. int board_init(void)
  129. {
  130. /* address of boot parameters */
  131. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  132. imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D4__GPIO2_IO04 |
  133. MUX_PAD_CTRL(NO_PAD_CTRL));
  134. gpio_direction_output(IMX_GPIO_NR(2, 4), 0);
  135. /* Set Low */
  136. gpio_set_value(IMX_GPIO_NR(2, 4), 0);
  137. udelay(1000);
  138. /* Set High */
  139. gpio_set_value(IMX_GPIO_NR(2, 4), 1);
  140. return 0;
  141. }
  142. int checkboard(void)
  143. {
  144. puts("Board: SECO uQ7\n");
  145. return 0;
  146. }