RE: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-19 Thread Jun Li


> -Original Message-
> From: Mats Karrman [mailto:mats.dev.l...@gmail.com]
> Sent: 2018年3月16日 0:06
> To: Jun Li <jun...@nxp.com>; robh...@kernel.org; mark.rutl...@arm.com;
> gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com
> Cc: a.ha...@samsung.com; li...@roeck-us.net; yue...@google.com;
> shufan_...@richtek.com; o_leve...@orange.fr; linux-usb@vger.kernel.org;
> dl-linux-imx <linux-...@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...@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 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -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",
> > + >max_snk_mv) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "max-sink-microamp",
> > + >max_snk_ma) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> > + >max_snk_mw) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> > + >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 */
> >


RE: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-19 Thread Jun Li
Hi
> -Original Message-
> From: Heikki Krogerus [mailto:heikki.kroge...@linux.intel.com]
> Sent: 2018年3月15日 20:06
> To: Jun Li <jun...@nxp.com>
> Cc: robh...@kernel.org; mark.rutl...@arm.com;
> gre...@linuxfoundation.org; a.ha...@samsung.com; li...@roeck-us.net;
> yue...@google.com; shufan_...@richtek.com; o_leve...@orange.fr;
> linux-usb@vger.kernel.org; dl-linux-imx <linux-...@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


RE: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-19 Thread Jun Li

> -Original Message-
> From: linux-usb-ow...@vger.kernel.org
> [mailto:linux-usb-ow...@vger.kernel.org] On Behalf Of Heikki Krogerus
> Sent: 2018年3月15日 19:21
> To: Jun Li <jun...@nxp.com>
> Cc: robh...@kernel.org; mark.rutl...@arm.com;
> gre...@linuxfoundation.org; a.ha...@samsung.com; li...@roeck-us.net;
> yue...@google.com; shufan_...@richtek.com; o_leve...@orange.fr;
> linux-usb@vger.kernel.org; dl-linux-imx <linux-...@nxp.com>
> Subject: Re: [PATCH v3 05/12] usb: typec: add API to get sink and source
> config
> 
> 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...@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 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -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",
> > + >max_snk_mv) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "max-sink-microamp",
> > + >max_snk_ma) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> > + >max_snk_mw) < 0) ||
> > +   (fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> > + >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.

OK, I will read those properties directly to port->typec_caps without involve
tcpc->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;
> > + 

Re: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-15 Thread Mats Karrman

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 
---
  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 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -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",
+ >max_snk_mv) < 0) ||
+   (fwnode_property_read_u32(fwnode, "max-sink-microamp",
+ >max_snk_ma) < 0) ||
+   (fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
+ >max_snk_mw) < 0) ||
+   (fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
+ >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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-15 Thread Heikki Krogerus
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 
> ---
>  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 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -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",
> +   >max_snk_mv) < 0) ||
> + (fwnode_property_read_u32(fwnode, "max-sink-microamp",
> +   >max_snk_ma) < 0) ||
> + (fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> +   >max_snk_mw) < 0) ||
> + (fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> +   >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

-- 
heikki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 05/12] usb: typec: add API to get sink and source config

2018-03-15 Thread Heikki Krogerus
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 
> ---
>  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 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -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",
> +   >max_snk_mv) < 0) ||
> + (fwnode_property_read_u32(fwnode, "max-sink-microamp",
> +   >max_snk_ma) < 0) ||
> + (fwnode_property_read_u32(fwnode, "max-sink-microwatt-hours",
> +   >max_snk_mw) < 0) ||
> + (fwnode_property_read_u32(fwnode, "op-sink-microwatt-hours",
> +   >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,

-- 
heikki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html