Lines Matching refs:rphy

167 	int		(*phy_tuning)(struct rockchip_usb2phy *rphy);
168 int (*phy_lowpower)(struct rockchip_usb2phy *rphy, bool en);
284 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_prepare() local
289 if (!property_enabled(rphy->grf, &rphy->phy_cfg->clkout_ctl)) { in rockchip_usb2phy_clk480m_prepare()
290 ret = property_enable(rphy->grf, &rphy->phy_cfg->clkout_ctl, in rockchip_usb2phy_clk480m_prepare()
304 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_unprepare() local
308 property_enable(rphy->grf, &rphy->phy_cfg->clkout_ctl, false); in rockchip_usb2phy_clk480m_unprepare()
313 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_prepared() local
316 return property_enabled(rphy->grf, &rphy->phy_cfg->clkout_ctl); in rockchip_usb2phy_clk480m_prepared()
335 struct rockchip_usb2phy *rphy = data; in rockchip_usb2phy_clk480m_unregister() local
337 of_clk_del_provider(rphy->dev->of_node); in rockchip_usb2phy_clk480m_unregister()
338 clk_unregister(rphy->clk480m); in rockchip_usb2phy_clk480m_unregister()
342 rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy) in rockchip_usb2phy_clk480m_register() argument
344 struct device_node *node = rphy->dev->of_node; in rockchip_usb2phy_clk480m_register()
366 rphy->clk480m_hw.init = &init; in rockchip_usb2phy_clk480m_register()
369 rphy->clk480m = clk_register(rphy->dev, &rphy->clk480m_hw); in rockchip_usb2phy_clk480m_register()
370 if (IS_ERR(rphy->clk480m)) { in rockchip_usb2phy_clk480m_register()
371 ret = PTR_ERR(rphy->clk480m); in rockchip_usb2phy_clk480m_register()
375 ret = of_clk_add_provider(node, of_clk_src_simple_get, rphy->clk480m); in rockchip_usb2phy_clk480m_register()
379 ret = devm_add_action(rphy->dev, rockchip_usb2phy_clk480m_unregister, in rockchip_usb2phy_clk480m_register()
380 rphy); in rockchip_usb2phy_clk480m_register()
389 clk_unregister(rphy->clk480m); in rockchip_usb2phy_clk480m_register()
395 static int rockchip_usb2phy_enable_id_irq(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_enable_id_irq() argument
401 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_id_irq()
406 ret = property_enable(rphy->grf, &rport->port_cfg->idfall_det_en, en); in rockchip_usb2phy_enable_id_irq()
410 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_id_irq()
415 ret = property_enable(rphy->grf, &rport->port_cfg->idrise_det_en, en); in rockchip_usb2phy_enable_id_irq()
421 static int rockchip_usb2phy_enable_vbus_irq(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_enable_vbus_irq() argument
427 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_vbus_irq()
432 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_vbus_irq()
437 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_vbus_irq()
442 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_vbus_irq()
448 static int rockchip_usb2phy_enable_line_irq(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_enable_line_irq() argument
454 ret = property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true); in rockchip_usb2phy_enable_line_irq()
458 ret = property_enable(rphy->grf, &rport->port_cfg->ls_det_en, en); in rockchip_usb2phy_enable_line_irq()
464 rockchip_usb2phy_enable_disconn_irq(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_enable_disconn_irq() argument
470 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_disconn_irq()
475 ret = property_enable(rphy->grf, in rockchip_usb2phy_enable_disconn_irq()
481 static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy) in rockchip_usb2phy_extcon_register() argument
484 struct device_node *node = rphy->dev->of_node; in rockchip_usb2phy_extcon_register()
488 edev = extcon_get_edev_by_phandle(rphy->dev, 0); in rockchip_usb2phy_extcon_register()
491 dev_err(rphy->dev, in rockchip_usb2phy_extcon_register()
497 edev = devm_extcon_dev_allocate(rphy->dev, in rockchip_usb2phy_extcon_register()
503 ret = devm_extcon_dev_register(rphy->dev, edev); in rockchip_usb2phy_extcon_register()
505 dev_err(rphy->dev, in rockchip_usb2phy_extcon_register()
510 rphy->edev_self = true; in rockchip_usb2phy_extcon_register()
513 rphy->edev = edev; in rockchip_usb2phy_extcon_register()
521 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_init() local
528 ret = rockchip_usb2phy_enable_disconn_irq(rphy, rport, true); in rockchip_usb2phy_init()
530 dev_err(rphy->dev, "failed to enable disconnect irq\n"); in rockchip_usb2phy_init()
539 ret = rockchip_usb2phy_enable_line_irq(rphy, rport, true); in rockchip_usb2phy_init()
541 dev_err(rphy->dev, "failed to enable linestate irq\n"); in rockchip_usb2phy_init()
548 ret = rockchip_usb2phy_enable_vbus_irq(rphy, rport, true); in rockchip_usb2phy_init()
550 dev_err(rphy->dev, in rockchip_usb2phy_init()
556 property_enabled(rphy->grf, in rockchip_usb2phy_init()
563 ret = rockchip_usb2phy_enable_id_irq(rphy, rport, in rockchip_usb2phy_init()
566 dev_err(rphy->dev, in rockchip_usb2phy_init()
580 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_power_on() local
592 ret = property_enable(rphy->grf, &rport->port_cfg->phy_sus, false); in rockchip_usb2phy_power_on()
610 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_power_off() local
622 ret = property_enable(rphy->grf, &rport->port_cfg->phy_sus, true); in rockchip_usb2phy_power_off()
666 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_set_mode() local
678 extcon_set_state_sync(rphy->edev, EXTCON_USB_VBUS_EN, false); in rockchip_usb2phy_set_mode()
689 extcon_set_state_sync(rphy->edev, EXTCON_USB_VBUS_EN, true); in rockchip_usb2phy_set_mode()
704 struct rockchip_usb2phy *rphy = container_of(t, struct rockchip_usb2phy, in rv1126_wait_timer_fn() local
707 switch (rphy->cal_state) { in rv1126_wait_timer_fn()
710 writel(0x5d, rphy->base + 0x20); in rv1126_wait_timer_fn()
712 reg = readl(rphy->base + 0x10); in rv1126_wait_timer_fn()
715 gpiod_set_value(rphy->vup_gpio, 1); in rv1126_wait_timer_fn()
717 writel(0x08, rphy->base + 0x00); in rv1126_wait_timer_fn()
722 writel(0x7c, rphy->base + 0x10); in rv1126_wait_timer_fn()
725 hrtimer_forward_now(&rphy->wait_timer, delay); in rv1126_wait_timer_fn()
726 rphy->cal_state = CURRENT_COMPENSATION; in rv1126_wait_timer_fn()
731 gpiod_set_value(rphy->vup_gpio, 0); in rv1126_wait_timer_fn()
736 writel(0xe8, rphy->base + 0x00); in rv1126_wait_timer_fn()
738 writel(reg, rphy->base + 0x10); in rv1126_wait_timer_fn()
741 hrtimer_forward_now(&rphy->wait_timer, delay); in rv1126_wait_timer_fn()
742 rphy->cal_state = CALIBRATION_DONE; in rv1126_wait_timer_fn()
747 writel(0x4d, rphy->base + 0x20); in rv1126_wait_timer_fn()
760 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rv1126_usb2phy_calibrate() local
767 rphy->cal_state = SWING_CALIBRATION; in rv1126_usb2phy_calibrate()
768 hrtimer_start(&rphy->wait_timer, delay, HRTIMER_MODE_REL); in rv1126_usb2phy_calibrate()
796 static void rockchip_chg_detect(struct rockchip_usb2phy *rphy, in rockchip_chg_detect() argument
805 reset_control_assert(rphy->reset); in rockchip_chg_detect()
808 property_enable(rphy->grf, &rphy->phy_cfg->chg_det.chg_en, true); in rockchip_chg_detect()
809 property_enable(rphy->grf, &rphy->phy_cfg->chg_det.chg_rst, false); in rockchip_chg_detect()
814 chg_valid = property_enabled(rphy->grf, in rockchip_chg_detect()
815 &rphy->phy_cfg->chg_det.chg_valid); in rockchip_chg_detect()
817 property_enabled(rphy->grf, in rockchip_chg_detect()
818 &rphy->phy_cfg->chg_det.phy_connect); in rockchip_chg_detect()
827 rphy->chg_type = POWER_SUPPLY_TYPE_USB; in rockchip_chg_detect()
830 rphy->chg_type = POWER_SUPPLY_TYPE_USB_DCP; in rockchip_chg_detect()
833 rphy->chg_type = POWER_SUPPLY_TYPE_USB_CDP; in rockchip_chg_detect()
838 rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; in rockchip_chg_detect()
843 chg_to_string(rphy->chg_type)); in rockchip_chg_detect()
846 reset_control_deassert(rphy->reset); in rockchip_chg_detect()
851 property_enable(rphy->grf, &rphy->phy_cfg->chg_det.chg_rst, true); in rockchip_chg_detect()
852 property_enable(rphy->grf, &rphy->phy_cfg->chg_det.chg_en, false); in rockchip_chg_detect()
860 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_disconnect_irq() local
862 if (!property_enabled(rphy->grf, &rport->port_cfg->disconrise_det_st)) in rockchip_usb2phy_disconnect_irq()
868 property_enable(rphy->grf, &rport->port_cfg->disconrise_det_clr, true); in rockchip_usb2phy_disconnect_irq()
874 if (!property_enabled(rphy->grf, &rport->port_cfg->utmi_hostdet)) in rockchip_usb2phy_disconnect_irq()
880 rockchip_usb2phy_enable_line_irq(rphy, rport, true); in rockchip_usb2phy_disconnect_irq()
893 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_linestate_irq() local
895 if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st)) in rockchip_usb2phy_linestate_irq()
903 rockchip_usb2phy_enable_line_irq(rphy, rport, false); in rockchip_usb2phy_linestate_irq()
926 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_otg_sm_work() local
929 if (extcon_get_state(rphy->edev, EXTCON_USB_HOST) || in rockchip_usb2phy_otg_sm_work()
930 extcon_get_state(rphy->edev, EXTCON_USB_VBUS_EN) || in rockchip_usb2phy_otg_sm_work()
931 !property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig)) in rockchip_usb2phy_otg_sm_work()
937 rockchip_chg_detect(rphy, rport); in rockchip_usb2phy_otg_sm_work()
939 switch (rphy->chg_type) { in rockchip_usb2phy_otg_sm_work()
961 if (extcon_get_state(rphy->edev, EXTCON_CHG_USB_DCP) > 0) in rockchip_usb2phy_otg_sm_work()
962 extcon_set_state_sync(rphy->edev, EXTCON_CHG_USB_DCP, 0); in rockchip_usb2phy_otg_sm_work()
969 rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; in rockchip_usb2phy_otg_sm_work()
972 if (extcon_get_state(rphy->edev, cable) != rport->vbus_attached) { in rockchip_usb2phy_otg_sm_work()
973 extcon_set_state(rphy->edev, cable, rport->vbus_attached); in rockchip_usb2phy_otg_sm_work()
974 extcon_sync(rphy->edev, cable); in rockchip_usb2phy_otg_sm_work()
977 if (rphy->edev_self && (extcon_get_state(rphy->edev, EXTCON_USB) != in rockchip_usb2phy_otg_sm_work()
979 extcon_set_state(rphy->edev, EXTCON_USB, in rockchip_usb2phy_otg_sm_work()
982 extcon_sync(rphy->edev, EXTCON_USB); in rockchip_usb2phy_otg_sm_work()
983 extcon_sync(rphy->edev, EXTCON_USB_HOST); in rockchip_usb2phy_otg_sm_work()
992 struct rockchip_usb2phy *rphy = dev_get_drvdata(device); in otg_mode_show() local
996 for (index = 0; index < rphy->phy_cfg->num_ports; index++) { in otg_mode_show()
997 rport = &rphy->ports[index]; in otg_mode_show()
1003 dev_err(rphy->dev, "Fail to get otg port\n"); in otg_mode_show()
1006 dev_err(rphy->dev, "No support otg\n"); in otg_mode_show()
1030 struct rockchip_usb2phy *rphy = dev_get_drvdata(device); in otg_mode_store() local
1036 for (index = 0; index < rphy->phy_cfg->num_ports; index++) { in otg_mode_store()
1037 rport = &rphy->ports[index]; in otg_mode_store()
1043 dev_err(rphy->dev, "Fail to get otg port!\n"); in otg_mode_store()
1048 dev_err(rphy->dev, "No support otg!\n"); in otg_mode_store()
1062 dev_err(rphy->dev, "Error mode! Input 'otg' or 'host' or 'peripheral'\n"); in otg_mode_store()
1068 dev_warn(rphy->dev, "Same as current mode\n"); in otg_mode_store()
1077 extcon_set_state(rphy->edev, EXTCON_USB, false); in otg_mode_store()
1078 extcon_set_state(rphy->edev, EXTCON_USB_HOST, true); in otg_mode_store()
1079 extcon_sync(rphy->edev, EXTCON_USB); in otg_mode_store()
1080 extcon_sync(rphy->edev, EXTCON_USB_HOST); in otg_mode_store()
1082 property_enable(rphy->grf, &rport->port_cfg->idpullup, in otg_mode_store()
1084 property_enable(rphy->grf, &rport->port_cfg->iddig_output, in otg_mode_store()
1086 property_enable(rphy->grf, &rport->port_cfg->iddig_en, in otg_mode_store()
1091 property_enable(rphy->grf, &rport->port_cfg->idpullup, in otg_mode_store()
1093 property_enable(rphy->grf, &rport->port_cfg->iddig_output, in otg_mode_store()
1095 property_enable(rphy->grf, &rport->port_cfg->iddig_en, in otg_mode_store()
1100 property_enable(rphy->grf, &rport->port_cfg->iddig_output, in otg_mode_store()
1102 property_enable(rphy->grf, &rport->port_cfg->iddig_en, in otg_mode_store()
1111 rport->mode == USB_DR_MODE_OTG) && property_enabled(rphy->grf, in otg_mode_store()
1139 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_bvalid_irq() local
1141 if (!property_enabled(rphy->grf, &rport->port_cfg->bvalidfall_det_st) && in rockchip_usb2phy_bvalid_irq()
1142 !property_enabled(rphy->grf, &rport->port_cfg->bvalidrise_det_st)) in rockchip_usb2phy_bvalid_irq()
1148 if (property_enabled(rphy->grf, &rport->port_cfg->bvalidfall_det_st)) { in rockchip_usb2phy_bvalid_irq()
1149 property_enable(rphy->grf, &rport->port_cfg->bvalidfall_det_clr, in rockchip_usb2phy_bvalid_irq()
1152 } else if (property_enabled(rphy->grf, in rockchip_usb2phy_bvalid_irq()
1154 property_enable(rphy->grf, &rport->port_cfg->bvalidrise_det_clr, in rockchip_usb2phy_bvalid_irq()
1170 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_id_irq() local
1173 if (!property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st) && in rockchip_usb2phy_id_irq()
1174 !property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) in rockchip_usb2phy_id_irq()
1180 if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) { in rockchip_usb2phy_id_irq()
1181 property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr, in rockchip_usb2phy_id_irq()
1184 } else if (property_enabled(rphy->grf, in rockchip_usb2phy_id_irq()
1186 property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr, in rockchip_usb2phy_id_irq()
1193 extcon_set_state(rphy->edev, EXTCON_USB_HOST, cable_vbus_state); in rockchip_usb2phy_id_irq()
1194 extcon_set_state(rphy->edev, EXTCON_USB_VBUS_EN, cable_vbus_state); in rockchip_usb2phy_id_irq()
1196 extcon_sync(rphy->edev, EXTCON_USB_HOST); in rockchip_usb2phy_id_irq()
1197 extcon_sync(rphy->edev, EXTCON_USB_VBUS_EN); in rockchip_usb2phy_id_irq()
1206 static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_otg_port_init() argument
1216 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; in rockchip_usb2phy_otg_port_init()
1224 ret = rockchip_usb2phy_extcon_register(rphy); in rockchip_usb2phy_otg_port_init()
1245 property_enable(rphy->grf, &rport->port_cfg->bypass_otgsuspendm, in rockchip_usb2phy_otg_port_init()
1251 dev_err(rphy->dev, "no linestate irq provided\n"); in rockchip_usb2phy_otg_port_init()
1255 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL, in rockchip_usb2phy_otg_port_init()
1260 dev_err(rphy->dev, "failed to request linestate irq handle\n"); in rockchip_usb2phy_otg_port_init()
1266 if (rphy->edev_self) { in rockchip_usb2phy_otg_port_init()
1267 extcon_set_state(rphy->edev, EXTCON_USB, false); in rockchip_usb2phy_otg_port_init()
1268 extcon_set_state(rphy->edev, EXTCON_USB_HOST, true); in rockchip_usb2phy_otg_port_init()
1277 property_enable(rphy->grf, &rport->port_cfg->idpullup, false); in rockchip_usb2phy_otg_port_init()
1283 dev_err(rphy->dev, "no disconnect irq provided\n"); in rockchip_usb2phy_otg_port_init()
1287 ret = devm_request_threaded_irq(rphy->dev, in rockchip_usb2phy_otg_port_init()
1293 dev_err(rphy->dev, in rockchip_usb2phy_otg_port_init()
1301 if (rphy->edev_self) { in rockchip_usb2phy_otg_port_init()
1304 dev_err(rphy->dev, "no otg id irq provided\n"); in rockchip_usb2phy_otg_port_init()
1308 ret = devm_request_threaded_irq(rphy->dev, in rockchip_usb2phy_otg_port_init()
1315 dev_err(rphy->dev, in rockchip_usb2phy_otg_port_init()
1320 iddig = property_enabled(rphy->grf, in rockchip_usb2phy_otg_port_init()
1323 extcon_set_state(rphy->edev, EXTCON_USB, false); in rockchip_usb2phy_otg_port_init()
1324 extcon_set_state(rphy->edev, EXTCON_USB_HOST, true); in rockchip_usb2phy_otg_port_init()
1325 extcon_set_state(rphy->edev, EXTCON_USB_VBUS_EN, true); in rockchip_usb2phy_otg_port_init()
1339 dev_err(rphy->dev, "no vbus valid irq provided\n"); in rockchip_usb2phy_otg_port_init()
1343 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq, in rockchip_usb2phy_otg_port_init()
1350 dev_err(rphy->dev, in rockchip_usb2phy_otg_port_init()
1363 ret = property_enable(rphy->grf, &rport->port_cfg->phy_sus, true); in rockchip_usb2phy_otg_port_init()
1374 static int rockchip_usb2phy_host_port_init(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_host_port_init() argument
1383 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST]; in rockchip_usb2phy_host_port_init()
1388 dev_err(rphy->dev, "no disconnect irq provided\n"); in rockchip_usb2phy_host_port_init()
1392 ret = devm_request_threaded_irq(rphy->dev, rport->disconnect_irq, NULL, in rockchip_usb2phy_host_port_init()
1397 dev_err(rphy->dev, "failed to request disconnect irq handle\n"); in rockchip_usb2phy_host_port_init()
1404 dev_err(rphy->dev, "no linestate irq provided\n"); in rockchip_usb2phy_host_port_init()
1408 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL, in rockchip_usb2phy_host_port_init()
1413 dev_err(rphy->dev, "failed to request linestate irq handle\n"); in rockchip_usb2phy_host_port_init()
1422 ret = property_enable(rphy->grf, &rport->port_cfg->phy_sus, true); in rockchip_usb2phy_host_port_init()
1437 struct rockchip_usb2phy *rphy; in rockchip_usb2phy_probe() local
1445 rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL); in rockchip_usb2phy_probe()
1446 if (!rphy) in rockchip_usb2phy_probe()
1455 rphy->base = devm_ioremap_resource(dev, res); in rockchip_usb2phy_probe()
1456 if (IS_ERR(rphy->base)) { in rockchip_usb2phy_probe()
1458 return PTR_ERR(rphy->base); in rockchip_usb2phy_probe()
1461 rphy->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_usb2phy_probe()
1462 if (IS_ERR(rphy->grf)) in rockchip_usb2phy_probe()
1463 return PTR_ERR(rphy->grf); in rockchip_usb2phy_probe()
1466 rphy->reset = devm_reset_control_get(dev, "u2phy"); in rockchip_usb2phy_probe()
1467 if (IS_ERR(rphy->reset)) in rockchip_usb2phy_probe()
1468 return PTR_ERR(rphy->reset); in rockchip_usb2phy_probe()
1470 rphy->vup_gpio = devm_gpiod_get_optional(dev, "vup", GPIOD_OUT_LOW); in rockchip_usb2phy_probe()
1471 if (IS_ERR(rphy->vup_gpio)) { in rockchip_usb2phy_probe()
1472 ret = PTR_ERR(rphy->vup_gpio); in rockchip_usb2phy_probe()
1477 reset_control_assert(rphy->reset); in rockchip_usb2phy_probe()
1479 reset_control_deassert(rphy->reset); in rockchip_usb2phy_probe()
1493 rphy->dev = dev; in rockchip_usb2phy_probe()
1500 rphy->phy_cfg = &phy_cfgs[index]; in rockchip_usb2phy_probe()
1505 if (!rphy->phy_cfg) { in rockchip_usb2phy_probe()
1511 rphy->num_clks = rphy->phy_cfg->num_clks; in rockchip_usb2phy_probe()
1513 rphy->clks = devm_kmemdup(dev, rphy->phy_cfg->clks, in rockchip_usb2phy_probe()
1514 rphy->num_clks * sizeof(struct clk_bulk_data), in rockchip_usb2phy_probe()
1517 if (!rphy->clks) in rockchip_usb2phy_probe()
1520 ret = devm_clk_bulk_get(dev, rphy->num_clks, rphy->clks); in rockchip_usb2phy_probe()
1524 rphy->num_clks = 0; in rockchip_usb2phy_probe()
1526 ret = clk_bulk_prepare_enable(rphy->num_clks, rphy->clks); in rockchip_usb2phy_probe()
1530 platform_set_drvdata(pdev, rphy); in rockchip_usb2phy_probe()
1532 if (rphy->phy_cfg->phy_tuning) { in rockchip_usb2phy_probe()
1533 ret = rphy->phy_cfg->phy_tuning(rphy); in rockchip_usb2phy_probe()
1540 struct rockchip_usb2phy_port *rport = &rphy->ports[index]; in rockchip_usb2phy_probe()
1548 if (rphy->vup_gpio && in rockchip_usb2phy_probe()
1552 hrtimer_init(&rphy->wait_timer, CLOCK_MONOTONIC, in rockchip_usb2phy_probe()
1554 rphy->wait_timer.function = &rv1126_wait_timer_fn; in rockchip_usb2phy_probe()
1569 ret = rockchip_usb2phy_host_port_init(rphy, rport, in rockchip_usb2phy_probe()
1574 ret = rockchip_usb2phy_otg_port_init(rphy, rport, in rockchip_usb2phy_probe()
1582 if (++index >= rphy->phy_cfg->num_ports) in rockchip_usb2phy_probe()
1597 ret = rockchip_usb2phy_clk480m_register(rphy); in rockchip_usb2phy_probe()
1604 device_init_wakeup(rphy->dev, true); in rockchip_usb2phy_probe()
1606 device_init_wakeup(rphy->dev, false); in rockchip_usb2phy_probe()
1613 clk_bulk_disable_unprepare(rphy->num_clks, rphy->clks); in rockchip_usb2phy_probe()
1621 struct rockchip_usb2phy *rphy = platform_get_drvdata(pdev); in rockchip_usb2phy_remove() local
1623 if (rphy->vup_gpio && in rockchip_usb2phy_remove()
1625 hrtimer_cancel(&rphy->wait_timer); in rockchip_usb2phy_remove()
1630 static int rv1126_usb2phy_tuning(struct rockchip_usb2phy *rphy) in rv1126_usb2phy_tuning() argument
1635 if (rphy->phy_cfg->reg == 0xff4c0000) { in rv1126_usb2phy_tuning()
1637 ret = regmap_write(rphy->grf, 0x1031c, 0x000f4240); in rv1126_usb2phy_tuning()
1642 ret = regmap_write(rphy->grf, 0x1027c, 0x0f0f0100); in rv1126_usb2phy_tuning()
1646 reg = readl(rphy->base + 0x10); in rv1126_usb2phy_tuning()
1648 writel(reg & ~BIT(2), rphy->base + 0x10); in rv1126_usb2phy_tuning()
1654 if (readl(rphy->base + 0x34) & BIT(4)) { in rv1126_usb2phy_tuning()
1655 dev_dbg(rphy->dev, "Rterm disconnected"); in rv1126_usb2phy_tuning()
1657 ret = readl_poll_timeout(rphy->base + 0x34, rcal, in rv1126_usb2phy_tuning()
1661 dev_err(rphy->dev, "Rterm calibration timeout"); in rv1126_usb2phy_tuning()
1668 writel(reg | BIT(2), rphy->base + 0x10); in rv1126_usb2phy_tuning()
1671 if (rphy->phy_cfg->reg == 0xff4c8000) { in rv1126_usb2phy_tuning()
1673 ret = regmap_write(rphy->grf, 0x1028c, 0x0f0f0100); in rv1126_usb2phy_tuning()
1678 ret = regmap_write(rphy->grf, 0x0000, 0x00040004); in rv1126_usb2phy_tuning()
1687 static int rv1126_usb2phy_low_power(struct rockchip_usb2phy *rphy, bool en) in rv1126_usb2phy_low_power() argument
1691 reg = readl(rphy->base + 0x20); in rv1126_usb2phy_low_power()
1694 writel(reg, rphy->base + 0x20); in rv1126_usb2phy_low_power()
1708 struct rockchip_usb2phy *rphy = dev_get_drvdata(dev); in rockchip_usb2phy_pm_suspend() local
1713 if (device_may_wakeup(rphy->dev)) in rockchip_usb2phy_pm_suspend()
1716 for (index = 0; index < rphy->phy_cfg->num_ports; index++) { in rockchip_usb2phy_pm_suspend()
1717 rport = &rphy->ports[index]; in rockchip_usb2phy_pm_suspend()
1725 property_enabled(rphy->grf, in rockchip_usb2phy_pm_suspend()
1727 ret = rockchip_usb2phy_enable_id_irq(rphy, rport, in rockchip_usb2phy_pm_suspend()
1731 dev_err(rphy->dev, in rockchip_usb2phy_pm_suspend()
1743 ret = rockchip_usb2phy_enable_line_irq(rphy, rport, true); in rockchip_usb2phy_pm_suspend()
1746 dev_err(rphy->dev, "failed to enable linestate irq\n"); in rockchip_usb2phy_pm_suspend()
1755 if (rphy->phy_cfg->phy_lowpower) in rockchip_usb2phy_pm_suspend()
1756 ret = rphy->phy_cfg->phy_lowpower(rphy, true); in rockchip_usb2phy_pm_suspend()
1764 struct rockchip_usb2phy *rphy = dev_get_drvdata(dev); in rockchip_usb2phy_pm_resume() local
1770 if (device_may_wakeup(rphy->dev)) in rockchip_usb2phy_pm_resume()
1774 if (rphy->phy_cfg->phy_lowpower) in rockchip_usb2phy_pm_resume()
1775 ret = rphy->phy_cfg->phy_lowpower(rphy, false); in rockchip_usb2phy_pm_resume()
1777 for (index = 0; index < rphy->phy_cfg->num_ports; index++) { in rockchip_usb2phy_pm_resume()
1778 rport = &rphy->ports[index]; in rockchip_usb2phy_pm_resume()
1785 iddig = property_enabled(rphy->grf, in rockchip_usb2phy_pm_resume()
1787 ret = rockchip_usb2phy_enable_id_irq(rphy, rport, in rockchip_usb2phy_pm_resume()
1791 dev_err(rphy->dev, in rockchip_usb2phy_pm_resume()
1800 extcon_set_state_sync(rphy->edev, in rockchip_usb2phy_pm_resume()
1803 extcon_set_state_sync(rphy->edev, in rockchip_usb2phy_pm_resume()