Lines Matching +full:otg +full:- +full:bvalid

1 // SPDX-License-Identifier: GPL-2.0+
12 #include <linux/usb/otg.h>
87 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */
105 /* The default DM/DP value is pull-down */
170 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx25_init()
174 if (data->index > 1) in usbmisc_imx25_init()
175 return -EINVAL; in usbmisc_imx25_init()
177 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx25_init()
178 switch (data->index) { in usbmisc_imx25_init()
180 val = readl(usbmisc->base); in usbmisc_imx25_init()
189 if (data->oc_pol_configured && data->oc_pol_active_low) in usbmisc_imx25_init()
192 writel(val, usbmisc->base); in usbmisc_imx25_init()
195 val = readl(usbmisc->base); in usbmisc_imx25_init()
205 if (data->oc_pol_configured && data->oc_pol_active_low) in usbmisc_imx25_init()
208 writel(val, usbmisc->base); in usbmisc_imx25_init()
212 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx25_init()
219 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx25_post()
224 if (data->index > 2) in usbmisc_imx25_post()
225 return -EINVAL; in usbmisc_imx25_post()
227 if (data->index) in usbmisc_imx25_post()
230 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx25_post()
231 reg = usbmisc->base + MX25_USB_PHY_CTRL_OFFSET; in usbmisc_imx25_post()
234 if (data->evdo) in usbmisc_imx25_post()
240 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx25_post()
248 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx27_init()
252 switch (data->index) { in usbmisc_imx27_init()
263 return -EINVAL; in usbmisc_imx27_init()
266 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx27_init()
267 if (data->disable_oc) in usbmisc_imx27_init()
268 val = readl(usbmisc->base) | val; in usbmisc_imx27_init()
270 val = readl(usbmisc->base) & ~val; in usbmisc_imx27_init()
271 writel(val, usbmisc->base); in usbmisc_imx27_init()
272 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx27_init()
279 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx53_init()
284 if (data->index > 3) in usbmisc_imx53_init()
285 return -EINVAL; in usbmisc_imx53_init()
288 val = readl(usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET); in usbmisc_imx53_init()
291 writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET); in usbmisc_imx53_init()
293 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx53_init()
295 switch (data->index) { in usbmisc_imx53_init()
297 if (data->disable_oc) { in usbmisc_imx53_init()
298 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET; in usbmisc_imx53_init()
304 if (data->disable_oc) { in usbmisc_imx53_init()
305 reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET; in usbmisc_imx53_init()
311 if (data->ulpi) { in usbmisc_imx53_init()
312 /* set USBH2 into ULPI-mode. */ in usbmisc_imx53_init()
313 reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET; in usbmisc_imx53_init()
320 reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET; in usbmisc_imx53_init()
326 reg = usbmisc->base + in usbmisc_imx53_init()
334 if (data->disable_oc) { in usbmisc_imx53_init()
335 reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET; in usbmisc_imx53_init()
341 if (data->ulpi) { in usbmisc_imx53_init()
342 /* set USBH3 into ULPI-mode. */ in usbmisc_imx53_init()
343 reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET; in usbmisc_imx53_init()
350 reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET; in usbmisc_imx53_init()
357 reg = usbmisc->base + in usbmisc_imx53_init()
364 if (data->disable_oc) { in usbmisc_imx53_init()
365 reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET; in usbmisc_imx53_init()
372 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx53_init()
381 if (data->ext_id || data->available_role != USB_DR_MODE_OTG) in usbmisc_wakeup_setting()
384 if (data->ext_vbus || data->available_role == USB_DR_MODE_HOST) in usbmisc_wakeup_setting()
393 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6q_set_wakeup()
398 if (data->index > 3) in usbmisc_imx6q_set_wakeup()
399 return -EINVAL; in usbmisc_imx6q_set_wakeup()
401 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6q_set_wakeup()
402 val = readl(usbmisc->base + data->index * 4); in usbmisc_imx6q_set_wakeup()
408 pr_debug("wakeup int at ci_hdrc.%d\n", data->index); in usbmisc_imx6q_set_wakeup()
411 writel(val, usbmisc->base + data->index * 4); in usbmisc_imx6q_set_wakeup()
412 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6q_set_wakeup()
419 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6q_init()
423 if (data->index > 3) in usbmisc_imx6q_init()
424 return -EINVAL; in usbmisc_imx6q_init()
426 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6q_init()
428 reg = readl(usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
429 if (data->disable_oc) { in usbmisc_imx6q_init()
438 if (data->oc_pol_configured && data->oc_pol_active_low) in usbmisc_imx6q_init()
440 else if (data->oc_pol_configured) in usbmisc_imx6q_init()
444 if (data->pwr_pol == 1) in usbmisc_imx6q_init()
446 writel(reg, usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
448 /* SoC non-burst setting */ in usbmisc_imx6q_init()
449 reg = readl(usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
451 usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
454 if (data->hsic) { in usbmisc_imx6q_init()
455 reg = readl(usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
457 usbmisc->base + data->index * 4); in usbmisc_imx6q_init()
458 reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET in usbmisc_imx6q_init()
459 + (data->index - 2) * 4); in usbmisc_imx6q_init()
461 writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET in usbmisc_imx6q_init()
462 + (data->index - 2) * 4); in usbmisc_imx6q_init()
465 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6q_init()
476 if (data->index == 2 || data->index == 3) { in usbmisc_imx6_hsic_get_reg_offset()
477 offset = (data->index - 2) * 4; in usbmisc_imx6_hsic_get_reg_offset()
478 } else if (data->index == 0) { in usbmisc_imx6_hsic_get_reg_offset()
481 * its own non-core register region. For SoCs before i.MX7D, in usbmisc_imx6_hsic_get_reg_offset()
482 * the first two USB controllers are non-HSIC controllers. in usbmisc_imx6_hsic_get_reg_offset()
486 dev_err(data->dev, "index is error for usbmisc\n"); in usbmisc_imx6_hsic_get_reg_offset()
487 ret = -EINVAL; in usbmisc_imx6_hsic_get_reg_offset()
497 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6_hsic_set_connect()
500 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_connect()
503 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_connect()
507 val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); in usbmisc_imx6_hsic_set_connect()
510 usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); in usbmisc_imx6_hsic_set_connect()
512 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_connect()
521 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6_hsic_set_clk()
524 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_clk()
527 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_clk()
531 val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); in usbmisc_imx6_hsic_set_clk()
538 writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + offset); in usbmisc_imx6_hsic_set_clk()
539 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6_hsic_set_clk()
549 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6sx_init()
554 if (data->index == 0 || data->index == 1) { in usbmisc_imx6sx_init()
555 reg = usbmisc->base + MX6_USB_OTG1_PHY_CTRL + data->index * 4; in usbmisc_imx6sx_init()
556 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6sx_init()
557 /* Set vbus wakeup source as bvalid */ in usbmisc_imx6sx_init()
564 val = readl(usbmisc->base + data->index * 4); in usbmisc_imx6sx_init()
566 usbmisc->base + data->index * 4); in usbmisc_imx6sx_init()
567 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6sx_init()
571 if (data->hsic) { in usbmisc_imx6sx_init()
572 val = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); in usbmisc_imx6sx_init()
574 writel(val, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); in usbmisc_imx6sx_init()
582 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_vf610_init()
589 if (data->index >= 1) in usbmisc_vf610_init()
590 return -EINVAL; in usbmisc_vf610_init()
592 if (data->disable_oc) { in usbmisc_vf610_init()
593 reg = readl(usbmisc->base); in usbmisc_vf610_init()
594 writel(reg | VF610_OVER_CUR_DIS, usbmisc->base); in usbmisc_vf610_init()
603 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx7d_set_wakeup()
607 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx7d_set_wakeup()
608 val = readl(usbmisc->base); in usbmisc_imx7d_set_wakeup()
612 writel(val, usbmisc->base); in usbmisc_imx7d_set_wakeup()
615 dev_dbg(data->dev, "wakeup int\n"); in usbmisc_imx7d_set_wakeup()
616 writel(val & ~MX6_USB_OTG_WAKEUP_BITS, usbmisc->base); in usbmisc_imx7d_set_wakeup()
618 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx7d_set_wakeup()
625 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx7d_init()
629 if (data->index >= 1) in usbmisc_imx7d_init()
630 return -EINVAL; in usbmisc_imx7d_init()
632 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx7d_init()
633 reg = readl(usbmisc->base); in usbmisc_imx7d_init()
634 if (data->disable_oc) { in usbmisc_imx7d_init()
643 if (data->oc_pol_configured && data->oc_pol_active_low) in usbmisc_imx7d_init()
645 else if (data->oc_pol_configured) in usbmisc_imx7d_init()
649 if (data->pwr_pol == 1) in usbmisc_imx7d_init()
651 writel(reg, usbmisc->base); in usbmisc_imx7d_init()
653 /* SoC non-burst setting */ in usbmisc_imx7d_init()
654 reg = readl(usbmisc->base); in usbmisc_imx7d_init()
655 writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base); in usbmisc_imx7d_init()
657 if (!data->hsic) { in usbmisc_imx7d_init()
658 reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7d_init()
662 usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7d_init()
664 reg = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG1); in usbmisc_imx7d_init()
665 if (data->emp_curr_control >= 0 && in usbmisc_imx7d_init()
666 data->emp_curr_control <= in usbmisc_imx7d_init()
669 reg |= (data->emp_curr_control << TXPREEMPAMPTUNE0_BIT); in usbmisc_imx7d_init()
672 if (data->dc_vol_level_adjust >= 0 && in usbmisc_imx7d_init()
673 data->dc_vol_level_adjust <= in usbmisc_imx7d_init()
676 reg |= (data->dc_vol_level_adjust << TXVREFTUNE0_BIT); in usbmisc_imx7d_init()
679 if (data->rise_fall_time_adjust >= 0 && in usbmisc_imx7d_init()
680 data->rise_fall_time_adjust <= in usbmisc_imx7d_init()
683 reg |= (data->rise_fall_time_adjust << TXRISETUNE0_BIT); in usbmisc_imx7d_init()
686 writel(reg, usbmisc->base + MX7D_USB_OTG_PHY_CFG1); in usbmisc_imx7d_init()
689 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx7d_init()
698 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in imx7d_charger_secondary_detection()
699 struct usb_phy *usb_phy = data->usb_phy; in imx7d_charger_secondary_detection()
704 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_secondary_detection()
705 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_secondary_detection()
707 writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_secondary_detection()
708 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_secondary_detection()
713 /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ in imx7d_charger_secondary_detection()
714 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_secondary_detection()
715 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_secondary_detection()
719 usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_secondary_detection()
720 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_secondary_detection()
730 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); in imx7d_charger_secondary_detection()
732 dev_dbg(data->dev, "It is a dedicate charging port\n"); in imx7d_charger_secondary_detection()
733 usb_phy->chg_type = DCP_TYPE; in imx7d_charger_secondary_detection()
735 dev_dbg(data->dev, "It is a charging downstream port\n"); in imx7d_charger_secondary_detection()
736 usb_phy->chg_type = CDP_TYPE; in imx7d_charger_secondary_detection()
744 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in imx7_disable_charger_detector()
748 spin_lock_irqsave(&usbmisc->lock, flags); in imx7_disable_charger_detector()
749 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7_disable_charger_detector()
754 writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7_disable_charger_detector()
757 val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7_disable_charger_detector()
759 writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7_disable_charger_detector()
761 val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7_disable_charger_detector()
763 usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7_disable_charger_detector()
764 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7_disable_charger_detector()
769 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in imx7d_charger_data_contact_detect()
775 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_data_contact_detect()
776 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_data_contact_detect()
778 usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_data_contact_detect()
779 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_data_contact_detect()
782 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); in imx7d_charger_data_contact_detect()
795 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_data_contact_detect()
796 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_data_contact_detect()
798 usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_data_contact_detect()
799 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_data_contact_detect()
802 dev_err(data->dev, in imx7d_charger_data_contact_detect()
804 return -ENXIO; in imx7d_charger_data_contact_detect()
812 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in imx7d_charger_primary_detection()
813 struct usb_phy *usb_phy = data->usb_phy; in imx7d_charger_primary_detection()
817 /* VDP_SRC is connected to D+ and IDM_SINK is connected to D- */ in imx7d_charger_primary_detection()
818 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_primary_detection()
819 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_primary_detection()
823 usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in imx7d_charger_primary_detection()
824 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_primary_detection()
829 /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ in imx7d_charger_primary_detection()
830 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); in imx7d_charger_primary_detection()
832 dev_dbg(data->dev, "It is a standard downstream port\n"); in imx7d_charger_primary_detection()
833 usb_phy->chg_type = SDP_TYPE; in imx7d_charger_primary_detection()
841 * 1. OPMODE override to be non-driving
849 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in imx7d_charger_detection()
850 struct usb_phy *usb_phy = data->usb_phy; in imx7d_charger_detection()
856 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); in imx7d_charger_detection()
858 dev_err(data->dev, "vbus is error\n"); in imx7d_charger_detection()
859 return -EINVAL; in imx7d_charger_detection()
863 * Keep OPMODE to be non-driving mode during the whole in imx7d_charger_detection()
866 spin_lock_irqsave(&usbmisc->lock, flags); in imx7d_charger_detection()
867 val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7d_charger_detection()
870 writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7d_charger_detection()
872 val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7d_charger_detection()
874 usbmisc->base + MX7D_USBNC_USB_CTRL2); in imx7d_charger_detection()
875 spin_unlock_irqrestore(&usbmisc->lock, flags); in imx7d_charger_detection()
882 if (!ret && usb_phy->chg_type != SDP_TYPE) in imx7d_charger_detection()
894 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx7d_vbus_comparator_on()
897 if (data->hsic) in usbmisc_imx7d_vbus_comparator_on()
900 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx7d_vbus_comparator_on()
903 * when OTG is disabled and DRVVBUS0 is asserted case in usbmisc_imx7d_vbus_comparator_on()
907 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in usbmisc_imx7d_vbus_comparator_on()
913 writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); in usbmisc_imx7d_vbus_comparator_on()
914 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx7d_vbus_comparator_on()
919 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx7ulp_init()
923 if (data->index >= 1) in usbmisc_imx7ulp_init()
924 return -EINVAL; in usbmisc_imx7ulp_init()
926 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx7ulp_init()
927 reg = readl(usbmisc->base); in usbmisc_imx7ulp_init()
928 if (data->disable_oc) { in usbmisc_imx7ulp_init()
937 if (data->oc_pol_configured && data->oc_pol_active_low) in usbmisc_imx7ulp_init()
939 else if (data->oc_pol_configured) in usbmisc_imx7ulp_init()
943 if (data->pwr_pol == 1) in usbmisc_imx7ulp_init()
946 writel(reg, usbmisc->base); in usbmisc_imx7ulp_init()
948 /* SoC non-burst setting */ in usbmisc_imx7ulp_init()
949 reg = readl(usbmisc->base); in usbmisc_imx7ulp_init()
950 writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base); in usbmisc_imx7ulp_init()
952 if (data->hsic) { in usbmisc_imx7ulp_init()
953 reg = readl(usbmisc->base); in usbmisc_imx7ulp_init()
954 writel(reg | MX6_BM_UTMI_ON_CLOCK, usbmisc->base); in usbmisc_imx7ulp_init()
956 reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); in usbmisc_imx7ulp_init()
958 writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET); in usbmisc_imx7ulp_init()
961 * For non-HSIC controller, the autoresume is enabled in usbmisc_imx7ulp_init()
964 reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7ulp_init()
966 usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7ulp_init()
968 reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7ulp_init()
971 usbmisc->base + MX7D_USBNC_USB_CTRL2); in usbmisc_imx7ulp_init()
974 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx7ulp_init()
983 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx7d_power_lost_check()
987 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx7d_power_lost_check()
988 val = readl(usbmisc->base); in usbmisc_imx7d_power_lost_check()
989 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx7d_power_lost_check()
1002 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in usbmisc_imx6sx_power_lost_check()
1006 spin_lock_irqsave(&usbmisc->lock, flags); in usbmisc_imx6sx_power_lost_check()
1007 val = readl(usbmisc->base + data->index * 4); in usbmisc_imx6sx_power_lost_check()
1008 spin_unlock_irqrestore(&usbmisc->lock, flags); in usbmisc_imx6sx_power_lost_check()
1073 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); in is_imx53_usbmisc()
1075 return usbmisc->ops == &imx53_usbmisc_ops; in is_imx53_usbmisc()
1085 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_init()
1086 if (!usbmisc->ops->init) in imx_usbmisc_init()
1088 return usbmisc->ops->init(data); in imx_usbmisc_init()
1100 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_init_post()
1101 if (usbmisc->ops->post) in imx_usbmisc_init_post()
1102 ret = usbmisc->ops->post(data); in imx_usbmisc_init_post()
1104 dev_err(data->dev, "post init failed, ret=%d\n", ret); in imx_usbmisc_init_post()
1108 if (usbmisc->ops->set_wakeup) in imx_usbmisc_init_post()
1109 ret = usbmisc->ops->set_wakeup(data, false); in imx_usbmisc_init_post()
1111 dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); in imx_usbmisc_init_post()
1126 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_hsic_set_connect()
1127 if (!usbmisc->ops->hsic_set_connect || !data->hsic) in imx_usbmisc_hsic_set_connect()
1129 return usbmisc->ops->hsic_set_connect(data); in imx_usbmisc_hsic_set_connect()
1140 return -EINVAL; in imx_usbmisc_charger_detection()
1142 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_charger_detection()
1143 usb_phy = data->usb_phy; in imx_usbmisc_charger_detection()
1144 if (!usbmisc->ops->charger_detection) in imx_usbmisc_charger_detection()
1145 return -ENOTSUPP; in imx_usbmisc_charger_detection()
1148 ret = usbmisc->ops->charger_detection(data); in imx_usbmisc_charger_detection()
1150 dev_err(data->dev, in imx_usbmisc_charger_detection()
1153 usb_phy->chg_state = USB_CHARGER_ABSENT; in imx_usbmisc_charger_detection()
1155 usb_phy->chg_state = USB_CHARGER_PRESENT; in imx_usbmisc_charger_detection()
1158 usb_phy->chg_state = USB_CHARGER_ABSENT; in imx_usbmisc_charger_detection()
1159 usb_phy->chg_type = UNKNOWN_TYPE; in imx_usbmisc_charger_detection()
1173 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_suspend()
1175 if (usbmisc->ops->vbus_comparator_on) in imx_usbmisc_suspend()
1176 usbmisc->ops->vbus_comparator_on(data, false); in imx_usbmisc_suspend()
1178 if (wakeup && usbmisc->ops->set_wakeup) in imx_usbmisc_suspend()
1179 ret = usbmisc->ops->set_wakeup(data, true); in imx_usbmisc_suspend()
1181 dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); in imx_usbmisc_suspend()
1185 if (usbmisc->ops->hsic_set_clk && data->hsic) in imx_usbmisc_suspend()
1186 ret = usbmisc->ops->hsic_set_clk(data, false); in imx_usbmisc_suspend()
1188 dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); in imx_usbmisc_suspend()
1204 usbmisc = dev_get_drvdata(data->dev); in imx_usbmisc_resume()
1206 if (usbmisc->ops->power_lost_check) in imx_usbmisc_resume()
1207 ret = usbmisc->ops->power_lost_check(data); in imx_usbmisc_resume()
1209 /* re-init if resume from power lost */ in imx_usbmisc_resume()
1212 dev_err(data->dev, "re-init failed, ret=%d\n", ret); in imx_usbmisc_resume()
1217 if (wakeup && usbmisc->ops->set_wakeup) in imx_usbmisc_resume()
1218 ret = usbmisc->ops->set_wakeup(data, false); in imx_usbmisc_resume()
1220 dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); in imx_usbmisc_resume()
1224 if (usbmisc->ops->hsic_set_clk && data->hsic) in imx_usbmisc_resume()
1225 ret = usbmisc->ops->hsic_set_clk(data, true); in imx_usbmisc_resume()
1227 dev_err(data->dev, "set_wakeup failed, ret=%d\n", ret); in imx_usbmisc_resume()
1231 if (usbmisc->ops->vbus_comparator_on) in imx_usbmisc_resume()
1232 usbmisc->ops->vbus_comparator_on(data, true); in imx_usbmisc_resume()
1237 if (wakeup && usbmisc->ops->set_wakeup) in imx_usbmisc_resume()
1238 usbmisc->ops->set_wakeup(data, true); in imx_usbmisc_resume()
1245 .compatible = "fsl,imx25-usbmisc",
1249 .compatible = "fsl,imx35-usbmisc",
1253 .compatible = "fsl,imx27-usbmisc",
1257 .compatible = "fsl,imx51-usbmisc",
1261 .compatible = "fsl,imx53-usbmisc",
1265 .compatible = "fsl,imx6q-usbmisc",
1269 .compatible = "fsl,vf610-usbmisc",
1273 .compatible = "fsl,imx6sx-usbmisc",
1277 .compatible = "fsl,imx6ul-usbmisc",
1281 .compatible = "fsl,imx7d-usbmisc",
1285 .compatible = "fsl,imx7ulp-usbmisc",
1296 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in usbmisc_imx_probe()
1298 return -ENOMEM; in usbmisc_imx_probe()
1300 spin_lock_init(&data->lock); in usbmisc_imx_probe()
1302 data->base = devm_platform_ioremap_resource(pdev, 0); in usbmisc_imx_probe()
1303 if (IS_ERR(data->base)) in usbmisc_imx_probe()
1304 return PTR_ERR(data->base); in usbmisc_imx_probe()
1306 data->ops = of_device_get_match_data(&pdev->dev); in usbmisc_imx_probe()
1322 MODULE_ALIAS("platform:usbmisc-imx");
1324 MODULE_DESCRIPTION("driver for imx usb non-core registers");