From patchwork Wed Dec 19 12:33:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10737207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 150B9924 for ; Wed, 19 Dec 2018 12:33:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 061A72925B for ; Wed, 19 Dec 2018 12:33:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 038FF294B4; Wed, 19 Dec 2018 12:33:51 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 7E4872925B for ; Wed, 19 Dec 2018 12:33:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 785DB6EF39; Wed, 19 Dec 2018 12:33:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10056.outbound.protection.outlook.com [40.107.1.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id AF5BA6EF39 for ; Wed, 19 Dec 2018 12:33:47 +0000 (UTC) Received: from AM0PR08MB4483.eurprd08.prod.outlook.com (20.179.35.149) by AM0PR08MB3924.eurprd08.prod.outlook.com (20.178.118.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.19; Wed, 19 Dec 2018 12:33:43 +0000 Received: from AM0PR08MB4483.eurprd08.prod.outlook.com ([fe80::1dff:434f:5905:45db]) by AM0PR08MB4483.eurprd08.prod.outlook.com ([fe80::1dff:434f:5905:45db%5]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 12:33:43 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau Subject: [PATCH v2 4/9] drm/komeda: Add DT parsing Thread-Topic: [PATCH v2 4/9] drm/komeda: Add DT parsing Thread-Index: AQHUl5cUt9ULts/t3UaAJkdKdzOFrQ== Date: Wed, 19 Dec 2018 12:33:43 +0000 Message-ID: <20181219123147.16090-5-james.qian.wang@arm.com> References: <20181219123147.16090-1-james.qian.wang@arm.com> In-Reply-To: <20181219123147.16090-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: SYBPR01CA0132.ausprd01.prod.outlook.com (2603:10c6:10:5::24) To AM0PR08MB4483.eurprd08.prod.outlook.com (2603:10a6:208:145::21) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3924; 6:+8fIjqU9TaqfpHt8JDh4l8BfjY9pN1vKC3hBmfSw92mCq926J9UKCTrYgEljHtseiGKE17mqCvhfYa5Vbq2dW1fG4nw7SJ8I6OZFf8UH7iAcEVV6EhpuDV6kjp/slvMbT66AgjG9+CvhRU4MwLcZDChVxh2WbEXCgsi9gXiCIFKyshcwd9/2Hs4DehWCDsGVPPqiBsyxuykYzbVp2XvpiBOI6lPF0s0ate+hQCClj/hgbYgd7qly4eu2Zj91CsU9oRisCjsmRxwH/ZvqWehn7Nqc3YYOk3Iy78fu1Nm5rDIKvMf8j63gkd2IsrzSjnADr/Os8gxDJNScCkpULMm5DUllcglVFfIqNj0tnDf24YI+UXdXsSwpRE7hkHRilfQRiNu9qy1uC6kccxqfjnL3dxo7O3jVTgIVgegahAYYX5+vjZY3/cFr/C2ESMncNoyKM4w9AS863HzRuXUBmmY8hg==; 5:v2nDbtW9hQAuJ3KJaYyh0D+EoIgocf3R5EmXRyEceudxGpoL6yo+mskpfd1ABFzfvu/yoXIhb8dqt2OM1cHKJU9ZbBpDyzFKZF0pqd+tXCbEfc1kyUtAw4MDUXwUe3dCpacLMIqrlja9ihjbM2IiD0JS+pdt1kxEtxQ0ZHm7vk4=; 7:OEfnRJHhRQBufY+tRunVKVUeigzhpnx/ZurwheRgl2xwc0zo7OaBToOQFIqYARo0VYvFPgzLSfAGS6y9PYQ/EDcrRsQv4a2GeF+9ODfBxrKOaT9/FOKBFIUicV2xJfTaaedMzU7VMSciEZqYVtncIQ== x-ms-office365-filtering-correlation-id: 701a94d2-96d8-40a3-5514-08d665ae367f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3924; x-ms-traffictypediagnostic: AM0PR08MB3924: nodisclaimer: True x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3924; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3924; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(346002)(39860400002)(366004)(376002)(199004)(189003)(316002)(8936002)(103116003)(37006003)(1076003)(71190400001)(81166006)(81156014)(11346002)(446003)(97736004)(36756003)(54906003)(256004)(2616005)(486006)(6636002)(99286004)(71200400001)(476003)(575784001)(86362001)(8676002)(106356001)(105586002)(5660300001)(3846002)(7416002)(6116002)(14454004)(68736007)(6512007)(2906002)(4326008)(25786009)(6486002)(76176011)(52116002)(53936002)(186003)(55236004)(102836004)(26005)(6862004)(6436002)(305945005)(478600001)(6506007)(66066001)(386003)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3924; H:AM0PR08MB4483.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: l89mpEenLD+s/Tp08B2a1ZcyGzBBnAeQt86+uyIYu/E5021jZ+s5i/x/nRwubpmNHIxt5ozTV262j/ySFPrqnCffKsJuO/UphFcSgdojH/sFiZtcgMFd7O4IH1GzmkQoRBQpaMZSS226LIEV2iGUHYvLLGoJcGPY6DY+wG7tC3YKstBmJXrohwPAAttItMLFJQD5eOvjUtVPi25FrnSlUOqwgnj051pCkbiCSIeD3EYmBzH3nyzfBSUhFuHfBMID0L0ZrSDrgZ85d+dCRyVWN+C7tRlbSngS69ZqqfviC4uPXqw3JkZqAekYsZzdPBAe spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 701a94d2-96d8-40a3-5514-08d665ae367f X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 12:33:43.6155 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3924 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "linux-doc@vger.kernel.org" , "maxime.ripard@bootlin.com" , "Jonathan Chai \(Arm Technology China\)" , Alexandru-Cosmin Gheorghe , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "yamada.masahiro@socionext.com" , "Yiqi Kang \(Arm Technology China\)" , "mchehab+samsung@kernel.org" , "Tiannan Zhu \(Arm Technology China\)" , "corbet@lwn.net" , "airlied@linux.ie" , "malidp@foss.arm.com" , "thomas Sun \(Arm Technology China\)" , Ayan Halder , "devicetree@vger.kernel.org" , "arnd@arndb.de" , "robh+dt@kernel.org" , "Jin Gao \(Arm Technology China\)" , nd , "sean@poorly.run" , "Lowry Li \(Arm Technology China\)" , "gregkh@linuxfoundation.org" , "rdunlap@infradead.org" , "nicolas.ferre@microchip.com" , "Julien Yin \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "akpm@linux-foundation.org" , "davem@davemloft.net" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Parse DT and initialize corresponding dev/pipeline attributes. Signed-off-by: James (Qian) Wang --- .../gpu/drm/arm/display/komeda/komeda_dev.c | 74 +++++++++++++++++++ .../gpu/drm/arm/display/komeda/komeda_dev.h | 3 + .../drm/arm/display/komeda/komeda_pipeline.c | 4 + .../drm/arm/display/komeda/komeda_pipeline.h | 7 ++ 4 files changed, 88 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c index 887a17005367..214ef75e0e24 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c @@ -12,6 +12,74 @@ #include #include "komeda_dev.h" +static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np) +{ + struct komeda_pipeline *pipe; + struct clk *clk; + u32 pipe_id; + int ret = 0; + + ret = of_property_read_u32(np, "reg", &pipe_id); + if (ret != 0 || pipe_id >= mdev->n_pipelines) + return -EINVAL; + + pipe = mdev->pipelines[pipe_id]; + + clk = of_clk_get_by_name(np, "aclk"); + if (IS_ERR(clk)) { + DRM_ERROR("get aclk for pipeline %d failed!\n", pipe_id); + return PTR_ERR(clk); + } + pipe->aclk = clk; + + clk = of_clk_get_by_name(np, "pxclk"); + if (IS_ERR(clk)) { + DRM_ERROR("get pxclk for pipeline %d failed!\n", pipe_id); + return PTR_ERR(clk); + } + pipe->pxlclk = clk; + + /* enum ports */ + pipe->of_output_dev = of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0); + pipe->of_output_port = of_graph_get_port_by_id(np, KOMEDA_OF_PORT_OUTPUT); + + pipe->of_node = np; + + return 0; +} + +static int komeda_parse_dt(struct device *dev, struct komeda_dev *mdev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct device_node *child, *np = dev->of_node; + struct clk *clk; + int ret; + + clk = devm_clk_get(dev, "mclk"); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + mdev->mclk = clk; + mdev->irq = platform_get_irq_byname(pdev, "DPU"); + if (mdev->irq < 0) { + DRM_ERROR("could not get IRQ number.\n"); + return mdev->irq; + } + + for_each_available_child_of_node(np, child) { + if (of_node_cmp(child->name, "pipeline") == 0) { + ret = komeda_parse_pipe_dt(mdev, child); + if (ret) { + DRM_ERROR("parse pipeline dt error!\n"); + of_node_put(child); + break; + } + } + } + + return ret; +} + struct komeda_dev *komeda_dev_create(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -74,6 +142,12 @@ struct komeda_dev *komeda_dev_create(struct device *dev) goto err_cleanup; } + err = komeda_parse_dt(dev, mdev); + if (err) { + DRM_ERROR("parse device tree failed.\n"); + goto err_cleanup; + } + return mdev; err_cleanup: diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h index 680e3e2cf100..4a27a44e2ec6 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h @@ -72,6 +72,9 @@ struct komeda_dev { /** @mck: HW main engine clk */ struct clk *mclk; + /** @irq: irq number */ + u32 irq; + int n_pipelines; struct komeda_pipeline *pipelines[KOMEDA_MAX_PIPELINES]; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c index 10378df8e5a8..2f36b6bd8282 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c @@ -55,6 +55,10 @@ void komeda_pipeline_destroy(struct komeda_dev *mdev, clk_put(pipe->pxlclk); clk_put(pipe->aclk); + of_node_put(pipe->of_output_dev); + of_node_put(pipe->of_output_port); + of_node_put(pipe->of_node); + devm_kfree(mdev->dev, pipe); } diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index eea1e64c4624..e097d4fcb2c5 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -286,6 +286,13 @@ struct komeda_pipeline { struct komeda_improc *improc; struct komeda_timing_ctrlr *ctrlr; struct komeda_pipeline_funcs *funcs; /* private pipeline functions */ + + /** @of_node: pipeline dt node */ + struct device_node *of_node; + /** @of_output_port: pipeline output port */ + struct device_node *of_output_port; + /** @of_output_dev: output connector device node */ + struct device_node *of_output_dev; }; /**