1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) 2020 Marvell International Ltd. 4 * 5 * Helper Functions for the Configuration Framework 6 * 7 * OCTEON_CN68XX introduces a flexible hw interface configuration 8 * scheme. To cope with this change and the requirements of 9 * configurability for other system resources, e.g., IPD/PIP pknd and 10 * PKO ports and queues, a configuration framework for the SDK is 11 * designed. It has two goals: first to recognize and establish the 12 * default configuration and, second, to allow the user to define key 13 * parameters in a high-level language. 14 * 15 * The helper functions query the QLM setup to help achieving the 16 * first goal. 17 * 18 * The second goal is accomplished by generating 19 * cvmx_helper_cfg_init() from a high-level lanaguage. 20 */ 21 22#ifndef __CVMX_HELPER_CFG_H__ 23#define __CVMX_HELPER_CFG_H__ 24 25#include "cvmx-helper-util.h" 26 27#define CVMX_HELPER_CFG_MAX_PKO_PORT 128 28#define CVMX_HELPER_CFG_MAX_PIP_BPID 64 29#define CVMX_HELPER_CFG_MAX_PIP_PKND 64 30#define CVMX_HELPER_CFG_MAX_PKO_QUEUES 256 31#define CVMX_HELPER_CFG_MAX_PORT_PER_IFACE 256 32 33#define CVMX_HELPER_CFG_INVALID_VALUE -1 34 35#define cvmx_helper_cfg_assert(cond) \ 36 do { \ 37 if (!(cond)) { \ 38 debug("cvmx_helper_cfg_assert (%s) at %s:%d\n", #cond, __FILE__, \ 39 __LINE__); \ 40 } \ 41 } while (0) 42 43extern int cvmx_npi_max_pknds; 44 45/* 46 * Config Options 47 * 48 * These options have to be set via cvmx_helper_cfg_opt_set() before calling the 49 * routines that set up the hw. These routines process the options and set them 50 * correctly to take effect at runtime. 51 */ 52enum cvmx_helper_cfg_option { 53 CVMX_HELPER_CFG_OPT_USE_DWB, /* 54 * Global option to control if 55 * the SDK configures units (DMA, 56 * SSO, and PKO) to send don't 57 * write back (DWB) requests for 58 * freed buffers. Set to 1/0 to 59 * enable/disable DWB. 60 * 61 * For programs that fit inside 62 * L2, sending DWB just causes 63 * more L2 operations without 64 * benefit. 65 */ 66 67 CVMX_HELPER_CFG_OPT_MAX 68}; 69 70typedef enum cvmx_helper_cfg_option cvmx_helper_cfg_option_t; 71 72struct cvmx_phy_info; 73struct cvmx_fdt_sfp_info; 74struct cvmx_vsc7224_chan; 75struct phy_device; 76 77struct cvmx_srio_port_param { 78 /** True to override SRIO CTLE zero setting */ 79 bool srio_rx_ctle_zero_override : 1; 80 /** Equalization peaking control dft: 6 */ 81 u8 srio_rx_ctle_zero : 4; 82 /** Set true to override CTLE taps */ 83 bool srio_rx_ctle_agc_override : 1; 84 u8 srio_rx_agc_pre_ctle : 4; /** AGC pre-CTLE gain */ 85 u8 srio_rx_agc_post_ctle : 4; /** AGC post-CTLE gain */ 86 bool srio_tx_swing_override : 1; /** True to override TX Swing */ 87 u8 srio_tx_swing : 5; /** TX Swing */ 88 bool srio_tx_gain_override : 1; /** True to override TX gain */ 89 u8 srio_tx_gain : 3; /** TX gain */ 90 bool srio_tx_premptap_override : 1; /** True to override premptap values */ 91 u8 srio_tx_premptap_pre : 4; /** Pre premptap value */ 92 u8 srio_tx_premptap_post : 5; /** Post premptap value */ 93 bool srio_tx_vboost_override : 1; /** True to override TX vboost setting */ 94 bool srio_tx_vboost : 1; /** vboost setting (default 1) */ 95}; 96 97/* 98 * Per physical port 99 * Note: This struct is passed between linux and SE apps. 100 */ 101struct cvmx_cfg_port_param { 102 int port_fdt_node; /** Node offset in FDT of node */ 103 int phy_fdt_node; /** Node offset in FDT of PHY */ 104 struct cvmx_phy_info *phy_info; /** Data structure with PHY information */ 105 int8_t ccpp_pknd; 106 int8_t ccpp_bpid; 107 int8_t ccpp_pko_port_base; 108 int8_t ccpp_pko_num_ports; 109 u8 agl_rx_clk_skew; /** AGL rx clock skew setting (default 0) */ 110 u8 rgmii_tx_clk_delay; /** RGMII TX clock delay value if not bypassed */ 111 bool valid : 1; /** 1 = port valid, 0 = invalid */ 112 bool sgmii_phy_mode : 1; /** 1 = port in PHY mode, 0 = MAC mode */ 113 bool sgmii_1000x_mode : 1; /** 1 = 1000Base-X mode, 0 = SGMII mode */ 114 bool agl_rx_clk_delay_bypass : 1; /** 1 = use rx clock delay bypass for AGL mode */ 115 bool force_link_up : 1; /** Ignore PHY and always report link up */ 116 bool disable_an : 1; /** true to disable autonegotiation */ 117 bool link_down_pwr_dn : 1; /** Power PCS off when link is down */ 118 bool phy_present : 1; /** true if PHY is present */ 119 bool tx_clk_delay_bypass : 1; /** True to bypass the TX clock delay */ 120 bool enable_fec : 1; /** True to enable FEC for 10/40G links */ 121 /** Settings for short-run SRIO host */ 122 struct cvmx_srio_port_param srio_short; 123 /** Settings for long-run SRIO host */ 124 struct cvmx_srio_port_param srio_long; 125 u8 agl_refclk_sel; /** RGMII refclk select to use */ 126 /** Set if local (non-PHY) LEDs are used */ 127 struct cvmx_phy_gpio_leds *gpio_leds; 128 struct cvmx_fdt_sfp_info *sfp_info; /** SFP+/QSFP info for port */ 129 /** Offset of SFP/SFP+/QSFP slot in device tree */ 130 int sfp_of_offset; 131 /** Microsemi VSC7224 channel info data structure */ 132 struct cvmx_vsc7224_chan *vsc7224_chan; 133 /** Avago AVSP-5410 Phy */ 134 struct cvmx_avsp5410 *avsp5410; 135 struct phy_device *phydev; 136}; 137 138/* 139 * Per pko_port 140 */ 141struct cvmx_cfg_pko_port_param { 142 s16 ccppp_queue_base; 143 s16 ccppp_num_queues; 144}; 145 146/* 147 * A map from pko_port to 148 * interface, 149 * index, and 150 * pko engine id 151 */ 152struct cvmx_cfg_pko_port_map { 153 s16 ccppl_interface; 154 s16 ccppl_index; 155 s16 ccppl_eid; 156}; 157 158/* 159 * This is for looking up pko_base_port and pko_nport for ipd_port 160 */ 161struct cvmx_cfg_pko_port_pair { 162 int8_t ccppp_base_port; 163 int8_t ccppp_nports; 164}; 165 166typedef union cvmx_user_static_pko_queue_config { 167 struct { 168 struct pko_queues_cfg { 169 unsigned queues_per_port : 11, qos_enable : 1, pfc_enable : 1; 170 } pko_cfg_iface[6]; 171 struct pko_queues_cfg pko_cfg_loop; 172 struct pko_queues_cfg pko_cfg_npi; 173 } pknd; 174 struct { 175 u8 pko_ports_per_interface[5]; 176 u8 pko_queues_per_port_interface[5]; 177 u8 pko_queues_per_port_loop; 178 u8 pko_queues_per_port_pci; 179 u8 pko_queues_per_port_srio[4]; 180 } non_pknd; 181} cvmx_user_static_pko_queue_config_t; 182 183extern cvmx_user_static_pko_queue_config_t __cvmx_pko_queue_static_config[CVMX_MAX_NODES]; 184extern struct cvmx_cfg_pko_port_map cvmx_cfg_pko_port_map[CVMX_HELPER_CFG_MAX_PKO_PORT]; 185extern struct cvmx_cfg_port_param cvmx_cfg_port[CVMX_MAX_NODES][CVMX_HELPER_MAX_IFACE] 186 [CVMX_HELPER_CFG_MAX_PORT_PER_IFACE]; 187extern struct cvmx_cfg_pko_port_param cvmx_pko_queue_table[]; 188extern int cvmx_enable_helper_flag; 189 190/* 191 * @INTERNAL 192 * Return configured pknd for the port 193 * 194 * @param interface the interface number 195 * @param index the port's index number 196 * @return the pknd 197 */ 198int __cvmx_helper_cfg_pknd(int interface, int index); 199 200/* 201 * @INTERNAL 202 * Return the configured bpid for the port 203 * 204 * @param interface the interface number 205 * @param index the port's index number 206 * @return the bpid 207 */ 208int __cvmx_helper_cfg_bpid(int interface, int index); 209 210/** 211 * @INTERNAL 212 * Return the configured pko_port base for the port 213 * 214 * @param interface the interface number 215 * @param index the port's index number 216 * @return the pko_port base 217 */ 218int __cvmx_helper_cfg_pko_port_base(int interface, int index); 219 220/* 221 * @INTERNAL 222 * Return the configured number of pko_ports for the port 223 * 224 * @param interface the interface number 225 * @param index the port's index number 226 * @return the number of pko_ports 227 */ 228int __cvmx_helper_cfg_pko_port_num(int interface, int index); 229 230/* 231 * @INTERNAL 232 * Return the configured pko_queue base for the pko_port 233 * 234 * @param pko_port 235 * @return the pko_queue base 236 */ 237int __cvmx_helper_cfg_pko_queue_base(int pko_port); 238 239/* 240 * @INTERNAL 241 * Return the configured number of pko_queues for the pko_port 242 * 243 * @param pko_port 244 * @return the number of pko_queues 245 */ 246int __cvmx_helper_cfg_pko_queue_num(int pko_port); 247 248/* 249 * @INTERNAL 250 * Return the interface the pko_port is configured for 251 * 252 * @param pko_port 253 * @return the interface for the pko_port 254 */ 255int __cvmx_helper_cfg_pko_port_interface(int pko_port); 256 257/* 258 * @INTERNAL 259 * Return the index of the port the pko_port is configured for 260 * 261 * @param pko_port 262 * @return the index of the port 263 */ 264int __cvmx_helper_cfg_pko_port_index(int pko_port); 265 266/* 267 * @INTERNAL 268 * Return the pko_eid of the pko_port 269 * 270 * @param pko_port 271 * @return the pko_eid 272 */ 273int __cvmx_helper_cfg_pko_port_eid(int pko_port); 274 275/* 276 * @INTERNAL 277 * Return the max# of pko queues allocated. 278 * 279 * @return the max# of pko queues 280 * 281 * Note: there might be holes in the queue space depending on user 282 * configuration. The function returns the highest queue's index in 283 * use. 284 */ 285int __cvmx_helper_cfg_pko_max_queue(void); 286 287/* 288 * @INTERNAL 289 * Return the max# of PKO DMA engines allocated. 290 * 291 * @return the max# of DMA engines 292 * 293 * NOTE: the DMA engines are allocated contiguously and starting from 294 * 0. 295 */ 296int __cvmx_helper_cfg_pko_max_engine(void); 297 298/* 299 * Get the value set for the config option ``opt''. 300 * 301 * @param opt is the config option. 302 * @return the value set for the option 303 * 304 * LR: only used for DWB in NPI, POW, PKO1 305 */ 306u64 cvmx_helper_cfg_opt_get(cvmx_helper_cfg_option_t opt); 307 308/* 309 * Set the value for a config option. 310 * 311 * @param opt is the config option. 312 * @param val is the value to set for the opt. 313 * @return 0 for success and -1 on error 314 * 315 * Note an option here is a config-time parameter and this means that 316 * it has to be set before calling the corresponding setup functions 317 * that actually sets the option in hw. 318 * 319 * LR: Not used. 320 */ 321int cvmx_helper_cfg_opt_set(cvmx_helper_cfg_option_t opt, u64 val); 322 323/* 324 * Retrieve the pko_port base given ipd_port. 325 * 326 * @param ipd_port is the IPD eport 327 * @return the corresponding PKO port base for the physical port 328 * represented by the IPD eport or CVMX_HELPER_CFG_INVALID_VALUE. 329 */ 330int cvmx_helper_cfg_ipd2pko_port_base(int ipd_port); 331 332/* 333 * Retrieve the number of pko_ports given ipd_port. 334 * 335 * @param ipd_port is the IPD eport 336 * @return the corresponding number of PKO ports for the physical port 337 * represented by IPD eport or CVMX_HELPER_CFG_INVALID_VALUE. 338 */ 339int cvmx_helper_cfg_ipd2pko_port_num(int ipd_port); 340 341/* 342 * @INTERNAL 343 * The init function 344 * 345 * @param node 346 * @return 0 for success. 347 * 348 * Note: this function is meant to be called to set the ``configured 349 * parameters,'' e.g., pknd, bpid, etc. and therefore should be before 350 * any of the corresponding cvmx_helper_cfg_xxxx() functions are 351 * called. 352 */ 353int __cvmx_helper_init_port_config_data(int node); 354 355/* 356 * @INTERNAL 357 * The local init function 358 * 359 * @param none 360 * @return 0 for success. 361 * 362 * Note: this function is meant to be called to set the ``configured 363 * parameters locally,'' e.g., pknd, bpid, etc. and therefore should be before 364 * any of the corresponding cvmx_helper_cfg_xxxx() functions are 365 * called. 366 */ 367int __cvmx_helper_init_port_config_data_local(void); 368 369/* 370 * Set the frame max size and jabber size to 65535. 371 * 372 */ 373void cvmx_helper_cfg_set_jabber_and_frame_max(void); 374 375/* 376 * Enable storing short packets only in the WQE. 377 */ 378void cvmx_helper_cfg_store_short_packets_in_wqe(void); 379 380/* 381 * Allocated a block of internal ports and queues for the specified 382 * interface/port 383 * 384 * @param interface the interface for which the internal ports and queues 385 * are requested 386 * @param port the index of the port within in the interface for which 387 the internal ports and queues are requested. 388 * @param pot_count the number of internal ports requested 389 * @param queue_cnt the number of queues requested for each of the internal 390 * port. This call will allocate a total of 391 * (port_cnt * queue_cnt) queues 392 * 393 * @return 0 on success 394 * -1 on failure 395 * 396 * LR: Called ONLY from comfig-parse! 397 */ 398int cvmx_pko_alloc_iport_and_queues(int interface, int port, int port_cnt, int queue_cnt); 399 400/* 401 * Free the queues that are associated with the specified port 402 * 403 * @param port the internal port for which the queues are freed. 404 * 405 * @return 0 on success 406 * -1 on failure 407 */ 408int cvmx_pko_queue_free(u64 port); 409 410/* 411 * Initializes the pko queue range data structure. 412 * @return 0 on success 413 * -1 on failure 414 */ 415int init_cvmx_pko_que_range(void); 416 417/* 418 * Frees up all the allocated ques. 419 */ 420void cvmx_pko_queue_free_all(void); 421 422/** 423 * Returns if port is valid for a given interface 424 * 425 * @param xiface interface to check 426 * @param index port index in the interface 427 * 428 * @return status of the port present or not. 429 */ 430int cvmx_helper_is_port_valid(int xiface, int index); 431 432/** 433 * Set whether or not a port is valid 434 * 435 * @param interface interface to set 436 * @param index port index to set 437 * @param valid set 0 to make port invalid, 1 for valid 438 */ 439void cvmx_helper_set_port_valid(int interface, int index, bool valid); 440 441/** 442 * @INTERNAL 443 * Return if port is in PHY mode 444 * 445 * @param interface the interface number 446 * @param index the port's index number 447 * 448 * @return 1 if port is in PHY mode, 0 if port is in MAC mode 449 */ 450bool cvmx_helper_get_mac_phy_mode(int interface, int index); 451void cvmx_helper_set_mac_phy_mode(int interface, int index, bool valid); 452 453/** 454 * @INTERNAL 455 * Return if port is in 1000Base X mode 456 * 457 * @param interface the interface number 458 * @param index the port's index number 459 * 460 * @return 1 if port is in 1000Base X mode, 0 if port is in SGMII mode 461 */ 462bool cvmx_helper_get_1000x_mode(int interface, int index); 463void cvmx_helper_set_1000x_mode(int interface, int index, bool valid); 464 465/** 466 * @INTERNAL 467 * Return if an AGL port should bypass the RX clock delay 468 * 469 * @param interface the interface number 470 * @param index the port's index number 471 */ 472bool cvmx_helper_get_agl_rx_clock_delay_bypass(int interface, int index); 473void cvmx_helper_set_agl_rx_clock_delay_bypass(int interface, int index, bool valid); 474 475/** 476 * @INTERNAL 477 * Forces a link to always return that it is up ignoring the PHY (if present) 478 * 479 * @param interface the interface number 480 * @param index the port's index 481 */ 482bool cvmx_helper_get_port_force_link_up(int interface, int index); 483void cvmx_helper_set_port_force_link_up(int interface, int index, bool value); 484 485/** 486 * @INTERNAL 487 * Return true if PHY is present to the passed xiface 488 * 489 * @param xiface the interface number 490 * @param index the port's index 491 */ 492bool cvmx_helper_get_port_phy_present(int xiface, int index); 493void cvmx_helper_set_port_phy_present(int xiface, int index, bool value); 494 495/** 496 * @INTERNAL 497 * Return the AGL port rx clock skew, only used 498 * if agl_rx_clock_delay_bypass is set. 499 * 500 * @param interface the interface number 501 * @param index the port's index number 502 */ 503u8 cvmx_helper_get_agl_rx_clock_skew(int interface, int index); 504void cvmx_helper_set_agl_rx_clock_skew(int interface, int index, u8 value); 505u8 cvmx_helper_get_agl_refclk_sel(int interface, int index); 506void cvmx_helper_set_agl_refclk_sel(int interface, int index, u8 value); 507 508/** 509 * @INTERNAL 510 * Store the FDT node offset in the device tree of a port 511 * 512 * @param xiface node and interface 513 * @param index port index 514 * @param node_offset node offset to store 515 */ 516void cvmx_helper_set_port_fdt_node_offset(int xiface, int index, int node_offset); 517 518/** 519 * @INTERNAL 520 * Return the FDT node offset in the device tree of a port 521 * 522 * @param xiface node and interface 523 * @param index port index 524 * @return node offset of port or -1 if invalid 525 */ 526int cvmx_helper_get_port_fdt_node_offset(int xiface, int index); 527 528/** 529 * @INTERNAL 530 * Store the FDT node offset in the device tree of a phy 531 * 532 * @param xiface node and interface 533 * @param index port index 534 * @param node_offset node offset to store 535 */ 536void cvmx_helper_set_phy_fdt_node_offset(int xiface, int index, int node_offset); 537 538/** 539 * @INTERNAL 540 * Return the FDT node offset in the device tree of a phy 541 * 542 * @param xiface node and interface 543 * @param index port index 544 * @return node offset of phy or -1 if invalid 545 */ 546int cvmx_helper_get_phy_fdt_node_offset(int xiface, int index); 547 548/** 549 * @INTERNAL 550 * Override default autonegotiation for a port 551 * 552 * @param xiface node and interface 553 * @param index port index 554 * @param enable true to enable autonegotiation, false to force full 555 * duplex, full speed. 556 */ 557void cvmx_helper_set_port_autonegotiation(int xiface, int index, bool enable); 558 559/** 560 * @INTERNAL 561 * Returns if autonegotiation is enabled or not. 562 * 563 * @param xiface node and interface 564 * @param index port index 565 * 566 * @return 0 if autonegotiation is disabled, 1 if enabled. 567 */ 568bool cvmx_helper_get_port_autonegotiation(int xiface, int index); 569 570/** 571 * @INTERNAL 572 * Returns if forward error correction is enabled or not. 573 * 574 * @param xiface node and interface 575 * @param index port index 576 * 577 * @return 0 if fec is disabled, 1 if enabled. 578 */ 579bool cvmx_helper_get_port_fec(int xiface, int index); 580 581/** 582 * @INTERNAL 583 * Override default forward error correction for a port 584 * 585 * @param xiface node and interface 586 * @param index port index 587 * @param enable true to enable fec, false to disable. 588 */ 589void cvmx_helper_set_port_fec(int xiface, int index, bool enable); 590 591/** 592 * @INTERNAL 593 * Configure the SRIO RX interface AGC settings in host mode 594 * 595 * @param xiface node and interface 596 * @param index lane 597 * @param long_run true for long run, false for short run 598 * @param agc_override true to put AGC in manual mode 599 * @param ctle_zero RX equalizer peaking control (default 0x6) 600 * @param agc_pre_ctle AGC pre-CTLE gain (default 0x5) 601 * @param agc_post_ctle AGC post-CTLE gain (default 0x4) 602 * 603 * NOTE: This must be called before SRIO is initialized to take effect 604 */ 605void cvmx_helper_set_srio_rx(int xiface, int index, bool long_run, bool ctle_zero_override, 606 u8 ctle_zero, bool agc_override, u8 agc_pre_ctle, u8 agc_post_ctle); 607 608/** 609 * @INTERNAL 610 * Get the SRIO RX interface AGC settings for host mode 611 * 612 * @param xiface node and interface 613 * @param index lane 614 * @param long_run true for long run, false for short run 615 * @param[out] ctle_zero_override true if overridden 616 * @param[out] ctle_zero RX equalizer peaking control (default 0x6) 617 * @param[out] agc_override true to put AGC in manual mode 618 * @param[out] agc_pre_ctle AGC pre-CTLE gain (default 0x5) 619 * @param[out] agc_post_ctle AGC post-CTLE gain (default 0x4) 620 */ 621void cvmx_helper_get_srio_rx(int xiface, int index, bool long_run, bool *ctle_zero_override, 622 u8 *ctle_zero, bool *agc_override, u8 *agc_pre_ctle, 623 u8 *agc_post_ctle); 624 625/** 626 * @INTERNAL 627 * Configure the SRIO TX interface for host mode 628 * 629 * @param xiface node and interface 630 * @param index lane 631 * @param long_run true for long run, false for short run 632 * @param tx_swing tx swing value to use (default 0x7), -1 to not 633 * override. 634 * @param tx_gain PCS SDS TX gain (default 0x3), -1 to not 635 * override 636 * @param tx_premptap_override true to override preemphasis control 637 * @param tx_premptap_pre preemphasis pre tap value (default 0x0) 638 * @param tx_premptap_post preemphasis post tap value (default 0xF) 639 * @param tx_vboost vboost enable (1 = enable, -1 = don't override) 640 * hardware default is 1. 641 * 642 * NOTE: This must be called before SRIO is initialized to take effect 643 */ 644void cvmx_helper_set_srio_tx(int xiface, int index, bool long_run, int tx_swing, int tx_gain, 645 bool tx_premptap_override, u8 tx_premptap_pre, u8 tx_premptap_post, 646 int tx_vboost); 647 648/** 649 * @INTERNAL 650 * Get the SRIO TX interface settings for host mode 651 * 652 * @param xiface node and interface 653 * @param index lane 654 * @param long_run true for long run, false for short run 655 * @param[out] tx_swing_override true to override pcs_sds_txX_swing 656 * @param[out] tx_swing tx swing value to use (default 0x7) 657 * @param[out] tx_gain_override true to override default gain 658 * @param[out] tx_gain PCS SDS TX gain (default 0x3) 659 * @param[out] tx_premptap_override true to override preemphasis control 660 * @param[out] tx_premptap_pre preemphasis pre tap value (default 0x0) 661 * @param[out] tx_premptap_post preemphasis post tap value (default 0xF) 662 * @param[out] tx_vboost_override override vboost setting 663 * @param[out] tx_vboost vboost enable (default true) 664 */ 665void cvmx_helper_get_srio_tx(int xiface, int index, bool long_run, bool *tx_swing_override, 666 u8 *tx_swing, bool *tx_gain_override, u8 *tx_gain, 667 bool *tx_premptap_override, u8 *tx_premptap_pre, u8 *tx_premptap_post, 668 bool *tx_vboost_override, bool *tx_vboost); 669 670/** 671 * @INTERNAL 672 * Sets the PHY info data structure 673 * 674 * @param xiface node and interface 675 * @param index port index 676 * @param[in] phy_info phy information data structure pointer 677 */ 678void cvmx_helper_set_port_phy_info(int xiface, int index, struct cvmx_phy_info *phy_info); 679/** 680 * @INTERNAL 681 * Returns the PHY information data structure for a port 682 * 683 * @param xiface node and interface 684 * @param index port index 685 * 686 * @return pointer to PHY information data structure or NULL if not set 687 */ 688struct cvmx_phy_info *cvmx_helper_get_port_phy_info(int xiface, int index); 689 690/** 691 * @INTERNAL 692 * Returns a pointer to the PHY LED configuration (if local GPIOs drive them) 693 * 694 * @param xiface node and interface 695 * @param index portindex 696 * 697 * @return pointer to the PHY LED information data structure or NULL if not 698 * present 699 */ 700struct cvmx_phy_gpio_leds *cvmx_helper_get_port_phy_leds(int xiface, int index); 701 702/** 703 * @INTERNAL 704 * Sets a pointer to the PHY LED configuration (if local GPIOs drive them) 705 * 706 * @param xiface node and interface 707 * @param index portindex 708 * @param leds pointer to led data structure 709 */ 710void cvmx_helper_set_port_phy_leds(int xiface, int index, struct cvmx_phy_gpio_leds *leds); 711 712/** 713 * @INTERNAL 714 * Disables RGMII TX clock bypass and sets delay value 715 * 716 * @param xiface node and interface 717 * @param index portindex 718 * @param bypass Set true to enable the clock bypass and false 719 * to sync clock and data synchronously. 720 * Default is false. 721 * @param clk_delay Delay value to skew TXC from TXD 722 */ 723void cvmx_helper_cfg_set_rgmii_tx_clk_delay(int xiface, int index, bool bypass, int clk_delay); 724 725/** 726 * @INTERNAL 727 * Gets RGMII TX clock bypass and delay value 728 * 729 * @param xiface node and interface 730 * @param index portindex 731 * @param bypass Set true to enable the clock bypass and false 732 * to sync clock and data synchronously. 733 * Default is false. 734 * @param clk_delay Delay value to skew TXC from TXD, default is 0. 735 */ 736void cvmx_helper_cfg_get_rgmii_tx_clk_delay(int xiface, int index, bool *bypass, int *clk_delay); 737 738/** 739 * @INTERNAL 740 * Retrieve node-specific PKO Queue configuration. 741 * 742 * @param node OCTEON3 node. 743 * @param pkocfg PKO Queue static configuration. 744 */ 745int cvmx_helper_pko_queue_config_get(int node, cvmx_user_static_pko_queue_config_t *cfg); 746 747/** 748 * @INTERNAL 749 * Update node-specific PKO Queue configuration. 750 * 751 * @param node OCTEON3 node. 752 * @param pkocfg PKO Queue static configuration. 753 */ 754int cvmx_helper_pko_queue_config_set(int node, cvmx_user_static_pko_queue_config_t *cfg); 755 756/** 757 * @INTERNAL 758 * Retrieve the SFP node offset in the device tree 759 * 760 * @param xiface node and interface 761 * @param index port index 762 * 763 * @return offset in device tree or -1 if error or not defined. 764 */ 765int cvmx_helper_cfg_get_sfp_fdt_offset(int xiface, int index); 766 767/** 768 * Search for a port based on its FDT node offset 769 * 770 * @param of_offset Node offset of port to search for 771 * 772 * @return ipd_port or -1 if not found 773 */ 774int cvmx_helper_cfg_get_ipd_port_by_fdt_node_offset(int of_offset); 775 776/** 777 * @INTERNAL 778 * Sets the SFP node offset 779 * 780 * @param xiface node and interface 781 * @param index port index 782 * @param sfp_of_offset Offset of SFP node in device tree 783 */ 784void cvmx_helper_cfg_set_sfp_fdt_offset(int xiface, int index, int sfp_of_offset); 785 786/** 787 * Search for a port based on its FDT node offset 788 * 789 * @param of_offset Node offset of port to search for 790 * @param[out] xiface xinterface of match 791 * @param[out] index port index of match 792 * 793 * @return 0 if found, -1 if not found 794 */ 795int cvmx_helper_cfg_get_xiface_index_by_fdt_node_offset(int of_offset, int *xiface, int *index); 796 797/** 798 * Get data structure defining the Microsemi VSC7224 channel info 799 * or NULL if not present 800 * 801 * @param xiface node and interface 802 * @param index port index 803 * 804 * @return pointer to vsc7224 data structure or NULL if not present 805 */ 806struct cvmx_vsc7224_chan *cvmx_helper_cfg_get_vsc7224_chan_info(int xiface, int index); 807 808/** 809 * Sets the Microsemi VSC7224 channel data structure 810 * 811 * @param xiface node and interface 812 * @param index port index 813 * @param[in] vsc7224_info Microsemi VSC7224 data structure 814 */ 815void cvmx_helper_cfg_set_vsc7224_chan_info(int xiface, int index, 816 struct cvmx_vsc7224_chan *vsc7224_chan_info); 817 818/** 819 * Get data structure defining the Avago AVSP5410 phy info 820 * or NULL if not present 821 * 822 * @param xiface node and interface 823 * @param index port index 824 * 825 * @return pointer to avsp5410 data structure or NULL if not present 826 */ 827struct cvmx_avsp5410 *cvmx_helper_cfg_get_avsp5410_info(int xiface, int index); 828 829/** 830 * Sets the Avago AVSP5410 phy info data structure 831 * 832 * @param xiface node and interface 833 * @param index port index 834 * @param[in] avsp5410_info Avago AVSP5410 data structure 835 */ 836void cvmx_helper_cfg_set_avsp5410_info(int xiface, int index, struct cvmx_avsp5410 *avsp5410_info); 837 838/** 839 * Gets the SFP data associated with a port 840 * 841 * @param xiface node and interface 842 * @param index port index 843 * 844 * @return pointer to SFP data structure or NULL if none 845 */ 846struct cvmx_fdt_sfp_info *cvmx_helper_cfg_get_sfp_info(int xiface, int index); 847 848/** 849 * Sets the SFP data associated with a port 850 * 851 * @param xiface node and interface 852 * @param index port index 853 * @param[in] sfp_info port SFP data or NULL for none 854 */ 855void cvmx_helper_cfg_set_sfp_info(int xiface, int index, struct cvmx_fdt_sfp_info *sfp_info); 856 857/* 858 * Initializes cvmx with user specified config info. 859 */ 860int cvmx_user_static_config(void); 861void cvmx_pko_queue_show(void); 862int cvmx_fpa_pool_init_from_cvmx_config(void); 863int __cvmx_helper_init_port_valid(void); 864 865/** 866 * Returns a pointer to the phy device associated with a port 867 * 868 * @param xiface node and interface 869 * @param index port index 870 * 871 * return pointer to phy device or NULL if none 872 */ 873struct phy_device *cvmx_helper_cfg_get_phy_device(int xiface, int index); 874 875/** 876 * Sets the phy device associated with a port 877 * 878 * @param xiface node and interface 879 * @param index port index 880 * @param[in] phydev phy device to assiciate 881 */ 882void cvmx_helper_cfg_set_phy_device(int xiface, int index, struct phy_device *phydev); 883 884#endif /* __CVMX_HELPER_CFG_H__ */ 885