summaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 19:13:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 19:13:02 -0500
commitec513b16c480c6cdda1e3d597e611eafca05227b (patch)
treeba8855093dbf4ca15f864947d947d65fdfa2a76d /drivers/phy
parentbcee63488ece9a0fca8be19951428a7b41001e66 (diff)
parent2fc5a7dace3c43e62402ab4e8800a8f1834ffe2a (diff)
Merge tag 'usb-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH: "Here's the big USB pull request for 3.14-rc1 Lots of little things all over the place, and the usual USB gadget updates, and XHCI fixes (some for an issue reported by a lot of people). USB PHY updates as well as chipidea updates and fixes. All of these have been in the linux-next tree with no reported issues" * tag 'usb-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (318 commits) usb: chipidea: udc: using MultO at TD as real mult value for ISO-TX usb: chipidea: need to mask INT_STATUS when write otgsc usb: chipidea: put hw_phymode_configure before ci_usb_phy_init usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28 usb: chipidea: add freescale imx28 special write register method usb: ehci: add freescale imx28 special write register method usb: core: check for valid id_table when using the RefId feature usb: cdc-wdm: resp_count can be 0 even if WDM_READ is set usb: core: bail out if user gives an unknown RefId when using new_id usb: core: allow a reference device for new_id usb: core: add sanity checks when using bInterfaceClass with new_id USB: image: correct spelling mistake in comment USB: c67x00: correct spelling mistakes in comments usb: delete non-required instances of include <linux/init.h> usb:hub set hub->change_bits when over-current happens Revert "usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28" xhci: Set scatter-gather limit to avoid failed block writes. xhci: Avoid infinite loop when sg urb requires too many trbs usb: gadget: remove unused variable in gr_queue_int() ...
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/Kconfig6
-rw-r--r--drivers/phy/Makefile1
-rw-r--r--drivers/phy/phy-bcm-kona-usb2.c158
3 files changed, 165 insertions, 0 deletions
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index d0611b84d7f7..b901c472d7f3 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -57,4 +57,10 @@ config PHY_EXYNOS_DP_VIDEO
57 help 57 help
58 Support for Display Port PHY found on Samsung EXYNOS SoCs. 58 Support for Display Port PHY found on Samsung EXYNOS SoCs.
59 59
60config BCM_KONA_USB2_PHY
61 tristate "Broadcom Kona USB2 PHY Driver"
62 depends on GENERIC_PHY
63 help
64 Enable this to support the Broadcom Kona USB 2.0 PHY.
65
60endmenu 66endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 4e4adc96f753..b57c25371cca 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
3# 3#
4 4
5obj-$(CONFIG_GENERIC_PHY) += phy-core.o 5obj-$(CONFIG_GENERIC_PHY) += phy-core.o
6obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
6obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o 7obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o
7obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o 8obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o
8obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o 9obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
new file mode 100644
index 000000000000..efc5c1a13a5d
--- /dev/null
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -0,0 +1,158 @@
1/*
2 * phy-bcm-kona-usb2.c - Broadcom Kona USB2 Phy Driver
3 *
4 * Copyright (C) 2013 Linaro Limited
5 * Matt Porter <mporter@linaro.org>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/clk.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/io.h>
21#include <linux/module.h>
22#include <linux/of.h>
23#include <linux/phy/phy.h>
24#include <linux/platform_device.h>
25
26#define OTGCTL (0)
27#define OTGCTL_OTGSTAT2 BIT(31)
28#define OTGCTL_OTGSTAT1 BIT(30)
29#define OTGCTL_PRST_N_SW BIT(11)
30#define OTGCTL_HRESET_N BIT(10)
31#define OTGCTL_UTMI_LINE_STATE1 BIT(9)
32#define OTGCTL_UTMI_LINE_STATE0 BIT(8)
33
34#define P1CTL (8)
35#define P1CTL_SOFT_RESET BIT(1)
36#define P1CTL_NON_DRIVING BIT(0)
37
38struct bcm_kona_usb {
39 void __iomem *regs;
40};
41
42static void bcm_kona_usb_phy_power(struct bcm_kona_usb *phy, int on)
43{
44 u32 val;
45
46 val = readl(phy->regs + OTGCTL);
47 if (on) {
48 /* Configure and power PHY */
49 val &= ~(OTGCTL_OTGSTAT2 | OTGCTL_OTGSTAT1 |
50 OTGCTL_UTMI_LINE_STATE1 | OTGCTL_UTMI_LINE_STATE0);
51 val |= OTGCTL_PRST_N_SW | OTGCTL_HRESET_N;
52 } else {
53 val &= ~(OTGCTL_PRST_N_SW | OTGCTL_HRESET_N);
54 }
55 writel(val, phy->regs + OTGCTL);
56}
57
58static int bcm_kona_usb_phy_init(struct phy *gphy)
59{
60 struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
61 u32 val;
62
63 /* Soft reset PHY */
64 val = readl(phy->regs + P1CTL);
65 val &= ~P1CTL_NON_DRIVING;
66 val |= P1CTL_SOFT_RESET;
67 writel(val, phy->regs + P1CTL);
68 writel(val & ~P1CTL_SOFT_RESET, phy->regs + P1CTL);
69 /* Reset needs to be asserted for 2ms */
70 mdelay(2);
71 writel(val | P1CTL_SOFT_RESET, phy->regs + P1CTL);
72
73 return 0;
74}
75
76static int bcm_kona_usb_phy_power_on(struct phy *gphy)
77{
78 struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
79
80 bcm_kona_usb_phy_power(phy, 1);
81
82 return 0;
83}
84
85static int bcm_kona_usb_phy_power_off(struct phy *gphy)
86{
87 struct bcm_kona_usb *phy = phy_get_drvdata(gphy);
88
89 bcm_kona_usb_phy_power(phy, 0);
90
91 return 0;
92}
93
94static struct phy_ops ops = {
95 .init = bcm_kona_usb_phy_init,
96 .power_on = bcm_kona_usb_phy_power_on,
97 .power_off = bcm_kona_usb_phy_power_off,
98 .owner = THIS_MODULE,
99};
100
101static int bcm_kona_usb2_probe(struct platform_device *pdev)
102{
103 struct device *dev = &pdev->dev;
104 struct bcm_kona_usb *phy;
105 struct resource *res;
106 struct phy *gphy;
107 struct phy_provider *phy_provider;
108
109 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
110 if (!phy)
111 return -ENOMEM;
112
113 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
114 phy->regs = devm_ioremap_resource(&pdev->dev, res);
115 if (IS_ERR(phy->regs))
116 return PTR_ERR(phy->regs);
117
118 platform_set_drvdata(pdev, phy);
119
120 gphy = devm_phy_create(dev, &ops, NULL);
121 if (IS_ERR(gphy))
122 return PTR_ERR(gphy);
123
124 /* The Kona PHY supports an 8-bit wide UTMI interface */
125 phy_set_bus_width(gphy, 8);
126
127 phy_set_drvdata(gphy, phy);
128
129 phy_provider = devm_of_phy_provider_register(dev,
130 of_phy_simple_xlate);
131 if (IS_ERR(phy_provider))
132 return PTR_ERR(phy_provider);
133
134 return 0;
135}
136
137static const struct of_device_id bcm_kona_usb2_dt_ids[] = {
138 { .compatible = "brcm,kona-usb2-phy" },
139 { /* sentinel */ }
140};
141
142MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids);
143
144static struct platform_driver bcm_kona_usb2_driver = {
145 .probe = bcm_kona_usb2_probe,
146 .driver = {
147 .name = "bcm-kona-usb2",
148 .owner = THIS_MODULE,
149 .of_match_table = bcm_kona_usb2_dt_ids,
150 },
151};
152
153module_platform_driver(bcm_kona_usb2_driver);
154
155MODULE_ALIAS("platform:bcm-kona-usb2");
156MODULE_AUTHOR("Matt Porter <mporter@linaro.org>");
157MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver");
158MODULE_LICENSE("GPL v2");