apx4devkit.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. */
  27. #include <common.h>
  28. #include <asm/gpio.h>
  29. #include <asm/io.h>
  30. #include <asm/arch/imx-regs.h>
  31. #include <asm/arch/iomux-mx28.h>
  32. #include <asm/arch/clock.h>
  33. #include <asm/arch/sys_proto.h>
  34. #include <linux/mii.h>
  35. #include <miiphy.h>
  36. #include <netdev.h>
  37. #include <errno.h>
  38. DECLARE_GLOBAL_DATA_PTR;
  39. /* Functions */
  40. int board_early_init_f(void)
  41. {
  42. /* IO0 clock at 480MHz */
  43. mx28_set_ioclk(MXC_IOCLK0, 480000);
  44. /* IO1 clock at 480MHz */
  45. mx28_set_ioclk(MXC_IOCLK1, 480000);
  46. /* SSP0 clock at 96MHz */
  47. mx28_set_sspclk(MXC_SSPCLK0, 96000, 0);
  48. return 0;
  49. }
  50. int dram_init(void)
  51. {
  52. return mx28_dram_init();
  53. }
  54. int board_init(void)
  55. {
  56. /* Adress of boot parameters */
  57. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  58. return 0;
  59. }
  60. #ifdef CONFIG_CMD_MMC
  61. int board_mmc_init(bd_t *bis)
  62. {
  63. return mxsmmc_initialize(bis, 0, NULL);
  64. }
  65. #endif
  66. #ifdef CONFIG_CMD_NET
  67. #define MII_PHY_CTRL2 0x1f
  68. int fecmxc_mii_postcall(int phy)
  69. {
  70. /* change PHY RMII clock to 50MHz */
  71. miiphy_write("FEC", 0, MII_PHY_CTRL2, 0x8180);
  72. return 0;
  73. }
  74. int board_eth_init(bd_t *bis)
  75. {
  76. int ret;
  77. struct eth_device *dev;
  78. ret = cpu_eth_init(bis);
  79. if (ret) {
  80. printf("FEC MXS: Unable to init FEC clocks\n");
  81. return ret;
  82. }
  83. ret = fecmxc_initialize(bis);
  84. if (ret) {
  85. printf("FEC MXS: Unable to init FEC\n");
  86. return ret;
  87. }
  88. dev = eth_get_dev_by_name("FEC");
  89. if (!dev) {
  90. printf("FEC MXS: Unable to get FEC device entry\n");
  91. return -EINVAL;
  92. }
  93. ret = fecmxc_register_mii_postcall(dev, fecmxc_mii_postcall);
  94. if (ret) {
  95. printf("FEC MXS: Unable to register FEC MII postcall\n");
  96. return ret;
  97. }
  98. return ret;
  99. }
  100. #endif
  101. #ifdef CONFIG_SERIAL_TAG
  102. #define MXS_OCOTP_MAX_TIMEOUT 1000000
  103. void get_board_serial(struct tag_serialnr *serialnr)
  104. {
  105. struct mxs_ocotp_regs *ocotp_regs =
  106. (struct mxs_ocotp_regs *)MXS_OCOTP_BASE;
  107. serialnr->high = 0;
  108. serialnr->low = 0;
  109. writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set);
  110. if (mxs_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY,
  111. MXS_OCOTP_MAX_TIMEOUT)) {
  112. printf("MXS: Can't get serial number from OCOTP\n");
  113. return;
  114. }
  115. serialnr->low = readl(&ocotp_regs->hw_ocotp_cust3);
  116. }
  117. #endif
  118. #ifdef CONFIG_REVISION_TAG
  119. u32 get_board_rev(void)
  120. {
  121. if (getenv("revision#") != NULL)
  122. return simple_strtoul(getenv("revision#"), NULL, 10);
  123. return 0;
  124. }
  125. #endif