mx6quq7.c 3.4 KB

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