1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
4 #include <rte_bus_pci.h>
6 #include <rte_rawdev.h>
7 #include <rte_rawdev_pmd.h>
10 #include <roc_bphy_irq.h>
12 #include "cnxk_bphy_irq.h"
14 static struct bphy_device *
15 cnxk_bphy_get_bphy_dev_by_dev_id(uint16_t dev_id)
17 struct rte_rawdev *rawdev;
19 if (!rte_rawdev_pmd_is_valid_dev(dev_id))
22 rawdev = &rte_rawdevs[dev_id];
24 return (struct bphy_device *)rawdev->dev_private;
28 cnxk_bphy_irq_max_get(uint16_t dev_id)
30 struct roc_bphy_irq_chip *irq_chip;
31 struct bphy_device *bphy_dev;
33 bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
34 irq_chip = bphy_dev->irq_chip;
36 return irq_chip->max_irq;
40 cnxk_bphy_intr_init(uint16_t dev_id)
42 struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
44 bphy_dev->irq_chip = roc_bphy_intr_init();
45 if (bphy_dev->irq_chip == NULL)
52 cnxk_bphy_intr_fini(uint16_t dev_id)
54 struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
55 struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip;
57 roc_bphy_intr_fini(irq_chip);
58 bphy_dev->irq_chip = NULL;
62 cnxk_bphy_intr_register(uint16_t dev_id, int irq_num,
63 cnxk_bphy_intr_handler_t handler, void *data, int cpu)
65 struct roc_bphy_intr intr = {
67 .intr_handler = handler,
72 struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
73 struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip;
77 if (!handler || !data)
80 return roc_bphy_intr_register(irq_chip, &intr);
84 cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num)
86 struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
88 if (bphy_dev->irq_chip)
89 roc_bphy_handler_clear(bphy_dev->irq_chip, irq_num);
91 plt_err("Missing irq chip");
95 cnxk_bphy_mem_get(uint16_t dev_id)
97 struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id);
99 return &bphy_dev->mem;