diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/usb/role.h | 3 | ||||
-rw-r--r-- | include/linux/usb/tcpm.h | 41 | ||||
-rw-r--r-- | include/linux/usb/typec.h | 41 |
3 files changed, 26 insertions, 59 deletions
diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index 2d77f97df72d..efac3af83d6b 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -51,6 +51,9 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *node); void usb_role_switch_put(struct usb_role_switch *sw); struct usb_role_switch * +usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode); + +struct usb_role_switch * usb_role_switch_register(struct device *parent, const struct usb_role_switch_desc *desc); void usb_role_switch_unregister(struct usb_role_switch *sw); diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index f516955a0cf4..e7979c01c351 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -46,45 +46,6 @@ enum tcpm_transmit_type { TCPC_TX_BIST_MODE_2 = 7 }; -/** - * struct tcpc_config - Port configuration - * @src_pdo: PDO parameters sent to port partner as response to - * PD_CTRL_GET_SOURCE_CAP message - * @nr_src_pdo: Number of entries in @src_pdo - * @snk_pdo: PDO parameters sent to partner as response to - * PD_CTRL_GET_SINK_CAP message - * @nr_snk_pdo: Number of entries in @snk_pdo - * @operating_snk_mw: - * Required operating sink power in mW - * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or - * TYPEC_PORT_DRP) - * @default_role: - * Default port role (TYPEC_SINK or TYPEC_SOURCE). - * Set to TYPEC_NO_PREFERRED_ROLE if no default role. - * @try_role_hw:True if try.{Src,Snk} is implemented in hardware - * @alt_modes: List of supported alternate modes - */ -struct tcpc_config { - const u32 *src_pdo; - unsigned int nr_src_pdo; - - const u32 *snk_pdo; - unsigned int nr_snk_pdo; - - const u32 *snk_vdo; - unsigned int nr_snk_vdo; - - unsigned int operating_snk_mw; - - enum typec_port_type type; - enum typec_port_data data; - enum typec_role default_role; - bool try_role_hw; /* try.{src,snk} implemented in hardware */ - bool self_powered; /* port belongs to a self powered device */ - - const struct typec_altmode_desc *alt_modes; -}; - /* Mux state attributes */ #define TCPC_MUX_USB_ENABLED BIT(0) /* USB enabled */ #define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ @@ -92,7 +53,6 @@ struct tcpc_config { /** * 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: @@ -121,7 +81,6 @@ struct tcpc_config { * @mux: Pointer to multiplexer data */ struct tcpc_dev { - const struct tcpc_config *config; struct fwnode_handle *fwnode; int (*init)(struct tcpc_dev *dev); diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 7df4ecabc78a..0f52723a11bd 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -168,6 +168,23 @@ struct typec_partner_desc { struct usb_pd_identity *identity; }; +/** + * struct typec_operations - USB Type-C Port Operations + * @try_role: Set data role preference for DRP port + * @dr_set: Set Data Role + * @pr_set: Set Power Role + * @vconn_set: Source VCONN + * @port_type_set: Set port type + */ +struct typec_operations { + int (*try_role)(struct typec_port *port, int role); + int (*dr_set)(struct typec_port *port, enum typec_data_role role); + int (*pr_set)(struct typec_port *port, enum typec_role role); + int (*vconn_set)(struct typec_port *port, enum typec_role role); + int (*port_type_set)(struct typec_port *port, + enum typec_port_type type); +}; + /* * struct typec_capability - USB Type-C Port Capabilities * @type: Supported power role of the port @@ -179,11 +196,8 @@ struct typec_partner_desc { * @sw: Cable plug orientation switch * @mux: Multiplexer switch for Alternate/Accessory Modes * @fwnode: Optional fwnode of the port - * @try_role: Set data role preference for DRP port - * @dr_set: Set Data Role - * @pr_set: Set Power Role - * @vconn_set: Set VCONN Role - * @port_type_set: Set port type + * @driver_data: Private pointer for driver specific info + * @ops: Port operations vector * * Static capabilities of a single USB Type-C port. */ @@ -195,21 +209,10 @@ struct typec_capability { int prefer_role; enum typec_accessory accessory[TYPEC_MAX_ACCESSORY]; - struct typec_switch *sw; - struct typec_mux *mux; struct fwnode_handle *fwnode; + void *driver_data; - int (*try_role)(const struct typec_capability *, - int role); - - int (*dr_set)(const struct typec_capability *, - enum typec_data_role); - int (*pr_set)(const struct typec_capability *, - enum typec_role); - int (*vconn_set)(const struct typec_capability *, - enum typec_role); - int (*port_type_set)(const struct typec_capability *, - enum typec_port_type); + const struct typec_operations *ops; }; /* Specific to try_role(). Indicates the user want's to clear the preference. */ @@ -241,6 +244,8 @@ int typec_set_orientation(struct typec_port *port, enum typec_orientation typec_get_orientation(struct typec_port *port); int typec_set_mode(struct typec_port *port, int mode); +void *typec_get_drvdata(struct typec_port *port); + int typec_find_port_power_role(const char *name); int typec_find_power_role(const char *name); int typec_find_port_data_role(const char *name); |