All of lore.kernel.org
 help / color / mirror / Atom feed
* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-20  2:05 Jun Li
  0 siblings, 0 replies; 7+ messages in thread
From: Jun Li @ 2018-03-20  2:05 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: robh+dt, mark.rutland, gregkh, a.hajda, linux, yueyao,
	shufan_lee, o_leveque, linux-usb, dl-linux-imx

DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IGxpbnV4LXVzYi1vd25lckB2
Z2VyLmtlcm5lbC5vcmcNCj4gW21haWx0bzpsaW51eC11c2Itb3duZXJAdmdlci5rZXJuZWwub3Jn
XSBPbiBCZWhhbGYgT2YgSGVpa2tpIEtyb2dlcnVzDQo+IFNlbnQ6IDIwMTjE6jPUwjE1yNUgMTk6
MjENCj4gVG86IEp1biBMaSA8anVuLmxpQG54cC5jb20+DQo+IENjOiByb2JoK2R0QGtlcm5lbC5v
cmc7IG1hcmsucnV0bGFuZEBhcm0uY29tOw0KPiBncmVna2hAbGludXhmb3VuZGF0aW9uLm9yZzsg
YS5oYWpkYUBzYW1zdW5nLmNvbTsgbGludXhAcm9lY2stdXMubmV0Ow0KPiB5dWV5YW9AZ29vZ2xl
LmNvbTsgc2h1ZmFuX2xlZUByaWNodGVrLmNvbTsgb19sZXZlcXVlQG9yYW5nZS5mcjsNCj4gbGlu
dXgtdXNiQHZnZXIua2VybmVsLm9yZzsgZGwtbGludXgtaW14IDxsaW51eC1pbXhAbnhwLmNvbT4N
Cj4gU3ViamVjdDogUmU6IFtQQVRDSCB2MyAwNS8xMl0gdXNiOiB0eXBlYzogYWRkIEFQSSB0byBn
ZXQgc2luayBhbmQgc291cmNlDQo+IGNvbmZpZw0KPiANCj4gT24gVHVlLCBNYXIgMTMsIDIwMTgg
YXQgMDU6MzQ6MzFQTSArMDgwMCwgTGkgSnVuIHdyb3RlOg0KPiA+IFRoaXMgcGF0Y2ggYWRkIDIg
QVBJcyB0by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PiAraW50IHRjcG1fZ2V0X3NyY19jb25maWcoc3RydWN0IGZ3bm9kZV9oYW5kbGUgKmZ3bm9kZSwg
c3RydWN0DQo+ID4gK3RjcGNfY29uZmlnICp0Y2ZnKTsgaW50IHRjcG1fZ2V0X3Nua19jb25maWco
c3RydWN0IGZ3bm9kZV9oYW5kbGUNCj4gPiArKmZ3bm9kZSwgc3RydWN0IHRjcGNfY29uZmlnICp0
Y2ZnKTsNCj4gDQo+IA0KPiBDaGVlcnMsDQo+IA0KPiAtLQ0KPiBoZWlra2kNCj4gLS0NCj4gVG8g
dW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vic2NyaWJlIGxp
bnV4LXVzYiIgaW4gdGhlIGJvZHkNCj4gb2YgYSBtZXNzYWdlIHRvIG1ham9yZG9tb0B2Z2VyLmtl
cm5lbC5vcmcgTW9yZSBtYWpvcmRvbW8gaW5mbyBhdA0KPiBodHRwczovL2VtZWEwMS5zYWZlbGlu
a3MucHJvdGVjdGlvbi5vdXRsb29rLmNvbS8/dXJsPWh0dHAlM0ElMkYlMkZ2Z2VyLmsNCj4gZXJu
ZWwub3JnJTJGbWFqb3Jkb21vLWluZm8uaHRtbCZkYXRhPTAyJTdDMDElN0NqdW4ubGklNDBueHAu
Y29tJTdDDQo+IGNiMGMxYjIyYzVhMTRkYjBiYTMwMDhkNThhNjZkZTlkJTdDNjg2ZWExZDNiYzJi
NGM2ZmE5MmNkOTljNWMzMA0KPiAxNjM1JTdDMCU3QzElN0M2MzY1NjcwOTY4MDc0NDMwMTQmc2Rh
dGE9TG1sUDhTN3BYZ3pvdmV5eGlBSkh1Ug0KPiA2YWVEaVdoaDFxajVWaDFLWVdGWmMlM0QmcmVz
ZXJ2ZWQ9MA0K
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-20  2:30 Jun Li
  0 siblings, 0 replies; 7+ messages in thread
From: Jun Li @ 2018-03-20  2:30 UTC (permalink / raw)
  To: Mats Karrman, robh+dt, mark.rutland, gregkh, heikki.krogerus
  Cc: a.hajda, linux, yueyao, shufan_lee, o_leveque, linux-usb, dl-linux-imx

> -----Original Message-----
> From: Mats Karrman [mailto:mats.dev.list@gmail.com]
> Sent: 2018年3月16日 0:06
> To: Jun Li <jun.li@nxp.com>; robh+dt@kernel.org; mark.rutland@arm.com;
> gregkh@linuxfoundation.org; heikki.krogerus@linux.intel.com
> Cc: a.hajda@samsung.com; linux@roeck-us.net; yueyao@google.com;
> shufan_lee@richtek.com; o_leveque@orange.fr; linux-usb@vger.kernel.org;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v3 05/12] usb: typec: add API to get sink and source
> config
> 
> Hi,
> 
> On 2018-03-13 10:34, Li Jun wrote:
> 
> > This patch add 2 APIs to get sink and source power config from
> > firmware description in case the port supports PD.
> >
> > Signed-off-by: Li Jun <jun.li@nxp.com>
> > ---
> >   drivers/usb/typec/tcpm.c | 47
> +++++++++++++++++++++++++++++++++++++++++++++++
> >   include/linux/usb/tcpm.h |  8 +++++---
> >   2 files changed, 52 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index
> > 7500dc0..0bd34c9 100644
> > --- a/drivers/usb/typec/tcpm.c
> > +++ b/drivers/usb/typec/tcpm.c
> > @@ -13,6 +13,7 @@
> >   #include <linux/module.h>
> >   #include <linux/mutex.h>
> >   #include <linux/proc_fs.h>
> > +#include <linux/property.h>
> >   #include <linux/sched/clock.h>
> >   #include <linux/seq_file.h>
> >   #include <linux/slab.h>
> > @@ -3595,6 +3596,52 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const
> u32 *src_vdo,
> >   	return nr_vdo;
> >   }
> >
> > +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct
> > +tcpc_config *tcfg) {
> > +	int ret;
> > +
> > +	if (!fwnode)
> > +		return -EINVAL;
> > +
> > +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> > +					     NULL, 0);
> > +	if (ret <= 0)
> > +		return -EINVAL;
> > +
> > +	tcfg->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> > +	return fwnode_property_read_u32_array(fwnode, "source-pdos",
> > +					      tcfg->src_pdo, tcfg->nr_src_pdo); }
> > +EXPORT_SYMBOL_GPL(tcpm_get_src_config);
> > +
> > +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct
> > +tcpc_config *tcfg) {
> > +	int ret;
> > +
> > +	if (!fwnode)
> > +		return -EINVAL;
> > +
> > +	if ((fwnode_property_read_u32(fwnode, "max-sink-microvolt",
> > +				      &tcfg->max_snk_mv) < 0) ||
> > +		(fwnode_property_read_u32(fwnode, "max-sink-microamp",
> > +					  &tcfg->max_snk_ma) < 0) ||
> > +		(fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> > +					  &tcfg->max_snk_mw) < 0) ||
> > +		(fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> > +					  &tcfg->operating_snk_mw) < 0))
> 
> If DT is changed to use micro instead of milli, these values needs to be divided
> by 1000.

Yes, I will update in v4, thanks.

Jun
> 
> // Mats
> 
> > +		return -EINVAL;
> > +
> > +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> > +					     NULL, 0);
> > +	if (ret <= 0)
> > +		return -EINVAL;
> > +
> > +	tcfg->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> > +	return fwnode_property_read_u32_array(fwnode, "sink-pdos",
> > +					      tcfg->snk_pdo, tcfg->nr_snk_pdo); }
> > +EXPORT_SYMBOL_GPL(tcpm_get_snk_config);
> > +
> >   int tcpm_update_source_capabilities(struct tcpm_port *port, const u32
> *pdo,
> >   				    unsigned int nr_pdo)
> >   {
> > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index
> > e2e2db3..5d361f6 100644
> > --- a/include/linux/usb/tcpm.h
> > +++ b/include/linux/usb/tcpm.h
> > @@ -76,10 +76,10 @@ enum tcpm_transmit_type {
> >    * @alt_modes:	List of supported alternate modes
> >    */
> >   struct tcpc_config {
> > -	const u32 *src_pdo;
> > +	u32 *src_pdo;
> >   	unsigned int nr_src_pdo;
> >
> > -	const u32 *snk_pdo;
> > +	u32 *snk_pdo;
> >   	unsigned int nr_snk_pdo;
> >
> >   	const u32 *snk_vdo;
> > @@ -143,7 +143,7 @@ enum tcpc_mux_mode {
> >    * @mux:	Pointer to multiplexer data
> >    */
> >   struct tcpc_dev {
> > -	const struct tcpc_config *config;
> > +	struct tcpc_config *config;
> >   	struct fwnode_handle *fwnode;
> >
> >   	int (*init)(struct tcpc_dev *dev);
> > @@ -189,5 +189,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port
> *port,
> >   			       enum tcpm_transmit_status status);
> >   void tcpm_pd_hard_reset(struct tcpm_port *port);
> >   void tcpm_tcpc_reset(struct tcpm_port *port);
> > +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct
> > +tcpc_config *tcfg); int tcpm_get_snk_config(struct fwnode_handle
> > +*fwnode, struct tcpc_config *tcfg);
> >
> >   #endif /* __LINUX_USB_TCPM_H */
> >

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-20  2:11 Jun Li
  0 siblings, 0 replies; 7+ messages in thread
From: Jun Li @ 2018-03-20  2:11 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: robh+dt, mark.rutland, gregkh, a.hajda, linux, yueyao,
	shufan_lee, o_leveque, linux-usb, dl-linux-imx

Hi
> -----Original Message-----
> From: Heikki Krogerus [mailto:heikki.krogerus@linux.intel.com]
> Sent: 2018年3月15日 20:06
> To: Jun Li <jun.li@nxp.com>
> Cc: robh+dt@kernel.org; mark.rutland@arm.com;
> gregkh@linuxfoundation.org; a.hajda@samsung.com; linux@roeck-us.net;
> yueyao@google.com; shufan_lee@richtek.com; o_leveque@orange.fr;
> linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v3 05/12] usb: typec: add API to get sink and source
> config
> 
> Hi,
> 
> A small nitpick. The subject lines seem to be a little bit inconsistent in this
> series. This patch for example does not mention tcpm at all in its subject or
> even commit message, even though it only modifies tcpm.c.
> 
> Please change the subject lines of all the patches in this series mainly dealing
> with tcpm.c for example to:
> 
> usb: typec: tcpm: ...
> 

Thanks, I will update in v4.

Jun

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-15 16:06 Mats Karrman
  0 siblings, 0 replies; 7+ messages in thread
From: Mats Karrman @ 2018-03-15 16:06 UTC (permalink / raw)
  To: Li Jun, robh+dt, mark.rutland, gregkh, heikki.krogerus
  Cc: a.hajda, linux, yueyao, shufan_lee, o_leveque, linux-usb, linux-imx

Hi,

On 2018-03-13 10:34, Li Jun wrote:

> This patch add 2 APIs to get sink and source power config from firmware
> description in case the port supports PD.
>
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>   drivers/usb/typec/tcpm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>   include/linux/usb/tcpm.h |  8 +++++---
>   2 files changed, 52 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 7500dc0..0bd34c9 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -13,6 +13,7 @@
>   #include <linux/module.h>
>   #include <linux/mutex.h>
>   #include <linux/proc_fs.h>
> +#include <linux/property.h>
>   #include <linux/sched/clock.h>
>   #include <linux/seq_file.h>
>   #include <linux/slab.h>
> @@ -3595,6 +3596,52 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>   	return nr_vdo;
>   }
>   
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					      tcfg->src_pdo, tcfg->nr_src_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_src_config);
> +
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	if ((fwnode_property_read_u32(fwnode, "max-sink-microvolt",
> +				      &tcfg->max_snk_mv) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microamp",
> +					  &tcfg->max_snk_ma) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> +					  &tcfg->max_snk_mw) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> +					  &tcfg->operating_snk_mw) < 0))

If DT is changed to use micro instead of milli, these values needs to be divided by 1000.

// Mats

> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					      tcfg->snk_pdo, tcfg->nr_snk_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_snk_config);
> +
>   int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
>   				    unsigned int nr_pdo)
>   {
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index e2e2db3..5d361f6 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -76,10 +76,10 @@ enum tcpm_transmit_type {
>    * @alt_modes:	List of supported alternate modes
>    */
>   struct tcpc_config {
> -	const u32 *src_pdo;
> +	u32 *src_pdo;
>   	unsigned int nr_src_pdo;
>   
> -	const u32 *snk_pdo;
> +	u32 *snk_pdo;
>   	unsigned int nr_snk_pdo;
>   
>   	const u32 *snk_vdo;
> @@ -143,7 +143,7 @@ enum tcpc_mux_mode {
>    * @mux:	Pointer to multiplexer data
>    */
>   struct tcpc_dev {
> -	const struct tcpc_config *config;
> +	struct tcpc_config *config;
>   	struct fwnode_handle *fwnode;
>   
>   	int (*init)(struct tcpc_dev *dev);
> @@ -189,5 +189,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
>   			       enum tcpm_transmit_status status);
>   void tcpm_pd_hard_reset(struct tcpm_port *port);
>   void tcpm_tcpc_reset(struct tcpm_port *port);
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
>   
>   #endif /* __LINUX_USB_TCPM_H */
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-15 12:06 Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2018-03-15 12:06 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, mark.rutland, gregkh, a.hajda, linux, yueyao,
	shufan_lee, o_leveque, linux-usb, linux-imx

Hi,

A small nitpick. The subject lines seem to be a little bit
inconsistent in this series. This patch for example does not mention
tcpm at all in its subject or even commit message, even though it only
modifies tcpm.c.

Please change the subject lines of all the patches in this series
mainly dealing with tcpm.c for example to:

usb: typec: tcpm: ...


On Tue, Mar 13, 2018 at 05:34:31PM +0800, Li Jun wrote:
> This patch add 2 APIs to get sink and source power config from firmware
> description in case the port supports PD.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/tcpm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/tcpm.h |  8 +++++---
>  2 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 7500dc0..0bd34c9 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -13,6 +13,7 @@
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/proc_fs.h>
> +#include <linux/property.h>
>  #include <linux/sched/clock.h>
>  #include <linux/seq_file.h>
>  #include <linux/slab.h>
> @@ -3595,6 +3596,52 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>  	return nr_vdo;
>  }
>  
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					      tcfg->src_pdo, tcfg->nr_src_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_src_config);
> +
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	if ((fwnode_property_read_u32(fwnode, "max-sink-microvolt",
> +				      &tcfg->max_snk_mv) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microamp",
> +					  &tcfg->max_snk_ma) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> +					  &tcfg->max_snk_mw) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> +					  &tcfg->operating_snk_mw) < 0))
> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					      tcfg->snk_pdo, tcfg->nr_snk_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_snk_config);
> +
>  int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
>  				    unsigned int nr_pdo)
>  {
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index e2e2db3..5d361f6 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -76,10 +76,10 @@ enum tcpm_transmit_type {
>   * @alt_modes:	List of supported alternate modes
>   */
>  struct tcpc_config {
> -	const u32 *src_pdo;
> +	u32 *src_pdo;
>  	unsigned int nr_src_pdo;
>  
> -	const u32 *snk_pdo;
> +	u32 *snk_pdo;
>  	unsigned int nr_snk_pdo;
>  
>  	const u32 *snk_vdo;
> @@ -143,7 +143,7 @@ enum tcpc_mux_mode {
>   * @mux:	Pointer to multiplexer data
>   */
>  struct tcpc_dev {
> -	const struct tcpc_config *config;
> +	struct tcpc_config *config;
>  	struct fwnode_handle *fwnode;
>  
>  	int (*init)(struct tcpc_dev *dev);
> @@ -189,5 +189,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
>  			       enum tcpm_transmit_status status);
>  void tcpm_pd_hard_reset(struct tcpm_port *port);
>  void tcpm_tcpc_reset(struct tcpm_port *port);
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
>  
>  #endif /* __LINUX_USB_TCPM_H */
> -- 
> 2.7.4

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-15 11:21 Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2018-03-15 11:21 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, mark.rutland, gregkh, a.hajda, linux, yueyao,
	shufan_lee, o_leveque, linux-usb, linux-imx

On Tue, Mar 13, 2018 at 05:34:31PM +0800, Li Jun wrote:
> This patch add 2 APIs to get sink and source power config from firmware
> description in case the port supports PD.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/tcpm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/tcpm.h |  8 +++++---
>  2 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 7500dc0..0bd34c9 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -13,6 +13,7 @@
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/proc_fs.h>
> +#include <linux/property.h>
>  #include <linux/sched/clock.h>
>  #include <linux/seq_file.h>
>  #include <linux/slab.h>
> @@ -3595,6 +3596,52 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>  	return nr_vdo;
>  }
>  
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					      tcfg->src_pdo, tcfg->nr_src_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_src_config);
> +
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
> +{
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	if ((fwnode_property_read_u32(fwnode, "max-sink-microvolt",
> +				      &tcfg->max_snk_mv) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microamp",
> +					  &tcfg->max_snk_ma) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> +					  &tcfg->max_snk_mw) < 0) ||
> +		(fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> +					  &tcfg->operating_snk_mw) < 0))
> +		return -EINVAL;
> +
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	tcfg->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	return fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					      tcfg->snk_pdo, tcfg->nr_snk_pdo);
> +}
> +EXPORT_SYMBOL_GPL(tcpm_get_snk_config);

tcpm_register_port() can check these. No need to involve the tcpc
drivers.

>  int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
>  				    unsigned int nr_pdo)
>  {
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index e2e2db3..5d361f6 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -76,10 +76,10 @@ enum tcpm_transmit_type {
>   * @alt_modes:	List of supported alternate modes
>   */
>  struct tcpc_config {
> -	const u32 *src_pdo;
> +	u32 *src_pdo;
>  	unsigned int nr_src_pdo;
>  
> -	const u32 *snk_pdo;
> +	u32 *snk_pdo;
>  	unsigned int nr_snk_pdo;
>  
>  	const u32 *snk_vdo;
> @@ -143,7 +143,7 @@ enum tcpc_mux_mode {
>   * @mux:	Pointer to multiplexer data
>   */
>  struct tcpc_dev {
> -	const struct tcpc_config *config;
> +	struct tcpc_config *config;

If you check the properties in tcpm, the above members can continue to
be declared constant for now.

>  	struct fwnode_handle *fwnode;
>  
>  	int (*init)(struct tcpc_dev *dev);
> @@ -189,5 +189,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
>  			       enum tcpm_transmit_status status);
>  void tcpm_pd_hard_reset(struct tcpm_port *port);
>  void tcpm_tcpc_reset(struct tcpm_port *port);
> +int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
> +int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);


Cheers,

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

* [v3,05/12] usb: typec: add API to get sink and source config
@ 2018-03-13  9:34 Jun Li
  0 siblings, 0 replies; 7+ messages in thread
From: Jun Li @ 2018-03-13  9:34 UTC (permalink / raw)
  To: robh+dt, mark.rutland, gregkh, heikki.krogerus
  Cc: a.hajda, jun.li, linux, yueyao, shufan_lee, o_leveque, linux-usb,
	linux-imx

This patch add 2 APIs to get sink and source power config from firmware
description in case the port supports PD.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/tcpm.h |  8 +++++---
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 7500dc0..0bd34c9 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/proc_fs.h>
+#include <linux/property.h>
 #include <linux/sched/clock.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
@@ -3595,6 +3596,52 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
 	return nr_vdo;
 }
 
+int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
+{
+	int ret;
+
+	if (!fwnode)
+		return -EINVAL;
+
+	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	tcfg->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
+	return fwnode_property_read_u32_array(fwnode, "source-pdos",
+					      tcfg->src_pdo, tcfg->nr_src_pdo);
+}
+EXPORT_SYMBOL_GPL(tcpm_get_src_config);
+
+int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg)
+{
+	int ret;
+
+	if (!fwnode)
+		return -EINVAL;
+
+	if ((fwnode_property_read_u32(fwnode, "max-sink-microvolt",
+				      &tcfg->max_snk_mv) < 0) ||
+		(fwnode_property_read_u32(fwnode, "max-sink-microamp",
+					  &tcfg->max_snk_ma) < 0) ||
+		(fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
+					  &tcfg->max_snk_mw) < 0) ||
+		(fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
+					  &tcfg->operating_snk_mw) < 0))
+		return -EINVAL;
+
+	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	tcfg->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
+	return fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					      tcfg->snk_pdo, tcfg->nr_snk_pdo);
+}
+EXPORT_SYMBOL_GPL(tcpm_get_snk_config);
+
 int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
 				    unsigned int nr_pdo)
 {
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index e2e2db3..5d361f6 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -76,10 +76,10 @@ enum tcpm_transmit_type {
  * @alt_modes:	List of supported alternate modes
  */
 struct tcpc_config {
-	const u32 *src_pdo;
+	u32 *src_pdo;
 	unsigned int nr_src_pdo;
 
-	const u32 *snk_pdo;
+	u32 *snk_pdo;
 	unsigned int nr_snk_pdo;
 
 	const u32 *snk_vdo;
@@ -143,7 +143,7 @@ enum tcpc_mux_mode {
  * @mux:	Pointer to multiplexer data
  */
 struct tcpc_dev {
-	const struct tcpc_config *config;
+	struct tcpc_config *config;
 	struct fwnode_handle *fwnode;
 
 	int (*init)(struct tcpc_dev *dev);
@@ -189,5 +189,7 @@ void tcpm_pd_transmit_complete(struct tcpm_port *port,
 			       enum tcpm_transmit_status status);
 void tcpm_pd_hard_reset(struct tcpm_port *port);
 void tcpm_tcpc_reset(struct tcpm_port *port);
+int tcpm_get_src_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
+int tcpm_get_snk_config(struct fwnode_handle *fwnode, struct tcpc_config *tcfg);
 
 #endif /* __LINUX_USB_TCPM_H */

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

end of thread, other threads:[~2018-03-20  2:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20  2:05 [v3,05/12] usb: typec: add API to get sink and source config Jun Li
  -- strict thread matches above, loose matches on Subject: below --
2018-03-20  2:30 Jun Li
2018-03-20  2:11 Jun Li
2018-03-15 16:06 Mats Karrman
2018-03-15 12:06 Heikki Krogerus
2018-03-15 11:21 Heikki Krogerus
2018-03-13  9:34 Jun Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.