static void gpio_switch_work_func(struct work_struct *work) { int state; state = gpio_get_value(otg_id_switch.otg_id_gpio); hwlog_info("gpio_switch_work state = %d ---\n", state); if (otg_id_switch.otg_id_gpio_last_state == GPIO_HIGH_VOLTAGE && state == GPIO_LOW_VOLTAGE) { hwlog_err("gpio_switch_work ID_FALL_EVENT ---\n"); hisi_usb_id_change(ID_FALL_EVENT); otg_id_switch.otg_id_gpio_last_state = state; return; } if (otg_id_switch.otg_id_gpio_last_state == GPIO_LOW_VOLTAGE && state == GPIO_HIGH_VOLTAGE) { hwlog_err("gpio_switch_work ID_RISE_EVENT +++\n"); hisi_usb_id_change(ID_RISE_EVENT); otg_id_switch.otg_id_gpio_last_state = state; return; } }
/** * typec_close_otg() - stop otg work as a pair of typec_open_otg(). */ static void typec_close_otg(void) { hisi_usb_id_change(ID_RISE_EVENT); }
/** * typec_open_otg() - start otg work by calling related modules. * fsa9685_manual_sw() is to connect USB signal path. * hisi_usb_id_change() is to open VBUS to charge slave devices. */ static void typec_open_otg(void) { fsa9685_manual_sw(FSA9685_USB1_ID_TO_IDBYPASS); mdelay(10); hisi_usb_id_change(ID_FALL_EVENT); }