* [v6,04/15] usb: typec: add fwnode to tcpc
@ 2018-05-28 2:52 Jun Li
0 siblings, 0 replies; 2+ messages in thread
From: Jun Li @ 2018-05-28 2:52 UTC (permalink / raw)
To: robh+dt, gregkh, heikki.krogerus, linux
Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
jun.li, linux-usb, devicetree, linux-imx
Add fwnode handle to get the fwnode so we can get typec configs
it contains.
Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
drivers/staging/typec/tcpci.c | 7 +++++++
drivers/usb/typec/tcpm.c | 1 +
include/linux/usb/tcpm.h | 2 ++
3 files changed, 10 insertions(+)
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index dd29288..e59547a 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/usb/pd.h>
#include <linux/usb/tcpm.h>
@@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
/* TODO: Populate struct tcpc_config from ACPI/device-tree */
tcpci->tcpc.config = &tcpci_tcpc_config;
+ tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
+ "connector");
+ if (!tcpci->tcpc.fwnode) {
+ dev_err(tcpci->dev, "Can't find connector node.\n");
+ return -EINVAL;
+ }
return 0;
}
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 0ccd2ce..fcd22e8 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
else
port->try_role = TYPEC_NO_PREFERRED_ROLE;
+ port->typec_caps.fwnode = tcpc->fwnode;
port->typec_caps.prefer_role = tcpc->config->default_role;
port->typec_caps.type = tcpc->config->type;
port->typec_caps.data = tcpc->config->data;
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index b231b93..193920a 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -110,6 +110,7 @@ enum tcpc_mux_mode {
/**
* struct tcpc_dev - Port configuration and callback functions
* @config: Pointer to port configuration
+ * @fwnode: Pointer to port fwnode
* @get_vbus: Called to read current VBUS state
* @get_current_limit:
* Optional; called by the tcpm core when configured as a snk
@@ -138,6 +139,7 @@ enum tcpc_mux_mode {
*/
struct tcpc_dev {
const struct tcpc_config *config;
+ struct fwnode_handle *fwnode;
int (*init)(struct tcpc_dev *dev);
int (*get_vbus)(struct tcpc_dev *dev);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [v6,04/15] usb: typec: add fwnode to tcpc
@ 2018-06-11 11:44 Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2018-06-11 11:44 UTC (permalink / raw)
To: Li Jun
Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx
On Mon, May 28, 2018 at 10:52:36AM +0800, Li Jun wrote:
> Add fwnode handle to get the fwnode so we can get typec configs
> it contains.
>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/staging/typec/tcpci.c | 7 +++++++
> drivers/usb/typec/tcpm.c | 1 +
> include/linux/usb/tcpm.h | 2 ++
> 3 files changed, 10 insertions(+)
>
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index dd29288..e59547a 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -10,6 +10,7 @@
> #include <linux/module.h>
> #include <linux/i2c.h>
> #include <linux/interrupt.h>
> +#include <linux/property.h>
> #include <linux/regmap.h>
> #include <linux/usb/pd.h>
> #include <linux/usb/tcpm.h>
> @@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
>
> /* TODO: Populate struct tcpc_config from ACPI/device-tree */
> tcpci->tcpc.config = &tcpci_tcpc_config;
> + tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
> + "connector");
> + if (!tcpci->tcpc.fwnode) {
> + dev_err(tcpci->dev, "Can't find connector node.\n");
> + return -EINVAL;
> + }
>
> return 0;
> }
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 0ccd2ce..fcd22e8 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
> else
> port->try_role = TYPEC_NO_PREFERRED_ROLE;
>
> + port->typec_caps.fwnode = tcpc->fwnode;
> port->typec_caps.prefer_role = tcpc->config->default_role;
> port->typec_caps.type = tcpc->config->type;
> port->typec_caps.data = tcpc->config->data;
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index b231b93..193920a 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -110,6 +110,7 @@ enum tcpc_mux_mode {
> /**
> * struct tcpc_dev - Port configuration and callback functions
> * @config: Pointer to port configuration
> + * @fwnode: Pointer to port fwnode
> * @get_vbus: Called to read current VBUS state
> * @get_current_limit:
> * Optional; called by the tcpm core when configured as a snk
> @@ -138,6 +139,7 @@ enum tcpc_mux_mode {
> */
> struct tcpc_dev {
> const struct tcpc_config *config;
> + struct fwnode_handle *fwnode;
>
> int (*init)(struct tcpc_dev *dev);
> int (*get_vbus)(struct tcpc_dev *dev);
> --
> 2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-11 11:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 2:52 [v6,04/15] usb: typec: add fwnode to tcpc Jun Li
-- strict thread matches above, loose matches on Subject: below --
2018-06-11 11:44 Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).