Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp606674ybl; Fri, 10 Jan 2020 03:56:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxNNnypmPKmw/qSQQWNx/SgvQHEl859hdDa5qdbunPH/6I7UND5tz8wyquSUMKevT7kbp8H X-Received: by 2002:aca:f456:: with SMTP id s83mr1813793oih.12.1578657410593; Fri, 10 Jan 2020 03:56:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578657410; cv=none; d=google.com; s=arc-20160816; b=nHgnmw9vnLf36AZFdvcHwjKc6MH9W5AHrKcskFQ3ad8PnL+VUY/YkbEGyqNG5Ell/3 gjawgVIKYgxJK/pi/HfqDBzUdEhFiDn3lx4Q1BA10YmJpuo+b6NCx785o2273MhUgSuP 27+5f058ed2rrkbDtWo2ZQN30SsKVIwmMRYwK0liiXOT97q4+N0MB8EiXIvJ+UpNQZCu zK+jRWzCee5wF5AzEKNU6kQ9gXLB1p2+MHWdPY1Bd7uyv2Yssn8xV0IY3tCdmNjhJoxo pX1kdJAVovvkDNA+zlZg5mRFxrnlgmCtyoXmPCXqwrMWNGs1VCLd+SW2ygMHThkVuIez p3RA== 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; bh=HSQjV3mhFglKD3HANScCTmdxki+icjXdefRnHq1C6c4=; b=WIABKGXv4hXgfY4FIq+pyGy3NCrSQLpfXC8gpP34hupYwweEE7Cuc7xT1K5/VjjM5E f41fkmvRQK9JNT+abIXRX6p5iWiaj46h42hvhsaSLdP4UNZn/d7qKOqaPkErXBiFP79Z tP1ljR/FKf5OsFnA1Qz9k3LOFS1QIa0QPUC+oOdvj+T7MIn6De42FpTVsIUZChPNUcws hJFiEAMI0ZJXgn/pBm/egR45lGAHQcYcWUgMXA9nupgvZL+GoJ+djt3/apiz6DDQ4Ljo lWEIqVKQTR0Ui8ZN+NN0UlPnuxWSPojTKz5x8siHAosz8fbKdoXv8R5a/vugli/bSit0 Er7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si1115652otf.42.2020.01.10.03.56.39; Fri, 10 Jan 2020 03:56:50 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbgAJLyn (ORCPT + 99 others); Fri, 10 Jan 2020 06:54:43 -0500 Received: from foss.arm.com ([217.140.110.172]:43198 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728153AbgAJLyj (ORCPT ); Fri, 10 Jan 2020 06:54:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6BADF1435; Fri, 10 Jan 2020 03:54:39 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 52C513F534; Fri, 10 Jan 2020 03:54:38 -0800 (PST) From: Andre Przywara To: "David S . Miller" , Radhey Shyam Pandey Cc: Michal Simek , Robert Hancock , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/14] net: axienet: Autodetect 64-bit DMA capability Date: Fri, 10 Jan 2020 11:54:13 +0000 Message-Id: <20200110115415.75683-13-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200110115415.75683-1-andre.przywara@arm.com> References: <20200110115415.75683-1-andre.przywara@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When newer revisions of the Axienet IP are configured for a 64-bit bus, we *need* to write to the MSB part of the an address registers, otherwise the IP won't recognise this as a DMA start condition. This is even true when the actual DMA address comes from the lower 4 GB. To autodetect this configuration, at probe time we write all 1's to such an MSB register, and see if any bits stick. If this is configured for a 32-bit bus, those MSB registers are RES0, so reading back 0 indicates that no MSB writes are necessary. On the other hands reading anything other than 0 indicated the need to write the MSB registers, so we set the respective flag. For now this leaves the actual DMA mask at 32-bit, as we can't reliably detect the actually wired number of address lines beyond 32. Signed-off-by: Andre Przywara --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 1 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index 4aea4c23d3bb..4feaaa02819c 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -161,6 +161,7 @@ #define XAE_FCC_OFFSET 0x0000040C /* Flow Control Configuration */ #define XAE_EMMC_OFFSET 0x00000410 /* EMAC mode configuration */ #define XAE_PHYC_OFFSET 0x00000414 /* RGMII/SGMII configuration */ +#define XAE_ID_OFFSET 0x000004F8 /* Identification register */ #define XAE_MDIO_MC_OFFSET 0x00000500 /* MII Management Config */ #define XAE_MDIO_MCR_OFFSET 0x00000504 /* MII Management Control */ #define XAE_MDIO_MWD_OFFSET 0x00000508 /* MII Management Write Data */ diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 133f088d797e..f7f593df0c11 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -151,6 +151,9 @@ static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg, dma_addr_t addr) { axienet_dma_out32(lp, reg, lower_32_bits(addr)); + + if (lp->features & XAE_FEATURE_DMA_64BIT) + axienet_dma_out32(lp, reg + 4, upper_32_bits(addr)); } static void desc_set_phys_addr(struct axienet_local *lp, dma_addr_t addr, @@ -1934,6 +1937,30 @@ static int axienet_probe(struct platform_device *pdev) goto free_netdev; } + /* + * Autodetect the need for 64-bit DMA pointers. + * When the IP is configured for a bus width bigger than 32 bits, + * writing the MSB registers is mandatory, even if they are all 0. + * We can detect this case by writing all 1's to one such register + * and see if that sticks: when the IP is configured for 32 bits + * only, those registers are RES0. + * Those MSB registers were introduced in IP v7.1, which we check first. + */ + if ((axienet_ior(lp, XAE_ID_OFFSET) >> 24) >= 0x9) { + void __iomem *desc = lp->dma_regs + XAXIDMA_TX_CDESC_OFFSET + 4; + + iowrite32(0x0, desc); + if (ioread32(desc) == 0) { /* sanity check */ + iowrite32(0xffffffff, desc); + if (ioread32(desc) > 0) { + lp->features |= XAE_FEATURE_DMA_64BIT; + dev_info(&pdev->dev, + "autodetected 64-bit DMA range\n"); + } + iowrite32(0x0, desc); + } + } + /* Check for Ethernet core IRQ (optional) */ if (lp->eth_irq <= 0) dev_info(&pdev->dev, "Ethernet core IRQ not defined\n"); -- 2.17.1