felix.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright 2019 NXP
  3. */
  4. #ifndef _MSCC_FELIX_H
  5. #define _MSCC_FELIX_H
  6. #define ocelot_to_felix(o) container_of((o), struct felix, ocelot)
  7. #define FELIX_MAC_QUIRKS OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
  8. #define OCELOT_PORT_MODE_NONE 0
  9. #define OCELOT_PORT_MODE_INTERNAL BIT(0)
  10. #define OCELOT_PORT_MODE_SGMII BIT(1)
  11. #define OCELOT_PORT_MODE_QSGMII BIT(2)
  12. #define OCELOT_PORT_MODE_2500BASEX BIT(3)
  13. #define OCELOT_PORT_MODE_USXGMII BIT(4)
  14. #define OCELOT_PORT_MODE_1000BASEX BIT(5)
  15. struct device_node;
  16. /* Platform-specific information */
  17. struct felix_info {
  18. /* Hardcoded resources provided by the hardware instantiation. */
  19. const struct resource *resources;
  20. size_t num_resources;
  21. /* Names of the mandatory resources that will be requested during
  22. * probe. Must have TARGET_MAX elements, since it is indexed by target.
  23. */
  24. const char *const *resource_names;
  25. const struct reg_field *regfields;
  26. const u32 *const *map;
  27. const struct ocelot_ops *ops;
  28. const u32 *port_modes;
  29. int num_mact_rows;
  30. int num_ports;
  31. struct vcap_props *vcap;
  32. u16 vcap_pol_base;
  33. u16 vcap_pol_max;
  34. u16 vcap_pol_base2;
  35. u16 vcap_pol_max2;
  36. const struct ptp_clock_info *ptp_caps;
  37. unsigned long quirks;
  38. /* Some Ocelot switches are integrated into the SoC without the
  39. * extraction IRQ line connected to the ARM GIC. By enabling this
  40. * workaround, the few packets that are delivered to the CPU port
  41. * module (currently only PTP) are copied not only to the hardware CPU
  42. * port module, but also to the 802.1Q Ethernet CPU port, and polling
  43. * the extraction registers is triggered once the DSA tagger sees a PTP
  44. * frame. The Ethernet frame is only used as a notification: it is
  45. * dropped, and the original frame is extracted over MMIO and annotated
  46. * with the RX timestamp.
  47. */
  48. bool quirk_no_xtr_irq;
  49. int (*mdio_bus_alloc)(struct ocelot *ocelot);
  50. void (*mdio_bus_free)(struct ocelot *ocelot);
  51. int (*port_setup_tc)(struct dsa_switch *ds, int port,
  52. enum tc_setup_type type, void *type_data);
  53. void (*port_sched_speed_set)(struct ocelot *ocelot, int port,
  54. u32 speed);
  55. void (*phylink_mac_config)(struct ocelot *ocelot, int port,
  56. unsigned int mode,
  57. const struct phylink_link_state *state);
  58. int (*configure_serdes)(struct ocelot *ocelot, int port,
  59. struct device_node *portnp);
  60. int (*request_irq)(struct ocelot *ocelot);
  61. };
  62. /* Methods for initializing the hardware resources specific to a tagging
  63. * protocol (like the NPI port, for "ocelot" or "seville", or the VCAP TCAMs,
  64. * for "ocelot-8021q").
  65. * It is important that the resources configured here do not have side effects
  66. * for the other tagging protocols. If that is the case, their configuration
  67. * needs to go to felix_tag_proto_setup_shared().
  68. */
  69. struct felix_tag_proto_ops {
  70. int (*setup)(struct dsa_switch *ds);
  71. void (*teardown)(struct dsa_switch *ds);
  72. unsigned long (*get_host_fwd_mask)(struct dsa_switch *ds);
  73. int (*change_conduit)(struct dsa_switch *ds, int port,
  74. struct net_device *conduit,
  75. struct netlink_ext_ack *extack);
  76. };
  77. /* DSA glue / front-end for struct ocelot */
  78. struct felix {
  79. struct dsa_switch *ds;
  80. const struct felix_info *info;
  81. struct ocelot ocelot;
  82. struct mii_bus *imdio;
  83. struct phylink_pcs **pcs;
  84. resource_size_t switch_base;
  85. enum dsa_tag_protocol tag_proto;
  86. const struct felix_tag_proto_ops *tag_proto_ops;
  87. struct kthread_worker *xmit_worker;
  88. unsigned long host_flood_uc_mask;
  89. unsigned long host_flood_mc_mask;
  90. };
  91. int felix_register_switch(struct device *dev, resource_size_t switch_base,
  92. int num_flooding_pgids, bool ptp,
  93. bool mm_supported,
  94. enum dsa_tag_protocol init_tag_proto,
  95. const struct felix_info *info);
  96. struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
  97. int felix_netdev_to_port(struct net_device *dev);
  98. #endif