Skip to content

Commit dfd7b08

Browse files
Andrei Kuchynskigregkh
authored andcommitted
usb: typec: Add mode_control field to port property
This new field in the port properties dictates whether the Platform Policy Manager (PPM) allows the OS Policy Manager (OPM) to change the currently active, negotiated alternate mode. Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Benson Leung <bleung@chromium.org> Link: https://patch.msgid.link/20260119131824.2529334-2-akuchynski@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1360eb4 commit dfd7b08

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/usb/typec/class.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,13 @@ static umode_t typec_altmode_attr_is_visible(struct kobject *kobj,
457457
struct attribute *attr, int n)
458458
{
459459
struct typec_altmode *adev = to_typec_altmode(kobj_to_dev(kobj));
460+
struct typec_port *port = typec_altmode2port(adev);
460461

461462
if (attr == &dev_attr_active.attr)
462-
if (!is_typec_port(adev->dev.parent) &&
463-
(!adev->ops || !adev->ops->activate))
464-
return 0444;
463+
if (!is_typec_port(adev->dev.parent)) {
464+
if (!port->mode_control || !adev->ops || !adev->ops->activate)
465+
return 0444;
466+
}
465467

466468
return attr->mode;
467469
}
@@ -2708,6 +2710,7 @@ struct typec_port *typec_register_port(struct device *parent,
27082710
}
27092711

27102712
port->pd = cap->pd;
2713+
port->mode_control = !cap->no_mode_control;
27112714

27122715
ret = device_add(&port->dev);
27132716
if (ret) {

drivers/usb/typec/class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct typec_port {
6262
struct mutex partner_link_lock;
6363

6464
enum typec_orientation orientation;
65+
bool mode_control;
6566
struct typec_switch *sw;
6667
struct typec_mux *mux;
6768
struct typec_retimer *retimer;

include/linux/usb/typec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ enum usb_pd_svdm_ver {
290290
* @prefer_role: Initial role preference (DRP ports).
291291
* @accessory: Supported Accessory Modes
292292
* @usb_capability: Supported USB Modes
293+
* @no_mode_control: Ability to manage Alternate Modes
293294
* @fwnode: Optional fwnode of the port
294295
* @driver_data: Private pointer for driver specific info
295296
* @pd: Optional USB Power Delivery Support
@@ -307,6 +308,7 @@ struct typec_capability {
307308
enum typec_accessory accessory[TYPEC_MAX_ACCESSORY];
308309
unsigned int orientation_aware:1;
309310
u8 usb_capability;
311+
bool no_mode_control;
310312

311313
struct fwnode_handle *fwnode;
312314
void *driver_data;

0 commit comments

Comments
 (0)