From patchwork Tue Aug 28 10:57:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10578229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 524325A4 for ; Tue, 28 Aug 2018 11:06:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 406EE28D1E for ; Tue, 28 Aug 2018 11:06:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 347EE28DCC; Tue, 28 Aug 2018 11:06:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B75428D1E for ; Tue, 28 Aug 2018 11:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Pw3L2HgscldAExUeZsJVFrRrGvMRPf01laYElPtrI3U=; b=j8Y0ABIId0ppbXsK6vx8v/NWF9 s0gTORE4WKZidwuWjE6AmlaR4+xlo3wOqRVjHdtlJmzj3kZhdM5O/GsOuPVZ9cpz3UtRqqNAfmk3n udWFo2ajMtZqbPj9lsgqh+sUQ1Eax683DSEZQI/JA3TXLSve5UW1yLU8FPTnfBiZdiuAfLTxZL3nE pPp2L94+mwtMKFv+n8r6h/s++GhlPCMqkcKmrn7KKfsH4CFCRo60mJQENkblB0ESwE9xTSn66Z3uM 7C9WdLbI6VlyqlJBpp1SbzbxVOxjFEnXnWICHLQ145AJvWKOaFiVfM5W4t1brilEGzws9OY/sEiyh jlS77apw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fubpU-0007QK-TJ; Tue, 28 Aug 2018 11:06:36 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fubhZ-0001aY-D2 for linux-arm-kernel@lists.infradead.org; Tue, 28 Aug 2018 10:58:32 +0000 Received: by mail-pl1-x641.google.com with SMTP id b12-v6so568807plr.8 for ; Tue, 28 Aug 2018 03:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=weOadS4lpPoQPgGDTcJ/9TW9J6/Vv9yYEu24IdrbEIs=; b=gmOazeFNGG6maF0uWq9wPRzHK4UEYJEk+KWMJ8BAuy8WswTvgxmEDFX+gSY1cN91Gk NVmvvl+L1+nh+pEk0T7ixyo47f2Z2+YkoNVpnjMn11SGIg4Tq/LwgMNPcKZMLcaVNJsa 3RRq7pW2cjMxuYpEit9HeZzJD1hXo6v3meKQunNXd7YNcYutEqseYFn+aYrNUltUnBTg JALlkwVMcv/CYw2qeImLapk/twz9P1L21bGlb0X47eJA6JVNt0GR21Z7i6ViGPuEpP7D ZK6MdIgop53nYE/hdenptl6JyX5YzrB8VPvT9sLij0iydsfJsmXgzHwCOWDE6gI/kGu+ ur7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=weOadS4lpPoQPgGDTcJ/9TW9J6/Vv9yYEu24IdrbEIs=; b=geNWaTr31Qd/uwmHoo7BIKY8RvJ4siiaYc5xmLsPuGxhHQNySPpQY8EgBC1Ujcnt8X NWS5IE+d1L4snM5fI/LGbCdXdxuZkyrTEQPf2O4JBA40lCC1WcSmFK+Mxpg+NYvoIJHo sldPQY5pfKaQkngB9BkLfYphOPEhLqljDnB2FkuddxOqoyQKLRN6UtMr8xbTWdvBD+vG +5Orn7VUshHllhhCL8j3THMy+p/isWoMjTaBbQR3xSlkQT4pnwR11nKR0ToEhwVpheNz 1Q2O/hV1Cy/Qu26E0U8+N+8hppFasw/kDTehGpIUhO5QJzoVK/8TgckvcoP57pBUB6jr wedw== X-Gm-Message-State: APzg51B/g0h+uPutw3hVx11yVSGvb/Z88PnYC741MKnAxI50bUZnBdIq Jz6m7sdYUlN7NMg7IZSLlhYKbugd X-Google-Smtp-Source: ANB0Vdbm8irCtA95hsW10VfU/AhyZ6AiGunYnFTXEK9OJJ+D+CGDWHL0znorJRs2pok36FsLfF4qkg== X-Received: by 2002:a17:902:8ec7:: with SMTP id x7-v6mr1033603plo.336.1535453894058; Tue, 28 Aug 2018 03:58:14 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id n22-v6sm2946798pfj.68.2018.08.28.03.58.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 03:58:13 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver Date: Tue, 28 Aug 2018 16:27:14 +0530 Message-Id: <1535453838-12154-12-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com> References: <1535453838-12154-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180828_035825_680117_786C85F2 X-CRM114-Status: GOOD ( 20.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-soc@vger.kernel.org, Sunil Goutham , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham 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 --- 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 */