Lines Matching +full:auto +full:- +full:detection

4  * SPDX-License-Identifier: Apache-2.0
29 /* Run-time configuration data */
57 * The USB Type-C specification limits the maximum amount of current from BC 1.2
88 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_interrupt_enable()
91 return i2c_reg_update_byte_dt(&cfg->i2c, PI3USB9201_REG_CTRL_1, in pi3usb9201_interrupt_enable()
98 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_bc12_detect_ctrl()
100 return i2c_reg_update_byte_dt(&cfg->i2c, PI3USB9201_REG_CTRL_2, in pi3usb9201_bc12_detect_ctrl()
107 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_bc12_usb_switch()
110 return i2c_reg_update_byte_dt(&cfg->i2c, PI3USB9201_REG_CTRL_2, in pi3usb9201_bc12_usb_switch()
117 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_set_mode()
119 return i2c_reg_update_byte_dt(&cfg->i2c, PI3USB9201_REG_CTRL_1, in pi3usb9201_set_mode()
127 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_get_mode()
131 rv = i2c_reg_read_byte_dt(&cfg->i2c, PI3USB9201_REG_CTRL_1, &ctrl1); in pi3usb9201_get_mode()
146 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_get_status()
150 rv = i2c_reg_read_byte_dt(&cfg->i2c, PI3USB9201_REG_CLIENT_STS, &status); in pi3usb9201_get_status()
159 rv = i2c_reg_read_byte_dt(&cfg->i2c, PI3USB9201_REG_HOST_STS, &status); in pi3usb9201_get_status()
174 struct pi3usb9201_data *pi3usb9201_data = dev->data; in pi3usb9201_notify_callback()
176 if (pi3usb9201_data->result_cb) { in pi3usb9201_notify_callback()
177 pi3usb9201_data->result_cb(dev, state, pi3usb9201_data->result_cb_data); in pi3usb9201_notify_callback()
184 struct pi3usb9201_data *pi3usb9201_data = dev->data; in pi3usb9201_partner_has_changed()
191 if (state->bc12_role != pi3usb9201_data->partner_state.bc12_role) { in pi3usb9201_partner_has_changed()
195 if (state->bc12_role == BC12_PORTABLE_DEVICE && in pi3usb9201_partner_has_changed()
196 pi3usb9201_data->partner_state.type != state->type) { in pi3usb9201_partner_has_changed()
200 if (state->bc12_role == BC12_CHARGING_PORT && in pi3usb9201_partner_has_changed()
201 pi3usb9201_data->partner_state.pd_partner_connected != state->pd_partner_connected) { in pi3usb9201_partner_has_changed()
218 struct pi3usb9201_data *pi3usb9201_data = dev->data; in pi3usb9201_update_charging_partner()
227 pi3usb9201_data->partner_state = *state; in pi3usb9201_update_charging_partner()
230 pi3usb9201_data->partner_state.bc12_role = BC12_DISCONNECTED; in pi3usb9201_update_charging_partner()
241 * are cleared prior to starting bc1.2 detection. in pi3usb9201_client_detect_start()
251 /* Have pi3usb9201 start bc1.2 detection */ in pi3usb9201_client_detect_start()
257 /* Enable interrupt to wake task when detection completes */ in pi3usb9201_client_detect_start()
276 bit_pos = __builtin_ffs(status) - 1; in pi3usb9201_client_detect_finish()
284 /* bc1.2 is complete and start bit does not auto clear */ in pi3usb9201_client_detect_finish()
305 const struct pi3usb9201_config *pi3usb9201_config = dev->config; in pi3usb9201_host_interrupt()
308 switch (pi3usb9201_config->charging_mode) { in pi3usb9201_host_interrupt()
311 * For USB-C connections, enable the USB data path in pi3usb9201_host_interrupt()
312 * TODO - Provide a devicetree property indicating in pi3usb9201_host_interrupt()
321 * noise (pulse on D-) causing USB disconnect in pi3usb9201_host_interrupt()
357 /* Ensure USB switch auto-on is enabled */ in pi3usb9201_disconnect()
369 /* The start bc1.2 bit does not auto clear */ in pi3usb9201_disconnect()
375 /* Mask interrupts until next bc1.2 detection event */ in pi3usb9201_disconnect()
404 * VBUS is present, but starting bc1.2 detection failed in pi3usb9201_set_portable_device()
414 LOG_ERR("bc1.2 detection failed, using defaults"); in pi3usb9201_set_portable_device()
416 return -EIO; in pi3usb9201_set_portable_device()
424 const struct pi3usb9201_config *pi3usb9201_config = dev->config; in pi3usb9201_set_charging_mode()
430 if (pi3usb9201_config->charging_mode == BC12_TYPE_NONE) { in pi3usb9201_set_charging_mode()
432 * For USB-C connections, enable the USB data path when configured in pi3usb9201_set_charging_mode()
435 * TODO - Provide a devicetree property indicating in pi3usb9201_set_charging_mode()
460 desired_mode = charging_mode_to_host_mode[pi3usb9201_config->charging_mode]; in pi3usb9201_set_charging_mode()
492 const struct device *dev = pi3usb9201_data->dev; in pi3usb9201_isr_work()
506 * BC1.2 detection has completed. in pi3usb9201_isr_work()
521 k_work_submit(&pi3usb9201_data->work); in pi3usb9201_gpio_callback()
535 return -EINVAL; in pi3usb9201_set_role()
543 struct pi3usb9201_data *pi3usb9201_data = dev->data; in pi3usb9201_set_result_cb()
545 pi3usb9201_data->result_cb = cb; in pi3usb9201_set_result_cb()
546 pi3usb9201_data->result_cb_data = user_data; in pi3usb9201_set_result_cb()
558 const struct pi3usb9201_config *cfg = dev->config; in pi3usb9201_init()
559 struct pi3usb9201_data *pi3usb9201_data = dev->data; in pi3usb9201_init()
562 if (!i2c_is_ready_dt(&cfg->i2c)) { in pi3usb9201_init()
564 return -ENODEV; in pi3usb9201_init()
567 if (!gpio_is_ready_dt(&cfg->intb_gpio)) { in pi3usb9201_init()
569 return -ENODEV; in pi3usb9201_init()
572 pi3usb9201_data->dev = dev; in pi3usb9201_init()
575 * Set most recent bc1.2 detection type result to in pi3usb9201_init()
578 pi3usb9201_data->partner_state.bc12_role = BC12_DISCONNECTED; in pi3usb9201_init()
580 rv = gpio_pin_configure_dt(&cfg->intb_gpio, GPIO_INPUT); in pi3usb9201_init()
586 gpio_init_callback(&pi3usb9201_data->gpio_cb, pi3usb9201_gpio_callback, in pi3usb9201_init()
587 BIT(cfg->intb_gpio.pin)); in pi3usb9201_init()
588 k_work_init(&pi3usb9201_data->work, pi3usb9201_isr_work); in pi3usb9201_init()
590 rv = gpio_add_callback(cfg->intb_gpio.port, &pi3usb9201_data->gpio_cb); in pi3usb9201_init()
596 rv = gpio_pin_interrupt_configure_dt(&cfg->intb_gpio, GPIO_INT_EDGE_FALLING); in pi3usb9201_init()