From patchwork Mon May 20 20:19:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 1102351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4579Jv6WnVz9sBV for ; Tue, 21 May 2019 06:21:19 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4579Jv5ZzVzDqKy for ; Tue, 21 May 2019 06:21:19 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=eajames@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4579Jq2QFtzDqJT for ; Tue, 21 May 2019 06:21:15 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4KK7xIU011696; Mon, 20 May 2019 16:21:03 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sm2m315hu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 May 2019 16:21:02 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x4KJbcLI014553; Mon, 20 May 2019 19:39:10 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma01dal.us.ibm.com with ESMTP id 2sj9p3k7w9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 May 2019 19:39:10 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4KKJjFt34210286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 20:19:45 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA3C5B2068; Mon, 20 May 2019 20:19:45 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DCD9B2064; Mon, 20 May 2019 20:19:45 +0000 (GMT) Received: from talon7.ibm.com (unknown [9.41.179.222]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 20 May 2019 20:19:45 +0000 (GMT) From: Eddie James To: linux-aspeed@lists.ozlabs.org Subject: [PATCH v2 4/7] drivers/soc: xdma: Add PCI device configuration sysfs Date: Mon, 20 May 2019 15:19:22 -0500 Message-Id: <1558383565-11821-5-git-send-email-eajames@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1558383565-11821-1-git-send-email-eajames@linux.ibm.com> References: <1558383565-11821-1-git-send-email-eajames@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-20_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200126 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, arnd@arndb.de, linux-kernel@vger.kernel.org, robh+dt@kernel.org Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" The AST2500 has two PCI devices embedded. The XDMA engine can use either device to perform DMA transfers. Users need the capability to choose which device to use. This commit therefore adds two sysfs files that toggle the AST2500 and XDMA engine between the two PCI devices. Signed-off-by: Eddie James --- drivers/soc/aspeed/aspeed-xdma.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c index 2162ca0..002b571 100644 --- a/drivers/soc/aspeed/aspeed-xdma.c +++ b/drivers/soc/aspeed/aspeed-xdma.c @@ -667,6 +667,64 @@ static void aspeed_xdma_free_vga_blks(struct aspeed_xdma *ctx) } } +static int aspeed_xdma_change_pcie_conf(struct aspeed_xdma *ctx, u32 conf) +{ + int rc; + + mutex_lock(&ctx->start_lock); + rc = wait_event_interruptible_timeout(ctx->wait, + !test_bit(XDMA_IN_PRG, + &ctx->flags), + msecs_to_jiffies(1000)); + if (rc < 0) { + mutex_unlock(&ctx->start_lock); + return -EINTR; + } + + /* previous op didn't complete, wake up waiters anyway */ + if (!rc) + wake_up_interruptible_all(&ctx->wait); + + reset_control_assert(ctx->reset); + msleep(10); + + aspeed_scu_pcie_write(ctx, conf); + msleep(10); + + reset_control_deassert(ctx->reset); + msleep(10); + + aspeed_xdma_init_eng(ctx); + + mutex_unlock(&ctx->start_lock); + + return 0; +} + +static ssize_t aspeed_xdma_use_bmc(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int rc; + struct aspeed_xdma *ctx = dev_get_drvdata(dev); + + rc = aspeed_xdma_change_pcie_conf(ctx, aspeed_xdma_bmc_pcie_conf); + return rc ?: count; +} +static DEVICE_ATTR(use_bmc, 0200, NULL, aspeed_xdma_use_bmc); + +static ssize_t aspeed_xdma_use_vga(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int rc; + struct aspeed_xdma *ctx = dev_get_drvdata(dev); + + rc = aspeed_xdma_change_pcie_conf(ctx, aspeed_xdma_vga_pcie_conf); + return rc ?: count; +} +static DEVICE_ATTR(use_vga, 0200, NULL, aspeed_xdma_use_vga); + static int aspeed_xdma_probe(struct platform_device *pdev) { int irq; @@ -745,6 +803,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev) return rc; } + device_create_file(dev, &dev_attr_use_bmc); + device_create_file(dev, &dev_attr_use_vga); + return 0; } @@ -752,6 +813,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev) { struct aspeed_xdma *ctx = platform_get_drvdata(pdev); + device_remove_file(ctx->dev, &dev_attr_use_vga); + device_remove_file(ctx->dev, &dev_attr_use_bmc); + misc_deregister(&ctx->misc); aspeed_xdma_free_vga_blks(ctx);