From patchwork Sun Dec 22 13:22:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 954 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E5C9D3F042 for ; Sun, 22 Dec 2019 14:29:47 +0100 (CET) Received: by mail-pl1-f197.google.com with SMTP id c11sf2901674plz.8 for ; Sun, 22 Dec 2019 05:29:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1577021386; cv=pass; d=google.com; s=arc-20160816; b=tP+n9on8TlsBFPCRm7MxoKmC1SF1XY4CIRQLHXCdksMPSC5m2m6HNlq03N+2eNdwZ+ zE4XsCSv2V89dXgnVs/yZxxZ0y2F9xrUoQgB5vZpYJJZqieNYdcbNthXkE9xOcjeACfb 3inKU+MUziTlSOTZkyPdGGLMvP5ALrukbAxCavle5sqmwF3/+X83jlzGUS55PL8Hruyq x7Ea2CWp1Gj7DakZnj1KwiN9kh64z7ou+N5FBFBC5Ai7T3SGwOcyb/eViU8NemoEdTwX gOSP9+vFz7T7Oc3do0BNn6kEb9pHpl3ZXOsmARv0jADdLuePJq7O3p66DGeDflo3Mvj7 Dvfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=zL3W63uLIAumVnvvlfF/M0UBax4HZOTKJTvkc2HsLHU=; b=mIOE5oomQnHHPoHXUl0onWDzRcztOmNfzn7/QjSGQ/A6r60MTukU2FWhTKdydVpnj8 Cndfh2BuLlqboGf2S2O6Ak6OqnxxXzyzp3b7siy33oh87niqqqiFfNCnLnzGrBSu0ShV MUn6m9k8uyqtjk35PUyUkUTb1lvZqRII9oJsjwjLhMdQJSyQs5DY4jhUd+XSbtEaMDXQ B0ujEoaHV44EOnKE93Dgi7UqGBkWe6YS+NDWIvKgvq8v3kjYXF6w0XZBJSR+7gwEMGnD WDfeYm0HN8VG8sTUsG+DDB/QdjXV4U8Oh8G73k0FBzVNbRjG6LXa/9/J/jRkAMxeWqDs RbsA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=elp3iMXt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=zL3W63uLIAumVnvvlfF/M0UBax4HZOTKJTvkc2HsLHU=; b=aC3ira8IyWuy9vjBtA1z9RvblV1GMGdXCQGzy7gPdnqkAECY3oT/h80k5Vk3odwTvY 3ETAMJ+PpSm7QXr5xumqDpEtF5l3RXuuVpDUARJ1i/6TxRr0FgYD2Bv7L1YDQCiBZ7j6 IVqe0TBnzYl8vwqu/E8N/KEdge87lzlo6+eE8= 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:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=zL3W63uLIAumVnvvlfF/M0UBax4HZOTKJTvkc2HsLHU=; b=Te9sXPmfRwU31aEvGCtkAr7GoLXfZ8hDZXilcsNCO3ix556Zy1yGPSYRYL0+hAYVEe YPCFC+2S6CLBMd2zmzL5/Svsf6Tl+1CoVR6c2ehEfhTbuJ/fDPHm/A58FRFqK6UwDQl7 bhAX/SmUU5VOr8C5SyMxpntOyxYg40zTMLISy2a3wvaX8fO5uz+3Kp1MVpBqKPJtKEF2 Ii4C1hC3Wq4IK8i79cd9enSGbfBsemtE7pIRVUAmkk2MZznqIW0rWUF5rzNBDtWgMJyM sJ1iZm/ovCouwIVDnF95c/xQRqzFGVD8LHqPvcTfo46NaFAh9aOjOZXuKP+OUmstSoiX Bk6w== X-Gm-Message-State: APjAAAUIE1fmLc1kJt44dBfA7Zk0FKIMynz1Wk2XKMYaNd3Bko87e33w 0WQHlfO1KZCRT92PuS2Y8oaYLSEc X-Google-Smtp-Source: APXvYqzHRa/GTrv25qNMGv+7RHHGBmNriu7XaS8hQu+GhE4DRCsLmYAOTq5qpXtAlqxS9KBJFRw/wg== X-Received: by 2002:a65:4106:: with SMTP id w6mr26286051pgp.347.1577021386194; Sun, 22 Dec 2019 05:29:46 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:c244:: with SMTP id l4ls707836pgg.2.gmail; Sun, 22 Dec 2019 05:29:45 -0800 (PST) X-Received: by 2002:aa7:991e:: with SMTP id z30mr26746384pff.259.1577021385657; Sun, 22 Dec 2019 05:29:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577021385; cv=none; d=google.com; s=arc-20160816; b=HkvkgUErlJJCucJg9DQerSljU8YA/z9Zcrxfc3bzqUv/Wyhqjjwpa7hnyKlWZS0pJT 2KsRMpJj6A+hkEnt10+XG71opACV69sOm/8/Y6K7W7ayCza9CbIh/NNVp80ZgTZWBPaa L+LTr1VYRjqOhU6qnZQuPCb+umnMC2atCDmar2v10ZPFkFatDR1+2YixG0uuHAz2QLbT Q45D06Evf0E2DEcn8YckaEDcQ1wIwc09oK3/GXmBGOGQeW+s4nVultNV/4VuzepbTOOP VwrJo6/t45S7X1Etm5Vo5JnHn1pBrOGrxfjAOBMxjdQ3uEu45QJqleIX7dXaWMCjW4rv gsdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9EK74rOb2z7EDUkpcZJ+pjm2y3iAMcEo48mh6FOoxhw=; b=tuEGLf9O04BwxkrbfCPaMzdM2f3LYvRRR7Ql/ejXAN/0h1Txr2twYwPW2bbgKD88nC WJzkXH8Xo+wrtvwHPvgQa9nZCih03n6w0yMpCJnUlLtTs1+5vRAt28U+iXsS+AiIxFih CIyFA6oNJRrxoZmHlKOe+YlGNwYQojdNkfReedrtlfjGuYR/rGr0SfbqWHkyUu4mQ/ur 6UEKmqrqO3PSJVn2YzlCkltZypkCkaNEEWhsl2n/+ATT9nTR0OMdNp9FfuQUnRixmZeX cXxkQaXOMnZNhUm8XW3XqjCy2bQ9pDHPuPA5o3FG+win000uwsOCuBEaLatU3BUT+EOu YiXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=elp3iMXt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a1sor16793839pjh.7.2019.12.22.05.29.45 for (Google Transport Security); Sun, 22 Dec 2019 05:29:45 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:db48:: with SMTP id u8mr7360374pjx.54.1577021385351; Sun, 22 Dec 2019 05:29:45 -0800 (PST) Received: from localhost.localdomain ([49.206.202.16]) by smtp.gmail.com with ESMTPSA id o2sm12073058pjo.26.2019.12.22.05.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2019 05:29:44 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland Cc: michael@amarulasolutions.com, Icenowy Zheng , linux-sunxi , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v14 4/7] drm/sun4i: dsi: Handle bus clock via regmap_mmio_attach_clk Date: Sun, 22 Dec 2019 18:52:26 +0530 Message-Id: <20191222132229.30276-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191222132229.30276-1-jagan@amarulasolutions.com> References: <20191222132229.30276-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=elp3iMXt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , regmap has special API to enable the controller bus clock while initializing register space, and current driver is using devm_regmap_init_mmio_clk which require to specify bus clk_id argument as "bus" But, the usage of clocks are varies between different Allwinner DSI controllers. Clocking in A33 would need bus and mod clocks where as A64 would need only bus clock. Since A64 support only single bus clock, it is optional to specify the clock-names on the controller device tree node. So using NULL on clk_id would get the attached clock. To support clk_id as "bus" and "NULL" during clock enablement between controllers, this patch add generic code to handle the bus clock using regmap_mmio_attach_clk with associated regmap APIs. Signed-off-by: Jagan Teki --- Changes for v14: - drop regmap_exit, clk_put drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 37 ++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 68b88a3dc4c5..2577b237d06a 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -1081,6 +1081,7 @@ static const struct component_ops sun6i_dsi_ops = { static int sun6i_dsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const char *bus_clk_name = NULL; struct sun6i_dsi *dsi; struct resource *res; void __iomem *base; @@ -1094,6 +1095,10 @@ static int sun6i_dsi_probe(struct platform_device *pdev) dsi->host.ops = &sun6i_dsi_host_ops; dsi->host.dev = dev; + if (of_device_is_compatible(dev->of_node, + "allwinner,sun6i-a31-mipi-dsi")) + bus_clk_name = "bus"; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) { @@ -1107,25 +1112,35 @@ static int sun6i_dsi_probe(struct platform_device *pdev) return PTR_ERR(dsi->regulator); } - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, - &sun6i_dsi_regmap_config); - if (IS_ERR(dsi->regs)) { - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); - return PTR_ERR(dsi->regs); - } - dsi->reset = devm_reset_control_get_shared(dev, NULL); if (IS_ERR(dsi->reset)) { dev_err(dev, "Couldn't get our reset line\n"); return PTR_ERR(dsi->reset); } + dsi->regs = devm_regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); + if (IS_ERR(dsi->regs)) { + dev_err(dev, "Couldn't init regmap\n"); + return PTR_ERR(dsi->regs); + } + + dsi->bus_clk = devm_clk_get(dev, bus_clk_name); + if (IS_ERR(dsi->bus_clk)) { + dev_err(dev, "Couldn't get the DSI bus clock\n"); + return PTR_ERR(dsi->bus_clk); + } else { + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); + if (ret) + return ret; + } + if (of_device_is_compatible(dev->of_node, "allwinner,sun6i-a31-mipi-dsi")) { dsi->mod_clk = devm_clk_get(dev, "mod"); if (IS_ERR(dsi->mod_clk)) { dev_err(dev, "Couldn't get the DSI mod clock\n"); - return PTR_ERR(dsi->mod_clk); + ret = PTR_ERR(dsi->mod_clk); + goto err_attach_clk; } } @@ -1164,6 +1179,9 @@ static int sun6i_dsi_probe(struct platform_device *pdev) pm_runtime_disable(dev); err_unprotect_clk: clk_rate_exclusive_put(dsi->mod_clk); +err_attach_clk: + if (!IS_ERR(dsi->bus_clk)) + regmap_mmio_detach_clk(dsi->regs); return ret; } @@ -1177,6 +1195,9 @@ static int sun6i_dsi_remove(struct platform_device *pdev) pm_runtime_disable(dev); clk_rate_exclusive_put(dsi->mod_clk); + if (!IS_ERR(dsi->bus_clk)) + regmap_mmio_detach_clk(dsi->regs); + return 0; }