Lines Matching +full:drv +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
13 #include "phy-samsung-usb2.h"
16 #define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0
17 #define EXYNOS_5250_REFCLKSEL_XO 0x1
18 #define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2
20 #define EXYNOS_5250_FSEL_9MHZ6 0x0
21 #define EXYNOS_5250_FSEL_10MHZ 0x1
22 #define EXYNOS_5250_FSEL_12MHZ 0x2
23 #define EXYNOS_5250_FSEL_19MHZ2 0x3
24 #define EXYNOS_5250_FSEL_20MHZ 0x4
25 #define EXYNOS_5250_FSEL_24MHZ 0x5
26 #define EXYNOS_5250_FSEL_50MHZ 0x7
29 #define EXYNOS_5250_HOSTPHYCTRL0 0x0
34 (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
37 (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
41 #define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK (0x3 << 7)
42 #define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL (0x0 << 7)
43 #define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7)
44 #define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7)
51 #define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRST BIT(0)
54 #define EXYNOS_5250_HSICPHYCTRL1 0x10
55 #define EXYNOS_5250_HSICPHYCTRL2 0x20
57 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKSEL_MASK (0x3 << 23)
58 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKSEL_DEFAULT (0x2 << 23)
59 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_MASK (0x7f << 16)
60 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_12 (0x24 << 16)
61 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_15 (0x1c << 16)
62 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_16 (0x1a << 16)
63 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_19_2 (0x15 << 16)
64 #define EXYNOS_5250_HSICPHYCTRLX_REFCLKDIV_20 (0x14 << 16)
70 #define EXYNOS_5250_HSICPHYCTRLX_PHYSWRST BIT(0)
73 #define EXYNOS_5250_HOSTEHCICTRL 0x30
81 (0x3f << EXYNOS_5250_HOSTEHCICTRL_FLADJVAL0_SHIFT)
84 (0x3f << EXYNOS_5250_HOSTEHCICTRL_FLADJVAL1_SHIFT)
87 (0x3f << EXYNOS_5250_HOSTEHCICTRL_FLADJVAL0_SHIFT)
90 (0x1 << EXYNOS_5250_HOSTEHCICTRL_FLADJVALHOST_SHIFT)
91 #define EXYNOS_5250_HOSTEHCICTRL_SIMULATIONMODE BIT(0)
94 #define EXYNOS_5250_HOSTOHCICTRL 0x34
97 (0x3ff << EXYNOS_5250_HOSTOHCICTRL_FRAMELENVAL_SHIFT)
98 #define EXYNOS_5250_HOSTOHCICTRL_FRAMELENVALEN BIT(0)
101 #define EXYNOS_5250_USBOTGSYS 0x38
107 (0x3 << EXYNOS_5250_USBOTGSYS_REFCLKSEL_SHIFT)
112 (0x3 << EXYNOS_5250_USBOTGSYS_FSEL_SHIFT)
116 #define EXYNOS_5250_USBOTGSYS_FORCE_SUSPEND BIT(0)
119 #define EXYNOS_5250_USB_ISOL_OTG_OFFSET 0x704
120 #define EXYNOS_5250_USB_ISOL_HOST_OFFSET 0x708
121 #define EXYNOS_5420_USB_ISOL_HOST_OFFSET 0x70C
122 #define EXYNOS_5250_USB_ISOL_ENABLE BIT(0)
125 #define EXYNOS_5250_MODE_SWITCH_OFFSET 0x230
127 #define EXYNOS_5250_MODE_SWITCH_DEVICE 0
168 return -EINVAL; in exynos5250_rate_to_clk()
171 return 0; in exynos5250_rate_to_clk()
176 struct samsung_usb2_phy_driver *drv = inst->drv; in exynos5250_isol() local
180 if (drv->cfg == &exynos5250_usb2_phy_config && in exynos5250_isol()
181 inst->cfg->id == EXYNOS5250_DEVICE) in exynos5250_isol()
183 else if (drv->cfg == &exynos5250_usb2_phy_config && in exynos5250_isol()
184 inst->cfg->id == EXYNOS5250_HOST) in exynos5250_isol()
186 else if (drv->cfg == &exynos5420_usb2_phy_config && in exynos5250_isol()
187 inst->cfg->id == EXYNOS5250_HOST) in exynos5250_isol()
192 regmap_update_bits(drv->reg_pmu, offset, mask, on ? 0 : mask); in exynos5250_isol()
197 struct samsung_usb2_phy_driver *drv = inst->drv; in exynos5250_power_on() local
204 switch (inst->cfg->id) { in exynos5250_power_on()
206 regmap_update_bits(drv->reg_sys, in exynos5250_power_on()
212 otg = readl(drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_on()
215 otg |= drv->ref_reg_val << EXYNOS_5250_USBOTGSYS_FSEL_SHIFT; in exynos5250_power_on()
228 writel(otg, drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_on()
234 writel(otg, drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_on()
242 ctrl0 = readl(drv->reg_phy + EXYNOS_5250_HOSTPHYCTRL0); in exynos5250_power_on()
245 ctrl0 |= drv->ref_reg_val << in exynos5250_power_on()
257 writel(ctrl0, drv->reg_phy + EXYNOS_5250_HOSTPHYCTRL0); in exynos5250_power_on()
261 writel(ctrl0, drv->reg_phy + EXYNOS_5250_HOSTPHYCTRL0); in exynos5250_power_on()
264 otg = readl(drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_on()
267 otg |= drv->ref_reg_val << EXYNOS_5250_USBOTGSYS_FSEL_SHIFT; in exynos5250_power_on()
280 writel(otg, drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_on()
290 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL1); in exynos5250_power_on()
291 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL2); in exynos5250_power_on()
294 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL1); in exynos5250_power_on()
295 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL2); in exynos5250_power_on()
301 ehci = readl(drv->reg_phy + EXYNOS_5250_HOSTEHCICTRL); in exynos5250_power_on()
306 writel(ehci, drv->reg_phy + EXYNOS_5250_HOSTEHCICTRL); in exynos5250_power_on()
309 ohci = readl(drv->reg_phy + EXYNOS_5250_HOSTOHCICTRL); in exynos5250_power_on()
311 ohci |= 0x1 << 3; in exynos5250_power_on()
312 writel(ohci, drv->reg_phy + EXYNOS_5250_HOSTOHCICTRL); in exynos5250_power_on()
316 exynos5250_isol(inst, 0); in exynos5250_power_on()
318 return 0; in exynos5250_power_on()
323 struct samsung_usb2_phy_driver *drv = inst->drv; in exynos5250_power_off() local
330 switch (inst->cfg->id) { in exynos5250_power_off()
332 otg = readl(drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_off()
336 writel(otg, drv->reg_phy + EXYNOS_5250_USBOTGSYS); in exynos5250_power_off()
339 ctrl0 = readl(drv->reg_phy + EXYNOS_5250_HOSTPHYCTRL0); in exynos5250_power_off()
345 writel(ctrl0, drv->reg_phy + EXYNOS_5250_HOSTPHYCTRL0); in exynos5250_power_off()
355 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL1); in exynos5250_power_off()
356 writel(hsic, drv->reg_phy + EXYNOS_5250_HSICPHYCTRL2); in exynos5250_power_off()
360 return 0; in exynos5250_power_off()