From patchwork Fri Oct 25 17:56:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 883 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A76323F0E1 for ; Fri, 25 Oct 2019 19:57:03 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id 196sf2318646pge.14 for ; Fri, 25 Oct 2019 10:57:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1572026222; cv=pass; d=google.com; s=arc-20160816; b=NUywG+kLg6/ZXTjRvFCGbjFVVnwDP5LPBedaKvEwvkFm4YjByGYYAUP5naizA96NPr uYlhP7Wx4qMDAhqUvyiCrB1XRCD02xKAWWHA6l8KvvGwzR1R+IVP+y1QuOAhW0J/Nx7p uE1wn3K40X7ezpGGoAakYG6M04X3amGyffjuB6+0zV/HrJDH+dXVeloCXgb1z8C3PJ3K 5bw46NPRyTIeOCEKFl1WaiFU7rRlr+/iZcaRD6n6sflqGBaeEG2VwGRnvAyBXAtKlw3+ xTAoVE3TgyK6FFot9WDCqa6foTP+KydfJUBRNRBgKYpJfkIdoAjh0FjzjGeh+vwMi5+0 hzGw== 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=a1S90qWy1QPWq/RUSeVXjod6PmK3fV6TEX/PWOMcJck=; b=cT8lkdBSEF/9l1Z/60Y4naEBIYdVKZOljBGJuM36OGu6BbV4OmQqpHHhZfn3OFhpy0 g66cX4ZCYoXL1BT2gBZWt68Kgv6S5D5vKmZLXNMflvCkp7RXkaKk0H2zC9c9m376VGS2 JzB9kG7sL+viX9bpnID+6WOX2PeXr09UZ+zge7tjxzCMUUDn3wtTcfIYm3Pg/H5v9fhP ioO1bJb4gJI8vKd14DfFayCFtjyExpJttBacojh4vEbxOcA5l6SNBDunP1azDaQyWa84 Mb/O8PKor5qx7YxKzNU3PXgKsqvBIZXdwh7ZHSH0FEL2InpkMqjzCmEndNWfFeqlq49z TYAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mhoVW4q3; 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=a1S90qWy1QPWq/RUSeVXjod6PmK3fV6TEX/PWOMcJck=; b=hpWI0vKewLXYNlDNizauv1pNsY8dPaK8Z1AkQ83thhC5vgn5aba8droOXv1OxegD/z Y2d1idcL5j2dUnUXeEpAMSZZoG4s0iYWH75KKVJuMRsoUJRQbjcPMQHXA8Eyjnmii5iC qRbV17AbIeHCjcYdIpYzyz3YEFCVshrdfpYzo= 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=a1S90qWy1QPWq/RUSeVXjod6PmK3fV6TEX/PWOMcJck=; b=h4OzBjIV4j1coCBFBhY3HCfcCRUgOBdoor7y7kHNuQqUxTr2ERfaFaFxh1ZrWDzIv4 WmLZd1R5/j4Iv32pKHUGsfuZ/oWEzAwCHdoDCJ17En2bgiy+QDCp+YiZugxKJpES0/YS tZMbm6/pDlx90HG+c6z7cCLzNbFlg9npSiP+/PFwEBe60GWdtuKenTzHMcD0SD5/EQVM nlAZGQgrc+KOZWhn40Ta3DGFIDuZUsISjPdeXFy9sDgakvKtAKlGAtkq4dCHNUVZzS2G WMDqEd28NjgwOfK4il/0ENc1RVHi/Vnc/Mhhmi8m1SrCCFpQEDh0syMndpj/88Kko86O 08Ew== X-Gm-Message-State: APjAAAWMCtguiJNLYXbiu4mvy98i1OJb1vhMiznUgkdPfPAsHmPzDeoO B8YOvPUgMYLp/bHObjyyFBoTbxmk X-Google-Smtp-Source: APXvYqyWpGHBCqWL2am7xpiKVVFHzmwsF2VLzR/8est7wajBvqe4igAOt2WmlksT/8B9FrcQcWRSdQ== X-Received: by 2002:a17:902:768a:: with SMTP id m10mr5221781pll.343.1572026222065; Fri, 25 Oct 2019 10:57:02 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:2c1:: with SMTP id 184ls888409pfc.7.gmail; Fri, 25 Oct 2019 10:57:01 -0700 (PDT) X-Received: by 2002:a63:cc4a:: with SMTP id q10mr5957231pgi.221.1572026221458; Fri, 25 Oct 2019 10:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572026221; cv=none; d=google.com; s=arc-20160816; b=y968zK4kVoKyowJEfGEIEUty998ZcqOLfydzUc+ADcDBc8hXszvnoUpaax4+szzOIj DAAcasIN3MWcgo8QkRpCIzMNeCYAAnuAkQswO9lXjOvz2ziHT5ZVXYYLxcfRxp1C/L3b ht50+T93+UwHCHZAr7RnZm5UG8JTCJxgFVh/D5cXYsTMqkX6YDGtlGIsIZBtxhhOSDBn lxO9BWAymqskY1alrDmCwALwj0CG2fGPGL5lnvEgVaRq4RJNwZpN/DyEZgDWYVSWn0Pa jGZUdKCCIQYZBmsYTrU3GhADzfIdxfJpQimtB9SN25Dp8UMk8fM3FTyGB0rOGsoD4drj wE6w== 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=oNviLkxeRT2QWy07lD/cdFtoGXA9IjHjIMTuJSUpyNM=; b=VL5bYIgfdNC9uRHYx/QstQT00/eu5g439TFTJz1acj/9FUI5JHjlTgoOAsKLD/yfp+ QF8Nn/qbzXOwS4LDLshmf7Lu+g9EnY+mCDqSsTeMt0arcp/tUEu+ec5NhFcm//D6X9ZO 6zie/9hRfDyDHitFQ16L6E4hKZLqA2tN4M9nnq0z8LGr5tcGI+8DnATijjZsWNCS3OiH cGwEbLTPyOu4+lCt+LK/800ZgEQ0+cAMiDPK8rO1t1O2Tn1byQ3Cf5/plCX6BOhXyJsj PtqCkG9G9f+37gImjRuwRNUoa1NJkoUqcehawzOxDIXCUX8xQQlBHduTNdBWNbvddpzf je+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mhoVW4q3; 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 s73sor3436750pjc.6.2019.10.25.10.57.01 for (Google Transport Security); Fri, 25 Oct 2019 10:57:01 -0700 (PDT) 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:b285:: with SMTP id c5mr5667166pjr.123.1572026221036; Fri, 25 Oct 2019 10:57:01 -0700 (PDT) Received: from localhost.localdomain ([115.97.180.31]) by smtp.gmail.com with ESMTPSA id n15sm2926580pfq.146.2019.10.25.10.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 10:57:00 -0700 (PDT) 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 v11 3/7] drm/sun4i: dsi: Add has_mod_clk quirk Date: Fri, 25 Oct 2019 23:26:21 +0530 Message-Id: <20191025175625.8011-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191025175625.8011-1-jagan@amarulasolutions.com> References: <20191025175625.8011-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=mhoVW4q3; 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 --- 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)