Lines Matching refs:rport
449 struct rockchip_usb2phy_port *rport,
454 ret = property_enable(rphy->grf, &rport->port_cfg->disfall_clr, true);
458 ret = property_enable(rphy->grf, &rport->port_cfg->disfall_en, en);
462 ret = property_enable(rphy->grf, &rport->port_cfg->disrise_clr, true);
466 return property_enable(rphy->grf, &rport->port_cfg->disrise_en, en);
471 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
475 mutex_lock(&rport->mutex);
477 if (rport->port_id == USB2PHY_PORT_OTG) {
478 if (rport->mode != USB_DR_MODE_HOST &&
479 rport->mode != USB_DR_MODE_UNKNOWN) {
482 &rport->port_cfg->bvalid_det_clr,
488 &rport->port_cfg->bvalid_det_en,
495 &rport->port_cfg->id_det_clr,
501 &rport->port_cfg->id_det_en,
506 schedule_delayed_work(&rport->otg_sm_work,
510 dev_dbg(&rport->phy->dev, "mode %d\n", rport->mode);
512 } else if (rport->port_id == USB2PHY_PORT_HOST) {
513 if (rport->port_cfg->disfall_en.offset) {
514 rport->host_disconnect = true;
515 ret = rockchip_usb2phy_enable_host_disc_irq(rphy, rport, true);
524 &rport->port_cfg->ls_det_clr, true);
529 &rport->port_cfg->ls_det_en, true);
533 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
537 mutex_unlock(&rport->mutex);
543 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
548 dev_dbg(&rport->phy->dev, "port power on\n");
550 if (!rport->suspended)
557 ret = property_enable(base, &rport->port_cfg->phy_sus, false);
578 rport->suspended = false;
584 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
589 dev_dbg(&rport->phy->dev, "port power off\n");
591 if (rport->suspended)
594 ret = property_enable(base, &rport->port_cfg->phy_sus, true);
598 rport->suspended = true;
606 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
608 if (rport->port_id == USB2PHY_PORT_OTG &&
609 rport->mode != USB_DR_MODE_HOST &&
610 rport->mode != USB_DR_MODE_UNKNOWN) {
611 cancel_delayed_work_sync(&rport->otg_sm_work);
612 cancel_delayed_work_sync(&rport->chg_work);
613 } else if (rport->port_id == USB2PHY_PORT_HOST)
614 cancel_delayed_work_sync(&rport->sm_work);
629 struct rockchip_usb2phy_port *rport =
632 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
638 &rport->port_cfg->utmi_bvalid);
643 dev_dbg(&rport->phy->dev, "%s otg sm work\n",
644 usb_otg_state_string(rport->state));
646 switch (rport->state) {
648 rport->state = OTG_STATE_B_IDLE;
650 rockchip_usb2phy_power_off(rport->phy);
654 dev_dbg(&rport->phy->dev, "usb otg host connect\n");
655 rport->state = OTG_STATE_A_HOST;
656 rockchip_usb2phy_power_on(rport->phy);
659 dev_dbg(&rport->phy->dev, "vbus_attach\n");
662 schedule_delayed_work(&rport->chg_work, 0);
667 dev_dbg(&rport->phy->dev, "sdp cable is connected\n");
668 rockchip_usb2phy_power_on(rport->phy);
669 rport->state = OTG_STATE_B_PERIPHERAL;
675 dev_dbg(&rport->phy->dev, "dcp cable is connected\n");
676 rockchip_usb2phy_power_off(rport->phy);
682 dev_dbg(&rport->phy->dev, "cdp cable is connected\n");
683 rockchip_usb2phy_power_on(rport->phy);
684 rport->state = OTG_STATE_B_PERIPHERAL;
702 if (rport->vbus_attached != vbus_attach) {
703 rport->vbus_attached = vbus_attach;
717 dev_dbg(&rport->phy->dev, "usb disconnect\n");
720 rport->state = OTG_STATE_B_IDLE;
722 rockchip_usb2phy_power_off(rport->phy);
728 dev_dbg(&rport->phy->dev, "usb otg host disconnect\n");
729 rport->state = OTG_STATE_B_IDLE;
730 rockchip_usb2phy_power_off(rport->phy);
738 schedule_delayed_work(&rport->otg_sm_work, delay);
788 struct rockchip_usb2phy_port *rport =
790 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
795 dev_dbg(&rport->phy->dev, "chg detection work state = %d\n",
799 if (!rport->suspended)
800 rockchip_usb2phy_power_off(rport->phy);
866 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
867 dev_dbg(&rport->phy->dev, "charger = %s\n",
874 schedule_delayed_work(&rport->chg_work, delay);
892 struct rockchip_usb2phy_port *rport =
894 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
899 mutex_lock(&rport->mutex);
901 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_ls.offset, &ul);
905 ul_mask = GENMASK(rport->port_cfg->utmi_ls.bitend,
906 rport->port_cfg->utmi_ls.bitstart);
908 if (rport->port_cfg->utmi_hstdet.offset) {
909 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_hstdet.offset, &uhd);
913 uhd_mask = GENMASK(rport->port_cfg->utmi_hstdet.bitend,
914 rport->port_cfg->utmi_hstdet.bitstart);
916 sh = rport->port_cfg->utmi_hstdet.bitend -
917 rport->port_cfg->utmi_hstdet.bitstart + 1;
919 state = ((uhd & uhd_mask) >> rport->port_cfg->utmi_hstdet.bitstart) |
920 (((ul & ul_mask) >> rport->port_cfg->utmi_ls.bitstart) << sh);
922 state = ((ul & ul_mask) >> rport->port_cfg->utmi_ls.bitstart) << 1 |
923 rport->host_disconnect;
928 dev_dbg(&rport->phy->dev, "HS online\n");
940 if (!rport->suspended) {
942 dev_dbg(&rport->phy->dev, "FS/LS online\n");
947 if (rport->suspended) {
948 dev_dbg(&rport->phy->dev, "Connected\n");
949 rockchip_usb2phy_power_on(rport->phy);
950 rport->suspended = false;
953 dev_dbg(&rport->phy->dev, "FS/LS online\n");
957 if (!rport->suspended) {
958 dev_dbg(&rport->phy->dev, "Disconnected\n");
959 rockchip_usb2phy_power_off(rport->phy);
960 rport->suspended = true;
967 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
968 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, true);
974 mutex_unlock(&rport->mutex);
977 dev_dbg(&rport->phy->dev, "unknown phy state\n");
982 mutex_unlock(&rport->mutex);
983 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
988 struct rockchip_usb2phy_port *rport = data;
989 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
991 if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st))
994 mutex_lock(&rport->mutex);
997 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, false);
998 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
1000 mutex_unlock(&rport->mutex);
1007 if (rport->suspended && rport->port_id == USB2PHY_PORT_HOST)
1008 rockchip_usb2phy_sm_work(&rport->sm_work.work);
1015 struct rockchip_usb2phy_port *rport = data;
1016 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1018 if (!property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
1022 property_enable(rphy->grf, &rport->port_cfg->bvalid_det_clr, true);
1024 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
1031 struct rockchip_usb2phy_port *rport = data;
1032 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1035 if (!property_enabled(rphy->grf, &rport->port_cfg->id_det_st))
1039 property_enable(rphy->grf, &rport->port_cfg->id_det_clr, true);
1041 id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
1059 struct rockchip_usb2phy_port *rport = data;
1060 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1062 if (!property_enabled(rphy->grf, &rport->port_cfg->disfall_st) &&
1063 !property_enabled(rphy->grf, &rport->port_cfg->disrise_st))
1066 mutex_lock(&rport->mutex);
1069 if (property_enabled(rphy->grf, &rport->port_cfg->disfall_st)) {
1070 property_enable(rphy->grf, &rport->port_cfg->disfall_clr, true);
1071 rport->host_disconnect = false;
1072 } else if (property_enabled(rphy->grf, &rport->port_cfg->disrise_st)) {
1073 property_enable(rphy->grf, &rport->port_cfg->disrise_clr, true);
1074 rport->host_disconnect = true;
1077 mutex_unlock(&rport->mutex);
1085 struct rockchip_usb2phy_port *rport;
1090 rport = &rphy->ports[index];
1091 if (!rport->phy)
1094 if (rport->port_id == USB2PHY_PORT_HOST &&
1095 rport->port_cfg->disfall_en.offset)
1096 ret |= rockchip_usb2phy_host_disc_irq(irq, rport);
1098 switch (rport->port_id) {
1100 if (rport->mode != USB_DR_MODE_HOST &&
1101 rport->mode != USB_DR_MODE_UNKNOWN)
1102 ret |= rockchip_usb2phy_otg_mux_irq(irq, rport);
1105 ret |= rockchip_usb2phy_linestate_irq(irq, rport);
1114 struct rockchip_usb2phy_port *rport,
1126 switch (rport->port_id) {
1128 rport->ls_irq = of_irq_get_byname(child_np, "linestate");
1129 if (rport->ls_irq < 0) {
1131 return rport->ls_irq;
1134 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL,
1137 "rockchip_usb2phy", rport);
1149 rport->otg_mux_irq = of_irq_get_byname(child_np, "otg-mux");
1150 if (rport->otg_mux_irq > 0) {
1151 ret = devm_request_threaded_irq(rphy->dev, rport->otg_mux_irq,
1156 rport);
1163 rport->bvalid_irq = of_irq_get_byname(child_np, "otg-bvalid");
1164 if (rport->bvalid_irq < 0) {
1166 ret = rport->bvalid_irq;
1170 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq,
1175 rport);
1182 rport->id_irq = of_irq_get_byname(child_np, "otg-id");
1183 if (rport->id_irq < 0) {
1185 ret = rport->id_irq;
1189 ret = devm_request_threaded_irq(rphy->dev, rport->id_irq,
1194 rport);
1210 struct rockchip_usb2phy_port *rport,
1215 rport->port_id = USB2PHY_PORT_HOST;
1216 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST];
1217 rport->suspended = true;
1219 mutex_init(&rport->mutex);
1220 INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work);
1222 ret = rockchip_usb2phy_port_irq_init(rphy, rport, child_np);
1234 struct rockchip_usb2phy_port *rport =
1237 schedule_delayed_work(&rport->otg_sm_work, OTG_SCHEDULE_DELAY);
1243 struct rockchip_usb2phy_port *rport,
1248 rport->port_id = USB2PHY_PORT_OTG;
1249 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
1250 rport->state = OTG_STATE_UNDEFINED;
1258 rport->suspended = true;
1259 rport->vbus_attached = false;
1261 mutex_init(&rport->mutex);
1263 rport->mode = of_usb_get_dr_mode_by_phy(child_np, -1);
1264 if (rport->mode == USB_DR_MODE_HOST ||
1265 rport->mode == USB_DR_MODE_UNKNOWN) {
1270 INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
1271 INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work);
1273 ret = rockchip_usb2phy_port_irq_init(rphy, rport, child_np);
1280 rport->event_nb.notifier_call = rockchip_otg_event;
1283 EXTCON_USB_HOST, &rport->event_nb);
1291 id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
1408 struct rockchip_usb2phy_port *rport = &rphy->ports[index];
1423 rport->phy = phy;
1424 phy_set_drvdata(rport->phy, rport);
1428 ret = rockchip_usb2phy_host_port_init(rphy, rport,
1433 ret = rockchip_usb2phy_otg_port_init(rphy, rport,