From: Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Christian Daudt <bcm-xK7y4jjYLqYh9ZMKESR00Q@public.gmane.org>,
Paul Zimmerman <paulz-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>,
Tomasz Figa <t.figa-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Kamil Debski <k.debski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Kyungmin Park
<kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Linux USB List
<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux ARM Kernel List
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Devicetree List
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linaro Patches <patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver
Date: Wed, 27 Nov 2013 12:21:37 -0500 [thread overview]
Message-ID: <20131127172137.GG31091@beef> (raw)
In-Reply-To: <5295B2A8.80705-l0cyMroinI0@public.gmane.org>
On Wed, Nov 27, 2013 at 02:21:52PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
>
> On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > Add a driver for the internal Broadcom Kona USB 2.0 PHY found
> > on the BCM281xx family of SoCs.
> >
> > Signed-off-by: Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > ---
> > drivers/phy/Kconfig | 6 ++
> > drivers/phy/Makefile | 1 +
> > drivers/phy/phy-bcm-kona-usb2.c | 158 ++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 165 insertions(+)
> > create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
> >
> > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> > index a344f3d..2e87fa8 100644
> > --- a/drivers/phy/Kconfig
> > +++ b/drivers/phy/Kconfig
> > @@ -51,4 +51,10 @@ config PHY_EXYNOS_DP_VIDEO
> > help
> > Support for Display Port PHY found on Samsung EXYNOS SoCs.
> >
> > +config BCM_KONA_USB2_PHY
> > + tristate "Broadcom Kona USB2 PHY Driver"
> > + depends on GENERIC_PHY
> > + help
> > + Enable this to support the Broadcom Kona USB 2.0 PHY.
> > +
> > endmenu
> > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> > index d0caae9..c447f1a 100644
> > --- a/drivers/phy/Makefile
> > +++ b/drivers/phy/Makefile
> > @@ -3,6 +3,7 @@
> > #
> >
> > obj-$(CONFIG_GENERIC_PHY) += phy-core.o
> > +obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
> > obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o
> > obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o
> > obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o
> > diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
> > new file mode 100644
> > index 0000000..2c54fb8
> > --- /dev/null
> > +++ b/drivers/phy/phy-bcm-kona-usb2.c
> > @@ -0,0 +1,158 @@
> > +/*
> > + * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
> > + *
> > + * Copyright (C) 2013 Linaro Limited
> > + * Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > + *
> > + * This software is licensed under the terms of the GNU General Public
> > + * License version 2, as published by the Free Software Foundation, and
> > + * may be copied, distributed, and modified under those terms.
> > + *
> > + * 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/module.h>
> > +#include <linux/of.h>
> > +#include <linux/delay.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/err.h>
> > +#include <linux/io.h>
> > +#include <linux/clk.h>
> > +#include <linux/phy/phy.h>
>
> arrange the headers in alphabetical order so that it's easy while adding new
> headers. Just my preference.
yeah, same here. just development creep that I will address.
> > +
> > +#define OTGCTL (0)
> > +#define OTGCTL_OTGSTAT2 (1 << 31)
> > +#define OTGCTL_OTGSTAT1 (1 << 30)
> > +#define OTGCTL_PRST_N_SW (1 << 11)
> > +#define OTGCTL_HRESET_N (1 << 10)
> > +#define OTGCTL_UTMI_LINE_STATE1 (1 << 9)
> > +#define OTGCTL_UTMI_LINE_STATE0 (1 << 8)
> > +
> > +#define P1CTL (8)
> > +#define P1CTL_SOFT_RESET (1 << 1)
> > +#define P1CTL_NON_DRIVING (1 << 0)
>
> you can use BIT() instead.
will do
> > +
> > +struct bcm_kona_usb {
> > + void __iomem *regs;
> > +};
> > +
> > +static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
> > +{
> > + u32 val;
> > +
> > + val = readl(phy->regs + OTGCTL);
> > + if (on) {
> > + /* Configure and power PHY */
> > + val &= ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
> > + OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
> > + val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
> > + } else {
> > + val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
> > + }
> > + writel(val, phy->regs + OTGCTL);
> > +}
> > +
> > +static int bcm_kona_usb_phy_init(struct phy *gphy)
> > +{
> > + struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > + u32 val;
> > +
> > + /* Soft reset PHY */
> > + val = readl(phy->regs + P1CTL);
> > + val &= ~P1CTL_NON_DRIVING;
> > + val |= P1CTL_SOFT_RESET;
> > + writel(val, phy->regs + P1CTL);
> > + writel(val & ~P1CTL_SOFT_RESET, phy->regs + P1CTL);
> > + /* Reset needs to be asserted for 2ms */
> > + mdelay(2);
> > + writel(val | P1CTL_SOFT_RESET, phy->regs + P1CTL);
> > +
> > + return 0;
> > +}
> > +
> > +static int bcm_kona_usb_phy_power_on(struct phy *gphy)
> > +{
> > + struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > +
> > + bcm_kona_usb_phy_power(phy, 1);
> > +
> > + return 0;
> > +}
> > +
> > +static int bcm_kona_usb_phy_power_off(struct phy *gphy)
> > +{
> > + struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
> > +
> > + bcm_kona_usb_phy_power(phy, 0);
> > +
> > + return 0;
> > +}
> > +
> > +static struct phy_ops ops = {
> > + .init = bcm_kona_usb_phy_init,
> > + .power_on = bcm_kona_usb_phy_power_on,
> > + .power_off = bcm_kona_usb_phy_power_off,
> > + .owner = THIS_MODULE,
>
> owner is aligned differently..
ok
> > +};
> > +
> > +static int bcm_kona_usb2_probe(struct platform_device *pdev)
> > +{
> > + struct device *dev = &pdev->dev;
> > + struct bcm_kona_usb *phy;
> > + struct resource *res;
> > + struct phy *gphy;
> > + struct phy_provider *phy_provider;
> > +
> > + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
> > + if (!phy)
> > + return -ENOMEM;
> > +
> > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + phy->regs = devm_ioremap_resource(&pdev->dev, res);
> > + if (IS_ERR(phy->regs))
> > + return PTR_ERR(phy->regs);
> > +
> > + platform_set_drvdata(pdev, phy);
> > +
> > + phy_provider = devm_of_phy_provider_register(dev,
> > + of_phy_simple_xlate);
> > + if (IS_ERR(phy_provider))
> > + return PTR_ERR(phy_provider);
> > +
> > + gphy = devm_phy_create(dev, &ops, NULL);
> > + if (IS_ERR(gphy))
> > + return PTR_ERR(gphy);
> > +
> > + /* The Kona PHY supports an 8-bit wide UTMI interface */
> > + phy_set_bus_width(gphy, 8);
> > +
> > + phy_set_drvdata(gphy, phy);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct of_device_id bcm_kona_usb2_dt_ids[] = {
> > + { .compatible = "brcm,kona-usb2-phy" },
> > + { /* sentinel */ }
> > +};
> > +
> > +MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids);
> > +
> > +static struct platform_driver bcm_kona_usb2_driver = {
> > + .probe = bcm_kona_usb2_probe,
> > + .driver = {
> > + .name = "bcm-kona-usb2",
> > + .owner = THIS_MODULE,
> > + .of_match_table = bcm_kona_usb2_dt_ids,
> > + },
> > +};
> > +
> > +module_platform_driver(bcm_kona_usb2_driver);
> > +
> > +MODULE_ALIAS("platform:bcm-kona-usb2");
> > +MODULE_AUTHOR("Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>");
> > +MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
> > +MODULE_LICENSE("GPL v2");
> >
> Apart from those comments, this patch looks good.
Ok, thanks much for all the reviews.
-Matt
--
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
prev parent reply other threads:[~2013-11-27 17:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-25 18:15 [PATCH v3 0/9] USB Device Controller support for BCM281xx Matt Porter
2013-11-25 18:15 ` [PATCH v3 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
2013-11-26 10:16 ` Kishon Vijay Abraham I
2013-11-27 16:55 ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
2013-11-26 10:19 ` Kishon Vijay Abraham I
2013-11-27 16:56 ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
2013-11-25 18:16 ` [PATCH v3 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string Matt Porter
[not found] ` <1385403367-18144-1-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-25 18:16 ` [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support Matt Porter
2013-11-26 10:23 ` Kishon Vijay Abraham I
2013-11-27 17:13 ` Matt Porter
2013-11-27 22:36 ` Matt Porter
2013-11-28 5:53 ` Kishon Vijay Abraham I
[not found] ` <5296DA70.8010409-l0cyMroinI0@public.gmane.org>
2013-11-28 16:41 ` Matt Porter
2013-11-28 17:02 ` Kamil Debski
2013-11-25 18:16 ` [PATCH v3 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
2013-11-27 8:57 ` Kishon Vijay Abraham I
[not found] ` <5295B3EF.8010602-l0cyMroinI0@public.gmane.org>
2013-11-27 17:24 ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
2013-11-26 10:28 ` Kishon Vijay Abraham I
[not found] ` <529477DD.8000906-l0cyMroinI0@public.gmane.org>
2013-11-27 17:16 ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
[not found] ` <1385403367-18144-8-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-26 10:31 ` Kishon Vijay Abraham I
[not found] ` <52947869.4040101-l0cyMroinI0@public.gmane.org>
2013-11-27 17:19 ` Matt Porter
2013-11-25 18:16 ` [PATCH v3 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
2013-11-27 8:51 ` Kishon Vijay Abraham I
[not found] ` <5295B2A8.80705-l0cyMroinI0@public.gmane.org>
2013-11-27 17:21 ` Matt Porter [this message]
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=20131127172137.GG31091@beef \
--to=matt.porter-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=balbi-l0cyMroinI0@public.gmane.org \
--cc=bcm-xK7y4jjYLqYh9ZMKESR00Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=k.debski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=kishon-l0cyMroinI0@public.gmane.org \
--cc=kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@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=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=paulz-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
--cc=t.figa-Sze3O3UU22JBDgjK7y7TUQ@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).