Lines Matching full:ocelot
3 * Microsemi Ocelot Switch driver
19 #include "ocelot.h"
484 static void ocelot_pll5_init(struct ocelot *ocelot) in ocelot_pll5_init() argument
487 * The values are coming from the VTSS API for Ocelot in ocelot_pll5_init()
489 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG4, in ocelot_pll5_init()
492 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG0, in ocelot_pll5_init()
504 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG2, in ocelot_pll5_init()
513 static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops) in ocelot_chip_init() argument
517 ocelot->map = ocelot_regmap; in ocelot_chip_init()
518 ocelot->stats_layout = ocelot_stats_layout; in ocelot_chip_init()
519 ocelot->num_stats = ARRAY_SIZE(ocelot_stats_layout); in ocelot_chip_init()
520 ocelot->shared_queue_sz = 224 * 1024; in ocelot_chip_init()
521 ocelot->num_mact_rows = 1024; in ocelot_chip_init()
522 ocelot->ops = ops; in ocelot_chip_init()
524 ret = ocelot_regfields_init(ocelot, ocelot_regfields); in ocelot_chip_init()
528 ocelot_pll5_init(ocelot); in ocelot_chip_init()
530 eth_random_addr(ocelot->base_mac); in ocelot_chip_init()
531 ocelot->base_mac[5] &= 0xf0; in ocelot_chip_init()
559 static int ocelot_rx_frame_word(struct ocelot *ocelot, u8 grp, bool ifh, in ocelot_rx_frame_word() argument
565 val = ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_rx_frame_word()
571 val = ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_rx_frame_word()
584 val = ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_rx_frame_word()
586 *rval = ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_rx_frame_word()
592 *rval = ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_rx_frame_word()
604 struct ocelot *ocelot = arg; in ocelot_xtr_irq_handler() local
608 if (!(ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp))) in ocelot_xtr_irq_handler()
624 err = ocelot_rx_frame_word(ocelot, grp, true, &ifh[i]); in ocelot_xtr_irq_handler()
642 ocelot_port = ocelot->ports[info.port]; in ocelot_xtr_irq_handler()
659 sz = ocelot_rx_frame_word(ocelot, grp, false, &val); in ocelot_xtr_irq_handler()
665 sz = ocelot_rx_frame_word(ocelot, grp, false, &val); in ocelot_xtr_irq_handler()
679 if (ocelot->ptp) { in ocelot_xtr_irq_handler()
680 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); in ocelot_xtr_irq_handler()
698 if (ocelot->bridge_mask & BIT(info.port)) in ocelot_xtr_irq_handler()
706 } while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)); in ocelot_xtr_irq_handler()
709 while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) in ocelot_xtr_irq_handler()
710 ocelot_read_rix(ocelot, QS_XTR_RD, grp); in ocelot_xtr_irq_handler()
717 struct ocelot *ocelot = arg; in ocelot_ptp_rdy_irq_handler() local
719 ocelot_get_txtstamp(ocelot); in ocelot_ptp_rdy_irq_handler()
730 static int ocelot_reset(struct ocelot *ocelot) in ocelot_reset() argument
735 regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); in ocelot_reset()
736 regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); in ocelot_reset()
740 regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], in ocelot_reset()
747 regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); in ocelot_reset()
748 regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); in ocelot_reset()
1024 .name = "ocelot ptp",
1039 static void mscc_ocelot_release_ports(struct ocelot *ocelot) in mscc_ocelot_release_ports() argument
1043 for (port = 0; port < ocelot->num_phys_ports; port++) { in mscc_ocelot_release_ports()
1047 ocelot_port = ocelot->ports[port]; in mscc_ocelot_release_ports()
1051 ocelot_deinit_port(ocelot, port); in mscc_ocelot_release_ports()
1064 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_init_ports() local
1068 ocelot->ports = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, in mscc_ocelot_init_ports()
1070 if (!ocelot->ports) in mscc_ocelot_init_ports()
1092 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_init_ports()
1105 err = ocelot_probe_port(ocelot, port, target, phy); in mscc_ocelot_init_ports()
1111 ocelot_port = ocelot->ports[port]; in mscc_ocelot_init_ports()
1134 dev_err(ocelot->dev, in mscc_ocelot_init_ports()
1141 serdes = devm_of_phy_get(ocelot->dev, portnp, NULL); in mscc_ocelot_init_ports()
1145 dev_dbg(ocelot->dev, "deferring probe\n"); in mscc_ocelot_init_ports()
1147 dev_err(ocelot->dev, in mscc_ocelot_init_ports()
1166 struct ocelot *ocelot; in mscc_ocelot_probe() local
1189 ocelot = devm_kzalloc(&pdev->dev, sizeof(*ocelot), GFP_KERNEL); in mscc_ocelot_probe()
1190 if (!ocelot) in mscc_ocelot_probe()
1193 platform_set_drvdata(pdev, ocelot); in mscc_ocelot_probe()
1194 ocelot->dev = &pdev->dev; in mscc_ocelot_probe()
1203 target = ocelot_regmap_init(ocelot, res); in mscc_ocelot_probe()
1206 ocelot->targets[io_target[i].id] = NULL; in mscc_ocelot_probe()
1212 ocelot->targets[io_target[i].id] = target; in mscc_ocelot_probe()
1215 hsio = syscon_regmap_lookup_by_compatible("mscc,ocelot-hsio"); in mscc_ocelot_probe()
1221 ocelot->targets[HSIO] = hsio; in mscc_ocelot_probe()
1223 err = ocelot_chip_init(ocelot, &ocelot_ops); in mscc_ocelot_probe()
1233 "frame extraction", ocelot); in mscc_ocelot_probe()
1238 if (irq_ptp_rdy > 0 && ocelot->targets[PTP]) { in mscc_ocelot_probe()
1242 ocelot); in mscc_ocelot_probe()
1247 ocelot->ptp = 1; in mscc_ocelot_probe()
1252 dev_err(ocelot->dev, "no ethernet-ports child node found\n"); in mscc_ocelot_probe()
1256 ocelot->num_phys_ports = of_get_child_count(ports); in mscc_ocelot_probe()
1257 ocelot->num_flooding_pgids = 1; in mscc_ocelot_probe()
1259 ocelot->vcap = vsc7514_vcap_props; in mscc_ocelot_probe()
1260 ocelot->inj_prefix = OCELOT_TAG_PREFIX_NONE; in mscc_ocelot_probe()
1261 ocelot->xtr_prefix = OCELOT_TAG_PREFIX_NONE; in mscc_ocelot_probe()
1262 ocelot->npi = -1; in mscc_ocelot_probe()
1264 err = ocelot_init(ocelot); in mscc_ocelot_probe()
1272 if (ocelot->ptp) { in mscc_ocelot_probe()
1273 err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info); in mscc_ocelot_probe()
1275 dev_err(ocelot->dev, in mscc_ocelot_probe()
1277 ocelot->ptp = 0; in mscc_ocelot_probe()
1285 dev_info(&pdev->dev, "Ocelot switch probed\n"); in mscc_ocelot_probe()
1294 struct ocelot *ocelot = platform_get_drvdata(pdev); in mscc_ocelot_remove() local
1296 ocelot_deinit_timestamp(ocelot); in mscc_ocelot_remove()
1297 mscc_ocelot_release_ports(ocelot); in mscc_ocelot_remove()
1298 ocelot_deinit(ocelot); in mscc_ocelot_remove()
1310 .name = "ocelot-switch",
1317 MODULE_DESCRIPTION("Microsemi Ocelot switch driver");