From: sunil.kovvuri@gmail.com (sunil.kovvuri at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver
Date: Tue, 28 Aug 2018 16:27:14 +0530 [thread overview]
Message-ID: <1535453838-12154-12-git-send-email-sunil.kovvuri@gmail.com> (raw)
In-Reply-To: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com>
From: Sunil Goutham <sgoutham@marvell.com>
This patch adds basic template for Marvell OcteonTX2's
CGX ethernet interface driver. Just the probe.
RVU AF driver will use APIs exported by this driver
for various things like PF to physical interface mapping,
loopback mode, interface stats etc.
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
drivers/soc/marvell/Kconfig | 10 +++
drivers/soc/marvell/octeontx2/Makefile | 2 +
drivers/soc/marvell/octeontx2/cgx.c | 117 +++++++++++++++++++++++++++++++++
drivers/soc/marvell/octeontx2/cgx.h | 20 ++++++
4 files changed, 149 insertions(+)
create mode 100644 drivers/soc/marvell/octeontx2/cgx.c
create mode 100644 drivers/soc/marvell/octeontx2/cgx.h
diff --git a/drivers/soc/marvell/Kconfig b/drivers/soc/marvell/Kconfig
index 4499caf..73c8f8d 100644
--- a/drivers/soc/marvell/Kconfig
+++ b/drivers/soc/marvell/Kconfig
@@ -7,7 +7,17 @@ menu "Marvell SoC drivers"
config OCTEONTX2_AF
tristate "OcteonTX2 RVU Admin Function driver"
depends on ARM64 && PCI
+ select OCTEONTX2_CGX
help
This driver supports Marvell's OcteonTX2 Resource Virtualization
Unit's admin function manager which manages all RVU HW resources.
+
+config OCTEONTX2_CGX
+ tristate "OcteonTX2 MAC interface (CGX) driver"
+ depends on ARM64 && PCI
+ select PHYLIB
+ help
+ This driver supports programming and controlling of MAC
+ interfaces from RVU Admin Function driver.
+
endmenu
diff --git a/drivers/soc/marvell/octeontx2/Makefile b/drivers/soc/marvell/octeontx2/Makefile
index 8737ec3..50b8f74 100644
--- a/drivers/soc/marvell/octeontx2/Makefile
+++ b/drivers/soc/marvell/octeontx2/Makefile
@@ -3,6 +3,8 @@
# Makefile for Marvell's OcteonTX2 RVU Admin Function driver
#
+obj-$(CONFIG_OCTEONTX2_CGX) += octeontx2_cgx.o
obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
+octeontx2_cgx-y := cgx.o
octeontx2_af-y := rvu.o mbox.o
diff --git a/drivers/soc/marvell/octeontx2/cgx.c b/drivers/soc/marvell/octeontx2/cgx.c
new file mode 100644
index 0000000..6f0b6f4
--- /dev/null
+++ b/drivers/soc/marvell/octeontx2/cgx.c
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 CGX driver
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/phy.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>
+
+#include "cgx.h"
+
+#define DRV_NAME "octeontx2-cgx"
+#define DRV_STRING "Marvell OcteonTX2 CGX/MAC Driver"
+#define DRV_VERSION "1.0"
+
+struct cgx {
+ void __iomem *reg_base;
+ struct pci_dev *pdev;
+ u8 cgx_id;
+};
+
+/* Supported devices */
+static const struct pci_device_id cgx_id_table[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_CGX) },
+ { 0, } /* end of table */
+};
+
+MODULE_AUTHOR("Marvell International Ltd.");
+MODULE_DESCRIPTION(DRV_STRING);
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(DRV_VERSION);
+MODULE_DEVICE_TABLE(pci, cgx_id_table);
+
+static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+ int err;
+ struct device *dev = &pdev->dev;
+ struct cgx *cgx;
+
+ cgx = devm_kzalloc(dev, sizeof(*cgx), GFP_KERNEL);
+ if (!cgx)
+ return -ENOMEM;
+ cgx->pdev = pdev;
+
+ pci_set_drvdata(pdev, cgx);
+
+ err = pci_enable_device(pdev);
+ if (err) {
+ dev_err(dev, "Failed to enable PCI device\n");
+ pci_set_drvdata(pdev, NULL);
+ return err;
+ }
+
+ err = pci_request_regions(pdev, DRV_NAME);
+ if (err) {
+ dev_err(dev, "PCI request regions failed 0x%x\n", err);
+ goto err_disable_device;
+ }
+
+ /* MAP configuration registers */
+ cgx->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0);
+ if (!cgx->reg_base) {
+ dev_err(dev, "CGX: Cannot map CSR memory space, aborting\n");
+ err = -ENOMEM;
+ goto err_release_regions;
+ }
+
+ return 0;
+
+err_release_regions:
+ pci_release_regions(pdev);
+err_disable_device:
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+ return err;
+}
+
+static void cgx_remove(struct pci_dev *pdev)
+{
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+}
+
+static struct pci_driver cgx_driver = {
+ .name = DRV_NAME,
+ .id_table = cgx_id_table,
+ .probe = cgx_probe,
+ .remove = cgx_remove,
+};
+
+static int __init cgx_init_module(void)
+{
+ pr_info("%s: %s\n", DRV_NAME, DRV_STRING);
+
+ return pci_register_driver(&cgx_driver);
+}
+
+static void __exit cgx_cleanup_module(void)
+{
+ pci_unregister_driver(&cgx_driver);
+}
+
+module_init(cgx_init_module);
+module_exit(cgx_cleanup_module);
diff --git a/drivers/soc/marvell/octeontx2/cgx.h b/drivers/soc/marvell/octeontx2/cgx.h
new file mode 100644
index 0000000..8056264
--- /dev/null
+++ b/drivers/soc/marvell/octeontx2/cgx.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * Marvell OcteonTx2 CGX driver
+ *
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef CGX_H
+#define CGX_H
+
+ /* PCI device IDs */
+#define PCI_DEVID_OCTEONTX2_CGX 0xA059
+
+/* PCI BAR nos */
+#define PCI_CFG_REG_BAR_NUM 0
+
+#endif /* CGX_H */
--
2.7.4
next prev parent reply other threads:[~2018-08-28 10:57 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-28 10:57 [PATCH 00/15] soc: octeontx2: Add RVU admin function driver sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 01/15] soc: octeontx2: Add Marvell OcteonTX2 RVU AF driver sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 02/15] soc: octeontx2: Reset all RVU blocks sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 03/15] soc: octeontx2: Gather RVU blocks HW info sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 04/15] soc: octeontx2: Add mailbox support infra sunil.kovvuri at gmail.com
2018-08-28 12:03 ` Arnd Bergmann
2018-08-28 12:47 ` Sunil Kovvuri
2018-08-28 12:52 ` Arnd Bergmann
2018-08-28 13:23 ` Sunil Kovvuri
2018-08-30 13:56 ` Arnd Bergmann
2018-08-30 18:36 ` Sunil Kovvuri
2018-08-31 14:16 ` Arnd Bergmann
2018-08-31 17:25 ` Sunil Kovvuri
2018-08-28 10:57 ` [PATCH 05/15] soc: octeontx2: Add mailbox IRQ and msg handlers sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 06/15] soc: octeontx2: Convert mbox msg id check to a macro sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 07/15] soc: octeontx2: Scan blocks for LFs provisioned to PF/VF sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 08/15] soc: octeontx2: Add RVU block LF provisioning support sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 09/15] soc: octeontx2: Configure block LF's MSIX vector offset sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 10/15] soc: octeontx2: Reconfig MSIX base with IOVA sunil.kovvuri at gmail.com
2018-08-28 12:08 ` Arnd Bergmann
2018-08-28 12:42 ` Sunil Kovvuri
2018-08-28 12:57 ` Arnd Bergmann
2018-08-28 13:17 ` Sunil Kovvuri
2018-08-30 13:53 ` Arnd Bergmann
2018-08-30 18:39 ` Sunil Kovvuri
2018-08-28 10:57 ` sunil.kovvuri at gmail.com [this message]
2018-08-28 12:10 ` [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver Arnd Bergmann
2018-08-28 12:30 ` Sunil Kovvuri
2018-08-28 12:48 ` Arnd Bergmann
2018-08-28 13:09 ` Sunil Kovvuri
2018-08-30 14:07 ` Arnd Bergmann
2018-08-30 17:55 ` Sunil Kovvuri
2018-08-31 14:20 ` Arnd Bergmann
2018-08-31 16:00 ` Sunil Kovvuri
2018-08-31 18:29 ` Arnd Bergmann
2018-08-31 18:35 ` Sunil Kovvuri
2018-08-28 10:57 ` [PATCH 12/15] soc: octeontx2: Set RVU PFs to CGX LMACs mapping sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 13/15] soc: octeontx2: Add support for CGX link management sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 14/15] soc: octeontx2: Register for CGX lmac events sunil.kovvuri at gmail.com
2018-08-28 10:57 ` [PATCH 15/15] MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver sunil.kovvuri at gmail.com
2018-08-28 12:23 ` [PATCH 00/15] soc: octeontx2: Add RVU admin function driver Arnd Bergmann
2018-08-28 13:24 ` Sunil Kovvuri
2018-08-30 9:40 ` Sunil Kovvuri
2018-08-30 13:26 ` Andrew Lunn
2018-08-30 18:31 ` Sunil Kovvuri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535453838-12154-12-git-send-email-sunil.kovvuri@gmail.com \
--to=sunil.kovvuri@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).