From patchwork Tue Dec 3 13:48:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 917 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4E4D33F0CC for ; Tue, 3 Dec 2019 14:48:48 +0100 (CET) Received: by mail-pj1-f72.google.com with SMTP id n89sf1885245pji.6 for ; Tue, 03 Dec 2019 05:48:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1575380926; cv=pass; d=google.com; s=arc-20160816; b=HEpNnEh0wohB2YSegf76Z33nolHcec+swGOHn7357ZkKLGchKvmBal3T+bihs9vL1/ cYo9uB7xMoqQO15GeoEcgdFaCH+56/MuB2e/7L23tneEKCh64JgH31BXhm83VLsKhK0A opN89fPed+CYD8f9pv//4MwM07LnlWddQAe5zpYAnuTc1KuhWhc/upZWReuT6pQEuTvB h4r7uTkM4lLnm0pIyI01AT6WvyGwCNDROhbP0JOngStskuecDdemLMdZ2BTq3gyqnWbt nVz58If2RFmi+5kk4m8SdOZZzb4ZB1bxmTJKyAh2NjRMY9eMfikfgnNd0Kp2O+Y93Btd zzyQ== 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=NTy+i3ibPZypYhbZBvwKw39he2XYvndEfxe143zm40g=; b=yLYJ220kArascRR+xREIWiPWrMf0q9lbLYtW3lxV8fu2N5Eek5u7/fjHky2B/XsGNl aMCon6dwJFViX8YUge4I0nWm1Q67wnxvDA/CQ5tWfrHb+SOqRmzN7pimXgYev0Vw2K+X 2PiraV85MbuGCyWehQsqWpT+XpwkLQsoqUKs0SxepSVmame2bA/VKbjmmDot6PsSRWnk Mj2DJdVtFy80MmaIl6ugHbHkAJWI2rviC4xSdbcj6/3U7oX9GI+8Hssdf+0YFlq2I1wE 2jXdWkGxQAI8EFXvnAwDkQ3p6IqlIQs0VWSCcjTpus8ISLtKIjT3iWDNNpJuYeQ0Wmnq 4ZOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bzQVtQsv; 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=NTy+i3ibPZypYhbZBvwKw39he2XYvndEfxe143zm40g=; b=kb/gmAl5b+U/ma4IEznTeBAMYB4WxtxzR6UIlok/UG9kHmzuQWUHTvUzw0yZFSjCn8 bTCQ2hnv33ztSYZbSv2He2x2kGxk8E8tSc0PZO/U7/PyLdvJ9zOK+R/33SyPcMq/ct8H g64cD3Xzjw8Krdcu49WZXvsngUFA1jTVkfABQ= 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=NTy+i3ibPZypYhbZBvwKw39he2XYvndEfxe143zm40g=; b=S+/RDSqPiJTypmr3zfCVjsb2QHbNCNDHUH9//M10jx6Iq0Z84hoijDgcQ0OIv5zvjN i47i/gikmh8CYW2pib242IhRmY7xyNMo9uoq0I6cjCuS4x4Cyyex3Xz9uRX0FarzsDGF uihb8/f0EgqJFQgQ4B7fJflqplJc0S5gB/mNJ4+FujC6LNjnV3qekbsZTpDDaaDZ0Lr0 WiLlX98c0HWBHK5uClsJeCpihlC7v7YKwBhjOVgQVCjfs2D6hI6VhvRQG9GPszoezb30 3Rqv+LjIAqBk422neCYqMoG+i6LZaGsZ7CmEMI8qxJT4O1eaLchLaKL+qxoqVltRnQ8C q5Jw== X-Gm-Message-State: APjAAAXGCZIVu315nxeQ5ui0S02RGkXdJx1KceZBI2UvZQ0TERC5Njvj CF3YZMxrJc9fdyZD817MEaMdyY1h X-Google-Smtp-Source: APXvYqwkv1pucDx7jSt9TDANEK0qa1BcWzWeuy0TX+62BHeBEKoSbxF2WFLchgD8s0k+tm0jtsekuQ== X-Received: by 2002:a17:90a:fa92:: with SMTP id cu18mr5665564pjb.114.1575380926521; Tue, 03 Dec 2019 05:48:46 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:ac0a:: with SMTP id v10ls831351pfe.4.gmail; Tue, 03 Dec 2019 05:48:46 -0800 (PST) X-Received: by 2002:a63:4d12:: with SMTP id a18mr5320916pgb.451.1575380925928; Tue, 03 Dec 2019 05:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575380925; cv=none; d=google.com; s=arc-20160816; b=X2qGmXnFTmuY+mhLpoEvUM+dJZjtu3stf5lQSnWMv8pI9tetUKaU+jxA0e4xL35RuH WLBS+Rajci+H3ppx+anLDwYw0xl3XGOGNCAX2kW9c+Q/2dixlSuM6jx5OYDLd2eqcAMM z+no0N+PLMbNHvQm0RvUCtdxLRAYZCwk7qZbUDvJHDSleKRI1a5KFoZJCET878O+pW9g N5Oks/ClbVEc58BNm5smJvc5TpE2/ccGSaFA5kGzQwKiJtfVugeMTs/J75sB4cp8sCS7 j5yfLXgtbTSZCZhtHYBG5Ns2TDuOPV8UiugHW0TAM/owfmMS4kEbmxRfg0Zyr03CoE5V JPaw== 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=cZ4/teiuFdafb5RuME47dUY85SO685foNncJ+cZhSOo=; b=BRxVSk+T95YKR8cQzQgFDZ1FpDA8vRT8/NY42gQ4IKwzOIrzdt1m61AxF6qPUB2J4V tQdvem68C7WKnVgIjO+WiJCcKVhN8zFRRZRwBJXFm9f4raPZ7U03VVkjaZzzkgpdiOIl Kd3E1V08Jl3ooeafiy4h2Ojpv1ppN3fx3z+lkL1IoGPr2/nDg+yUtr7jyuI4KWFnsi6B +3glfqSYeB3uqFLDjGtVVPY85+/2ixlhBsiduBT8Gdk49rhOV6vGW/owGhK6v9MYrIUn wQ25UQeNruCZrpySHhlKnB/b1zQQmuTwktAG+ae5oNwxVmYMY3oLn21OHhgt6uamOTHL dFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bzQVtQsv; 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 k11sor2672679pgr.29.2019.12.03.05.48.45 for (Google Transport Security); Tue, 03 Dec 2019 05:48: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:a63:c652:: with SMTP id x18mr5478439pgg.211.1575380925537; Tue, 03 Dec 2019 05:48:45 -0800 (PST) Received: from localhost.localdomain ([115.97.190.29]) by smtp.gmail.com with ESMTPSA id y144sm4397892pfb.188.2019.12.03.05.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 05:48:45 -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 3/7] drm/sun4i: dsi: Add has_mod_clk quirk Date: Tue, 3 Dec 2019 19:18:12 +0530 Message-Id: <20191203134816.5319-4-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=bzQVtQsv; 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: , As per the user manual, look like mod clock is not mandatory for all Allwinner MIPI DSI controllers, it is connected to CLK_DSI_SCLK for A31 and not available in A64. So add has_mod_clk quirk and process the mod clk accordingly. Tested-by: Merlijn Wajer Signed-off-by: Jagan Teki --- Changes for v12: - none drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 38 ++++++++++++++++++-------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 5 ++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index c958ca9bae63..8c4c541224dd 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1093,6 +1094,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev) dsi->dev = dev; dsi->host.ops = &sun6i_dsi_host_ops; dsi->host.dev = dev; + dsi->variant = of_device_get_match_data(dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(dev, res); @@ -1120,17 +1122,20 @@ static int sun6i_dsi_probe(struct platform_device *pdev) return PTR_ERR(dsi->reset); } - 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); + 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); + } } /* * In order to operate properly, that clock seems to be always * set to 297MHz. */ - clk_set_rate_exclusive(dsi->mod_clk, 297000000); + if (dsi->variant->has_mod_clk) + clk_set_rate_exclusive(dsi->mod_clk, 297000000); dsi->dphy = devm_phy_get(dev, "dphy"); if (IS_ERR(dsi->dphy)) { @@ -1160,7 +1165,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(dev); err_unprotect_clk: - clk_rate_exclusive_put(dsi->mod_clk); + if (dsi->variant->has_mod_clk) + clk_rate_exclusive_put(dsi->mod_clk); return ret; } @@ -1172,7 +1178,8 @@ static int sun6i_dsi_remove(struct platform_device *pdev) component_del(&pdev->dev, &sun6i_dsi_ops); mipi_dsi_host_unregister(&dsi->host); pm_runtime_disable(dev); - clk_rate_exclusive_put(dsi->mod_clk); + if (dsi->variant->has_mod_clk) + clk_rate_exclusive_put(dsi->mod_clk); return 0; } @@ -1189,7 +1196,8 @@ static int __maybe_unused sun6i_dsi_runtime_resume(struct device *dev) } reset_control_deassert(dsi->reset); - clk_prepare_enable(dsi->mod_clk); + if (dsi->variant->has_mod_clk) + clk_prepare_enable(dsi->mod_clk); /* * Enable the DSI block. @@ -1217,7 +1225,8 @@ static int __maybe_unused sun6i_dsi_runtime_suspend(struct device *dev) { struct sun6i_dsi *dsi = dev_get_drvdata(dev); - clk_disable_unprepare(dsi->mod_clk); + if (dsi->variant->has_mod_clk) + clk_disable_unprepare(dsi->mod_clk); reset_control_assert(dsi->reset); regulator_disable(dsi->regulator); @@ -1230,9 +1239,16 @@ static const struct dev_pm_ops sun6i_dsi_pm_ops = { NULL) }; +static const struct sun6i_dsi_variant sun6i_a31_mipi_dsi = { + .has_mod_clk = true, +}; + static const struct of_device_id sun6i_dsi_of_table[] = { - { .compatible = "allwinner,sun6i-a31-mipi-dsi" }, - { } + { + .compatible = "allwinner,sun6i-a31-mipi-dsi", + .data = &sun6i_a31_mipi_dsi, + }, + { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun6i_dsi_of_table); diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index 3f4846f581ef..d791c9f6fccf 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -15,6 +15,10 @@ #define SUN6I_DSI_TCON_DIV 4 +struct sun6i_dsi_variant { + bool has_mod_clk; +}; + struct sun6i_dsi { struct drm_connector connector; struct drm_encoder encoder; @@ -31,6 +35,7 @@ struct sun6i_dsi { struct sun4i_drv *drv; struct mipi_dsi_device *device; struct drm_panel *panel; + const struct sun6i_dsi_variant *variant; }; static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)