From patchwork Thu Oct 19 11:26:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 10016499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2119460215 for ; Thu, 19 Oct 2017 11:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0760A28CC4 for ; Thu, 19 Oct 2017 11:28:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F000B28CC7; Thu, 19 Oct 2017 11:28:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8041928CC4 for ; Thu, 19 Oct 2017 11:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DiIrqX7izIo6H0Mk6dFEenUFxFx4R9bkP4RsvTId/IE=; b=ma9kxiUCMxsCeDJjH3X2kH84gI XxZ+osryosm1mOGfvKxrEvlKkx0xdKVk4Lya8yir7/E0wVqU9UI0r2YlMMRmeJQS77w6Wy04zRyM0 AO0NRodDOeYTiAHBjqbECxQ47/ByQdPQ6upsyZyGkPPbAu39gwg+v4tp+tRJgU/QLdY5eUHmZ7CEn GapbikkXtUQ6hd7TrtlxAm+hWMl2PzQhXlDt4S6kw0e9/ffz9QDmp5HqpkeXyd4LOa1T1kfWZRc9v 2EeT/EmzbEORyUMLfjJuQy6LSg5PJ+GehRDoy56xwqO1/V6dSTscEtf3MbvKAAt06w1gFT4SI372f 5ci/nIhA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e58zc-0000jn-Vy; Thu, 19 Oct 2017 11:28:05 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e58yo-0008Qv-UA; Thu, 19 Oct 2017 11:27:21 +0000 Received: by mail-pf0-x244.google.com with SMTP id b85so6360340pfj.13; Thu, 19 Oct 2017 04:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+WNmdCAhpCCiDBJ0dydSqw9qWsDpDO/cQt5pVNb5lVI=; b=iZDc4QEZ3Vb/RK5fnaSawt4f8sUf0EOBLnQjud1S9q3PiJIZewPEgyHhwLCOiHF37F y4FeICo5Db7Lg+6JTHfDnMsL0UN5w9UgDAYrM/L3eEUJ6ViET8shyh0iMc/KZ71JmvUB aQBN1s7F0RqwUgSjlqgrpxWSjh1F2FrHay+FMfpWWuYDzXhMogw8rVCwTrPvcqHfq7zO gefx/IhNt1Am6N6Vp0DETm100vLwLVtlZtsB9w2kLKp7uahpwoAU1E9UDhiy5riDQdNA H6weN/6DE5PvE5TNYTAXhwub2Cup08OMRzlpgxcOQwVd1fEBEcjJo4mYsIiCxjxLBYF5 vZ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+WNmdCAhpCCiDBJ0dydSqw9qWsDpDO/cQt5pVNb5lVI=; b=hRrty+qTXCwSyylPi3i8rQxsvUJ32q7tjXzXF5uxme+bYT6eSYRZf9JtdmyRx8GCrU PWSqRNNkk/o7LMDlNtTiOvqaqBRAJI9F+5qz7PKviaSUZn5aCSSbDCr6+dlg/Nhln5ZC W0+DNgXLQ8wf2VD7cBm6tH6ARgFz8ka8+b6R9Mco4DeEXZOVn7XIvr2UMD+X+v3qPmlf bnfl8iZTOwkmBSOL8dcGmfTj5I4ef9vJ8V9F57dHuVacbz53alvE852YZpnX5COd0W98 8f/BU5Ozrx2xg5/hdZEiXILiIYPDVCo9xm8lTmteQnKKYgwV/C4tTzwkTnWkIgEMbDZw Gdcw== X-Gm-Message-State: AMCzsaUe0MVcAEFW2txayeOEVFwf3EMzHureVRcw2BJaLntTQz6Htmoy yvnX4ZDg586NpQI4Ul3MY1I= X-Google-Smtp-Source: ABhQp+QLzPWVMAeRAK0ihrWsWJUNmJseWLnPSYcg5+P6HKWpG9gWMnxd5HLld5w7zKQHpCUUCLhZ0g== X-Received: by 10.101.77.144 with SMTP id p16mr1101331pgq.226.1508412418562; Thu, 19 Oct 2017 04:26:58 -0700 (PDT) Received: from ziggy.de ([37.223.199.11]) by smtp.gmail.com with ESMTPSA id m78sm29961763pfj.164.2017.10.19.04.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 04:26:57 -0700 (PDT) From: Matthias Brugger X-Google-Original-From: Matthias Brugger To: ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com, ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, robh+dt@kernel.org, mark.rutland@arm.com Subject: [RFC resend 2/4] drm/mediatek: Add new compatible to probe multimedia subsystem. Date: Thu, 19 Oct 2017 13:26:08 +0200 Message-Id: <20171019112610.13645-3-mbrugger@suse.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171019112610.13645-1-mbrugger@suse.com> References: <20171019112610.13645-1-mbrugger@suse.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171019_042715_377516_7D7CBDD4 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Matthias Brugger , catalin.marinas@arm.com, will.deacon@arm.com, linux@armlinux.org.uk, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The mmsys block is an independent block that probes the clock driver. The multimedia subsystem therefore does not get probed. We add a new compatible for the multimedia subsystem. We pass the mmsys registers via syscon and access them using regmap instead of relaxed read/write. Signed-off-by: Matthias Brugger --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 ++-- drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 30 +++++++++++++++++------------- drivers/gpu/drm/mediatek/mtk_drm_ddp.h | 4 ++-- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 17 ++++++----------- drivers/gpu/drm/mediatek/mtk_drm_drv.h | 2 +- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 658b8dd45b83..4c65873b4867 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -33,7 +33,7 @@ * @enabled: records whether crtc_enable succeeded * @planes: array of 4 drm_plane structures, one for each overlay plane * @pending_planes: whether any plane has pending changes to be applied - * @config_regs: memory mapped mmsys configuration register space + * @config_regs: regmap mapped mmsys configuration register space * @mutex: handle to one of the ten disp_mutex streams * @ddp_comp_nr: number of components in ddp_comp * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc @@ -48,7 +48,7 @@ struct mtk_drm_crtc { struct drm_plane planes[OVL_LAYER_NR]; bool pending_planes; - void __iomem *config_regs; + struct regmap *config_regs; struct mtk_disp_mutex *mutex; unsigned int ddp_comp_nr; struct mtk_ddp_comp **ddp_comp; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c index 8130f3dab661..1227d6db07da 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c @@ -185,16 +185,16 @@ static unsigned int mtk_ddp_sel_in(enum mtk_ddp_comp_id cur, return value; } -static void mtk_ddp_sout_sel(void __iomem *config_regs, +static void mtk_ddp_sout_sel(struct regmap *config_regs, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next) { if (cur == DDP_COMPONENT_BLS && next == DDP_COMPONENT_DSI0) - writel_relaxed(BLS_TO_DSI_RDMA1_TO_DPI1, - config_regs + DISP_REG_CONFIG_OUT_SEL); + regmap_write(config_regs, DISP_REG_CONFIG_OUT_SEL, + BLS_TO_DSI_RDMA1_TO_DPI1); } -void mtk_ddp_add_comp_to_path(void __iomem *config_regs, +void mtk_ddp_add_comp_to_path(struct regmap *config_regs, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next) { @@ -202,20 +202,22 @@ void mtk_ddp_add_comp_to_path(void __iomem *config_regs, value = mtk_ddp_mout_en(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) | value; - writel_relaxed(reg, config_regs + addr); + regmap_read(config_regs, addr, ®); + reg |= value; + regmap_write(config_regs, addr, reg); } mtk_ddp_sout_sel(config_regs, cur, next); value = mtk_ddp_sel_in(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) | value; - writel_relaxed(reg, config_regs + addr); + regmap_read(config_regs, addr, ®); + reg |= value; + regmap_write(config_regs, addr, reg); } } -void mtk_ddp_remove_comp_from_path(void __iomem *config_regs, +void mtk_ddp_remove_comp_from_path(struct regmap *config_regs, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next) { @@ -223,14 +225,16 @@ void mtk_ddp_remove_comp_from_path(void __iomem *config_regs, value = mtk_ddp_mout_en(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) & ~value; - writel_relaxed(reg, config_regs + addr); + regmap_read(config_regs, addr, ®); + reg &= ~value; + regmap_write(config_regs, addr, reg); } value = mtk_ddp_sel_in(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) & ~value; - writel_relaxed(reg, config_regs + addr); + regmap_read(config_regs, addr, ®); + reg &= ~value; + regmap_write(config_regs, addr, reg); } } diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h index f9a799168077..32e12f33b76a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h @@ -20,10 +20,10 @@ struct regmap; struct device; struct mtk_disp_mutex; -void mtk_ddp_add_comp_to_path(void __iomem *config_regs, +void mtk_ddp_add_comp_to_path(struct regmap *config_regs, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next); -void mtk_ddp_remove_comp_from_path(void __iomem *config_regs, +void mtk_ddp_remove_comp_from_path(struct regmap *config_regs, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index a2ca90fc403c..f013d0039821 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -385,7 +386,6 @@ static int mtk_drm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mtk_drm_private *private; - struct resource *mem; struct device_node *node; struct component_match *match = NULL; int ret; @@ -399,14 +399,9 @@ static int mtk_drm_probe(struct platform_device *pdev) INIT_WORK(&private->commit.work, mtk_atomic_work); private->data = of_device_get_match_data(dev); - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - private->config_regs = devm_ioremap_resource(dev, mem); - if (IS_ERR(private->config_regs)) { - ret = PTR_ERR(private->config_regs); - dev_err(dev, "Failed to ioremap mmsys-config resource: %d\n", - ret); - return ret; - } + private->config_regs = syscon_regmap_lookup_by_compatible("mediatek,mmsys"); + if (IS_ERR(private->config_regs)) + return PTR_ERR(private->config_regs); /* Iterate over sibling DISP function blocks */ for_each_child_of_node(dev->of_node->parent, node) { @@ -550,9 +545,9 @@ static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend, mtk_drm_sys_resume); static const struct of_device_id mtk_drm_of_ids[] = { - { .compatible = "mediatek,mt2701-mmsys", + { .compatible = "mediatek,mt2701-dispsys", .data = &mt2701_mmsys_driver_data}, - { .compatible = "mediatek,mt8173-mmsys", + { .compatible = "mediatek,mt8173-dispsys", .data = &mt8173_mmsys_driver_data}, { } }; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h index c3378c452c0a..c6fa0ad458e8 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h @@ -44,7 +44,7 @@ struct mtk_drm_private { struct device_node *mutex_node; struct device *mutex_dev; - void __iomem *config_regs; + struct regmap *config_regs; struct device_node *comp_node[DDP_COMPONENT_ID_MAX]; struct mtk_ddp_comp *ddp_comp[DDP_COMPONENT_ID_MAX]; const struct mtk_mmsys_driver_data *data;