From patchwork Tue Dec 3 13:48:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 918 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A9A393F0CC for ; Tue, 3 Dec 2019 14:48:52 +0100 (CET) Received: by mail-pj1-f69.google.com with SMTP id b23sf1876167pjz.10 for ; Tue, 03 Dec 2019 05:48:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1575380931; cv=pass; d=google.com; s=arc-20160816; b=QS2GAS/7y6knU96XufLsA6JpVPF8iVxUiwssKMFJEr/33xHyW29oXpOwAS4BenGaVu VqnMg8KXbKd6yoAq8wRnDozdDU/fZL0cCg19hFisfFL2D/VCHBpWf75TXV0XnwKjL8v8 Bhbkek3AUf8VEvhbdIYuXocgHOECPiyMSQlsManJkjJkLPG/fJqXQXX+vwa5ypJIR3KV NSHwY5xt9ZsKD2OTP+aZqCY83w7lwA3N+L4N7Pp0wO6wdF5rEfb7/GvYor3nzAdMNJj/ KqadCyZFGxdZVyCtJ3pJ3aOFrBS1/zReobD+J0aDCMxebeSSAZ2WD+iHESkue4xcoBQx 2b2Q== 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=vB5qUk8gDps7jtVP9aCJ3LYb8Frh4sDSrd8Ptg1uRlQ=; b=rDB1lfjiY4xQMcJgREn9Zle1qY8wYVaUQoCiKYina/muw3qC3QT01a9wuNnA+Sfats mLayszd7mLmtJVkR2ANRSovbgifU0SNgqV23zSN7NRuiKJxAscCeWilPucMG7gf/KeNh jk2fOe3CTcgKJgmpy5vf6Pb7IMz9+j20CyEsAHaZNsbmwnvyycjEISWNrHeCNqO6fbeG rVdOLylyv66fDDypRtolqFg4zLEtlXa2uJ4mLWVW4lCqWnu01rV8CoNexxDFme6OM1pI RiT3LMgXFkOiLICrxgdpqibT4GaCuEeOXMuJhgBCqTmOTwo4aFQc5bXkEaoCRIGX6hqy ZCNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dljMBjZT; 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=vB5qUk8gDps7jtVP9aCJ3LYb8Frh4sDSrd8Ptg1uRlQ=; b=ZOHxd+HdAfVFn9FuabpZZBKlEKaxc+ao7DQEtscW9v5JCyZ7wBe48o3AxsbVuY1bpZ EQPF58J96CZvr7istzQfGMjOQ7fCcVlCioQ8+1cTgYKGPs3ob9+hSLYV9pgpq5iTVh4J LY/D6G13hFqZLqQDvqcjebjf6CvvfEtcbTLlo= 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=vB5qUk8gDps7jtVP9aCJ3LYb8Frh4sDSrd8Ptg1uRlQ=; b=YBQ6qYZQnLFiCqIG47U1u9YdOVjiSCfVIAz+vWHKJ0QQCOiHgCs1g6yH/cN+5f0zx7 X/mx3EdryMY+tB5K2uik+rHkliKwN6hwYcfM+C46p0Uby1irto6C4560LbrC96uBZdhj 04lk886TWu7Oq8FN/7ttocsMCfE06yZUeiLbwI1JPHfka7VyFCKuvTOrlfMbCNntlQNI J3I/RqNDzkA+tBsmrXKFVU5UCcanZKM0zczg5g8+BB02LPb74T7vv7A/murV7/Uc0Fve Xrc5aGc/s70NGUbVtJYeCYEvOf3OYkbma5aKpXxACEf9UvMhpFBbnLjiFCTVTqolzliT 5zWA== X-Gm-Message-State: APjAAAV+gqYpdVkK8a9EdI+elSQFXYTt79aWeLEiZ2JjLpbsJop2rt3A u+8j7p7AhzgWmcSL0AkkGg+obm2w X-Google-Smtp-Source: APXvYqzn3jfJ5G+3cVmNZpf8EFCHzR4RhvCIu5+aBplp+chK+uAIk0ThiyesodzEOFjKdFH0+UFKyg== X-Received: by 2002:a17:902:7b88:: with SMTP id w8mr5059772pll.197.1575380931395; Tue, 03 Dec 2019 05:48:51 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:cf8a:: with SMTP id i10ls809512pju.4.canary-gmail; Tue, 03 Dec 2019 05:48:51 -0800 (PST) X-Received: by 2002:a17:902:161:: with SMTP id 88mr4627892plb.253.1575380930812; Tue, 03 Dec 2019 05:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575380930; cv=none; d=google.com; s=arc-20160816; b=J03toVqowGRxnlF7w84uitn5Aklw6VNJOpYLng1N+JPgOCQJQN6C7WWzt8iSvMgPId 4Tlv1LFMCSw9oQvw2hEa1CvdkCw3+OFE8LzRMwXKDWUSHV6VzFX37uYIYjfUtcJUwK8L 1ZL7ToTsOvAUpOSyMwWpJwUZHuPjWnLNLxNZwjJL3dGqc5EjvR7NC4y4szQHEfrhicrW u5pFXdB12H1gKSY79Z9HTSaa+Igm+h2GbCF2QG/FWg/0D1UaNsYs6E/GESAPKXz7azIF daYP/8MZdqE9kq+BpKMhHlJ9844+IIZXWKwCKXCh1WZv2yc63VcwWAEZum+qP4HPORbf D2rA== 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=lDJf2uYfDmQWtbbV6ZzytU1h+3qcWlYg0vHzuCFbvic=; b=y5y4ZbSLhmTnLzrM+xwt6S6HlyZo1AN5u8oVHrsLa1ALXgSPpdPACL8c29RnBQ3pOA q8VbRVYpbNZHyU+oJvrUEL7+OzvnZ9Of9OabPTIJNlcBkpMh+Fv8y1vzvLUBeIkBdO2k vyxKnTlBK3kqtrT3DItJDIdgBuE+EKzzW7jHIEg349TJQcbMYZiQzaP2+Q3LuVlIFwmg z4/Uxmcc927mCFbKa5wfOGXqqUxh6Z2mJVRkS/57YB3hjc1qDQPNHMI2+DiIRlROuf9L iLqRHNQOSIqyRtWf4wOplZy5gkRtkE2y5XMp/16TbeH8hqnRa8DOEN0f/b29pPJNqmbW 0M4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dljMBjZT; 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 x12sor2629914pgt.80.2019.12.03.05.48.50 for (Google Transport Security); Tue, 03 Dec 2019 05:48:50 -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:a63:4466:: with SMTP id t38mr5499310pgk.316.1575380930403; Tue, 03 Dec 2019 05:48:50 -0800 (PST) Received: from localhost.localdomain ([115.97.190.29]) by smtp.gmail.com with ESMTPSA id y144sm4397892pfb.188.2019.12.03.05.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 05:48:49 -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 v12 4/7] drm/sun4i: dsi: Handle bus clock via regmap_mmio_attach_clk Date: Tue, 3 Dec 2019 19:18:13 +0530 Message-Id: <20191203134816.5319-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191203134816.5319-1-jagan@amarulasolutions.com> References: <20191203134816.5319-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=dljMBjZT; 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 v12: - get bus clock only when mod clock present - use regmap_mmio_attach_clk drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 43 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 8c4c541224dd..6085ad2eafc3 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -1082,6 +1082,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 *clk_name = NULL; struct sun6i_dsi *dsi; struct resource *res; void __iomem *base; @@ -1095,6 +1096,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev) dsi->host.ops = &sun6i_dsi_host_ops; dsi->host.dev = dev; dsi->variant = of_device_get_match_data(dev); + if (dsi->variant->has_mod_clk) + clk_name = "bus"; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(dev, res); @@ -1109,24 +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, 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 (dsi->variant->has_mod_clk) { 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; } } @@ -1167,6 +1181,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) err_unprotect_clk: if (dsi->variant->has_mod_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; } @@ -1181,6 +1203,11 @@ static int sun6i_dsi_remove(struct platform_device *pdev) if (dsi->variant->has_mod_clk) 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; }