Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright 2019 NXP
0003  */
0004 #ifndef _MSCC_FELIX_H
0005 #define _MSCC_FELIX_H
0006 
0007 #define ocelot_to_felix(o)      container_of((o), struct felix, ocelot)
0008 #define FELIX_MAC_QUIRKS        OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
0009 
0010 #define OCELOT_PORT_MODE_INTERNAL   BIT(0)
0011 #define OCELOT_PORT_MODE_SGMII      BIT(1)
0012 #define OCELOT_PORT_MODE_QSGMII     BIT(2)
0013 #define OCELOT_PORT_MODE_2500BASEX  BIT(3)
0014 #define OCELOT_PORT_MODE_USXGMII    BIT(4)
0015 #define OCELOT_PORT_MODE_1000BASEX  BIT(5)
0016 
0017 /* Platform-specific information */
0018 struct felix_info {
0019     const struct resource       *target_io_res;
0020     const struct resource       *port_io_res;
0021     const struct resource       *imdio_res;
0022     const struct reg_field      *regfields;
0023     const u32 *const        *map;
0024     const struct ocelot_ops     *ops;
0025     const u32           *port_modes;
0026     int             num_mact_rows;
0027     const struct ocelot_stat_layout *stats_layout;
0028     int             num_ports;
0029     int             num_tx_queues;
0030     struct vcap_props       *vcap;
0031     u16             vcap_pol_base;
0032     u16             vcap_pol_max;
0033     u16             vcap_pol_base2;
0034     u16             vcap_pol_max2;
0035     const struct ptp_clock_info *ptp_caps;
0036 
0037     /* Some Ocelot switches are integrated into the SoC without the
0038      * extraction IRQ line connected to the ARM GIC. By enabling this
0039      * workaround, the few packets that are delivered to the CPU port
0040      * module (currently only PTP) are copied not only to the hardware CPU
0041      * port module, but also to the 802.1Q Ethernet CPU port, and polling
0042      * the extraction registers is triggered once the DSA tagger sees a PTP
0043      * frame. The Ethernet frame is only used as a notification: it is
0044      * dropped, and the original frame is extracted over MMIO and annotated
0045      * with the RX timestamp.
0046      */
0047     bool                quirk_no_xtr_irq;
0048 
0049     int (*mdio_bus_alloc)(struct ocelot *ocelot);
0050     void    (*mdio_bus_free)(struct ocelot *ocelot);
0051     void    (*phylink_validate)(struct ocelot *ocelot, int port,
0052                     unsigned long *supported,
0053                     struct phylink_link_state *state);
0054     int (*port_setup_tc)(struct dsa_switch *ds, int port,
0055                  enum tc_setup_type type, void *type_data);
0056     void    (*tas_guard_bands_update)(struct ocelot *ocelot, int port);
0057     void    (*port_sched_speed_set)(struct ocelot *ocelot, int port,
0058                     u32 speed);
0059     struct regmap *(*init_regmap)(struct ocelot *ocelot,
0060                       struct resource *res);
0061 };
0062 
0063 /* Methods for initializing the hardware resources specific to a tagging
0064  * protocol (like the NPI port, for "ocelot" or "seville", or the VCAP TCAMs,
0065  * for "ocelot-8021q").
0066  * It is important that the resources configured here do not have side effects
0067  * for the other tagging protocols. If that is the case, their configuration
0068  * needs to go to felix_tag_proto_setup_shared().
0069  */
0070 struct felix_tag_proto_ops {
0071     int (*setup)(struct dsa_switch *ds);
0072     void (*teardown)(struct dsa_switch *ds);
0073     unsigned long (*get_host_fwd_mask)(struct dsa_switch *ds);
0074 };
0075 
0076 extern const struct dsa_switch_ops felix_switch_ops;
0077 
0078 /* DSA glue / front-end for struct ocelot */
0079 struct felix {
0080     struct dsa_switch       *ds;
0081     const struct felix_info     *info;
0082     struct ocelot           ocelot;
0083     struct mii_bus          *imdio;
0084     struct phylink_pcs      **pcs;
0085     resource_size_t         switch_base;
0086     resource_size_t         imdio_base;
0087     enum dsa_tag_protocol       tag_proto;
0088     const struct felix_tag_proto_ops *tag_proto_ops;
0089     struct kthread_worker       *xmit_worker;
0090     unsigned long           host_flood_uc_mask;
0091     unsigned long           host_flood_mc_mask;
0092 };
0093 
0094 struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
0095 int felix_netdev_to_port(struct net_device *dev);
0096 
0097 #endif