Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3397552ybl; Sun, 15 Dec 2019 09:00:47 -0800 (PST) X-Google-Smtp-Source: APXvYqx9S/quqfYLxD7+lq0LO01PR4IiTPIbIMK9RoMHyT7qJZqkbaj5iO/NlK7HrMgDsTsWbb8b X-Received: by 2002:a9d:22a8:: with SMTP id y37mr15539207ota.359.1576429247269; Sun, 15 Dec 2019 09:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576429247; cv=none; d=google.com; s=arc-20160816; b=Yoi/PFfEGrcj4zxjsrddv1xALXLuwlYnpqnmy0uHUaXIT6LCnHaHvbt0JS7LRLwjTf p95WQsOM6QzBeF90T6tgpXCF6AJhV6IGcPZxIEdt0UEv3G4/YOPBeRB/iH5e5bZm9PqX Bybtpa9bquuTbKKU0Pxvd84tulDMT1cwyApAl5n2rhjE1KvPGHt3fifUrDy9Hu0SBST4 qDeW791lAmML7nuwM9VCC4wuTENjI2oXUToSVyN0DMIXgCNMXuVQD8jmCF7CFNLAttcy t81W13tLn1hTGCGbcWc/i8FdgG79yPch7FmVvoowABXoBgpR5rerJXLjtbhucFz2N/oP d57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2+JHIS6uYUe/Th0f2vlm01QCJLSTHbDgjohMJGN/pqg=; b=v7mI+MkxW2qvZLyiXe1ME/slRZCnfryi5/pS/H4XGM7mpUgbxiX5bBwWwhm60PxfK7 aSySMlABzeOfYTIkaap6OZUrlmiATBAN+YXO1fyLwxFKHaLgEUxrIeLYDQnN6hbsZWMn yKcAaXNvHQIJ4kdzLrmCnhwLmcCmtfQYz3Iv3agZOrX7x4JBImcAnqNaLrfCD4ydHu4T wpkjPcl+ldi4YVkWKro+Yzp3qybgB6tHzINowbA/m52V3MffA0vZ6IwhsHtLJtnK2320 kGhus6GVVNMPncp4939q2iVMt0Tfgak1TmOzVXBbF8yYGIJGY//CN8WNXMg9mAyupfnY r+VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R27jcToG; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15si8801814oij.64.2019.12.15.09.00.32; Sun, 15 Dec 2019 09:00:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=R27jcToG; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbfLOQ7f (ORCPT + 99 others); Sun, 15 Dec 2019 11:59:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:55122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbfLOQ7c (ORCPT ); Sun, 15 Dec 2019 11:59:32 -0500 Received: from wens.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8CB9E2467D; Sun, 15 Dec 2019 16:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576429171; bh=2HvYCOg9JIsgIj4BOPEnWKWDtaJsP2z/GYbgmDwmqNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R27jcToGRL+lsE9KhkS+b9kJsgcMxW/mcACduEJdBkspVYezS/MfYqQLFonqqJKc+ y+aL2h9GYXGKSYag1paOupscaZJRze034RYmdZvkF/Agko/Io4jo02no3Q1TNXMWyg WHr5rxr13Afcq2OBDXZfCyAu6XmbCxcAzLB3lA2I= Received: by wens.tw (Postfix, from userid 1000) id 47DAC5FD28; Mon, 16 Dec 2019 00:59:26 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Mauro Carvalho Chehab , Sakari Ailus , Rob Herring , Mark Rutland Cc: Chen-Yu Tsai , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai Subject: [PATCH 05/14] media: sun4i-csi: Deal with DRAM offset Date: Mon, 16 Dec 2019 00:59:15 +0800 Message-Id: <20191215165924.28314-6-wens@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191215165924.28314-1-wens@kernel.org> References: <20191215165924.28314-1-wens@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen-Yu Tsai On Allwinner SoCs, some high memory bandwidth devices do DMA directly over the memory bus (called MBUS), instead of the system bus. These devices include the CSI camera sensor interface, video (codec) engine, display subsystem, etc.. The memory bus has a different addressing scheme without the DRAM starting offset. Deal with this using the "interconnects" property from the device tree, or if that is not available, set dev->dma_pfn_offset to PHYS_PFN_OFFSET. Fixes: 577bbf23b758 ("media: sunxi: Add A10 CSI driver") Signed-off-by: Chen-Yu Tsai --- .../platform/sunxi/sun4i-csi/sun4i_csi.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c index f36dc6258900..b8b07c1de2a8 100644 --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -155,6 +156,27 @@ static int sun4i_csi_probe(struct platform_device *pdev) subdev = &csi->subdev; vdev = &csi->vdev; + /* + * On Allwinner SoCs, some high memory bandwidth devices do DMA + * directly over the memory bus (called MBUS), instead of the + * system bus. The memory bus has a different addressing scheme + * without the DRAM starting offset. + * + * In some cases this can be described by an interconnect in + * the device tree. In other cases where the hardware is not + * fully understood and the interconnect is left out of the + * device tree, fall back to a default offset. + */ + if (of_find_property(csi->dev->of_node, "interconnects", NULL)) { + ret = of_dma_configure(csi->dev, csi->dev->of_node, true); + if (ret) + return ret; + } else { +#ifdef PHYS_PFN_OFFSET + csi->dev->dma_pfn_offset = PHYS_PFN_OFFSET; +#endif + } + csi->mdev.dev = csi->dev; strscpy(csi->mdev.model, "Allwinner Video Capture Device", sizeof(csi->mdev.model)); -- 2.24.0