Lines Matching refs:rport

405 	struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
409 mutex_lock(&rport->mutex);
411 if (rport->port_id == USB2PHY_PORT_OTG) {
412 if (rport->mode != USB_DR_MODE_HOST &&
413 rport->mode != USB_DR_MODE_UNKNOWN) {
416 &rport->port_cfg->bvalid_det_clr,
422 &rport->port_cfg->bvalid_det_en,
427 schedule_delayed_work(&rport->otg_sm_work,
431 dev_dbg(&rport->phy->dev, "mode %d\n", rport->mode);
433 } else if (rport->port_id == USB2PHY_PORT_HOST) {
436 &rport->port_cfg->ls_det_clr, true);
441 &rport->port_cfg->ls_det_en, true);
445 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
449 mutex_unlock(&rport->mutex);
455 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
460 dev_dbg(&rport->phy->dev, "port power on\n");
462 if (!rport->suspended)
469 ret = property_enable(base, &rport->port_cfg->phy_sus, false);
478 rport->suspended = false;
484 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
489 dev_dbg(&rport->phy->dev, "port power off\n");
491 if (rport->suspended)
494 ret = property_enable(base, &rport->port_cfg->phy_sus, true);
498 rport->suspended = true;
506 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
508 if (rport->port_id == USB2PHY_PORT_OTG &&
509 rport->mode != USB_DR_MODE_HOST &&
510 rport->mode != USB_DR_MODE_UNKNOWN) {
511 cancel_delayed_work_sync(&rport->otg_sm_work);
512 cancel_delayed_work_sync(&rport->chg_work);
513 } else if (rport->port_id == USB2PHY_PORT_HOST)
514 cancel_delayed_work_sync(&rport->sm_work);
529 struct rockchip_usb2phy_port *rport =
532 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
538 &rport->port_cfg->utmi_bvalid);
543 dev_dbg(&rport->phy->dev, "%s otg sm work\n",
544 usb_otg_state_string(rport->state));
546 switch (rport->state) {
548 rport->state = OTG_STATE_B_IDLE;
550 rockchip_usb2phy_power_off(rport->phy);
554 dev_dbg(&rport->phy->dev, "usb otg host connect\n");
555 rport->state = OTG_STATE_A_HOST;
556 rockchip_usb2phy_power_on(rport->phy);
559 dev_dbg(&rport->phy->dev, "vbus_attach\n");
562 schedule_delayed_work(&rport->chg_work, 0);
567 dev_dbg(&rport->phy->dev, "sdp cable is connected\n");
568 rockchip_usb2phy_power_on(rport->phy);
569 rport->state = OTG_STATE_B_PERIPHERAL;
575 dev_dbg(&rport->phy->dev, "dcp cable is connected\n");
576 rockchip_usb2phy_power_off(rport->phy);
582 dev_dbg(&rport->phy->dev, "cdp cable is connected\n");
583 rockchip_usb2phy_power_on(rport->phy);
584 rport->state = OTG_STATE_B_PERIPHERAL;
602 if (rport->vbus_attached != vbus_attach) {
603 rport->vbus_attached = vbus_attach;
617 dev_dbg(&rport->phy->dev, "usb disconnect\n");
620 rport->state = OTG_STATE_B_IDLE;
622 rockchip_usb2phy_power_off(rport->phy);
628 dev_dbg(&rport->phy->dev, "usb otg host disconnect\n");
629 rport->state = OTG_STATE_B_IDLE;
630 rockchip_usb2phy_power_off(rport->phy);
638 schedule_delayed_work(&rport->otg_sm_work, delay);
688 struct rockchip_usb2phy_port *rport =
690 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
695 dev_dbg(&rport->phy->dev, "chg detection work state = %d\n",
699 if (!rport->suspended)
700 rockchip_usb2phy_power_off(rport->phy);
767 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
768 dev_dbg(&rport->phy->dev, "charger = %s\n",
775 schedule_delayed_work(&rport->chg_work, delay);
793 struct rockchip_usb2phy_port *rport =
795 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
796 unsigned int sh = rport->port_cfg->utmi_hstdet.bitend -
797 rport->port_cfg->utmi_hstdet.bitstart + 1;
802 mutex_lock(&rport->mutex);
804 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_ls.offset, &ul);
808 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_hstdet.offset, &uhd);
812 uhd_mask = GENMASK(rport->port_cfg->utmi_hstdet.bitend,
813 rport->port_cfg->utmi_hstdet.bitstart);
814 ul_mask = GENMASK(rport->port_cfg->utmi_ls.bitend,
815 rport->port_cfg->utmi_ls.bitstart);
818 state = ((uhd & uhd_mask) >> rport->port_cfg->utmi_hstdet.bitstart) |
819 (((ul & ul_mask) >> rport->port_cfg->utmi_ls.bitstart) << sh);
823 dev_dbg(&rport->phy->dev, "HS online\n");
835 if (!rport->suspended) {
837 dev_dbg(&rport->phy->dev, "FS/LS online\n");
842 if (rport->suspended) {
843 dev_dbg(&rport->phy->dev, "Connected\n");
844 rockchip_usb2phy_power_on(rport->phy);
845 rport->suspended = false;
848 dev_dbg(&rport->phy->dev, "FS/LS online\n");
852 if (!rport->suspended) {
853 dev_dbg(&rport->phy->dev, "Disconnected\n");
854 rockchip_usb2phy_power_off(rport->phy);
855 rport->suspended = true;
862 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
863 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, true);
869 mutex_unlock(&rport->mutex);
872 dev_dbg(&rport->phy->dev, "unknown phy state\n");
877 mutex_unlock(&rport->mutex);
878 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
883 struct rockchip_usb2phy_port *rport = data;
884 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
886 if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st))
889 mutex_lock(&rport->mutex);
892 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, false);
893 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
895 mutex_unlock(&rport->mutex);
902 if (rport->suspended && rport->port_id == USB2PHY_PORT_HOST)
903 rockchip_usb2phy_sm_work(&rport->sm_work.work);
910 struct rockchip_usb2phy_port *rport = data;
911 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
913 if (!property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
916 mutex_lock(&rport->mutex);
919 property_enable(rphy->grf, &rport->port_cfg->bvalid_det_clr, true);
921 mutex_unlock(&rport->mutex);
923 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
930 struct rockchip_usb2phy_port *rport = data;
931 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
933 if (property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
940 struct rockchip_usb2phy_port *rport,
945 rport->port_id = USB2PHY_PORT_HOST;
946 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST];
947 rport->suspended = true;
949 mutex_init(&rport->mutex);
950 INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work);
952 rport->ls_irq = of_irq_get_byname(child_np, "linestate");
953 if (rport->ls_irq < 0) {
955 return rport->ls_irq;
958 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL,
961 "rockchip_usb2phy", rport);
973 struct rockchip_usb2phy_port *rport =
976 schedule_delayed_work(&rport->otg_sm_work, OTG_SCHEDULE_DELAY);
982 struct rockchip_usb2phy_port *rport,
987 rport->port_id = USB2PHY_PORT_OTG;
988 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
989 rport->state = OTG_STATE_UNDEFINED;
997 rport->suspended = true;
998 rport->vbus_attached = false;
1000 mutex_init(&rport->mutex);
1002 rport->mode = of_usb_get_dr_mode_by_phy(child_np, -1);
1003 if (rport->mode == USB_DR_MODE_HOST ||
1004 rport->mode == USB_DR_MODE_UNKNOWN) {
1009 INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
1010 INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work);
1017 rport->otg_mux_irq = of_irq_get_byname(child_np, "otg-mux");
1018 if (rport->otg_mux_irq > 0) {
1019 ret = devm_request_threaded_irq(rphy->dev, rport->otg_mux_irq,
1024 rport);
1031 rport->bvalid_irq = of_irq_get_byname(child_np, "otg-bvalid");
1032 if (rport->bvalid_irq < 0) {
1034 ret = rport->bvalid_irq;
1038 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq,
1043 rport);
1052 rport->event_nb.notifier_call = rockchip_otg_event;
1055 EXTCON_USB_HOST, &rport->event_nb);
1152 struct rockchip_usb2phy_port *rport = &rphy->ports[index];
1167 rport->phy = phy;
1168 phy_set_drvdata(rport->phy, rport);
1172 ret = rockchip_usb2phy_host_port_init(rphy, rport,
1177 ret = rockchip_usb2phy_otg_port_init(rphy, rport,