devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yunzhi Li <lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
To: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>,
	heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jwerner-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org,
	huangtao-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
	zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
	cf-TNX95d0MmH7DzftRWevZcw@public.gmane.org
Subject: Re: [PATCH v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY
Date: Wed, 21 Jan 2015 18:06:29 +0800	[thread overview]
Message-ID: <54BF7A25.2050000@rock-chips.com> (raw)
In-Reply-To: <54BF75FF.6020207-l0cyMroinI0@public.gmane.org>

Hi Kishon :
> Hi,
>
> On Friday 12 December 2014 08:37 PM, Yunzhi Li wrote:
>> This patch to add a generic PHY driver for ROCKCHIP usb PHYs,
>> currently this driver can support RK3288. The RK3288 SoC have
>> three independent USB PHY IPs which are all configured through a
>> set of registers located in the GRF (general register files)
>> module.
>>
>> Signed-off-by: Yunzhi Li <lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
>>
>> ---
>>
>> Changes in v7:
>> - Accept Kishon's comments to use phandle args to find a phy
>>    struct directly and get rid of using a custom of_xlate
>>    function.
>>
>> Changes in v6:
>> - Rename SIDDQ_MSK to SIDDQ_WRITE_ENA.
>>
>> Changes in v5: None
>> Changes in v4:
>> - Get number of PHYs from device tree.
>> - Model each PHY as subnode of the phy provider node.
>>
>> Changes in v3:
>> - Use BIT macro instead of bit shift ops.
>> - Rename the config entry to PHY_ROCKCHIP_USB.
>>
>>   drivers/phy/Kconfig            |   7 ++
>>   drivers/phy/Makefile           |   1 +
>>   drivers/phy/phy-rockchip-usb.c | 158 +++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 166 insertions(+)
>>   create mode 100644 drivers/phy/phy-rockchip-usb.c
>>
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index ccad880..b24500a 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
>>   	depends on OF
>>   	select GENERIC_PHY
>>   
>> +config PHY_ROCKCHIP_USB
>> +	tristate "Rockchip USB2 PHY Driver"
>> +	depends on ARCH_ROCKCHIP && OF
>> +	select GENERIC_PHY
>> +	help
>> +	  Enable this to support the Rockchip USB 2.0 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 aa74f96..48bf5a1 100644
>> --- a/drivers/phy/Makefile
>> +++ b/drivers/phy/Makefile
>> @@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)	+= phy-exynos5250-usb2.o
>>   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_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-usb.c b/drivers/phy/phy-rockchip-usb.c
>> new file mode 100644
>> index 0000000..22011c3
>> --- /dev/null
>> +++ b/drivers/phy/phy-rockchip-usb.c
>> @@ -0,0 +1,158 @@
>> +/*
>> + * Rockchip usb PHY driver
>> + *
>> + * Copyright (C) 2014 Yunzhi Li <lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
>> + * Copyright (C) 2014 ROCKCHIP, Inc.
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/mutex.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/phy/phy.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/regulator/consumer.h>
>> +#include <linux/reset.h>
>> +#include <linux/regmap.h>
>> +#include <linux/mfd/syscon.h>
>> +
>> +/*
>> + * The higher 16-bit of this register is used for write protection
>> + * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
>> + */
>> +#define SIDDQ_WRITE_ENA	BIT(29)
>> +#define SIDDQ_ON		BIT(13)
>> +#define SIDDQ_OFF		(0 << 13)
>> +
>> +struct rockchip_usb_phy {
>> +	unsigned int	reg_offset;
>> +	struct regmap	*reg_base;
>> +	struct clk	*clk;
>> +	struct phy	*phy;
>> +};
>> +
>> +static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
>> +					   bool siddq)
>> +{
>> +	return regmap_write(phy->reg_base, phy->reg_offset,
>> +			    SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
>> +}
>> +
>> +static int rockchip_usb_phy_power_off(struct phy *_phy)
>> +{
>> +	struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
>> +	int ret = 0;
>> +
>> +	/* Power down usb phy analog blocks by set siddq 1 */
>> +	ret = rockchip_usb_phy_power(phy, 1);
>> +	if (ret)
>> +		return ret;
>> +
>> +	clk_disable_unprepare(phy->clk);
>> +	if (ret)
>> +		return ret;
>> +
>> +	return 0;
>> +}
>> +
>> +static int rockchip_usb_phy_power_on(struct phy *_phy)
>> +{
>> +	struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
>> +	int ret = 0;
>> +
>> +	ret = clk_prepare_enable(phy->clk);
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* Power up usb phy analog blocks by set siddq 0 */
>> +	ret = rockchip_usb_phy_power(phy, 0);
>> +	if (ret)
>> +		return ret;
>> +
>> +	return 0;
>> +}
>> +
>> +static struct phy_ops ops = {
>> +	.power_on	= rockchip_usb_phy_power_on,
>> +	.power_off	= rockchip_usb_phy_power_off,
>> +	.owner		= THIS_MODULE,
>> +};
>> +
>> +static int rockchip_usb_phy_probe(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct rockchip_usb_phy *rk_phy;
>> +	struct phy_provider *phy_provider;
>> +	struct device_node *child;
>> +	struct regmap *grf;
>> +	unsigned int reg_offset;
>> +
>> +	grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf");
>> +	if (IS_ERR(grf)) {
>> +		dev_err(&pdev->dev, "Missing rockchip,grf property\n");
>> +		return PTR_ERR(grf);
>> +	}
>> +
>> +	for_each_available_child_of_node(dev->of_node, child) {
>> +		rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL);
>> +		if (!rk_phy)
>> +			return -ENOMEM;
>> +
>> +		if (of_property_read_u32(child, "reg", &reg_offset)) {
>> +			dev_err(dev, "missing reg property in node %s\n",
>> +				child->name);
>> +			return -EINVAL;
>> +		}
>> +
>> +		rk_phy->reg_offset = reg_offset;
>> +		rk_phy->reg_base = grf;
>> +
>> +		rk_phy->clk = of_clk_get_by_name(child, "phyclk");
>> +		if (IS_ERR(rk_phy->clk))
>> +			rk_phy->clk = NULL;
>> +
>> +		rk_phy->phy = devm_phy_create(dev, child, &ops);
>> +		if (IS_ERR(rk_phy->phy)) {
>> +			dev_err(dev, "failed to create PHY\n");
>> +			return PTR_ERR(rk_phy->phy);
>> +		}
>> +		phy_set_drvdata(rk_phy->phy, rk_phy);
>> +	}
>> +
>> +	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_usb_phy_dt_ids[] = {
>> +	{ .compatible = "rockchip,rk3288-usb-phy" },
> have you added devicetree binding documentation where I can find this
> compatible string?
>
> Thanks
> Kishon
>
>
You could find this documentation in this page :
https://lkml.org/lkml/2014/12/12/439
Thanks

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-01-21 10:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12 15:00 [PATCH v7 0/5] Patches to add support for Rockchip usb PHYs Yunzhi Li
2014-12-12 15:00 ` [PATCH v7 1/5] Documentation: bindings: add dt documentation for Rockchip usb PHY Yunzhi Li
2014-12-12 15:17 ` [PATCH v7 5/5] ARM: dts: rockchip: Enable usb PHY on rk3288-evb board Yunzhi Li
2014-12-15 18:15   ` Doug Anderson
     [not found] ` <1418396413-27937-1-git-send-email-lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2014-12-12 15:07   ` [PATCH v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY Yunzhi Li
     [not found]     ` <1418396866-32625-1-git-send-email-lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2014-12-13  0:19       ` Doug Anderson
2014-12-13  7:24         ` Kishon Vijay Abraham I
     [not found]           ` <548BE99E.2000409-l0cyMroinI0@public.gmane.org>
2014-12-13 23:12             ` Doug Anderson
2014-12-15 18:12       ` Doug Anderson
2015-01-21  9:48       ` Kishon Vijay Abraham I
     [not found]         ` <54BF75FF.6020207-l0cyMroinI0@public.gmane.org>
2015-01-21 10:06           ` Yunzhi Li [this message]
     [not found]             ` <54BF7A25.2050000-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-01-21 10:10               ` Kishon Vijay Abraham I
2015-01-21 10:21                 ` Yunzhi Li
2014-12-12 15:12   ` [PATCH v7 4/5] ARM: dts: rockchip: add rk3288 usb PHY Yunzhi Li
     [not found]     ` <1418397141-1079-1-git-send-email-lyz-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2014-12-15 18:14       ` Doug Anderson
2015-02-19 22:36   ` [PATCH v7 0/5] Patches to add support for Rockchip usb PHYs Heiko Stübner

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=54BF7A25.2050000@rock-chips.com \
    --to=lyz-tnx95d0mmh7dzftrwevzcw@public.gmane.org \
    --cc=cf-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=huangtao-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=jwerner-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=kishon-l0cyMroinI0@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.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).