cvmx-helper-cfg.h 26 KB

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