imx8qm_mek.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2018 NXP
  4. */
  5. #include <common.h>
  6. #include <env.h>
  7. #include <errno.h>
  8. #include <init.h>
  9. #include <linux/libfdt.h>
  10. #include <asm/io.h>
  11. #include <asm/gpio.h>
  12. #include <asm/arch/clock.h>
  13. #include <asm/arch/sci/sci.h>
  14. #include <asm/arch/imx8-pins.h>
  15. #include <asm/arch/iomux.h>
  16. #include <asm/arch/sys_proto.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #define UART_PAD_CTRL ((SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
  19. (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
  20. (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
  21. (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
  22. static iomux_cfg_t uart0_pads[] = {
  23. SC_P_UART0_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
  24. SC_P_UART0_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
  25. };
  26. static void setup_iomux_uart(void)
  27. {
  28. imx8_iomux_setup_multiple_pads(uart0_pads, ARRAY_SIZE(uart0_pads));
  29. }
  30. int board_early_init_f(void)
  31. {
  32. sc_pm_clock_rate_t rate = SC_80MHZ;
  33. int ret;
  34. /* Set UART0 clock root to 80 MHz */
  35. ret = sc_pm_setup_uart(SC_R_UART_0, rate);
  36. if (ret)
  37. return ret;
  38. setup_iomux_uart();
  39. sc_pm_set_resource_power_mode(-1, SC_R_GPIO_5, SC_PM_PW_MODE_ON);
  40. return 0;
  41. }
  42. #if CONFIG_IS_ENABLED(DM_GPIO)
  43. static void board_gpio_init(void)
  44. {
  45. /* TODO */
  46. }
  47. #else
  48. static inline void board_gpio_init(void) {}
  49. #endif
  50. #if IS_ENABLED(CONFIG_FEC_MXC)
  51. #include <miiphy.h>
  52. int board_phy_config(struct phy_device *phydev)
  53. {
  54. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
  55. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
  56. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
  57. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
  58. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
  59. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
  60. if (phydev->drv->config)
  61. phydev->drv->config(phydev);
  62. return 0;
  63. }
  64. #endif
  65. int checkboard(void)
  66. {
  67. puts("Board: iMX8QM MEK\n");
  68. build_info();
  69. print_bootinfo();
  70. return 0;
  71. }
  72. int board_init(void)
  73. {
  74. /* Power up base board */
  75. sc_pm_set_resource_power_mode(-1, SC_R_BOARD_R1, SC_PM_PW_MODE_ON);
  76. board_gpio_init();
  77. return 0;
  78. }
  79. void detail_board_ddr_info(void)
  80. {
  81. puts("\nDDR ");
  82. }
  83. /*
  84. * Board specific reset that is system reset.
  85. */
  86. void reset_cpu(ulong addr)
  87. {
  88. /* TODO */
  89. }
  90. #ifdef CONFIG_OF_BOARD_SETUP
  91. int ft_board_setup(void *blob, bd_t *bd)
  92. {
  93. return 0;
  94. }
  95. #endif
  96. int board_mmc_get_env_dev(int devno)
  97. {
  98. return devno;
  99. }
  100. int board_late_init(void)
  101. {
  102. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  103. env_set("board_name", "MEK");
  104. env_set("board_rev", "iMX8QM");
  105. #endif
  106. return 0;
  107. }