spl.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2020 PHYTEC Messtechnik GmbH
  4. * Author: Teresa Remmet <t.remmet@phytec.de>
  5. */
  6. #include <common.h>
  7. #include <asm/arch/clock.h>
  8. #include <asm/arch/ddr.h>
  9. #include <asm/arch/imx8mp_pins.h>
  10. #include <asm/arch/sys_proto.h>
  11. #include <asm/global_data.h>
  12. #include <asm/mach-imx/boot_mode.h>
  13. #include <asm/mach-imx/gpio.h>
  14. #include <asm/mach-imx/mxc_i2c.h>
  15. #include <asm/mach-imx/iomux-v3.h>
  16. #include <hang.h>
  17. #include <init.h>
  18. #include <log.h>
  19. #include <power/pmic.h>
  20. #include <power/pca9450.h>
  21. #include <spl.h>
  22. DECLARE_GLOBAL_DATA_PTR;
  23. int spl_board_boot_device(enum boot_device boot_dev_spl)
  24. {
  25. return BOOT_DEVICE_BOOTROM;
  26. }
  27. void spl_dram_init(void)
  28. {
  29. ddr_init(&dram_timing);
  30. }
  31. #define I2C_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PE)
  32. #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
  33. struct i2c_pads_info i2c_pad_info1 = {
  34. .scl = {
  35. .i2c_mode = MX8MP_PAD_I2C1_SCL__I2C1_SCL | PC,
  36. .gpio_mode = MX8MP_PAD_I2C1_SCL__GPIO5_IO14 | PC,
  37. .gp = IMX_GPIO_NR(5, 14),
  38. },
  39. .sda = {
  40. .i2c_mode = MX8MP_PAD_I2C1_SDA__I2C1_SDA | PC,
  41. .gpio_mode = MX8MP_PAD_I2C1_SDA__GPIO5_IO15 | PC,
  42. .gp = IMX_GPIO_NR(5, 15),
  43. },
  44. };
  45. int power_init_board(void)
  46. {
  47. struct pmic *p;
  48. int ret;
  49. ret = power_pca9450_init(0, 0x25);
  50. if (ret)
  51. printf("power init failed");
  52. p = pmic_get("PCA9450");
  53. pmic_probe(p);
  54. /* BUCKxOUT_DVS0/1 control BUCK123 output */
  55. pmic_reg_write(p, PCA9450_BUCK123_DVS, 0x29);
  56. /* Increase VDD_SOC and VDD_ARM to OD voltage 0.95V */
  57. pmic_reg_write(p, PCA9450_BUCK1OUT_DVS0, 0x1C);
  58. pmic_reg_write(p, PCA9450_BUCK2OUT_DVS0, 0x1C);
  59. /* Set BUCK1 DVS1 to suspend controlled through PMIC_STBY_REQ */
  60. pmic_reg_write(p, PCA9450_BUCK1OUT_DVS1, 0x14);
  61. pmic_reg_write(p, PCA9450_BUCK1CTRL, 0x59);
  62. /* Set WDOG_B_CFG to cold reset */
  63. pmic_reg_write(p, PCA9450_RESET_CTRL, 0xA1);
  64. return 0;
  65. }
  66. void spl_board_init(void)
  67. {
  68. /* Set GIC clock to 500Mhz for OD VDD_SOC. */
  69. clock_enable(CCGR_GIC, 0);
  70. clock_set_target_val(GIC_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(5));
  71. clock_enable(CCGR_GIC, 1);
  72. }
  73. int board_fit_config_name_match(const char *name)
  74. {
  75. return 0;
  76. }
  77. void board_init_f(ulong dummy)
  78. {
  79. int ret;
  80. arch_cpu_init();
  81. init_uart_clk(0);
  82. ret = spl_early_init();
  83. if (ret) {
  84. debug("spl_early_init() failed: %d\n", ret);
  85. hang();
  86. }
  87. preloader_console_init();
  88. enable_tzc380();
  89. setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
  90. power_init_board();
  91. /* DDR initialization */
  92. spl_dram_init();
  93. }