Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1639353pxa; Thu, 20 Aug 2020 17:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysVFjOAP88qT/jmI9wIgNEV1LXB2YWmZLKW9oIiLnV9RQs+dmclgIMKUmuebdkcxVxNZ01 X-Received: by 2002:aa7:d585:: with SMTP id r5mr383017edq.30.1597968160919; Thu, 20 Aug 2020 17:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597968160; cv=none; d=google.com; s=arc-20160816; b=G82HqqEP9jecDfno6psrFWeYxva6sBFDDBRzdQqeDCe3q2KIRU+SAqhOxW7ElnYw4R yLSZJH9XruyCCoulhniXFGtAde7pDC2uROjj7M5fC0OgFaqcS2pY7rk11tTDySW+KnjG GU+JbXmoibljcpsMeRHz4Zv5MkeKvLa9mjBACYxVC9q00DKnteFzAmAczaLs6mnDqoOR TsyN9xTlv5FWWCAmQHnDGEwz+Vvv7kFz9tYBAyZtUeSh2Ma1SmXbexEUdU7Rym5Bq79B viw4mPn5DkoY0OMV75GmwDimK9B1tvpww8VJ5nHMn+JzcgJoalz23NLoSEGLHPuZEC1Y eQ4A== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=JcInZokqGXHBBhNOv8PIIpyDZwyZ6Av/5Zb9DYhdGC8=; b=H2m4tlqaodih0+bZPOEfwWdD9jdJ90YjKTFdYJEIWyqiRZz1bHutsb2ADEGMP5AHRk IM5tQd0luTWkkQhDbbwhFNNPrZAeWuF8sSAMS0jxw5PIg8az7zAu8XXIxOe4j1Ms+D6w NYD0sXM7PcZWoqcGUx0zjh0o4MPtjZVK6WUzGSd6YM0tK7neyYPRcvQjH+i1EfCHSgB9 tqi8qAh3WVkBGi0pCGG3sbNFQEqG2tf3j8PIaDc943JbojciX65q8TSZcq2U7fVZ5XSe Mx2Ya9ToITTocRY+ssoX1xN6zq7Y6Fxe6ICqyMDGghzb9jPb1CgUfwlkhcmi2vGQJaZf LL5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p39NFF2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id e16si2997ejl.531.2020.08.20.17.02.16; Thu, 20 Aug 2020 17:02:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p39NFF2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728784AbgHTXfh (ORCPT + 99 others); Thu, 20 Aug 2020 19:35:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:53146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbgHTXff (ORCPT ); Thu, 20 Aug 2020 19:35:35 -0400 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25382207DF; Thu, 20 Aug 2020 23:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597966534; bh=liAuRg5Rej4YmwcBjkY8n0f/tmyXRRoBRQ4qaTdkfm8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=p39NFF2N5v4Ts0BZXAh7stjpHZvRllSbTUgMwYZ1sTcNEpuRHBYTnp2hyHCjFdZy5 k+HUELxjQgNyzD7dx4hxqKjparUxzIiDZwW3E8QC66ob4//YkJ+SOkwpfXM8BEc2ZK fBUF9+3R1kh1I7TBt4DMyMmsoh/AgjoEgTFYK+xg= Received: by mail-ed1-f42.google.com with SMTP id m20so17387eds.2; Thu, 20 Aug 2020 16:35:34 -0700 (PDT) X-Gm-Message-State: AOAM531bp6VbLzK+ovQOXsCuUe3+TtqAgzGeD78+81RbJtSQJ4FRrK7E FqUugxaMqsk1OrIGI2+xK3mlyb8a7I/Myx7ZAQ== X-Received: by 2002:a50:d9c6:: with SMTP id x6mr162434edj.271.1597966532764; Thu, 20 Aug 2020 16:35:32 -0700 (PDT) MIME-Version: 1.0 References: <1597903458-8055-1-git-send-email-yongqiang.niu@mediatek.com> <1597903458-8055-5-git-send-email-yongqiang.niu@mediatek.com> In-Reply-To: <1597903458-8055-5-git-send-email-yongqiang.niu@mediatek.com> From: Chun-Kuang Hu Date: Fri, 21 Aug 2020 07:35:20 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 04/21] mtk-mmsys: add mt8192 mmsys support To: Yongqiang Niu Cc: CK Hu , Philipp Zabel , Rob Herring , Matthias Brugger , Mark Rutland , devicetree@vger.kernel.org, David Airlie , linux-kernel , DRI Development , "moderated list:ARM/Mediatek SoC support" , Daniel Vetter , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Yongqiang: Yongqiang Niu =E6=96=BC 2020=E5=B9=B48=E6=9C= =8820=E6=97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=882:16=E5=AF=AB=E9=81=93= =EF=BC=9A > > add mt8192 mmsys support > > Signed-off-by: Yongqiang Niu > --- > drivers/soc/mediatek/mmsys/Makefile | 1 + > drivers/soc/mediatek/mmsys/mt8192-mmsys.c | 159 ++++++++++++++++++++++++= ++++++ > 2 files changed, 160 insertions(+) > create mode 100644 drivers/soc/mediatek/mmsys/mt8192-mmsys.c > > diff --git a/drivers/soc/mediatek/mmsys/Makefile b/drivers/soc/mediatek/m= msys/Makefile > index 62cfedf..c4bb6be 100644 > --- a/drivers/soc/mediatek/mmsys/Makefile > +++ b/drivers/soc/mediatek/mmsys/Makefile > @@ -1,3 +1,4 @@ > # SPDX-License-Identifier: GPL-2.0-only > obj-y +=3D mt2701-mmsys.o > obj-y +=3D mt8183-mmsys.o > +obj-y +=3D mt8192-mmsys.o > diff --git a/drivers/soc/mediatek/mmsys/mt8192-mmsys.c b/drivers/soc/medi= atek/mmsys/mt8192-mmsys.c > new file mode 100644 > index 0000000..006d41d > --- /dev/null > +++ b/drivers/soc/mediatek/mmsys/mt8192-mmsys.c > @@ -0,0 +1,159 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// > +// Copyright (c) 2020 MediaTek Inc. > + > +#include > +#include > +#include > +#include > +#include > + > +#define MT8192_MMSYS_OVL_MOUT_EN 0xf04 > +#define DISP_OVL0_GO_BLEND BIT(0) > +#define DISP_OVL0_GO_BG BIT(1) > +#define DISP_OVL0_2L_GO_BLEND BIT(2) > +#define DISP_OVL0_2L_GO_BG BIT(3) > +#define MT8192_DISP_OVL0_2L_MOUT_EN 0xf18 > +#define MT8192_DISP_OVL0_MOUT_EN 0xf1c > +#define OVL0_MOUT_EN_DISP_RDMA0 BIT(0) > +#define MT8192_DISP_RDMA0_SEL_IN 0xf2c > +#define MT8192_RDMA0_SEL_IN_OVL0_2L 0x3 > +#define MT8192_DISP_RDMA0_SOUT_SEL 0xf30 > +#define MT8192_RDMA0_SOUT_COLOR0 0x1 > +#define MT8192_DISP_CCORR0_SOUT_SEL 0xf34 > +#define MT8192_CCORR0_SOUT_AAL0 0x1 > +#define MT8192_DISP_AAL0_SEL_IN 0xf38 > +#define MT8192_AAL0_SEL_IN_CCORR0 0x1 > +#define MT8192_DISP_DITHER0_MOUT_EN 0xf3c > +#define MT8192_DITHER0_MOUT_DSI0 BIT(0) > +#define MT8192_DISP_DSI0_SEL_IN 0xf40 > +#define MT8192_DSI0_SEL_IN_DITHER0 0x1 > +#define MT8192_DISP_OVL2_2L_MOUT_EN 0xf4c > +#define MT8192_OVL2_2L_MOUT_RDMA4 BIT(0) > + > +struct mmsys_path_sel { > + enum mtk_ddp_comp_id cur; > + enum mtk_ddp_comp_id next; > + u32 addr; > + u32 val; > +}; > + > +static struct mmsys_path_sel mmsys_mout_en[] =3D { > + { > + DDP_COMPONENT_OVL_2L0, DDP_COMPONENT_RDMA0, > + MT8192_DISP_OVL0_MOUT_EN, OVL0_MOUT_EN_DISP_RDMA0, > + }, > + { > + DDP_COMPONENT_OVL_2L2, DDP_COMPONENT_RDMA4, > + MT8192_DISP_OVL2_2L_MOUT_EN, MT8192_OVL2_2L_MOUT_RDMA4, > + }, > + { > + DDP_COMPONENT_DITHER, DDP_COMPONENT_DSI0, > + MT8192_DISP_DITHER0_MOUT_EN, MT8192_DITHER0_MOUT_DSI0, > + }, > +}; > + > +static struct mmsys_path_sel mmsys_sel_in[] =3D { > + { > + DDP_COMPONENT_OVL_2L0, DDP_COMPONENT_RDMA0, > + MT8192_DISP_RDMA0_SEL_IN, MT8192_RDMA0_SEL_IN_OVL0_2L, > + }, > + { > + DDP_COMPONENT_CCORR, DDP_COMPONENT_AAL0, > + MT8192_DISP_AAL0_SEL_IN, MT8192_AAL0_SEL_IN_CCORR0, > + }, > + { > + DDP_COMPONENT_DITHER, DDP_COMPONENT_DSI0, > + MT8192_DISP_DSI0_SEL_IN, MT8192_DSI0_SEL_IN_DITHER0, > + }, > +}; > + > +static struct mmsys_path_sel mmsys_sout_sel[] =3D { > + { > + DDP_COMPONENT_RDMA0, DDP_COMPONENT_COLOR0, > + MT8192_DISP_RDMA0_SOUT_SEL, MT8192_RDMA0_SOUT_COLOR0, > + }, > + { > + DDP_COMPONENT_CCORR, DDP_COMPONENT_AAL0, > + MT8192_DISP_CCORR0_SOUT_SEL, MT8192_CCORR0_SOUT_AAL0, > + } > +}; > + > +static unsigned int mtk_mmsys_ddp_mout_en(enum mtk_ddp_comp_id cur, > + enum mtk_ddp_comp_id next, > + unsigned int *addr) > +{ > + u32 i; > + struct mmsys_path_sel *path; > + > + for (i =3D 0; i < ARRAY_SIZE(mmsys_mout_en); i++) { > + path =3D &mmsys_mout_en[i]; > + if (cur =3D=3D path->cur && next =3D=3D path->next) { > + *addr =3D path->addr; > + return path->val; > + } > + } > + > + return 0; > +} > + > +static unsigned int mtk_mmsys_ddp_sel_in(enum mtk_ddp_comp_id cur, > + enum mtk_ddp_comp_id next, > + unsigned int *addr) > +{ > + u32 i; > + struct mmsys_path_sel *path; > + > + for (i =3D 0; i < ARRAY_SIZE(mmsys_sel_in); i++) { > + path =3D &mmsys_sel_in[i]; > + if (cur =3D=3D path->cur && next =3D=3D path->next) { > + *addr =3D path->addr; > + return path->val; > + } > + } > + > + return 0; > +} > + > +static void mtk_mmsys_ddp_sout_sel(void __iomem *config_regs, > + enum mtk_ddp_comp_id cur, > + enum mtk_ddp_comp_id next) > +{ > + u32 i; > + u32 val =3D 0; > + u32 addr =3D 0; > + struct mmsys_path_sel *path; > + > + for (i =3D 0; i < ARRAY_SIZE(mmsys_sout_sel); i++) { > + path =3D &mmsys_sout_sel[i]; > + if (cur =3D=3D path->cur && next =3D=3D path->next) { > + addr =3D path->addr; > + writel_relaxed(path->val, config_regs + addr); > + return; > + } > + } > +} > + > +static struct mtk_mmsys_conn_funcs mmsys_funcs =3D { > + .mout_en =3D mtk_mmsys_ddp_mout_en, > + .sel_in =3D mtk_mmsys_ddp_sel_in, > + .sout_sel =3D mtk_mmsys_ddp_sout_sel, > +}; I would like to do routing control like [1]. [1] https://chromium-review.googlesource.com/c/chromiumos/third_party/kerne= l/+/2345186 Regards, Chun-Kuang. > + > +static int mmsys_probe(struct platform_device *pdev) > +{ > + struct device *dev =3D &pdev->dev; > + > + mtk_mmsys_register_conn_funcs(dev->parent, &mmsys_funcs); > + > + return 0; > +} > + > +static struct platform_driver mmsys_drv =3D { > + .probe =3D mmsys_probe, > + .driver =3D { > + .name =3D "mt8192-mmsys", > + }, > +}; > + > +builtin_platform_driver(mmsys_drv); > -- > 1.8.1.1.dirty > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek