2022-12-28 01:38:24

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 00/10] platform/chrome: cros_ec_typec: VDM support

This series adds support for sending and receiving USB PD Vendor
Defined Messages (VDMs) between the Application Processor's Type-C
ports and connected peripherals.

Thir enables the Application processor to enter alternate modes and
process VDMs directly, instead of relying on state machines that exist
inside of co-processors like the ChromeOS Embedded Controller (EC).

Patch 1/10 reverts an incorrect EC header modification.
Patch 2/10 to 5/10 update headers and existing Type-C structs to
accommodate the VDM code.
Patch 6/10 and 7/10 prepare the Type-C driver to have more than 1 file.
Patch 8/10 to 10/10 introduce the VDM functionality.

Patch submissions suggestion (if approved):
- Even though Patch 1 touches drivers/mfd, it would be better to take
the entire series through the cbrome-platform branch, to avoid
cross-dependencies across maintainer trees.


Prashant Malani (10):
Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
platform_chrome: cros_ec: Add Type-C VDM defines
platform/chrome: cros_ec_typec: Stash port driver info
platform/chrome: cros_ec_typec: Set port alt mode drvdata
platform/chrome: cros_ec_typec: Update port DP VDO
platform/chrome: cros_ec_typec: Move structs to header
platform/chrome: cros_ec_typec: Alter module name with hyphens
platform/chrome: cros_ec_typec: Add initial VDM support
platform/chrome: cros_typec_vdm: Add VDM reply support
platform/chrome: cros_typec_vdm: Add VDM send support

MAINTAINERS | 3 +-
drivers/mfd/cros_ec_dev.c | 5 -
drivers/platform/chrome/Kconfig | 2 +-
drivers/platform/chrome/Makefile | 3 +-
drivers/platform/chrome/cros_ec_typec.c | 91 +++------------
drivers/platform/chrome/cros_ec_typec.h | 85 ++++++++++++++
drivers/platform/chrome/cros_typec_vdm.c | 106 ++++++++++++++++++
drivers/platform/chrome/cros_typec_vdm.h | 12 ++
.../linux/platform_data/cros_ec_commands.h | 53 ++++++++-
include/linux/platform_data/cros_ec_proto.h | 1 -
10 files changed, 276 insertions(+), 85 deletions(-)
create mode 100644 drivers/platform/chrome/cros_ec_typec.h
create mode 100644 drivers/platform/chrome/cros_typec_vdm.c
create mode 100644 drivers/platform/chrome/cros_typec_vdm.h

--
2.39.0.314.g84b9a713c41-goog


2022-12-28 01:38:52

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 03/10] platform/chrome: cros_ec_typec: Stash port driver info

Stash port number and a pointer to the driver-specific struct in the
local typec port struct.

These can be useful to the port driver to figure out how to communicate
with the Chrome EC when an altmode-driver related callback is invoked
from the Type-C class code.

Signed-off-by: Prashant Malani <[email protected]>
---
drivers/platform/chrome/cros_ec_typec.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 001b0de95a46..bc8dc8bd90b3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -45,6 +45,7 @@ struct cros_typec_altmode_node {
/* Per port data. */
struct cros_typec_port {
struct typec_port *port;
+ int port_num;
/* Initial capabilities for the port. */
struct typec_capability caps;
struct typec_partner *partner;
@@ -78,6 +79,8 @@ struct cros_typec_port {
struct usb_power_delivery *partner_pd;
struct usb_power_delivery_capabilities *partner_src_caps;
struct usb_power_delivery_capabilities *partner_sink_caps;
+
+ struct cros_typec_data *typec_data;
};

/* Platform-specific data for the Chrome OS EC Type C controller. */
@@ -408,6 +411,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
goto unregister_ports;
}

+ cros_port->port_num = port_num;
+ cros_port->typec_data = typec;
typec->ports[port_num] = cros_port;
cap = &cros_port->caps;

--
2.39.0.314.g84b9a713c41-goog

2022-12-28 01:39:08

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 06/10] platform/chrome: cros_ec_typec: Move structs to header

Move ChromeOS Type-C structs into their own header, so they can be
referenced by other files which can be added to the same module.

No functional changes introduced by this patch.

Signed-off-by: Prashant Malani <[email protected]>
---
MAINTAINERS | 2 +-
drivers/platform/chrome/cros_ec_typec.c | 78 +----------------------
drivers/platform/chrome/cros_ec_typec.h | 85 +++++++++++++++++++++++++
3 files changed, 88 insertions(+), 77 deletions(-)
create mode 100644 drivers/platform/chrome/cros_ec_typec.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f61eb221415b..8219b646ab50 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4998,7 +4998,7 @@ CHROMEOS EC USB TYPE-C DRIVER
M: Prashant Malani <[email protected]>
L: [email protected]
S: Maintained
-F: drivers/platform/chrome/cros_ec_typec.c
+F: drivers/platform/chrome/cros_ec_typec.*
F: drivers/platform/chrome/cros_typec_switch.c

CHROMEOS EC USB PD NOTIFY DRIVER
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 665fa76e2416..a4eff590ca56 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -7,96 +7,22 @@
*/

#include <linux/acpi.h>
-#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_data/cros_ec_commands.h>
-#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_data/cros_usbpd_notify.h>
#include <linux/platform_device.h>
-#include <linux/usb/pd.h>
#include <linux/usb/pd_vdo.h>
-#include <linux/usb/typec.h>
-#include <linux/usb/typec_altmode.h>
#include <linux/usb/typec_dp.h>
-#include <linux/usb/typec_mux.h>
-#include <linux/usb/typec_retimer.h>
#include <linux/usb/typec_tbt.h>
-#include <linux/usb/role.h>
+
+#include "cros_ec_typec.h"

#define DRV_NAME "cros-ec-typec"

#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \
DP_CAP_DFP_D | DP_CAP_RECEPTACLE)

-/* Supported alt modes. */
-enum {
- CROS_EC_ALTMODE_DP = 0,
- CROS_EC_ALTMODE_TBT,
- CROS_EC_ALTMODE_MAX,
-};
-
-/* Container for altmode pointer nodes. */
-struct cros_typec_altmode_node {
- struct typec_altmode *amode;
- struct list_head list;
-};
-
-/* Per port data. */
-struct cros_typec_port {
- struct typec_port *port;
- int port_num;
- /* Initial capabilities for the port. */
- struct typec_capability caps;
- struct typec_partner *partner;
- struct typec_cable *cable;
- /* SOP' plug. */
- struct typec_plug *plug;
- /* Port partner PD identity info. */
- struct usb_pd_identity p_identity;
- /* Port cable PD identity info. */
- struct usb_pd_identity c_identity;
- struct typec_switch *ori_sw;
- struct typec_mux *mux;
- struct typec_retimer *retimer;
- struct usb_role_switch *role_sw;
-
- /* Variables keeping track of switch state. */
- struct typec_mux_state state;
- uint8_t mux_flags;
- uint8_t role;
-
- struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX];
-
- /* Flag indicating that PD partner discovery data parsing is completed. */
- bool sop_disc_done;
- bool sop_prime_disc_done;
- struct ec_response_typec_discovery *disc_data;
- struct list_head partner_mode_list;
- struct list_head plug_mode_list;
-
- /* PDO-related structs */
- struct usb_power_delivery *partner_pd;
- struct usb_power_delivery_capabilities *partner_src_caps;
- struct usb_power_delivery_capabilities *partner_sink_caps;
-
- struct cros_typec_data *typec_data;
-};
-
-/* Platform-specific data for the Chrome OS EC Type C controller. */
-struct cros_typec_data {
- struct device *dev;
- struct cros_ec_device *ec;
- int num_ports;
- unsigned int pd_ctrl_ver;
- /* Array of ports, indexed by port number. */
- struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS];
- struct notifier_block nb;
- struct work_struct port_work;
- bool typec_cmd_supported;
- bool needs_mux_ack;
-};
-
static int cros_typec_parse_port_props(struct typec_capability *cap,
struct fwnode_handle *fwnode,
struct device *dev)
diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h
new file mode 100644
index 000000000000..deda180a646f
--- /dev/null
+++ b/drivers/platform/chrome/cros_ec_typec.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __CROS_EC_TYPEC__
+#define __CROS_EC_TYPEC__
+
+#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/platform_data/cros_ec_proto.h>
+#include <linux/usb/pd.h>
+#include <linux/usb/role.h>
+#include <linux/usb/typec.h>
+#include <linux/usb/typec_altmode.h>
+#include <linux/usb/typec_mux.h>
+#include <linux/usb/typec_retimer.h>
+#include <linux/workqueue.h>
+
+/* Supported alt modes. */
+enum {
+ CROS_EC_ALTMODE_DP = 0,
+ CROS_EC_ALTMODE_TBT,
+ CROS_EC_ALTMODE_MAX,
+};
+
+/* Container for altmode pointer nodes. */
+struct cros_typec_altmode_node {
+ struct typec_altmode *amode;
+ struct list_head list;
+};
+
+/* Platform-specific data for the Chrome OS EC Type C controller. */
+struct cros_typec_data {
+ struct device *dev;
+ struct cros_ec_device *ec;
+ int num_ports;
+ unsigned int pd_ctrl_ver;
+ /* Array of ports, indexed by port number. */
+ struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS];
+ struct notifier_block nb;
+ struct work_struct port_work;
+ bool typec_cmd_supported;
+ bool needs_mux_ack;
+};
+
+/* Per port data. */
+struct cros_typec_port {
+ struct typec_port *port;
+ int port_num;
+ /* Initial capabilities for the port. */
+ struct typec_capability caps;
+ struct typec_partner *partner;
+ struct typec_cable *cable;
+ /* SOP' plug. */
+ struct typec_plug *plug;
+ /* Port partner PD identity info. */
+ struct usb_pd_identity p_identity;
+ /* Port cable PD identity info. */
+ struct usb_pd_identity c_identity;
+ struct typec_switch *ori_sw;
+ struct typec_mux *mux;
+ struct typec_retimer *retimer;
+ struct usb_role_switch *role_sw;
+
+ /* Variables keeping track of switch state. */
+ struct typec_mux_state state;
+ uint8_t mux_flags;
+ uint8_t role;
+
+ struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX];
+
+ /* Flag indicating that PD partner discovery data parsing is completed. */
+ bool sop_disc_done;
+ bool sop_prime_disc_done;
+ struct ec_response_typec_discovery *disc_data;
+ struct list_head partner_mode_list;
+ struct list_head plug_mode_list;
+
+ /* PDO-related structs */
+ struct usb_power_delivery *partner_pd;
+ struct usb_power_delivery_capabilities *partner_src_caps;
+ struct usb_power_delivery_capabilities *partner_sink_caps;
+
+ struct cros_typec_data *typec_data;
+};
+
+#endif /* __CROS_EC_TYPEC__ */
--
2.39.0.314.g84b9a713c41-goog

2022-12-28 01:39:09

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 08/10] platform/chrome: cros_ec_typec: Add initial VDM support

Add ops to support USB PD VDM (Vendor Defined Message) from the port
driver. This enables the port driver to interface with alternate mode
drivers and communicate with connected peripherals.

The initial support just contains an implementation of the Enter
Mode command.

Cc: Heikki Krogerus <[email protected]>
Signed-off-by: Prashant Malani <[email protected]>
---
MAINTAINERS | 1 +
drivers/platform/chrome/Makefile | 2 +-
drivers/platform/chrome/cros_ec_typec.c | 3 ++
drivers/platform/chrome/cros_typec_vdm.c | 43 ++++++++++++++++++++++++
drivers/platform/chrome/cros_typec_vdm.h | 10 ++++++
5 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 drivers/platform/chrome/cros_typec_vdm.c
create mode 100644 drivers/platform/chrome/cros_typec_vdm.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 8219b646ab50..cfccbbbb083f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5000,6 +5000,7 @@ L: [email protected]
S: Maintained
F: drivers/platform/chrome/cros_ec_typec.*
F: drivers/platform/chrome/cros_typec_switch.c
+F: drivers/platform/chrome/cros_typec_vdm.*

CHROMEOS EC USB PD NOTIFY DRIVER
M: Prashant Malani <[email protected]>
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index fd29fa74ba33..dae0ed3c8656 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o
obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
-cros-ec-typec-objs := cros_ec_typec.o
+cros-ec-typec-objs := cros_ec_typec.o cros_typec_vdm.o
obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index a4eff590ca56..1e28d56b094d 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -17,6 +17,7 @@
#include <linux/usb/typec_tbt.h>

#include "cros_ec_typec.h"
+#include "cros_typec_vdm.h"

#define DRV_NAME "cros-ec-typec"

@@ -272,6 +273,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,
return PTR_ERR(amode);
port->port_altmode[CROS_EC_ALTMODE_DP] = amode;
typec_altmode_set_drvdata(amode, port);
+ amode->ops = &port_amode_ops;

/*
* Register TBT compatibility alt mode. The EC will not enter the mode
@@ -286,6 +288,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,
return PTR_ERR(amode);
port->port_altmode[CROS_EC_ALTMODE_TBT] = amode;
typec_altmode_set_drvdata(amode, port);
+ amode->ops = &port_amode_ops;

port->state.alt = NULL;
port->state.mode = TYPEC_STATE_USB;
diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
new file mode 100644
index 000000000000..df0102ca3a18
--- /dev/null
+++ b/drivers/platform/chrome/cros_typec_vdm.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * USB Power Delivery Vendor Defined Message (VDM) support code.
+ *
+ * Copyright 2023 Google LLC
+ * Author: Prashant Malani <[email protected]>
+ */
+
+#include <linux/module.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/usb/pd_vdo.h>
+
+#include "cros_ec_typec.h"
+#include "cros_typec_vdm.h"
+
+static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo)
+{
+ struct cros_typec_port *port = typec_altmode_get_drvdata(amode);
+ struct ec_params_typec_control req = {
+ .port = port->port_num,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ };
+ struct typec_vdm_req vdm_req = {};
+ u32 hdr;
+
+ hdr = VDO(amode->svid, 1, SVDM_VER_2_0, CMD_ENTER_MODE);
+ hdr |= VDO_OPOS(amode->mode);
+
+ vdm_req.vdm_data[0] = hdr;
+ vdm_req.vdm_data_objects = 1;
+ vdm_req.partner_type = TYPEC_PARTNER_SOP;
+ req.vdm_req_params = vdm_req;
+
+ dev_dbg(port->typec_data->dev, "Sending EnterMode VDM, hdr: %x, port: %d\n",
+ hdr, port->port_num);
+
+ return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
+ sizeof(req), NULL, 0);
+}
+
+struct typec_altmode_ops port_amode_ops = {
+ .enter = cros_typec_port_amode_enter,
+};
diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/chrome/cros_typec_vdm.h
new file mode 100644
index 000000000000..7e282d168a98
--- /dev/null
+++ b/drivers/platform/chrome/cros_typec_vdm.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __CROS_TYPEC_VDM__
+#define __CROS_TYPEC_VDM__
+
+#include <linux/usb/typec_altmode.h>
+
+extern struct typec_altmode_ops port_amode_ops;
+
+#endif /* __CROS_TYPEC_VDM__ */
--
2.39.0.314.g84b9a713c41-goog

2022-12-28 01:42:46

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 10/10] platform/chrome: cros_typec_vdm: Add VDM send support

Add support to send generic VDM messages from the alt mode driver to the
partner (via the ChromeOS EC). The function introduced here is intended
to be called by the alt mode driver (via the Type-C bus logic).

Cc: Heikki Krogerus <[email protected]>
Signed-off-by: Prashant Malani <[email protected]>
---
drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
index fc7b602ceb37..aca9d337118e 100644
--- a/drivers/platform/chrome/cros_typec_vdm.c
+++ b/drivers/platform/chrome/cros_typec_vdm.c
@@ -77,6 +77,30 @@ static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo)
sizeof(req), NULL, 0);
}

+static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
+ const u32 *vdo, int cnt)
+{
+ struct cros_typec_port *port = typec_altmode_get_drvdata(amode);
+ struct ec_params_typec_control req = {
+ .port = port->port_num,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ };
+ struct typec_vdm_req vdm_req = {};
+
+ vdm_req.vdm_data[0] = hdr;
+ vdm_req.vdm_data_objects = cnt;
+ memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
+ vdm_req.partner_type = TYPEC_PARTNER_SOP;
+ req.vdm_req_params = vdm_req;
+
+ dev_dbg(port->typec_data->dev, "Sending VDM, hdr: %x, num_objects: %d, port: %d\n",
+ hdr, cnt, port->port_num);
+
+ return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
+ sizeof(req), NULL, 0);
+}
+
struct typec_altmode_ops port_amode_ops = {
.enter = cros_typec_port_amode_enter,
+ .vdm = cros_typec_port_amode_vdm,
};
--
2.39.0.314.g84b9a713c41-goog

2022-12-28 01:44:36

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens

Change the Type-C module name from cros_ec_typec to cros-ec-typec. This
allows us to include more files in the same module (rather than relying
on the file name cros_ec_typec to also be the module name).

Signed-off-by: Prashant Malani <[email protected]>
---
drivers/platform/chrome/Kconfig | 2 +-
drivers/platform/chrome/Makefile | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index c1ca247987d2..5e420c27662a 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -226,7 +226,7 @@ config CROS_EC_TYPEC
information from the Chrome OS EC.

To compile this driver as a module, choose M here: the module will be
- called cros_ec_typec.
+ called cros-ec-typec.

config CROS_HPS_I2C
tristate "ChromeOS HPS device"
diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
index f6068d077a40..fd29fa74ba33 100644
--- a/drivers/platform/chrome/Makefile
+++ b/drivers/platform/chrome/Makefile
@@ -16,7 +16,8 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o
obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
-obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o
+cros-ec-typec-objs := cros_ec_typec.o
+obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
--
2.39.0.314.g84b9a713c41-goog

2022-12-28 02:29:32

by Prashant Malani

[permalink] [raw]
Subject: [PATCH 05/10] platform/chrome: cros_ec_typec: Update port DP VDO

The port advertising DP support is a Type-C receptacle. Fix the port's
DisplayPort VDO to reflect this.

Fixes: 1903adae0464 ("platform/chrome: cros_ec_typec: Add bit offset for DP VDO")
Signed-off-by: Prashant Malani <[email protected]>
---
drivers/platform/chrome/cros_ec_typec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 05dc5a63af53..665fa76e2416 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -27,7 +27,7 @@
#define DRV_NAME "cros-ec-typec"

#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \
- DP_CAP_DFP_D)
+ DP_CAP_DFP_D | DP_CAP_RECEPTACLE)

/* Supported alt modes. */
enum {
--
2.39.0.314.g84b9a713c41-goog

2023-01-02 11:43:26

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH 00/10] platform/chrome: cros_ec_typec: VDM support

On Wed, Dec 28, 2022 at 12:45:03AM +0000, Prashant Malani wrote:
> This series adds support for sending and receiving USB PD Vendor
> Defined Messages (VDMs) between the Application Processor's Type-C
> ports and connected peripherals.
>
> Thir enables the Application processor to enter alternate modes and
> process VDMs directly, instead of relying on state machines that exist
> inside of co-processors like the ChromeOS Embedded Controller (EC).
>
> Patch 1/10 reverts an incorrect EC header modification.
> Patch 2/10 to 5/10 update headers and existing Type-C structs to
> accommodate the VDM code.
> Patch 6/10 and 7/10 prepare the Type-C driver to have more than 1 file.
> Patch 8/10 to 10/10 introduce the VDM functionality.
>
> Patch submissions suggestion (if approved):
> - Even though Patch 1 touches drivers/mfd, it would be better to take
> the entire series through the cbrome-platform branch, to avoid
> cross-dependencies across maintainer trees.

For the whole series, FWIW:

Acked-by: Heikki Krogerus <[email protected]>

> Prashant Malani (10):
> Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
> platform_chrome: cros_ec: Add Type-C VDM defines
> platform/chrome: cros_ec_typec: Stash port driver info
> platform/chrome: cros_ec_typec: Set port alt mode drvdata
> platform/chrome: cros_ec_typec: Update port DP VDO
> platform/chrome: cros_ec_typec: Move structs to header
> platform/chrome: cros_ec_typec: Alter module name with hyphens
> platform/chrome: cros_ec_typec: Add initial VDM support
> platform/chrome: cros_typec_vdm: Add VDM reply support
> platform/chrome: cros_typec_vdm: Add VDM send support
>
> MAINTAINERS | 3 +-
> drivers/mfd/cros_ec_dev.c | 5 -
> drivers/platform/chrome/Kconfig | 2 +-
> drivers/platform/chrome/Makefile | 3 +-
> drivers/platform/chrome/cros_ec_typec.c | 91 +++------------
> drivers/platform/chrome/cros_ec_typec.h | 85 ++++++++++++++
> drivers/platform/chrome/cros_typec_vdm.c | 106 ++++++++++++++++++
> drivers/platform/chrome/cros_typec_vdm.h | 12 ++
> .../linux/platform_data/cros_ec_commands.h | 53 ++++++++-
> include/linux/platform_data/cros_ec_proto.h | 1 -
> 10 files changed, 276 insertions(+), 85 deletions(-)
> create mode 100644 drivers/platform/chrome/cros_ec_typec.h
> create mode 100644 drivers/platform/chrome/cros_typec_vdm.c
> create mode 100644 drivers/platform/chrome/cros_typec_vdm.h

--
heikki

2023-01-09 19:47:37

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 10/10] platform/chrome: cros_typec_vdm: Add VDM send support

On Wed, Dec 28, 2022 at 12:45:13AM +0000, Prashant Malani wrote:
> Add support to send generic VDM messages from the alt mode driver to the
> partner (via the ChromeOS EC). The function introduced here is intended
> to be called by the alt mode driver (via the Type-C bus logic).
>
> Cc: Heikki Krogerus <[email protected]>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
> index fc7b602ceb37..aca9d337118e 100644
> --- a/drivers/platform/chrome/cros_typec_vdm.c
> +++ b/drivers/platform/chrome/cros_typec_vdm.c
> @@ -77,6 +77,30 @@ static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo)
> sizeof(req), NULL, 0);
> }
>
> +static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
> + const u32 *vdo, int cnt)
> +{
> + struct cros_typec_port *port = typec_altmode_get_drvdata(amode);
> + struct ec_params_typec_control req = {
> + .port = port->port_num,
> + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
> + };
> + struct typec_vdm_req vdm_req = {};
> +
> + vdm_req.vdm_data[0] = hdr;
> + vdm_req.vdm_data_objects = cnt;
> + memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
> + vdm_req.partner_type = TYPEC_PARTNER_SOP;
> + req.vdm_req_params = vdm_req;
> +
> + dev_dbg(port->typec_data->dev, "Sending VDM, hdr: %x, num_objects: %d, port: %d\n",
> + hdr, cnt, port->port_num);
> +
> + return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
> + sizeof(req), NULL, 0);
> +}
> +
> struct typec_altmode_ops port_amode_ops = {
> .enter = cros_typec_port_amode_enter,
> + .vdm = cros_typec_port_amode_vdm,
> };
> --
> 2.39.0.314.g84b9a713c41-goog
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (2.07 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-09 19:54:35

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 06/10] platform/chrome: cros_ec_typec: Move structs to header

On Wed, Dec 28, 2022 at 12:45:09AM +0000, Prashant Malani wrote:
> Move ChromeOS Type-C structs into their own header, so they can be
> referenced by other files which can be added to the same module.
>
> No functional changes introduced by this patch.
>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> MAINTAINERS | 2 +-
> drivers/platform/chrome/cros_ec_typec.c | 78 +----------------------
> drivers/platform/chrome/cros_ec_typec.h | 85 +++++++++++++++++++++++++
> 3 files changed, 88 insertions(+), 77 deletions(-)
> create mode 100644 drivers/platform/chrome/cros_ec_typec.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f61eb221415b..8219b646ab50 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4998,7 +4998,7 @@ CHROMEOS EC USB TYPE-C DRIVER
> M: Prashant Malani <[email protected]>
> L: [email protected]
> S: Maintained
> -F: drivers/platform/chrome/cros_ec_typec.c
> +F: drivers/platform/chrome/cros_ec_typec.*
> F: drivers/platform/chrome/cros_typec_switch.c
>
> CHROMEOS EC USB PD NOTIFY DRIVER
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 665fa76e2416..a4eff590ca56 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -7,96 +7,22 @@
> */
>
> #include <linux/acpi.h>
> -#include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/platform_data/cros_ec_commands.h>
> -#include <linux/platform_data/cros_ec_proto.h>
> #include <linux/platform_data/cros_usbpd_notify.h>
> #include <linux/platform_device.h>
> -#include <linux/usb/pd.h>
> #include <linux/usb/pd_vdo.h>
> -#include <linux/usb/typec.h>
> -#include <linux/usb/typec_altmode.h>
> #include <linux/usb/typec_dp.h>
> -#include <linux/usb/typec_mux.h>
> -#include <linux/usb/typec_retimer.h>
> #include <linux/usb/typec_tbt.h>
> -#include <linux/usb/role.h>
> +
> +#include "cros_ec_typec.h"
>
> #define DRV_NAME "cros-ec-typec"
>
> #define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \
> DP_CAP_DFP_D | DP_CAP_RECEPTACLE)
>
> -/* Supported alt modes. */
> -enum {
> - CROS_EC_ALTMODE_DP = 0,
> - CROS_EC_ALTMODE_TBT,
> - CROS_EC_ALTMODE_MAX,
> -};
> -
> -/* Container for altmode pointer nodes. */
> -struct cros_typec_altmode_node {
> - struct typec_altmode *amode;
> - struct list_head list;
> -};
> -
> -/* Per port data. */
> -struct cros_typec_port {
> - struct typec_port *port;
> - int port_num;
> - /* Initial capabilities for the port. */
> - struct typec_capability caps;
> - struct typec_partner *partner;
> - struct typec_cable *cable;
> - /* SOP' plug. */
> - struct typec_plug *plug;
> - /* Port partner PD identity info. */
> - struct usb_pd_identity p_identity;
> - /* Port cable PD identity info. */
> - struct usb_pd_identity c_identity;
> - struct typec_switch *ori_sw;
> - struct typec_mux *mux;
> - struct typec_retimer *retimer;
> - struct usb_role_switch *role_sw;
> -
> - /* Variables keeping track of switch state. */
> - struct typec_mux_state state;
> - uint8_t mux_flags;
> - uint8_t role;
> -
> - struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX];
> -
> - /* Flag indicating that PD partner discovery data parsing is completed. */
> - bool sop_disc_done;
> - bool sop_prime_disc_done;
> - struct ec_response_typec_discovery *disc_data;
> - struct list_head partner_mode_list;
> - struct list_head plug_mode_list;
> -
> - /* PDO-related structs */
> - struct usb_power_delivery *partner_pd;
> - struct usb_power_delivery_capabilities *partner_src_caps;
> - struct usb_power_delivery_capabilities *partner_sink_caps;
> -
> - struct cros_typec_data *typec_data;
> -};
> -
> -/* Platform-specific data for the Chrome OS EC Type C controller. */
> -struct cros_typec_data {
> - struct device *dev;
> - struct cros_ec_device *ec;
> - int num_ports;
> - unsigned int pd_ctrl_ver;
> - /* Array of ports, indexed by port number. */
> - struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS];
> - struct notifier_block nb;
> - struct work_struct port_work;
> - bool typec_cmd_supported;
> - bool needs_mux_ack;
> -};
> -
> static int cros_typec_parse_port_props(struct typec_capability *cap,
> struct fwnode_handle *fwnode,
> struct device *dev)
> diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h
> new file mode 100644
> index 000000000000..deda180a646f
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_ec_typec.h
> @@ -0,0 +1,85 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __CROS_EC_TYPEC__
> +#define __CROS_EC_TYPEC__
> +
> +#include <linux/list.h>
> +#include <linux/notifier.h>
> +#include <linux/platform_data/cros_ec_proto.h>
> +#include <linux/usb/pd.h>
> +#include <linux/usb/role.h>
> +#include <linux/usb/typec.h>
> +#include <linux/usb/typec_altmode.h>
> +#include <linux/usb/typec_mux.h>
> +#include <linux/usb/typec_retimer.h>
> +#include <linux/workqueue.h>
> +
> +/* Supported alt modes. */
> +enum {
> + CROS_EC_ALTMODE_DP = 0,
> + CROS_EC_ALTMODE_TBT,
> + CROS_EC_ALTMODE_MAX,
> +};
> +
> +/* Container for altmode pointer nodes. */
> +struct cros_typec_altmode_node {
> + struct typec_altmode *amode;
> + struct list_head list;
> +};
> +
> +/* Platform-specific data for the Chrome OS EC Type C controller. */
> +struct cros_typec_data {
> + struct device *dev;
> + struct cros_ec_device *ec;
> + int num_ports;
> + unsigned int pd_ctrl_ver;
> + /* Array of ports, indexed by port number. */
> + struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS];
> + struct notifier_block nb;
> + struct work_struct port_work;
> + bool typec_cmd_supported;
> + bool needs_mux_ack;
> +};
> +
> +/* Per port data. */
> +struct cros_typec_port {
> + struct typec_port *port;
> + int port_num;
> + /* Initial capabilities for the port. */
> + struct typec_capability caps;
> + struct typec_partner *partner;
> + struct typec_cable *cable;
> + /* SOP' plug. */
> + struct typec_plug *plug;
> + /* Port partner PD identity info. */
> + struct usb_pd_identity p_identity;
> + /* Port cable PD identity info. */
> + struct usb_pd_identity c_identity;
> + struct typec_switch *ori_sw;
> + struct typec_mux *mux;
> + struct typec_retimer *retimer;
> + struct usb_role_switch *role_sw;
> +
> + /* Variables keeping track of switch state. */
> + struct typec_mux_state state;
> + uint8_t mux_flags;
> + uint8_t role;
> +
> + struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX];
> +
> + /* Flag indicating that PD partner discovery data parsing is completed. */
> + bool sop_disc_done;
> + bool sop_prime_disc_done;
> + struct ec_response_typec_discovery *disc_data;
> + struct list_head partner_mode_list;
> + struct list_head plug_mode_list;
> +
> + /* PDO-related structs */
> + struct usb_power_delivery *partner_pd;
> + struct usb_power_delivery_capabilities *partner_src_caps;
> + struct usb_power_delivery_capabilities *partner_sink_caps;
> +
> + struct cros_typec_data *typec_data;
> +};
> +
> +#endif /* __CROS_EC_TYPEC__ */
> --
> 2.39.0.314.g84b9a713c41-goog
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (7.40 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-09 20:10:45

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 08/10] platform/chrome: cros_ec_typec: Add initial VDM support

On Wed, Dec 28, 2022 at 12:45:11AM +0000, Prashant Malani wrote:
> Add ops to support USB PD VDM (Vendor Defined Message) from the port
> driver. This enables the port driver to interface with alternate mode
> drivers and communicate with connected peripherals.
>
> The initial support just contains an implementation of the Enter
> Mode command.
>
> Cc: Heikki Krogerus <[email protected]>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> MAINTAINERS | 1 +
> drivers/platform/chrome/Makefile | 2 +-
> drivers/platform/chrome/cros_ec_typec.c | 3 ++
> drivers/platform/chrome/cros_typec_vdm.c | 43 ++++++++++++++++++++++++
> drivers/platform/chrome/cros_typec_vdm.h | 10 ++++++
> 5 files changed, 58 insertions(+), 1 deletion(-)
> create mode 100644 drivers/platform/chrome/cros_typec_vdm.c
> create mode 100644 drivers/platform/chrome/cros_typec_vdm.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8219b646ab50..cfccbbbb083f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5000,6 +5000,7 @@ L: [email protected]
> S: Maintained
> F: drivers/platform/chrome/cros_ec_typec.*
> F: drivers/platform/chrome/cros_typec_switch.c
> +F: drivers/platform/chrome/cros_typec_vdm.*
>
> CHROMEOS EC USB PD NOTIFY DRIVER
> M: Prashant Malani <[email protected]>
> diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
> index fd29fa74ba33..dae0ed3c8656 100644
> --- a/drivers/platform/chrome/Makefile
> +++ b/drivers/platform/chrome/Makefile
> @@ -16,7 +16,7 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o
> obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
> obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
> cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
> -cros-ec-typec-objs := cros_ec_typec.o
> +cros-ec-typec-objs := cros_ec_typec.o cros_typec_vdm.o
> obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
> obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
> obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index a4eff590ca56..1e28d56b094d 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -17,6 +17,7 @@
> #include <linux/usb/typec_tbt.h>
>
> #include "cros_ec_typec.h"
> +#include "cros_typec_vdm.h"
>
> #define DRV_NAME "cros-ec-typec"
>
> @@ -272,6 +273,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,
> return PTR_ERR(amode);
> port->port_altmode[CROS_EC_ALTMODE_DP] = amode;
> typec_altmode_set_drvdata(amode, port);
> + amode->ops = &port_amode_ops;
>
> /*
> * Register TBT compatibility alt mode. The EC will not enter the mode
> @@ -286,6 +288,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,
> return PTR_ERR(amode);
> port->port_altmode[CROS_EC_ALTMODE_TBT] = amode;
> typec_altmode_set_drvdata(amode, port);
> + amode->ops = &port_amode_ops;
>
> port->state.alt = NULL;
> port->state.mode = TYPEC_STATE_USB;
> diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
> new file mode 100644
> index 000000000000..df0102ca3a18
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_typec_vdm.c
> @@ -0,0 +1,43 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * USB Power Delivery Vendor Defined Message (VDM) support code.
> + *
> + * Copyright 2023 Google LLC
> + * Author: Prashant Malani <[email protected]>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/platform_data/cros_ec_commands.h>
> +#include <linux/usb/pd_vdo.h>
> +
> +#include "cros_ec_typec.h"
> +#include "cros_typec_vdm.h"
> +
> +static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo)
> +{
> + struct cros_typec_port *port = typec_altmode_get_drvdata(amode);
> + struct ec_params_typec_control req = {
> + .port = port->port_num,
> + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
> + };
> + struct typec_vdm_req vdm_req = {};
> + u32 hdr;
> +
> + hdr = VDO(amode->svid, 1, SVDM_VER_2_0, CMD_ENTER_MODE);
> + hdr |= VDO_OPOS(amode->mode);
> +
> + vdm_req.vdm_data[0] = hdr;
> + vdm_req.vdm_data_objects = 1;
> + vdm_req.partner_type = TYPEC_PARTNER_SOP;
> + req.vdm_req_params = vdm_req;
> +
> + dev_dbg(port->typec_data->dev, "Sending EnterMode VDM, hdr: %x, port: %d\n",
> + hdr, port->port_num);
> +
> + return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
> + sizeof(req), NULL, 0);
> +}
> +
> +struct typec_altmode_ops port_amode_ops = {
> + .enter = cros_typec_port_amode_enter,
> +};
> diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/chrome/cros_typec_vdm.h
> new file mode 100644
> index 000000000000..7e282d168a98
> --- /dev/null
> +++ b/drivers/platform/chrome/cros_typec_vdm.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __CROS_TYPEC_VDM__
> +#define __CROS_TYPEC_VDM__
> +
> +#include <linux/usb/typec_altmode.h>
> +
> +extern struct typec_altmode_ops port_amode_ops;
> +
> +#endif /* __CROS_TYPEC_VDM__ */
> --
> 2.39.0.314.g84b9a713c41-goog
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (5.44 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-09 20:17:46

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 03/10] platform/chrome: cros_ec_typec: Stash port driver info

On Wed, Dec 28, 2022 at 12:45:06AM +0000, Prashant Malani wrote:
> Stash port number and a pointer to the driver-specific struct in the
> local typec port struct.
>
> These can be useful to the port driver to figure out how to communicate
> with the Chrome EC when an altmode-driver related callback is invoked
> from the Type-C class code.
>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> drivers/platform/chrome/cros_ec_typec.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 001b0de95a46..bc8dc8bd90b3 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -45,6 +45,7 @@ struct cros_typec_altmode_node {
> /* Per port data. */
> struct cros_typec_port {
> struct typec_port *port;
> + int port_num;
> /* Initial capabilities for the port. */
> struct typec_capability caps;
> struct typec_partner *partner;
> @@ -78,6 +79,8 @@ struct cros_typec_port {
> struct usb_power_delivery *partner_pd;
> struct usb_power_delivery_capabilities *partner_src_caps;
> struct usb_power_delivery_capabilities *partner_sink_caps;
> +
> + struct cros_typec_data *typec_data;
> };
>
> /* Platform-specific data for the Chrome OS EC Type C controller. */
> @@ -408,6 +411,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> goto unregister_ports;
> }
>
> + cros_port->port_num = port_num;
> + cros_port->typec_data = typec;
> typec->ports[port_num] = cros_port;
> cap = &cros_port->caps;
>
> --
> 2.39.0.314.g84b9a713c41-goog
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (1.84 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-09 20:45:41

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens

On Wed, Dec 28, 2022 at 12:45:10AM +0000, Prashant Malani wrote:
> Change the Type-C module name from cros_ec_typec to cros-ec-typec. This
> allows us to include more files in the same module (rather than relying
> on the file name cros_ec_typec to also be the module name).
>
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> drivers/platform/chrome/Kconfig | 2 +-
> drivers/platform/chrome/Makefile | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
> index c1ca247987d2..5e420c27662a 100644
> --- a/drivers/platform/chrome/Kconfig
> +++ b/drivers/platform/chrome/Kconfig
> @@ -226,7 +226,7 @@ config CROS_EC_TYPEC
> information from the Chrome OS EC.
>
> To compile this driver as a module, choose M here: the module will be
> - called cros_ec_typec.
> + called cros-ec-typec.
>
> config CROS_HPS_I2C
> tristate "ChromeOS HPS device"
> diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
> index f6068d077a40..fd29fa74ba33 100644
> --- a/drivers/platform/chrome/Makefile
> +++ b/drivers/platform/chrome/Makefile
> @@ -16,7 +16,8 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o
> obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o
> obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
> cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o
> -obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o
> +cros-ec-typec-objs := cros_ec_typec.o
> +obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o
> obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
> obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
> obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
> --
> 2.39.0.314.g84b9a713c41-goog
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (1.96 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-09 20:47:12

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 05/10] platform/chrome: cros_ec_typec: Update port DP VDO

On Wed, Dec 28, 2022 at 12:45:08AM +0000, Prashant Malani wrote:
> The port advertising DP support is a Type-C receptacle. Fix the port's
> DisplayPort VDO to reflect this.
>
> Fixes: 1903adae0464 ("platform/chrome: cros_ec_typec: Add bit offset for DP VDO")
> Signed-off-by: Prashant Malani <[email protected]>

Reviewed-by: Benson Leung <[email protected]>

> ---
> drivers/platform/chrome/cros_ec_typec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 05dc5a63af53..665fa76e2416 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -27,7 +27,7 @@
> #define DRV_NAME "cros-ec-typec"
>
> #define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \
> - DP_CAP_DFP_D)
> + DP_CAP_DFP_D | DP_CAP_RECEPTACLE)
>
> /* Supported alt modes. */
> enum {
> --
> 2.39.0.314.g84b9a713c41-goog
>
>

--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (1.15 kB)
signature.asc (235.00 B)
Download all attachments
Subject: Re: [PATCH 00/10] platform/chrome: cros_ec_typec: VDM support

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci)
by Prashant Malani <[email protected]>:

On Wed, 28 Dec 2022 00:45:03 +0000 you wrote:
> This series adds support for sending and receiving USB PD Vendor
> Defined Messages (VDMs) between the Application Processor's Type-C
> ports and connected peripherals.
>
> Thir enables the Application processor to enter alternate modes and
> process VDMs directly, instead of relying on state machines that exist
> inside of co-processors like the ChromeOS Embedded Controller (EC).
>
> [...]

Here is the summary with links:
- [01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
https://git.kernel.org/chrome-platform/c/0ac7200e3317
- [02/10] platform_chrome: cros_ec: Add Type-C VDM defines
https://git.kernel.org/chrome-platform/c/0e0dba884c43
- [03/10] platform/chrome: cros_ec_typec: Stash port driver info
https://git.kernel.org/chrome-platform/c/4dc9355cef4f
- [04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata
https://git.kernel.org/chrome-platform/c/c856e3ff98bb
- [05/10] platform/chrome: cros_ec_typec: Update port DP VDO
https://git.kernel.org/chrome-platform/c/8d2b28df6c3d
- [06/10] platform/chrome: cros_ec_typec: Move structs to header
https://git.kernel.org/chrome-platform/c/690580965153
- [07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens
https://git.kernel.org/chrome-platform/c/e5eea6a3319f
- [08/10] platform/chrome: cros_ec_typec: Add initial VDM support
https://git.kernel.org/chrome-platform/c/493e699b9934
- [09/10] platform/chrome: cros_typec_vdm: Add VDM reply support
https://git.kernel.org/chrome-platform/c/50ed638bbc47
- [10/10] platform/chrome: cros_typec_vdm: Add VDM send support
https://git.kernel.org/chrome-platform/c/40a9b13a09ef

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


Subject: Re: [PATCH 00/10] platform/chrome: cros_ec_typec: VDM support

Hello:

This series was applied to chrome-platform/linux.git (for-next)
by Prashant Malani <[email protected]>:

On Wed, 28 Dec 2022 00:45:03 +0000 you wrote:
> This series adds support for sending and receiving USB PD Vendor
> Defined Messages (VDMs) between the Application Processor's Type-C
> ports and connected peripherals.
>
> Thir enables the Application processor to enter alternate modes and
> process VDMs directly, instead of relying on state machines that exist
> inside of co-processors like the ChromeOS Embedded Controller (EC).
>
> [...]

Here is the summary with links:
- [01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
https://git.kernel.org/chrome-platform/c/0ac7200e3317
- [02/10] platform_chrome: cros_ec: Add Type-C VDM defines
https://git.kernel.org/chrome-platform/c/0e0dba884c43
- [03/10] platform/chrome: cros_ec_typec: Stash port driver info
https://git.kernel.org/chrome-platform/c/4dc9355cef4f
- [04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata
https://git.kernel.org/chrome-platform/c/c856e3ff98bb
- [05/10] platform/chrome: cros_ec_typec: Update port DP VDO
https://git.kernel.org/chrome-platform/c/8d2b28df6c3d
- [06/10] platform/chrome: cros_ec_typec: Move structs to header
https://git.kernel.org/chrome-platform/c/690580965153
- [07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens
https://git.kernel.org/chrome-platform/c/e5eea6a3319f
- [08/10] platform/chrome: cros_ec_typec: Add initial VDM support
https://git.kernel.org/chrome-platform/c/493e699b9934
- [09/10] platform/chrome: cros_typec_vdm: Add VDM reply support
https://git.kernel.org/chrome-platform/c/50ed638bbc47
- [10/10] platform/chrome: cros_typec_vdm: Add VDM send support
https://git.kernel.org/chrome-platform/c/40a9b13a09ef

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html