warp7.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright (C) 2016 NXP Semiconductors
  3. * Author: Fabio Estevam <fabio.estevam@nxp.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <asm/arch/clock.h>
  8. #include <asm/arch/imx-regs.h>
  9. #include <asm/arch/mx7-pins.h>
  10. #include <asm/arch/sys_proto.h>
  11. #include <asm/gpio.h>
  12. #include <asm/imx-common/iomux-v3.h>
  13. #include <asm/imx-common/mxc_i2c.h>
  14. #include <asm/io.h>
  15. #include <common.h>
  16. #include <fsl_esdhc.h>
  17. #include <i2c.h>
  18. #include <mmc.h>
  19. #include <asm/arch/crm_regs.h>
  20. #include <usb.h>
  21. #include <netdev.h>
  22. #include <power/pmic.h>
  23. #include <power/pfuze3000_pmic.h>
  24. #include "../freescale/common/pfuze.h"
  25. DECLARE_GLOBAL_DATA_PTR;
  26. #define UART_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU100KOHM | \
  27. PAD_CTL_HYS)
  28. #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
  29. PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM)
  30. #define I2C_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
  31. PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU100KOHM)
  32. #ifdef CONFIG_SYS_I2C_MXC
  33. #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
  34. /* I2C1 for PMIC */
  35. static struct i2c_pads_info i2c_pad_info1 = {
  36. .scl = {
  37. .i2c_mode = MX7D_PAD_I2C1_SCL__I2C1_SCL | PC,
  38. .gpio_mode = MX7D_PAD_I2C1_SCL__GPIO4_IO8 | PC,
  39. .gp = IMX_GPIO_NR(4, 8),
  40. },
  41. .sda = {
  42. .i2c_mode = MX7D_PAD_I2C1_SDA__I2C1_SDA | PC,
  43. .gpio_mode = MX7D_PAD_I2C1_SDA__GPIO4_IO9 | PC,
  44. .gp = IMX_GPIO_NR(4, 9),
  45. },
  46. };
  47. #endif
  48. int dram_init(void)
  49. {
  50. gd->ram_size = PHYS_SDRAM_SIZE;
  51. return 0;
  52. }
  53. static iomux_v3_cfg_t const wdog_pads[] = {
  54. MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
  55. };
  56. static iomux_v3_cfg_t const uart1_pads[] = {
  57. MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
  58. MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
  59. };
  60. static iomux_v3_cfg_t const usdhc3_pads[] = {
  61. MX7D_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  62. MX7D_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  63. MX7D_PAD_SD3_DATA0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  64. MX7D_PAD_SD3_DATA1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  65. MX7D_PAD_SD3_DATA2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  66. MX7D_PAD_SD3_DATA3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  67. MX7D_PAD_SD3_DATA4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  68. MX7D_PAD_SD3_DATA5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  69. MX7D_PAD_SD3_DATA6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  70. MX7D_PAD_SD3_DATA7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  71. MX7D_PAD_SD3_RESET_B__SD3_RESET_B | MUX_PAD_CTRL(USDHC_PAD_CTRL),
  72. };
  73. static void setup_iomux_uart(void)
  74. {
  75. imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
  76. };
  77. static struct fsl_esdhc_cfg usdhc_cfg[1] = {
  78. {USDHC3_BASE_ADDR},
  79. };
  80. int board_mmc_getcd(struct mmc *mmc)
  81. {
  82. /* Assume uSDHC3 emmc is always present */
  83. return 1;
  84. }
  85. int board_mmc_init(bd_t *bis)
  86. {
  87. imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
  88. usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
  89. return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
  90. }
  91. int board_early_init_f(void)
  92. {
  93. setup_iomux_uart();
  94. return 0;
  95. }
  96. #ifdef CONFIG_POWER
  97. #define I2C_PMIC 0
  98. static struct pmic *pfuze;
  99. int power_init_board(void)
  100. {
  101. int ret;
  102. unsigned int reg, rev_id;
  103. ret = power_pfuze3000_init(I2C_PMIC);
  104. if (ret)
  105. return ret;
  106. pfuze = pmic_get("PFUZE3000");
  107. ret = pmic_probe(pfuze);
  108. if (ret)
  109. return ret;
  110. pmic_reg_read(pfuze, PFUZE3000_DEVICEID, &reg);
  111. pmic_reg_read(pfuze, PFUZE3000_REVID, &rev_id);
  112. printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev_id);
  113. /* disable Low Power Mode during standby mode */
  114. pmic_reg_write(pfuze, PFUZE3000_LDOGCTL, 0x1);
  115. return 0;
  116. }
  117. #endif
  118. int board_eth_init(bd_t *bis)
  119. {
  120. int ret = 0;
  121. #ifdef CONFIG_USB_ETHER
  122. ret = usb_eth_initialize(bis);
  123. if (ret < 0)
  124. printf("Error %d registering USB ether.\n", ret);
  125. #endif
  126. return ret;
  127. }
  128. int board_init(void)
  129. {
  130. /* address of boot parameters */
  131. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  132. #ifdef CONFIG_SYS_I2C_MXC
  133. setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
  134. #endif
  135. return 0;
  136. }
  137. int checkboard(void)
  138. {
  139. char *mode;
  140. if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
  141. mode = "secure";
  142. else
  143. mode = "non-secure";
  144. printf("Board: WARP7 in %s mode\n", mode);
  145. return 0;
  146. }
  147. int board_usb_phy_mode(int port)
  148. {
  149. return USB_INIT_DEVICE;
  150. }
  151. int board_late_init(void)
  152. {
  153. struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
  154. imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
  155. set_wdog_reset(wdog);
  156. /*
  157. * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
  158. * since we use PMIC_PWRON to reset the board.
  159. */
  160. clrsetbits_le16(&wdog->wcr, 0, 0x10);
  161. return 0;
  162. }