Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3538756imu; Mon, 24 Dec 2018 04:05:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wmyu49I5E1EYLMYeiMB+DYnsD1UkXBwz3h5dV8q2LvaOyvBn7CFGi7RYjJ5GZ9hB3DNqlA X-Received: by 2002:a62:1043:: with SMTP id y64mr13086447pfi.78.1545653138257; Mon, 24 Dec 2018 04:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545653138; cv=none; d=google.com; s=arc-20160816; b=fGEm8h3KkhH4zFXczffh1KFbwhrQtya7l/MCVb1B9idhdVzcLpFsW0y/apJdi3hZeP bhdLjpK0KmdFc0CsjWdM1YvwYZPWvebOpv2/0FqM/9DPuwxvTcpsn8AeurJ0mMkzxE+M 6r84yj3c/+ZRCptZDUF1HZAVPZNEn43zdVqBuj6sUXiAG0xTLV3kBdd/SWon82IsnrF/ fkdOvDKUQsURVT7FJkVO7SdszWsER9qDyFpjOyewegHNcLUZ92J0LG+iAtRMrHVZb4DA 1OWAH3wA61sd5IeEYfQ+D8m5M9p83NDXV9W2iqR7F/AexS1V0lAmu4Ws/377PSzLePC5 mCHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xH0dGNyISB8vkeahDVpU1Z+0bDXMmzxWnNt3bPlKvIA=; b=am3zEHH1VWVwF72UeJanF9k1+Nh+h092Gx/W1VaVb9l5BxoUW0FgdZR9K+QmtVw6w2 dsylR9340BVskeuJYzIGpdRmSfzX8q23EwpvYCbP3zkVkiPaLdvSW3kaT6dq3QIjWjIt 0waY8BMx7d00L1bI1jcIleWALT4bgJeKZ8NsrCErh3Q2OV4RuPlWfwWLX3EGI3dByw/f o2Ow4XdyLLwY8rR8WlF4VpLUcLgQ5ZeMbKcday8jmz2YFU15710wKFdjnIoA98XjzhX1 14kFfxKCFyQ4fYT5xAUzIVcN42rq83QLGkQbC4dw4mkUcqOJ4h/PzbDlaYrTo4nVtzil vPJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si25867875pgj.60.2018.12.24.04.05.23; Mon, 24 Dec 2018 04:05:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725919AbeLXMDH (ORCPT + 99 others); Mon, 24 Dec 2018 07:03:07 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58116 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbeLXMDH (ORCPT ); Mon, 24 Dec 2018 07:03:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7D44E80D; Mon, 24 Dec 2018 04:03:06 -0800 (PST) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27F653F718; Mon, 24 Dec 2018 04:03:06 -0800 (PST) Received: by e110455-lin.cambridge.arm.com (Postfix, from userid 1000) id 84ECB680369; Mon, 24 Dec 2018 12:03:04 +0000 (GMT) Date: Mon, 24 Dec 2018 12:03:04 +0000 From: Liviu Dudau To: "james qian wang (Arm Technology China)" Cc: "Jonathan Chai (Arm Technology China)" , Brian Starkey , "Julien Yin (Arm Technology China)" , "thomas Sun (Arm Technology China)" , Alexandru-Cosmin Gheorghe , "Lowry Li (Arm Technology China)" , Ayan Halder , "Tiannan Zhu (Arm Technology China)" , "Jin Gao (Arm Technology China)" , "Yiqi Kang (Arm Technology China)" , nd , "malidp@foss.arm.com" , "maarten.lankhorst@linux.intel.com" , "maxime.ripard@bootlin.com" , "sean@poorly.run" , "corbet@lwn.net" , "linux-doc@vger.kernel.org" , "rdunlap@infradead.org" , "mchehab+samsung@kernel.org" , "davem@davemloft.net" , "gregkh@linuxfoundation.org" , "akpm@linux-foundation.org" , "nicolas.ferre@microchip.com" , "arnd@arndb.de" , "robh+dt@kernel.org" , Mark Rutland , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "airlied@linux.ie" , "yamada.masahiro@socionext.com" Subject: Re: [PATCH v3 4/9] drm/komeda: Add DT parsing Message-ID: <20181224120304.GF22341@e110455-lin.cambridge.arm.com> References: <20181221095757.15510-1-james.qian.wang@arm.com> <20181221095757.15510-5-james.qian.wang@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181221095757.15510-5-james.qian.wang@arm.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 21, 2018 at 09:59:44AM +0000, james qian wang (Arm Technology China) wrote: > Parse DT and initialize corresponding dev/pipeline attributes. > > Changes in v3: > - Fixed style problem found by checkpatch.pl --strict. > > Changes in v2: > - Unified abbreviation of "pipeline" to "pipe". > > Signed-off-by: James (Qian) Wang Acked-by: Liviu Dudau Best regards, Liviu > --- > .../gpu/drm/arm/display/komeda/komeda_dev.c | 76 +++++++++++++++++++ > .../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, 90 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..d0cc4f758077 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c > @@ -12,6 +12,76 @@ > #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(pdev, 0); > + 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 +144,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 9293598b0533..e731b2a85c3a 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 2174796d47c5..d1e0c1140273 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h > @@ -290,6 +290,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; > }; > > /** > -- > 2.17.1 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯