apx4devkit.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Bluegiga APX4 Development Kit
  3. *
  4. * Copyright (C) 2012 Bluegiga Technologies Oy
  5. *
  6. * Authors:
  7. * Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
  8. * Lauri Hintsala <lauri.hintsala@bluegiga.com>
  9. *
  10. * Based on m28evk.c:
  11. * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  12. * on behalf of DENX Software Engineering GmbH
  13. *
  14. * SPDX-License-Identifier: GPL-2.0+
  15. */
  16. #include <common.h>
  17. #include <asm/gpio.h>
  18. #include <asm/io.h>
  19. #include <asm/arch/imx-regs.h>
  20. #include <asm/arch/iomux-mx28.h>
  21. #include <asm/arch/clock.h>
  22. #include <asm/arch/sys_proto.h>
  23. #include <linux/mii.h>
  24. #include <miiphy.h>
  25. #include <netdev.h>
  26. #include <errno.h>
  27. DECLARE_GLOBAL_DATA_PTR;
  28. /* Functions */
  29. int board_early_init_f(void)
  30. {
  31. /* IO0 clock at 480MHz */
  32. mxs_set_ioclk(MXC_IOCLK0, 480000);
  33. /* IO1 clock at 480MHz */
  34. mxs_set_ioclk(MXC_IOCLK1, 480000);
  35. /* SSP0 clock at 96MHz */
  36. mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
  37. return 0;
  38. }
  39. int dram_init(void)
  40. {
  41. return mxs_dram_init();
  42. }
  43. int board_init(void)
  44. {
  45. /* Adress of boot parameters */
  46. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  47. return 0;
  48. }
  49. #ifdef CONFIG_CMD_MMC
  50. int board_mmc_init(bd_t *bis)
  51. {
  52. return mxsmmc_initialize(bis, 0, NULL, NULL);
  53. }
  54. #endif
  55. #ifdef CONFIG_CMD_NET
  56. #define MII_PHY_CTRL2 0x1f
  57. int fecmxc_mii_postcall(int phy)
  58. {
  59. /* change PHY RMII clock to 50MHz */
  60. miiphy_write("FEC", 0, MII_PHY_CTRL2, 0x8180);
  61. return 0;
  62. }
  63. int board_eth_init(bd_t *bis)
  64. {
  65. int ret;
  66. struct eth_device *dev;
  67. ret = cpu_eth_init(bis);
  68. if (ret) {
  69. printf("FEC MXS: Unable to init FEC clocks\n");
  70. return ret;
  71. }
  72. ret = fecmxc_initialize(bis);
  73. if (ret) {
  74. printf("FEC MXS: Unable to init FEC\n");
  75. return ret;
  76. }
  77. dev = eth_get_dev_by_name("FEC");
  78. if (!dev) {
  79. printf("FEC MXS: Unable to get FEC device entry\n");
  80. return -EINVAL;
  81. }
  82. ret = fecmxc_register_mii_postcall(dev, fecmxc_mii_postcall);
  83. if (ret) {
  84. printf("FEC MXS: Unable to register FEC MII postcall\n");
  85. return ret;
  86. }
  87. return ret;
  88. }
  89. #endif
  90. #ifdef CONFIG_SERIAL_TAG
  91. #define MXS_OCOTP_MAX_TIMEOUT 1000000
  92. void get_board_serial(struct tag_serialnr *serialnr)
  93. {
  94. struct mxs_ocotp_regs *ocotp_regs =
  95. (struct mxs_ocotp_regs *)MXS_OCOTP_BASE;
  96. serialnr->high = 0;
  97. serialnr->low = 0;
  98. writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
  99. if (mxs_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
  100. MXS_OCOTP_MAX_TIMEOUT)) {
  101. printf("MXS: Can't get serial number from OCOTP\n");
  102. return;
  103. }
  104. serialnr->low = readl(&ocotp_regs->hw_ocotp_cust3);
  105. }
  106. #endif
  107. #ifdef CONFIG_REVISION_TAG
  108. u32 get_board_rev(void)
  109. {
  110. if (getenv("revision#") != NULL)
  111. return simple_strtoul(getenv("revision#"), NULL, 10);
  112. return 0;
  113. }
  114. #endif