imx8qm_rom7720_a1.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2017-2018 NXP
  4. * Copyright (C) 2019 Oliver Graute <oliver.graute@kococonnector.com>
  5. */
  6. #include <common.h>
  7. #include <cpu_func.h>
  8. #include <env.h>
  9. #include <errno.h>
  10. #include <init.h>
  11. #include <asm/global_data.h>
  12. #include <linux/delay.h>
  13. #include <linux/libfdt.h>
  14. #include <asm/io.h>
  15. #include <asm/gpio.h>
  16. #include <asm/arch/clock.h>
  17. #include <asm/arch/sci/sci.h>
  18. #include <asm/arch/imx8-pins.h>
  19. #include <asm/arch/iomux.h>
  20. #include <asm/arch/sys_proto.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. #define UART_PAD_CTRL ((SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
  23. (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
  24. (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
  25. (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
  26. static iomux_cfg_t uart0_pads[] = {
  27. SC_P_UART0_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
  28. SC_P_UART0_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
  29. };
  30. static void setup_iomux_uart(void)
  31. {
  32. imx8_iomux_setup_multiple_pads(uart0_pads, ARRAY_SIZE(uart0_pads));
  33. }
  34. int board_early_init_f(void)
  35. {
  36. sc_pm_clock_rate_t rate = SC_80MHZ;
  37. int ret;
  38. /* Set UART0 clock root to 80 MHz */
  39. ret = sc_pm_setup_uart(SC_R_UART_0, rate);
  40. if (ret)
  41. return ret;
  42. setup_iomux_uart();
  43. /* This is needed to because Kernel do not Power Up DC_0 */
  44. sc_pm_set_resource_power_mode(-1, SC_R_DC_0, SC_PM_PW_MODE_ON);
  45. sc_pm_set_resource_power_mode(-1, SC_R_GPIO_5, SC_PM_PW_MODE_ON);
  46. return 0;
  47. }
  48. #if IS_ENABLED(CONFIG_FEC_MXC)
  49. #include <miiphy.h>
  50. int board_phy_config(struct phy_device *phydev)
  51. {
  52. #ifdef CONFIG_FEC_ENABLE_MAX7322
  53. u8 value;
  54. /* This is needed to drive the pads to 1.8V instead of 1.5V */
  55. i2c_set_bus_num(CONFIG_MAX7322_I2C_BUS);
  56. if (!i2c_probe(CONFIG_MAX7322_I2C_ADDR)) {
  57. /* Write 0x1 to enable O0 output, this device has no addr */
  58. /* hence addr length is 0 */
  59. value = 0x1;
  60. if (dm_i2c_write(CONFIG_MAX7322_I2C_ADDR, 0, 0, &value, 1))
  61. printf("MAX7322 write failed\n");
  62. } else {
  63. printf("MAX7322 Not found\n");
  64. }
  65. mdelay(1);
  66. #endif
  67. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
  68. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
  69. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
  70. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
  71. phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
  72. phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
  73. if (phydev->drv->config)
  74. phydev->drv->config(phydev);
  75. return 0;
  76. }
  77. #endif
  78. int checkboard(void)
  79. {
  80. puts("Board: ROM-7720-A1 4GB\n");
  81. build_info();
  82. print_bootinfo();
  83. return 0;
  84. }
  85. int board_init(void)
  86. {
  87. /* Power up base board */
  88. sc_pm_set_resource_power_mode(-1, SC_R_BOARD_R1, SC_PM_PW_MODE_ON);
  89. return 0;
  90. }
  91. /*
  92. * Board specific reset that is system reset.
  93. */
  94. void reset_cpu(void)
  95. {
  96. /* TODO */
  97. }
  98. int board_mmc_get_env_dev(int devno)
  99. {
  100. return devno;
  101. }
  102. int board_late_init(void)
  103. {
  104. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  105. env_set("board_name", "ROM-7720-A1");
  106. env_set("board_rev", "iMX8QM");
  107. #endif
  108. env_set("sec_boot", "no");
  109. #ifdef CONFIG_AHAB_BOOT
  110. env_set("sec_boot", "yes");
  111. #endif
  112. return 0;
  113. }