platform/chrome: cros_ec_typec: Move structs to header
authorPrashant Malani <pmalani@chromium.org>
Wed, 28 Dec 2022 00:45:09 +0000 (00:45 +0000)
committerPrashant Malani <pmalani@chromium.org>
Mon, 9 Jan 2023 20:32:53 +0000 (20:32 +0000)
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 <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20221228004648.793339-7-pmalani@chromium.org
MAINTAINERS
drivers/platform/chrome/cros_ec_typec.c
drivers/platform/chrome/cros_ec_typec.h [new file with mode: 0644]

index 49b0f0525502f7dcb7dc5be823531ff3d41ee37c..f383b78bceb2fdea208a8825c21d64e2619061f4 100644 (file)
@@ -5005,7 +5005,7 @@ CHROMEOS EC USB TYPE-C DRIVER
 M:     Prashant Malani <pmalani@chromium.org>
 L:     chrome-platform@lists.linux.dev
 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
index 665fa76e241653b58bcc18c10932cce745635e44..a4eff590ca5699f46aa3771c15bf7731d8a7c2e2 100644 (file)
@@ -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 (file)
index 0000000..deda180
--- /dev/null
@@ -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__ */