From patchwork Mon Dec 10 16:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 74 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id D5FC92E5487 for ; Mon, 10 Dec 2018 17:17:48 +0100 (CET) Received: by mail-wr1-f69.google.com with SMTP id x3sf3585416wru.22 for ; Mon, 10 Dec 2018 08:17:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1544458668; cv=pass; d=google.com; s=arc-20160816; b=KpWc252nZCrtR/sXhZmX0zNlpg+9rI7ti1ce2Aj1desScwbIUR1/vMOfeAHEbM4oWx y9V9ZvlW15+Tv9GxxVJ6HFI3udLxRlQiik0GR1MxGaKd0Q1gsFPp98v79wGSJ0dPuM43 bD//b9qOcA45xBh7DM8Nqrj0v5EodMbBeSKx/9yMe8Jp0DSKjyHnonmvYdI9hQwL5HbB fPlMbmkEFzWEC4sa/MywWyjykXTDSY/7cWhY899Dtsy7Ylu93EfbCfh9E8Ekq/LdYRse LSxd1RiJzKhOTLJWQfLt1wfj4a7S6YvmY8KQ4qfCohxAu01AHLPef1va0A7TBGfsk9WZ kXGA== 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:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rlpTqVyJlpHFfIEuYuSfPKgTjg+EAGEL37BZe3O0asI=; b=MF4imGxZQRBIj/Tq127fGBN38EzMPeyvlDtpTdxcWLDJTq63gq1zWwaSmp0M3WOTZ8 b2i5fhoj834gSJIHaYDGzeqQb1Y5o0tyyt4jPquio3WBI5PLjc6bN3EXe7i//kbGsKc2 cgoBuGcRoKWb5csDfhi/rZiLBdjqzLkz8ZmP7Sld8ag0Wag5KCIbeJBmt2F/kiT2HiUW xSmwMZpTu+k+BSMAcxkQzCsjAeynVDUF9L5QDNX3o3Fn0UEMB+VpX12bYOJdvpn7Gy8H 75pGzU/iT36ThIZ84iYFPcBuq6Rr9dB5ZWIZH+J64hdHobdZV6R2Kk1/17GoF13C2KN6 9snw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kNb5POBI; 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:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=rlpTqVyJlpHFfIEuYuSfPKgTjg+EAGEL37BZe3O0asI=; b=HtfMUn+OMa1nNxKkhvPq34ug9Q4P16DqLiInAUTMh8WjCJsaFHxpKqqIJA/wxava0j /D49B00i8I2bZ2IPlqBnLaGjzC5+9u2BeH9Tmyzvi4ksMX/EzQOXeTxj8vkbiMYs9Mka kEYEQLdWIGjDjfZ8ojpcEtnGO1OkolLsMfGPs= 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:content-transfer-encoding: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=rlpTqVyJlpHFfIEuYuSfPKgTjg+EAGEL37BZe3O0asI=; b=XljBNzbXr3PatE7LL6J7ckbMk7gtzzb6HWKRKO0Eu8AQwN/mqdejN33OZ2YKDcK1cI 8DM+wYaKzMEavSznwzGMpObjawG4PqCye+lBqiV3B5WLM3NVrxa7h7Mn/5hicZwgCQYw z07ouWQtYIyymOdKVJEauz2Q1eoL/+ch/hcKhZPAApRTOgKKvNeVtBFXZbNLqSqzDIWt zAmzd4qUULAOhPUxdjeRp0sErxaT8SC+8pXEyjXzlJ+6t6llD86vu1ZOGnCstd56qi58 A+UXtVSdKEx8cgCW9WpqCn9rXTVj3RwTyJAV2Lm1iyDzM2Ynu/hyijsI6POIJJrppSE2 ebqw== X-Gm-Message-State: AA+aEWZ7NmwJVGvFPv2ZzjPKaUf+70qDNzU6ldrHzM5uyHuPVfkWKowt ckDDN2xAkvPNk08rrECbZNe4GFqt X-Google-Smtp-Source: AFSGD/XHbeakWfqCdhYpwnkLmOi9LIVYwpYgBBCuHZfe081AW/iTguQoUqvuVEKdNIGExTiSzwAOfg== X-Received: by 2002:a1c:b4c3:: with SMTP id d186mr1324954wmf.15.1544458668499; Mon, 10 Dec 2018 08:17:48 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:b6ac:: with SMTP id j44ls2285654wre.13.gmail; Mon, 10 Dec 2018 08:17:48 -0800 (PST) X-Received: by 2002:adf:9205:: with SMTP id 5mr10435608wrj.189.1544458668071; Mon, 10 Dec 2018 08:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544458668; cv=none; d=google.com; s=arc-20160816; b=u5niYoyxVpWQXoun076VHmt/c77Pozb0IRS42yjKa8pz/1RYFSux0RgCOMI2gkCwOt PGHUxLXV+G8p055XpxSLeHQAKRAROKOlKknODPwOjhSebFOs+uBrXLjiunmsWmLR/JJ8 9phSC3+jhHM1HL0Pxvjd/p8eOG+MbAXGh5oi58HGV2jb/D0dhrfZ6Tgb9cEhpFi/kfLn lAuSD92lpHnvJRhZ+bS4Q46xtWm/+tPrJGfyEb45SVmafjuT0khhMEZ397mcwHQWBiUb bk7gwlQq9+8h88X+stgCbR0g+BjH/c29Edu2kQu73GQc7dfFRumttZWVnc7mCoCl/anW d0UA== 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=rlpTqVyJlpHFfIEuYuSfPKgTjg+EAGEL37BZe3O0asI=; b=jGn0Nps+DD6ZJ5HVQKckuqVZneP+4k5Kq7+DU4b8WiQgw3iaBST0QYvWm6xHj/rfh4 9afDRcjP26NmSuPTrETXEH/dIxJpi1IgtwcYHZzxmYB2cts7p52gftVu/ysO7UUErx5l LTkDZYsWQ449UtNOx0fhdtNEqUck+MiMxO6DsHtc7EoqpiwQyIckdhikylXH8l+CYEOA ILFGnHVpfulv2ctY7YfbYQGFV2EvrNxuebofR6Nkw7vGU/vg5HSLENJKjCnhwM5BleRH yaRCrLPib1IvQkgzgNJkcHxe4a8RFMTPaMLd+zpwuG81J5vh8jsjfa2SpusBcxSneWpx evgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kNb5POBI; 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 b5sor4558244wmc.5.2018.12.10.08.17.48 for (Google Transport Security); Mon, 10 Dec 2018 08:17:48 -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:a1c:18c:: with SMTP id 134mr10850811wmb.88.1544458667726; Mon, 10 Dec 2018 08:17:47 -0800 (PST) Received: from localhost.localdomain (ip-162-59.sn-213-198.clouditalia.com. [213.198.162.59]) by smtp.gmail.com with ESMTPSA id b13sm8397503wrn.28.2018.12.10.08.17.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:17:47 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Michael Turquette , Stephen Boyd Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Trimarchi , linux-sunxi , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 02/17] drm/sun4i: sun6i_mipi_dsi: Add has_mod_clk quirk Date: Mon, 10 Dec 2018 21:47:14 +0530 Message-Id: <20181210161729.29720-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181210161729.29720-1-jagan@amarulasolutions.com> References: <20181210161729.29720-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=kNb5POBI; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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: , Mod clock is not mandatory for all Allwinner MIPI DSI controllers, it is connected as CLK_DSI_SCLK for A31 and not available in A64. So add has_mod_clk quirk and process the clk accordingly. Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 39 ++++++++++++++++++-------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 5 ++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index e3b34a345546..561de393ea23 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -981,6 +982,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); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) { @@ -1001,17 +1004,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); dphy_node = of_parse_phandle(dev->of_node, "phys", 0); ret = sun6i_dphy_probe(dsi, dphy_node); @@ -1043,7 +1049,8 @@ static int sun6i_dsi_probe(struct platform_device *pdev) pm_runtime_disable(dev); sun6i_dphy_remove(dsi); 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; } @@ -1056,7 +1063,8 @@ static int sun6i_dsi_remove(struct platform_device *pdev) mipi_dsi_host_unregister(&dsi->host); pm_runtime_disable(dev); sun6i_dphy_remove(dsi); - clk_rate_exclusive_put(dsi->mod_clk); + if (dsi->variant->has_mod_clk) + clk_rate_exclusive_put(dsi->mod_clk); return 0; } @@ -1066,7 +1074,8 @@ static int __maybe_unused sun6i_dsi_runtime_resume(struct device *dev) struct sun6i_dsi *dsi = dev_get_drvdata(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. @@ -1094,7 +1103,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); return 0; @@ -1106,9 +1116,16 @@ static const struct dev_pm_ops sun6i_dsi_pm_ops = { NULL) }; +static const struct sun6i_dsi_variant sun6i_a31_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_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 dbbc5b3ecbda..597b62227019 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -20,6 +20,10 @@ struct sun6i_dphy { struct reset_control *reset; }; +struct sun6i_dsi_variant { + bool has_mod_clk; +}; + struct sun6i_dsi { struct drm_connector connector; struct drm_encoder encoder; @@ -35,6 +39,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)