fm_eth.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright 2009-2012 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #ifndef __FM_ETH_H__
  20. #define __FM_ETH_H__
  21. #include <common.h>
  22. #include <asm/types.h>
  23. #include <asm/fsl_enet.h>
  24. enum fm_port {
  25. FM1_DTSEC1,
  26. FM1_DTSEC2,
  27. FM1_DTSEC3,
  28. FM1_DTSEC4,
  29. FM1_DTSEC5,
  30. FM1_DTSEC6,
  31. FM1_DTSEC9,
  32. FM1_DTSEC10,
  33. FM1_10GEC1,
  34. FM1_10GEC2,
  35. FM2_DTSEC1,
  36. FM2_DTSEC2,
  37. FM2_DTSEC3,
  38. FM2_DTSEC4,
  39. FM2_DTSEC5,
  40. FM2_DTSEC6,
  41. FM2_DTSEC9,
  42. FM2_DTSEC10,
  43. FM2_10GEC1,
  44. FM2_10GEC2,
  45. NUM_FM_PORTS,
  46. };
  47. enum fm_eth_type {
  48. FM_ETH_1G_E,
  49. FM_ETH_10G_E,
  50. };
  51. #ifdef CONFIG_SYS_FMAN_V3
  52. #define CONFIG_SYS_FM1_DTSEC_MDIO_ADDR (CONFIG_SYS_FSL_FM1_ADDR + 0xfc000)
  53. #define CONFIG_SYS_FM1_TGEC_MDIO_ADDR (CONFIG_SYS_FSL_FM1_ADDR + 0xfd000)
  54. #define CONFIG_SYS_FM2_DTSEC_MDIO_ADDR (CONFIG_SYS_FSL_FM2_ADDR + 0xfc000)
  55. #define CONFIG_SYS_FM2_TGEC_MDIO_ADDR (CONFIG_SYS_FSL_FM2_ADDR + 0xfd000)
  56. #else
  57. #define CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR (CONFIG_SYS_FSL_FM1_ADDR + 0xe1120)
  58. #define CONFIG_SYS_FM1_TGEC_MDIO_ADDR (CONFIG_SYS_FSL_FM1_ADDR + 0xf1000)
  59. #endif
  60. #define DEFAULT_FM_MDIO_NAME "FSL_MDIO0"
  61. #define DEFAULT_FM_TGEC_MDIO_NAME "FM_TGEC_MDIO"
  62. /* Fman ethernet info struct */
  63. #define FM_ETH_INFO_INITIALIZER(idx, pregs) \
  64. .fm = idx, \
  65. .phy_regs = (void *)pregs, \
  66. .enet_if = PHY_INTERFACE_MODE_NONE, \
  67. #ifdef CONFIG_SYS_FMAN_V3
  68. #define FM_DTSEC_INFO_INITIALIZER(idx, n) \
  69. { \
  70. FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_DTSEC_MDIO_ADDR) \
  71. .index = idx, \
  72. .num = n - 1, \
  73. .type = FM_ETH_1G_E, \
  74. .port = FM##idx##_DTSEC##n, \
  75. .rx_port_id = RX_PORT_1G_BASE + n - 1, \
  76. .tx_port_id = TX_PORT_1G_BASE + n - 1, \
  77. .compat_offset = CONFIG_SYS_FSL_FM##idx##_OFFSET + \
  78. offsetof(struct ccsr_fman, memac[n-1]),\
  79. }
  80. #define FM_TGEC_INFO_INITIALIZER(idx, n) \
  81. { \
  82. FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM2_TGEC_MDIO_ADDR) \
  83. .index = idx, \
  84. .num = n - 1, \
  85. .type = FM_ETH_10G_E, \
  86. .port = FM##idx##_10GEC##n, \
  87. .rx_port_id = RX_PORT_10G_BASE + n - 1, \
  88. .tx_port_id = TX_PORT_10G_BASE + n - 1, \
  89. .compat_offset = CONFIG_SYS_FSL_FM##idx##_OFFSET + \
  90. offsetof(struct ccsr_fman, memac[n-1+8]),\
  91. }
  92. #else
  93. #define FM_DTSEC_INFO_INITIALIZER(idx, n) \
  94. { \
  95. FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR) \
  96. .index = idx, \
  97. .num = n - 1, \
  98. .type = FM_ETH_1G_E, \
  99. .port = FM##idx##_DTSEC##n, \
  100. .rx_port_id = RX_PORT_1G_BASE + n - 1, \
  101. .tx_port_id = TX_PORT_1G_BASE + n - 1, \
  102. .compat_offset = CONFIG_SYS_FSL_FM##idx##_OFFSET + \
  103. offsetof(struct ccsr_fman, mac_1g[n-1]),\
  104. }
  105. #define FM_TGEC_INFO_INITIALIZER(idx, n) \
  106. { \
  107. FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_TGEC_MDIO_ADDR) \
  108. .index = idx, \
  109. .num = n - 1, \
  110. .type = FM_ETH_10G_E, \
  111. .port = FM##idx##_10GEC##n, \
  112. .rx_port_id = RX_PORT_10G_BASE + n - 1, \
  113. .tx_port_id = TX_PORT_10G_BASE + n - 1, \
  114. .compat_offset = CONFIG_SYS_FSL_FM##idx##_OFFSET + \
  115. offsetof(struct ccsr_fman, mac_10g[n-1]),\
  116. }
  117. #endif
  118. struct fm_eth_info {
  119. u8 enabled;
  120. u8 fm;
  121. u8 num;
  122. u8 phy_addr;
  123. int index;
  124. u16 rx_port_id;
  125. u16 tx_port_id;
  126. enum fm_port port;
  127. enum fm_eth_type type;
  128. void *phy_regs;
  129. phy_interface_t enet_if;
  130. u32 compat_offset;
  131. struct mii_dev *bus;
  132. };
  133. struct tgec_mdio_info {
  134. struct tgec_mdio_controller *regs;
  135. char *name;
  136. };
  137. struct memac_mdio_info {
  138. struct memac_mdio_controller *regs;
  139. char *name;
  140. };
  141. int fm_tgec_mdio_init(bd_t *bis, struct tgec_mdio_info *info);
  142. int fm_memac_mdio_init(bd_t *bis, struct memac_mdio_info *info);
  143. int fm_standard_init(bd_t *bis);
  144. void fman_enet_init(void);
  145. void fdt_fixup_fman_ethernet(void *fdt);
  146. phy_interface_t fm_info_get_enet_if(enum fm_port port);
  147. void fm_info_set_phy_address(enum fm_port port, int address);
  148. int fm_info_get_phy_address(enum fm_port port);
  149. void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus);
  150. void fm_disable_port(enum fm_port port);
  151. #endif