On Tue, 2019-02-19 at 11:20 +0800, Chen Yu wrote: > Hi, > > On 2019/2/19 10:50, Chunfeng Yun wrote: > >> + if (ret) > >> + hisi_hikey_usb->typec_vbus_enable_val = 1; > >> + > >> + hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus", > >> + hisi_hikey_usb->typec_vbus_enable_val ? > >> + GPIOD_OUT_LOW : GPIOD_OUT_HIGH); > >> + if (!hisi_hikey_usb->typec_vbus) > >> + return -ENOENT; > >> + else if (IS_ERR(hisi_hikey_usb->typec_vbus)) > >> + return PTR_ERR(hisi_hikey_usb->typec_vbus); > >> + > >> + gpiod_direction_output(hisi_hikey_usb->typec_vbus, > >> + !hisi_hikey_usb->typec_vbus_enable_val); > > maybe a simple way if use fixed regulator? > > > The hardware of the Hikey960 board has been fixed, and the type-c > port can act as UFP. So it is better to close the vbus when Hikey960 > connect to host(e.g PC). I guess you misunderstand what I mean? Please refer to bindings/regulator/fixed-regulator.txt If you control vbus by gpio, you can use fixed-regulator, it will be easy to make compatible with other cases, think about using a LDO to control vbus > >> + > >> + hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", GPIOD_IN); > >> + if (!hisi_hikey_usb->otg_switch) > >> + return -ENOENT; > >> + else if (IS_ERR(hisi_hikey_usb->otg_switch)) > >> + return PTR_ERR(hisi_hikey_usb->otg_switch); > >> + > >> + gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB); > >> + > >> + /* hub-vdd33-en is optional */ > >> + hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en", > >> + GPIOD_OUT_LOW); > >> + if (IS_ERR(hisi_hikey_usb->hub_vbus)) > >> + return PTR_ERR(hisi_hikey_usb->hub_vbus); > >> + > >> + gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON); > > ditto > >> + > >> + hisi_hikey_usb->role_sw = usb_role_switch_get(dev); > >> + if (!hisi_hikey_usb->role_sw) > >> + return -EPROBE_DEFER; > >> + else if (IS_ERR(hisi_hikey_usb->role_sw)) > >> + return PTR_ERR(hisi_hikey_usb->role_sw); > >> + > > Thanks > Yu Chen >