cvmx-helper-board.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: support@caviumnetworks.com
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2008 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. /**
  28. *
  29. * Helper functions to abstract board specific data about
  30. * network ports from the rest of the cvmx-helper files.
  31. *
  32. */
  33. #ifndef __CVMX_HELPER_BOARD_H__
  34. #define __CVMX_HELPER_BOARD_H__
  35. #include <asm/octeon/cvmx-helper.h>
  36. enum cvmx_helper_board_usb_clock_types {
  37. USB_CLOCK_TYPE_REF_12,
  38. USB_CLOCK_TYPE_REF_24,
  39. USB_CLOCK_TYPE_REF_48,
  40. USB_CLOCK_TYPE_CRYSTAL_12,
  41. };
  42. typedef enum {
  43. set_phy_link_flags_autoneg = 0x1,
  44. set_phy_link_flags_flow_control_dont_touch = 0x0 << 1,
  45. set_phy_link_flags_flow_control_enable = 0x1 << 1,
  46. set_phy_link_flags_flow_control_disable = 0x2 << 1,
  47. set_phy_link_flags_flow_control_mask = 0x3 << 1, /* Mask for 2 bit wide flow control field */
  48. } cvmx_helper_board_set_phy_link_flags_types_t;
  49. /*
  50. * Fake IPD port, the RGMII/MII interface may use different PHY, use
  51. * this macro to return appropriate MIX address to read the PHY.
  52. */
  53. #define CVMX_HELPER_BOARD_MGMT_IPD_PORT -10
  54. /**
  55. * cvmx_override_board_link_get(int ipd_port) is a function
  56. * pointer. It is meant to allow customization of the process of
  57. * talking to a PHY to determine link speed. It is called every
  58. * time a PHY must be polled for link status. Users should set
  59. * this pointer to a function before calling any cvmx-helper
  60. * operations.
  61. */
  62. extern cvmx_helper_link_info_t(*cvmx_override_board_link_get) (int ipd_port);
  63. /**
  64. * Return the MII PHY address associated with the given IPD
  65. * port. A result of -1 means there isn't a MII capable PHY
  66. * connected to this port. On chips supporting multiple MII
  67. * busses the bus number is encoded in bits <15:8>.
  68. *
  69. * This function must be modifed for every new Octeon board.
  70. * Internally it uses switch statements based on the cvmx_sysinfo
  71. * data to determine board types and revisions. It relys on the
  72. * fact that every Octeon board receives a unique board type
  73. * enumeration from the bootloader.
  74. *
  75. * @ipd_port: Octeon IPD port to get the MII address for.
  76. *
  77. * Returns MII PHY address and bus number or -1.
  78. */
  79. extern int cvmx_helper_board_get_mii_address(int ipd_port);
  80. /**
  81. * This function as a board specific method of changing the PHY
  82. * speed, duplex, and autonegotiation. This programs the PHY and
  83. * not Octeon. This can be used to force Octeon's links to
  84. * specific settings.
  85. *
  86. * @phy_addr: The address of the PHY to program
  87. * @link_flags:
  88. * Flags to control autonegotiation. Bit 0 is autonegotiation
  89. * enable/disable to maintain backware compatibility.
  90. * @link_info: Link speed to program. If the speed is zero and autonegotiation
  91. * is enabled, all possible negotiation speeds are advertised.
  92. *
  93. * Returns Zero on success, negative on failure
  94. */
  95. int cvmx_helper_board_link_set_phy(int phy_addr,
  96. cvmx_helper_board_set_phy_link_flags_types_t
  97. link_flags,
  98. cvmx_helper_link_info_t link_info);
  99. /**
  100. * This function is the board specific method of determining an
  101. * ethernet ports link speed. Most Octeon boards have Marvell PHYs
  102. * and are handled by the fall through case. This function must be
  103. * updated for boards that don't have the normal Marvell PHYs.
  104. *
  105. * This function must be modifed for every new Octeon board.
  106. * Internally it uses switch statements based on the cvmx_sysinfo
  107. * data to determine board types and revisions. It relys on the
  108. * fact that every Octeon board receives a unique board type
  109. * enumeration from the bootloader.
  110. *
  111. * @ipd_port: IPD input port associated with the port we want to get link
  112. * status for.
  113. *
  114. * Returns The ports link status. If the link isn't fully resolved, this must
  115. * return zero.
  116. */
  117. extern cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port);
  118. /**
  119. * This function is called by cvmx_helper_interface_probe() after it
  120. * determines the number of ports Octeon can support on a specific
  121. * interface. This function is the per board location to override
  122. * this value. It is called with the number of ports Octeon might
  123. * support and should return the number of actual ports on the
  124. * board.
  125. *
  126. * This function must be modifed for every new Octeon board.
  127. * Internally it uses switch statements based on the cvmx_sysinfo
  128. * data to determine board types and revisions. It relys on the
  129. * fact that every Octeon board receives a unique board type
  130. * enumeration from the bootloader.
  131. *
  132. * @interface: Interface to probe
  133. * @supported_ports:
  134. * Number of ports Octeon supports.
  135. *
  136. * Returns Number of ports the actual board supports. Many times this will
  137. * simple be "support_ports".
  138. */
  139. extern int __cvmx_helper_board_interface_probe(int interface,
  140. int supported_ports);
  141. /**
  142. * Enable packet input/output from the hardware. This function is
  143. * called after by cvmx_helper_packet_hardware_enable() to
  144. * perform board specific initialization. For most boards
  145. * nothing is needed.
  146. *
  147. * @interface: Interface to enable
  148. *
  149. * Returns Zero on success, negative on failure
  150. */
  151. extern int __cvmx_helper_board_hardware_enable(int interface);
  152. enum cvmx_helper_board_usb_clock_types __cvmx_helper_board_usb_get_clock_type(void);
  153. #endif /* __CVMX_HELPER_BOARD_H__ */