Lines Matching +full:sp7021 +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0
4 * Sunplus SP7021 USB 2.0 phy driver
8 * Note 1 : non-posted write command for the registers accesses of
9 * Sunplus SP7021.
18 #include <linux/nvmem-consumer.h>
22 #include <linux/reset.h>
86 cell = nvmem_cell_get(usbphy->dev, disc_name); in update_disc_vol()
88 if (PTR_ERR(cell) == -EPROBE_DEFER) in update_disc_vol()
89 return -EPROBE_DEFER; in update_disc_vol()
98 set = (set >> usbphy->disc_vol_addr_off) & J_DISC; in update_disc_vol()
104 val = readl(usbphy->phy_regs + CONFIG7); in update_disc_vol()
106 writel(val, usbphy->phy_regs + CONFIG7); in update_disc_vol()
117 ret = clk_prepare_enable(usbphy->phy_clk); in sp_uphy_init()
121 ret = reset_control_deassert(usbphy->rstc); in sp_uphy_init()
126 writel(HIGH_MASK_BITS | 0x4002, usbphy->moon4_regs + UPHY_CONTROL0); in sp_uphy_init()
127 writel(HIGH_MASK_BITS | 0x8747, usbphy->moon4_regs + UPHY_CONTROL1); in sp_uphy_init()
135 val = readl(usbphy->phy_regs + CONFIG9); in sp_uphy_init()
137 writel(val, usbphy->phy_regs + CONFIG9); in sp_uphy_init()
139 val = readl(usbphy->phy_regs + CONFIG1); in sp_uphy_init()
141 writel(val, usbphy->phy_regs + CONFIG1); in sp_uphy_init()
143 val = readl(usbphy->phy_regs + CONFIG23); in sp_uphy_init()
145 writel(val, usbphy->phy_regs + CONFIG23); in sp_uphy_init()
149 usbphy->moon4_regs + UPHY_CONTROL2); in sp_uphy_init()
153 usbphy->phy_regs + CONFIG16); in sp_uphy_init()
154 writel(IBG_TRIM0_SSLVHT | J_VDATREE_TRIM_DEFAULT, usbphy->phy_regs + CONFIG17); in sp_uphy_init()
157 writel(J_FORCE_DISC_ON | J_DEBUG_CTRL_ADDR_MACRO, usbphy->phy_regs + CONFIG3); in sp_uphy_init()
162 reset_control_assert(usbphy->rstc); in sp_uphy_init()
164 clk_disable_unprepare(usbphy->phy_clk); in sp_uphy_init()
175 pll_pwr_off = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) in sp_uphy_power_on()
177 pll_pwr_on = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) in sp_uphy_power_on()
181 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_on()
184 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_on()
187 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_on()
190 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_on()
193 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_on()
203 pll_pwr_off = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) in sp_uphy_power_off()
207 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_off()
210 usbphy->moon4_regs + UPHY_CONTROL3); in sp_uphy_power_off()
219 reset_control_assert(usbphy->rstc); in sp_uphy_exit()
220 clk_disable_unprepare(usbphy->phy_clk); in sp_uphy_exit()
233 {.compatible = "sunplus,sp7021-usb2-phy", },
245 usbphy = devm_kzalloc(&pdev->dev, sizeof(*usbphy), GFP_KERNEL); in sp_usb_phy_probe()
247 return -ENOMEM; in sp_usb_phy_probe()
249 usbphy->dev = &pdev->dev; in sp_usb_phy_probe()
251 usbphy->phy_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); in sp_usb_phy_probe()
252 usbphy->phy_regs = devm_ioremap_resource(&pdev->dev, usbphy->phy_res_mem); in sp_usb_phy_probe()
253 if (IS_ERR(usbphy->phy_regs)) in sp_usb_phy_probe()
254 return PTR_ERR(usbphy->phy_regs); in sp_usb_phy_probe()
256 usbphy->moon4_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "moon4"); in sp_usb_phy_probe()
257 if (!usbphy->moon4_res_mem) in sp_usb_phy_probe()
258 return -EINVAL; in sp_usb_phy_probe()
260 usbphy->moon4_regs = devm_ioremap(&pdev->dev, usbphy->moon4_res_mem->start, in sp_usb_phy_probe()
261 resource_size(usbphy->moon4_res_mem)); in sp_usb_phy_probe()
262 if (!usbphy->moon4_regs) in sp_usb_phy_probe()
263 return -ENOMEM; in sp_usb_phy_probe()
265 usbphy->phy_clk = devm_clk_get(&pdev->dev, NULL); in sp_usb_phy_probe()
266 if (IS_ERR(usbphy->phy_clk)) in sp_usb_phy_probe()
267 return PTR_ERR(usbphy->phy_clk); in sp_usb_phy_probe()
269 usbphy->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); in sp_usb_phy_probe()
270 if (IS_ERR(usbphy->rstc)) in sp_usb_phy_probe()
271 return PTR_ERR(usbphy->rstc); in sp_usb_phy_probe()
273 of_property_read_u32(pdev->dev.of_node, "sunplus,disc-vol-addr-off", in sp_usb_phy_probe()
274 &usbphy->disc_vol_addr_off); in sp_usb_phy_probe()
276 phy = devm_phy_create(&pdev->dev, NULL, &sp_uphy_ops); in sp_usb_phy_probe()
283 phy_provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate); in sp_usb_phy_probe()
291 .name = "sunplus-usb2-phy",