Hello everyone,
I have added USB as otg and charger in our custom imx6ul board. I can see usb added and I also verified usb serial functionality which is working perfectly fine.
I also want to verify usb charger type(cdp,dcp,sdp) functionality which I am not able to do.
My device tree is as follows:
reg_usb_otg_vbus: regulator-usb-otg-vbus {
compatible = "regulator-fixed";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_regulator_usbotg_pwr>;
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
enable-active-high;
status = "okay";
};
&usbotg1 {
pinctrl-names = "default";
vbus-supply = <®_usb_otg_vbus>;
dr_mode = "otg";
imx6-usb-charger-detection;
srp-disable;
hnp-disable;
adp-disable;
status = "okay";
};
I can see usb device in sysfs:
root@imx6ulevk:~# cat /sys/class/udc/ci_hdrc.0/device/role
gadget
I followed i.MX Linux® Reference Manual, when I do following command
cat /sys/class/power_supply/imx6_usb_charger/type
it says, No such directory.
My kernel version is:
Linux imx6ulevk 4.19.35-04767-g8890ce5c8d98-dirty
Can anybody please let me know what I am missing?
Thanks,
Asma
Hi Asma
one can try patch below:
diff --git a/arch/arm/boot/dts/imx6ul-14x14-evk.dts b/arch/arm/boot/dts/imx6ul-14x14-evk.dts
index 9099525..246d49c 100755
--- a/arch/arm/boot/dts/imx6ul-14x14-evk.dts
+++ b/arch/arm/boot/dts/imx6ul-14x14-evk.dts
@@ -742,6 +742,7 @@
srp-disable;
hnp-disable;
adp-disable;
+ imx-usb-charger-detection;
status = "okay";
};
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 60a4e4a..fe0c926
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -546,8 +546,8 @@ static int imx6_charger_data_contact_detect(struct imx_usbmisc_data *data)
if (i == 100) {
dev_err(charger->dev,
"VBUS is coming from a dedicated power supply.\n");
- imx6_disable_charger_detector(data);
- return -ENXIO;
+ //imx6_disable_charger_detector(data);
+ //return -ENXIO;
}
return 0;
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
Thank you for quick reply. The change is present my device tree that I have already posted above. My usbmisc_imx.c does not have the function that you have mentioned , but its in drivers/usb/phy/phy-mxs-usb.c. I made the change but its still not working.
Debugging further, it's giving me mxs_phy 20c9000.usbphy: vbus is not valid. My vbus is connected to pin T12 as shown in schematic below.
pin T12 is USB_OTG1_VBUS, but I dont find any pad definition for this pin in scripts/dtc/include-prefixes/arm/imx6ul-pinfunc.h. Is there any thing I am missing How should I configure this pin in device tree if there is no definition in imx6ul-pinfunc.h?
Looking forward to your response.
Thanks,
Asma
Hi Asma
USB_OTG1_VBUS pad has not alternative functions, so there is no
its settings in dts file.
Best regards
igor
Thank you,
But what can be the reason for getting "mxs_phy 20c9000.usbphy: vbus is not valid". I checked with the voltmeter volatge value is coming out to be 4.93 volt.
I was reading charger detection algorithm. According to this , it first asks to Enable the vdd3p0 curret limiter
but I dont see it has been done anywhere in the source file drivers/usb/phy/phy-mxs-usb.c
can you please check if the driver is correct, has anyone verfied charger detection before?
provided patch was tested internally and it works. You can
try to debug errors using AN4553 Using Open Source Debugging Tools for Linux on i.MX Processors
https://www.nxp.com/docs/en/application-note/AN4553.pdf
Best regards
igor