1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright 2019 NXP Semiconductors
4 #include <uapi/linux/if_bridge.h>
5 #include <soc/mscc/ocelot_vcap.h>
6 #include <soc/mscc/ocelot_qsys.h>
7 #include <soc/mscc/ocelot_sys.h>
8 #include <soc/mscc/ocelot_dev.h>
9 #include <soc/mscc/ocelot_ana.h>
10 #include <soc/mscc/ocelot.h>
11 #include <linux/packing.h>
12 #include <linux/module.h>
13 #include <linux/of_net.h>
14 #include <linux/pci.h>
16 #include <net/pkt_sched.h>
20 static enum dsa_tag_protocol felix_get_tag_protocol(struct dsa_switch *ds,
22 enum dsa_tag_protocol mp)
24 return DSA_TAG_PROTO_OCELOT;
27 static int felix_set_ageing_time(struct dsa_switch *ds,
28 unsigned int ageing_time)
30 struct ocelot *ocelot = ds->priv;
32 ocelot_set_ageing_time(ocelot, ageing_time);
37 static int felix_fdb_dump(struct dsa_switch *ds, int port,
38 dsa_fdb_dump_cb_t *cb, void *data)
40 struct ocelot *ocelot = ds->priv;
42 return ocelot_fdb_dump(ocelot, port, cb, data);
45 static int felix_fdb_add(struct dsa_switch *ds, int port,
46 const unsigned char *addr, u16 vid)
48 struct ocelot *ocelot = ds->priv;
50 return ocelot_fdb_add(ocelot, port, addr, vid);
53 static int felix_fdb_del(struct dsa_switch *ds, int port,
54 const unsigned char *addr, u16 vid)
56 struct ocelot *ocelot = ds->priv;
58 return ocelot_fdb_del(ocelot, port, addr, vid);
61 static void felix_bridge_stp_state_set(struct dsa_switch *ds, int port,
64 struct ocelot *ocelot = ds->priv;
66 return ocelot_bridge_stp_state_set(ocelot, port, state);
69 static int felix_bridge_join(struct dsa_switch *ds, int port,
70 struct net_device *br)
72 struct ocelot *ocelot = ds->priv;
74 return ocelot_port_bridge_join(ocelot, port, br);
77 static void felix_bridge_leave(struct dsa_switch *ds, int port,
78 struct net_device *br)
80 struct ocelot *ocelot = ds->priv;
82 ocelot_port_bridge_leave(ocelot, port, br);
85 /* This callback needs to be present */
86 static int felix_vlan_prepare(struct dsa_switch *ds, int port,
87 const struct switchdev_obj_port_vlan *vlan)
92 static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)
94 struct ocelot *ocelot = ds->priv;
96 ocelot_port_vlan_filtering(ocelot, port, enabled);
101 static void felix_vlan_add(struct dsa_switch *ds, int port,
102 const struct switchdev_obj_port_vlan *vlan)
104 struct ocelot *ocelot = ds->priv;
108 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
109 err = ocelot_vlan_add(ocelot, port, vid,
110 vlan->flags & BRIDGE_VLAN_INFO_PVID,
111 vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED);
113 dev_err(ds->dev, "Failed to add VLAN %d to port %d: %d\n",
120 static int felix_vlan_del(struct dsa_switch *ds, int port,
121 const struct switchdev_obj_port_vlan *vlan)
123 struct ocelot *ocelot = ds->priv;
127 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
128 err = ocelot_vlan_del(ocelot, port, vid);
130 dev_err(ds->dev, "Failed to remove VLAN %d from port %d: %d\n",
138 static int felix_port_enable(struct dsa_switch *ds, int port,
139 struct phy_device *phy)
141 struct ocelot *ocelot = ds->priv;
143 ocelot_port_enable(ocelot, port, phy);
148 static void felix_port_disable(struct dsa_switch *ds, int port)
150 struct ocelot *ocelot = ds->priv;
152 return ocelot_port_disable(ocelot, port);
155 static void felix_phylink_validate(struct dsa_switch *ds, int port,
156 unsigned long *supported,
157 struct phylink_link_state *state)
159 struct ocelot *ocelot = ds->priv;
160 struct ocelot_port *ocelot_port = ocelot->ports[port];
161 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
163 if (state->interface != PHY_INTERFACE_MODE_NA &&
164 state->interface != ocelot_port->phy_mode) {
165 bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
169 /* No half-duplex. */
170 phylink_set_port_modes(mask);
171 phylink_set(mask, Autoneg);
172 phylink_set(mask, Pause);
173 phylink_set(mask, Asym_Pause);
174 phylink_set(mask, 10baseT_Full);
175 phylink_set(mask, 100baseT_Full);
176 phylink_set(mask, 1000baseT_Full);
178 if (state->interface == PHY_INTERFACE_MODE_INTERNAL ||
179 state->interface == PHY_INTERFACE_MODE_2500BASEX ||
180 state->interface == PHY_INTERFACE_MODE_USXGMII) {
181 phylink_set(mask, 2500baseT_Full);
182 phylink_set(mask, 2500baseX_Full);
185 bitmap_and(supported, supported, mask,
186 __ETHTOOL_LINK_MODE_MASK_NBITS);
187 bitmap_and(state->advertising, state->advertising, mask,
188 __ETHTOOL_LINK_MODE_MASK_NBITS);
191 static int felix_phylink_mac_pcs_get_state(struct dsa_switch *ds, int port,
192 struct phylink_link_state *state)
194 struct ocelot *ocelot = ds->priv;
195 struct felix *felix = ocelot_to_felix(ocelot);
197 if (felix->info->pcs_link_state)
198 felix->info->pcs_link_state(ocelot, port, state);
203 static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
204 unsigned int link_an_mode,
205 const struct phylink_link_state *state)
207 struct ocelot *ocelot = ds->priv;
208 struct ocelot_port *ocelot_port = ocelot->ports[port];
209 struct felix *felix = ocelot_to_felix(ocelot);
212 /* Take port out of reset by clearing the MAC_TX_RST, MAC_RX_RST and
213 * PORT_RST bits in CLOCK_CFG
215 ocelot_port_writel(ocelot_port, DEV_CLOCK_CFG_LINK_SPEED(state->speed),
218 /* Flow control. Link speed is only used here to evaluate the time
219 * specification in incoming pause frames.
221 mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(state->speed);
223 /* handle Rx pause in all cases, with 2500base-X this is used for rate
226 mac_fc_cfg |= SYS_MAC_FC_CFG_RX_FC_ENA;
228 if (state->pause & MLO_PAUSE_TX)
229 mac_fc_cfg |= SYS_MAC_FC_CFG_TX_FC_ENA |
230 SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
231 SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
232 SYS_MAC_FC_CFG_ZERO_PAUSE_ENA;
233 ocelot_write_rix(ocelot, mac_fc_cfg, SYS_MAC_FC_CFG, port);
235 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
237 if (felix->info->pcs_init)
238 felix->info->pcs_init(ocelot, port, link_an_mode, state);
241 static void felix_phylink_mac_an_restart(struct dsa_switch *ds, int port)
243 struct ocelot *ocelot = ds->priv;
244 struct felix *felix = ocelot_to_felix(ocelot);
246 if (felix->info->pcs_an_restart)
247 felix->info->pcs_an_restart(ocelot, port);
250 static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
251 unsigned int link_an_mode,
252 phy_interface_t interface)
254 struct ocelot *ocelot = ds->priv;
255 struct ocelot_port *ocelot_port = ocelot->ports[port];
257 ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
258 ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
259 QSYS_SWITCH_PORT_MODE, port);
262 static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
263 unsigned int link_an_mode,
264 phy_interface_t interface,
265 struct phy_device *phydev,
266 int speed, int duplex,
267 bool tx_pause, bool rx_pause)
269 struct ocelot *ocelot = ds->priv;
270 struct ocelot_port *ocelot_port = ocelot->ports[port];
272 /* Enable MAC module */
273 ocelot_port_writel(ocelot_port, DEV_MAC_ENA_CFG_RX_ENA |
274 DEV_MAC_ENA_CFG_TX_ENA, DEV_MAC_ENA_CFG);
276 /* Enable receiving frames on the port, and activate auto-learning of
279 ocelot_write_gix(ocelot, ANA_PORT_PORT_CFG_LEARNAUTO |
280 ANA_PORT_PORT_CFG_RECV_ENA |
281 ANA_PORT_PORT_CFG_PORTID_VAL(port),
282 ANA_PORT_PORT_CFG, port);
284 /* Core: Enable port for frame transfer */
285 ocelot_write_rix(ocelot, QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE |
286 QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG(1) |
287 QSYS_SWITCH_PORT_MODE_PORT_ENA,
288 QSYS_SWITCH_PORT_MODE, port);
291 static void felix_get_strings(struct dsa_switch *ds, int port,
292 u32 stringset, u8 *data)
294 struct ocelot *ocelot = ds->priv;
296 return ocelot_get_strings(ocelot, port, stringset, data);
299 static void felix_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data)
301 struct ocelot *ocelot = ds->priv;
303 ocelot_get_ethtool_stats(ocelot, port, data);
306 static int felix_get_sset_count(struct dsa_switch *ds, int port, int sset)
308 struct ocelot *ocelot = ds->priv;
310 return ocelot_get_sset_count(ocelot, port, sset);
313 static int felix_get_ts_info(struct dsa_switch *ds, int port,
314 struct ethtool_ts_info *info)
316 struct ocelot *ocelot = ds->priv;
318 return ocelot_get_ts_info(ocelot, port, info);
321 static int felix_parse_ports_node(struct felix *felix,
322 struct device_node *ports_node,
323 phy_interface_t *port_phy_modes)
325 struct ocelot *ocelot = &felix->ocelot;
326 struct device *dev = felix->ocelot.dev;
327 struct device_node *child;
329 for_each_available_child_of_node(ports_node, child) {
330 phy_interface_t phy_mode;
334 /* Get switch port number from DT */
335 if (of_property_read_u32(child, "reg", &port) < 0) {
336 dev_err(dev, "Port number not defined in device tree "
337 "(property \"reg\")\n");
342 /* Get PHY mode from DT */
343 err = of_get_phy_mode(child, &phy_mode);
345 dev_err(dev, "Failed to read phy-mode or "
346 "phy-interface-type property for port %d\n",
352 err = felix->info->prevalidate_phy_mode(ocelot, port, phy_mode);
354 dev_err(dev, "Unsupported PHY mode %s on port %d\n",
355 phy_modes(phy_mode), port);
359 port_phy_modes[port] = phy_mode;
365 static int felix_parse_dt(struct felix *felix, phy_interface_t *port_phy_modes)
367 struct device *dev = felix->ocelot.dev;
368 struct device_node *switch_node;
369 struct device_node *ports_node;
372 switch_node = dev->of_node;
374 ports_node = of_get_child_by_name(switch_node, "ports");
376 dev_err(dev, "Incorrect bindings: absent \"ports\" node\n");
380 err = felix_parse_ports_node(felix, ports_node, port_phy_modes);
381 of_node_put(ports_node);
386 static int felix_init_structs(struct felix *felix, int num_phys_ports)
388 struct ocelot *ocelot = &felix->ocelot;
389 phy_interface_t *port_phy_modes;
390 resource_size_t switch_base;
393 ocelot->num_phys_ports = num_phys_ports;
394 ocelot->ports = devm_kcalloc(ocelot->dev, num_phys_ports,
395 sizeof(struct ocelot_port *), GFP_KERNEL);
399 ocelot->map = felix->info->map;
400 ocelot->stats_layout = felix->info->stats_layout;
401 ocelot->num_stats = felix->info->num_stats;
402 ocelot->shared_queue_sz = felix->info->shared_queue_sz;
403 ocelot->vcap_is2_keys = felix->info->vcap_is2_keys;
404 ocelot->vcap_is2_actions= felix->info->vcap_is2_actions;
405 ocelot->vcap = felix->info->vcap;
406 ocelot->ops = felix->info->ops;
408 port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t),
413 err = felix_parse_dt(felix, port_phy_modes);
415 kfree(port_phy_modes);
419 switch_base = pci_resource_start(felix->pdev,
420 felix->info->switch_pci_bar);
422 for (i = 0; i < TARGET_MAX; i++) {
423 struct regmap *target;
424 struct resource *res;
426 if (!felix->info->target_io_res[i].name)
429 res = &felix->info->target_io_res[i];
430 res->flags = IORESOURCE_MEM;
431 res->start += switch_base;
432 res->end += switch_base;
434 target = ocelot_regmap_init(ocelot, res);
435 if (IS_ERR(target)) {
437 "Failed to map device memory space\n");
438 kfree(port_phy_modes);
439 return PTR_ERR(target);
442 ocelot->targets[i] = target;
445 err = ocelot_regfields_init(ocelot, felix->info->regfields);
447 dev_err(ocelot->dev, "failed to init reg fields map\n");
448 kfree(port_phy_modes);
452 for (port = 0; port < num_phys_ports; port++) {
453 struct ocelot_port *ocelot_port;
454 void __iomem *port_regs;
455 struct resource *res;
457 ocelot_port = devm_kzalloc(ocelot->dev,
458 sizeof(struct ocelot_port),
462 "failed to allocate port memory\n");
463 kfree(port_phy_modes);
467 res = &felix->info->port_io_res[port];
468 res->flags = IORESOURCE_MEM;
469 res->start += switch_base;
470 res->end += switch_base;
472 port_regs = devm_ioremap_resource(ocelot->dev, res);
473 if (IS_ERR(port_regs)) {
475 "failed to map registers for port %d\n", port);
476 kfree(port_phy_modes);
477 return PTR_ERR(port_regs);
480 ocelot_port->phy_mode = port_phy_modes[port];
481 ocelot_port->ocelot = ocelot;
482 ocelot_port->regs = port_regs;
483 ocelot->ports[port] = ocelot_port;
486 kfree(port_phy_modes);
488 if (felix->info->mdio_bus_alloc) {
489 err = felix->info->mdio_bus_alloc(ocelot);
497 /* Hardware initialization done here so that we can allocate structures with
498 * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing
499 * us to allocate structures twice (leak memory) and map PCI memory twice
500 * (which will not work).
502 static int felix_setup(struct dsa_switch *ds)
504 struct ocelot *ocelot = ds->priv;
505 struct felix *felix = ocelot_to_felix(ocelot);
508 err = felix_init_structs(felix, ds->num_ports);
514 for (port = 0; port < ds->num_ports; port++) {
515 ocelot_init_port(ocelot, port);
517 /* Bring up the CPU port module and configure the NPI port */
518 if (dsa_is_cpu_port(ds, port))
519 ocelot_configure_cpu(ocelot, port,
520 OCELOT_TAG_PREFIX_NONE,
521 OCELOT_TAG_PREFIX_LONG);
524 /* Include the CPU port module in the forwarding mask for unknown
525 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST
526 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since
527 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU.
529 ocelot_write_rix(ocelot,
530 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)),
531 ANA_PGID_PGID, PGID_UC);
533 ds->mtu_enforcement_ingress = true;
534 /* It looks like the MAC/PCS interrupt register - PM0_IEVENT (0x8040)
535 * isn't instantiated for the Felix PF.
536 * In-band AN may take a few ms to complete, so we need to poll.
543 static void felix_teardown(struct dsa_switch *ds)
545 struct ocelot *ocelot = ds->priv;
546 struct felix *felix = ocelot_to_felix(ocelot);
548 if (felix->info->mdio_bus_free)
549 felix->info->mdio_bus_free(ocelot);
551 /* stop workqueue thread */
552 ocelot_deinit(ocelot);
555 static int felix_hwtstamp_get(struct dsa_switch *ds, int port,
558 struct ocelot *ocelot = ds->priv;
560 return ocelot_hwstamp_get(ocelot, port, ifr);
563 static int felix_hwtstamp_set(struct dsa_switch *ds, int port,
566 struct ocelot *ocelot = ds->priv;
568 return ocelot_hwstamp_set(ocelot, port, ifr);
571 static bool felix_rxtstamp(struct dsa_switch *ds, int port,
572 struct sk_buff *skb, unsigned int type)
574 struct skb_shared_hwtstamps *shhwtstamps;
575 struct ocelot *ocelot = ds->priv;
576 u8 *extraction = skb->data - ETH_HLEN - OCELOT_TAG_LEN;
577 u32 tstamp_lo, tstamp_hi;
578 struct timespec64 ts;
581 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts);
582 tstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
584 packing(extraction, &val, 116, 85, OCELOT_TAG_LEN, UNPACK, 0);
585 tstamp_lo = (u32)val;
587 tstamp_hi = tstamp >> 32;
588 if ((tstamp & 0xffffffff) < tstamp_lo)
591 tstamp = ((u64)tstamp_hi << 32) | tstamp_lo;
593 shhwtstamps = skb_hwtstamps(skb);
594 memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
595 shhwtstamps->hwtstamp = tstamp;
599 static bool felix_txtstamp(struct dsa_switch *ds, int port,
600 struct sk_buff *clone, unsigned int type)
602 struct ocelot *ocelot = ds->priv;
603 struct ocelot_port *ocelot_port = ocelot->ports[port];
605 if (!ocelot_port_add_txtstamp_skb(ocelot_port, clone))
611 static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
613 struct ocelot *ocelot = ds->priv;
615 ocelot_port_set_maxlen(ocelot, port, new_mtu);
620 static int felix_get_max_mtu(struct dsa_switch *ds, int port)
622 struct ocelot *ocelot = ds->priv;
624 return ocelot_get_max_mtu(ocelot, port);
627 static int felix_cls_flower_add(struct dsa_switch *ds, int port,
628 struct flow_cls_offload *cls, bool ingress)
630 struct ocelot *ocelot = ds->priv;
632 return ocelot_cls_flower_replace(ocelot, port, cls, ingress);
635 static int felix_cls_flower_del(struct dsa_switch *ds, int port,
636 struct flow_cls_offload *cls, bool ingress)
638 struct ocelot *ocelot = ds->priv;
640 return ocelot_cls_flower_destroy(ocelot, port, cls, ingress);
643 static int felix_cls_flower_stats(struct dsa_switch *ds, int port,
644 struct flow_cls_offload *cls, bool ingress)
646 struct ocelot *ocelot = ds->priv;
648 return ocelot_cls_flower_stats(ocelot, port, cls, ingress);
651 static int felix_port_policer_add(struct dsa_switch *ds, int port,
652 struct dsa_mall_policer_tc_entry *policer)
654 struct ocelot *ocelot = ds->priv;
655 struct ocelot_policer pol = {
656 .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8,
657 .burst = div_u64(policer->rate_bytes_per_sec *
658 PSCHED_NS2TICKS(policer->burst),
659 PSCHED_TICKS_PER_SEC),
662 return ocelot_port_policer_add(ocelot, port, &pol);
665 static void felix_port_policer_del(struct dsa_switch *ds, int port)
667 struct ocelot *ocelot = ds->priv;
669 ocelot_port_policer_del(ocelot, port);
672 static const struct dsa_switch_ops felix_switch_ops = {
673 .get_tag_protocol = felix_get_tag_protocol,
674 .setup = felix_setup,
675 .teardown = felix_teardown,
676 .set_ageing_time = felix_set_ageing_time,
677 .get_strings = felix_get_strings,
678 .get_ethtool_stats = felix_get_ethtool_stats,
679 .get_sset_count = felix_get_sset_count,
680 .get_ts_info = felix_get_ts_info,
681 .phylink_validate = felix_phylink_validate,
682 .phylink_mac_link_state = felix_phylink_mac_pcs_get_state,
683 .phylink_mac_config = felix_phylink_mac_config,
684 .phylink_mac_an_restart = felix_phylink_mac_an_restart,
685 .phylink_mac_link_down = felix_phylink_mac_link_down,
686 .phylink_mac_link_up = felix_phylink_mac_link_up,
687 .port_enable = felix_port_enable,
688 .port_disable = felix_port_disable,
689 .port_fdb_dump = felix_fdb_dump,
690 .port_fdb_add = felix_fdb_add,
691 .port_fdb_del = felix_fdb_del,
692 .port_bridge_join = felix_bridge_join,
693 .port_bridge_leave = felix_bridge_leave,
694 .port_stp_state_set = felix_bridge_stp_state_set,
695 .port_vlan_prepare = felix_vlan_prepare,
696 .port_vlan_filtering = felix_vlan_filtering,
697 .port_vlan_add = felix_vlan_add,
698 .port_vlan_del = felix_vlan_del,
699 .port_hwtstamp_get = felix_hwtstamp_get,
700 .port_hwtstamp_set = felix_hwtstamp_set,
701 .port_rxtstamp = felix_rxtstamp,
702 .port_txtstamp = felix_txtstamp,
703 .port_change_mtu = felix_change_mtu,
704 .port_max_mtu = felix_get_max_mtu,
705 .port_policer_add = felix_port_policer_add,
706 .port_policer_del = felix_port_policer_del,
707 .cls_flower_add = felix_cls_flower_add,
708 .cls_flower_del = felix_cls_flower_del,
709 .cls_flower_stats = felix_cls_flower_stats,
712 static struct felix_info *felix_instance_tbl[] = {
713 [FELIX_INSTANCE_VSC9959] = &felix_info_vsc9959,
716 static irqreturn_t felix_irq_handler(int irq, void *data)
718 struct ocelot *ocelot = (struct ocelot *)data;
720 /* The INTB interrupt is used for both PTP TX timestamp interrupt
721 * and preemption status change interrupt on each port.
723 * - Get txtstamp if have
724 * - TODO: handle preemption. Without handling it, driver may get
728 ocelot_get_txtstamp(ocelot);
733 static int felix_pci_probe(struct pci_dev *pdev,
734 const struct pci_device_id *id)
736 enum felix_instance instance = id->driver_data;
737 struct dsa_switch *ds;
738 struct ocelot *ocelot;
742 err = pci_enable_device(pdev);
744 dev_err(&pdev->dev, "device enable failed\n");
748 /* set up for high or low dma */
749 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
751 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
754 "DMA configuration failed: 0x%x\n", err);
759 felix = kzalloc(sizeof(struct felix), GFP_KERNEL);
762 dev_err(&pdev->dev, "Failed to allocate driver memory\n");
763 goto err_alloc_felix;
766 pci_set_drvdata(pdev, felix);
767 ocelot = &felix->ocelot;
768 ocelot->dev = &pdev->dev;
770 felix->info = felix_instance_tbl[instance];
772 pci_set_master(pdev);
774 err = devm_request_threaded_irq(&pdev->dev, pdev->irq, NULL,
775 &felix_irq_handler, IRQF_ONESHOT,
776 "felix-intb", ocelot);
778 dev_err(&pdev->dev, "Failed to request irq\n");
784 ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);
787 dev_err(&pdev->dev, "Failed to allocate DSA switch\n");
791 ds->dev = &pdev->dev;
792 ds->num_ports = felix->info->num_ports;
793 ds->ops = &felix_switch_ops;
797 err = dsa_register_switch(ds);
799 dev_err(&pdev->dev, "Failed to register DSA switch: %d\n", err);
800 goto err_register_ds;
812 pci_disable_device(pdev);
817 static void felix_pci_remove(struct pci_dev *pdev)
821 felix = pci_get_drvdata(pdev);
823 dsa_unregister_switch(felix->ds);
828 pci_disable_device(pdev);
831 static struct pci_device_id felix_ids[] = {
834 PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0xEEF0),
835 .driver_data = FELIX_INSTANCE_VSC9959,
839 MODULE_DEVICE_TABLE(pci, felix_ids);
841 static struct pci_driver felix_pci_driver = {
842 .name = KBUILD_MODNAME,
843 .id_table = felix_ids,
844 .probe = felix_pci_probe,
845 .remove = felix_pci_remove,
848 module_pci_driver(felix_pci_driver);
850 MODULE_DESCRIPTION("Felix Switch driver");
851 MODULE_LICENSE("GPL v2");