Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci
@ 2019-08-15  4:19 cy_huang
  2019-08-15  7:08 ` Greg KH
  2019-08-15  7:14 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: cy_huang @ 2019-08-15  4:19 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus
  Cc: cy_huang, gregkh, linux-usb, linux-kernel, gene_chen, shufan_lee

From: cy_huang <cy_huang@richtek.com>

In real case, not all TCPCs support the tcpc PP control command.
Sometimes, charger/OTG/CurrentLimit functions will need to externally
control via power_supply/regulator/BC1.2(extcon). This patch add the ops
set_vbus/get_current_limit/set_current_limit for vendors.

Signed-off-by: cy_huang <cy_huang@richtek.com>
---
 drivers/usb/typec/tcpm/tcpci.c | 34 ++++++++++++++++++++++++++++++++++
 drivers/usb/typec/tcpm/tcpci.h |  5 +++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index c1f7073..22dfcd8 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -279,6 +279,13 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink)
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
 	int ret;
 
+	/* Handle vendor set vbus */
+	if (tcpci->data->set_vbus) {
+		ret = tcpci->data->set_vbus(tcpci, tcpci->data, source, sink);
+		if (ret < 0)
+			return ret;
+	}
+
 	/* Disable both source and sink first before enabling anything */
 
 	if (!source) {
@@ -346,6 +353,30 @@ static int tcpci_pd_transmit(struct tcpc_dev *tcpc,
 	return 0;
 }
 
+static int tcpci_get_current_limit(struct tcpc_dev *tcpc)
+{
+	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+
+	/* Handle vendor get current limit */
+	if (tcpci->data->get_current_limit)
+		return tcpci->data->get_current_limit(tcpci, tcpci->data);
+
+	return 0;
+}
+
+static int tcpci_set_current_limit(struct tcpc_dev *tcpc, u32 max_ma, u32 mv)
+{
+	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+
+	/* Handle vendor set current limit */
+	if (tcpci->data->set_current_limit) {
+		return tcpci->data->set_current_limit(tcpci,
+						      tcpci->data, max_ma, mv);
+	}
+
+	return 0;
+}
+
 static int tcpci_init(struct tcpc_dev *tcpc)
 {
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
@@ -521,6 +552,9 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
 	tcpci->tcpc.set_roles = tcpci_set_roles;
 	tcpci->tcpc.pd_transmit = tcpci_pd_transmit;
 
+	tcpci->tcpc.get_current_limit = tcpci_get_current_limit;
+	tcpci->tcpc.set_current_limit = tcpci_set_current_limit;
+
 	err = tcpci_parse_config(tcpci);
 	if (err < 0)
 		return ERR_PTR(err);
diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
index 303ebde..a6754fb 100644
--- a/drivers/usb/typec/tcpm/tcpci.h
+++ b/drivers/usb/typec/tcpm/tcpci.h
@@ -130,6 +130,11 @@ struct tcpci_data {
 			 bool enable);
 	int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
 				  enum typec_cc_status cc);
+	int (*set_vbus)(struct tcpci *tcpci,
+			struct tcpci_data *data, bool source, bool sink);
+	int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
+	int (*set_current_limit)(struct tcpci *tcpci,
+				 struct tcpci_data *data, u32 max_ma, u32 mv);
 };
 
 struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci
  2019-08-15  4:19 [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci cy_huang
@ 2019-08-15  7:08 ` Greg KH
  2019-08-15  7:14 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-08-15  7:08 UTC (permalink / raw)
  To: cy_huang
  Cc: Guenter Roeck, Heikki Krogerus, cy_huang, linux-usb,
	linux-kernel, gene_chen, shufan_lee

On Thu, Aug 15, 2019 at 12:19:13PM +0800, cy_huang wrote:
> From: cy_huang <cy_huang@richtek.com>

Your subject line is a bit odd :)

Also, we need a "real" name here, and in the signed-off-by line, not an
email prefix.

Please fix up and resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci
  2019-08-15  4:19 [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci cy_huang
  2019-08-15  7:08 ` Greg KH
@ 2019-08-15  7:14 ` Greg KH
  2019-08-15  8:04   ` 啟原黃
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2019-08-15  7:14 UTC (permalink / raw)
  To: cy_huang
  Cc: Guenter Roeck, Heikki Krogerus, cy_huang, linux-usb,
	linux-kernel, gene_chen, shufan_lee

On Thu, Aug 15, 2019 at 12:19:13PM +0800, cy_huang wrote:
> diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
> index 303ebde..a6754fb 100644
> --- a/drivers/usb/typec/tcpm/tcpci.h
> +++ b/drivers/usb/typec/tcpm/tcpci.h
> @@ -130,6 +130,11 @@ struct tcpci_data {
>  			 bool enable);
>  	int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
>  				  enum typec_cc_status cc);
> +	int (*set_vbus)(struct tcpci *tcpci,
> +			struct tcpci_data *data, bool source, bool sink);
> +	int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
> +	int (*set_current_limit)(struct tcpci *tcpci,
> +				 struct tcpci_data *data, u32 max_ma, u32 mv);
>  };

You are adding callbacks here with no users of them, which isn't
allowed.  Please also submit the code that uses these callbacks at the
same time so we can review it all together.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci
  2019-08-15  7:14 ` Greg KH
@ 2019-08-15  8:04   ` 啟原黃
  0 siblings, 0 replies; 4+ messages in thread
From: 啟原黃 @ 2019-08-15  8:04 UTC (permalink / raw)
  To: Greg KH
  Cc: Guenter Roeck, Heikki Krogerus, cy_huang, linux-usb,
	linux-kernel, gene_chen, shufan_lee

Greg KH <gregkh@linuxfoundation.org> 於 2019年8月15日 週四 下午3:14寫道:
>
> On Thu, Aug 15, 2019 at 12:19:13PM +0800, cy_huang wrote:
> > diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
> > index 303ebde..a6754fb 100644
> > --- a/drivers/usb/typec/tcpm/tcpci.h
> > +++ b/drivers/usb/typec/tcpm/tcpci.h
> > @@ -130,6 +130,11 @@ struct tcpci_data {
> >                        bool enable);
> >       int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
> >                                 enum typec_cc_status cc);
> > +     int (*set_vbus)(struct tcpci *tcpci,
> > +                     struct tcpci_data *data, bool source, bool sink);
> > +     int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
> > +     int (*set_current_limit)(struct tcpci *tcpci,
> > +                              struct tcpci_data *data, u32 max_ma, u32 mv);
> >  };
>
> You are adding callbacks here with no users of them, which isn't
> allowed.  Please also submit the code that uses these callbacks at the
> same time so we can review it all together.
>
> thanks,
>
> greg k-h

Yes, I'm adding the callback for the sub-pmic (CHG/TCPC)

I'll push the mfd driver first. for the tcpc, it's just a sub device.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15  4:19 [PATCH] From: cy_huang <cy_huang@richtek.com> Subject: usb: add more vendor defined ops in tcpci cy_huang
2019-08-15  7:08 ` Greg KH
2019-08-15  7:14 ` Greg KH
2019-08-15  8:04   ` 啟原黃

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org linux-usb@archiver.kernel.org
	public-inbox-index linux-usb


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/ public-inbox