From patchwork Wed Aug 14 18:46:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171337 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1203077ily; Wed, 14 Aug 2019 11:47:21 -0700 (PDT) X-Received: by 2002:a62:7d93:: with SMTP id y141mr1411395pfc.164.1565808441244; Wed, 14 Aug 2019 11:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565808441; cv=none; d=google.com; s=arc-20160816; b=K8ZsbwQIONezkpp2jsgphmLGbhrPMQrYnH/2mPg8f2zHnH0dgNZle3kzRIXcCqIIfU 1c/5y7g230fuDj1c4+IcCpX5XsWepxkWKjfTpGylwAnoimTZFPDot8ZlyYhQtJS19MT+ hIYUxMdQ/kcYjl2GqLC4C7StZbCzVuFLGY4h4mLtNbe2JewUQOa6AIbG2+NS+oOS3PX7 5QVUhQE1Sk7EA5DwVTCyuE9T5A84ESB2+DlEUwH/AjRGoH4nFBu9Z7YGfgqIQ+lmT1bR B+CmayfE7GsNYsXjKiw6k30M3CBLgc+4br/JewDAFY0uuvAYSFsIxqJiTWtYh91bxmqQ l3rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S7G+b/AKW3ZGIOc1Uy5hIvA+emi22Ls1Jq5SWNDVSjE=; b=hi+HmKeUvz6gst77lPxyZ6Y2u3Z0HPr8jI2l076AMW0cn6dUqfFZw7QAUwEsxpgNVh oVGkIMdv/1SP9vc3difTsj9caJIp9g3MvT5Yqb0dpt801BKoV+HSiSWRLasZ4APxwxc6 Z9ni2I8FKLY9rvGCoNw0QstW8wwZJI05CeeE5pM+UouaN2JOLfMwl9G8G6DUUi5dB/Gw ORA2kfPTX+7HqJEJWwukq8Ex4/OGdu+/NmieGjJuEKB7uZOv43ZY3ioXBcbA26Af+7Pp 481f47nlZ6NhHh8GH6IDxXj0CnQWhkUpoueBC6+WT3q/hby1PnX5yEHqtSKMnWcSZ+nF 3rWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nc6VyDeL; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v13sor409849pgn.35.2019.08.14.11.47.21 for (Google Transport Security); Wed, 14 Aug 2019 11:47:21 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nc6VyDeL; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S7G+b/AKW3ZGIOc1Uy5hIvA+emi22Ls1Jq5SWNDVSjE=; b=Nc6VyDeLkp4MAbOVFgNDIEDfMdp0ijLVLpHeDJmme19KqUpqX+fHbwurSw04qnZLL6 JCH6P0UQRYb7SFDeqHuj41hMixuWPJJFZq02BBnWJHH8Mli44qR+3YT9X8om9y3/SV30 BMgRd0BMrno37eHclBWeNqb0d5vSye8FVTVoMxjuERMYuFKAlBvlkcpgmZ3N1wrXLVfR KmuQCmk7+BYlKXZkuwDxhTVdB1fqRdO1uSGNTOhgpJK8TebqflZTQdMHQ7UL/11w6CIv xLO2aOYiJXhRDZc5g5fR9CSuHMv3rSOmlK23rcUWy/cIHjKTlcRVmcojG7tgnCq8cnWb dLog== 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=S7G+b/AKW3ZGIOc1Uy5hIvA+emi22Ls1Jq5SWNDVSjE=; b=ioua2/auv04IcJUyJhVZGT6q0RHWarh40gw2NfqpIBtwmRra+yWoybcqLn6I+SNyXT PQ6kvDobPrNu0Un5iq1sjwwtV7pgIsdaox/e2QIpmTHpdGlyhj6OV1VC8lnfFSguJo9D AOsJJkOT7r8TuyJ6DJ4+9dvqhkreKldpC/+tJqyQz7sOs3PQSEdf/VRE4GfyphWS/vB8 j5kmVuVKjZz1cVMQ0WrVMpBo8jH+7SZ4gwwaYnT13E+gykivdY2Pm1KyRWo3zFO1uMuD wumXtqBXPUU/QeHXtiL9ybpFa+iboOMtknGQt9L6udsmbDx1l19/FqTDQ8o8ZTLctSSE mpoA== X-Gm-Message-State: APjAAAX9PWT5ilZBOUBp62t+oxGe4xaZgsNtnrZ5K5l6zIVEXw7Vp0Yi JP1YUvNnDaeBcHOOb5UrM+jaHtLa X-Google-Smtp-Source: APXvYqycFrgHQDs7Dh4+d+eohgA56r1m5xdvJK1utw9z5PlXMq5ucRmdbzs2NNCTGHKWQ0/rxxINJw== X-Received: by 2002:a63:4823:: with SMTP id v35mr517107pga.138.1565808440616; Wed, 14 Aug 2019 11:47:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y16sm610855pfc.36.2019.08.14.11.47.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 11:47:19 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [RESEND][PATCH v3 09/26] drm: kirin: Dynamically allocate the hw_ctx Date: Wed, 14 Aug 2019 18:46:45 +0000 Message-Id: <20190814184702.54275-10-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814184702.54275-1-john.stultz@linaro.org> References: <20190814184702.54275-1-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization function to dynamically allocate the ade_hw_ctx structure previously kept as part of struct ade_data. This is done so that later we can have the hw_ctx point to hardware revision specific ctx structures. Cc: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index ee3dc3d0f738..ddcfe0c42d7c 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -72,7 +72,7 @@ struct kirin_plane { struct ade_data { struct kirin_crtc crtc; struct kirin_plane planes[ADE_CH_NUM]; - struct ade_hw_ctx ctx; + struct ade_hw_ctx *hw_ctx; }; /* ade-format info: */ @@ -951,55 +951,62 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, return 0; } -static int ade_dts_parse(struct platform_device *pdev, struct ade_hw_ctx *ctx) +static void *ade_hw_ctx_alloc(struct platform_device *pdev) { struct resource *res; struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; + struct ade_hw_ctx *ctx = NULL; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) { + DRM_ERROR("failed to alloc ade_hw_ctx\n"); + return ERR_PTR(-ENOMEM); + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ctx->base = devm_ioremap_resource(dev, res); if (IS_ERR(ctx->base)) { DRM_ERROR("failed to remap ade io base\n"); - return PTR_ERR(ctx->base); + return ERR_PTR(-EIO); } ctx->reset = devm_reset_control_get(dev, NULL); if (IS_ERR(ctx->reset)) - return PTR_ERR(ctx->reset); + return ERR_PTR(-ENODEV); ctx->noc_regmap = syscon_regmap_lookup_by_phandle(np, "hisilicon,noc-syscon"); if (IS_ERR(ctx->noc_regmap)) { DRM_ERROR("failed to get noc regmap\n"); - return PTR_ERR(ctx->noc_regmap); + return ERR_PTR(-ENODEV); } ctx->irq = platform_get_irq(pdev, 0); if (ctx->irq < 0) { DRM_ERROR("failed to get irq\n"); - return -ENODEV; + return ERR_PTR(-ENODEV); } ctx->ade_core_clk = devm_clk_get(dev, "clk_ade_core"); if (IS_ERR(ctx->ade_core_clk)) { DRM_ERROR("failed to parse clk ADE_CORE\n"); - return PTR_ERR(ctx->ade_core_clk); + return ERR_PTR(-ENODEV); } ctx->media_noc_clk = devm_clk_get(dev, "clk_codec_jpeg"); if (IS_ERR(ctx->media_noc_clk)) { DRM_ERROR("failed to parse clk CODEC_JPEG\n"); - return PTR_ERR(ctx->media_noc_clk); + return ERR_PTR(-ENODEV); } ctx->ade_pix_clk = devm_clk_get(dev, "clk_ade_pix"); if (IS_ERR(ctx->ade_pix_clk)) { DRM_ERROR("failed to parse clk ADE_PIX\n"); - return PTR_ERR(ctx->ade_pix_clk); + return ERR_PTR(-ENODEV); } - return 0; + return ctx; } static int ade_drm_init(struct platform_device *pdev) @@ -1020,14 +1027,16 @@ static int ade_drm_init(struct platform_device *pdev) } platform_set_drvdata(pdev, ade); - ctx = &ade->ctx; + ctx = ade_hw_ctx_alloc(pdev); + if (IS_ERR(ctx)) { + DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); + return -EINVAL; + } + ade->hw_ctx = ctx; + kcrtc = &ade->crtc; kcrtc->hw_ctx = ctx; - ret = ade_dts_parse(pdev, ctx); - if (ret) - return ret; - /* * plane init * TODO: Now only support primary plane, overlay planes