From patchwork Tue Sep 4 11:54:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587229 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 C46AB920 for ; Tue, 4 Sep 2018 12:04:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB2BF28F94 for ; Tue, 4 Sep 2018 12:04:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E99E2901B; Tue, 4 Sep 2018 12:04:21 +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 EA61A28F94 for ; Tue, 4 Sep 2018 12:04:20 +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=tZyixfNBvwXebmg8xCC8ymGDQHO6EG1MuIwedi0PxvY=; b=Okw//ONifZRIexzYY0DozlDkr8 7l41NrsZcywMxf9ZHKEkylTg0JYz4rmVRHSRSak6pRNeFW0FvcEZu5sFR6bkst/4G7QjpThrsKDB/ zltuzjsPVDhCrr8agK4LsKF3jrJ3hYWe9mxzXJ+C0EKb97pG6FoM5+1KxQDz+oqA3aefWOZNl9vuu AhUiFvXREpa2awReCibg86BngZWoPQbk5rxhDXFqPmU67XB6ncrL1gyw7k2tQMC4AByckaLu7AFTh YJUoBCgdXDbi6gv3PBgtncQhgqE5IKbIj+1djRGbcscatec2XPbqxFKHWb+rN/3KW1YUABpTtVT5O GUvM8jYQ==; 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 1fxA3z-0001tY-49; Tue, 04 Sep 2018 12:04:07 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fx9w7-0005qP-HW for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 11:56:03 +0000 Received: by mail-pl1-x643.google.com with SMTP id g2-v6so570422plo.2 for ; Tue, 04 Sep 2018 04:55:56 -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=amDUWHx9CIuzOcKbTAVVhSov5p8oHO7SGU2wtf8SFSk=; b=IiYpANy5zDIcNvocZEHJEEXJ88IulOnmCgGbMD/BlVfJld9U4rk58Ts8W7jt90mPDX NyMFRVkt5joAsufYcORy2ddK+Qh8q9nR4/0YHe3PtYj23A/iAvabKnw4hI9Ycpt5PqxA sm3NRbNwdsHSXIUFOUaoL2mdTiMGxubnZIqaiGXDAroRX3KdDDCr3wQ9XZog87DSMCTH DmHcMA/eDa/2XhB+zFH1HJMVwlErbyVqSPO8evkjipYDbCED1DMqurmAhY2hHp668eqE xWUD0Hac0bdOfS8ejss+d5NAK298ralij5TbMLbWrzTDj/xJ1xsDN154EpBPIifNr0UV o44A== 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=amDUWHx9CIuzOcKbTAVVhSov5p8oHO7SGU2wtf8SFSk=; b=IlvRz7dWuGZDGfXoG3utN9jJkyrQq6tsAVoSzQTgSA3Mh84a2a+us75KlWQGAP/wKr /F1BbVf2h3MPqB8MeK5o7H/aoXyuW/44ZLRP08QqsQOkFahR4WrTzD//wscck+wOnauH oMqUCRzBNGe9e5Nrq00R+d8Eh102vZS7vFevDYmHeUjUUecKzIpr6z0hGMo756FJRQo0 gLWeyX3+XE/D85AVAYJN8BJ4+DUR2SpeAncm6kfd3iqM6/asT4uR+W0MD6rPZMjY7WZ1 iaQqvG2HMR5QgGPl16fp+v8aDQ4cDiHDykqr8zZ9yJ+Fbme5Y2X/UbmIQOPpZANox7vW JqRQ== X-Gm-Message-State: APzg51CEmyYsuJg1gD7UNFhSRFwfYHOzVX4HZ12eL2UNIodkgAn8FzAa EaczlEoKituBaHvooC9v5jk= X-Google-Smtp-Source: ANB0VdZZsRbpfzlHGOIbfyRPI13LVIjrLOKYq6fxWbvR+DbF+Pw4OY+yRmFlFNcMVS64BY+vKrGpEA== X-Received: by 2002:a17:902:74ca:: with SMTP id f10-v6mr33533514plt.260.1536062155756; Tue, 04 Sep 2018 04:55:55 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id u184-v6sm29740190pgd.46.2018.09.04.04.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 04:55:54 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v2 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver Date: Tue, 4 Sep 2018 17:24:46 +0530 Message-Id: <1536062090-30446-12-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536062090-30446-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536062090-30446-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180904_045559_620495_82B32670 X-CRM114-Status: GOOD ( 23.29 ) 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: andrew@lunn.ch, linux-soc@vger.kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, Sunil Goutham 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. Hence marged both drivers into a single module. Signed-off-by: Sunil Goutham --- drivers/soc/marvell/Kconfig | 3 +- drivers/soc/marvell/octeontx2/Makefile | 2 +- drivers/soc/marvell/octeontx2/cgx.c | 102 +++++++++++++++++++++++++++++++++ drivers/soc/marvell/octeontx2/cgx.h | 22 +++++++ drivers/soc/marvell/octeontx2/rvu.c | 14 ++++- 5 files changed, 140 insertions(+), 3 deletions(-) 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 428d22e..8f36f3a 100644 --- a/drivers/soc/marvell/Kconfig +++ b/drivers/soc/marvell/Kconfig @@ -11,7 +11,8 @@ config OCTEONTX2_AF tristate "OcteonTX2 RVU Admin Function driver" select OCTEONTX2_MBOX depends on ARM64 && PCI - help + ---help--- This driver supports Marvell's OcteonTX2 Resource Virtualization Unit's admin function manager which manages all RVU HW resources. + endmenu diff --git a/drivers/soc/marvell/octeontx2/Makefile b/drivers/soc/marvell/octeontx2/Makefile index ac17cb9..8646421 100644 --- a/drivers/soc/marvell/octeontx2/Makefile +++ b/drivers/soc/marvell/octeontx2/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_OCTEONTX2_MBOX) += octeontx2_mbox.o obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o -octeontx2_af-y := rvu.o +octeontx2_af-y := cgx.o rvu.o diff --git a/drivers/soc/marvell/octeontx2/cgx.c b/drivers/soc/marvell/octeontx2/cgx.c new file mode 100644 index 0000000..47aa4cb --- /dev/null +++ b/drivers/soc/marvell/octeontx2/cgx.c @@ -0,0 +1,102 @@ +// 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); +} + +struct pci_driver cgx_driver = { + .name = DRV_NAME, + .id_table = cgx_id_table, + .probe = cgx_probe, + .remove = cgx_remove, +}; diff --git a/drivers/soc/marvell/octeontx2/cgx.h b/drivers/soc/marvell/octeontx2/cgx.h new file mode 100644 index 0000000..a7d4b39 --- /dev/null +++ b/drivers/soc/marvell/octeontx2/cgx.h @@ -0,0 +1,22 @@ +/* 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 + +extern struct pci_driver cgx_driver; + +#endif /* CGX_H */ diff --git a/drivers/soc/marvell/octeontx2/rvu.c b/drivers/soc/marvell/octeontx2/rvu.c index 40684c9..daa6fd3 100644 --- a/drivers/soc/marvell/octeontx2/rvu.c +++ b/drivers/soc/marvell/octeontx2/rvu.c @@ -15,6 +15,7 @@ #include #include +#include "cgx.h" #include "rvu.h" #include "rvu_reg.h" @@ -1605,14 +1606,25 @@ static struct pci_driver rvu_driver = { static int __init rvu_init_module(void) { + int err; + pr_info("%s: %s\n", DRV_NAME, DRV_STRING); - return pci_register_driver(&rvu_driver); + err = pci_register_driver(&cgx_driver); + if (err < 0) + return err; + + err = pci_register_driver(&rvu_driver); + if (err < 0) + pci_unregister_driver(&cgx_driver); + + return err; } static void __exit rvu_cleanup_module(void) { pci_unregister_driver(&rvu_driver); + pci_unregister_driver(&cgx_driver); } module_init(rvu_init_module);