From patchwork Wed Dec 18 19:10:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 934 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6EB363F08E for ; Wed, 18 Dec 2019 20:10:47 +0100 (CET) Received: by mail-pl1-f200.google.com with SMTP id p16sf1657674plq.10 for ; Wed, 18 Dec 2019 11:10:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1576696246; cv=pass; d=google.com; s=arc-20160816; b=eU0qvFn8k8H1FSvvWLc4PdivWsasyIqMEB6spAKH46bO+tbP/kY8YgbU5jtYtwU292 sb5bm4LBnr7o7D65rzro5n4dNJzIKfWvxlNHxJ7uRdA3b64R7zLHcc1ew0qFK0dT6Kb3 FGrEcuXXVwMIXv3It9EpEXZB8EN9Ec6vCSv1+v8sV4LtSqWcy6sTJ6+FSFJXXPjMH4i9 xhrHde8/IN5k8QoJ4AjSHFKxIVKlwqL5x05jR4x9m4NI1TVzJKgLBj/DQIc038GrYaRq R8yUughNXt3dhw0rAcjVRhB+uzHNaCFU7gs1Ejq3srUiZCoqLl8Fj0JNqXJSwjAO7/v3 L4WQ== 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=Gyaf5VzGK89On9kJHXvI2AQkAmjJgZxC9JvrT2LEU08=; b=RKD6XwyJSfMs55BDZjpgFP5wi54AXHdkUqQHyuWVvQ3hi66cQ8XsGG5oX70FnoQOUD JKncHiKPSfgFRmn0g25B5HHFoR2O5dydtk8uZgqUvONEDewEpSWZ0DmCFL+6i6gEu7oR mAlVsuu4aXFIPpK1j3u/MLcSmfH1E2HHAV5SxN10rCqwE5Qs//zVUZcYw6PHtr9K8P0y 7jzMm34E77Itdk+jKPvtZkflFSdg7+f5QdALgcihyrlLoPMP1tICSAgXUWfNTs4BWuF4 iMG+AHfUEeGw0/q7XjE1X5O4MoeBrvcUWkTVsO3aQyXgpG1TCjXfMNUubB7mz/D5H6+X 1pOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YxQafe8j; 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=Gyaf5VzGK89On9kJHXvI2AQkAmjJgZxC9JvrT2LEU08=; b=AyCYUCnoj4RMvXne5fmidM8GLHuE+ZR5SLxuPBkr3vR9oMYuOoX+NaC+cg6QBCQkMn CoPITcdB4KoAUt7LlI2GTSh1v1L9+EwWhwH1vJMbwCBTrA+6NpQegtehGORydpfj/PZf g7EXwAM9+xrJpSgw9u1X9vLZQMglLqwXAxnT0= 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=Gyaf5VzGK89On9kJHXvI2AQkAmjJgZxC9JvrT2LEU08=; b=KL7+9nzSc975XoYq6ByyCeevIzliYdhJK4ZWLRs9NO17G9hoIYfG3PXQLyJ4y4vBuj AxRqQYMfVZ1xVpzV83B5a3YBhRP02qZGet4qBG+B7ZHdu87wc1yg5+hHxgYE5w5svXRV q4lMfHe8iP1zQvxYy1+NwaLJH9oEJcs9pwx6GMxzvQVGC8qMSKHqh5uqkBCz7YFYpWE5 Kpxz1BpLsQJ4vME/tBUp9Nu1VY7bZRy62q4d5sFcbHcsD1R1GUtz780KLeGoRrP82+Sz 3GmAwmA3cMgLfluS0LNAvm0eTbI2+YKvGU4Uk9+67Eub30cmV5LXOtXaRwLT+qOJgAtl ZC/A== X-Gm-Message-State: APjAAAWE6f/XUV+gcBW6bYHTOLJ1IQTSD0OLIHtoQ3fKWAvzrEwNDQX2 LSmxf0Blb85OeE2aMoLK6cuvS1Qm X-Google-Smtp-Source: APXvYqzrxdU/LDZ1CqAzW198RJR+i5TLX9nQRffxlXSQyTMfiRsCfoDtM3d/qQspNzMsmIuBvCvoUA== X-Received: by 2002:a17:90a:d985:: with SMTP id d5mr4819299pjv.73.1576696246212; Wed, 18 Dec 2019 11:10:46 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:f8d:: with SMTP id 13ls757350pjz.0.gmail; Wed, 18 Dec 2019 11:10:45 -0800 (PST) X-Received: by 2002:a17:90a:a60c:: with SMTP id c12mr4728905pjq.61.1576696245633; Wed, 18 Dec 2019 11:10:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576696245; cv=none; d=google.com; s=arc-20160816; b=cEsUXTb3o2Bu8VfxvnAd1viFERFy9s5cw5V4Ls0Tf0OvBGIayzVI7cR/ZqC3192zau rNUQbhsOa5X37H/lBP8LNZ5n9S4eyAyzSGZZaIapqNZ+EjfpJ4HUmUX/XvJ1/Aw5AszT 5iPAQQstagdQ3ZSl1J1DZeQKj9wSfZI0ffBkCrJ5Zqr56KIcRrNZEEfDmDWYcdXE8Yag JNWUplq/1wLsuOiCyAu2O7Gcf8ZDA53CM9Yke8rjbqALHeNmI6lhdvprGOOhupKRWMR7 kjug4n4tSIZFjIMC5kUbOPkuUCpd+Gad5rQfjIazHiGXQtb9y+7eUxbMrwaso9ugAi7z emrg== 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=qISq29HsJqizQ/dr9IDqB+kkI7D+OvUtJAFPrAy/nl4=; b=ZoQfVJXfPtDCYSg0AIvspdisEvQ0bOVZd15uhnhsxARelxNGJ6L+m3jm2d25B7wkJ+ LXzR3plUo1sBTt7MhuLmyqI57nV82rzt8NT8Tmy2jadDWhDcGDk7NkcEZn4Xf9tFOoGC Jbn8B39IkOx0esfEiMcMTWy4wxW/FLkmA33KLpO3x/rPXfEvQAjQ4knWYuH7msuYiMDO sKlLvvi1K0I/L3XLDMFZ9s3c72k+VkiavjxI6cfeCpoysFEtrBOxI6wPliJbENbKDny0 v2NREVHsDoUgBIM186FB7mxUFtcDLiT5KbCbxiOSMLg8tu2sFOD80qUYktyH/GUfnu8P 4u+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YxQafe8j; 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 n16sor3181957pjc.27.2019.12.18.11.10.45 for (Google Transport Security); Wed, 18 Dec 2019 11:10: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:3747:: with SMTP id u65mr2730117pjb.25.1576696245276; Wed, 18 Dec 2019 11:10:45 -0800 (PST) Received: from localhost.localdomain ([2405:201:c809:c7d5:78ea:e014:edb4:e862]) by smtp.gmail.com with ESMTPSA id q7sm3745855pjd.3.2019.12.18.11.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 11:10: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 v13 4/7] drm/sun4i: dsi: Handle bus clock via regmap_mmio_attach_clk Date: Thu, 19 Dec 2019 00:40:14 +0530 Message-Id: <20191218191017.2895-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191218191017.2895-1-jagan@amarulasolutions.com> References: <20191218191017.2895-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=YxQafe8j; 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 v13: - update the changes since has_mod_clk is dropped in previous patch drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 45 +++++++++++++++++++++----- 1 file changed, 37 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..de8955fbeb00 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,36 @@ 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"); + ret = PTR_ERR(dsi->bus_clk); + goto err_regmap; + } else { + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); + if (ret) + goto err_bus_clk; + } + 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 +1180,14 @@ 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); +err_bus_clk: + if (!IS_ERR(dsi->bus_clk)) + clk_put(dsi->bus_clk); +err_regmap: + regmap_exit(dsi->regs); return ret; } @@ -1177,6 +1201,11 @@ 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); + + regmap_exit(dsi->regs); + return 0; }