Lines Matching full:ocelot
3 * Microsemi Ocelot Switch driver
7 #include <linux/dsa/ocelot.h>
20 #include <soc/mscc/ocelot.h>
24 #include "ocelot.h"
29 static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops) in ocelot_chip_init() argument
33 ocelot->map = vsc7514_regmap; in ocelot_chip_init()
34 ocelot->num_mact_rows = 1024; in ocelot_chip_init()
35 ocelot->ops = ops; in ocelot_chip_init()
37 ret = ocelot_regfields_init(ocelot, vsc7514_regfields); in ocelot_chip_init()
41 ocelot_pll5_init(ocelot); in ocelot_chip_init()
43 eth_random_addr(ocelot->base_mac); in ocelot_chip_init()
44 ocelot->base_mac[5] &= 0xf0; in ocelot_chip_init()
51 struct ocelot *ocelot = arg; in ocelot_xtr_irq_handler() local
54 ocelot_lock_xtr_grp(ocelot, grp); in ocelot_xtr_irq_handler()
56 while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) { in ocelot_xtr_irq_handler()
59 err = ocelot_xtr_poll_frame(ocelot, grp, &skb); in ocelot_xtr_irq_handler()
72 ocelot_drain_cpu_queue(ocelot, 0); in ocelot_xtr_irq_handler()
74 ocelot_unlock_xtr_grp(ocelot, grp); in ocelot_xtr_irq_handler()
81 struct ocelot *ocelot = arg; in ocelot_ptp_rdy_irq_handler() local
83 ocelot_get_txtstamp(ocelot); in ocelot_ptp_rdy_irq_handler()
105 .name = "ocelot ptp",
120 static void mscc_ocelot_teardown_devlink_ports(struct ocelot *ocelot) in mscc_ocelot_teardown_devlink_ports() argument
124 for (port = 0; port < ocelot->num_phys_ports; port++) in mscc_ocelot_teardown_devlink_ports()
125 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_teardown_devlink_ports()
128 static void mscc_ocelot_release_ports(struct ocelot *ocelot) in mscc_ocelot_release_ports() argument
132 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_release_ports()
135 ocelot_port = ocelot->ports[port]; in mscc_ocelot_release_ports()
139 ocelot_deinit_port(ocelot, port); in mscc_ocelot_release_ports()
147 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_init_ports() local
153 ocelot->ports = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, in mscc_ocelot_init_ports()
155 if (!ocelot->ports) in mscc_ocelot_init_ports()
158 ocelot->devlink_ports = devm_kcalloc(ocelot->dev, in mscc_ocelot_init_ports()
159 ocelot->num_phys_ports, in mscc_ocelot_init_ports()
160 sizeof(*ocelot->devlink_ports), in mscc_ocelot_init_ports()
162 if (!ocelot->devlink_ports) in mscc_ocelot_init_ports()
174 if (port < 0 || port >= ocelot->num_phys_ports) { in mscc_ocelot_init_ports()
175 dev_err(ocelot->dev, in mscc_ocelot_init_ports()
177 ocelot->num_phys_ports); in mscc_ocelot_init_ports()
185 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_init_ports()
192 err = ocelot_port_devlink_init(ocelot, port, in mscc_ocelot_init_ports()
199 err = ocelot_probe_port(ocelot, port, target, portnp); in mscc_ocelot_init_ports()
201 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_init_ports()
209 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_init_ports()
213 err = ocelot_port_devlink_init(ocelot, port, in mscc_ocelot_init_ports()
225 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_init_ports()
227 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_init_ports()
229 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_init_ports()
240 struct ocelot *ocelot; in mscc_ocelot_probe() local
265 devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot), &pdev->dev); in mscc_ocelot_probe()
269 ocelot = devlink_priv(devlink); in mscc_ocelot_probe()
270 ocelot->devlink = priv_to_devlink(ocelot); in mscc_ocelot_probe()
271 platform_set_drvdata(pdev, ocelot); in mscc_ocelot_probe()
272 ocelot->dev = &pdev->dev; in mscc_ocelot_probe()
281 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_probe()
284 ocelot->targets[io_target[i].id] = NULL; in mscc_ocelot_probe()
291 ocelot->targets[io_target[i].id] = target; in mscc_ocelot_probe()
294 if (ocelot->targets[FDMA]) in mscc_ocelot_probe()
295 ocelot_fdma_init(pdev, ocelot); in mscc_ocelot_probe()
297 hsio = syscon_regmap_lookup_by_compatible("mscc,ocelot-hsio"); in mscc_ocelot_probe()
304 ocelot->targets[HSIO] = hsio; in mscc_ocelot_probe()
306 err = ocelot_chip_init(ocelot, &ocelot_ops); in mscc_ocelot_probe()
318 "frame extraction", ocelot); in mscc_ocelot_probe()
323 if (irq_ptp_rdy > 0 && ocelot->targets[PTP]) { in mscc_ocelot_probe()
327 ocelot); in mscc_ocelot_probe()
332 ocelot->ptp = 1; in mscc_ocelot_probe()
337 dev_err(ocelot->dev, "no ethernet-ports child node found\n"); in mscc_ocelot_probe()
342 ocelot->num_phys_ports = of_get_child_count(ports); in mscc_ocelot_probe()
343 ocelot->num_flooding_pgids = 1; in mscc_ocelot_probe()
345 ocelot->vcap = vsc7514_vcap_props; in mscc_ocelot_probe()
347 ocelot->vcap_pol.base = VSC7514_VCAP_POLICER_BASE; in mscc_ocelot_probe()
348 ocelot->vcap_pol.max = VSC7514_VCAP_POLICER_MAX; in mscc_ocelot_probe()
350 ocelot->npi = -1; in mscc_ocelot_probe()
352 err = ocelot_init(ocelot); in mscc_ocelot_probe()
360 if (ocelot->fdma) in mscc_ocelot_probe()
361 ocelot_fdma_start(ocelot); in mscc_ocelot_probe()
363 err = ocelot_devlink_sb_register(ocelot); in mscc_ocelot_probe()
367 if (ocelot->ptp) { in mscc_ocelot_probe()
368 err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info); in mscc_ocelot_probe()
370 dev_err(ocelot->dev, in mscc_ocelot_probe()
372 ocelot->ptp = 0; in mscc_ocelot_probe()
383 dev_info(&pdev->dev, "Ocelot switch probed\n"); in mscc_ocelot_probe()
388 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_probe()
389 mscc_ocelot_teardown_devlink_ports(ocelot); in mscc_ocelot_probe()
391 ocelot_deinit(ocelot); in mscc_ocelot_probe()
401 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_remove() local
403 if (ocelot->fdma) in mscc_ocelot_remove()
404 ocelot_fdma_deinit(ocelot); in mscc_ocelot_remove()
405 devlink_unregister(ocelot->devlink); in mscc_ocelot_remove()
406 ocelot_deinit_timestamp(ocelot); in mscc_ocelot_remove()
407 ocelot_devlink_sb_unregister(ocelot); in mscc_ocelot_remove()
408 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_remove()
409 mscc_ocelot_teardown_devlink_ports(ocelot); in mscc_ocelot_remove()
410 ocelot_deinit(ocelot); in mscc_ocelot_remove()
414 devlink_free(ocelot->devlink); in mscc_ocelot_remove()
421 .name = "ocelot-switch",
428 MODULE_DESCRIPTION("Microsemi Ocelot switch driver");