warp7.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 NXP Semiconductors
  4. * Author: Fabio Estevam <fabio.estevam@nxp.com>
  5. */
  6. #include <init.h>
  7. #include <net.h>
  8. #include <asm/arch/clock.h>
  9. #include <asm/arch/imx-regs.h>
  10. #include <asm/arch/mx7-pins.h>
  11. #include <asm/arch/sys_proto.h>
  12. #include <asm/global_data.h>
  13. #include <asm/gpio.h>
  14. #include <asm/mach-imx/hab.h>
  15. #include <asm/mach-imx/iomux-v3.h>
  16. #include <asm/io.h>
  17. #include <common.h>
  18. #include <env.h>
  19. #include <asm/arch/crm_regs.h>
  20. #include <netdev.h>
  21. #include <power/pmic.h>
  22. #include <power/pfuze3000_pmic.h>
  23. #include "../freescale/common/pfuze.h"
  24. #include <asm/setup.h>
  25. #include <asm/bootm.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. #define UART_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU100KOHM | \
  28. PAD_CTL_HYS)
  29. int dram_init(void)
  30. {
  31. gd->ram_size = PHYS_SDRAM_SIZE;
  32. /* Subtract the defined OPTEE runtime firmware length */
  33. #ifdef CONFIG_OPTEE_TZDRAM_SIZE
  34. gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
  35. #endif
  36. return 0;
  37. }
  38. static iomux_v3_cfg_t const wdog_pads[] = {
  39. MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
  40. };
  41. static iomux_v3_cfg_t const uart1_pads[] = {
  42. MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
  43. MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
  44. };
  45. static void setup_iomux_uart(void)
  46. {
  47. imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
  48. };
  49. int board_early_init_f(void)
  50. {
  51. setup_iomux_uart();
  52. return 0;
  53. }
  54. #ifdef CONFIG_DM_PMIC
  55. int power_init_board(void)
  56. {
  57. struct udevice *dev;
  58. int ret, dev_id, rev_id;
  59. ret = pmic_get("pfuze3000@8", &dev);
  60. if (ret == -ENODEV)
  61. return 0;
  62. if (ret != 0)
  63. return ret;
  64. dev_id = pmic_reg_read(dev, PFUZE3000_DEVICEID);
  65. rev_id = pmic_reg_read(dev, PFUZE3000_REVID);
  66. printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
  67. /* disable Low Power Mode during standby mode */
  68. pmic_reg_write(dev, PFUZE3000_LDOGCTL, 1);
  69. return 0;
  70. }
  71. #endif
  72. int board_eth_init(struct bd_info *bis)
  73. {
  74. int ret = 0;
  75. #ifdef CONFIG_USB_ETHER
  76. ret = usb_eth_initialize(bis);
  77. if (ret < 0)
  78. printf("Error %d registering USB ether.\n", ret);
  79. #endif
  80. return ret;
  81. }
  82. int board_init(void)
  83. {
  84. /* address of boot parameters */
  85. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  86. return 0;
  87. }
  88. int checkboard(void)
  89. {
  90. char *mode;
  91. if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
  92. mode = "secure";
  93. else
  94. mode = "non-secure";
  95. #ifdef CONFIG_OPTEE_TZDRAM_SIZE
  96. unsigned long optee_start, optee_end;
  97. optee_end = PHYS_SDRAM + PHYS_SDRAM_SIZE;
  98. optee_start = optee_end - CONFIG_OPTEE_TZDRAM_SIZE;
  99. printf("Board: WARP7 in %s mode OPTEE DRAM 0x%08lx-0x%08lx\n",
  100. mode, optee_start, optee_end);
  101. #else
  102. printf("Board: WARP7 in %s mode\n", mode);
  103. #endif
  104. return 0;
  105. }
  106. int board_late_init(void)
  107. {
  108. struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
  109. #ifdef CONFIG_SERIAL_TAG
  110. struct tag_serialnr serialnr;
  111. char serial_string[0x20];
  112. #endif
  113. imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
  114. set_wdog_reset(wdog);
  115. /*
  116. * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
  117. * since we use PMIC_PWRON to reset the board.
  118. */
  119. clrsetbits_le16(&wdog->wcr, 0, 0x10);
  120. #ifdef CONFIG_IMX_HAB
  121. /* Determine HAB state */
  122. env_set_ulong(HAB_ENABLED_ENVNAME, imx_hab_is_enabled());
  123. #else
  124. env_set_ulong(HAB_ENABLED_ENVNAME, 0);
  125. #endif
  126. #ifdef CONFIG_SERIAL_TAG
  127. /* Set serial# standard environment variable based on OTP settings */
  128. get_board_serial(&serialnr);
  129. snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%08x%08x",
  130. serialnr.low, serialnr.high);
  131. env_set("serial#", serial_string);
  132. #endif
  133. return 0;
  134. }