-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add TCPC driver for FUSB307 #85831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TCPC driver for FUSB307 #85831
Conversation
d3aca59
to
24959e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first commits on this PR are bug fixes and could be merged into the 4.1 release if you split them out into a separate PR.
Thank you for your review. I've created a new PR #86143 |
24959e8
to
d4fd4ff
Compare
Corrected macro definitions. Signed-off-by: Jianxiong Gu <[email protected]>
de601ac
to
fa4feea
Compare
fa4feea
to
7a4ee45
Compare
drivers/usb_c/tcpc/tcpci.c
Outdated
|
||
ret = tcpci_tcpm_get_status_register(bus, TCPC_REG_POWER_STATUS, ®); | ||
if (ret == 0) { | ||
*sinking = !!(reg & TCPC_REG_POWER_STATUS_SINKING_VBUS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be just *sinking = reg & TCPC_REG_POWER_STATUS_SINKING_VBUS;
, see C STD scalar value conversion to bool.
drivers/usb_c/tcpc/tcpci.c
Outdated
|
||
ret = tcpci_tcpm_get_status_register(bus, TCPC_REG_POWER_STATUS, ®); | ||
if (ret == 0) { | ||
*sourcing = !!(reg & TCPC_REG_POWER_STATUS_SOURCING_VBUS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
drivers/usb_c/tcpc/tcpci.c
Outdated
if (enable) { | ||
/* Set Look4Connection command */ | ||
return tcpci_write_reg8(bus, TCPC_REG_COMMAND, TCPC_REG_COMMAND_LOOK4CONNECTION); | ||
} else { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (enable) {
/* Set Look4Connection command */
return tcpci_write_reg8(bus, TCPC_REG_COMMAND, TCPC_REG_COMMAND_LOOK4CONNECTION);
}
return 0;
IIRC, there should be checkpatch warning for this kind of constructs.
drivers/usb_c/tcpc/fusb307.c
Outdated
#define DT_DRV_COMPAT onnn_fusb307_tcpc | ||
LOG_MODULE_REGISTER(tcpc_fusb307, CONFIG_USBC_LOG_LEVEL); | ||
|
||
/** Data structure for device instances */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment style must be /* */, it is documented.
Also, there is no need to comment obvious things like /* Data structure for device instances */
, Delayable work
, Boolean valu
, State of CC1
...
drivers/usb_c/tcpc/fusb307.c
Outdated
VCONN_DISC_GPIO(node), \ | ||
} | ||
|
||
#define FUSB307_DRIVER_INIT(inst) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define FUSB307_INSTANCE_DEFINE(inst)
drivers/usb_c/tcpc/fusb307.c
Outdated
static struct fusb307_data drv_data_fusb307##inst = \ | ||
FUSB307_DRIVER_DATA_INIT(DT_DRV_INST(inst)); \ | ||
static struct fusb307_cfg drv_cfg_fusb307##inst = \ | ||
FUSB307_DRIVER_CFG_INIT(DT_DRV_INST(inst)); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just
static struct fusb307_cfg fusb307_cfg_##inst = {
.bus = I2C_DT_SPEC_GET(node), \
.alert_gpio = GPIO_DT_SPEC_GET(node, irq_gpios), \
.transmit_retries = DT_PROP(node, transmit_retries), \
VCONN_DISC_GPIO(node), \
};
and the same for the data
Add generic functions that will be common to TCPCI compliant drivers. Signed-off-by: Jianxiong Gu <[email protected]>
Update set_snk_ctrl, set_src_ctrl, and set_low_power_mode to use the generic TCPCI function. Signed-off-by: Jianxiong Gu <[email protected]>
Updated set_drp_toggle to handle differences in TCPCI revisions. Added a macro for TCPCI revision and read it from the chip register during initialization. Signed-off-by: Jianxiong Gu <[email protected]>
7a4ee45
to
9fe0c8d
Compare
@jfischer-no thanks for the review. |
Sorry,I closed this PR by mistake. Reopen |
Add support for FUSB307. Signed-off-by: Jianxiong Gu <[email protected]>
Enable VBUS measurement before checking the VBUS level and disable it when unattached. Signed-off-by: Jianxiong Gu <[email protected]>
Add a build test to verify fusb307 driver builds correctly. Signed-off-by: Jianxiong Gu <[email protected]>
9fe0c8d
to
a5d4dbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is the status on this one? @sambhurst |
This PR adds the TCPC driver for the FUSB307 and includes several related fixes.