mx6quq7.c 3.5 KB

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