linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] staging: typec: tcpci: declare private structure as static
@ 2017-05-09 16:04 Guenter Roeck
  2017-05-09 16:04 ` [PATCH 2/7] staging: typec: fusb302: Fix module autoload Guenter Roeck
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Yueyao Zhu, devel, linux-kernel, Olivier Leveque, Guenter Roeck

From: Olivier Leveque <o_leveque@orange.fr>

This fixes a sparse warning regarding an undeclared symbol. Since the
structure tcpci_tcpc_config is private to tcpci.c, it should be declared as
static.

Signed-off-by: Olivier Leveque <o_leveque@orange.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/tcpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 5e5be74c7850..df72d8b01e73 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -425,7 +425,7 @@ static const struct regmap_config tcpci_regmap_config = {
 	.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
 };
 
-const struct tcpc_config tcpci_tcpc_config = {
+static const struct tcpc_config tcpci_tcpc_config = {
 	.type = TYPEC_PORT_DFP,
 	.default_role = TYPEC_SINK,
 };
-- 
2.7.4

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

* [PATCH 2/7] staging: typec: fusb302: Fix module autoload
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 16:04 ` [PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value Guenter Roeck
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Yueyao Zhu, devel, linux-kernel, Javier Martinez Canillas, Guenter Roeck

From: Javier Martinez Canillas <javier@dowhile0.org>

If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the OF and I2C device ID table entries as module aliases, using the
MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/staging/typec/fusb302/fusb302.ko | grep alias
$

After this patch:

$ modinfo drivers/staging/typec/fusb302/fusb302.ko | grep alias
alias:          of:N*T*Cfcs,fusb302C*
alias:          of:N*T*Cfcs,fusb302
alias:          i2c:typec_fusb302

Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/fusb302/fusb302.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c
index 2cee9a952c9b..aa460f93a293 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1787,11 +1787,13 @@ static const struct of_device_id fusb302_dt_match[] = {
 	{.compatible = "fcs,fusb302"},
 	{},
 };
+MODULE_DEVICE_TABLE(of, fusb302_dt_match);
 
 static const struct i2c_device_id fusb302_i2c_device_id[] = {
 	{"typec_fusb302", 0},
 	{},
 };
+MODULE_DEVICE_TABLE(i2c, fusb302_i2c_device_id);
 
 static const struct dev_pm_ops fusb302_pm_ops = {
 	.suspend = fusb302_pm_suspend,
-- 
2.7.4

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

* [PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
  2017-05-09 16:04 ` [PATCH 2/7] staging: typec: fusb302: Fix module autoload Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 16:04 ` [PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages Guenter Roeck
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Yueyao Zhu, devel, linux-kernel, Guenter Roeck

From: Yueyao Zhu <yueyao.zhu@gmail.com>

FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK = 0x40 & 0x80 is always
zero. Fix the code to what it is intended to be: check the VBUSOK
bit of the value read from address FUSB_REG_STATUS0.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Yueyao Zhu <yueyao.zhu@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/fusb302/fusb302.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c
index aa460f93a293..d8b50b49bb2d 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -489,7 +489,7 @@ static int tcpm_init(struct tcpc_dev *dev)
 	ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data);
 	if (ret < 0)
 		return ret;
-	chip->vbus_present = !!(FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK);
+	chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK);
 	ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data);
 	if (ret < 0)
 		return ret;
-- 
2.7.4

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

* [PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
  2017-05-09 16:04 ` [PATCH 2/7] staging: typec: fusb302: Fix module autoload Guenter Roeck
  2017-05-09 16:04 ` [PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 16:04 ` [PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages Guenter Roeck
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Yueyao Zhu, devel, linux-kernel, Guenter Roeck

Per USB PD standard, we have to drop duplicate PD messages.
We can not expect lower protocol layers to drop such messages,
since lower layers don't know if a message was dropped somewhere
else in the stack.

Originally-from: Puma Hsu <puma_hsu@htc.com>
Cc: Yueyao Zhu <yueyao.zhu@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/pd.h   | 10 ++++++++++
 drivers/staging/typec/tcpm.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h
index 8d97bdb95f23..510ef7279900 100644
--- a/drivers/staging/typec/pd.h
+++ b/drivers/staging/typec/pd.h
@@ -92,6 +92,16 @@ static inline unsigned int pd_header_type_le(__le16 header)
 	return pd_header_type(le16_to_cpu(header));
 }
 
+static inline unsigned int pd_header_msgid(u16 header)
+{
+	return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK;
+}
+
+static inline unsigned int pd_header_msgid_le(__le16 header)
+{
+	return pd_header_msgid(le16_to_cpu(header));
+}
+
 #define PD_MAX_PAYLOAD		7
 
 struct pd_message {
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index abba655ba00a..c5d8b129c4f4 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -238,6 +238,7 @@ struct tcpm_port {
 	unsigned int hard_reset_count;
 	bool pd_capable;
 	bool explicit_contract;
+	unsigned int rx_msgid;
 
 	/* Partner capabilities/requests */
 	u32 sink_request;
@@ -1415,6 +1416,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 			break;
 		case SOFT_RESET_SEND:
 			port->message_id = 0;
+			port->rx_msgid = -1;
 			if (port->pwr_role == TYPEC_SOURCE)
 				next_state = SRC_SEND_CAPABILITIES;
 			else
@@ -1503,6 +1505,22 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
 		 port->attached);
 
 	if (port->attached) {
+		enum pd_ctrl_msg_type type = pd_header_type_le(msg->header);
+		unsigned int msgid = pd_header_msgid_le(msg->header);
+
+		/*
+		 * USB PD standard, 6.6.1.2:
+		 * "... if MessageID value in a received Message is the
+		 * same as the stored value, the receiver shall return a
+		 * GoodCRC Message with that MessageID value and drop
+		 * the Message (this is a retry of an already received
+		 * Message). Note: this shall not apply to the Soft_Reset
+		 * Message which always has a MessageID value of zero."
+		 */
+		if (msgid == port->rx_msgid && type != PD_CTRL_SOFT_RESET)
+			goto done;
+		port->rx_msgid = msgid;
+
 		/*
 		 * If both ends believe to be DFP/host, we have a data role
 		 * mismatch.
@@ -1520,6 +1538,7 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
 		}
 	}
 
+done:
 	mutex_unlock(&port->lock);
 	kfree(event);
 }
@@ -1957,6 +1976,12 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	port->attached = false;
 	port->pd_capable = false;
 
+	/*
+	 * First Rx ID should be 0; set this to a sentinel of -1 so that
+	 * we can check tcpm_pd_rx_handler() if we had seen it before.
+	 */
+	port->rx_msgid = -1;
+
 	port->tcpc->set_pd_rx(port->tcpc, false);
 	tcpm_init_vbus(port);	/* also disables charging */
 	tcpm_init_vconn(port);
@@ -2170,6 +2195,7 @@ static void run_state_machine(struct tcpm_port *port)
 		port->pwr_opmode = TYPEC_PWR_MODE_USB;
 		port->caps_count = 0;
 		port->message_id = 0;
+		port->rx_msgid = -1;
 		port->explicit_contract = false;
 		tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
 		break;
@@ -2329,6 +2355,7 @@ static void run_state_machine(struct tcpm_port *port)
 		typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB);
 		port->pwr_opmode = TYPEC_PWR_MODE_USB;
 		port->message_id = 0;
+		port->rx_msgid = -1;
 		port->explicit_contract = false;
 		tcpm_set_state(port, SNK_DISCOVERY, 0);
 		break;
@@ -2496,6 +2523,7 @@ static void run_state_machine(struct tcpm_port *port)
 	/* Soft_Reset states */
 	case SOFT_RESET:
 		port->message_id = 0;
+		port->rx_msgid = -1;
 		tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
 		if (port->pwr_role == TYPEC_SOURCE)
 			tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
@@ -2504,6 +2532,7 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 	case SOFT_RESET_SEND:
 		port->message_id = 0;
+		port->rx_msgid = -1;
 		if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
 			tcpm_set_state_cond(port, hard_reset_state(port), 0);
 		else
-- 
2.7.4

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

* [PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
                   ` (2 preceding siblings ...)
  2017-05-09 16:04 ` [PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 16:04 ` [PATCH 6/7] staging: typec: tcpm: Respond to Discover Identity commands Guenter Roeck
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Yueyao Zhu, devel, linux-kernel, Guenter Roeck

We do support USB PD communication, and devices supported by this driver
typically use USB power for purposes other than USB communication.

Originally-from: Puma Hsu <puma_hsu@htc.com>
Cc: Yueyao Zhu <yueyao.zhu@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index c5d8b129c4f4..a385f7e2a6fd 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1738,8 +1738,7 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo)
 	}
 	ma = min(ma, port->max_snk_ma);
 
-	/* XXX: Any other flags need to be set? */
-	flags = 0;
+	flags = RDO_USB_COMM | RDO_NO_SUSPEND;
 
 	/* Set mismatch bit if offered power is less than operating power */
 	mw = ma * mv / 1000;
-- 
2.7.4

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

* [PATCH 6/7] staging: typec: tcpm: Respond to Discover Identity commands
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
                   ` (3 preceding siblings ...)
  2017-05-09 16:04 ` [PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 16:04 ` [PATCH 7/7] staging: typec: tcpm: Fix Port Power Role field in PS_RDY messages Guenter Roeck
  2017-05-09 17:46 ` [PATCH 1/7] staging: typec: tcpci: declare private structure as static Greg Kroah-Hartman
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Yueyao Zhu, devel, linux-kernel, Guenter Roeck

If the lower level driver provided a list of VDOs in its configuration
data, send it to the partner as response to a Discover Identity command
if in device mode (UFP).

Cc: Yueyao Zhu <yueyao.zhu@gmail.com>
Originally-from: Puma Hsu <puma_hsu@htc.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/pd_vdo.h |  4 +++-
 drivers/staging/typec/tcpm.c   | 27 +++++++++++++++++++++++++++
 drivers/staging/typec/tcpm.h   |  3 +++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/typec/pd_vdo.h b/drivers/staging/typec/pd_vdo.h
index dba172e0e0d1..d92259f8de0a 100644
--- a/drivers/staging/typec/pd_vdo.h
+++ b/drivers/staging/typec/pd_vdo.h
@@ -22,6 +22,9 @@
  * VDM object is minimum of VDM header + 6 additional data objects.
  */
 
+#define VDO_MAX_OBJECTS		6
+#define VDO_MAX_SIZE		(VDO_MAX_OBJECTS + 1)
+
 /*
  * VDM header
  * ----------
@@ -34,7 +37,6 @@
  * <5>      :: reserved (SVDM), command type (UVDM)
  * <4:0>    :: command
  */
-#define VDO_MAX_SIZE 7
 #define VDO(vid, type, custom)				\
 	(((vid) << 16) |				\
 	 ((type) << 15) |				\
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index a385f7e2a6fd..c749e980ddf9 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -252,6 +252,8 @@ struct tcpm_port {
 	unsigned int nr_src_pdo;
 	u32 snk_pdo[PDO_MAX_OBJECTS];
 	unsigned int nr_snk_pdo;
+	u32 snk_vdo[VDO_MAX_OBJECTS];
+	unsigned int nr_snk_vdo;
 
 	unsigned int max_snk_mv;
 	unsigned int max_snk_ma;
@@ -998,6 +1000,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
 	struct pd_mode_data *modep;
 	int rlen = 0;
 	u16 svid;
+	int i;
 
 	tcpm_log(port, "Rx VDM cmd 0x%x type %d cmd %d len %d",
 		 p0, cmd_type, cmd, cnt);
@@ -1008,6 +1011,14 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
 	case CMDT_INIT:
 		switch (cmd) {
 		case CMD_DISCOVER_IDENT:
+			/* 6.4.4.3.1: Only respond as UFP (device) */
+			if (port->data_role == TYPEC_DEVICE &&
+			    port->nr_snk_vdo) {
+				for (i = 0; i <  port->nr_snk_vdo; i++)
+					response[i + 1]
+						= cpu_to_le32(port->snk_vdo[i]);
+				rlen = port->nr_snk_vdo + 1;
+			}
 			break;
 		case CMD_DISCOVER_SVID:
 			break;
@@ -3320,6 +3331,20 @@ static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo,
 	return nr_pdo;
 }
 
+static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
+			  unsigned int nr_vdo)
+{
+	unsigned int i;
+
+	if (nr_vdo > VDO_MAX_OBJECTS)
+		nr_vdo = VDO_MAX_OBJECTS;
+
+	for (i = 0; i < nr_vdo; i++)
+		dest_vdo[i] = src_vdo[i];
+
+	return nr_vdo;
+}
+
 void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
 				     unsigned int nr_pdo)
 {
@@ -3410,6 +3435,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 					  tcpc->config->nr_src_pdo);
 	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
 					  tcpc->config->nr_snk_pdo);
+	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
+					  tcpc->config->nr_snk_vdo);
 
 	port->max_snk_mv = tcpc->config->max_snk_mv;
 	port->max_snk_ma = tcpc->config->max_snk_ma;
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 969b365e6549..19c307d31a5a 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -60,6 +60,9 @@ struct tcpc_config {
 	const u32 *snk_pdo;
 	unsigned int nr_snk_pdo;
 
+	const u32 *snk_vdo;
+	unsigned int nr_snk_vdo;
+
 	unsigned int max_snk_mv;
 	unsigned int max_snk_ma;
 	unsigned int max_snk_mw;
-- 
2.7.4

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

* [PATCH 7/7] staging: typec: tcpm: Fix Port Power Role field in PS_RDY messages
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
                   ` (4 preceding siblings ...)
  2017-05-09 16:04 ` [PATCH 6/7] staging: typec: tcpm: Respond to Discover Identity commands Guenter Roeck
@ 2017-05-09 16:04 ` Guenter Roeck
  2017-05-09 17:46 ` [PATCH 1/7] staging: typec: tcpci: declare private structure as static Greg Kroah-Hartman
  6 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 16:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Yueyao Zhu, devel, linux-kernel, Guenter Roeck

PS_RDY messages sent during power swap sequences are expected to reflect
the new power role.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/staging/typec/tcpm.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index c749e980ddf9..20eb4ebcf8c3 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -2607,6 +2607,14 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 	case PR_SWAP_SRC_SNK_SOURCE_OFF:
 		tcpm_set_cc(port, TYPEC_CC_RD);
+		/*
+		 * USB-PD standard, 6.2.1.4, Port Power Role:
+		 * "During the Power Role Swap Sequence, for the initial Source
+		 * Port, the Port Power Role field shall be set to Sink in the
+		 * PS_RDY Message indicating that the initial Source’s power
+		 * supply is turned off"
+		 */
+		tcpm_set_pwr_role(port, TYPEC_SINK);
 		if (tcpm_pd_send_control(port, PD_CTRL_PS_RDY)) {
 			tcpm_set_state(port, ERROR_RECOVERY, 0);
 			break;
@@ -2614,7 +2622,6 @@ static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON);
 		break;
 	case PR_SWAP_SRC_SNK_SINK_ON:
-		tcpm_set_pwr_role(port, TYPEC_SINK);
 		tcpm_swap_complete(port, 0);
 		tcpm_set_state(port, SNK_STARTUP, 0);
 		break;
@@ -2626,8 +2633,15 @@ static void run_state_machine(struct tcpm_port *port)
 	case PR_SWAP_SNK_SRC_SOURCE_ON:
 		tcpm_set_cc(port, tcpm_rp_cc(port));
 		tcpm_set_vbus(port, true);
-		tcpm_pd_send_control(port, PD_CTRL_PS_RDY);
+		/*
+		 * USB PD standard, 6.2.1.4:
+		 * "Subsequent Messages initiated by the Policy Engine,
+		 * such as the PS_RDY Message sent to indicate that Vbus
+		 * is ready, will have the Port Power Role field set to
+		 * Source."
+		 */
 		tcpm_set_pwr_role(port, TYPEC_SOURCE);
+		tcpm_pd_send_control(port, PD_CTRL_PS_RDY);
 		tcpm_swap_complete(port, 0);
 		tcpm_set_state(port, SRC_STARTUP, 0);
 		break;
-- 
2.7.4

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

* Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static
  2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
                   ` (5 preceding siblings ...)
  2017-05-09 16:04 ` [PATCH 7/7] staging: typec: tcpm: Fix Port Power Role field in PS_RDY messages Guenter Roeck
@ 2017-05-09 17:46 ` Greg Kroah-Hartman
  2017-05-09 21:13   ` Guenter Roeck
  6 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-05-09 17:46 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: devel, Yueyao Zhu, Olivier Leveque, linux-kernel

On Tue, May 09, 2017 at 09:04:53AM -0700, Guenter Roeck wrote:
> From: Olivier Leveque <o_leveque@orange.fr>
> 
> This fixes a sparse warning regarding an undeclared symbol. Since the
> structure tcpci_tcpc_config is private to tcpci.c, it should be declared as
> static.
> 
> Signed-off-by: Olivier Leveque <o_leveque@orange.fr>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/staging/typec/tcpci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Are any of these bugfixes for 4.12-stable, or can they wait for
4.13-rc1?

thanks,

greg k-h

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

* Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static
  2017-05-09 17:46 ` [PATCH 1/7] staging: typec: tcpci: declare private structure as static Greg Kroah-Hartman
@ 2017-05-09 21:13   ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2017-05-09 21:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Yueyao Zhu, Olivier Leveque, linux-kernel

On Tue, May 09, 2017 at 07:46:17PM +0200, Greg Kroah-Hartman wrote:
> On Tue, May 09, 2017 at 09:04:53AM -0700, Guenter Roeck wrote:
> > From: Olivier Leveque <o_leveque@orange.fr>
> > 
> > This fixes a sparse warning regarding an undeclared symbol. Since the
> > structure tcpci_tcpc_config is private to tcpci.c, it should be declared as
> > static.
> > 
> > Signed-off-by: Olivier Leveque <o_leveque@orange.fr>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> >  drivers/staging/typec/tcpci.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Are any of these bugfixes for 4.12-stable, or can they wait for
> 4.13-rc1?
> 

They should all go into v4.12. There are no functionality enhancements,
only real bug fixes.

Thanks,
Guenter

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

end of thread, other threads:[~2017-05-09 21:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 16:04 [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck
2017-05-09 16:04 ` [PATCH 2/7] staging: typec: fusb302: Fix module autoload Guenter Roeck
2017-05-09 16:04 ` [PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value Guenter Roeck
2017-05-09 16:04 ` [PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages Guenter Roeck
2017-05-09 16:04 ` [PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages Guenter Roeck
2017-05-09 16:04 ` [PATCH 6/7] staging: typec: tcpm: Respond to Discover Identity commands Guenter Roeck
2017-05-09 16:04 ` [PATCH 7/7] staging: typec: tcpm: Fix Port Power Role field in PS_RDY messages Guenter Roeck
2017-05-09 17:46 ` [PATCH 1/7] staging: typec: tcpci: declare private structure as static Greg Kroah-Hartman
2017-05-09 21:13   ` Guenter Roeck

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).