aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy
diff options
context:
space:
mode:
authorPramod Kumar <pramod.kumar@broadcom.com>2016-06-10 01:33:51 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-11 02:24:54 -0400
commit4484f730b3358363ca4b3b422354676581fab2cb (patch)
tree2239c99f470a89b420ca902b40c8d5731469676b /drivers/phy
parent464e3b4b118f5c7abfdb68f3628df0ca65d28948 (diff)
phy: Add Northstar2 PCI Phy support
Add PCI Phy support for Broadcom Northstar2 SoCs. This driver uses the interface from the iproc mdio mux driver to enable the devices respective phys. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Jon Mason <jonmason@broadcom.com> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/Kconfig8
-rw-r--r--drivers/phy/Makefile2
-rw-r--r--drivers/phy/phy-bcm-ns2-pcie.c115
3 files changed, 124 insertions, 1 deletions
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98835f4..01fb93b4b1e4 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
434 434
435source "drivers/phy/tegra/Kconfig" 435source "drivers/phy/tegra/Kconfig"
436 436
437config PHY_NS2_PCIE
438 tristate "Broadcom Northstar2 PCIe PHY driver"
439 depends on OF && MDIO_BUS_MUX_BCM_IPROC
440 select GENERIC_PHY
441 default ARCH_BCM_IPROC
442 help
443 Enable this to support the Broadcom Northstar2 PCIe PHY.
444 If unsure, say N.
437endmenu 445endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73ccabc4..7aea094da3e2 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -53,5 +53,5 @@ obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
53obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o 53obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o
54obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o 54obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
55obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o 55obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o
56
57obj-$(CONFIG_ARCH_TEGRA) += tegra/ 56obj-$(CONFIG_ARCH_TEGRA) += tegra/
57obj-$(CONFIG_PHY_NS2_PCIE) += phy-bcm-ns2-pcie.o
diff --git a/drivers/phy/phy-bcm-ns2-pcie.c b/drivers/phy/phy-bcm-ns2-pcie.c
new file mode 100644
index 000000000000..9513f7ab1eaa
--- /dev/null
+++ b/drivers/phy/phy-bcm-ns2-pcie.c
@@ -0,0 +1,115 @@
1/*
2 * Copyright (C) 2016 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/device.h>
15#include <linux/module.h>
16#include <linux/of_mdio.h>
17#include <linux/mdio.h>
18#include <linux/phy.h>
19#include <linux/phy/phy.h>
20
21struct ns2_pci_phy {
22 struct mdio_device *mdiodev;
23 struct phy *phy;
24};
25
26#define BLK_ADDR_REG_OFFSET 0x1f
27#define PLL_AFE1_100MHZ_BLK 0x2100
28#define PLL_CLK_AMP_OFFSET 0x03
29#define PLL_CLK_AMP_2P05V 0x2b18
30
31static int ns2_pci_phy_init(struct phy *p)
32{
33 struct ns2_pci_phy *phy = phy_get_drvdata(p);
34 int rc;
35
36 /* select the AFE 100MHz block page */
37 rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
38 BLK_ADDR_REG_OFFSET, PLL_AFE1_100MHZ_BLK);
39 if (rc)
40 goto err;
41
42 /* set the 100 MHz reference clock amplitude to 2.05 v */
43 rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
44 PLL_CLK_AMP_OFFSET, PLL_CLK_AMP_2P05V);
45 if (rc)
46 goto err;
47
48 return 0;
49
50err:
51 dev_err(&phy->mdiodev->dev, "Error %d writing to phy\n", rc);
52 return rc;
53}
54
55static struct phy_ops ns2_pci_phy_ops = {
56 .init = ns2_pci_phy_init,
57};
58
59static int ns2_pci_phy_probe(struct mdio_device *mdiodev)
60{
61 struct device *dev = &mdiodev->dev;
62 struct phy_provider *provider;
63 struct ns2_pci_phy *p;
64 struct phy *phy;
65
66 phy = devm_phy_create(dev, dev->of_node, &ns2_pci_phy_ops);
67 if (IS_ERR(phy)) {
68 dev_err(dev, "failed to create Phy\n");
69 return PTR_ERR(phy);
70 }
71
72 p = devm_kmalloc(dev, sizeof(struct ns2_pci_phy),
73 GFP_KERNEL);
74 if (!p)
75 return -ENOMEM;
76
77 p->mdiodev = mdiodev;
78 dev_set_drvdata(dev, p);
79
80 p->phy = phy;
81 phy_set_drvdata(phy, p);
82
83 provider = devm_of_phy_provider_register(&phy->dev,
84 of_phy_simple_xlate);
85 if (IS_ERR(provider)) {
86 dev_err(dev, "failed to register Phy provider\n");
87 return PTR_ERR(provider);
88 }
89
90 dev_info(dev, "%s PHY registered\n", dev_name(dev));
91
92 return 0;
93}
94
95static const struct of_device_id ns2_pci_phy_of_match[] = {
96 { .compatible = "brcm,ns2-pcie-phy", },
97 { /* sentinel */ },
98};
99MODULE_DEVICE_TABLE(of, ns2_pci_phy_of_match);
100
101static struct mdio_driver ns2_pci_phy_driver = {
102 .mdiodrv = {
103 .driver = {
104 .name = "phy-bcm-ns2-pci",
105 .of_match_table = ns2_pci_phy_of_match,
106 },
107 },
108 .probe = ns2_pci_phy_probe,
109};
110mdio_module_driver(ns2_pci_phy_driver);
111
112MODULE_AUTHOR("Broadcom");
113MODULE_DESCRIPTION("Broadcom Northstar2 PCI Phy driver");
114MODULE_LICENSE("GPL v2");
115MODULE_ALIAS("platform:phy-bcm-ns2-pci");