USB power control and over-current error message problem

I controlled the USB1_EN_OC# pin by referring to the previous Can I controlled USB1_EN_OC# pin? forum content.

However, as in the error at USB Power Control,
usb usb1-port2: over-current condition error occurs, and USB freezing occurs.

So I removed the following 3 lines from the source as the forum told me, and no more over-current condition errors occurred.

reg = padctl_readl(padctl, XUSB_PADCTL_VBUS_OC_MAP);
reg |= VBUS_ENABLE(pin);
padctl_writel(padctl, reg, XUSB_PADCTL_VBUS_OC_MAP);

I have some questions.

  1. What is the role of the above 3 lines?

  2. I usually want to enable the above 3 lines, disable it only when controlling USB1_EN_OC#, and then enable it again after the control is over. Is it possible?
    (When I tried using otg_vbus node, it didn’t work, is there another way?)

  3. If it is impossible, what is the reason?

  4. Currently, I am using ubuntu 16.04 for the TX2 OS.
    Rumor has it that there is no infinite over-current condition error in ubuntu 18.04, can’t it be fixed in 16.04?

You may disable the function by removing nvidia,oc-pin in device tree:

usb2-0 {
        status = "okay";
        mode = "otg";
        vbus-supply = <&vdd_usb0_5v>;
        nvidia,oc-pin = <0>;
usb2-1 {
        status = "okay";
        mode = "host";
        vbus-supply = <&vdd_usb1_5v>;
        nvidia,oc-pin = <1>;

The function is not runtime configurable. If the warning can be ignored in your usecase, you may disable it.