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: 10016607 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 6AF39602C8 for ; Thu, 19 Oct 2017 12:34:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C75428D29 for ; Thu, 19 Oct 2017 12:34:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FA6028D36; Thu, 19 Oct 2017 12:34:02 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E066028D29 for ; Thu, 19 Oct 2017 12:34:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE09D6EA8A; Thu, 19 Oct 2017 12:33:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E9466EA6B for ; Thu, 19 Oct 2017 11:26:59 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id b6so6374755pfh.7 for ; Thu, 19 Oct 2017 04:26:59 -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=WzDypsfS3yQ9+RF8kQ/0Uel5L1iedttPGHtwbAOpZ01ZNzmzznN050S73SWtIfLu1Z uL30yeLuHzotAjhzbs2QtyvVG3g+HGnlwvyKNpY+4owHuQrZAwdC38Cv91ruB/Fcwz61 NDykHrjpmUfIOjTmqYyCqp8L/9m0CORXmCMDsJWt/T9wKE32iTYvj1yGUbrULceqsf3J dZAxqBRXNJzeZ/qzrM9cKYPULbqi1XjoMIQb5Q3TlFeGcqeIrgK5b8DO2/u8tnenequG COantwLpYkcpMjDITySAFBseBdUq2OEAfsNQDvBjmBN6RdYoXtmAWmdaoUmZTyn+6kAY sncg== X-Gm-Message-State: AMCzsaXa3O8WmiNM88GzrKhg7veY4xSDu+ycfNc7fl6kXXXekczlaZvw L9I3dOpRmq8aSftlgClZtGc= 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-Mailman-Approved-At: Thu, 19 Oct 2017 12:33:49 +0000 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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;