Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2757477imm; Tue, 4 Sep 2018 09:31:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZGar91G7ZuPnajNZAikuev/kFF2JtGkvwQU1sTPw+SrHlsnfZa7PQkg7OCDjhMrN4lvg8n X-Received: by 2002:a63:221b:: with SMTP id i27-v6mr24566143pgi.212.1536078685642; Tue, 04 Sep 2018 09:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536078685; cv=none; d=google.com; s=arc-20160816; b=Qnj4P/qt97IZG0v0lrmueziOeNnZWl9+A6cnKl0tRoWooiVEy/qcP+ImJmR/cd8FhK u2nzX1qchP5/KLPb077GZXrXt7UANS9kQZzE5eQ31KjZZq6SD/WQTcF5ix6wQQlpIdGH PJBQVY8wCTARsq9xfnEwnShcoHEpUkbr81hwaZmQERHyaARCAl4aFvbZu0pmvB0ittvd DeSO6Xg+1R1PiJk/gn+Z9tR9/qFvDhgGTgmv8KRtx6/O/U8VWPh/yjBccGHLXOuMjDmv X9scZ+umNxahnPI0IEIl3jR/Cv3+AiY+MrLGp4AhhH14syHRP21qWshyA98PU4pmsh9a siVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=amDUWHx9CIuzOcKbTAVVhSov5p8oHO7SGU2wtf8SFSk=; b=dfA7JP7nxysoM/FgzlyukZ+uHrX4G/ivFw3iFvbXDImNchTnORJke2FQ79lfdjY/45 mu5o7QjGqOGDoA6eyvCmeW40/fnBhm/1TterMfhwJH2bRBU9jOIlPZrDdsjM4ZM+LC1X 61HUj2EsX/x6QXKmNTSCK0wBSL+xbpQ/kL35vtlnKOxaid3JcAmVeenNoLA7Kk1VRdIs zn70FtFC7dpCWn2Nt+rY3aG19Z9abfdFc+UAM1obDIvKIao2retTUdigIP5ipf7N0TTU QKml2HaY45fHMQ2p3/QCHkATqA/FiQKEXN6+zuFZI5JnjYb46jW9UBxP5Ta1xpHjTQey T6QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a7KvnMBn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12-v6si21987934plr.120.2018.09.04.09.31.07; Tue, 04 Sep 2018 09:31:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a7KvnMBn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728103AbeIDUza (ORCPT + 99 others); Tue, 4 Sep 2018 16:55:30 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45712 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbeIDUz3 (ORCPT ); Tue, 4 Sep 2018 16:55:29 -0400 Received: by mail-pf1-f194.google.com with SMTP id i26-v6so1939577pfo.12; Tue, 04 Sep 2018 09:29:37 -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=a7KvnMBnoIF75UTPQzPJffddyZmOsKmjtTb79n76t5tk4zhTID3XjCdyTGuZQrQDLG rdzw1I3qrXE2FF6jNg5TfUc9FzMhu6TNzu0umXDje4fWgBIpLbUhst9oX/3WEALhL+XD 2sQlhjir2+6+ttFmiHO/U59T3AOaa5yeXbsV4Ivq5nvbT53/PupXjxG7Uo5DqEkHCqiE 41Lc6HEKpVrZk1unkKcsFCS5UA8vnBy1abkRwSMYH1Z+LMru3Hv2yn94mq52fF6Pf9DQ LwwaKcZdNbP3FersCfEEUamgXxNUG6NZNjfHwgmR0SSE6PdyIKhq7tqejrWUGIIVnxYc ep+A== 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=F67zSTOkC0TVgmRfQ2S/g1ulrEHGkhljcmmtOTtG6VCWccW5f2bxrnIvkE8xSUF2vs 0Q/IJa/hc6OD6HuxNeLV+ZHNEBJhXDxpB3g3CKtHCu8Yip2DIdTvnFXS1xkVyH7xJsjS 7SRt6I70+JhDbvFyjfPgybl8rC1xlv6RrAtbTcbfgTjYHi2D0PJWRRDIcRJ00s2OO3tp JUtLMo5JBKieZ+HLTNTgmirQA5slHylsG5gZPT73xDYBzCaUSK6pDLvtxmoKHPqktWEj ZrJUSrq8AUqrKEFApaMOAFgT/5u3EviMzNqMPR9tuyUnew1GkiDi0T7ferZnqvRSgJ9h 6w1w== X-Gm-Message-State: APzg51DuHrQLqyAh3ZthRL6twLzeHhK/kEd0iwvA9oDhttYaVA5baEb6 3aKgCGwAvEeUkk4bMoGoQI8FhPe3 X-Received: by 2002:a63:f14d:: with SMTP id o13-v6mr31979716pgk.236.1536078577048; Tue, 04 Sep 2018 09:29:37 -0700 (PDT) Received: from machine421.caveonetworks.com ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id j191-v6sm32243827pfc.136.2018.09.04.09.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 09:29:35 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, arnd@arndb.de, olof@lixom.net Cc: linux-arm-kernel@lists.infradead.org, linux-soc@vger.kernel.org, andrew@lunn.ch, davem@davemloft.net, netdev@vger.kernel.org, Sunil Goutham Subject: [PATCH v3 11/15] soc: octeontx2: Add Marvell OcteonTX2 CGX driver Date: Tue, 4 Sep 2018 21:58:41 +0530 Message-Id: <1536078525-31534-12-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536078525-31534-1-git-send-email-sunil.kovvuri@gmail.com> References: <1536078525-31534-1-git-send-email-sunil.kovvuri@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4