From: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
To: Gregory CLEMENT
<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Mathias Nyman
<mathias.nyman-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
Sebastian Hesselbarth
<sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Thomas Petazzoni
<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Ezequiel Garcia
<ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Lior Amsalem <alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Tawfik Bayouk <tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Nadav Haklai <nadavh-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/5] phy: add support for USB cluster on the Armada 375 SoC
Date: Mon, 26 May 2014 15:12:45 +0530 [thread overview]
Message-ID: <53830C95.2030202@ti.com> (raw)
In-Reply-To: <537FC2BE.1040501-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
hI,
On Saturday 24 May 2014 03:20 AM, Gregory CLEMENT wrote:
> On 23/05/2014 11:20, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Friday 16 May 2014 09:52 PM, Gregory CLEMENT wrote:
>>> The Armada 375 SoC comes with an USB2 host and device controller and
>>> an USB3 controller. The USB cluster control register allows to manage
>>> common features of both USB controllers.
>>>
>>> This commit adds a driver integrated in the generic PHY framework to
>>> control this USB cluster feature.
>>>
>>> Signed-off-by: Gregory CLEMENT <gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>> Signed-off-by: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>> ---
>>> drivers/phy/Kconfig | 6 +
>>> drivers/phy/Makefile | 1 +
>>> drivers/phy/phy-armada375-usb2.c | 140 +++++++++++++++++++++++
>>> include/dt-bindings/phy/armada-375-usb-cluster.h | 18 +++
> [...]
>
>>> +static struct phy_ops armada375_usb_phy_ops = {
>>> + .init = armada375_usb_phy_init,
>>> + .owner = THIS_MODULE,
>>
>> nitpick: unnecessary tab.
>
> OK
>
>>> +};
>>> +
>>> +/*
>>> + * Only one controller can use this PHY. We shouldn't have the case
>>> + * when two controllers want to use this PHY. But if this case occurs
>>> + * then we provide a phy to the first one and return an error for the
>>> + * next one. This error has also to be an error returned by
>>> + * devm_phy_optional_get() so different from ENODEV for USB2. In the
>>> + * USB3 case it still optional and we use ENODEV.
>>> + */
>>> +static struct phy *armada375_usb_phy_xlate(struct device *dev,
>>> + struct of_phandle_args *args)
>>> +{
>>> + if (WARN_ON(usb_cluster_phy.phy_provided)) {
>>> + dev_err(dev, "This PHY has already been provided!\n");
>>> + dev_err(dev, "Check your device tree, only one controller can use it\n.");
>>> + if (args->args[0] == PHY_USB2)
>>> + return ERR_PTR(-EBUSY);
>>> + else
>>> + return ERR_PTR(-ENODEV);
>>> + }
>>> +
>>> + if (args->args[0] == PHY_USB2)
>>> + usb_cluster_phy.use_usb3 = false;
>>> + else if (args->args[0] == PHY_USB3)
>>> + usb_cluster_phy.use_usb3 = true;
>>> + else {
>>> + dev_err(dev, "Invalid PHY mode\n");
>>> + return ERR_PTR(-ENODEV);
>>> + }
>>
>> how will this behave if there is a phy_put and then a phy_get?
>
> Badly I think :(
>
> I have to think about a better solution then.
>
>>> +
>>> + usb_cluster_phy.phy_provided = true;
>>> +
>>> + return usb_cluster_phy.phy;
>>> +}
>>> +
>>> +static int armada375_usb_phy_probe(struct platform_device *pdev)
>>> +{
>>> + struct device *dev = &pdev->dev;
>>> + struct phy *phy;
>>> + struct phy_provider *phy_provider;
>>> + void __iomem *usb_cluster_base;
>>> + struct resource *res;
>>> +
>>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> + usb_cluster_base = devm_ioremap_resource(&pdev->dev, res);
>>> + if (!usb_cluster_base)
>>> + return -ENOMEM;
>>> +
>>> + phy = devm_phy_create(dev, &armada375_usb_phy_ops, NULL);
>>> + if (IS_ERR(phy)) {
>>> + dev_err(dev, "failed to create PHY \n");
>>> + return PTR_ERR(phy);
>>> + }
>>> +
>>> + usb_cluster_phy.phy = phy;
>>> + usb_cluster_phy.reg = usb_cluster_base;
>>> + phy_set_drvdata(phy, &usb_cluster_phy);
>>> +
>>> + phy_provider = devm_of_phy_provider_register(&pdev->dev,
>>> + armada375_usb_phy_xlate);
>>> + if (IS_ERR(phy_provider))
>>> + return PTR_ERR(phy_provider);
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static const struct of_device_id of_usb_cluster_table[] = {
>>> + { .compatible = "marvell,armada-375-usb-cluster", },
>>> + { /* end of list */ },
>>> +};
>>> +MODULE_DEVICE_TABLE(of, of_usb_cluster_table);
>>> +
>>> +static struct platform_driver armada375_usb_phy_driver = {
>>> + .probe = armada375_usb_phy_probe,
>>> + .driver = {
>>> + .of_match_table = of_usb_cluster_table,
>>> + .name = "armada-375-usb-cluster",
>>> + .owner = THIS_MODULE,
>>> + }
>>> +};
>>> +module_platform_driver(armada375_usb_phy_driver);
>>> +
>>> +MODULE_DESCRIPTION("Armada 375 USB cluster driver");
>>> +MODULE_AUTHOR("Gregory CLEMENT <gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
>>> +MODULE_LICENSE("GPL");
>>
>> GPL v2?
>
> See the header, I chose "GNU General Public License version 2 or later."
> so "GPL" match it.
Indeed! Just figured it's documented in include/linux/module.h.
Thanks
Kishon
--
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
next prev parent reply other threads:[~2014-05-26 9:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 16:22 [PATCH 1/5] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
[not found] ` <1400257376-13251-1-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-05-16 16:22 ` [PATCH 2/5] Documentation: dt-bindings: document the Armada 375 USB cluster binding Gregory CLEMENT
[not found] ` <1400257376-13251-2-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-05-23 9:24 ` Kishon Vijay Abraham I
2014-05-23 13:21 ` Andrew Lunn
[not found] ` <20140523132145.GA31314-g2DYL2Zd6BY@public.gmane.org>
2014-05-23 13:36 ` Andrew Lunn
[not found] ` <20140523133608.GB31314-g2DYL2Zd6BY@public.gmane.org>
2014-05-23 13:52 ` Kishon Vijay Abraham I
[not found] ` <537F52B0.5030204-l0cyMroinI0@public.gmane.org>
2014-05-23 13:59 ` Andrew Lunn
[not found] ` <20140523135943.GC31314-g2DYL2Zd6BY@public.gmane.org>
2014-05-23 21:25 ` Gregory CLEMENT
2014-05-23 13:50 ` Kishon Vijay Abraham I
[not found] ` <537F13B2.6070500-l0cyMroinI0@public.gmane.org>
2014-05-23 13:24 ` Gregory CLEMENT
2014-05-23 9:20 ` [PATCH 1/5] phy: add support for USB cluster on the Armada 375 SoC Kishon Vijay Abraham I
[not found] ` <537F12F5.2030102-l0cyMroinI0@public.gmane.org>
2014-05-23 21:50 ` Gregory CLEMENT
2014-05-24 6:46 ` Thomas Petazzoni
[not found] ` <537FC2BE.1040501-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-05-26 9:42 ` Kishon Vijay Abraham I [this message]
2014-05-16 16:22 ` [PATCH 3/5] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
2014-05-16 16:22 ` [PATCH 4/5] usb: host: xhci-plat: add optional PHY support Gregory CLEMENT
2014-05-23 9:28 ` Kishon Vijay Abraham I
[not found] ` <537F14D4.1090705-l0cyMroinI0@public.gmane.org>
2014-05-23 21:39 ` Gregory CLEMENT
2014-05-16 16:22 ` [PATCH 5/5] ARM: mvebu: add PHY support to the dts for the USB controllers on Armada 375 Gregory CLEMENT
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=53830C95.2030202@ti.com \
--to=kishon-l0cymroini0@public.gmane.org \
--cc=alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=andrew-g2DYL2Zd6BY@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mathias.nyman-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=nadavh-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@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).