From: Yakir Yang <ykk@rock-chips.com>
To: Kishon Vijay Abraham I <kishon@ti.com>,
Heiko Stuebner <heiko@sntech.de>,
Thierry Reding <treding@nvidia.com>,
Jingoo Han <jingoohan1@gmail.com>,
Fabio Estevam <fabio.estevam@freescale.com>,
Inki Dae <inki.dae@samsung.com>,
joe@perches.com, Russell King <rmk+kernel@arm.linux.org.uk>
Cc: seanpaul@google.com, dri-devel@lists.freedesktop.org,
Andrzej Hajda <a.hajda@samsung.com>,
Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
linux-samsung-soc@vger.kernel.org,
Vincent Palatin <vpalatin@chromium.org>,
linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
dianders@google.com, Rob Herring <robh+dt@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Kyungmin Park <kyungmin.park@samsung.com>,
djkurtz@google.com, Kumar Gala <galak@codeaurora.org>,
ajaynumb@gmail.com, Andy Yan <andy.yan@rock-chips.com>
Subject: Re: [PATCH v3 08/14] phy: Add driver for rockchip Display Port PHY
Date: Thu, 20 Aug 2015 01:56:25 -0500 [thread overview]
Message-ID: <55D57A19.7020205@rock-chips.com> (raw)
In-Reply-To: <55D55A3E.8090905@ti.com>
[-- Attachment #1.1: Type: text/plain, Size: 10634 bytes --]
Hi Kishon,
On 08/19/2015 11:40 PM, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Wednesday 19 August 2015 08:21 PM, Yakir Yang wrote:
>> Signed-off-by: Yakir Yang <ykk@rock-chips.com>
> where's the commit message?
Actually I have no detail words for this, so leave this empty :-)
If you think I should add some words here, I may want to declare
the relationship of this driver and remote analogix dp driver.
>> ---
>> Changes in v3:
>> - Take Heiko suggest, add rockchip dp phy driver,
>> collect the phy clocks and power control.
>>
>> Changes in v2: None
>>
>> .../devicetree/bindings/phy/rockchip-dp-phy.txt | 26 +++
>> drivers/phy/Kconfig | 7 +
>> drivers/phy/Makefile | 1 +
>> drivers/phy/phy-rockchip-dp.c | 185 +++++++++++++++++++++
>> 4 files changed, 219 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/phy/rockchip-dp-phy.txt
>> create mode 100644 drivers/phy/phy-rockchip-dp.c
>>
>> diff --git a/Documentation/devicetree/bindings/phy/rockchip-dp-phy.txt b/Documentation/devicetree/bindings/phy/rockchip-dp-phy.txt
>> new file mode 100644
>> index 0000000..5de1088
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/rockchip-dp-phy.txt
>> @@ -0,0 +1,26 @@
>> +Rockchip Soc Seroes Display Port PHY
>> +------------------------------------
>> +
>> +Required properties:
>> +- compatible : should be one of the following supported values:
>> + - "rockchip.rk3288-dp-phy"
>> +
>> +- reg : a list of registers used by phy driver
>> +- clocks: from common clock binding: handle to dp clock.
>> + of memory mapped region.
>> +- clock-names: from common clock binding:
>> + Required elements: "sclk_dp" "sclk_dp_24m"
>> +
>> +- rockchip,grf: this soc should set GRF regs, so need get grf here.
>> +- #phy-cells : from the generic PHY bindings, must be 0;
>> +
>> +Example:
>> +
>> +edp_phy: phy@ff770274 {
>> + compatilble = "rockchip,rk3288-dp-phy";
>> + reg = <0xff770274 4>;
>> + rockchip,grf = <&grf>;
>> + clocks = <&cru SCLK_EDP_24M>;
>> + clock-names = "24m";
>> + #phy-cells = <0>;
>> +}
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index 6b8dd16..da00440 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -297,6 +297,13 @@ config PHY_ROCKCHIP_USB
>> help
>> Enable this to support the Rockchip USB 2.0 PHY.
>>
>> +config PHY_ROCKCHIP_DP
>> + tristate "Rockchip Display Port PHY Driver"
>> + depends on ARCH_ROCKCHIP && OF
>> + select GENERIC_PHY
>> + help
>> + Enable this to support the Rockchip Display Port PHY.
>> +
>> config PHY_ST_SPEAR1310_MIPHY
>> tristate "ST SPEAR1310-MIPHY driver"
>> select GENERIC_PHY
>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
>> index f344e1b..35e3ce6 100644
>> --- a/drivers/phy/Makefile
>> +++ b/drivers/phy/Makefile
>> @@ -33,6 +33,7 @@ phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
>> obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o
>> obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o
>> obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
>> +obj-$(CONFIG_PHY_ROCKCHIP_DP) += phy-rockchip-dp.o
>> obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o
>> obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
>> obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
>> diff --git a/drivers/phy/phy-rockchip-dp.c b/drivers/phy/phy-rockchip-dp.c
>> new file mode 100644
>> index 0000000..4759111
>> --- /dev/null
>> +++ b/drivers/phy/phy-rockchip-dp.c
>> @@ -0,0 +1,185 @@
>> +/*
>> + * Rockchip DP PHY driver
>> + *
>> + * Copyright (C) 2015 FuZhou Rockchip Co., Ltd.
>> + * Author: Yakir Yang <ykk@@rock-chips.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License.
>> + */
>> +
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/clk.h>
>> +#include <linux/phy/phy.h>
>> +#include <linux/regmap.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/platform_device.h>
>> +
>> +#define GRF_SOC_CON12 0x0274
>> +#define GRF_EDP_REF_CLK_SEL_INTER BIT(4)
>> +
>> +#define DP_PHY_SIDDQ_WRITE_EN BIT(21)
>> +#define DP_PHY_SIDDQ_ON 0
>> +#define DP_PHY_SIDDQ_OFF BIT(5)
>> +
>> +struct rockchip_dp_phy {
>> + struct device *dev;
>> + struct regmap *grf;
>> + void __iomem *regs;
>> + struct clk *phy_24m;
>> +};
>> +
>> +static int rockchip_dp_phy_clk_enable(struct rockchip_dp_phy *dp)
>> +{
>> + int ret = 0;
>> +
>> + ret = clk_set_rate(dp->phy_24m, 24000000);
>> + if (ret < 0) {
>> + dev_err(dp->dev, "cannot set clock phy_24m %d\n", ret);
>> + return ret;
>> + }
>> +
>> + ret = clk_prepare_enable(dp->phy_24m);
>> + if (ret < 0) {
>> + dev_err(dp->dev, "cannot enable clock phy_24m %d\n", ret);
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int rockchip_dp_phy_clk_disable(struct rockchip_dp_phy *dp)
>> +{
>> + clk_disable_unprepare(dp->phy_24m);
>> +
>> + return 0;
>> +}
>> +
>> +static int rockchip_set_phy_state(struct phy *phy, bool enable)
>> +{
>> + struct rockchip_dp_phy *dp = phy_get_drvdata(phy);
>> +
>> + if (enable) {
>> + rockchip_dp_phy_clk_enable(dp);
>> + writel(DP_PHY_SIDDQ_WRITE_EN | DP_PHY_SIDDQ_ON, dp->regs);
>> + } else {
>> + rockchip_dp_phy_clk_disable(dp);
>> + writel(DP_PHY_SIDDQ_WRITE_EN | DP_PHY_SIDDQ_OFF, dp->regs);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int rockchip_dp_phy_power_on(struct phy *phy)
>> +{
>> + return rockchip_set_phy_state(phy, true);
>> +}
>> +
>> +static int rockchip_dp_phy_power_off(struct phy *phy)
>> +{
>> + return rockchip_set_phy_state(phy, false);
>> +}
>> +
>> +static struct phy_ops rockchip_dp_phy_ops = {
>> + .power_on = rockchip_dp_phy_power_on,
>> + .power_off = rockchip_dp_phy_power_off,
>> + .owner = THIS_MODULE,
>> +};
>> +
>> +static int rockchip_dp_phy_init(struct rockchip_dp_phy *dp)
>> +{
>> + struct device *dev = dp->dev;
>> + struct device_node *np = dev->of_node;
>> + int ret;
>> +
>> + dp->phy_24m = devm_clk_get(dev, "24m");
>> + if (IS_ERR(dp->phy_24m)) {
>> + dev_err(dev, "cannot get clock 24m\n");
>> + return PTR_ERR(dp->phy_24m);
>> + }
>> +
>> + ret = rockchip_dp_phy_clk_enable(dp);
>> + if (ret < 0) {
>> + dev_err(dp->dev, "cannot enable dp phy clk %d\n", ret);
>> + return ret;
>> + }
>> +
>> + dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
>> + if (IS_ERR(dp->grf)) {
>> + dev_err(dev, "rk3288-dp needs rockchip,grf property\n");
>> + return PTR_ERR(dp->grf);
>> + }
>> +
>> + ret = regmap_write(dp->grf, GRF_SOC_CON12,
>> + GRF_EDP_REF_CLK_SEL_INTER |
>> + (GRF_EDP_REF_CLK_SEL_INTER << 16));
>> + if (ret != 0) {
>> + dev_err(dp->dev, "Could not config GRF edp ref clk: %d\n", ret);
>> + return ret;
>> + }
> This function can be split to do only clk_get and syscon_regmap_lookup in
> probe, clk_enable and regmap_write in phy_init?
Yeah, I agree with you to move DT property code to probe
function, and I do find a bug that clk_enable should be remove
from probe/phy_init function.
If clock have been enabled in probe function, then the reference
count of this clock would never reach zero, cause phy_power_on
always corresponding to phy_power_off.
So phy_init function would only have one expression regmap_write,
it's redundant, let's just delete phy_init function, move all code to probe.
Thanks,
- Yakir
------------------------------------------------------------------------------------------------
static int rockchip_dp_phy_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
struct phy_provider *phy_provider;
struct rockchip_dp_phy *dp;
struct resource *res;
@@ -146,15 +112,31 @@ static int rockchip_dp_phy_probe(struct
platform_device *pdev)
if (IS_ERR(dp->regs))
return PTR_ERR(dp->regs);
- ret = rockchip_dp_phy_init(dp);
- if (ret)
+ dp->phy_24m = devm_clk_get(dev, "24m");
+ if (IS_ERR(dp->phy_24m)) {
+ dev_err(dev, "cannot get clock 24m\n");
+ return PTR_ERR(dp->phy_24m);
+ }
+
+ dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
+ if (IS_ERR(dp->grf)) {
+ dev_err(dev, "rk3288-dp needs rockchip,grf property\n");
+ return PTR_ERR(dp->grf);
+ }
+
+ ret = regmap_write(dp->grf, GRF_SOC_CON12,
GRF_EDP_REF_CLK_SEL_INTER |
+ (GRF_EDP_REF_CLK_SEL_INTER << 16));
+ if (ret) {
+ dev_err(dp->dev, "Could not config GRF edp ref clk:
%d\n", ret);
return ret;
+ }
phy = devm_phy_create(dev, NULL, &rockchip_dp_phy_ops, NULL);
if (IS_ERR(phy)) {
dev_err(dev, "failed to create phy\n");
return PTR_ERR(phy);
}
>> +
>> + return 0;
>> +}
>> +
>> +static int rockchip_dp_phy_probe(struct platform_device *pdev)
>> +{
>> + struct device *dev = &pdev->dev;
>> + struct phy_provider *phy_provider;
>> + struct rockchip_dp_phy *dp;
>> + struct resource *res;
>> + struct phy *phy;
>> + int ret;
>> +
>> + dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
>> + if (IS_ERR(dp))
>> + return -ENOMEM;
>> +
>> + dp->dev = dev;
>> +
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + dp->regs = devm_ioremap_resource(dev, res);
>> + if (IS_ERR(dp->regs))
>> + return PTR_ERR(dp->regs);
>> +
>> + ret = rockchip_dp_phy_init(dp);
>> + if (ret)
>> + return ret;
>> +
>> + phy = devm_phy_create(dev, NULL, &rockchip_dp_phy_ops, NULL);
>> + if (IS_ERR(phy)) {
>> + dev_err(dev, "failed to create phy\n");
>> + return PTR_ERR(phy);
>> + }
>> + phy_set_drvdata(phy, dp);
>> +
>> + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
>> +
>> + return PTR_ERR_OR_ZERO(phy_provider);
>> +}
>> +
>> +static const struct of_device_id rockchip_dp_phy_dt_ids[] = {
>> + { .compatible = "rockchip,rk3288-dp-phy" },
>> + {}
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, rockchip_dp_phy_dt_ids);
>> +
>> +static struct platform_driver rockchip_dp_phy_driver = {
>> + .probe = rockchip_dp_phy_probe,
>> + .driver = {
>> + .name = "rockchip-dp-phy",
>> + .owner = THIS_MODULE,
> owner is not required here.
>
> Thanks
> Kishon
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 12080 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-08-20 6:56 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-19 14:48 [PATCH v3 0/14] Add Analogix Core Display Port Driver Yakir Yang
2015-08-19 14:49 ` [PATCH v3 01/14] drm: exynos/dp: fix code style Yakir Yang
2015-08-19 14:49 ` [PATCH v3 02/14] drm: exynos/dp: convert to drm bridge mode Yakir Yang
[not found] ` <1439995728-18046-1-git-send-email-ykk-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-08-19 14:50 ` [PATCH v3 03/14] drm: bridge: analogix_dp: split exynos dp driver to bridge dir Yakir Yang
2015-08-19 14:50 ` [PATCH v3 07/14] drm: rockchip/dp: add rockchip platform dp driver Yakir Yang
2015-08-19 14:51 ` [PATCH v3 09/14] drm: bridge/analogix_dp: add platform device type support Yakir Yang
2015-08-19 14:52 ` [PATCH v3 12/14] drm: bridge/analogix_dp: expand the delay time for hpd detect Yakir Yang
2015-08-20 6:11 ` Jingoo Han
2015-08-20 8:02 ` Yakir Yang
2015-08-21 8:20 ` [PATCH v3 0/14] Add Analogix Core Display Port Driver Jingoo Han
2015-08-21 10:01 ` Yakir Yang
2015-08-21 11:24 ` Jingoo Han
2015-08-21 13:16 ` Thierry Reding
2015-08-22 10:13 ` Yakir Yang
2015-08-30 12:16 ` Romain Perier
2015-08-31 2:40 ` Yakir Yang
2015-08-22 9:42 ` Yakir Yang
2015-08-19 14:50 ` [PATCH v3 04/14] drm: bridge/analogix_dp: dynamic parse sync_pol & interlace & colorimetry Yakir Yang
2015-08-19 14:50 ` [PATCH v3 05/14] drm: bridge/analogix_dp: fix link_rate & lane_count bug Yakir Yang
2015-08-20 7:22 ` Jingoo Han
2015-08-20 8:04 ` Yakir Yang
2015-08-19 14:50 ` [PATCH v3 06/14] Documentation: drm/bridge: add document for analogix_dp Yakir Yang
2015-08-23 23:23 ` Rob Herring
2015-08-24 0:43 ` Krzysztof Kozlowski
2015-08-24 2:42 ` Yakir Yang
[not found] ` <55DA8486.1000803-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-08-24 4:20 ` Krzysztof Kozlowski
2015-08-24 12:48 ` Yakir Yang
2015-08-24 13:03 ` Heiko Stuebner
2015-08-25 1:37 ` Yakir Yang
2015-08-24 23:49 ` Krzysztof Kozlowski
[not found] ` <55DBAD90.3040901-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-08-25 1:32 ` Yakir Yang
2015-08-25 1:33 ` Yakir Yang
2015-08-25 1:35 ` Krzysztof Kozlowski
2015-08-24 7:40 ` Jingoo Han
2015-08-24 12:55 ` Yakir Yang
2015-08-24 2:19 ` Yakir Yang
[not found] ` <CAL_JsqLz+8RtBucctUj4euXZ3Ac0DvB52N9ONpAerh5T9BiTJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-24 12:57 ` Russell King - ARM Linux
2015-08-24 14:48 ` Rob Herring
2015-08-24 16:16 ` Heiko Stuebner
2015-08-25 1:21 ` Yakir Yang
2015-08-25 9:12 ` Thierry Reding
[not found] ` <20150825091246.GA14034-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-08-25 9:29 ` Russell King - ARM Linux
2015-08-25 10:40 ` Thierry Reding
[not found] ` <20150825104000.GE14034-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-08-25 10:52 ` Russell King - ARM Linux
2015-08-25 9:41 ` Yakir Yang
2015-08-25 10:06 ` Thierry Reding
2015-08-25 14:02 ` Yakir Yang
2015-08-25 9:15 ` Thierry Reding
2015-08-25 9:37 ` Yakir Yang
2015-08-25 13:27 ` Rob Herring
2015-08-25 13:48 ` Yakir Yang
2015-08-25 14:16 ` Thierry Reding
2015-08-25 14:23 ` Yakir Yang
2015-08-25 9:58 ` Thierry Reding
[not found] ` <20150825095817.GC14034-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-08-25 14:03 ` Yakir Yang
2015-08-25 14:21 ` Thierry Reding
2015-08-25 15:57 ` Russell King - ARM Linux
2015-08-19 14:51 ` [PATCH v3 08/14] phy: Add driver for rockchip Display Port PHY Yakir Yang
[not found] ` <1439995877-18496-1-git-send-email-ykk-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-08-20 4:40 ` Kishon Vijay Abraham I
2015-08-20 6:56 ` Yakir Yang [this message]
2015-08-20 7:01 ` Yakir Yang
2015-08-19 14:51 ` [PATCH v3 10/14] drm: bridge: analogix_dp: add some rk3288 special registers setting Yakir Yang
2015-08-19 14:51 ` [PATCH v3 11/14] drm: bridge: analogix_dp: try force hpd after plug in lookup failed Yakir Yang
2015-08-19 14:52 ` [PATCH v3 13/14] drm: bridge/analogix_dp: move hpd detect to connector detect function Yakir Yang
2015-08-20 7:49 ` Jingoo Han
[not found] ` <6E5CEF9B-19D4-4AC4-B5B1-BC667979302D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-20 8:18 ` Yakir Yang
2015-08-19 14:52 ` [PATCH v3 14/14] drm: bridge/analogix_dp: add edid modes parse in get_modes method Yakir Yang
2015-08-19 23:54 ` [PATCH v3 0/14] Add Analogix Core Display Port Driver Dave Airlie
2015-08-20 1:02 ` Yakir Yang
2015-08-20 4:29 ` Archit Taneja
2015-08-20 5:54 ` Jingoo Han
2015-08-20 6:23 ` Yakir Yang
2015-08-20 6:55 ` Jingoo Han
2015-08-20 8:03 ` Yakir Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55D57A19.7020205@rock-chips.com \
--to=ykk@rock-chips.com \
--cc=a.hajda@samsung.com \
--cc=ajaynumb@gmail.com \
--cc=andy.yan@rock-chips.com \
--cc=devicetree@vger.kernel.org \
--cc=dianders@google.com \
--cc=djkurtz@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fabio.estevam@freescale.com \
--cc=galak@codeaurora.org \
--cc=gustavo.padovan@collabora.co.uk \
--cc=heiko@sntech.de \
--cc=ijc+devicetree@hellion.org.uk \
--cc=inki.dae@samsung.com \
--cc=jingoohan1@gmail.com \
--cc=joe@perches.com \
--cc=kishon@ti.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=pawel.moll@arm.com \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=robh+dt@kernel.org \
--cc=seanpaul@google.com \
--cc=treding@nvidia.com \
--cc=vpalatin@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).