Lines Matching refs:ocelot

107 static void ocelot_pll5_init(struct ocelot *ocelot)  in ocelot_pll5_init()  argument
112 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG4, in ocelot_pll5_init()
115 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG0, in ocelot_pll5_init()
127 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG2, in ocelot_pll5_init()
136 static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops) in ocelot_chip_init() argument
140 ocelot->map = ocelot_regmap; in ocelot_chip_init()
141 ocelot->stats_layout = ocelot_stats_layout; in ocelot_chip_init()
142 ocelot->num_mact_rows = 1024; in ocelot_chip_init()
143 ocelot->ops = ops; in ocelot_chip_init()
145 ret = ocelot_regfields_init(ocelot, ocelot_regfields); in ocelot_chip_init()
149 ocelot_pll5_init(ocelot); in ocelot_chip_init()
151 eth_random_addr(ocelot->base_mac); in ocelot_chip_init()
152 ocelot->base_mac[5] &= 0xf0; in ocelot_chip_init()
159 struct ocelot *ocelot = arg; in ocelot_xtr_irq_handler() local
162 while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) { in ocelot_xtr_irq_handler()
165 err = ocelot_xtr_poll_frame(ocelot, grp, &skb); in ocelot_xtr_irq_handler()
178 ocelot_drain_cpu_queue(ocelot, 0); in ocelot_xtr_irq_handler()
185 struct ocelot *ocelot = arg; in ocelot_ptp_rdy_irq_handler() local
187 ocelot_get_txtstamp(ocelot); in ocelot_ptp_rdy_irq_handler()
198 static int ocelot_mem_init_status(struct ocelot *ocelot) in ocelot_mem_init_status() argument
203 err = regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], in ocelot_mem_init_status()
209 static int ocelot_reset(struct ocelot *ocelot) in ocelot_reset() argument
214 err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); in ocelot_reset()
218 err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); in ocelot_reset()
225 err = readx_poll_timeout(ocelot_mem_init_status, ocelot, val, !val, in ocelot_reset()
230 err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); in ocelot_reset()
234 return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); in ocelot_reset()
334 static void mscc_ocelot_teardown_devlink_ports(struct ocelot *ocelot) in mscc_ocelot_teardown_devlink_ports() argument
338 for (port = 0; port < ocelot->num_phys_ports; port++) in mscc_ocelot_teardown_devlink_ports()
339 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_teardown_devlink_ports()
342 static void mscc_ocelot_release_ports(struct ocelot *ocelot) in mscc_ocelot_release_ports() argument
346 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_release_ports()
349 ocelot_port = ocelot->ports[port]; in mscc_ocelot_release_ports()
353 ocelot_deinit_port(ocelot, port); in mscc_ocelot_release_ports()
361 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_init_ports() local
367 ocelot->ports = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, in mscc_ocelot_init_ports()
369 if (!ocelot->ports) in mscc_ocelot_init_ports()
372 ocelot->devlink_ports = devm_kcalloc(ocelot->dev, in mscc_ocelot_init_ports()
373 ocelot->num_phys_ports, in mscc_ocelot_init_ports()
374 sizeof(*ocelot->devlink_ports), in mscc_ocelot_init_ports()
376 if (!ocelot->devlink_ports) in mscc_ocelot_init_ports()
391 if (port < 0 || port >= ocelot->num_phys_ports) { in mscc_ocelot_init_ports()
392 dev_err(ocelot->dev, in mscc_ocelot_init_ports()
394 ocelot->num_phys_ports); in mscc_ocelot_init_ports()
402 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_init_ports()
409 err = ocelot_port_devlink_init(ocelot, port, in mscc_ocelot_init_ports()
416 err = ocelot_probe_port(ocelot, port, target, portnp); in mscc_ocelot_init_ports()
418 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_init_ports()
424 ocelot_port = ocelot->ports[port]; in mscc_ocelot_init_ports()
427 dlp = &ocelot->devlink_ports[port]; in mscc_ocelot_init_ports()
432 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_init_ports()
436 err = ocelot_port_devlink_init(ocelot, port, in mscc_ocelot_init_ports()
448 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_init_ports()
450 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_init_ports()
452 ocelot_port_devlink_teardown(ocelot, port); in mscc_ocelot_init_ports()
463 struct ocelot *ocelot; in mscc_ocelot_probe() local
488 devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot), &pdev->dev); in mscc_ocelot_probe()
492 ocelot = devlink_priv(devlink); in mscc_ocelot_probe()
493 ocelot->devlink = priv_to_devlink(ocelot); in mscc_ocelot_probe()
494 platform_set_drvdata(pdev, ocelot); in mscc_ocelot_probe()
495 ocelot->dev = &pdev->dev; in mscc_ocelot_probe()
504 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_probe()
507 ocelot->targets[io_target[i].id] = NULL; in mscc_ocelot_probe()
514 ocelot->targets[io_target[i].id] = target; in mscc_ocelot_probe()
517 if (ocelot->targets[FDMA]) in mscc_ocelot_probe()
518 ocelot_fdma_init(pdev, ocelot); in mscc_ocelot_probe()
527 ocelot->targets[HSIO] = hsio; in mscc_ocelot_probe()
529 err = ocelot_chip_init(ocelot, &ocelot_ops); in mscc_ocelot_probe()
541 "frame extraction", ocelot); in mscc_ocelot_probe()
546 if (irq_ptp_rdy > 0 && ocelot->targets[PTP]) { in mscc_ocelot_probe()
550 ocelot); in mscc_ocelot_probe()
555 ocelot->ptp = 1; in mscc_ocelot_probe()
560 dev_err(ocelot->dev, "no ethernet-ports child node found\n"); in mscc_ocelot_probe()
565 ocelot->num_phys_ports = of_get_child_count(ports); in mscc_ocelot_probe()
566 ocelot->num_flooding_pgids = 1; in mscc_ocelot_probe()
568 ocelot->vcap = vsc7514_vcap_props; in mscc_ocelot_probe()
570 ocelot->vcap_pol.base = VSC7514_VCAP_POLICER_BASE; in mscc_ocelot_probe()
571 ocelot->vcap_pol.max = VSC7514_VCAP_POLICER_MAX; in mscc_ocelot_probe()
573 ocelot->npi = -1; in mscc_ocelot_probe()
575 err = ocelot_init(ocelot); in mscc_ocelot_probe()
583 if (ocelot->fdma) in mscc_ocelot_probe()
584 ocelot_fdma_start(ocelot); in mscc_ocelot_probe()
586 err = ocelot_devlink_sb_register(ocelot); in mscc_ocelot_probe()
590 if (ocelot->ptp) { in mscc_ocelot_probe()
591 err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info); in mscc_ocelot_probe()
593 dev_err(ocelot->dev, in mscc_ocelot_probe()
595 ocelot->ptp = 0; in mscc_ocelot_probe()
611 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_probe()
612 mscc_ocelot_teardown_devlink_ports(ocelot); in mscc_ocelot_probe()
614 ocelot_deinit(ocelot); in mscc_ocelot_probe()
624 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_remove() local
626 if (ocelot->fdma) in mscc_ocelot_remove()
627 ocelot_fdma_deinit(ocelot); in mscc_ocelot_remove()
628 devlink_unregister(ocelot->devlink); in mscc_ocelot_remove()
629 ocelot_deinit_timestamp(ocelot); in mscc_ocelot_remove()
630 ocelot_devlink_sb_unregister(ocelot); in mscc_ocelot_remove()
631 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_remove()
632 mscc_ocelot_teardown_devlink_ports(ocelot); in mscc_ocelot_remove()
633 ocelot_deinit(ocelot); in mscc_ocelot_remove()
637 devlink_free(ocelot->devlink); in mscc_ocelot_remove()