> -----Original Message-----
> From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
> Sent: Tuesday, September 26, 2017 9:37 PM
> To: Jun Li <[email protected]>; [email protected]; [email protected];
> [email protected]; [email protected]
> Cc: [email protected]; [email protected]; Peter Chen
> <[email protected]>; A.s. Dong <[email protected]>; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH 06/12] staging: typec: tcpci: enable vbus detection
>
> On 09/25/2017 05:45 PM, Li Jun wrote:
> > TCPCI implementation may need SW to enable VBUS detection to generate
> > power status events.
> >
> > Signed-off-by: Li Jun <[email protected]>
> > ---
> > drivers/staging/typec/tcpci.c | 23 +++++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
> >
> > diff --git a/drivers/staging/typec/tcpci.c
> > b/drivers/staging/typec/tcpci.c index 6d608b4..851d026 100644
> > --- a/drivers/staging/typec/tcpci.c
> > +++ b/drivers/staging/typec/tcpci.c
> > @@ -313,6 +313,26 @@ static int tcpci_pd_transmit(struct tcpc_dev *tcpc,
> > return 0;
> > }
> >
> > +static int tcpci_vbus_detect(struct tcpc_dev *tcpc, bool enable) {
> > + struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> > + int ret;
> > +
> > + if (enable) {
> > + ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
> > + TCPC_CMD_ENABLE_VBUS_DETECT);
> > + if (ret < 0)
> > + return ret;
> > + } else {
> > + ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
> > + TCPC_CMD_DISABLE_VBUS_DETECT);
> > + if (ret < 0)
> > + return ret;
> > + }
>
> This could be simplified to something like
>
> u8 cmd = enabled ? TCPC_CMD_ENABLE_VBUS_DETECT :
> TCPC_CMD_DISABLE_VBUS_DETECT;
>
> return regmap_write(tcpci->regmap, TCPC_COMMAND, cmd);
>
> though the question is why not just add a function named
> tcpci_vbus_detect_enable() since it is never disabled, at least not in this
> patch.
Will change to be tcpci_vbus_detect_enable().
>
> > +
> > + return 0;
> > +}
> > +
> > static int tcpci_init(struct tcpc_dev *tcpc)
> > {
> > struct tcpci *tcpci = tcpc_to_tcpci(tcpc); @@ -344,6 +364,9 @@
> > static int tcpci_init(struct tcpc_dev *tcpc)
> > if (ret < 0)
> > return ret;
> >
> > + /* Enable Vbus detection */
> > + tcpci_vbus_detect(tcpc, true);
> > +
> > reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
> > TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
> > TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;
> >
N�����r��y����b�X��ǧv�^�){.n�+����{������^n�r���z���h�����&���G���h�(�階�ݢj"���m������z�ޖ���f���h���~�m�