mx6quq7.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 <asm/mach-imx/mxc_i2c.h>
  29. #include <i2c.h>
  30. #include "../common/mx6.h"
  31. DECLARE_GLOBAL_DATA_PTR;
  32. int dram_init(void)
  33. {
  34. gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
  35. return 0;
  36. }
  37. int board_early_init_f(void)
  38. {
  39. seco_mx6_setup_uart_iomux();
  40. return 0;
  41. }
  42. int board_phy_config(struct phy_device *phydev)
  43. {
  44. seco_mx6_rgmii_rework(phydev);
  45. if (phydev->drv->config)
  46. phydev->drv->config(phydev);
  47. return 0;
  48. }
  49. int board_eth_init(bd_t *bis)
  50. {
  51. uint32_t base = IMX_FEC_BASE;
  52. struct mii_dev *bus = NULL;
  53. struct phy_device *phydev = NULL;
  54. int ret = 0;
  55. seco_mx6_setup_enet_iomux();
  56. #ifdef CONFIG_FEC_MXC
  57. bus = fec_get_miibus(base, -1);
  58. if (!bus)
  59. return -ENOMEM;
  60. /* scan phy 4,5,6,7 */
  61. phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
  62. if (!phydev) {
  63. free(bus);
  64. return -ENOMEM;
  65. }
  66. printf("using phy at %d\n", phydev->addr);
  67. ret = fec_probe(bis, -1, base, bus, phydev);
  68. if (ret) {
  69. free(phydev);
  70. free(bus);
  71. printf("FEC MXC: %s:failed\n", __func__);
  72. }
  73. #endif
  74. return ret;
  75. }
  76. #define USDHC4_CD_GPIO IMX_GPIO_NR(2, 6)
  77. static struct fsl_esdhc_cfg usdhc_cfg[2] = {
  78. {USDHC3_BASE_ADDR, 0, 4},
  79. {USDHC4_BASE_ADDR, 0, 4},
  80. };
  81. int board_mmc_getcd(struct mmc *mmc)
  82. {
  83. struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
  84. int ret = 0;
  85. switch (cfg->esdhc_base) {
  86. case USDHC3_BASE_ADDR:
  87. ret = 1; /* Assume eMMC is always present */
  88. break;
  89. case USDHC4_BASE_ADDR:
  90. ret = !gpio_get_value(USDHC4_CD_GPIO);
  91. break;
  92. }
  93. return ret;
  94. }
  95. int board_mmc_init(bd_t *bis)
  96. {
  97. u32 index = 0;
  98. int ret;
  99. /*
  100. * Following map is done:
  101. * (U-Boot device node) (Physical Port)
  102. * mmc0 eMMC on Board
  103. * mmc1 Ext SD
  104. */
  105. for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
  106. switch (index) {
  107. case 0:
  108. seco_mx6_setup_usdhc_iomux(3);
  109. usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
  110. break;
  111. case 1:
  112. seco_mx6_setup_usdhc_iomux(4);
  113. usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK);
  114. break;
  115. default:
  116. printf("Warning: %d exceed maximum number of SD ports %d\n",
  117. index + 1, CONFIG_SYS_FSL_USDHC_NUM);
  118. return -EINVAL;
  119. }
  120. ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
  121. if (ret)
  122. return ret;
  123. }
  124. return 0;
  125. }
  126. int board_init(void)
  127. {
  128. /* address of boot parameters */
  129. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  130. imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D4__GPIO2_IO04 |
  131. MUX_PAD_CTRL(NO_PAD_CTRL));
  132. gpio_direction_output(IMX_GPIO_NR(2, 4), 0);
  133. /* Set Low */
  134. gpio_set_value(IMX_GPIO_NR(2, 4), 0);
  135. udelay(1000);
  136. /* Set High */
  137. gpio_set_value(IMX_GPIO_NR(2, 4), 1);
  138. return 0;
  139. }
  140. int checkboard(void)
  141. {
  142. puts("Board: SECO uQ7\n");
  143. return 0;
  144. }