• Home
  • Raw
  • Download

Lines Matching refs:rphy

225 static inline struct regmap *get_reg_base(struct rockchip_usb2phy *rphy)  in get_reg_base()  argument
227 return rphy->usbgrf == NULL ? rphy->grf : rphy->usbgrf; in get_reg_base()
259 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_prepare() local
261 struct regmap *base = get_reg_base(rphy); in rockchip_usb2phy_clk480m_prepare()
265 if (!property_enabled(base, &rphy->phy_cfg->clkout_ctl)) { in rockchip_usb2phy_clk480m_prepare()
266 ret = property_enable(base, &rphy->phy_cfg->clkout_ctl, true); in rockchip_usb2phy_clk480m_prepare()
279 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_unprepare() local
281 struct regmap *base = get_reg_base(rphy); in rockchip_usb2phy_clk480m_unprepare()
284 property_enable(base, &rphy->phy_cfg->clkout_ctl, false); in rockchip_usb2phy_clk480m_unprepare()
289 struct rockchip_usb2phy *rphy = in rockchip_usb2phy_clk480m_prepared() local
291 struct regmap *base = get_reg_base(rphy); in rockchip_usb2phy_clk480m_prepared()
293 return property_enabled(base, &rphy->phy_cfg->clkout_ctl); in rockchip_usb2phy_clk480m_prepared()
312 struct rockchip_usb2phy *rphy = data; in rockchip_usb2phy_clk480m_unregister() local
314 of_clk_del_provider(rphy->dev->of_node); in rockchip_usb2phy_clk480m_unregister()
315 clk_unregister(rphy->clk480m); in rockchip_usb2phy_clk480m_unregister()
319 rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy) in rockchip_usb2phy_clk480m_register() argument
321 struct device_node *node = rphy->dev->of_node; in rockchip_usb2phy_clk480m_register()
333 if (rphy->clk) { in rockchip_usb2phy_clk480m_register()
334 clk_name = __clk_get_name(rphy->clk); in rockchip_usb2phy_clk480m_register()
342 rphy->clk480m_hw.init = &init; in rockchip_usb2phy_clk480m_register()
345 rphy->clk480m = clk_register(rphy->dev, &rphy->clk480m_hw); in rockchip_usb2phy_clk480m_register()
346 if (IS_ERR(rphy->clk480m)) { in rockchip_usb2phy_clk480m_register()
347 ret = PTR_ERR(rphy->clk480m); in rockchip_usb2phy_clk480m_register()
351 ret = of_clk_add_provider(node, of_clk_src_simple_get, rphy->clk480m); in rockchip_usb2phy_clk480m_register()
355 ret = devm_add_action(rphy->dev, rockchip_usb2phy_clk480m_unregister, in rockchip_usb2phy_clk480m_register()
356 rphy); in rockchip_usb2phy_clk480m_register()
365 clk_unregister(rphy->clk480m); in rockchip_usb2phy_clk480m_register()
370 static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy) in rockchip_usb2phy_extcon_register() argument
373 struct device_node *node = rphy->dev->of_node; in rockchip_usb2phy_extcon_register()
377 edev = extcon_get_edev_by_phandle(rphy->dev, 0); in rockchip_usb2phy_extcon_register()
380 dev_err(rphy->dev, "Invalid or missing extcon\n"); in rockchip_usb2phy_extcon_register()
385 edev = devm_extcon_dev_allocate(rphy->dev, in rockchip_usb2phy_extcon_register()
391 ret = devm_extcon_dev_register(rphy->dev, edev); in rockchip_usb2phy_extcon_register()
393 dev_err(rphy->dev, "failed to register extcon device\n"); in rockchip_usb2phy_extcon_register()
398 rphy->edev = edev; in rockchip_usb2phy_extcon_register()
406 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_init() local
415 ret = property_enable(rphy->grf, in rockchip_usb2phy_init()
421 ret = property_enable(rphy->grf, in rockchip_usb2phy_init()
435 ret = property_enable(rphy->grf, in rockchip_usb2phy_init()
440 ret = property_enable(rphy->grf, in rockchip_usb2phy_init()
456 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_power_on() local
457 struct regmap *base = get_reg_base(rphy); in rockchip_usb2phy_power_on()
465 ret = clk_prepare_enable(rphy->clk480m); in rockchip_usb2phy_power_on()
471 clk_disable_unprepare(rphy->clk480m); in rockchip_usb2phy_power_on()
485 struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent); in rockchip_usb2phy_power_off() local
486 struct regmap *base = get_reg_base(rphy); in rockchip_usb2phy_power_off()
499 clk_disable_unprepare(rphy->clk480m); in rockchip_usb2phy_power_off()
532 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_otg_sm_work() local
537 vbus_attach = property_enabled(rphy->grf, in rockchip_usb2phy_otg_sm_work()
553 if (extcon_get_state(rphy->edev, EXTCON_USB_HOST) > 0) { in rockchip_usb2phy_otg_sm_work()
560 switch (rphy->chg_state) { in rockchip_usb2phy_otg_sm_work()
565 switch (rphy->chg_type) { in rockchip_usb2phy_otg_sm_work()
598 rphy->chg_state = USB_CHG_STATE_UNDEFINED; in rockchip_usb2phy_otg_sm_work()
599 rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; in rockchip_usb2phy_otg_sm_work()
605 if (notify_charger && rphy->edev) { in rockchip_usb2phy_otg_sm_work()
606 extcon_set_state_sync(rphy->edev, in rockchip_usb2phy_otg_sm_work()
609 extcon_set_state_sync(rphy->edev, in rockchip_usb2phy_otg_sm_work()
618 rphy->chg_state = USB_CHG_STATE_UNDEFINED; in rockchip_usb2phy_otg_sm_work()
619 rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; in rockchip_usb2phy_otg_sm_work()
627 if (extcon_get_state(rphy->edev, EXTCON_USB_HOST) == 0) { in rockchip_usb2phy_otg_sm_work()
655 static void rockchip_chg_enable_dcd(struct rockchip_usb2phy *rphy, in rockchip_chg_enable_dcd() argument
658 struct regmap *base = get_reg_base(rphy); in rockchip_chg_enable_dcd()
660 property_enable(base, &rphy->phy_cfg->chg_det.rdm_pdwn_en, en); in rockchip_chg_enable_dcd()
661 property_enable(base, &rphy->phy_cfg->chg_det.idp_src_en, en); in rockchip_chg_enable_dcd()
664 static void rockchip_chg_enable_primary_det(struct rockchip_usb2phy *rphy, in rockchip_chg_enable_primary_det() argument
667 struct regmap *base = get_reg_base(rphy); in rockchip_chg_enable_primary_det()
669 property_enable(base, &rphy->phy_cfg->chg_det.vdp_src_en, en); in rockchip_chg_enable_primary_det()
670 property_enable(base, &rphy->phy_cfg->chg_det.idm_sink_en, en); in rockchip_chg_enable_primary_det()
673 static void rockchip_chg_enable_secondary_det(struct rockchip_usb2phy *rphy, in rockchip_chg_enable_secondary_det() argument
676 struct regmap *base = get_reg_base(rphy); in rockchip_chg_enable_secondary_det()
678 property_enable(base, &rphy->phy_cfg->chg_det.vdm_src_en, en); in rockchip_chg_enable_secondary_det()
679 property_enable(base, &rphy->phy_cfg->chg_det.idp_sink_en, en); in rockchip_chg_enable_secondary_det()
690 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_chg_detect_work() local
691 struct regmap *base = get_reg_base(rphy); in rockchip_chg_detect_work()
696 rphy->chg_state); in rockchip_chg_detect_work()
697 switch (rphy->chg_state) { in rockchip_chg_detect_work()
702 property_enable(base, &rphy->phy_cfg->chg_det.opmode, false); in rockchip_chg_detect_work()
704 rockchip_chg_enable_dcd(rphy, true); in rockchip_chg_detect_work()
705 rphy->chg_state = USB_CHG_STATE_WAIT_FOR_DCD; in rockchip_chg_detect_work()
706 rphy->dcd_retries = 0; in rockchip_chg_detect_work()
711 is_dcd = property_enabled(rphy->grf, in rockchip_chg_detect_work()
712 &rphy->phy_cfg->chg_det.dp_det); in rockchip_chg_detect_work()
713 tmout = ++rphy->dcd_retries == CHG_DCD_MAX_RETRIES; in rockchip_chg_detect_work()
718 rockchip_chg_enable_dcd(rphy, false); in rockchip_chg_detect_work()
720 rockchip_chg_enable_primary_det(rphy, true); in rockchip_chg_detect_work()
722 rphy->chg_state = USB_CHG_STATE_DCD_DONE; in rockchip_chg_detect_work()
729 vout = property_enabled(rphy->grf, in rockchip_chg_detect_work()
730 &rphy->phy_cfg->chg_det.cp_det); in rockchip_chg_detect_work()
731 rockchip_chg_enable_primary_det(rphy, false); in rockchip_chg_detect_work()
734 rockchip_chg_enable_secondary_det(rphy, true); in rockchip_chg_detect_work()
736 rphy->chg_state = USB_CHG_STATE_PRIMARY_DONE; in rockchip_chg_detect_work()
738 if (rphy->dcd_retries == CHG_DCD_MAX_RETRIES) { in rockchip_chg_detect_work()
740 rphy->chg_type = POWER_SUPPLY_TYPE_USB_DCP; in rockchip_chg_detect_work()
741 rphy->chg_state = USB_CHG_STATE_DETECTED; in rockchip_chg_detect_work()
744 rphy->chg_type = POWER_SUPPLY_TYPE_USB; in rockchip_chg_detect_work()
745 rphy->chg_state = USB_CHG_STATE_DETECTED; in rockchip_chg_detect_work()
751 vout = property_enabled(rphy->grf, in rockchip_chg_detect_work()
752 &rphy->phy_cfg->chg_det.dcp_det); in rockchip_chg_detect_work()
754 rockchip_chg_enable_secondary_det(rphy, false); in rockchip_chg_detect_work()
756 rphy->chg_type = POWER_SUPPLY_TYPE_USB_DCP; in rockchip_chg_detect_work()
758 rphy->chg_type = POWER_SUPPLY_TYPE_USB_CDP; in rockchip_chg_detect_work()
761 rphy->chg_state = USB_CHG_STATE_DETECTED; in rockchip_chg_detect_work()
766 property_enable(base, &rphy->phy_cfg->chg_det.opmode, true); in rockchip_chg_detect_work()
769 chg_to_string(rphy->chg_type)); in rockchip_chg_detect_work()
795 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_sm_work() local
804 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_ls.offset, &ul); in rockchip_usb2phy_sm_work()
808 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_hstdet.offset, &uhd); in rockchip_usb2phy_sm_work()
862 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true); in rockchip_usb2phy_sm_work()
863 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, true); in rockchip_usb2phy_sm_work()
884 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_linestate_irq() local
886 if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st)) in rockchip_usb2phy_linestate_irq()
892 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, false); in rockchip_usb2phy_linestate_irq()
893 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true); in rockchip_usb2phy_linestate_irq()
911 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_bvalid_irq() local
913 if (!property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st)) in rockchip_usb2phy_bvalid_irq()
919 property_enable(rphy->grf, &rport->port_cfg->bvalid_det_clr, true); in rockchip_usb2phy_bvalid_irq()
931 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent); in rockchip_usb2phy_otg_mux_irq() local
933 if (property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st)) in rockchip_usb2phy_otg_mux_irq()
939 static int rockchip_usb2phy_host_port_init(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_host_port_init() argument
946 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST]; in rockchip_usb2phy_host_port_init()
954 dev_err(rphy->dev, "no linestate irq provided\n"); in rockchip_usb2phy_host_port_init()
958 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL, in rockchip_usb2phy_host_port_init()
963 dev_err(rphy->dev, "failed to request linestate irq handle\n"); in rockchip_usb2phy_host_port_init()
981 static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, in rockchip_usb2phy_otg_port_init() argument
988 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; in rockchip_usb2phy_otg_port_init()
1019 ret = devm_request_threaded_irq(rphy->dev, rport->otg_mux_irq, in rockchip_usb2phy_otg_port_init()
1026 dev_err(rphy->dev, in rockchip_usb2phy_otg_port_init()
1033 dev_err(rphy->dev, "no vbus valid irq provided\n"); in rockchip_usb2phy_otg_port_init()
1038 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq, in rockchip_usb2phy_otg_port_init()
1045 dev_err(rphy->dev, in rockchip_usb2phy_otg_port_init()
1051 if (!IS_ERR(rphy->edev)) { in rockchip_usb2phy_otg_port_init()
1054 ret = devm_extcon_register_notifier(rphy->dev, rphy->edev, in rockchip_usb2phy_otg_port_init()
1057 dev_err(rphy->dev, "register USB HOST notifier failed\n"); in rockchip_usb2phy_otg_port_init()
1070 struct rockchip_usb2phy *rphy; in rockchip_usb2phy_probe() local
1076 rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL); in rockchip_usb2phy_probe()
1077 if (!rphy) in rockchip_usb2phy_probe()
1089 rphy->grf = syscon_node_to_regmap(dev->parent->of_node); in rockchip_usb2phy_probe()
1090 if (IS_ERR(rphy->grf)) in rockchip_usb2phy_probe()
1091 return PTR_ERR(rphy->grf); in rockchip_usb2phy_probe()
1094 rphy->usbgrf = in rockchip_usb2phy_probe()
1097 if (IS_ERR(rphy->usbgrf)) in rockchip_usb2phy_probe()
1098 return PTR_ERR(rphy->usbgrf); in rockchip_usb2phy_probe()
1100 rphy->usbgrf = NULL; in rockchip_usb2phy_probe()
1109 rphy->dev = dev; in rockchip_usb2phy_probe()
1111 rphy->chg_state = USB_CHG_STATE_UNDEFINED; in rockchip_usb2phy_probe()
1112 rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; in rockchip_usb2phy_probe()
1113 platform_set_drvdata(pdev, rphy); in rockchip_usb2phy_probe()
1115 ret = rockchip_usb2phy_extcon_register(rphy); in rockchip_usb2phy_probe()
1123 rphy->phy_cfg = &phy_cfgs[index]; in rockchip_usb2phy_probe()
1130 if (!rphy->phy_cfg) { in rockchip_usb2phy_probe()
1136 rphy->clk = of_clk_get_by_name(np, "phyclk"); in rockchip_usb2phy_probe()
1137 if (!IS_ERR(rphy->clk)) { in rockchip_usb2phy_probe()
1138 clk_prepare_enable(rphy->clk); in rockchip_usb2phy_probe()
1141 rphy->clk = NULL; in rockchip_usb2phy_probe()
1144 ret = rockchip_usb2phy_clk480m_register(rphy); in rockchip_usb2phy_probe()
1152 struct rockchip_usb2phy_port *rport = &rphy->ports[index]; in rockchip_usb2phy_probe()
1172 ret = rockchip_usb2phy_host_port_init(rphy, rport, in rockchip_usb2phy_probe()
1177 ret = rockchip_usb2phy_otg_port_init(rphy, rport, in rockchip_usb2phy_probe()
1185 if (++index >= rphy->phy_cfg->num_ports) { in rockchip_usb2phy_probe()
1197 if (rphy->clk) { in rockchip_usb2phy_probe()
1198 clk_disable_unprepare(rphy->clk); in rockchip_usb2phy_probe()
1199 clk_put(rphy->clk); in rockchip_usb2phy_probe()