net: mscc: Move ocelot_send and ocelot_recv in a different file.
[platform/kernel/u-boot.git] / drivers / net / mscc_eswitch / ocelot_switch.c
1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2 /*
3  * Copyright (c) 2018 Microsemi Corporation
4  */
5
6 #include <common.h>
7 #include <config.h>
8 #include <dm.h>
9 #include <dm/of_access.h>
10 #include <dm/of_addr.h>
11 #include <fdt_support.h>
12 #include <linux/io.h>
13 #include <linux/ioport.h>
14 #include <miiphy.h>
15 #include <net.h>
16 #include <wait_bit.h>
17
18 #include "mscc_miim.h"
19 #include "mscc_xfer.h"
20
21 #define PHY_CFG                         0x0
22 #define PHY_CFG_ENA                             0xF
23 #define PHY_CFG_COMMON_RST                      BIT(4)
24 #define PHY_CFG_RST                             (0xF << 5)
25 #define PHY_STAT                        0x4
26 #define PHY_STAT_SUPERVISOR_COMPLETE            BIT(0)
27
28 #define ANA_PORT_VLAN_CFG(x)            (0x7000 + 0x100 * (x))
29 #define         ANA_PORT_VLAN_CFG_AWARE_ENA     BIT(20)
30 #define         ANA_PORT_VLAN_CFG_POP_CNT(x)    ((x) << 18)
31 #define ANA_PORT_PORT_CFG(x)            (0x7070 + 0x100 * (x))
32 #define         ANA_PORT_PORT_CFG_RECV_ENA      BIT(6)
33 #define ANA_TABLES_MACHDATA             0x8b34
34 #define ANA_TABLES_MACLDATA             0x8b38
35 #define ANA_TABLES_MACACCESS            0x8b3c
36 #define         ANA_TABLES_MACACCESS_VALID      BIT(11)
37 #define         ANA_TABLES_MACACCESS_ENTRYTYPE(x)   ((x) << 9)
38 #define         ANA_TABLES_MACACCESS_DEST_IDX(x)    ((x) << 3)
39 #define         ANA_TABLES_MACACCESS_MAC_TABLE_CMD(x)   (x)
40 #define         ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M    GENMASK(2, 0)
41 #define         MACACCESS_CMD_IDLE                     0
42 #define         MACACCESS_CMD_LEARN                    1
43 #define         MACACCESS_CMD_GET_NEXT                 4
44 #define ANA_PGID(x)                     (0x8c00 + 4 * (x))
45
46 #define SYS_FRM_AGING                   0x574
47 #define         SYS_FRM_AGING_ENA               BIT(20)
48
49 #define SYS_SYSTEM_RST_CFG              0x508
50 #define         SYS_SYSTEM_RST_MEM_INIT         BIT(0)
51 #define         SYS_SYSTEM_RST_MEM_ENA          BIT(1)
52 #define         SYS_SYSTEM_RST_CORE_ENA         BIT(2)
53 #define SYS_PORT_MODE(x)                (0x514 + 0x4 * (x))
54 #define         SYS_PORT_MODE_INCL_INJ_HDR(x)   ((x) << 3)
55 #define         SYS_PORT_MODE_INCL_INJ_HDR_M    GENMASK(4, 3)
56 #define         SYS_PORT_MODE_INCL_XTR_HDR(x)   ((x) << 1)
57 #define         SYS_PORT_MODE_INCL_XTR_HDR_M    GENMASK(2, 1)
58 #define SYS_PAUSE_CFG(x)                (0x608 + 0x4 * (x))
59 #define         SYS_PAUSE_CFG_PAUSE_ENA         BIT(0)
60
61 #define QSYS_SWITCH_PORT_MODE(x)        (0x11234 + 0x4 * (x))
62 #define         QSYS_SWITCH_PORT_MODE_PORT_ENA  BIT(14)
63 #define QSYS_QMAP                       0x112d8
64 #define QSYS_EGR_NO_SHARING             0x1129c
65
66 /* Port registers */
67 #define DEV_CLOCK_CFG                   0x0
68 #define DEV_CLOCK_CFG_LINK_SPEED_1000           1
69 #define DEV_MAC_ENA_CFG                 0x1c
70 #define         DEV_MAC_ENA_CFG_RX_ENA          BIT(4)
71 #define         DEV_MAC_ENA_CFG_TX_ENA          BIT(0)
72
73 #define DEV_MAC_IFG_CFG                 0x30
74 #define         DEV_MAC_IFG_CFG_TX_IFG(x)       ((x) << 8)
75 #define         DEV_MAC_IFG_CFG_RX_IFG2(x)      ((x) << 4)
76 #define         DEV_MAC_IFG_CFG_RX_IFG1(x)      (x)
77
78 #define PCS1G_CFG                       0x48
79 #define         PCS1G_MODE_CFG_SGMII_MODE_ENA   BIT(0)
80 #define PCS1G_MODE_CFG                  0x4c
81 #define         PCS1G_MODE_CFG_UNIDIR_MODE_ENA  BIT(4)
82 #define         PCS1G_MODE_CFG_SGMII_MODE_ENA   BIT(0)
83 #define PCS1G_SD_CFG                    0x50
84 #define PCS1G_ANEG_CFG                  0x54
85 #define         PCS1G_ANEG_CFG_ADV_ABILITY(x)   ((x) << 16)
86
87 #define QS_XTR_GRP_CFG(x)               (4 * (x))
88 #define QS_XTR_GRP_CFG_MODE(x)                  ((x) << 2)
89 #define         QS_XTR_GRP_CFG_STATUS_WORD_POS  BIT(1)
90 #define         QS_XTR_GRP_CFG_BYTE_SWAP        BIT(0)
91 #define QS_INJ_GRP_CFG(x)               (0x24 + (x) * 4)
92 #define         QS_INJ_GRP_CFG_MODE(x)          ((x) << 2)
93 #define         QS_INJ_GRP_CFG_BYTE_SWAP        BIT(0)
94
95 #define IFH_INJ_BYPASS          BIT(31)
96 #define IFH_TAG_TYPE_C          0
97 #define MAC_VID                 1
98 #define CPU_PORT                11
99 #define INTERNAL_PORT_MSK       0xF
100 #define IFH_LEN                 4
101 #define ETH_ALEN                6
102 #define PGID_BROADCAST          13
103 #define PGID_UNICAST            14
104 #define PGID_SRC                80
105
106 enum ocelot_target {
107         ANA,
108         QS,
109         QSYS,
110         REW,
111         SYS,
112         HSIO,
113         PORT0,
114         PORT1,
115         PORT2,
116         PORT3,
117         TARGET_MAX,
118 };
119
120 #define MAX_PORT (PORT3 - PORT0)
121
122 /* MAC table entry types.
123  * ENTRYTYPE_NORMAL is subject to aging.
124  * ENTRYTYPE_LOCKED is not subject to aging.
125  * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
126  * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
127  */
128 enum macaccess_entry_type {
129         ENTRYTYPE_NORMAL = 0,
130         ENTRYTYPE_LOCKED,
131         ENTRYTYPE_MACv4,
132         ENTRYTYPE_MACv6,
133 };
134
135 enum ocelot_mdio_target {
136         MIIM,
137         PHY,
138         TARGET_MDIO_MAX,
139 };
140
141 enum ocelot_phy_id {
142         INTERNAL,
143         EXTERNAL,
144         NUM_PHY,
145 };
146
147 struct ocelot_private {
148         void __iomem *regs[TARGET_MAX];
149
150         struct mii_dev *bus[NUM_PHY];
151         struct phy_device *phydev;
152         int phy_mode;
153         int max_speed;
154
155         int rx_pos;
156         int rx_siz;
157         int rx_off;
158         int tx_num;
159
160         u8 tx_adj_packetbuf[PKTSIZE_ALIGN + PKTALIGN];
161         void *tx_adj_buf;
162 };
163
164 static const unsigned long ocelot_regs_qs[] = {
165         [MSCC_QS_XTR_RD] = 0x8,
166         [MSCC_QS_XTR_FLUSH] = 0x18,
167         [MSCC_QS_XTR_DATA_PRESENT] = 0x1c,
168         [MSCC_QS_INJ_WR] = 0x2c,
169         [MSCC_QS_INJ_CTRL] = 0x34,
170 };
171
172 struct mscc_miim_dev miim[NUM_PHY];
173
174 static int mscc_miim_reset(struct mii_dev *bus)
175 {
176         struct mscc_miim_dev *miim = (struct mscc_miim_dev *)bus->priv;
177
178         if (miim->phy_regs) {
179                 writel(0, miim->phy_regs + PHY_CFG);
180                 writel(PHY_CFG_RST | PHY_CFG_COMMON_RST
181                        | PHY_CFG_ENA, miim->phy_regs + PHY_CFG);
182                 mdelay(500);
183         }
184
185         return 0;
186 }
187
188 /* For now only setup the internal mdio bus */
189 static struct mii_dev *ocelot_mdiobus_init(struct udevice *dev)
190 {
191         unsigned long phy_size[TARGET_MAX];
192         phys_addr_t phy_base[TARGET_MAX];
193         struct ofnode_phandle_args phandle;
194         ofnode eth_node, node, mdio_node;
195         struct resource res;
196         struct mii_dev *bus;
197         fdt32_t faddr;
198         int i;
199
200         bus = mdio_alloc();
201
202         if (!bus)
203                 return NULL;
204
205         /* gathered only the first mdio bus */
206         eth_node = dev_read_first_subnode(dev);
207         node = ofnode_first_subnode(eth_node);
208         ofnode_parse_phandle_with_args(node, "phy-handle", NULL, 0, 0,
209                                        &phandle);
210         mdio_node = ofnode_get_parent(phandle.node);
211
212         for (i = 0; i < TARGET_MDIO_MAX; i++) {
213                 if (ofnode_read_resource(mdio_node, i, &res)) {
214                         pr_err("%s: get OF resource failed\n", __func__);
215                         return NULL;
216                 }
217                 faddr = cpu_to_fdt32(res.start);
218                 phy_base[i] = ofnode_translate_address(mdio_node, &faddr);
219                 phy_size[i] = res.end - res.start;
220         }
221
222         strcpy(bus->name, "miim-internal");
223         miim[INTERNAL].phy_regs = ioremap(phy_base[PHY], phy_size[PHY]);
224         miim[INTERNAL].regs = ioremap(phy_base[MIIM], phy_size[MIIM]);
225         bus->priv = &miim[INTERNAL];
226         bus->reset = mscc_miim_reset;
227         bus->read = mscc_miim_read;
228         bus->write = mscc_miim_write;
229
230         if (mdio_register(bus))
231                 return NULL;
232         else
233                 return bus;
234 }
235
236 __weak void mscc_switch_reset(void)
237 {
238 }
239
240 static void ocelot_stop(struct udevice *dev)
241 {
242         struct ocelot_private *priv = dev_get_priv(dev);
243         int i;
244
245         mscc_switch_reset();
246         for (i = 0; i < NUM_PHY; i++)
247                 if (priv->bus[i])
248                         mscc_miim_reset(priv->bus[i]);
249 }
250
251 static void ocelot_cpu_capture_setup(struct ocelot_private *priv)
252 {
253         int i;
254
255         /* map the 8 CPU extraction queues to CPU port 11 */
256         writel(0, priv->regs[QSYS] + QSYS_QMAP);
257
258         for (i = 0; i <= 1; i++) {
259                 /*
260                  * Do byte-swap and expect status after last data word
261                  * Extraction: Mode: manual extraction) | Byte_swap
262                  */
263                 writel(QS_XTR_GRP_CFG_MODE(1) | QS_XTR_GRP_CFG_BYTE_SWAP,
264                        priv->regs[QS] + QS_XTR_GRP_CFG(i));
265                 /*
266                  * Injection: Mode: manual extraction | Byte_swap
267                  */
268                 writel(QS_INJ_GRP_CFG_MODE(1) | QS_INJ_GRP_CFG_BYTE_SWAP,
269                        priv->regs[QS] + QS_INJ_GRP_CFG(i));
270         }
271
272         for (i = 0; i <= 1; i++)
273                 /* Enable IFH insertion/parsing on CPU ports */
274                 writel(SYS_PORT_MODE_INCL_INJ_HDR(1) |
275                        SYS_PORT_MODE_INCL_XTR_HDR(1),
276                        priv->regs[SYS] + SYS_PORT_MODE(CPU_PORT + i));
277         /*
278          * Setup the CPU port as VLAN aware to support switching frames
279          * based on tags
280          */
281         writel(ANA_PORT_VLAN_CFG_AWARE_ENA | ANA_PORT_VLAN_CFG_POP_CNT(1) |
282                MAC_VID, priv->regs[ANA] + ANA_PORT_VLAN_CFG(CPU_PORT));
283
284         /* Disable learning (only RECV_ENA must be set) */
285         writel(ANA_PORT_PORT_CFG_RECV_ENA,
286                priv->regs[ANA] + ANA_PORT_PORT_CFG(CPU_PORT));
287
288         /* Enable switching to/from cpu port */
289         setbits_le32(priv->regs[QSYS] + QSYS_SWITCH_PORT_MODE(CPU_PORT),
290                      QSYS_SWITCH_PORT_MODE_PORT_ENA);
291
292         /* No pause on CPU port - not needed (off by default) */
293         clrbits_le32(priv->regs[SYS] + SYS_PAUSE_CFG(CPU_PORT),
294                      SYS_PAUSE_CFG_PAUSE_ENA);
295
296         setbits_le32(priv->regs[QSYS] + QSYS_EGR_NO_SHARING, BIT(CPU_PORT));
297 }
298
299 static void ocelot_port_init(struct ocelot_private *priv, int port)
300 {
301         void __iomem *regs = priv->regs[port];
302
303         /* Enable PCS */
304         writel(PCS1G_MODE_CFG_SGMII_MODE_ENA, regs + PCS1G_CFG);
305
306         /* Disable Signal Detect */
307         writel(0, regs + PCS1G_SD_CFG);
308
309         /* Enable MAC RX and TX */
310         writel(DEV_MAC_ENA_CFG_RX_ENA | DEV_MAC_ENA_CFG_TX_ENA,
311                regs + DEV_MAC_ENA_CFG);
312
313         /* Clear sgmii_mode_ena */
314         writel(0, regs + PCS1G_MODE_CFG);
315
316         /*
317          * Clear sw_resolve_ena(bit 0) and set adv_ability to
318          * something meaningful just in case
319          */
320         writel(PCS1G_ANEG_CFG_ADV_ABILITY(0x20), regs + PCS1G_ANEG_CFG);
321
322         /* Set MAC IFG Gaps */
323         writel(DEV_MAC_IFG_CFG_TX_IFG(5) | DEV_MAC_IFG_CFG_RX_IFG1(5) |
324                DEV_MAC_IFG_CFG_RX_IFG2(1), regs + DEV_MAC_IFG_CFG);
325
326         /* Set link speed and release all resets */
327         writel(DEV_CLOCK_CFG_LINK_SPEED_1000, regs + DEV_CLOCK_CFG);
328
329         /* Make VLAN aware for CPU traffic */
330         writel(ANA_PORT_VLAN_CFG_AWARE_ENA | ANA_PORT_VLAN_CFG_POP_CNT(1) |
331                MAC_VID, priv->regs[ANA] + ANA_PORT_VLAN_CFG(port - PORT0));
332
333         /* Enable the port in the core */
334         setbits_le32(priv->regs[QSYS] + QSYS_SWITCH_PORT_MODE(port - PORT0),
335                      QSYS_SWITCH_PORT_MODE_PORT_ENA);
336 }
337
338 static int ocelot_switch_init(struct ocelot_private *priv)
339 {
340         /* Reset switch & memories */
341         writel(SYS_SYSTEM_RST_MEM_ENA | SYS_SYSTEM_RST_MEM_INIT,
342                priv->regs[SYS] + SYS_SYSTEM_RST_CFG);
343
344         /* Wait to complete */
345         if (wait_for_bit_le32(priv->regs[SYS] + SYS_SYSTEM_RST_CFG,
346                               SYS_SYSTEM_RST_MEM_INIT, false, 2000, false)) {
347                 pr_err("Timeout in memory reset\n");
348                 return -EIO;
349         }
350
351         /* Enable switch core */
352         setbits_le32(priv->regs[SYS] + SYS_SYSTEM_RST_CFG,
353                      SYS_SYSTEM_RST_CORE_ENA);
354
355         return 0;
356 }
357
358 static int ocelot_initialize(struct ocelot_private *priv)
359 {
360         int ret, i;
361
362         /* Initialize switch memories, enable core */
363         ret = ocelot_switch_init(priv);
364         if (ret)
365                 return ret;
366         /*
367          * Disable port-to-port by switching
368          * Put fron ports in "port isolation modes" - i.e. they cant send
369          * to other ports - via the PGID sorce masks.
370          */
371         for (i = 0; i <= MAX_PORT; i++)
372                 writel(0, priv->regs[ANA] + ANA_PGID(PGID_SRC + i));
373
374         /* Flush queues */
375         mscc_flush(priv->regs[QS], ocelot_regs_qs);
376
377         /* Setup frame ageing - "2 sec" - The unit is 6.5us on Ocelot */
378         writel(SYS_FRM_AGING_ENA | (20000000 / 65),
379                priv->regs[SYS] + SYS_FRM_AGING);
380
381         for (i = PORT0; i <= PORT3; i++)
382                 ocelot_port_init(priv, i);
383
384         ocelot_cpu_capture_setup(priv);
385
386         debug("Ports enabled\n");
387
388         return 0;
389 }
390
391 static inline int ocelot_vlant_wait_for_completion(struct ocelot_private *priv)
392 {
393         unsigned int val, timeout = 10;
394
395         /* Wait for the issued mac table command to be completed, or timeout.
396          * When the command read from ANA_TABLES_MACACCESS is
397          * MACACCESS_CMD_IDLE, the issued command completed successfully.
398          */
399         do {
400                 val = readl(priv->regs[ANA] + ANA_TABLES_MACACCESS);
401                 val &= ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M;
402         } while (val != MACACCESS_CMD_IDLE && timeout--);
403
404         if (!timeout)
405                 return -ETIMEDOUT;
406
407         return 0;
408 }
409
410 static int ocelot_mac_table_add(struct ocelot_private *priv,
411                                 const unsigned char mac[ETH_ALEN], int pgid)
412 {
413         u32 macl = 0, mach = 0;
414         int ret;
415
416         /* Set the MAC address to handle and the vlan associated in a format
417          * understood by the hardware.
418          */
419         mach |= MAC_VID << 16;
420         mach |= ((u32)mac[0]) << 8;
421         mach |= ((u32)mac[1]) << 0;
422         macl |= ((u32)mac[2]) << 24;
423         macl |= ((u32)mac[3]) << 16;
424         macl |= ((u32)mac[4]) << 8;
425         macl |= ((u32)mac[5]) << 0;
426
427         writel(macl, priv->regs[ANA] + ANA_TABLES_MACLDATA);
428         writel(mach, priv->regs[ANA] + ANA_TABLES_MACHDATA);
429
430         writel(ANA_TABLES_MACACCESS_VALID |
431                ANA_TABLES_MACACCESS_DEST_IDX(pgid) |
432                ANA_TABLES_MACACCESS_ENTRYTYPE(ENTRYTYPE_LOCKED) |
433                ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN),
434                priv->regs[ANA] + ANA_TABLES_MACACCESS);
435
436         ret = ocelot_vlant_wait_for_completion(priv);
437
438         return ret;
439 }
440
441 static int ocelot_write_hwaddr(struct udevice *dev)
442 {
443         struct ocelot_private *priv = dev_get_priv(dev);
444         struct eth_pdata *pdata = dev_get_platdata(dev);
445
446         ocelot_mac_table_add(priv, pdata->enetaddr, PGID_UNICAST);
447
448         writel(BIT(CPU_PORT), priv->regs[ANA] + ANA_PGID(PGID_UNICAST));
449
450         return 0;
451 }
452
453 static int ocelot_start(struct udevice *dev)
454 {
455         struct ocelot_private *priv = dev_get_priv(dev);
456         struct eth_pdata *pdata = dev_get_platdata(dev);
457         const unsigned char mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff,
458                                               0xff };
459         int ret;
460
461         ret = ocelot_initialize(priv);
462         if (ret)
463                 return ret;
464
465         /* Set MAC address tables entries for CPU redirection */
466         ocelot_mac_table_add(priv, mac, PGID_BROADCAST);
467
468         writel(BIT(CPU_PORT) | INTERNAL_PORT_MSK,
469                priv->regs[ANA] + ANA_PGID(PGID_BROADCAST));
470
471         /* It should be setup latter in ocelot_write_hwaddr */
472         ocelot_mac_table_add(priv, pdata->enetaddr, PGID_UNICAST);
473
474         writel(BIT(CPU_PORT), priv->regs[ANA] + ANA_PGID(PGID_UNICAST));
475
476         return 0;
477 }
478
479 static int ocelot_send(struct udevice *dev, void *packet, int length)
480 {
481         struct ocelot_private *priv = dev_get_priv(dev);
482         u32 ifh[IFH_LEN];
483         int port = BIT(0);      /* use port 0 */
484         u32 *buf = packet;
485
486         /*
487          * Generate the IFH for frame injection
488          *
489          * The IFH is a 128bit-value
490          * bit 127: bypass the analyzer processing
491          * bit 56-67: destination mask
492          * bit 28-29: pop_cnt: 3 disables all rewriting of the frame
493          * bit 20-27: cpu extraction queue mask
494          * bit 16: tag type 0: C-tag, 1: S-tag
495          * bit 0-11: VID
496          */
497         ifh[0] = IFH_INJ_BYPASS;
498         ifh[1] = (0xf00 & port) >> 8;
499         ifh[2] = (0xff & port) << 24;
500         ifh[3] = (IFH_TAG_TYPE_C << 16);
501
502         return mscc_send(priv->regs[QS], ocelot_regs_qs,
503                          ifh, IFH_LEN, buf, length);
504 }
505
506 static int ocelot_recv(struct udevice *dev, int flags, uchar **packetp)
507 {
508         struct ocelot_private *priv = dev_get_priv(dev);
509         u32 *rxbuf = (u32 *)net_rx_packets[0];
510         int byte_cnt;
511
512         byte_cnt = mscc_recv(priv->regs[QS], ocelot_regs_qs, rxbuf, IFH_LEN,
513                              false);
514
515         *packetp = net_rx_packets[0];
516
517         return byte_cnt;
518 }
519
520 static int ocelot_probe(struct udevice *dev)
521 {
522         struct ocelot_private *priv = dev_get_priv(dev);
523         int ret, i;
524
525         struct {
526                 enum ocelot_target id;
527                 char *name;
528         } reg[] = {
529                 { SYS, "sys" },
530                 { REW, "rew" },
531                 { QSYS, "qsys" },
532                 { ANA, "ana" },
533                 { QS, "qs" },
534                 { HSIO, "hsio" },
535                 { PORT0, "port0" },
536                 { PORT1, "port1" },
537                 { PORT2, "port2" },
538                 { PORT3, "port3" },
539         };
540
541         for (i = 0; i < ARRAY_SIZE(reg); i++) {
542                 priv->regs[reg[i].id] = dev_remap_addr_name(dev, reg[i].name);
543                 if (!priv->regs[reg[i].id]) {
544                         pr_err
545                             ("Error %d: can't get regs base addresses for %s\n",
546                              ret, reg[i].name);
547                         return -ENOMEM;
548                 }
549         }
550
551         priv->bus[INTERNAL] = ocelot_mdiobus_init(dev);
552
553         for (i = 0; i < 4; i++) {
554                 phy_connect(priv->bus[INTERNAL], i, dev,
555                             PHY_INTERFACE_MODE_NONE);
556         }
557
558         return 0;
559 }
560
561 static int ocelot_remove(struct udevice *dev)
562 {
563         struct ocelot_private *priv = dev_get_priv(dev);
564         int i;
565
566         for (i = 0; i < NUM_PHY; i++) {
567                 mdio_unregister(priv->bus[i]);
568                 mdio_free(priv->bus[i]);
569         }
570
571         return 0;
572 }
573
574 static const struct eth_ops ocelot_ops = {
575         .start        = ocelot_start,
576         .stop         = ocelot_stop,
577         .send         = ocelot_send,
578         .recv         = ocelot_recv,
579         .write_hwaddr = ocelot_write_hwaddr,
580 };
581
582 static const struct udevice_id mscc_ocelot_ids[] = {
583         {.compatible = "mscc,vsc7514-switch"},
584         { /* Sentinel */ }
585 };
586
587 U_BOOT_DRIVER(ocelot) = {
588         .name     = "ocelot-switch",
589         .id       = UCLASS_ETH,
590         .of_match = mscc_ocelot_ids,
591         .probe    = ocelot_probe,
592         .remove   = ocelot_remove,
593         .ops      = &ocelot_ops,
594         .priv_auto_alloc_size = sizeof(struct ocelot_private),
595         .platdata_auto_alloc_size = sizeof(struct eth_pdata),
596 };