Lines Matching refs:rport

453 						 struct rockchip_usb2phy_port *rport,
458 ret = property_enable(rphy->grf, &rport->port_cfg->disfall_clr, true);
462 ret = property_enable(rphy->grf, &rport->port_cfg->disfall_en, en);
466 ret = property_enable(rphy->grf, &rport->port_cfg->disrise_clr, true);
470 return property_enable(rphy->grf, &rport->port_cfg->disrise_en, en);
475 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
479 mutex_lock(&rport->mutex);
481 if (rport->port_id == USB2PHY_PORT_OTG) {
482 if (rport->mode != USB_DR_MODE_HOST &&
483 rport->mode != USB_DR_MODE_UNKNOWN) {
486 &rport->port_cfg->bvalid_det_clr,
492 &rport->port_cfg->bvalid_det_en,
499 &rport->port_cfg->idfall_det_clr,
505 &rport->port_cfg->idrise_det_clr,
511 &rport->port_cfg->idfall_det_en,
517 &rport->port_cfg->idrise_det_en,
522 schedule_delayed_work(&rport->otg_sm_work,
526 dev_dbg(&rport->phy->dev, "mode %d\n", rport->mode);
528 } else if (rport->port_id == USB2PHY_PORT_HOST) {
529 if (rport->port_cfg->disfall_en.offset) {
530 rport->host_disconnect = true;
531 ret = rockchip_usb2phy_enable_host_disc_irq(rphy, rport, true);
540 &rport->port_cfg->ls_det_clr, true);
545 &rport->port_cfg->ls_det_en, true);
549 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
553 mutex_unlock(&rport->mutex);
559 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
564 dev_dbg(&rport->phy->dev, "port power on\n");
566 if (!rport->suspended)
573 ret = property_enable(base, &rport->port_cfg->phy_sus, false);
594 rport->suspended = false;
600 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
605 dev_dbg(&rport->phy->dev, "port power off\n");
607 if (rport->suspended)
610 ret = property_enable(base, &rport->port_cfg->phy_sus, true);
614 rport->suspended = true;
622 struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
624 if (rport->port_id == USB2PHY_PORT_OTG &&
625 rport->mode != USB_DR_MODE_HOST &&
626 rport->mode != USB_DR_MODE_UNKNOWN) {
627 cancel_delayed_work_sync(&rport->otg_sm_work);
628 cancel_delayed_work_sync(&rport->chg_work);
629 } else if (rport->port_id == USB2PHY_PORT_HOST)
630 cancel_delayed_work_sync(&rport->sm_work);
645 struct rockchip_usb2phy_port *rport =
648 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
654 &rport->port_cfg->utmi_bvalid);
659 dev_dbg(&rport->phy->dev, "%s otg sm work\n",
660 usb_otg_state_string(rport->state));
662 switch (rport->state) {
664 rport->state = OTG_STATE_B_IDLE;
666 rockchip_usb2phy_power_off(rport->phy);
670 dev_dbg(&rport->phy->dev, "usb otg host connect\n");
671 rport->state = OTG_STATE_A_HOST;
672 rockchip_usb2phy_power_on(rport->phy);
675 dev_dbg(&rport->phy->dev, "vbus_attach\n");
678 schedule_delayed_work(&rport->chg_work, 0);
683 dev_dbg(&rport->phy->dev, "sdp cable is connected\n");
684 rockchip_usb2phy_power_on(rport->phy);
685 rport->state = OTG_STATE_B_PERIPHERAL;
691 dev_dbg(&rport->phy->dev, "dcp cable is connected\n");
692 rockchip_usb2phy_power_off(rport->phy);
698 dev_dbg(&rport->phy->dev, "cdp cable is connected\n");
699 rockchip_usb2phy_power_on(rport->phy);
700 rport->state = OTG_STATE_B_PERIPHERAL;
718 if (rport->vbus_attached != vbus_attach) {
719 rport->vbus_attached = vbus_attach;
733 dev_dbg(&rport->phy->dev, "usb disconnect\n");
736 rport->state = OTG_STATE_B_IDLE;
738 rockchip_usb2phy_power_off(rport->phy);
744 dev_dbg(&rport->phy->dev, "usb otg host disconnect\n");
745 rport->state = OTG_STATE_B_IDLE;
746 rockchip_usb2phy_power_off(rport->phy);
754 schedule_delayed_work(&rport->otg_sm_work, delay);
804 struct rockchip_usb2phy_port *rport =
806 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
811 dev_dbg(&rport->phy->dev, "chg detection work state = %d\n",
815 if (!rport->suspended)
816 rockchip_usb2phy_power_off(rport->phy);
882 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
883 dev_dbg(&rport->phy->dev, "charger = %s\n",
890 schedule_delayed_work(&rport->chg_work, delay);
908 struct rockchip_usb2phy_port *rport =
910 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
915 mutex_lock(&rport->mutex);
917 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_ls.offset, &ul);
921 ul_mask = GENMASK(rport->port_cfg->utmi_ls.bitend,
922 rport->port_cfg->utmi_ls.bitstart);
924 if (rport->port_cfg->utmi_hstdet.offset) {
925 ret = regmap_read(rphy->grf, rport->port_cfg->utmi_hstdet.offset, &uhd);
929 uhd_mask = GENMASK(rport->port_cfg->utmi_hstdet.bitend,
930 rport->port_cfg->utmi_hstdet.bitstart);
932 sh = rport->port_cfg->utmi_hstdet.bitend -
933 rport->port_cfg->utmi_hstdet.bitstart + 1;
935 state = ((uhd & uhd_mask) >> rport->port_cfg->utmi_hstdet.bitstart) |
936 (((ul & ul_mask) >> rport->port_cfg->utmi_ls.bitstart) << sh);
938 state = ((ul & ul_mask) >> rport->port_cfg->utmi_ls.bitstart) << 1 |
939 rport->host_disconnect;
944 dev_dbg(&rport->phy->dev, "HS online\n");
956 if (!rport->suspended) {
958 dev_dbg(&rport->phy->dev, "FS/LS online\n");
963 if (rport->suspended) {
964 dev_dbg(&rport->phy->dev, "Connected\n");
965 rockchip_usb2phy_power_on(rport->phy);
966 rport->suspended = false;
969 dev_dbg(&rport->phy->dev, "FS/LS online\n");
973 if (!rport->suspended) {
974 dev_dbg(&rport->phy->dev, "Disconnected\n");
975 rockchip_usb2phy_power_off(rport->phy);
976 rport->suspended = true;
983 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
984 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, true);
990 mutex_unlock(&rport->mutex);
993 dev_dbg(&rport->phy->dev, "unknown phy state\n");
998 mutex_unlock(&rport->mutex);
999 schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
1004 struct rockchip_usb2phy_port *rport = data;
1005 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1007 if (!property_enabled(rphy->grf, &rport->port_cfg->ls_det_st))
1010 mutex_lock(&rport->mutex);
1013 property_enable(rphy->grf, &rport->port_cfg->ls_det_en, false);
1014 property_enable(rphy->grf, &rport->port_cfg->ls_det_clr, true);
1016 mutex_unlock(&rport->mutex);
1023 if (rport->suspended && rport->port_id == USB2PHY_PORT_HOST)
1024 rockchip_usb2phy_sm_work(&rport->sm_work.work);
1031 struct rockchip_usb2phy_port *rport = data;
1032 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1034 if (!property_enabled(rphy->grf, &rport->port_cfg->bvalid_det_st))
1038 property_enable(rphy->grf, &rport->port_cfg->bvalid_det_clr, true);
1040 rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
1047 struct rockchip_usb2phy_port *rport = data;
1048 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1051 if (!property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st) &&
1052 !property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st))
1056 if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st))
1057 property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr, true);
1059 if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st))
1060 property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr, true);
1062 id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
1080 struct rockchip_usb2phy_port *rport = data;
1081 struct rockchip_usb2phy *rphy = dev_get_drvdata(rport->phy->dev.parent);
1083 if (!property_enabled(rphy->grf, &rport->port_cfg->disfall_st) &&
1084 !property_enabled(rphy->grf, &rport->port_cfg->disrise_st))
1087 mutex_lock(&rport->mutex);
1090 if (property_enabled(rphy->grf, &rport->port_cfg->disfall_st)) {
1091 property_enable(rphy->grf, &rport->port_cfg->disfall_clr, true);
1092 rport->host_disconnect = false;
1093 } else if (property_enabled(rphy->grf, &rport->port_cfg->disrise_st)) {
1094 property_enable(rphy->grf, &rport->port_cfg->disrise_clr, true);
1095 rport->host_disconnect = true;
1098 mutex_unlock(&rport->mutex);
1106 struct rockchip_usb2phy_port *rport;
1111 rport = &rphy->ports[index];
1112 if (!rport->phy)
1115 if (rport->port_id == USB2PHY_PORT_HOST &&
1116 rport->port_cfg->disfall_en.offset)
1117 ret |= rockchip_usb2phy_host_disc_irq(irq, rport);
1119 switch (rport->port_id) {
1121 if (rport->mode != USB_DR_MODE_HOST &&
1122 rport->mode != USB_DR_MODE_UNKNOWN)
1123 ret |= rockchip_usb2phy_otg_mux_irq(irq, rport);
1126 ret |= rockchip_usb2phy_linestate_irq(irq, rport);
1135 struct rockchip_usb2phy_port *rport,
1147 switch (rport->port_id) {
1149 rport->ls_irq = of_irq_get_byname(child_np, "linestate");
1150 if (rport->ls_irq < 0) {
1152 return rport->ls_irq;
1155 ret = devm_request_threaded_irq(rphy->dev, rport->ls_irq, NULL,
1158 "rockchip_usb2phy", rport);
1170 rport->otg_mux_irq = of_irq_get_byname(child_np, "otg-mux");
1171 if (rport->otg_mux_irq > 0) {
1172 ret = devm_request_threaded_irq(rphy->dev, rport->otg_mux_irq,
1177 rport);
1184 rport->bvalid_irq = of_irq_get_byname(child_np, "otg-bvalid");
1185 if (rport->bvalid_irq < 0) {
1187 ret = rport->bvalid_irq;
1191 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq,
1196 rport);
1203 rport->id_irq = of_irq_get_byname(child_np, "otg-id");
1204 if (rport->id_irq < 0) {
1206 ret = rport->id_irq;
1210 ret = devm_request_threaded_irq(rphy->dev, rport->id_irq,
1215 rport);
1231 struct rockchip_usb2phy_port *rport,
1236 rport->port_id = USB2PHY_PORT_HOST;
1237 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST];
1238 rport->suspended = true;
1240 mutex_init(&rport->mutex);
1241 INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work);
1243 ret = rockchip_usb2phy_port_irq_init(rphy, rport, child_np);
1255 struct rockchip_usb2phy_port *rport =
1258 schedule_delayed_work(&rport->otg_sm_work, OTG_SCHEDULE_DELAY);
1264 struct rockchip_usb2phy_port *rport,
1269 rport->port_id = USB2PHY_PORT_OTG;
1270 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];
1271 rport->state = OTG_STATE_UNDEFINED;
1279 rport->suspended = true;
1280 rport->vbus_attached = false;
1282 mutex_init(&rport->mutex);
1284 rport->mode = of_usb_get_dr_mode_by_phy(child_np, -1);
1285 if (rport->mode == USB_DR_MODE_HOST ||
1286 rport->mode == USB_DR_MODE_UNKNOWN) {
1291 INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
1292 INIT_DELAYED_WORK(&rport->otg_sm_work, rockchip_usb2phy_otg_sm_work);
1294 ret = rockchip_usb2phy_port_irq_init(rphy, rport, child_np);
1301 rport->event_nb.notifier_call = rockchip_otg_event;
1304 EXTCON_USB_HOST, &rport->event_nb);
1312 id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id);
1429 struct rockchip_usb2phy_port *rport = &rphy->ports[index];
1444 rport->phy = phy;
1445 phy_set_drvdata(rport->phy, rport);
1449 ret = rockchip_usb2phy_host_port_init(rphy, rport,
1454 ret = rockchip_usb2phy_otg_port_init(rphy, rport,