1210284Sjmallett/***********************license start*************** 2215990Sjmallett * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights 3215990Sjmallett * reserved. 4210284Sjmallett * 5210284Sjmallett * 6215990Sjmallett * Redistribution and use in source and binary forms, with or without 7215990Sjmallett * modification, are permitted provided that the following conditions are 8215990Sjmallett * met: 9210284Sjmallett * 10215990Sjmallett * * Redistributions of source code must retain the above copyright 11215990Sjmallett * notice, this list of conditions and the following disclaimer. 12210284Sjmallett * 13215990Sjmallett * * Redistributions in binary form must reproduce the above 14215990Sjmallett * copyright notice, this list of conditions and the following 15215990Sjmallett * disclaimer in the documentation and/or other materials provided 16215990Sjmallett * with the distribution. 17215990Sjmallett 18215990Sjmallett * * Neither the name of Cavium Networks nor the names of 19215990Sjmallett * its contributors may be used to endorse or promote products 20215990Sjmallett * derived from this software without specific prior written 21215990Sjmallett * permission. 22215990Sjmallett 23215990Sjmallett * This Software, including technical data, may be subject to U.S. export control 24215990Sjmallett * laws, including the U.S. Export Administration Act and its associated 25215990Sjmallett * regulations, and may be subject to export or import regulations in other 26215990Sjmallett * countries. 27215990Sjmallett 28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29215990Sjmallett * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR 30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38210284Sjmallett ***********************license end**************************************/ 39210284Sjmallett 40210284Sjmallett 41210284Sjmallett 42210284Sjmallett 43210284Sjmallett 44210284Sjmallett 45215990Sjmallett 46210284Sjmallett/** 47210284Sjmallett * @file 48210284Sjmallett * 49210284Sjmallett * Helper functions to abstract board specific data about 50210284Sjmallett * network ports from the rest of the cvmx-helper files. 51210284Sjmallett * 52215990Sjmallett * <hr>$Revision: 49448 $<hr> 53210284Sjmallett */ 54210284Sjmallett#ifndef __CVMX_HELPER_BOARD_H__ 55210284Sjmallett#define __CVMX_HELPER_BOARD_H__ 56210284Sjmallett 57210284Sjmallett#ifdef __cplusplus 58210284Sjmallettextern "C" { 59210284Sjmallett#endif 60210284Sjmallett 61210284Sjmallett 62210284Sjmalletttypedef enum { 63210284Sjmallett USB_CLOCK_TYPE_REF_12, 64210284Sjmallett USB_CLOCK_TYPE_REF_24, 65210284Sjmallett USB_CLOCK_TYPE_REF_48, 66210284Sjmallett USB_CLOCK_TYPE_CRYSTAL_12, 67210284Sjmallett} cvmx_helper_board_usb_clock_types_t; 68210284Sjmallett 69210284Sjmalletttypedef enum { 70210284Sjmallett set_phy_link_flags_autoneg = 0x1, 71210284Sjmallett set_phy_link_flags_flow_control_dont_touch = 0x0 << 1, 72210284Sjmallett set_phy_link_flags_flow_control_enable = 0x1 << 1, 73210284Sjmallett set_phy_link_flags_flow_control_disable = 0x2 << 1, 74210284Sjmallett set_phy_link_flags_flow_control_mask = 0x3 << 1, /* Mask for 2 bit wide flow control field */ 75210284Sjmallett} cvmx_helper_board_set_phy_link_flags_types_t; 76210284Sjmallett 77210284Sjmallett 78215990Sjmallett/* Fake IPD port, the RGMII/MII interface may use different PHY, use this 79215990Sjmallett macro to return appropriate MIX address to read the PHY. */ 80215990Sjmallett#define CVMX_HELPER_BOARD_MGMT_IPD_PORT -10 81215990Sjmallett 82210284Sjmallett/** 83210284Sjmallett * cvmx_override_board_link_get(int ipd_port) is a function 84210284Sjmallett * pointer. It is meant to allow customization of the process of 85210284Sjmallett * talking to a PHY to determine link speed. It is called every 86210284Sjmallett * time a PHY must be polled for link status. Users should set 87210284Sjmallett * this pointer to a function before calling any cvmx-helper 88210284Sjmallett * operations. 89210284Sjmallett */ 90210284Sjmallettextern cvmx_helper_link_info_t (*cvmx_override_board_link_get)(int ipd_port); 91210284Sjmallett 92210284Sjmallett/** 93210284Sjmallett * Return the MII PHY address associated with the given IPD 94210284Sjmallett * port. A result of -1 means there isn't a MII capable PHY 95210284Sjmallett * connected to this port. On chips supporting multiple MII 96210284Sjmallett * busses the bus number is encoded in bits <15:8>. 97210284Sjmallett * 98215990Sjmallett * This function must be modified for every new Octeon board. 99210284Sjmallett * Internally it uses switch statements based on the cvmx_sysinfo 100215990Sjmallett * data to determine board types and revisions. It relies on the 101210284Sjmallett * fact that every Octeon board receives a unique board type 102210284Sjmallett * enumeration from the bootloader. 103210284Sjmallett * 104210284Sjmallett * @param ipd_port Octeon IPD port to get the MII address for. 105210284Sjmallett * 106210284Sjmallett * @return MII PHY address and bus number or -1. 107210284Sjmallett */ 108210284Sjmallettextern int cvmx_helper_board_get_mii_address(int ipd_port); 109210284Sjmallett 110210284Sjmallett/** 111210284Sjmallett * This function as a board specific method of changing the PHY 112210284Sjmallett * speed, duplex, and autonegotiation. This programs the PHY and 113210284Sjmallett * not Octeon. This can be used to force Octeon's links to 114210284Sjmallett * specific settings. 115210284Sjmallett * 116210284Sjmallett * @param phy_addr The address of the PHY to program 117210284Sjmallett * @param link_flags 118210284Sjmallett * Flags to control autonegotiation. Bit 0 is autonegotiation 119215990Sjmallett * enable/disable to maintain backward compatibility. 120210284Sjmallett * @param link_info Link speed to program. If the speed is zero and autonegotiation 121210284Sjmallett * is enabled, all possible negotiation speeds are advertised. 122210284Sjmallett * 123210284Sjmallett * @return Zero on success, negative on failure 124210284Sjmallett */ 125210284Sjmallettint cvmx_helper_board_link_set_phy(int phy_addr, cvmx_helper_board_set_phy_link_flags_types_t link_flags, 126210284Sjmallett cvmx_helper_link_info_t link_info); 127210284Sjmallett 128210284Sjmallett/** 129210284Sjmallett * @INTERNAL 130210284Sjmallett * This function is the board specific method of determining an 131210284Sjmallett * ethernet ports link speed. Most Octeon boards have Marvell PHYs 132210284Sjmallett * and are handled by the fall through case. This function must be 133210284Sjmallett * updated for boards that don't have the normal Marvell PHYs. 134210284Sjmallett * 135215990Sjmallett * This function must be modified for every new Octeon board. 136210284Sjmallett * Internally it uses switch statements based on the cvmx_sysinfo 137215990Sjmallett * data to determine board types and revisions. It relies on the 138210284Sjmallett * fact that every Octeon board receives a unique board type 139210284Sjmallett * enumeration from the bootloader. 140210284Sjmallett * 141210284Sjmallett * @param ipd_port IPD input port associated with the port we want to get link 142210284Sjmallett * status for. 143210284Sjmallett * 144210284Sjmallett * @return The ports link status. If the link isn't fully resolved, this must 145210284Sjmallett * return zero. 146210284Sjmallett */ 147210284Sjmallettextern cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port); 148210284Sjmallett 149210284Sjmallett/** 150210284Sjmallett * @INTERNAL 151210284Sjmallett * This function is called by cvmx_helper_interface_probe() after it 152210284Sjmallett * determines the number of ports Octeon can support on a specific 153210284Sjmallett * interface. This function is the per board location to override 154210284Sjmallett * this value. It is called with the number of ports Octeon might 155210284Sjmallett * support and should return the number of actual ports on the 156210284Sjmallett * board. 157210284Sjmallett * 158215990Sjmallett * This function must be modified for every new Octeon board. 159210284Sjmallett * Internally it uses switch statements based on the cvmx_sysinfo 160215990Sjmallett * data to determine board types and revisions. It relies on the 161210284Sjmallett * fact that every Octeon board receives a unique board type 162210284Sjmallett * enumeration from the bootloader. 163210284Sjmallett * 164210284Sjmallett * @param interface Interface to probe 165210284Sjmallett * @param supported_ports 166210284Sjmallett * Number of ports Octeon supports. 167210284Sjmallett * 168210284Sjmallett * @return Number of ports the actual board supports. Many times this will 169210284Sjmallett * simple be "support_ports". 170210284Sjmallett */ 171210284Sjmallettextern int __cvmx_helper_board_interface_probe(int interface, int supported_ports); 172210284Sjmallett 173210284Sjmallett/** 174210284Sjmallett * @INTERNAL 175210284Sjmallett * Enable packet input/output from the hardware. This function is 176210284Sjmallett * called after by cvmx_helper_packet_hardware_enable() to 177210284Sjmallett * perform board specific initialization. For most boards 178210284Sjmallett * nothing is needed. 179210284Sjmallett * 180210284Sjmallett * @param interface Interface to enable 181210284Sjmallett * 182210284Sjmallett * @return Zero on success, negative on failure 183210284Sjmallett */ 184210284Sjmallettextern int __cvmx_helper_board_hardware_enable(int interface); 185210284Sjmallett 186210284Sjmallett 187210284Sjmallett 188210284Sjmallett 189210284Sjmallett/** 190210284Sjmallett * @INTERNAL 191210284Sjmallett * Gets the clock type used for the USB block based on board type. 192210284Sjmallett * Used by the USB code for auto configuration of clock type. 193210284Sjmallett * 194210284Sjmallett * @return USB clock type enumeration 195210284Sjmallett */ 196210284Sjmallettcvmx_helper_board_usb_clock_types_t __cvmx_helper_board_usb_get_clock_type(void); 197210284Sjmallett 198210284Sjmallett 199210284Sjmallett/** 200210284Sjmallett * @INTERNAL 201210284Sjmallett * Adjusts the number of available USB ports on Octeon based on board 202210284Sjmallett * specifics. 203215990Sjmallett * 204210284Sjmallett * @param supported_ports expected number of ports based on chip type; 205210284Sjmallett * 206215990Sjmallett * 207210284Sjmallett * @return number of available usb ports, based on board specifics. 208210284Sjmallett * Return value is supported_ports if function does not 209210284Sjmallett * override. 210210284Sjmallett */ 211210284Sjmallettint __cvmx_helper_board_usb_get_num_ports(int supported_ports); 212210284Sjmallett 213210284Sjmallett#ifdef __cplusplus 214210284Sjmallett} 215210284Sjmallett#endif 216210284Sjmallett 217210284Sjmallett#endif /* __CVMX_HELPER_BOARD_H__ */ 218