From patchwork Tue Aug 20 23:06:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171867 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180028ily; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) X-Received: by 2002:a63:188:: with SMTP id 130mr26469726pgb.231.1566342401642; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342401; cv=none; d=google.com; s=arc-20160816; b=Tzpz110SCIjLGvsv8/uqk5NKD9k3ucuNUJtkZ5xdizr3bIGQcAj74GXX/48jV0yUPJ TRNwUBwb3U8uZt6XHBkjEoq80uxkUZd33PIzpMLfPQqEL2EIopMAi4ifLuU0+D6MtNSD JSL7PEQUgRBESIZmecDiMHkdEUvg5ho1v5FWLN+7oUKK6vhMPXXYajGn6vD+B389XaLj C1vB78DolVF/0r3JzLyff9Eu1T0SNIFnn7HLf1VJl02E5TOn6aY4NpmICVzHJQmJjAvX FgG1VEGMlfb2HPx7HHhCavUIzdhNJ0dojemjIl8RyayhHlZF1ky9gL8o3bdBlPisVrmw VGmw== 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=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=fXQQ1jpcjd+zmG13aIf9WMrhTKli8IecW1seXDlMmmTUOsCYLmgWwzlkZBfcDPEjGs ipuvw0A9/WodHnUtSAqYAfj01ofdaS4g4SSYga8cVloyqafGLiyTNTsYGtvSygZaej/K hmbtlk6eXd+EoJhnm6mrl3Fsp20xzBR11pL9cnQhCjx2S/jmWx7ADveqd+m3tK0Jv7lJ UeauUliuqKqKWfJIoM3q4uM7BI405/JzJVnNcULxTXtFGAMuEihZL3M4/sbAfSav7Ff6 1eVAmECX9s4tT1ppGoPO9LkKRa3HO4E4mXwcSX95BgVCWwEQ/W6n9BcP/CoP8tY2ot/u GaSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ultjCohi; 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 q13sor5747990plr.43.2019.08.20.16.06.41 for (Google Transport Security); Tue, 20 Aug 2019 16:06:41 -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=ultjCohi; 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=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=ultjCohiF3aF5SKoBtMgvK3996QvDB4DB8LMN4ZJXzQ/IADuWxwM6RXS0aL1KWxhky f17ioMxRO2j+E5oyHoDncbYXqO0/p/6EdVY/+hlXpqUJvTKFAQ5imnrAr6qbwaLIbTXt JqijIJ7KAIMXd5/ir6UAwmV1WRSe3nm0N+Lbx1TS1rsEy3eAOKW6W7ooAnK1KJG3s6Bj XsKnzgBNlzhkM+dqHOFHXBVYDrRkqQJaJFR9JiJUVtwohJyi0I1YEDOEDGaaFwf1W6dS fBqwUySj7mnJbpGcZVapSGC6x2bu9M+D/iThbVPJ8PejNTx3fyX9iaxAXbf6VGxVzivY O9Kw== 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=JD7m4tZwO+IDa1xgX/FwZAd/NdHORHjMi+i9qNb5uKs=; b=jBV2zICvxA9hKck8B91RiBSjgJgebfVRHrAFF7/BeWcRtA8hUyDuZio9ORinIeziFd DlZnyn2dneQEsoGoFW38w1tlWxS9/3VgvjUylmmnLxpSaJXpS3ooJtiU/OpAegmb5LQ7 E0ePyMsvpq73E9S9Qbr7fa6Sj3YwVzIdqLe5B2MPdI43jf8VwkcfLvvsFXhEKj4r/MaX 4TUUOSrnf3NNEZ30ZZgXILIfBvMOuucTdcE6X97woEBNxZrDoKeiQXmAgLxVuSTtiRJm bYq4PF81/0+FyJP+MuU5VJFFgXVwlSq/vezvjHpZPZjmbxg8Q13w3aB4+ddEFPvwB6uL u9Nw== X-Gm-Message-State: APjAAAVf0Yplgj+3o2l6WWC14PfBMy5K6Bt5LC+DIrgUfmn+dMIzszTf HcAH9vvBcdsDGtq7Xjm8Y8tvqU7r X-Google-Smtp-Source: APXvYqyjR3pev/6MPv1S4rx9Fw8zhNrO4paP3w4iaxvHJPNck874/OAEJfh9LV3ko11Ugqjy3Y3w0g== X-Received: by 2002:a17:902:5a46:: with SMTP id f6mr28717477plm.319.1566342401294; Tue, 20 Aug 2019 16:06:41 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:40 -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: [PATCH v5 08/25] drm: kirin: Dynamically allocate the hw_ctx Date: Tue, 20 Aug 2019 23:06:09 +0000 Message-Id: <20190820230626.23253-9-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-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 Acked-by: Xinliang Liu 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 fce374ec69e8..ecb507985fea 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