From patchwork Fri Apr 17 13:37:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 47290 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A2E3920553 for ; Fri, 17 Apr 2015 13:40:12 +0000 (UTC) Received: by lbdc7 with SMTP id c7sf23960330lbd.2 for ; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=5wfXSQlWGQMbqPP+7oofH6tmCtXMPPW52ZjCy/iUEKI=; b=FHCcm5zwMh7FHJk6CN3hi1KNEucYsnrQSbcCQMUYjWX8dGdwP51FzxE5jtM/6HPfLH a/gmqC3PDiBSq39V+u0qlTAqVo75/wGluTi84c7Av8h6cadQTD/QX+tGRYSHaTR7+3NK tZcK1okRvF6wwQZFDl0aygaHtR4VfuSoaXfbW09E2EdD1KMRH7kSXV/WP+NeKoVVljtb 8fDRijdWg2cUE9L3Na+65jFGAICxctlLaApPDHkbSfyU95H99bq7MP0TcnJ5BDUcDEfA 7K6AfnnMSGaya6KZhj4U4xxfjEInaaJGSMqu+ZZcGEe4YdhB06zzyroqsyD7hpYpKaR7 TAqg== X-Gm-Message-State: ALoCoQl5V2zYiB90pXMekEeAw3DNeNvjJwH/Z8RkyVMY6KAM/EFg7UjfVb9yLv+/CIgbja8iY7if X-Received: by 10.152.26.134 with SMTP id l6mr1499413lag.10.1429278011633; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.181.5 with SMTP id ds5ls561432lac.20.gmail; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) X-Received: by 10.112.143.137 with SMTP id se9mr3747584lbb.60.1429278011475; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id 7si8795255lai.138.2015.04.17.06.40.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2015 06:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbzk7 with SMTP id zk7so83229571lbb.0 for ; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) X-Received: by 10.112.8.101 with SMTP id q5mr3770927lba.19.1429278011048; Fri, 17 Apr 2015 06:40:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp3743799lbt; Fri, 17 Apr 2015 06:40:10 -0700 (PDT) X-Received: by 10.112.162.167 with SMTP id yb7mr3778522lbb.121.1429278008274; Fri, 17 Apr 2015 06:40:08 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com. [209.85.212.169]) by mx.google.com with ESMTPS id w2si3015751wif.84.2015.04.17.06.40.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2015 06:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by wiax7 with SMTP id x7so34259220wia.0 for ; Fri, 17 Apr 2015 06:40:08 -0700 (PDT) X-Received: by 10.194.158.234 with SMTP id wx10mr6240290wjb.23.1429278007923; Fri, 17 Apr 2015 06:40:07 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id ub1sm14712357wjc.43.2015.04.17.06.40.06 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Apr 2015 06:40:07 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, agraf@suse.de, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, Bharat.Bhushan@freescale.com Subject: [RFC 3/3] VFIO: platform: add vfio-platform-calxedaxgmac driver Date: Fri, 17 Apr 2015 15:37:13 +0200 Message-Id: <1429277833-28663-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429277833-28663-1-git-send-email-eric.auger@linaro.org> References: <1429277833-28663-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch introduces a specialized vfio platform driver for the calxeda xgmac. On top of the generic vfio platform driver functionalities, it implements the reset modality. This latter basically disables interrupts and stops DMA transfers. Code is inherited from calxeda xgmac native driver Signed-off-by: Eric Auger --- drivers/vfio/platform/Kconfig | 2 + drivers/vfio/platform/Makefile | 2 + drivers/vfio/platform/reset/Kconfig | 7 ++ drivers/vfio/platform/reset/Makefile | 5 + .../platform/reset/vfio_platform_calxedaxgmac.c | 109 +++++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 drivers/vfio/platform/reset/Kconfig create mode 100644 drivers/vfio/platform/reset/Makefile create mode 100644 drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig index 9a4403e..1df7477 100644 --- a/drivers/vfio/platform/Kconfig +++ b/drivers/vfio/platform/Kconfig @@ -18,3 +18,5 @@ config VFIO_AMBA framework. If you don't know what to do here, say N. + +source "drivers/vfio/platform/reset/Kconfig" diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile index 81de144..9ce8afe 100644 --- a/drivers/vfio/platform/Makefile +++ b/drivers/vfio/platform/Makefile @@ -2,7 +2,9 @@ vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o +obj-$(CONFIG_VFIO_PLATFORM) += reset/ vfio-amba-y := vfio_amba.o obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o +obj-$(CONFIG_VFIO_AMBA) += reset/ diff --git a/drivers/vfio/platform/reset/Kconfig b/drivers/vfio/platform/reset/Kconfig new file mode 100644 index 0000000..2c09cea --- /dev/null +++ b/drivers/vfio/platform/reset/Kconfig @@ -0,0 +1,7 @@ +config VFIO_PLATFORM_CALXEDAXGMAC + tristate "VFIO support for calxeda xgmac" + depends on VFIO_PLATFORM + help + Support for VFIO platform driver specialized for Calxeda xgmac reset. + + If you don't know what to do here, say N. diff --git a/drivers/vfio/platform/reset/Makefile b/drivers/vfio/platform/reset/Makefile new file mode 100644 index 0000000..8977721 --- /dev/null +++ b/drivers/vfio/platform/reset/Makefile @@ -0,0 +1,5 @@ +vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o + +ccflags-y += -Idrivers/vfio/platform + +obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC) += vfio-platform-calxedaxgmac.o diff --git a/drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c b/drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c new file mode 100644 index 0000000..729d0cd --- /dev/null +++ b/drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c @@ -0,0 +1,109 @@ +/* + * VFIO platform driver specialized for Calxeda xgmac reset + * reset code is inherited from calxeda xgmac native driver + * + * Copyright 2010-2011 Calxeda, Inc. + * Copyright (c) 2015 Linaro Ltd. + * www.linaro.org + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include "vfio_platform_private.h" +#include + +#define DRIVER_VERSION "0.1" +#define DRIVER_AUTHOR "Eric Auger " +#define DRIVER_DESC "VFIO - Calxeda xgmac vfio platform driver" + +/* XGMAC Register definitions */ +#define XGMAC_CONTROL 0x00000000 /* MAC Configuration */ + +/* DMA Control and Status Registers */ +#define XGMAC_DMA_CONTROL 0x00000f18 /* Ctrl (Operational Mode) */ +#define XGMAC_DMA_INTR_ENA 0x00000f1c /* Interrupt Enable */ + +/* DMA Control registe defines */ +#define DMA_CONTROL_ST 0x00002000 /* Start/Stop Transmission */ +#define DMA_CONTROL_SR 0x00000002 /* Start/Stop Receive */ + +/* Common MAC defines */ +#define MAC_ENABLE_TX 0x00000008 /* Transmitter Enable */ +#define MAC_ENABLE_RX 0x00000004 /* Receiver Enable */ + +static inline void xgmac_mac_disable(void __iomem *ioaddr) +{ + u32 value = readl(ioaddr + XGMAC_DMA_CONTROL); + + value &= ~(DMA_CONTROL_ST | DMA_CONTROL_SR); + writel(value, ioaddr + XGMAC_DMA_CONTROL); + + value = readl(ioaddr + XGMAC_CONTROL); + value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX); + writel(value, ioaddr + XGMAC_CONTROL); +} + +static int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev) +{ + struct resource *res = get_platform_resource(vdev, 0); + void __iomem *base = phys_to_virt(res->start); + + if (!base) + return -ENOMEM; + + /* disable IRQ */ + writel(0, base + XGMAC_DMA_INTR_ENA); + + /* Disable the MAC core */ + xgmac_mac_disable(base); + + return 0; +} + +static int vfio_platform_calxedaxgmac_probe(struct platform_device *pdev) +{ + int ret; + struct vfio_device *vfio_dev; + struct vfio_platform_device *vpdev; + + ret = vfio_platform_probe(pdev); + if (ret) + return ret; + + vfio_dev = vfio_device_get_from_dev(&pdev->dev), + vpdev = (struct vfio_platform_device *) vfio_device_data(vfio_dev); + vpdev->reset = vfio_platform_calxedaxgmac_reset; + + return ret; +} + +static struct platform_driver vfio_platform_calxedaxgmac_driver = { + .driver = { + .name = "vfio-platform-calxedaxgmac", + }, + .probe = vfio_platform_calxedaxgmac_probe, + .remove = vfio_platform_remove, +}; + +module_platform_driver(vfio_platform_calxedaxgmac_driver); + +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC);