From patchwork Tue Sep 4 11:54:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 10587211 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 59E5E920 for ; Tue, 4 Sep 2018 11:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40028292C3 for ; Tue, 4 Sep 2018 11:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 322FD292C9; Tue, 4 Sep 2018 11:56: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 53AB6292C7 for ; Tue, 4 Sep 2018 11:56: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=NcmnIYdZDAYPmyk+M2JWL6qLEfWf3BRiSTFeo1+eWDA=; b=NRjW7klAl4c9g7Quw/muo08Z8T N9WOlhX0aGXzQaZS8jCGWdg17bspLh6hVlogVR6yajA22oOX15Yp8V2ytGp99noN7+AZXTsvDTcfU 1O3KTWvOLRxjhrccguiS7F093Pv6ObkL+4rZLNoFBlMYy8Pu2rw9X04Mcu5MaiSHHJc+uscVCSmOv fkxlI9Ln+qRwJEZ+DXhiDJBrjbSBUIiCfjpmsYw9aFPM7NFPq1/VRC9xWsGkq12e8NCN8hvj14VfF hEKX/7pcwo/WvVlaFAdkaBor6L5Zr4b+7oP6JXdpn+Ykba0/9Q3hixSYLYPgIypKg8sy0PE7WG2by xd1D+WcA==; 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 1fx9wG-0005uX-78; Tue, 04 Sep 2018 11:56:08 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fx9vc-0005Nn-Su for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2018 11:55:30 +0000 Received: by mail-pf1-x441.google.com with SMTP id l9-v6so1573208pff.9 for ; Tue, 04 Sep 2018 04:55:17 -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=4SUiWKDqC4hWvkutgrkP5c4aNIcliM098bsz0enCsLE=; b=FmkgYC9U65t3Z6C4Bh5Yh1MDu2CGFABnigXVyzM5Bfu7IztR8FvMvcs7qnMM6rwSfo /8hk+NeMEx1oMVacZvbAQ1q3yy14yRv7DfF4ihR9nyY3VbpMZUI5oLLPAIIkX1L+VxQX p0c8n17d1Gy0CBKDbxwRukmkYOuCCRKLdrJhxzDagy0bqbPEbuF4MBPq6qmE8u07kgH+ iGK8Q6ac9HBvlufhAuSMQOMag/OdXvNLG22q5n4ca/q6pREJqdafzHWygcSbFBoQO/n/ nkG+T7e1yn5smTcYoEuwBJDCX/+QdvHLo8N/xvOLzkMDDdz6HudFbgHEjiF8SHEynfie 76Kw== 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=4SUiWKDqC4hWvkutgrkP5c4aNIcliM098bsz0enCsLE=; b=OKOXKQeuT+vDxfcsBlW0UczW2a8hfJa2NdSlTfYmBnV7NWOfn8j5tnnzaO3FhpRdO/ h+gJeEOV++SLtfYGYCbPfwGqbVqUKMpflIm0l+8vrgCazMd5vOtlP/4+ZkCs6RQJWx/1 RV1HeNHR8GkBLsFh3RW3wafRh6ythMYUnPwcgKvy1M/djEZ3UG40o1wcp3dWYBkvlyoS fhnEKeiClnsoeI24rKoDWYw8dKb6FuZqK7k01Y+iCe7XPxiCdFexjH+rQX4TK2k1hWnM T0GPnijYklDrXtqsONh1jx1Yf//KCFU5tM+3r9yztcNaO7DBWia1dHBhwQbtxo06In6U sBRg== X-Gm-Message-State: APzg51Au3f1vnP59hqB0n+FXd/F3cuDr/JI5gD4X0dvdRAIBUFtbq1Jl YUgMRlBEWKxU5DlRxG6luIA= X-Google-Smtp-Source: ANB0VdbH1279rx2LfxBgeLLxdFZ9toZgJdPZOa3JyUMIAImWV8cvns4QFs4tU7WiXnAgXxi6+5Rpgg== X-Received: by 2002:a63:946:: with SMTP id 67-v6mr22071168pgj.132.1536062117305; Tue, 04 Sep 2018 04:55:17 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 04:55:16 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Subject: [PATCH v2 01/15] soc: octeontx2: Add Marvell OcteonTX2 RVU AF driver Date: Tue, 4 Sep 2018 17:24:36 +0530 Message-Id: <1536062090-30446-2-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_045528_968484_4E5D1717 X-CRM114-Status: GOOD ( 21.26 ) 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 resource virtualization unit (RVU) admin function (AF) driver. Just the driver registration and probe. Signed-off-by: Sunil Goutham --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/marvell/Kconfig | 13 ++++ drivers/soc/marvell/Makefile | 2 + drivers/soc/marvell/octeontx2/Makefile | 8 +++ drivers/soc/marvell/octeontx2/rvu.c | 126 +++++++++++++++++++++++++++++++++ drivers/soc/marvell/octeontx2/rvu.h | 31 ++++++++ 7 files changed, 182 insertions(+) create mode 100644 drivers/soc/marvell/Kconfig create mode 100644 drivers/soc/marvell/Makefile create mode 100644 drivers/soc/marvell/octeontx2/Makefile create mode 100644 drivers/soc/marvell/octeontx2/rvu.c create mode 100644 drivers/soc/marvell/octeontx2/rvu.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index c07b4a8..42f2d0b 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -6,6 +6,7 @@ source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/imx/Kconfig" +source "drivers/soc/marvell/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/renesas/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 113e884..5e18cbb 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -12,6 +12,7 @@ obj-y += fsl/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ obj-$(CONFIG_ARCH_MXC) += imx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ +obj-y += marvell/ obj-y += mediatek/ obj-$(CONFIG_ARCH_MESON) += amlogic/ obj-y += qcom/ diff --git a/drivers/soc/marvell/Kconfig b/drivers/soc/marvell/Kconfig new file mode 100644 index 0000000..4499caf --- /dev/null +++ b/drivers/soc/marvell/Kconfig @@ -0,0 +1,13 @@ +# +# MARVELL SoC drivers +# + +menu "Marvell SoC drivers" + +config OCTEONTX2_AF + tristate "OcteonTX2 RVU Admin Function driver" + depends on ARM64 && PCI + 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/Makefile b/drivers/soc/marvell/Makefile new file mode 100644 index 0000000..16e0ca0 --- /dev/null +++ b/drivers/soc/marvell/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-y += octeontx2/ diff --git a/drivers/soc/marvell/octeontx2/Makefile b/drivers/soc/marvell/octeontx2/Makefile new file mode 100644 index 0000000..dacbd16 --- /dev/null +++ b/drivers/soc/marvell/octeontx2/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for Marvell's OcteonTX2 RVU Admin Function driver +# + +obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o + +octeontx2_af-y := rvu.o diff --git a/drivers/soc/marvell/octeontx2/rvu.c b/drivers/soc/marvell/octeontx2/rvu.c new file mode 100644 index 0000000..5af4da6 --- /dev/null +++ b/drivers/soc/marvell/octeontx2/rvu.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell OcteonTx2 RVU Admin Function 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 "rvu.h" + +#define DRV_NAME "octeontx2-af" +#define DRV_STRING "Marvell OcteonTX2 RVU Admin Function Driver" +#define DRV_VERSION "1.0" + +/* Supported devices */ +static const struct pci_device_id rvu_id_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_AF) }, + { 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, rvu_id_table); + +static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct device *dev = &pdev->dev; + struct rvu *rvu; + int err; + + rvu = devm_kzalloc(dev, sizeof(*rvu), GFP_KERNEL); + if (!rvu) + return -ENOMEM; + + pci_set_drvdata(pdev, rvu); + rvu->pdev = pdev; + rvu->dev = &pdev->dev; + + err = pci_enable_device(pdev); + if (err) { + dev_err(dev, "Failed to enable PCI device\n"); + goto err_freemem; + } + + err = pci_request_regions(pdev, DRV_NAME); + if (err) { + dev_err(dev, "PCI request regions failed 0x%x\n", err); + goto err_disable_device; + } + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(48)); + if (err) { + dev_err(dev, "Unable to set DMA mask\n"); + goto err_release_regions; + } + + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(48)); + if (err) { + dev_err(dev, "Unable to set consistent DMA mask\n"); + goto err_release_regions; + } + + /* Map Admin function CSRs */ + rvu->afreg_base = pcim_iomap(pdev, PCI_AF_REG_BAR_NUM, 0); + rvu->pfreg_base = pcim_iomap(pdev, PCI_PF_REG_BAR_NUM, 0); + if (!rvu->afreg_base || !rvu->pfreg_base) { + dev_err(dev, "Unable to map admin function CSRs, aborting\n"); + err = -ENOMEM; + goto err_release_regions; + } + + return 0; + +err_release_regions: + pci_release_regions(pdev); +err_disable_device: + pci_disable_device(pdev); +err_freemem: + pci_set_drvdata(pdev, NULL); + devm_kfree(dev, rvu); + return err; +} + +static void rvu_remove(struct pci_dev *pdev) +{ + struct rvu *rvu = pci_get_drvdata(pdev); + + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + + devm_kfree(&pdev->dev, rvu); +} + +static struct pci_driver rvu_driver = { + .name = DRV_NAME, + .id_table = rvu_id_table, + .probe = rvu_probe, + .remove = rvu_remove, +}; + +static int __init rvu_init_module(void) +{ + pr_info("%s: %s\n", DRV_NAME, DRV_STRING); + + return pci_register_driver(&rvu_driver); +} + +static void __exit rvu_cleanup_module(void) +{ + pci_unregister_driver(&rvu_driver); +} + +module_init(rvu_init_module); +module_exit(rvu_cleanup_module); diff --git a/drivers/soc/marvell/octeontx2/rvu.h b/drivers/soc/marvell/octeontx2/rvu.h new file mode 100644 index 0000000..4a4b0ad --- /dev/null +++ b/drivers/soc/marvell/octeontx2/rvu.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 + * Marvell OcteonTx2 RVU Admin Function 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 RVU_H +#define RVU_H + +/* PCI device IDs */ +#define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065 + +/* PCI BAR nos */ +#define PCI_AF_REG_BAR_NUM 0 +#define PCI_PF_REG_BAR_NUM 2 +#define PCI_MBOX_BAR_NUM 4 + +#define NAME_SIZE 32 + +struct rvu { + void __iomem *afreg_base; + void __iomem *pfreg_base; + struct pci_dev *pdev; + struct device *dev; +}; + +#endif /* RVU_H */