Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3028019iob; Mon, 16 May 2022 11:22:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJZgvPnwOUpu8doQ1zw2tqXhc7KmQ7eCl8MzTWQ9RtcB6PrcOC/rtlXQ5aB845Ua5W6rcp X-Received: by 2002:aa7:de8a:0:b0:42a:b51a:554c with SMTP id j10-20020aa7de8a000000b0042ab51a554cmr5325840edv.318.1652725364963; Mon, 16 May 2022 11:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652725364; cv=none; d=google.com; s=arc-20160816; b=PyannGocwhQtMq8A3bmVMO4Htq2ZSpae2x/UznS5TbWV2g3kk8J01dYB8UnTI9DFr/ mMQPz6j3AZt83fy5BGp6YN0W9xrGQYE4Air0kkDmEZe4CF08wHW0LMh/NPWTqrxcCBoj zGeA4gDff5MjAAnLwHyqJr57emEgmTWHZ06MDGb2lQ1rJuQpcZDwy8frDYqG+hpRpGtV 0Hc67GNd0QkCCrlyzsGw5Vgzp928h4PC0R6+Pm38qGKKm1ytUXeKo4AkUyrrayCn11nA qTPOTjlvqSkpUxfDPms4BuO3PkGL7c5Mem3d7aSRmLh43uvUZ50lU4BV90PmM22AMjZX NKhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dC/cTQo/MJ767nLnh5GC42ACRkqVvW3EbSSHwsx8exs=; b=ZE1ZyUb8L/07VT2DCGRkBS0/VO5P9/G3cr3OFXJ6Gi6r/pDP8fabgsaCjg5X2Uz7iT Q7PiOrVOpvXKs5gxPjNDkXErjU+2k3Oyc2y5pL3wokt25xvXz7VjHNsBL87sPo9rfKuJ 6ztPudJJtnrsXNcAqIq4aUGLQC0QBM41JcQJQa/e5q2Yrp38nCsK3Mux2iAvN1321Y9H loKFCNAoVvqRhxTDxtscTX8SoAcCngfKTg2qz96knBeLQ+96TRnj8Wa8Kbayq95pFSU8 8sO7RHryo1/ML7zetBsj/Q16k97eoL7HtGjsiobdDPR1WKyBsz3CX3vJ3fMW3UNwwcS2 1EFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=eWpIEKWn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di5-20020a170906730500b006f49fb1b332si66920ejc.608.2022.05.16.11.22.18; Mon, 16 May 2022 11:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=eWpIEKWn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239434AbiEPKDK (ORCPT + 99 others); Mon, 16 May 2022 06:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234487AbiEPKCm (ORCPT ); Mon, 16 May 2022 06:02:42 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA02B5596; Mon, 16 May 2022 03:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=dC/cTQo/MJ767nLnh5GC42ACRkqVvW3EbSSHwsx8exs=; b=eWpIEKWn4b6F9NYXDMKPoozdTz iYbtZk7lvve0PKLiXxgCOSdtABK1nUYLq2VNvVx2tsPU6ssdoT6NZBykMoqEpBHXHMoeKR4YKWCUw Xac3P7g+Q2iUKqUWiOCrtT3aKQgWvU4fTheD+6TsaM7G7r3e4NCbQKO5Q3dfbBrSR5IRRzqhzAhJK zed2XtB2SC9hs21ijIry5O7IxtshMX1Baz+2o1vAIRKDOYSPVo7Q7sf5o6hNLzQHjnx6iei0pUNim EivaIwxq0e7p/1bTXiXDN788XM7XSCbXVXE5yVZSK9KBrg53zcFqMZTAXyBU6uJsG5aOhLIcx+HmA O1t3GZWA==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqXYf-0005yU-CT; Mon, 16 May 2022 13:02:33 +0300 From: cyndis@kapsi.fi To: thierry.reding@gmail.com, jonathanh@nvidia.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, digetx@gmail.com Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Mikko Perttunen Subject: [PATCH v1 05/13] gpu: host1x: Simplify register mapping and add common aperture Date: Mon, 16 May 2022 13:02:05 +0300 Message-Id: <20220516100213.1536571-6-cyndis@kapsi.fi> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516100213.1536571-1-cyndis@kapsi.fi> References: <20220516100213.1536571-1-cyndis@kapsi.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikko Perttunen Refactor 'regs' property loading using devm_platform_ioremap_* and add loading of the 'common' region found on Tegra234. Signed-off-by: Mikko Perttunen --- drivers/gpu/host1x/dev.c | 46 +++++++++++++++++----------------------- drivers/gpu/host1x/dev.h | 3 +++ 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 89cc79a48eab..8c6ce8014c09 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -40,6 +40,11 @@ #include "hw/host1x06.h" #include "hw/host1x07.h" +void host1x_common_writel(struct host1x *host1x, u32 v, u32 r) +{ + writel(v, host1x->common_regs + r); +} + void host1x_hypervisor_writel(struct host1x *host1x, u32 v, u32 r) { writel(v, host1x->hv_regs + r); @@ -412,7 +417,6 @@ static int host1x_get_resets(struct host1x *host) static int host1x_probe(struct platform_device *pdev) { struct host1x *host; - struct resource *regs, *hv_regs = NULL; int syncpt_irq; int err; @@ -423,25 +427,23 @@ static int host1x_probe(struct platform_device *pdev) host->info = of_device_get_match_data(&pdev->dev); if (host->info->has_hypervisor) { - regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vm"); - if (!regs) { - dev_err(&pdev->dev, "failed to get vm registers\n"); - return -ENXIO; - } + host->regs = devm_platform_ioremap_resource_byname(pdev, "vm"); + if (IS_ERR(host->regs)) + return PTR_ERR(host->regs); + + host->hv_regs = devm_platform_ioremap_resource_byname(pdev, "hypervisor"); + if (IS_ERR(host->hv_regs)) + return PTR_ERR(host->hv_regs); - hv_regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "hypervisor"); - if (!hv_regs) { - dev_err(&pdev->dev, - "failed to get hypervisor registers\n"); - return -ENXIO; + if (host->info->has_common) { + host->common_regs = devm_platform_ioremap_resource_byname(pdev, "common"); + if (IS_ERR(host->common_regs)) + return PTR_ERR(host->common_regs); } } else { - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!regs) { - dev_err(&pdev->dev, "failed to get registers\n"); - return -ENXIO; - } + host->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(host->regs)) + return PTR_ERR(host->regs); } syncpt_irq = platform_get_irq(pdev, 0); @@ -456,16 +458,6 @@ static int host1x_probe(struct platform_device *pdev) /* set common host1x device data */ platform_set_drvdata(pdev, host); - host->regs = devm_ioremap_resource(&pdev->dev, regs); - if (IS_ERR(host->regs)) - return PTR_ERR(host->regs); - - if (host->info->has_hypervisor) { - host->hv_regs = devm_ioremap_resource(&pdev->dev, hv_regs); - if (IS_ERR(host->hv_regs)) - return PTR_ERR(host->hv_regs); - } - host->dev->dma_parms = &host->dma_parms; dma_set_max_seg_size(host->dev, UINT_MAX); diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h index 7552a4554534..85edcc6e0fc7 100644 --- a/drivers/gpu/host1x/dev.h +++ b/drivers/gpu/host1x/dev.h @@ -100,6 +100,7 @@ struct host1x_info { u64 dma_mask; /* mask of addressable memory */ bool has_wide_gather; /* supports GATHER_W opcode */ bool has_hypervisor; /* has hypervisor registers */ + bool has_common; /* has common registers separate from hypervisor */ unsigned int num_sid_entries; const struct host1x_sid_entry *sid_table; /* @@ -115,6 +116,7 @@ struct host1x { void __iomem *regs; void __iomem *hv_regs; /* hypervisor region */ + void __iomem *common_regs; struct host1x_syncpt *syncpt; struct host1x_syncpt_base *bases; struct device *dev; @@ -156,6 +158,7 @@ struct host1x { struct host1x_bo_cache cache; }; +void host1x_common_writel(struct host1x *host1x, u32 v, u32 r); void host1x_hypervisor_writel(struct host1x *host1x, u32 r, u32 v); u32 host1x_hypervisor_readl(struct host1x *host1x, u32 r); void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v); -- 2.36.1