Lines Matching +full:reg +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0
3 * ulpi.c - DesignWare USB3 Controller's ULPI PHY interface
24 static int dwc3_ulpi_busyloop(struct dwc3 *dwc, u8 addr, bool read) in dwc3_ulpi_busyloop() argument
28 u32 reg; in dwc3_ulpi_busyloop() local
30 if (addr >= ULPI_EXT_VENDOR_SPECIFIC) in dwc3_ulpi_busyloop()
36 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); in dwc3_ulpi_busyloop()
37 if (reg & DWC3_GUSB2PHYCFG_SUSPHY) in dwc3_ulpi_busyloop()
40 while (count--) { in dwc3_ulpi_busyloop()
42 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYACC(0)); in dwc3_ulpi_busyloop()
43 if (reg & DWC3_GUSB2PHYACC_DONE) in dwc3_ulpi_busyloop()
48 return -ETIMEDOUT; in dwc3_ulpi_busyloop()
51 static int dwc3_ulpi_read(struct device *dev, u8 addr) in dwc3_ulpi_read() argument
54 u32 reg; in dwc3_ulpi_read() local
57 reg = DWC3_GUSB2PHYACC_NEWREGREQ | DWC3_ULPI_ADDR(addr); in dwc3_ulpi_read()
58 dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg); in dwc3_ulpi_read()
60 ret = dwc3_ulpi_busyloop(dwc, addr, true); in dwc3_ulpi_read()
64 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYACC(0)); in dwc3_ulpi_read()
66 return DWC3_GUSB2PHYACC_DATA(reg); in dwc3_ulpi_read()
69 static int dwc3_ulpi_write(struct device *dev, u8 addr, u8 val) in dwc3_ulpi_write() argument
72 u32 reg; in dwc3_ulpi_write() local
74 reg = DWC3_GUSB2PHYACC_NEWREGREQ | DWC3_ULPI_ADDR(addr); in dwc3_ulpi_write()
75 reg |= DWC3_GUSB2PHYACC_WRITE | val; in dwc3_ulpi_write()
76 dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg); in dwc3_ulpi_write()
78 return dwc3_ulpi_busyloop(dwc, addr, false); in dwc3_ulpi_write()
89 dwc->ulpi = ulpi_register_interface(dwc->dev, &dwc3_ulpi_ops); in dwc3_ulpi_init()
90 if (IS_ERR(dwc->ulpi)) { in dwc3_ulpi_init()
91 dev_err(dwc->dev, "failed to register ULPI interface"); in dwc3_ulpi_init()
92 return PTR_ERR(dwc->ulpi); in dwc3_ulpi_init()
100 if (dwc->ulpi) { in dwc3_ulpi_exit()
101 ulpi_unregister_interface(dwc->ulpi); in dwc3_ulpi_exit()
102 dwc->ulpi = NULL; in dwc3_ulpi_exit()