From: Matt Porter <matt.porter@linaro.org>
To: Felipe Balbi <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Rob Herring <rob.herring@calxeda.com>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Kumar Gala <galak@codeaurora.org>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Christian Daudt <bcm@fixthebug.org>,
Paul Zimmerman <paulz@synopsys.com>
Cc: Linux USB List <linux-usb@vger.kernel.org>,
Linux ARM Kernel List <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Devicetree List <devicetree@vger.kernel.org>,
Linaro Patches <patches@linaro.org>
Subject: [PATCH v2 8/9] phy: add Broadcom Kona USB2 PHY driver
Date: Fri, 1 Nov 2013 15:45:57 -0400 [thread overview]
Message-ID: <1383335158-19730-9-git-send-email-matt.porter@linaro.org> (raw)
In-Reply-To: <1383335158-19730-1-git-send-email-matt.porter@linaro.org>
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@linaro.org>
---
drivers/phy/Kconfig | 6 ++
drivers/phy/Makefile | 2 +
drivers/phy/phy-bcm-kona-usb2.c | 161 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 169 insertions(+)
create mode 100644 drivers/phy/phy-bcm-kona-usb2.c
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 349bef2..cedada5 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,4 +15,10 @@ config GENERIC_PHY
phy users can obtain reference to the PHY. All the users of this
framework should select this config.
+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 9e9560f..ce83a14 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,3 +3,5 @@
#
obj-$(CONFIG_GENERIC_PHY) += phy-core.o
+
+obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-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..1beea7f
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,161 @@
+/*
+ * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
+ *
+ * Copyright (C) 2013 Linaro Limited
+ * Matt Porter <matt.porter@linaro.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>
+
+#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_SOFT_RESET (1 << 1)
+#define P1CTL_NON_DRIVING (1 << 0)
+
+struct bcm_kona_usb_phy_regs {
+ u32 ctrl;
+ u32 cfg;
+ u32 p1ctl;
+ u32 status;
+ u32 bc_cfg;
+ u32 tp_in;
+ u32 tp_out;
+ u32 phy_ctrl;
+ u32 usbreg;
+ u32 usbproben;
+};
+
+struct bcm_kona_usb {
+ struct bcm_kona_usb_phy_regs *regs;
+};
+
+static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
+{
+ u32 val;
+
+ val = readl(&phy->regs->ctrl);
+ 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;
+ writel(val, &phy->regs->ctrl);
+
+ /* 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);
+ } else {
+ val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
+ writel(val, &phy->regs->ctrl);
+ }
+}
+
+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 = {
+ .power_on = bcm_kona_usb_phy_power_on,
+ .power_off = bcm_kona_usb_phy_power_off,
+ .owner = THIS_MODULE,
+};
+
+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");
+MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
+MODULE_LICENSE("GPL v2");
--
1.8.4
next prev parent reply other threads:[~2013-11-01 19:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 19:45 [PATCH v2 0/9] USB Device Controller support for BCM281xx Matt Porter
2013-11-01 19:45 ` [PATCH v2 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
[not found] ` <1383335158-19730-2-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-02 13:14 ` Tomasz Figa
2013-11-02 17:16 ` Kishon Vijay Abraham I
[not found] ` <52753387.5030202-l0cyMroinI0@public.gmane.org>
2013-11-02 17:47 ` Matt Porter
2013-11-02 17:58 ` Tomasz Figa
2013-11-04 6:04 ` Kishon Vijay Abraham I
2013-11-01 19:45 ` [PATCH v2 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
2013-11-01 19:45 ` [PATCH v2 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
2013-11-01 19:45 ` [PATCH v2 4/9] usb: gadget: s3c-hsotg: add snps,dwc2 compatible string Matt Porter
2013-11-01 19:45 ` [PATCH v2 5/9] usb: gadget: s3c-hsotg: enable generic phy support Matt Porter
[not found] ` <1383335158-19730-6-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-02 13:09 ` Tomasz Figa
2013-11-02 17:52 ` Matt Porter
2013-11-01 19:45 ` [PATCH v2 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
[not found] ` <1383335158-19730-1-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-01 19:45 ` [PATCH v2 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
2013-11-01 20:54 ` Arend van Spriel
[not found] ` <527414F2.7090402-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2013-11-01 22:56 ` Matt Porter
2013-11-01 19:45 ` Matt Porter [this message]
2013-11-04 6:27 ` [PATCH v2 8/9] phy: add Broadcom Kona USB2 PHY driver Kishon Vijay Abraham I
2013-11-25 14:16 ` Matt Porter
2013-11-01 19:45 ` [PATCH v2 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
[not found] ` <1383335158-19730-10-git-send-email-matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-11-01 20:56 ` Sergei Shtylyov
2013-11-01 22:52 ` Matt Porter
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=1383335158-19730-9-git-send-email-matt.porter@linaro.org \
--to=matt.porter@linaro.org \
--cc=balbi@ti.com \
--cc=bcm@fixthebug.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=patches@linaro.org \
--cc=paulz@synopsys.com \
--cc=pawel.moll@arm.com \
--cc=rob.herring@calxeda.com \
/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).