Lines Matching +full:ns +full:- +full:ax +full:- +full:usb3 +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Broadcom Northstar USB 3.0 PHY Driver
22 #include <linux/phy/phy.h>
54 struct phy *phy; member
59 .compatible = "brcm,ns-ax-usb3-phy",
63 .compatible = "brcm,ns-bx-usb3-phy",
69 static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
72 static int bcm_ns_usb3_phy_init_ns_bx(struct bcm_ns_usb3 *usb3) in bcm_ns_usb3_phy_init_ns_bx() argument
76 /* USB3 PLL Block */ in bcm_ns_usb3_phy_init_ns_bx()
77 err = bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, in bcm_ns_usb3_phy_init_ns_bx()
83 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLL_CONTROL, 0x1000); in bcm_ns_usb3_phy_init_ns_bx()
86 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLLA_CONTROL0, 0x6400); in bcm_ns_usb3_phy_init_ns_bx()
89 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLLA_CONTROL1, 0xc000); in bcm_ns_usb3_phy_init_ns_bx()
92 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLLA_CONTROL1, 0x8000); in bcm_ns_usb3_phy_init_ns_bx()
94 /* Deasserting USB3 system reset */ in bcm_ns_usb3_phy_init_ns_bx()
95 writel(0, usb3->dmp + BCMA_RESET_CTL); in bcm_ns_usb3_phy_init_ns_bx()
98 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLL_CONTROL, 0x9000); in bcm_ns_usb3_phy_init_ns_bx()
101 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, in bcm_ns_usb3_phy_init_ns_bx()
105 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_LFPS_CMP, 0xf30d); in bcm_ns_usb3_phy_init_ns_bx()
108 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_LFPS_DEGLITCH, 0x6302); in bcm_ns_usb3_phy_init_ns_bx()
111 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, in bcm_ns_usb3_phy_init_ns_bx()
115 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_TX_PMD_CONTROL1, 0x1003); in bcm_ns_usb3_phy_init_ns_bx()
120 static int bcm_ns_usb3_phy_init_ns_ax(struct bcm_ns_usb3 *usb3) in bcm_ns_usb3_phy_init_ns_ax() argument
125 err = bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, in bcm_ns_usb3_phy_init_ns_ax()
130 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PLLA_CONTROL0, 0x6400); in bcm_ns_usb3_phy_init_ns_ax()
132 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, 0x80e0); in bcm_ns_usb3_phy_init_ns_ax()
134 bcm_ns_usb3_mdio_phy_write(usb3, 0x02, 0x009c); in bcm_ns_usb3_phy_init_ns_ax()
137 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_PHY_BASE_ADDR_REG, in bcm_ns_usb3_phy_init_ns_ax()
140 bcm_ns_usb3_mdio_phy_write(usb3, 0x02, 0x21d3); in bcm_ns_usb3_phy_init_ns_ax()
142 bcm_ns_usb3_mdio_phy_write(usb3, BCM_NS_USB3_TX_PMD_CONTROL1, 0x1003); in bcm_ns_usb3_phy_init_ns_ax()
144 /* Deasserting USB3 system reset */ in bcm_ns_usb3_phy_init_ns_ax()
145 writel(0, usb3->dmp + BCMA_RESET_CTL); in bcm_ns_usb3_phy_init_ns_ax()
150 static int bcm_ns_usb3_phy_init(struct phy *phy) in bcm_ns_usb3_phy_init() argument
152 struct bcm_ns_usb3 *usb3 = phy_get_drvdata(phy); in bcm_ns_usb3_phy_init() local
155 /* Perform USB3 system soft reset */ in bcm_ns_usb3_phy_init()
156 writel(BCMA_RESET_CTL_RESET, usb3->dmp + BCMA_RESET_CTL); in bcm_ns_usb3_phy_init()
158 switch (usb3->family) { in bcm_ns_usb3_phy_init()
160 err = bcm_ns_usb3_phy_init_ns_ax(usb3); in bcm_ns_usb3_phy_init()
163 err = bcm_ns_usb3_phy_init_ns_bx(usb3); in bcm_ns_usb3_phy_init()
167 err = -ENOTSUPP; in bcm_ns_usb3_phy_init()
182 static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg, in bcm_ns_usb3_mdio_phy_write() argument
185 struct mdio_device *mdiodev = usb3->mdiodev; in bcm_ns_usb3_mdio_phy_write()
192 struct device *dev = &mdiodev->dev; in bcm_ns_usb3_mdio_probe()
195 struct bcm_ns_usb3 *usb3; in bcm_ns_usb3_mdio_probe() local
199 usb3 = devm_kzalloc(dev, sizeof(*usb3), GFP_KERNEL); in bcm_ns_usb3_mdio_probe()
200 if (!usb3) in bcm_ns_usb3_mdio_probe()
201 return -ENOMEM; in bcm_ns_usb3_mdio_probe()
203 usb3->dev = dev; in bcm_ns_usb3_mdio_probe()
204 usb3->mdiodev = mdiodev; in bcm_ns_usb3_mdio_probe()
206 usb3->family = (enum bcm_ns_family)device_get_match_data(dev); in bcm_ns_usb3_mdio_probe()
208 syscon_np = of_parse_phandle(dev->of_node, "usb3-dmp-syscon", 0); in bcm_ns_usb3_mdio_probe()
214 usb3->dmp = devm_ioremap_resource(dev, &res); in bcm_ns_usb3_mdio_probe()
215 if (IS_ERR(usb3->dmp)) in bcm_ns_usb3_mdio_probe()
216 return PTR_ERR(usb3->dmp); in bcm_ns_usb3_mdio_probe()
218 usb3->phy = devm_phy_create(dev, NULL, &ops); in bcm_ns_usb3_mdio_probe()
219 if (IS_ERR(usb3->phy)) { in bcm_ns_usb3_mdio_probe()
220 dev_err(dev, "Failed to create PHY\n"); in bcm_ns_usb3_mdio_probe()
221 return PTR_ERR(usb3->phy); in bcm_ns_usb3_mdio_probe()
224 phy_set_drvdata(usb3->phy, usb3); in bcm_ns_usb3_mdio_probe()
243 MODULE_DESCRIPTION("Broadcom Northstar USB 3.0 PHY Driver");